|
| 1 | +# CodeFRAME v2 — Golden Path Contract (CLI-first) |
| 2 | + |
| 3 | +This document is the contract for CodeFRAME v2 development. |
| 4 | + |
| 5 | +**Rule 0 (the only rule that matters):** |
| 6 | +> If a change does not directly support the Golden Path flow below, do not implement it. |
| 7 | +
|
| 8 | +This applies to both humans and agentic coding assistants. |
| 9 | + |
| 10 | +--- |
| 11 | + |
| 12 | +## Goals |
| 13 | + |
| 14 | +### What “done” looks like (MVP definition) |
| 15 | +CodeFRAME can run a complete end-to-end workflow **from the CLI** on a small repo: |
| 16 | + |
| 17 | +1) Initialize a workspace for a target repo |
| 18 | +2) Add a PRD |
| 19 | +3) Generate tasks |
| 20 | +4) Execute one task via agents |
| 21 | +5) Handle blockers (human-in-loop) |
| 22 | +6) Produce a patch/commit and run gates (tests/lint) |
| 23 | +7) Summarize results and checkpoint the state |
| 24 | + |
| 25 | +**No UI is required.** |
| 26 | +**A FastAPI server is not required for the Golden Path to work.** |
| 27 | + |
| 28 | +--- |
| 29 | + |
| 30 | +## Non-Goals (explicitly forbidden until Golden Path works) |
| 31 | + |
| 32 | +Do not build or refactor: |
| 33 | +- Web UI / dashboard features |
| 34 | +- Settings pages, preferences, themes |
| 35 | +- Multi-provider/model switching UI or complex provider management |
| 36 | +- Advanced metrics dashboards or timeseries endpoints |
| 37 | +- Auth / sessions for remote users |
| 38 | +- Electron desktop app |
| 39 | +- Plugin marketplace / extensibility frameworks |
| 40 | +- “Perfect” project structure, monorepo tooling, or build system redesign |
| 41 | +- Large migrations or renames that aren’t required by Golden Path |
| 42 | + |
| 43 | +These may be revisited **only after** Golden Path is working and stable. |
| 44 | + |
| 45 | +--- |
| 46 | + |
| 47 | +## Golden Path CLI Flow (the only flow that matters) |
| 48 | + |
| 49 | +### 0) Preconditions |
| 50 | +- A target repo exists (any small test repo is fine). |
| 51 | +- CodeFRAME runs locally and can store durable state (SQLite or filesystem). |
| 52 | +- The CLI can be run from anywhere. |
| 53 | + |
| 54 | +### 1) Initialize a workspace |
| 55 | +Command: |
| 56 | +- `codeframe init <path-to-repo>` |
| 57 | + |
| 58 | +Required behavior: |
| 59 | +- Registers the repo as a workspace. |
| 60 | +- Creates/updates durable state storage. |
| 61 | +- Prints a short workspace summary (repo path, workspace id, state location). |
| 62 | + |
| 63 | +Artifacts: |
| 64 | +- Local state created (DB/file), e.g. `.codeframe/` and/or `codeframe.db`. |
| 65 | + |
| 66 | +### 2) Add a PRD |
| 67 | +Command: |
| 68 | +- `codeframe prd add <file.md>` (or `codeframe prd set <file.md>`) |
| 69 | + |
| 70 | +Required behavior: |
| 71 | +- Stores PRD text in state. |
| 72 | +- Parses minimal metadata if available (title, optional tags). |
| 73 | +- Confirms PRD stored. |
| 74 | + |
| 75 | +### 3) Generate tasks from PRD |
| 76 | +Command: |
| 77 | +- `codeframe tasks generate` |
| 78 | + |
| 79 | +Required behavior: |
| 80 | +- Produces a task list in durable state. |
| 81 | +- Tasks have at minimum: |
| 82 | + - `id`, `title`, `description`, `status` |
| 83 | +- Status values must be from the state machine below. |
| 84 | + |
| 85 | +### 4) Start work on a task (agents run) |
| 86 | +Command: |
| 87 | +- `codeframe work start <task-id>` |
| 88 | + |
| 89 | +Required behavior: |
| 90 | +- Transitions task status to `IN_PROGRESS`. |
| 91 | +- Launches agent execution for that task (synchronously or via a worker loop). |
| 92 | +- Writes events to an event log (stdout + durable log). |
| 93 | +- Uses a working directory strategy (can be simple at MVP): |
| 94 | + - either worktree/branch OR plain git branch OR patch staging |
| 95 | +- Must not require any web UI to observe progress. |
| 96 | + |
| 97 | +### 5) Observe status and events (human-in-loop visibility) |
| 98 | +Commands: |
| 99 | +- `codeframe status` |
| 100 | +- `codeframe events tail` (optional, but strongly recommended) |
| 101 | +- `codeframe work status <task-id>` (optional) |
| 102 | + |
| 103 | +Required behavior: |
| 104 | +- Shows current tasks grouped by status. |
| 105 | +- Shows most recent events for active task. |
| 106 | +- Makes blockers visible. |
| 107 | + |
| 108 | +### 6) Blockers (human-in-loop) |
| 109 | +Commands: |
| 110 | +- `codeframe blockers` |
| 111 | +- `codeframe blocker answer <blocker-id> "<text>"` |
| 112 | +- `codeframe blocker resolve <blocker-id>` (optional) |
| 113 | + |
| 114 | +Required behavior: |
| 115 | +- Agents can emit blockers into state. |
| 116 | +- Human can answer. |
| 117 | +- Agent run continues after answer OR can be resumed with: |
| 118 | + - `codeframe work resume <task-id>` |
| 119 | + |
| 120 | +### 7) Gates / verification |
| 121 | +Command: |
| 122 | +- `codeframe review` OR `codeframe gates run` |
| 123 | + |
| 124 | +Required behavior: |
| 125 | +- Runs basic gates (minimal viable set): |
| 126 | + - `pytest` (if present) |
| 127 | + - lint (optional if already in repo) |
| 128 | +- Records results in state and event log. |
| 129 | + |
| 130 | +### 8) Produce an output artifact (patch or commit) |
| 131 | +Command: |
| 132 | +- `codeframe patch export` OR `codeframe commit create -m "<message>"` |
| 133 | + |
| 134 | +Required behavior: |
| 135 | +- Produces either: |
| 136 | + - a patch file (preferred early for safety), OR |
| 137 | + - a git commit on a branch |
| 138 | +- Records artifact path/commit hash in state. |
| 139 | + |
| 140 | +### 9) Checkpoint + summary |
| 141 | +Commands: |
| 142 | +- `codeframe checkpoint create "<name>"` |
| 143 | +- `codeframe summary` |
| 144 | + |
| 145 | +Required behavior: |
| 146 | +- Creates a checkpoint snapshot of state. |
| 147 | +- Produces a short summary: |
| 148 | + - PRD title |
| 149 | + - tasks and statuses |
| 150 | + - completed work and artifacts |
| 151 | + - open blockers |
| 152 | + |
| 153 | +--- |
| 154 | + |
| 155 | +## State Machine (authoritative) |
| 156 | + |
| 157 | +Statuses: |
| 158 | +- `BACKLOG` |
| 159 | +- `READY` |
| 160 | +- `IN_PROGRESS` |
| 161 | +- `BLOCKED` |
| 162 | +- `DONE` |
| 163 | +- `MERGED` (optional for later) |
| 164 | + |
| 165 | +Allowed transitions (minimal): |
| 166 | +- BACKLOG -> READY |
| 167 | +- READY -> IN_PROGRESS |
| 168 | +- IN_PROGRESS -> BLOCKED |
| 169 | +- BLOCKED -> IN_PROGRESS |
| 170 | +- IN_PROGRESS -> DONE |
| 171 | +- DONE -> READY (reopen) |
| 172 | +- DONE -> MERGED (later) |
| 173 | + |
| 174 | +The CLI is the authority for transitions. |
| 175 | +UIs (web/electron) are views over this state machine, not the source of truth. |
| 176 | + |
| 177 | +--- |
| 178 | + |
| 179 | +## Implementation Principles |
| 180 | + |
| 181 | +### Core-first (no FastAPI in the core) |
| 182 | +- Domain logic must live in a reusable core module/package. |
| 183 | +- Core must not import FastAPI, websockets, or HTTP request objects. |
| 184 | +- FastAPI server (if used) must be a thin adapter over core. |
| 185 | + |
| 186 | +### CLI-first (server optional) |
| 187 | +- Golden Path commands must work without any running backend server. |
| 188 | +- If a server exists, it may be started separately (`codeframe serve`) and must wrap core. |
| 189 | + |
| 190 | +### Salvage safely |
| 191 | +- Legacy code can be read and copied from. |
| 192 | +- Core must not take dependencies on legacy UI-driven modules. |
| 193 | +- Prefer copying useful functions into core and simplifying interfaces. |
| 194 | + |
| 195 | +### Keep it runnable |
| 196 | +- Every commit should keep `codeframe --help` working. |
| 197 | +- The Golden Path commands should remain executable even if stubs at first. |
| 198 | + |
| 199 | +--- |
| 200 | + |
| 201 | +## Acceptance Checklist (must pass) |
| 202 | + |
| 203 | +- [ ] `codeframe init` creates durable state for a repo |
| 204 | +- [ ] `codeframe prd add` stores PRD |
| 205 | +- [ ] `codeframe tasks generate` creates tasks in state machine |
| 206 | +- [ ] `codeframe work start <id>` runs an agent workflow and logs events |
| 207 | +- [ ] `codeframe blockers` + `codeframe blocker answer` works |
| 208 | +- [ ] `codeframe review` runs gates and records results |
| 209 | +- [ ] `codeframe patch export` or `codeframe commit create` produces an artifact |
| 210 | +- [ ] `codeframe checkpoint create` snapshots state |
| 211 | +- [ ] No UI is required at any point |
| 212 | + |
| 213 | +If any item is not met, do not add new features outside this list. |
0 commit comments