codebase-ai 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/commands/setup.md CHANGED
@@ -73,6 +73,120 @@ Print: `codebase manifest: generated`
73
73
 
74
74
  ---
75
75
 
76
+ ## Step 2b — Project Structure Standardisation
77
+
78
+ Scaffold the standard project structure. **Never overwrite existing files or directories.**
79
+
80
+ For each path, only create if it does not already exist:
81
+
82
+ ```bash
83
+ # Directories
84
+ mkdir -p docs src/core src/modules src/interfaces tests scripts
85
+
86
+ # README.md — only if missing
87
+ [ -f README.md ] || cat > README.md << 'EOF'
88
+ # [Project Name]
89
+
90
+ [What this project does — 1-2 sentences.]
91
+
92
+ ## Getting Started
93
+
94
+ ```bash
95
+ # install dependencies
96
+ # run the project
97
+ ```
98
+
99
+ ## Development
100
+
101
+ ```bash
102
+ # build
103
+ # test
104
+ # lint
105
+ ```
106
+ EOF
107
+
108
+ # .env.example — only if missing and no .env exists
109
+ [ -f .env.example ] || [ -f .env ] || cat > .env.example << 'EOF'
110
+ # Required environment variables
111
+ # Copy to .env and fill in values
112
+
113
+ # APP_PORT=3000
114
+ # DATABASE_URL=
115
+ # SECRET_KEY=
116
+ EOF
117
+
118
+ # docs/ARCHITECTURE.md — only if missing
119
+ [ -f docs/ARCHITECTURE.md ] || cat > docs/ARCHITECTURE.md << 'EOF'
120
+ # Architecture
121
+
122
+ ## System Overview
123
+
124
+ [High-level description of how the system works.]
125
+
126
+ ## Key Components
127
+
128
+ | Component | Purpose |
129
+ |---|---|
130
+ | `src/core/` | Business logic |
131
+ | `src/modules/` | Feature modules |
132
+ | `src/interfaces/` | Contracts, APIs, types |
133
+
134
+ ## Data Flow
135
+
136
+ [Describe the main request/data flow through the system.]
137
+
138
+ ## Key Design Decisions
139
+
140
+ [Document architectural decisions and their rationale here.]
141
+ EOF
142
+
143
+ # docs/IMPLEMENTATION.md — only if missing
144
+ [ -f docs/IMPLEMENTATION.md ] || cat > docs/IMPLEMENTATION.md << 'EOF'
145
+ # Implementation Guide
146
+
147
+ ## Code Organisation
148
+
149
+ [How the source code is structured and why.]
150
+
151
+ ## Patterns & Conventions
152
+
153
+ [Coding patterns, naming conventions, module rules.]
154
+
155
+ ## Adding Features
156
+
157
+ [Step-by-step guide for contributing new functionality.]
158
+
159
+ ## Common Tasks
160
+
161
+ [Runbook for frequent development tasks.]
162
+ EOF
163
+ ```
164
+
165
+ Print a structure report:
166
+ ```
167
+ PROJECT STRUCTURE
168
+ ══════════════════════════════════════
169
+ docs/ [created | exists]
170
+ ARCHITECTURE.md [created | exists]
171
+ IMPLEMENTATION.md [created | exists]
172
+ PRODUCT.md [pending — Step 6]
173
+ src/core/ [created | exists]
174
+ src/modules/ [created | exists]
175
+ src/interfaces/ [created | exists]
176
+ tests/ [created | exists]
177
+ scripts/ [created | exists]
178
+ README.md [created | exists]
179
+ .env.example [created | exists | skipped — .env present]
180
+ ══════════════════════════════════════
181
+ ```
182
+
183
+ **Rules:**
184
+ - Never delete or overwrite anything that already exists
185
+ - If the project has a non-standard structure (e.g. `app/` instead of `src/`), adapt the report but do not force-rename existing dirs
186
+ - Add any newly created paths to the Step 8 commit
187
+
188
+ ---
189
+
76
190
  ## Step 3 — GitHub labels
77
191
 
