-
Notifications
You must be signed in to change notification settings - Fork 4
Add CLAUDE.md with architecture guide and dev commands #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,121 @@ | ||||||||||||||||||||||
| # CLAUDE.md | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ## Commands | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||
| # Development (starts all 3 processes: Vite :5001, Express :5000, Python :8001) | ||||||||||||||||||||||
| scripts/start-dev.sh | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Production build (Vite → dist/public/, esbuild → dist/index.cjs) | ||||||||||||||||||||||
| npm run build | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # TypeScript type checking | ||||||||||||||||||||||
| npm run check | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Push Drizzle schema to PostgreSQL | ||||||||||||||||||||||
| npm run db:push | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Re-stamp all files with N:M ratio annotation (required after edits) | ||||||||||||||||||||||
| python scripts/annotate.py | ||||||||||||||||||||||
| ``` | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ### Tests | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||
| # Install Playwright browser (first time) | ||||||||||||||||||||||
| npx playwright install chromium | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Run all e2e tests (requires dev server on :5000) | ||||||||||||||||||||||
| npx playwright test | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Run a single test file | ||||||||||||||||||||||
| npx playwright test tests/e2e/console-tabs.spec.ts | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Console-tab regression guard (static preflight, no browser needed) | ||||||||||||||||||||||
| node scripts/check-console-tabs.mjs | ||||||||||||||||||||||
| ``` | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ## Architecture | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| This is a 3-process autonomous AI agent platform with a metadata-driven console UI. | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ### Process Topology | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ``` | ||||||||||||||||||||||
| Browser → Express (:5000) → [proxy /api/*] → Python/FastAPI (:8001, internal only) | ||||||||||||||||||||||
| ↘ [dev] Vite (:5001) | ||||||||||||||||||||||
| ``` | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - **Express** (`server/`) — Auth, sessions, guest-chat rate limiting, static serving. Adds `x-a0p-internal: <INTERNAL_API_SECRET>` and user identity headers (`x-user-id`, `x-user-email`, `x-user-role`) to every proxied request. Never expose Python port directly. | ||||||||||||||||||||||
| - **Python/FastAPI** (`python/`) — All AI orchestration, PCNA engine, agent lifecycle, billing, heartbeat scheduler. Validates `x-a0p-internal` on every request. | ||||||||||||||||||||||
| - **Vite** — Dev only; proxied by Express. | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ### Frontend (Metadata-Driven Console) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| `client/src/hooks/use-ui-structure.ts` polls `GET /api/v1/ui/structure`, which aggregates `UI_META` from every Python route module. The console (`client/src/pages/console.tsx`) renders tabs from this structure: | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - Tabs listed in `CUSTOM_TAB_RENDERERS` → custom React component | ||||||||||||||||||||||
| - All other tabs → generic `TabRenderer` (schema-driven via `DATA_SCHEMA`) | ||||||||||||||||||||||
|
Comment on lines
+57
to
+60
|
||||||||||||||||||||||
| `client/src/hooks/use-ui-structure.ts` polls `GET /api/v1/ui/structure`, which aggregates `UI_META` from every Python route module. The console (`client/src/pages/console.tsx`) renders tabs from this structure: | |
| - Tabs listed in `CUSTOM_TAB_RENDERERS` → custom React component | |
| - All other tabs → generic `TabRenderer` (schema-driven via `DATA_SCHEMA`) | |
| `client/src/hooks/use-ui-structure.ts` polls `GET /api/v1/ui/structure`, which returns tab structure assembled from module `UI_META` (including WS module UI metadata). The console (`client/src/pages/console.tsx`) renders tabs from this structure: | |
| - Tabs listed in `CUSTOM_TAB_RENDERERS` → custom React component | |
| - All other tabs → generic `TabRenderer` driven by `tab.sections` from `UI_META.sections` |
Copilot
AI
Apr 22, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This claims each python/routes/* file defines UI_META/DATA_SCHEMA and that adding a new route requires 4 edits to python/routes/__init__.py. However, there are registered routes like founders.py, admin.py, and guest.py that do not define UI_META/DATA_SCHEMA, and they are not included in the collect_ui_meta()/collect_doc_meta() lists. Please clarify that the extra registration steps apply only to routes that should appear in the console UI and/or docs aggregation.
| Each route file in `python/routes/` is self-declaring: it exports a FastAPI `router` and defines `UI_META`/`DATA_SCHEMA` at the top. **Adding a new route requires 4 edits to `python/routes/__init__.py`**: | |
| 1. Import the router | |
| 2. Add to `ALL_ROUTERS` | |
| Each route file in `python/routes/` exports a FastAPI `router`. Routes that should appear in the metadata-driven console UI and/or docs aggregation are additionally self-declaring: they define `UI_META`/`DATA_SCHEMA` at the top and are included in the metadata collectors in `python/routes/__init__.py`. | |
| **Adding a new route always requires 2 router-registration edits to `python/routes/__init__.py`**: | |
| 1. Import the router | |
| 2. Add to `ALL_ROUTERS` | |
| **If the route should also appear in the console UI and/or aggregated docs, make 2 additional metadata-registration edits**: |
Copilot
AI
Apr 22, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The heartbeat description implies a 30-second tick that performs specific work like sub-agent cleanup. In python/services/heartbeat.py, the tick interval is 30s, but individual tasks run on longer per-task intervals (e.g., propagate 120s, snapshot 600s, audit 300s, conversation review 21600s), and there’s no explicit “sub-agent cleanup” task listed. Consider updating this bullet to match the actual scheduled tasks/intervals.
| - `python/services/heartbeat.py` — 30-second tick: audit snapshots, memory checkpoints, PCNA propagation, sub-agent cleanup | |
| - `python/services/heartbeat.py` — 30-second scheduler tick that runs maintenance tasks on their own intervals, including PCNA propagation, snapshots/checkpoints, audits, and conversation review |
Copilot
AI
Apr 22, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tier list here ("Free → Seeker → Operator → Patron → Founder Lifetime") doesn’t match the tiers used in the current codebase (free, supporter, ws, admin), and python/routes/founders.py is marked as retired after tier simplification. Please update this section to reflect the actual tier names and how they’re assigned (Stripe sets supporter; ws may be auto-promoted for specific email domains; admin is role/email based).
| Auth is handled entirely by Express. Tiers (Free → Seeker → Operator → Patron → Founder Lifetime) are stored on the user record, updated via Stripe webhook (`python/routes/billing.py`), and injected into the LLM system prompt as `prompt_context`. | |
| Auth is handled entirely by Express. The current user tiers are `free`, `supporter`, `ws`, and `admin`, stored on the user record and injected into the LLM system prompt as `prompt_context`. Stripe billing/webhooks set `supporter` (`python/routes/billing.py`); `ws` may be auto-promoted for specific email domains; and `admin` is assigned via role/email-based checks. |
Copilot
AI
Apr 22, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The “Required in production” env var list looks inaccurate/incomplete: the app uses multiple provider keys (e.g., OPENAI_API_KEY, GEMINI_API_KEY, ANTHROPIC_API_KEY, XAI_API_KEY) depending on which energy providers you enable, and Stripe keys are only needed if billing is enabled. Also, ADMIN_USER_ID is declared in python/routes/contexts.py but not used for authorization (admin access is checked via role/email/admin_emails), while ADMIN_EMAIL is used but not listed here. Please update the list and indicate which variables are truly required vs optional/feature-gated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The doc says FastAPI "validates
x-a0p-internalon every request", butpython/main.pyexplicitly exempts/api/healthand/api/v1/guest/chatvia_OPEN_PATHS. Please document these exceptions (or soften the wording) so readers don’t assume all routes require the header.