Skip to content

Commit d022f1d

Browse files
committed
refactor: we fully effect now
also dogfooding pg-sourcerer
1 parent d49c175 commit d022f1d

152 files changed

Lines changed: 13268 additions & 9802 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/settings.local.json

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,53 @@
4848
"mcp__firefox-devtools__resolve_uid_to_selector",
4949
"mcp__firefox-devtools__take_snapshot",
5050
"mcp__plugin_context7_context7__query-docs",
51-
"mcp__plugin_context7_context7__resolve-library-id"
51+
"mcp__plugin_context7_context7__resolve-library-id",
52+
"Bash(prog context:*)",
53+
"WebFetch(domain:raw.githubusercontent.com)",
54+
"Bash(bun run test:unit:*)",
55+
"WebFetch(domain:bun.com)",
56+
"Bash(gh repo view:*)",
57+
"WebFetch(domain:effect.website)",
58+
"WebFetch(domain:effect-ts.github.io)",
59+
"WebFetch(domain:www.effect.solutions)",
60+
"WebFetch(domain:github.com)",
61+
"Bash(bun effect-solutions:*)",
62+
"Bash(npx effect-solutions:*)",
63+
"WebFetch(domain:elysiajs.com)",
64+
"mcp__plugin_compound-engineering_context7__resolve-library-id",
65+
"mcp__plugin_compound-engineering_context7__query-docs",
66+
"Bash(__NEW_LINE_3f3e368681926904__ prog add \"Migrate server/metrics.ts to Effect Metric\" -p pg.garden -d \"Replace raw @opentelemetry/sdk-metrics with Effect''s built-in Metric module.:*)",
67+
"Bash(__NEW_LINE_3f3e368681926904__ prog add \"Migrate server/otel-logger.ts to Effect.log\" -p pg.garden -d \"Replace raw @opentelemetry/sdk-logs with Effect''s structured logging.:*)",
68+
"Bash(__NEW_LINE_3f3e368681926904__ prog add \"Extract remaining auth/webhook route handlers to Effect.fn\" -p pg.garden -d \"After the proof of concept with auth.register, migrate the remaining manual-span handlers.:*)",
69+
"Bash(__NEW_LINE_3f3e368681926904__ prog add \"Browser: WebSdk.layer replaces raw WebTracerProvider\" -p pg.garden -d \"Replace src/telemetry.ts raw OTel with Effect WebSdk.layer.:*)",
70+
"mcp__effect-devtui__list_clients",
71+
"mcp__effect-devtui__get_active_spans",
72+
"mcp__effect-devtui__list_spans",
73+
"mcp__effect-devtui__get_span_tree",
74+
"mcp__effect-devtui__get_span",
75+
"mcp__effect-devtui__get_metrics",
76+
"mcp__chrome-devtools__take_snapshot",
77+
"mcp__chrome-devtools__evaluate_script",
78+
"mcp__chrome-devtools__list_console_messages",
79+
"mcp__chrome-devtools__list_network_requests",
80+
"mcp__chrome-devtools__get_console_message",
81+
"Bash(head:*)",
82+
"Bash(effect-solutions list:*)",
83+
"Bash(done)",
84+
"Bash(effect-solutions show:*)",
85+
"Bash(bun vitest:*)",
86+
"mcp__chrome-devtools__get_network_request",
87+
"mcp__chrome-devtools__navigate_page",
88+
"WebFetch(domain:api.github.com)",
89+
"WebFetch(domain:code.visualstudio.com)",
90+
"WebFetch(domain:dfg.codes)",
91+
"WebFetch(domain:tanstack.com)",
92+
"WebFetch(domain:frontendmasters.com)",
93+
"WebFetch(domain:pglite.dev)",
94+
"mcp__effect-devtui__get_span_stats",
95+
"Bash(jj diff:*)"
5296
]
5397
},
98+
"spinnerTipsEnabled": false,
5499
"prefersReducedMotion": true
55100
}

.gmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
{
8888
"_": "command",
8989
"shadow": false,
90-
"command": "bun db:types --url $GM_DBURL"
90+
"command": "bun db:types --url $GM_DBURL && bun sourcerer"
9191
}
9292
],
9393

.kysely-codegenrc.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"dialect": "postgres",
3+
"excludePattern": "graphile*.*",
4+
"outFile": "./generated/db.ts",
5+
"typeMapping": {
6+
"int8": "bigint"
7+
}
8+
}

CLAUDE.md

Lines changed: 25 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,65 +3,45 @@
33
## Tooling
44

55
- **Runtime**: Bun — always use `bun` instead of `npx`/`node`
6-
- **Lint**: Run `bun lint` after making changes. Fix errors before moving on.
7-
- **Typecheck**: Run `bun typecheck` after making changes. Zero errors policy.
8-
- **Dev server**: `bun run dev` (port 3000, Vite SSR)
9-
- **Build**: `bun run build` then `bun run start`
10-
- **Renderer**: Don't manually run `build:renderer` — it runs in watch mode alongside dev
6+
- **Dev server**: `bun run dev` (port 3000, Vite SSR, assume it is running, ask user to run it if down)
7+
- **Renderer**: Don't manually run `build:renderer` — it runs in watch mode alongside dev
8+
- **Webviews**: Don't manually run `build:webview` — it runs in watch mode alongside dev
9+
- **Production Build**: `bun run build && bun start` runs on port 3000
1110

12-
## Architecture
11+
## Debugging
1312