78
192
  ```bash
@@ -150,7 +264,7 @@ fi
150
264
 
151
265
  ---
152
266
 
153
- ## Step 6 — PRODUCT.md
267
+ ## Step 6 — Docs (PRODUCT.md, ARCHITECTURE.md, IMPLEMENTATION.md)
154
268
 
155
269
  Use `codebase brief` as the primary source of project intelligence:
156
270
 
@@ -160,7 +274,7 @@ npx codebase brief 2>/dev/null > /tmp/cb-brief.json || true
160
274
 
161
275
  Read the brief. If `docs/PRODUCT.md` exists and `--refresh` not passed: show diff of stale sections, ask user to confirm updates.
162
276
 
163
- Otherwise generate `docs/PRODUCT.md` from:
277
+ Otherwise generate `docs/PRODUCT.md` from (note: filename is all-caps `PRODUCT.md`):
164
278
  - `project.name`, `project.description` → Summary
165
279
  - `stack.languages`, `stack.frameworks`, `commands.*` → Tech Stack (auto-filled)
166
280
  - `patterns.architecture`, `patterns.api_style` → Context
@@ -173,9 +287,9 @@ Mark genuinely unknown sections with `[INFERRED: ...]`.
173
287
 
174
288
  ---
175
289
 
176
- ## Step 7 — CLAUDE.md
290
+ ## Step 7 — CLAUDE.md (last — reads everything set up above)
177
291
 
178
- Write (or update) `CLAUDE.md` for this specific project. Read `.codebase.json` and the codebase structure to produce a file that is genuinely useful to an AI starting a fresh session on this project.
292
+ Write (or update) `CLAUDE.md` for this specific project. At this point all other setup steps are complete — read `.codebase.json`, `docs/PRODUCT.md`, `docs/ARCHITECTURE.md`, `docs/IMPLEMENTATION.md`, and the full project structure before writing, so CLAUDE.md accurately reflects the final state of the project.
179
293
 
180
294
  **If `CLAUDE.md` already exists:** read it first. Preserve any existing sections. Only update the `<!-- codebase:start -->...<!-- codebase:end -->` block and add missing sections without removing human-authored content.
181
295
 
@@ -190,7 +304,7 @@ One paragraph describing what the project does, who it's for, and its current st
190
304
  Exact commands from `.codebase.json` → `commands.*`. Include build, dev, test, lint, typecheck.
191
305
 
192
306
  ### Architecture
193
- How the codebase is structured — key directories, entry points, data flow. Infer from `structure`, `patterns`, and file scanning. Be specific, not generic.
307
+ How the codebase is structured — key directories, entry points, data flow. Pull from `docs/ARCHITECTURE.md` if it was populated, otherwise infer from `structure`, `patterns`, and file scanning. Be specific, not generic.
194
308
 
195
309
  ### Key Conventions
196
310
  Language/framework conventions detected. Coding patterns observed. Things an AI must know to not break the codebase (e.g. "zero runtime dependencies", "no cross-module state", "all DB calls go through /lib/db").
@@ -229,7 +343,7 @@ npx codebase init --quiet 2>/dev/null || true
229
343
 
230
344
  ```bash
231
345
  git checkout develop 2>/dev/null || git checkout -b develop
232
- git add docs/PRODUCT.md CLAUDE.md .vibekit/ .gitignore 2>/dev/null || true
346
+ git add docs/PRODUCT.md docs/ARCHITECTURE.md docs/IMPLEMENTATION.md CLAUDE.md README.md .env.example .vibekit/ .gitignore src/ tests/ scripts/ 2>/dev/null || true
233
347
  git diff --cached --quiet || git commit -m "chore: bootstrap codebase + vibekit setup
234
348
 
235
349
  Initialized by /setup"
