Skip to content

Commit 5bddc8a

Browse files
committed
feat(phase-6): add codebase-context init wizard
Interactive CLI wizard (`codebase-context init`) for first-run adoption. Covers Claude Code, Cursor, Codex, and OpenCode with HTTP MCP config generation, preview-first UX, and instruction block scaffolding with delimiter-based dedup. 12 unit tests added. - src/cli-init.ts: new wizard module with 5 exports - tests/cli-init.test.ts: 12 vitest tests (4 groups) - src/cli.ts + src/index.ts: init subcommand wired - package.json: @inquirer/prompts ^3.0.0 added
1 parent 75b7c73 commit 5bddc8a

File tree

11 files changed

+795
-9
lines changed

11 files changed

+795
-9
lines changed

.codebase-context/memory.json

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,5 +327,68 @@
327327
"reason": "Auto-extracted from git commit history",
328328
"date": "2026-03-05T18:17:37.000Z",
329329
"source": "git"
330+
},
331+
{
332+
"id": "e9050a3936c9",
333+
"type": "gotcha",
334+
"category": "conventions",
335+
"memory": "fix: address greptile P2 review comments",
336+
"reason": "Auto-extracted from git commit history",
337+
"date": "2026-03-30T09:02:01.000Z",
338+
"source": "git"
339+
},
340+
{
341+
"id": "6bd8f128789c",
342+
"type": "gotcha",
343+
"category": "conventions",
344+
"memory": "fix(deps): patch picomatch audit path",
345+
"reason": "Auto-extracted from git commit history",
346+
"date": "2026-03-26T07:24:14.000Z",
347+
"source": "git"
348+
},
349+
{
350+
"id": "de2fbacf6c09",
351+
"type": "gotcha",
352+
"category": "conventions",
353+
"memory": "fix(config): reject empty roots and invalid ports",
354+
"reason": "Auto-extracted from git commit history",
355+
"date": "2026-03-26T07:11:10.000Z",
356+
"source": "git"
357+
},
358+
{
359+
"id": "67afc7eab730",
360+
"type": "gotcha",
361+
"category": "conventions",
362+
"memory": "fix: guard against unhandled rejections and resource leaks in HTTP transport",
363+
"reason": "Auto-extracted from git commit history",
364+
"date": "2026-03-25T21:19:51.000Z",
365+
"source": "git"
366+
},
367+
{
368+
"id": "aeea4306f46f",
369+
"type": "gotcha",
370+
"category": "conventions",
371+
"memory": "fix: satisfy lint in index",
372+
"reason": "Auto-extracted from git commit history",
373+
"date": "2026-04-04T22:09:20.000Z",
374+
"source": "git"
375+
},
376+
{
377+
"id": "96efbfb23a7d",
378+
"type": "gotcha",
379+
"category": "conventions",
380+
"memory": "fix: align discovery protocol metrics",
381+
"reason": "Auto-extracted from git commit history",
382+
"date": "2026-04-04T19:32:17.000Z",
383+
"source": "git"
384+
},
385+
{
386+
"id": "86ed745be25a",
387+
"type": "gotcha",
388+
"category": "conventions",
389+
"memory": "fix: format discovery benchmark sources",
390+
"reason": "Auto-extracted from git commit history",
391+
"date": "2026-04-04T18:56:05.000Z",
392+
"source": "git"
330393
}
331394
]

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,7 @@ nul
2525
grammars/*.wasm
2626
.agents/
2727
.tmp-research-repos/
28+
.tmp-claude-swap/
2829
docs/visuals.md
2930
.repolore/
31+
.opencode

.planning/ROADMAP.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ BEWARE: AI-GENERATED MARKDOWN FILE, DO NOT BLINDLY TRUST IT
99
## Active Phases
1010

1111
- [x] **Phase 5: Freeze Discovery Benchmark** - lock the discovery-only benchmark and fairness rules before product-shaping changes land
12-
- [ ] **Phase 6: Bootstrap First-Run Adoption** - ship the interactive bootstrap wizard for the first-wave clients
12+
- [x] **Phase 6: Bootstrap First-Run Adoption** - ship the interactive bootstrap wizard for the first-wave clients
1313
- [ ] **Phase 7: Promote the Map Surface** - make repo intelligence the primary first-call surface in CLI and MCP
1414
- [ ] **Phase 8: Tighten the Search Contract** - formalize compact-vs-full search and nuanced edit-readiness
1515
- [ ] **Phase 9: Publish Proof and Sync the Public Surface** - finish v2 with honest proof, locked messaging, and aligned public artifacts
@@ -31,13 +31,13 @@ BEWARE: AI-GENERATED MARKDOWN FILE, DO NOT BLINDLY TRUST IT
3131
### Phase 6: Bootstrap First-Run Adoption
3232

3333
**Goal**: make first-run setup and instruction seeding simple for a new public user without turning bootstrap into a separate product.
34-
**Status**: [ ]
34+
**Status**: [x]
3535
**Depends on**: Phase 5
3636
**Requirements**: `BOOT-01`
3737
**Plans**: 1 plan
3838

3939
Plans:
40-
- [ ] 06-01-PLAN.md — Add @inquirer/prompts, implement init wizard in src/cli-init.ts, wire subcommand, add unit tests
40+
- [x] 06-01-PLAN.md — Add @inquirer/prompts, implement init wizard in src/cli-init.ts, wire subcommand, add unit tests
4141

4242
**Success Criteria**:
4343
1. `codebase-context init` supports `Claude Code`, `Cursor`, `Codex`, and `OpenCode` only for the first wave.
@@ -86,4 +86,4 @@ Plans:
8686

8787
## Current Status
8888

89-
Active milestone is `v2.0.0 Map-First Discovery Relaunch`. Phase 5 is verified complete; the next workflow is `/gsdd-progress` to route into Phase 6.
89+
Active milestone is `v2.0.0 Map-First Discovery Relaunch`. Phase 5 and Phase 6 are complete. Next step is `/gsdd-verify 6` then `/gsdd-progress` to route into Phase 7.

.planning/phases/06-bootstrap-first-run-adoption/06-01-PLAN.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ must_haves:
5252
to: "@inquirer/prompts"
5353
via: "select/confirm imports"
5454
pattern: "from '@inquirer/prompts'"
55+
- from: "src/index.ts"
56+
to: "HTTP/MCP startup path"
57+
via: "argv[2] is a filesystem path, not a CLI_SUBCOMMAND"
58+
pattern: "else branch unchanged"
5559
---
5660

5761
<objective>
@@ -241,9 +245,9 @@ for the instruction-write step.
241245
<verify>
242246
`pnpm tsc --noEmit` exits 0.
243247
`pnpm test -- src/cli-init.test.ts` exits 0 with all tests passing (no skipped tests).
244-
Manual smoke: `node --import tsx/esm src/index.ts init --help` (or just `init` with stdin
245-
redirected to /dev/null) should not throw a module-not-found error. A prompt or an inquirer
246-
error about stdin is acceptable — confirms routing works.
248+
Routing check (programmatic): `node --import tsx/esm src/index.ts init < /dev/null; [ $? -ne 127 ]`
249+
— a non-127 exit (module not found) confirms the subcommand routes correctly. An inquirer stdin
250+
error or exit 1 is acceptable; only exit 127 (command not found) is a failure.
247251
</verify>
248252
<done>
249253
All tests in `src/cli-init.test.ts` pass. `'init'` appears in `_CLI_COMMANDS` in `src/cli.ts`

AGENTS.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,105 @@
11
# Agent Instructions
22

3+
<!-- BEGIN GSDD -->
4+
## GSDD Governance (Generated)
5+
6+
This block is managed by `gsdd`. Do not edit inside the block directly.
7+
Edit the source template in the GSDD framework instead.
8+
9+
### What This Project Uses
10+
- Framework: GSDD (Spec-Driven Development)
11+
- Planning dir: `.planning/` (specs, roadmaps, plans, research, templates)
12+
- Lifecycle: `bootstrap (gsdd init) -> new-project -> [discuss-approach -> plan -> execute -> verify] x N -> audit-milestone` for roadmap work
13+
- Supporting workflows: quick (sub-hour tasks), map-codebase (codebase analysis), pause/resume (session management), progress (status query)
14+
15+
### Rules You MUST Follow
16+
17+
1. Never Skip The Workflow
18+
- Roadmap work should follow: plan -> execute -> verify.
19+
- Direct user requests do NOT need to be forced into a phase or plan unless the user explicitly wants roadmap tracking.
20+
- Before coding roadmap work: read `.planning/SPEC.md`, `.planning/ROADMAP.md`, and the relevant phase plan if one exists.
21+
- After coding: verify against the relevant success criteria before claiming done.
22+
23+
2. Read Before You Write
24+
- If `.planning/` exists, read in order:
25+
- `.planning/SPEC.md`
26+
- `.planning/ROADMAP.md`
27+
- `.planning/config.json`
28+
- The relevant phase plan in `.planning/phases/` when the work is roadmap-scoped
29+
- If `.planning/` does not exist, the project has not been bootstrapped. Run `gsdd init`, then run the new-project workflow (`.agents/skills/gsdd-new-project/SKILL.md`).
30+
31+
3. Stay In Scope (Zero Deviation)
32+
- Implement ONLY what the approved plan or direct user request specifies.
33+
- If you notice unrelated improvements, do not implement them. Record them as a TODO for a future phase.
34+
35+
Priority order when instructions conflict:
36+
- Developer explicit instruction (highest)
37+
- Current approved plan or direct task scope
38+
- `.planning/SPEC.md`
39+
- General best practices (lowest)
40+
41+
4. Version Control Protocol
42+
- Treat `.planning/config.json` -> `gitProtocol` as advisory guidance, not a mandatory naming template.
43+
- Follow the existing repo or team git conventions first.
44+
- Do not mention phase, plan, or task IDs in commit or PR names unless explicitly requested.
45+
- Tests must pass before committing.
46+
47+
5. Verify Your Own Work (Exists -> Substantive -> Wired)
48+
Before reporting "done", verify each deliverable:
49+
- Exists: artifact is present where the plan says it should be
50+
- Substantive: real content/code, not placeholders or TODOs
51+
- Wired: connected to the system (imported, called, rendered, tested)
52+
53+
6. Research Before Unfamiliar Domains
54+
If you are not confident about a domain/library/pattern:
55+
- Stop and research first (docs + existing code).
56+
- Do not assume training data is current.
57+
- Cite sources in `.planning/research/` (or `.internal-research/` for framework work).
58+
59+
7. Never Hallucinate Paths Or APIs
60+
- Use only file paths you've confirmed exist.
61+
- Use only APIs verified in docs or source.
62+
63+
8. Adapter Architecture Rule
64+
- Do not pollute core workflows (`distilled/workflows/*.md`) with vendor-specific syntax.
65+
- Tool-specific adapters are generated in `bin/` (generators, not converters).
66+
67+
9. Anti-YOLO
68+
- Do not delete or rewrite code unless explicitly asked.
69+
- If asked for analysis, answer first; propose changes separately.
70+
71+
### Where The Workflows Live
72+
- Primary lifecycle:
73+
- `.agents/skills/gsdd-new-project/SKILL.md` — project initialization (spec + roadmap)
74+
- `.agents/skills/gsdd-plan/SKILL.md` — phase planning with optional independent checking
75+
- `.agents/skills/gsdd-execute/SKILL.md` — plan execution with quality gates
76+
- `.agents/skills/gsdd-verify/SKILL.md` — phase goal-backward verification
77+
- `.agents/skills/gsdd-verify-work/SKILL.md` — conversational UAT testing with structured gap tracking
78+
- `.agents/skills/gsdd-audit-milestone/SKILL.md` — milestone integration audit
79+
- Milestone lifecycle:
80+
- `.agents/skills/gsdd-complete-milestone/SKILL.md` — archive shipped milestone, evolve spec, collapse roadmap
81+
- `.agents/skills/gsdd-new-milestone/SKILL.md` — start next milestone cycle (goals, requirements, roadmap phases)
82+
- `.agents/skills/gsdd-plan-milestone-gaps/SKILL.md` — create gap-closure phases from audit results
83+
- Supporting workflows:
84+
- `.agents/skills/gsdd-quick/SKILL.md` — sub-hour tasks outside the phase cycle
85+
- `.agents/skills/gsdd-map-codebase/SKILL.md` — codebase analysis and refresh
86+
- `.agents/skills/gsdd-pause/SKILL.md` — session checkpoint
87+
- `.agents/skills/gsdd-resume/SKILL.md` — session context restore and routing
88+
- `.agents/skills/gsdd-progress/SKILL.md` — read-only status and next-action routing
89+
90+
### How To Invoke Workflows
91+
92+
How you run these workflows depends on your tool:
93+
94+
- **Claude Code / OpenCode / Cursor / Copilot / Gemini:** Use slash commands — `/gsdd-new-project`, `/gsdd-plan`, `/gsdd-execute`, etc.
95+
- **Codex CLI:** Use skill references — `$gsdd-new-project`, `$gsdd-plan`, `$gsdd-execute`, etc.
96+
- **Other AI tools:** Open the SKILL.md file listed above and follow its instructions.
97+
98+
If this root `AGENTS.md` block is present in a Cursor, Copilot, or Gemini project, treat it as behavioral governance on top of the runtime's native slash-command discovery. Do not treat this file as the mechanism that makes the workflows discoverable.
99+
100+
Start with the new-project workflow to produce `.planning/SPEC.md` and `.planning/ROADMAP.md`.
101+
<!-- END GSDD -->
102+
3103
## Project Constraints
4104

5105
These are non-negotiable. Every PR, feature, and design decision must respect them.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@
133133
"prepare": "husky"
134134
},
135135
"dependencies": {
136+
"@inquirer/prompts": "^3.0.0",
136137
"@huggingface/transformers": "^3.8.1",
137138
"@lancedb/lancedb": "^0.4.0",
138139
"@modelcontextprotocol/sdk": "^1.27.1",

0 commit comments

Comments
 (0)