Skip to content

Commit 8d1f64c

Browse files
lucbrinkmanclaude
andcommitted
Merge main into rename-json-node-types
Resolved conflicts: - Applied Prettier formatting from main - Preserved type renaming changes (descriptive names vs single letters) - Integrated ESLint config, CI workflow, and pre-commit hooks from main 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
2 parents 2801e10 + 951c6ba commit 8d1f64c

File tree

13 files changed

+2333
-1029
lines changed

13 files changed

+2333
-1029
lines changed

.eslintrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": ["next/core-web-vitals", "prettier"]
3+
}

.github/workflows/ci.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: ['**']
6+
pull_request:
7+
branches: ['**']
8+
9+
jobs:
10+
quality-checks:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: '20'
21+
cache: 'npm'
22+
23+
- name: Install dependencies
24+
run: npm ci
25+
26+
- name: Type check
27+
run: npm run type-check
28+
29+
- name: Lint
30+
run: npm run lint
31+
32+
- name: Build
33+
run: npm run build

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx lint-staged

.prettierignore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Dependencies
2+
node_modules
3+
4+
# Build output
5+
.next
6+
out
7+
build
8+
dist
9+
10+
# Cache
11+
.turbo
12+
.cache
13+
14+
# Environment variables
15+
.env
16+
.env.local
17+
.env.production.local
18+
.env.development.local
19+
20+
# Logs
21+
*.log
22+
23+
# OS files
24+
.DS_Store
25+
26+
# Lock files
27+
package-lock.json
28+
yarn.lock
29+
pnpm-lock.yaml
30+
31+
# Git
32+
.git
33+
.husky

.prettierrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"semi": true,
3+
"trailingComma": "es5",
4+
"singleQuote": false,
5+
"printWidth": 80,
6+
"tabWidth": 2,
7+
"useTabs": false,
8+
"arrowParens": "always",
9+
"endOfLine": "lf"
10+
}

CLAUDE.md

Lines changed: 56 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
77
Next.js application called "Map of AI Futures" - an interactive probability flowchart visualizing potential AI future scenarios. Users adjust probability sliders to explore how different decisions affect outcome likelihoods.
88

99
**Key Features:**
10+
1011
- Interactive probability sliders with real-time DAG-based calculations
1112
- Zoom and pan canvas navigation
1213
- Supabase authentication (passwordless magic link)
@@ -16,11 +17,20 @@ Next.js application called "Map of AI Futures" - an interactive probability flow
1617
## Development
1718