14-
Full VSCode workbench in the browser via `@codingame/monaco-vscode-api`. Not a simple Monaco demo — it has the complete extension API, multi-process workers, virtual filesystem (IndexedDB + memory overlays), and 300+ VSCode service packages.
13+
- **Lint**: Run `bun lint` after making changes. Fix errors before moving on.
14+
- **Typecheck**: Run `bun typecheck` after making changes. Zero errors policy.
15+
- **Smoke test**: After significant changes, use any available browser MCP to open `http://localhost:3000` and check console messages for errors.
16+
- `effect-devtui` mcp should be available to capture observability data from Effect apps
1517

1618
### Server (`server/`)
1719

18-
Bun + Elysia backend. SSR injects data via `window.__INITIAL_DATA__`.
19-
20-
- `index.ts` — entry, routes dev/prod
21-
- `app.ts` — API routes (Elysia + TypeBox validation)
22-
- `db.ts` — Kysely DB connections + `withAuthContext()` for RLS
20+
Bun + Effect Platform backend. Look at `server/httpapi/` for routes and `server/layers/` for service layers. SSR uses Effect HttpApi contracts. Kysely for DB queries with `withAuthContext()` for RLS.
2321

2422
### Client (`src/`)
2523

26-
- `entry.ts``loader.ts` — boot sequence
27-
- `setup.common.ts` / `setup.workbench.ts` — VSCode service overrides
28-
- `features/` — feature modules (auth, debugger, notebook, playground, serverSync, etc.)
29-
- `features/notebook/renderer/` — Preact notebook renderer (Shadow DOM, Vite lib mode)
30-
31-
### Notebook Renderer
32-
33-
- Built via `vite.renderer.config.ts` (lib mode, `inlineDynamicImports`)
34-
- CSS inlined into JS via custom `inlineCssPlugin` — captures CSS in `generateBundle`, replaces a unique placeholder in the JS entry
35-
- pev2 vendored at `src/features/notebook/renderer/pev2/`
36-
- Output: `src/features/notebook/renderer-dist/`
37-
38-
## Database Patterns
39-
40-
- Use Kysely query builder for all SQL (never raw SQL except for Postgres function calls with named args)
41-
- Wrap user-data queries in `withAuthContext(session.id, async (tx) => ...)`
42-
- TypeBox validation schemas on all route params, body, query
43-
- Never `body as any`, `Number(params.id)`, or `new Response(JSON.stringify())`
24+
Boot sequence starts at `src/entry.ts``src/loader.ts`. VSCode service overrides in `src/setup.*.ts`. Feature modules live in `src/features/` — each is an Effect Layer (auth, notebook, playground, serverSync, pglite, etc.).
4425

4526
## Code Quality Rules
4627

47-
- Keep TypeScript strict — no `any` leaks. Use `unknown` and narrow.
48-
- Use Effect Schema (`import * as S from "effect/Schema"`) for runtime JSON validation
49-
- Annotate `JSON.parse()` results as `unknown` or validate with a schema
50-
- Catch blocks: use bare `catch {}` if error unused, or `catch (err)` with `err instanceof Error ? err.message : String(err)`
51-
- Don't leave floating promises — use `void` or `await`
52-
- Don't leave `async` on functions that don't `await` — use `Promise.resolve()` if the interface requires it
53-
- Eden API error objects need `JSON.stringify(error.value)` in template literals
54-
- `registerExtension` destructuring needs `// eslint-disable-next-line @typescript-eslint/unbound-method`
28+
- Use Effect for all code — services, layers, error handling
29+
- All error handling should be handled through Effect so runtime errors can be traced through the type system
30+
- Use Effect Schema (`import * as S from "effect/Schema"`) for runtime any and all runtime validation
31+
- Never `JSON.parse(input)` use `S.parseJson(schema)(input)`
32+
- Use Kysely query builder for DB queries (never raw SQL except for Postgres function calls with named args)
33+
- Effect information can be found in through `effect-solutions` cli and from reading `~/.local/share/effect-solutions/effect`
34+
- You can and should immediately refactor any non-Effect code to use best practices
5535

5636
## Task Tracking
5737

58-
This project uses **prog** for cross-session task management. **Do NOT use internal TodoWrite/TaskCreate/TaskUpdate tools** — use `prog` for all task tracking.
59-
Run `prog prime` for workflow context, or configure hooks for auto-injection.
38+
This project uses **prog** for cross-session task management. **Do NOT use internal planning tools** — use `prog` for all task tracking.
39+
Run `prog prime` for workflow context
6040

6141
**Quick reference:**
6242

6343
```
64-
prog ready # Find unblocked work
44+
prog ready -p pg.garden # Find unblocked work
6545
prog add "Title" -p pg.garden # Create task
6646
prog start <id> # Claim work
6747
prog log <id> "msg" # Log progress
@@ -71,3 +51,7 @@ prog done <id> # Complete work
7151
MUST use `-p pg.garden` for all commands that dont have an <id>
7252

7353
For full workflow: `prog prime`
54+
55+
## Landing the plane
56+
57+
When you believe changes are complete, mark the current `prog` task as done and prompt the user with a commit message to describe changes.

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ COPY package.json bun.lock ./
66
RUN bun install --frozen-lockfile
77

88
COPY . .
9+
10+
# Vite inlines VITE_* env vars at build time; .env is dockerignored so pass via build arg
11+
ARG VITE_OTEL_COLLECTOR_URL
12+
ENV VITE_OTEL_COLLECTOR_URL=$VITE_OTEL_COLLECTOR_URL
13+
914
RUN bun run build
1015

1116
# Stage 2: Production runtime

0 commit comments

Comments
 (0)