feat(phase-6): add codebase-context init wizard#90
Conversation
Single-plan phase covering the init wizard: @inquirer/prompts dependency, src/cli-init.ts wizard logic, subcommand wiring in cli.ts and index.ts, and unit tests for all four clients and file-write scenarios.
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
Greptile SummaryThis PR implements Phase 6 of the v2.0.0 milestone: an interactive
Confidence Score: 4/5Mostly safe to merge — core wizard logic is correct, but the MCP JSON overwrite issue is a real data-loss risk for users with existing Cursor/OpenCode configs that should be fixed. One P1 finding (silent overwrite of existing MCP config files, which can destroy users' existing MCP server entries) keeps this at 4/5. The P2 unused-import issue is minor. All other logic is sound and well-tested. src/cli-init.ts (MCP file-write logic, lines 163–168) and src/index.ts (dead handleInitCli import, line 41)
|
| Filename | Overview |
|---|---|
| src/cli-init.ts | New 208-line wizard module; correct deduplication and preview-first UX, but MCP JSON configs for cursor/opencode silently overwrite existing files without merge. |
| src/cli.ts | Minor additions: handleInitCli import, 'init' added to CLI commands array, usage line, and dispatch branch. Clean and correct. |
| src/index.ts | Adds unused handleInitCli import (dead code, violates AGENTS.md) and 'init' to CLI_SUBCOMMANDS — the import should be removed. |
| tests/cli-init.test.ts | 12 vitest tests covering all 4 clients, instruction block invariants, path resolution, and file-write scenarios; correct and thorough. |
| package.json | @inquirer/prompts ^3.0.0 added to dependencies; appropriate addition for interactive CLI prompts. |
Sequence Diagram
sequenceDiagram
participant User
participant CLI as codebase-context init
participant FS as File System
participant Shell as execFileSync
User->>CLI: codebase-context init
CLI->>User: Which client? (select)
User->>CLI: claude-code | cursor | codex | opencode
CLI->>User: Preview MCP config
CLI->>User: Apply MCP config? [y/N]
alt kind === file (cursor / opencode)
CLI->>FS: mkdir -p dir
CLI->>FS: writeFile — OVERWRITES existing!
else kind === command (claude-code / codex)
CLI->>Shell: execFileSync('mcp', [...])
end
alt instructionPath !== null
CLI->>FS: access(instructionPath)
CLI->>User: Preview instruction block
CLI->>User: Write instruction block? [y/N]
CLI->>FS: readFile(instructionPath)
alt delimiter already present
CLI->>User: Skipped (idempotent)
else not present
CLI->>FS: writeFile (append block)
end
end
CLI->>User: Next steps message
Reviews (1): Last reviewed commit: "feat(phase-6): add codebase-context init..." | Re-trigger Greptile
Avoid overwriting existing Cursor/OpenCode MCP entries by merging only the codebase-context server config, and remove the unused init import in index to clear Quality Checks.
…irst-run-adoption # Conflicts: # .codebase-context/memory.json # .gitignore
Force tmp to 0.2.4 via pnpm overrides so production audit passes with @inquirer/prompts transitive dependencies.
Increase upper-bound timing tolerances in zombie process tests to reduce flaky failures on slower runners while keeping the timeout-behavior contract intact.
Summary
Implements Phase 6 of the v2.0.0 milestone: an interactive first-run setup wizard (codebase-context init) for new users.
What ships
Supported clients (first wave)
Claude Code, Cursor, Codex, OpenCode - as scoped in the Phase 6 requirements.
Behavior contract
Verification
Phase 6 verified in .planning/phases/06-bootstrap-first-run-adoption/06-VERIFICATION.md - 10/10 must-haves, 12/12 tests pass. One standing human-verification item (interactive TTY smoke test) non-blocking.