···11+# Phoenix VCS
22+33+**Regenerative version control that compiles intent to working software.**
44+55+Phoenix takes a specification written in plain language, extracts structured requirements, and generates a working application — database, API, validation, and UI — with full traceability from every line of spec to every line of generated code.
66+77+```
88+spec/todos.md (40 lines) → phoenix bootstrap → working app
99+```
1010+1111+## What it does
1212+1313+Write what you want in a markdown spec:
1414+1515+```markdown
1616+## Tasks
1717+1818+- A task has a title, a priority (urgent, high, normal, low), and an optional due date
1919+- Users can create tasks by providing at least a title
2020+- Users can mark a task as complete or reopen a completed task
2121+- Users can filter tasks by status, project, or priority
2222+- Overdue tasks must be visually highlighted
2323+```
2424+2525+Phoenix compiles this through a pipeline:
2626+2727+```
2828+Spec → Clauses → Canonical Requirements → Implementation Units → Generated Code
2929+```
3030+3131+Each transformation is tracked. Change one line in the spec and Phoenix knows exactly which code needs to regenerate — and which doesn't.
3232+3333+## Quick start
3434+3535+```bash
3636+# Install
3737+git clone https://github.com/chad/phoenix.git
3838+cd phoenix
3939+npm install
4040+npm run build
4141+4242+# Create a project with the sqlite-web-api architecture
4343+mkdir my-app && cd my-app
4444+mkdir spec
4545+4646+# Write your spec
4747+cat > spec/app.md << 'EOF'
4848+# My App
4949+5050+## Items
5151+5252+- An item has a name and a quantity
5353+- Users can create, view, update, and delete items
5454+- Name must not be empty
5555+EOF
5656+5757+# Generate
5858+npx phoenix init --arch=sqlite-web-api
5959+npx phoenix bootstrap
6060+6161+# Run
6262+npm install
6363+npm run dev
6464+# → http://localhost:3000
6565+```
6666+6767+## Architecture targets
6868+6969+Phoenix doesn't just generate code — it compiles to an **architecture**. The architecture target defines the runtime, frameworks, patterns, and conventions. The spec defines *what*, the architecture defines *how*.
7070+7171+The first built-in target is `sqlite-web-api`:
7272+- **HTTP**: [Hono](https://hono.dev)
7373+- **Database**: [better-sqlite3](https://github.com/WiseLibs/better-sqlite3)
7474+- **Validation**: [Zod](https://zod.dev)
7575+- **Pattern**: Route modules with shared DB, migration system, Zod schemas
7676+7777+New architectures can be added by creating a single file in `src/architectures/`. The pipeline doesn't change — only the compilation target.
7878+7979+## The pipeline
8080+8181+```
8282+┌──────────┐ ┌──────────┐ ┌──────────────┐ ┌──────┐ ┌───────────┐
8383+│ Spec │ → │ Clauses │ → │ Canonical │ → │ IUs │ → │ Generated │
8484+│ (markdown)│ │ (parsed) │ │ Requirements │ │ │ │ Code │
8585+└──────────┘ └──────────┘ └──────────────┘ └──────┘ └───────────┘
8686+ │
8787+ ◄──────────── Provenance edges track every transformation ───────┘
8888+```
8989+9090+- **Spec ingestion**: Parses markdown into content-addressed clauses with semantic hashes
9191+- **Canonicalization**: Extracts typed requirements (REQUIREMENT, CONSTRAINT, INVARIANT, DEFINITION, CONTEXT) with confidence scores and relationship edges
9292+- **IU planning**: Groups requirements into Implementation Units with risk tiers, contracts, and boundary policies
9393+- **Code generation**: LLM generates real implementations guided by architecture-specific prompts and few-shot examples, with typecheck-and-retry
9494+- **Selective invalidation**: Change one spec line → only the dependent subtree regenerates
9595+9696+## Visualization
9797+9898+```bash
9999+npx phoenix inspect
100100+```
101101+102102+Opens an interactive pipeline visualizer in your browser. Click the **Spec** tab to see your spec text with hover highlighting — click any line to trace its path through clauses → canonical nodes → IUs → generated files.
103103+104104+## CLI
105105+106106+```bash
107107+phoenix init [--arch=NAME] # Initialize a project
108108+phoenix bootstrap # Full pipeline: ingest → canonicalize → plan → generate
109109+phoenix ingest [--verbose] # Ingest spec changes (shows diff before applying)
110110+phoenix diff # Show clause-level diffs
111111+phoenix canonicalize # Extract canonical requirements
112112+phoenix regen [--iu=ID] # Regenerate code (all or specific IU)
113113+phoenix status # Trust dashboard
114114+phoenix inspect # Interactive pipeline visualization
115115+```
116116+117117+## Examples
118118+119119+### [todo-app](examples/todo-app/)
120120+121121+A Todoist-style task manager generated from a [user-centric spec](examples/todo-app/spec/todos.md). Features:
122122+- Tasks with priorities, due dates, projects, completion tracking
123123+- Projects with colors and active task counts
124124+- Filtering by status, priority, and project
125125+- Stats summary with completion percentage
126126+- Full web UI with sidebar, forms, filters
127127+- REST API for integration with external tools
128128+129129+All generated from ~40 lines of behavioral requirements.
130130+131131+### [phoenix-self](examples/phoenix-self/)
132132+133133+Phoenix specifying itself. The [PRD](PRD.md) decomposed into 6 specs covering ingestion, canonicalization, implementation, integrity, operations, and platform. Used to stress-test the canonicalization pipeline on real-world complexity.
134134+135135+### Other examples
136136+137137+- [settle-up](examples/settle-up/) — Expense splitting with debt simplification
138138+- [pixel-wars](examples/pixel-wars/) — Real-time multiplayer territory game
139139+- [tictactoe](examples/tictactoe/) — Multiplayer game with matchmaking
140140+- [taskflow](examples/taskflow/) — Task management with analytics
141141+142142+## How it works under the hood
143143+144144+### Canonicalization
145145+146146+Every spec sentence is scored against 5 canonical types using a keyword rubric with configurable weights. The resolution engine deduplicates nodes via token Jaccard similarity, infers typed edges (constrains, refines, defines, invariant_of), and builds a hierarchical graph. The pipeline was optimized through 32 automated experiments (autoresearch-style) across 18 gold-standard specs.
147147+148148+### Code generation
149149+150150+The LLM receives a structured prompt with:
151151+1. Canonical requirements, constraints, invariants, and definitions for the IU
152152+2. Architecture-specific system prompt (import rules, patterns, conventions)
153153+3. Few-shot code examples showing the exact patterns to follow
154154+4. Related context from other spec sections
155155+5. Sibling module mount paths (so the web UI knows where the API lives)
156156+157157+If generation fails or doesn't typecheck, the system retries with error feedback. If that fails, it falls back to architecture-aware stubs that still produce valid, mountable modules.
158158+159159+### Drift detection
160160+161161+Phoenix tracks a manifest of every generated file's content hash. `phoenix status` compares the working tree against the manifest and flags any unlabeled manual edits. This is how Phoenix knows if you've modified generated code and need to either promote the change to a spec requirement or add a waiver.
162162+163163+## Status
164164+165165+Alpha. The core pipeline works end-to-end — spec to working app with full traceability. The `sqlite-web-api` architecture target generates functional CRUD APIs with web UIs from behavioral specs.
166166+167167+What's next:
168168+- More architecture targets (Express + Postgres, Cloudflare Workers + D1, CLI apps)
169169+- Smarter IU planner (merge cross-cutting concerns into parent resources)
170170+- Selective regeneration from spec edits (the pipeline supports it, the UX needs work)
171171+- Test generation and evidence collection
172172+- Multi-file spec projects with cross-references
173173+174174+## License
175175+176176+MIT