@@ -0,0 +1,257 @@
1
+ ---
2
+ description: Full autonomous loop — simulate → build → launch, repeating until shipped. Zero intervention required.
3
+ argument-hint: [--max-rounds N] [--version X.Y.Z] [--dry-run] [--skip-launch] [--sim-count N]
4
+ model: sonnet
5
+ allowed-tools: Agent, Bash(gh:*), Bash(git add:*), Bash(git commit:*), Bash(git push:*), Bash(git checkout:*), Bash(git pull:*), Bash(git fetch:*), Bash(git stash:*), Bash(git log:*), Bash(git status:*), Bash(git diff:*), Bash(git tag:*), Bash(git rev-parse:*), Bash(git branch:*), Bash(git merge:*), Bash(pnpm:*), Bash(npx:*), Bash(npm:*), Bash(node:*), Bash(uv:*), Bash(curl:*), Read, Write, Edit, Glob, Grep
6
+ ---
7
+
8
+ # /vibeloop
9
+
10
+ **The single command that does everything.** Runs simulate → build → launch in a fully autonomous loop until your project is shipped. No human intervention required after invocation.
11
+
12
+ ```
13
+ /vibeloop # full run: simulate → build → launch
14
+ /vibeloop --skip-launch # simulate → build only, stop before release
15
+ /vibeloop --dry-run # full run with --dry-run passed to launch (no actual release/merge)
16
+ /vibeloop --max-rounds 5 # cap the build loop at 5 rounds (default: 20)
17
+ /vibeloop --sim-count 5 # number of simulated customers per cycle (default: 3)
18
+ /vibeloop --version 1.2.0 # pin the release version tag
19
+ ```
20
+
21
+ ---
22
+
23
+ ## Arguments
24
+
25
+ ```
26
+ $ARGUMENTS
27
+ ```
28
+
29
+ Parse from `$ARGUMENTS`:
30
+ - `--max-rounds N` → cap build loop rounds (default: 20)
31
+ - `--version X.Y.Z` → pin release version (passed to /launch)
32
+ - `--dry-run` → no commits to main, no GitHub release (passed to /launch)
33
+ - `--skip-launch` → stop after build loop, do not release
34
+ - `--sim-count N` → customers per simulate cycle (default: 3)
35
+
36
+ ---
37
+
38
+ ## Phase 0 — Preflight
39
+
40
+ ```bash
41
+ gh auth status || { echo "ERROR: gh auth login first."; exit 1; }
42
+ git remote get-url origin || { echo "ERROR: No git remote."; exit 1; }
43
+ gh label list --limit 1 --json name --jq '.[0].name' 2>/dev/null | grep -q "sim" || {
44
+ echo "Labels not found — run /setup first."; exit 1;
45
+ }
46
+ [ -f "docs/PRODUCT.md" ] || { echo "docs/PRODUCT.md missing — run /setup first."; exit 1; }
47
+ ```
48
+
49
+ ### Load codebase project intelligence
50
+
51
+ ```bash
52
+ npx codebase brief 2>/dev/null > /tmp/cb-brief.json || true
53
+ ```
54
+
55
+ Read `/tmp/cb-brief.json`. Extract and hold in context:
56
+ - `project.name`, `project.description`
57
+ - `commands.dev`, `commands.test`, `commands.build`
58
+ - `stack.frameworks`, `stack.languages`, `stack.package_manager`
59
+ - `git.default_branch` — verify it's `develop`
60
+
61
+ Ensure on develop and clean:
62
+ ```bash
63
+ git fetch origin
64
+ git checkout develop && git pull origin develop
65
+ git status --short # warn if dirty but don't block
66
+ ```
67
+
68
+ Print the startup banner:
69
+ ```
70
+ ╔══════════════════════════════════════════════════════════╗
71
+ ║ /vibeloop STARTING ║
72
+ ╠══════════════════════════════════════════════════════════╣
73
+ ║ Project: [name from brief] ║
74
+ ║ Stack: [frameworks from brief] ║
75
+ ║ Mode: simulate → build → launch ║
76
+ ║ Max rounds: [N] ║
77
+ ║ Sim customers:[N] per cycle ║
78
+ ║ Launch: [yes | --skip-launch | --dry-run] ║
79
+ ╚══════════════════════════════════════════════════════════╝
80
+ ```
81
+
82
+ ---
83
+
84
+ ## Phase 1 — Simulate (seed the issue queue)
85
+
86
+ Run a full simulation cycle to find bugs before building anything.
87
+
88
+ ### 1a. Run customer journeys
89
+
90
+ Invoke the full `/simulate` logic as a sub-agent:
91
+
92
+ Use the Agent tool to run one complete simulation cycle (Phase 0 through Phase 6 of /simulate). Pass `--count [sim-count]`. The simulation should:
93
+ - Run `[sim-count]` customer journeys against the live dev server
94
+ - Perform the 9-dimension UX audit
95
+ - Fix all fixable bugs inline with atomic commits
96
+ - Create GitHub issues for all findings
97
+ - Write the cycle summary issue
98
+
99
+ When the simulation cycle completes (one full pass), return to this orchestrator.
100
+
101
+ **Do not run /simulate in its own infinite loop** — vibeloop controls the outer loop. Run exactly one simulate cycle here.
102
+
103
+ ### 1b. Count open issues after simulate
104
+
105
+ ```bash
106
+ ARCH=$(gh issue list --label "arch" --state open --json number --jq 'length')
107
+ BUGS=$(gh issue list --label "bug" --state open --json number --jq 'length')
108
+ ```
109
+
110
+ Print:
111
+ ```
112
+ PHASE 1 COMPLETE — Simulate seeded [N] arch issues, [N] bug issues
113
+ ```
114
+
115
+ If `$ARCH == 0` and `$BUGS == 0`:
116
+ - Print "No issues found. Project looks clean."
117
+ - Skip Phase 2 and proceed directly to Phase 3.
118
+
119
+ ---
120
+
121
+ ## Phase 2 — Build loop
122
+
123
+ Run the full `/build` loop to resolve all arch and bug issues found by simulate.
124
+
125
+ ### 2a. Outer loop (controlled by vibeloop)
126
+
127
+ This phase repeats until either:
128
+ - All `arch` + `vibekit` labeled issues are closed AND no open `bug` issues remain, OR
129
+ - `--max-rounds` is reached
130
+
131
+ For each round:
132
+
133
+ **Step 1 — Build all arch/vibekit issues:**
134
+
135
+ Use the Agent tool to run one full `/build --once` pass (Phase 0 through Phase 2 of /build, then exit). This implements every open `arch`/`vibekit` issue once without running the inner simulate/poll loop — vibeloop controls that loop here.
136
+
137
+ **Step 2 — Simulate verification:**
138
+
139
+ Use the Agent tool to run one `/simulate --journey-only --count [sim-count]` cycle (customer journeys only, no full UX audit). This verifies the build didn't break anything and may find new bugs.
140
+
141
+ **Step 3 — Check gates:**
142
+
143
+ ```bash
144
+ npx codebase scan-only --quiet --sync
145
+ ARCH=$(gh issue list --label "arch" --state open --json number --jq 'length')
146
+ BUGS=$(gh issue list --label "bug,critical" --state open --json number --jq 'length')
147
+ BUGS_HIGH=$(gh issue list --label "bug,high" --state open --json number --jq 'length')
148
+ ```
149
+
150
+ Print round summary:
151
+ ```
152
+ VIBELOOP ROUND [R] / [max-rounds]
153
+ ════════════════════════════════════════════════════
154
+ Arch issues remaining: [N]
155
+ Critical/high bugs: [N]
156
+ Status: [continuing | all clear]
157
+ ════════════════════════════════════════════════════
158
+ ```
159
+
160
+ If `$ARCH == 0` and `$BUGS == 0` and `$BUGS_HIGH == 0`: break loop → proceed to Phase 3.
161
+
162
+ If round >= `--max-rounds`: print "Max rounds reached. Some issues may remain." → proceed to Phase 3 anyway.
163
+
164
+ Otherwise: increment round, repeat Step 1.
165
+
166
+ ### 2b. Final full simulate (pre-launch verification)
167
+
168
+ Before launching, run one final comprehensive simulate cycle:
169
+
170
+ Use the Agent tool to run one complete `/simulate` cycle (all phases). This is the final QA gate — any bugs found here must be fixed before launch can proceed.
171
+
172
+ ```bash
173
+ BUGS=$(gh issue list --label "bug,critical" --state open --json number --jq 'length')
174
+ BUGS_HIGH=$(gh issue list --label "bug,high" --state open --json number --jq 'length')
175
+ ```
176
+
177
+ If critical or high bugs remain after final simulate:
178
+ - Print "Final simulate found blocking bugs. Running one more build pass."
179
+ - Return to Phase 2a for one more round (hard cap at 3 extra rounds regardless of --max-rounds).
180
+
181
+ ---
182
+
183
+ ## Phase 3 — Launch
184
+
185
+ Skip this phase entirely if `--skip-launch` was passed. Print "Skipping launch (--skip-launch). Done." and exit.
186
+
187
+ ### 3a. Pre-launch gate summary
188
+
189
+ ```bash
190
+ CRITICAL=$(gh issue list --label "bug,critical" --state open --json number --jq 'length')
191
+ HIGH=$(gh issue list --label "bug,high" --state open --json number --jq 'length')
192
+ ARCH=$(gh issue list --label "arch" --state open --json number --jq 'length')
193
+ ```
194
+
195
+ Print:
196
+ ```
197
+ PRE-LAUNCH STATUS
198
+ ════════════════════════════════════════════════════
199
+ Critical bugs: [N] [BLOCKED if > 0]
200
+ High bugs: [N] [BLOCKED if > 0]
201
+ Arch issues: [N] [WARNING if > 0]
202
+ ════════════════════════════════════════════════════
203
+ ```
204
+
205
+ If `$CRITICAL > 0` or `$HIGH > 0`:
206
+ - Print "BLOCKED: Open critical/high bugs prevent launch. Fix them first or run /launch --dry-run to inspect."
207
+ - Exit.
208
+
209
+ ### 3b. Execute launch
210
+
211
+ Use the Agent tool to run the full `/launch` logic (all phases of /launch). Pass:
212
+ - `--version [version]` if `--version` was specified
213
+ - `--dry-run` if `--dry-run` was specified
214
+
215
+ The launch sub-agent will:
216
+ - Run all gate checks (bugs, tests, UX scores, branch cleanliness)
217
+ - Generate `docs/RELEASE-NOTES.md`
218
+ - Create the GitHub release and tag
219
+ - Merge `develop` → `main`
220
+ - Rotate the milestone
221
+ - Refresh the codebase manifest
222
+
223
+ ---
224
+
225
+ ## Phase 4 — Final Summary
226
+
227
+ ```
228
+ ╔══════════════════════════════════════════════════════════╗
229
+ ║ /vibeloop COMPLETE ║
230
+ ╠══════════════════════════════════════════════════════════╣
231
+ ║ Simulate cycles: [N] ║
232
+ ║ Build rounds: [N] ║
233
+ ║ Issues implemented: [N] ║
234
+ ║ Bugs fixed inline: [N] ║
235
+ ║ Version released: [vX.Y.Z | --dry-run | skipped] ║
236
+ ║ develop → main: [merged | --dry-run | skipped] ║
237
+ ╚══════════════════════════════════════════════════════════╝
238
+
239
+ Next steps:
240
+ • Check GitHub releases for the release notes
241
+ • Run /vibeloop again next sprint to start a new cycle
242
+ • Use /simulate for targeted UX testing
243
+ • Use /build --issue N to fix a specific issue
244
+ ```
245
+
246
+ ---
247
+
248
+ ## Ground Rules
249
+
250
+ 1. **One agent per phase** — simulate, build, and launch each run as isolated sub-agents via the Agent tool
251
+ 2. **vibeloop controls the outer loop** — do not let /build or /simulate run their own infinite loops; vibeloop orchestrates timing
252
+ 3. **Never force push** — if git state is broken, investigate before acting
253
+ 4. **Hard stop on launch blockers** — critical/high bugs always block Phase 3, no overrides
254
+ 5. **Atomic commits throughout** — every fix in every sub-agent must be `git add [specific files]`, never `git add .`
255
+ 6. **Dry-run is always safe** — `--dry-run` must propagate to all sub-agents and never touch `main` or create releases
256
+ 7. **Max-rounds is a safety net** — if hit, proceed to launch anyway (with warnings in release notes about remaining issues)
257
+ 8. **Always on develop** — vibeloop never switches away from develop except for the final merge to main in /launch