1819
**Commands:**
20+
1921
- `npm run dev` - Start dev server (http://localhost:3000)
2022
- `npm run build` - Build for production
2123
- `npm run lint` - Run ESLint
2224

25+
**Process Management:**
26+
27+
- **To stop a dev server cleanly:** `fuser -k <port>/tcp` (e.g., `fuser -k 3000/tcp`)
28+
- This kills all processes using that port, including orphaned child processes
29+
- More reliable than KillShell which can leave next-server processes running
30+
- Prevents accumulation of zombie processes that consume CPU/memory
31+
2332
**Environment Variables:**
33+
2434
- `NEXT_PUBLIC_SUPABASE_URL`
2535
- `NEXT_PUBLIC_SUPABASE_ANON_KEY`
2636
- `SUPABASE_SERVICE_ROLE_KEY` (server-side only)
@@ -32,63 +42,79 @@ Next.js application called "Map of AI Futures" - an interactive probability flow
3242
**Important:** This repository uses **multiple worktrees** - the user may be working in different directories on different branches simultaneously.
3343

3444
**Worktree Safety Rule:**
45+
3546
- **NEVER** make edits to files in any worktree other than the one Claude Code was started in
3647
- Only read from, write to, and execute commands within the current working directory
3748
- If the user needs changes in a different worktree, they will navigate there and start a new session
3849

3950
**Development Model:**
40-
- Solo developer project - no GitHub PRs or code review process
41-
- Merge feature branches to main locally, then push to GitHub
42-
- Direct push workflow: test locally → merge to main → push
4351

44-
**Branch Merging Protocol:**
45-
**IMPORTANT:** Only merge to main when the user explicitly says it's time to merge. Do not automatically merge or test for merging during development - features may need multiple iterations before being ready.
52+
- Solo developer project using GitHub Pull Request workflow
53+
- All changes go through PRs with automated CI checks
54+
- Work on feature branches → push to GitHub → create PR → merge via GitHub UI
55+
- **NEVER merge to main locally**
56+
- **NEVER push main branch directly**
4657

47-
When the user says to merge a feature branch to main, ALWAYS follow this sequence:
58+
**Pull Request Workflow:**
59+
60+
1. **Create and push feature branch:**
4861

49-
1. **First, update the feature branch with main:**
5062
```bash
51-
git checkout feature-branch
52-
git merge main
53-
# Resolve any conflicts HERE on the feature branch, never on main
63+
git checkout -b feature-branch
64+
# Make your changes and commit
65+
git push origin feature-branch
5466
```
5567

56-
2. **Test after merging:**
57-
- Clear the Next.js cache: `rm -rf .next`
58-
- Start dev server: `npm run dev`
59-
- Verify it runs without errors before proceeding
68+
2. **Create Pull Request:**
69+
- Use GitHub UI or `gh pr create --repo lucbrinkman/ai-world-model` command
70+
- **IMPORTANT:** Always create PRs to `lucbrinkman/ai-world-model` (NOT the upstream fork `swantescholz/aifutures`)
71+
- CI automatically runs type-check, lint, and build
72+
- PR cannot be merged until all CI checks pass
6073

61-
3. **Only then, merge to main using fast-forward only:**
62-
```bash
63-
git checkout main
64-
git merge --ff-only feature-branch
65-
# If this fails, return to step 1 - there are unresolved issues
66-
git push origin main
67-
```
74+
3. **Merge via GitHub:**
75+
- Once CI passes and changes are ready, merge via GitHub PR interface
76+
- Delete feature branch after merging (can be done automatically)
77+
- Pull latest main locally: `git checkout main && git pull origin main`
78+
79+
**CI/CD Pipeline:**
80+
81+
- GitHub Actions workflow runs on all pushes and PRs (`.github/workflows/ci.yml`)
82+
- Checks: TypeScript type-check, ESLint, Next.js build
83+
- PRs blocked from merging if CI fails
84+
- Local pre-commit hooks run same checks (via Husky) to catch issues early
85+
86+
**Branch Protection (configure in GitHub settings):**
87+
88+
- Require PR reviews before merging (optional for solo dev)
89+
- Require status checks to pass (CI workflow)
90+
- Require branches to be up to date before merging
6891

6992
**Key Rules:**
70-
- NEVER merge to main unless the user explicitly says to merge
71-
- NEVER resolve merge conflicts while on `main` branch
72-
- ALWAYS use `--ff-only` when merging into main (ensures clean, conflict-free merge)
73-
- ALWAYS test the dev server after merging but before pushing
74-
- If user says "merge to main", first update feature branch with main, then merge to main
93+
94+
- NEVER merge to main locally - always use GitHub PRs
95+
- NEVER push main branch directly - only push feature branches
96+
- Let CI validate all changes before merging
97+
- If CI fails, fix issues and push updates to the PR branch
7598

7699
## Architecture
77100

78101
### Core System
79102

80103
**Probability Engine:**
104+
81105
- **DAG Structure** (`lib/graphData.ts`, `graphData.json`): Nodes (question/start/outcome types) and edges with conditional probabilities
82106
- **Calculation** (`lib/probability.ts`): Recursive probability propagation with memoization. Question nodes (21 total) use slider values to control YES/NO branch probabilities
83107
- **URL State** (`lib/urlState.ts`): Slider values encoded as `?p=50i70i25i...` (integers separated by 'i')
84108

85109
**Unified Document Storage:**
110+
86111
- Single `documents` table replaces old `saved_scenarios` and `user_graphs` tables
87112
- Each document contains: graph nodes, slider values, metadata (all in one JSONB field)
88113
- Auto-save with 2-second debounce for authenticated users
89114
- localStorage fallback for anonymous users with auto-migration on signup
90115

91116
**Authentication:**
117+
92118
- Supabase passwordless magic link (`lib/supabase/`)
93119
- Server actions in `lib/actions/documents.ts`
94120
- Custom `useAuth` hook (`hooks/useAuth.ts`) with localStorage migration logic
@@ -107,23 +133,27 @@ When the user says to merge a feature branch to main, ALWAYS follow this sequenc
107133
### Important Implementation Details
108134

109135
**Node Interaction:**
136+
110137
- Clicking a node sets it as probability root (recalculates all probabilities from that point)
111138
- Clicking same node again resets to start node
112139
- Slider hover highlights corresponding flowchart node
113140

114141
**Edge Rendering:**
142+
115143
- Uses refs to track actual DOM node bounds for accurate arrow positioning
116144
- Adjusts for zoom scale when calculating edge paths
117145
- Adaptive opacity/width based on probability values
118146

119147
**State Management:**
148+
120149
- Auto-save hook (`lib/autoSave.ts`) with 2-second debounce for cloud saves
121150
- localStorage (`lib/documentState.ts`) for anonymous user drafts
122151
- Document state unified: graph structure, slider values, node positions all in one
123152
- `useMemo` for probability calculations to prevent unnecessary recomputation
124153
- Undo stack tracks slider history
125154

126155
**Storage Flow:**
156+
127157
- **Anonymous users**: Changes save instantly to localStorage
128158
- **Authenticated users**: Changes auto-save to cloud (debounced)
129159
- **On signup**: localStorage draft automatically migrates to cloud as "My First Map"

app/auth/auth-code-error/page.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import Link from "next/link";
2+
13
export default function AuthCodeError() {
24
return (
35
<div className="min-h-screen flex items-center justify-center bg-gray-50">
@@ -22,16 +24,17 @@ export default function AuthCodeError() {
2224
Authentication Error
2325
</h1>
2426
<p className="text-gray-600 mb-6">
25-
There was a problem confirming your email. The link may have expired or already been used.
27+
There was a problem confirming your email. The link may have expired
28+
or already been used.
2629
</p>
27-
<a
30+
<Link
2831
href="/"
2932
className="inline-block bg-purple-600 text-white px-6 py-2 rounded-md hover:bg-purple-700"
3033
>
3134
Return to Home
32-
</a>
35+
</Link>
3336
</div>
3437
</div>
3538
</div>
36-
)
39+
);
3740
}

0 commit comments

Comments
 (0)