compound-agent 1.3.0 → 1.3.1

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/dist/cli.js CHANGED
@@ -1489,6 +1489,30 @@ function checkBeadsAvailable() {
1489
1489
  };
1490
1490
  }
1491
1491
  }
1492
+ function checkBeadsInitialized(repoRoot) {
1493
+ return existsSync(join(repoRoot, ".beads"));
1494
+ }
1495
+ function checkBeadsHealthy(repoRoot) {
1496
+ try {
1497
+ execSync("bd doctor", { cwd: repoRoot, shell: "/bin/sh", stdio: "pipe", encoding: "utf-8" });
1498
+ return { healthy: true };
1499
+ } catch (e) {
1500
+ const msg = e instanceof Error && "stderr" in e ? String(e.stderr).trim() : "bd doctor failed";
1501
+ return { healthy: false, message: msg };
1502
+ }
1503
+ }
1504
+ function runFullBeadsCheck(repoRoot) {
1505
+ const cli = checkBeadsAvailable();
1506
+ if (!cli.available) {
1507
+ return { cliAvailable: false, initialized: false, healthy: false, healthMessage: cli.message };
1508
+ }
1509
+ const initialized = checkBeadsInitialized(repoRoot);
1510
+ if (!initialized) {
1511
+ return { cliAvailable: true, initialized: false, healthy: false };
1512
+ }
1513
+ const health = checkBeadsHealthy(repoRoot);
1514
+ return { cliAvailable: true, initialized: true, healthy: health.healthy, healthMessage: health.message };
1515
+ }
1492
1516
 
1493
1517
  // src/memory/capture/quality.ts
1494
1518
  var DEFAULT_SIMILARITY_THRESHOLD = 0.8;
@@ -2562,6 +2586,22 @@ function printPnpmConfigStatus(result) {
2562
2586
  console.log(` pnpm config: Added onlyBuiltDependencies [${result.added.join(", ")}]`);
2563
2587
  }
2564
2588
  }
2589
+ function printBeadsFullStatus(check) {
2590
+ console.log(` Beads CLI: ${check.cliAvailable ? "OK" : "not found"}`);
2591
+ if (check.cliAvailable) {
2592
+ console.log(` Beads repo: ${check.initialized ? "OK" : "not initialized (run: bd init)"}`);
2593
+ if (check.initialized) {
2594
+ console.log(` Beads health: ${check.healthy ? "OK" : `issues found${check.healthMessage ? ` \u2014 ${check.healthMessage}` : ""}`}`);
2595
+ }
2596
+ }
2597
+ }
2598
+ function printScopeStatus(scope) {
2599
+ if (scope.isUserScope) {
2600
+ console.log(" Scope: user-scope (reduced compounding value)");
2601
+ } else {
2602
+ console.log(" Scope: OK (repository scope)");
2603
+ }
2604
+ }
2565
2605
  async function runStatus(repoRoot) {
2566
2606
  const agentsDir = join(repoRoot, ".claude", "agents", "compound");
2567
2607
  const commandsDir = join(repoRoot, ".claude", "commands", "compound");
@@ -2580,12 +2620,10 @@ async function runStatus(repoRoot) {
2580
2620
  } catch {
2581
2621
  }
2582
2622
  console.log(` Hooks: ${hooksInstalled ? "installed" : "not installed"}`);
2583
- const beads = checkBeadsAvailable();
2584
- console.log(` Beads CLI: ${beads.available ? "available" : "not found"}`);
2623
+ const fullBeads = runFullBeadsCheck(repoRoot);
2624
+ printBeadsFullStatus(fullBeads);
2585
2625
  const scope = checkUserScope(repoRoot);
2586
- if (scope.isUserScope) {
2587
- console.log(" Scope: user-scope (reduced compounding value)");
2588
- }
2626
+ printScopeStatus(scope);
2589
2627
  }
2590
2628
  var REQUIRED_PATTERNS = ["node_modules/", ".claude/.cache/"];
2591
2629
  var SECTION_COMMENT = "# compound-agent";
@@ -4160,21 +4198,21 @@ npx ca prime
4160
4198
 
4161
4199
  // src/setup/templates/docs.ts
4162
4200
  var DOC_TEMPLATES = {
4163
- "HOW_TO_COMPOUND.md": `---
4201
+ "README.md": `---
4164
4202
  version: "{{VERSION}}"
4165
4203
  last-updated: "{{DATE}}"
4166
- summary: "Usage guide for compound-agent CLI, skills, and workflows"
4204
+ summary: "Overview and getting started guide for compound-agent"
4167
4205
  ---
4168
4206
 
4169
- # How to Compound
4207
+ # Compound Agent
4170
4208
 
4171
- A usage guide for humans and AI agents working with compound-agent -- the learning system that helps Claude Code avoid repeating mistakes across sessions.
4209
+ A learning system for Claude Code that captures, indexes, and retrieves lessons learned during development sessions -- so the same mistakes are not repeated.
4172
4210
 
4173
4211
  ---
4174
4212
 
4175
- ## 1. What is compound-agent
4213
+ ## What is compound-agent?
4176
4214
 
4177
- Compound-agent is a TypeScript CLI plugin for Claude Code that captures, indexes, and retrieves lessons learned during development sessions. When Claude makes a mistake and gets corrected, or discovers a useful pattern, that knowledge is stored as a **memory item** in \`.claude/lessons/index.jsonl\`. Future sessions search this memory before planning and implementing, so the same mistakes are not repeated.
4215
+ Compound-agent is a TypeScript CLI plugin for Claude Code. When Claude makes a mistake and gets corrected, or discovers a useful pattern, that knowledge is stored as a **memory item** in \`.claude/lessons/index.jsonl\`. Future sessions search this memory before planning and implementing.
4178
4216
 
4179
4217
  The system uses:
4180
4218
 
@@ -4183,17 +4221,21 @@ The system uses:
4183
4221
  - **Semantic embeddings** (EmbeddingGemma-300M via node-llama-cpp) for vector similarity search
4184
4222
  - **Claude Code hooks** to inject memory at session start, before compaction, and on tool failures
4185
4223
 
4186
- Memory items have four types: \`lesson\`, \`solution\`, \`pattern\`, and \`preference\`. Each has a trigger (what happened), an insight (what to do differently), tags, severity, and optional citations linking back to source code.
4224
+ Memory items have four types: \`lesson\`, \`solution\`, \`pattern\`, and \`preference\`. Each has a trigger, an insight, tags, severity, and optional citations.
4187
4225
 
4188
4226
  ---
4189
4227
 
4190
- ## 2. Installation
4191
-
4192
- ### Quick start
4228
+ ## Quick start
4193
4229
 
4194
4230
  \`\`\`bash
4195
- # In your project root:
4231
+ # Initialize in your project:
4196
4232
  npx ca init
4233
+
4234
+ # Full setup (includes embedding model download):
4235
+ npx ca setup
4236
+
4237
+ # Verify installation:
4238
+ npx ca doctor
4197
4239
  \`\`\`
4198
4240
 
4199
4241
  ### What \`init\` does
@@ -4202,31 +4244,16 @@ npx ca init
4202
4244
  2. Updates \`AGENTS.md\` with a compound-agent section
4203
4245
  3. Adds a reference to \`.claude/CLAUDE.md\`
4204
4246
  4. Creates \`.claude/plugin.json\` manifest
4205
- 5. Installs agent templates to \`.claude/agents/compound/\`
4206
- 6. Installs workflow slash commands to \`.claude/commands/compound/\`
4207
- 7. Installs phase skills to \`.claude/skills/compound/\`
4208
- 8. Installs agent role skills to \`.claude/skills/compound/agents/\`
4209
- 9. Installs a git pre-commit hook (lesson capture reminder)
4210
- 10. Installs Claude Code hooks (SessionStart, PreCompact, UserPromptSubmit, PostToolUseFailure, PostToolUse)
4211
- 11. For pnpm projects: auto-configures \`onlyBuiltDependencies\` for native addons
4247
+ 5. Installs agent templates, workflow commands, phase skills, and agent role skills
4248
+ 6. Installs a git pre-commit hook (lesson capture reminder)
4249
+ 7. Installs Claude Code hooks (SessionStart, PreCompact, UserPromptSubmit, PostToolUseFailure, PostToolUse)
4250
+ 8. For pnpm projects: auto-configures \`onlyBuiltDependencies\` for native addons
4212
4251
 
4213
- ### Full setup (with embedding model)
4252
+ \`setup\` does everything \`init\` does, plus downloads the EmbeddingGemma-300M model (~278MB). Use \`--skip-model\` to skip the download.
4214
4253
 
4215
- \`\`\`bash
4216
- npx ca setup
4217
- \`\`\`
4218
-
4219
- \`setup\` does everything \`init\` does, plus downloads the EmbeddingGemma-300M model (~278MB) for semantic search. Use \`--skip-model\` to skip the download.
4220
-
4221
- ### Verify installation
4222
-
4223
- \`\`\`bash
4224
- npx ca doctor
4225
- \`\`\`
4226
-
4227
- This checks for \`.claude/\` directory, lessons index, embedding model, Claude hooks, and beads (\`bd\`) availability.
4254
+ ---
4228
4255
 
4229
- ### Directory structure after install
4256
+ ## Directory structure
4230
4257
 
4231
4258
  \`\`\`
4232
4259
  .claude/
@@ -4245,29 +4272,57 @@ This checks for \`.claude/\` directory, lessons index, embedding model, Claude h
4245
4272
 
4246
4273
  ---
4247
4274
 
4248
- ## 3. The 5-phase workflow
4275
+ ## Quick reference
4276
+
4277
+ | Task | Command |
4278
+ |------|---------|
4279
+ | Capture a lesson | \`npx ca learn "insight" --trigger "what happened"\` |
4280
+ | Search memory | \`npx ca search "keywords"\` |
4281
+ | Check plan against memory | \`npx ca check-plan --plan "description"\` |
4282
+ | View stats | \`npx ca stats\` |
4283
+ | Run full workflow | \`/compound:lfg <epic-id>\` |
4284
+ | Health check | \`npx ca doctor\` |
4285
+
4286
+ ---
4287
+
4288
+ ## Further reading
4289
+
4290
+ - [WORKFLOW.md](WORKFLOW.md) -- The 5-phase development workflow and LFG orchestrator
4291
+ - [CLI_REFERENCE.md](CLI_REFERENCE.md) -- Complete CLI command reference
4292
+ - [SKILLS.md](SKILLS.md) -- Phase skills and agent role skills
4293
+ - [INTEGRATION.md](INTEGRATION.md) -- Memory system, hooks, beads, and agent guidance
4294
+ `,
4295
+ "WORKFLOW.md": `---
4296
+ version: "{{VERSION}}"
4297
+ last-updated: "{{DATE}}"
4298
+ summary: "The 5-phase compound-agent workflow and LFG orchestrator"
4299
+ ---
4300
+
4301
+ # Workflow
4249
4302
 
4250
- Every feature or epic follows five phases:
4303
+ Every feature or epic follows five phases. The \`/compound:lfg\` skill chains them with enforcement gates.
4251
4304
 
4252
- ### Phase 1: Brainstorm
4305
+ ---
4306
+
4307
+ ## Phase 1: Brainstorm
4253
4308
 
4254
- Explore the problem space before committing to a solution. Produce a structured brainstorm document with decisions, open questions, and a beads epic.
4309
+ Explore the problem space before committing to a solution.
4255
4310
 
4256
4311
  - Ask "why" before "how"
4257
4312
  - Search memory for similar past features
4258
4313
  - Generate multiple approaches, then converge
4259
4314
  - Create a beads epic: \`bd create --title="..." --type=epic\`
4260
4315
 
4261
- ### Phase 2: Plan
4316
+ ## Phase 2: Plan
4262
4317
 
4263
- Decompose work into small, testable tasks with dependencies and acceptance criteria.
4318
+ Decompose work into small, testable tasks with dependencies.
4264
4319
 
4265
4320
  - Review brainstorm output
4266
4321
  - Create beads tasks: \`bd create --title="..." --type=task\`
4267
4322
  - Create Review and Compound blocking tasks (these survive compaction)
4268
4323
  - Run \`npx ca worktree wire-deps <epic-id>\` if using worktrees
4269
4324
 
4270
- ### Phase 3: Work
4325
+ ## Phase 3: Work
4271
4326
 
4272
4327
  Execute implementation through agent teams using TDD.
4273
4328
 
@@ -4276,7 +4331,7 @@ Execute implementation through agent teams using TDD.
4276
4331
  - Commit incrementally as tests pass
4277
4332
  - Run \`/implementation-reviewer\` before closing tasks
4278
4333
 
4279
- ### Phase 4: Review
4334
+ ## Phase 4: Review
4280
4335
 
4281
4336
  Multi-agent code review with severity classification.
4282
4337
 
@@ -4285,7 +4340,7 @@ Multi-agent code review with severity classification.
4285
4340
  - Classify findings as P1/P2/P3
4286
4341
  - Fix all P1 findings before proceeding
4287
4342
 
4288
- ### Phase 5: Compound
4343
+ ## Phase 5: Compound
4289
4344
 
4290
4345
  Extract and store lessons learned. This is what makes the system compound.
4291
4346
 
@@ -4296,14 +4351,85 @@ Extract and store lessons learned. This is what makes the system compound.
4296
4351
 
4297
4352
  ---
4298
4353
 
4299
- ## 4. CLI reference
4354
+ ## LFG orchestrator
4355
+
4356
+ \`/compound:lfg\` chains all 5 phases with enforcement gates.
4357
+
4358
+ ### Invocation
4359
+
4360
+ \`\`\`
4361
+ /compound:lfg <epic-id>
4362
+ /compound:lfg <epic-id> from plan
4363
+ \`\`\`
4364
+
4365
+ ### Phase execution protocol
4366
+
4367
+ For each phase, LFG:
4368
+
4369
+ 1. Announces progress: \`[Phase N/5] PHASE_NAME\`
4370
+ 2. Initializes state: \`npx ca phase-check start <phase>\`
4371
+ 3. Reads the phase skill file (non-negotiable -- never from memory)
4372
+ 4. Runs \`npx ca search\` with the current goal
4373
+ 5. Executes the phase following skill instructions
4374
+ 6. Updates epic notes: \`bd update <epic-id> --notes="Phase: NAME COMPLETE | Next: NEXT"\`
4375
+ 7. Verifies the phase gate before proceeding
4376
+
4377
+ ### Phase gates
4378
+
4379
+ | Gate | When | Verification |
4380
+ |------|------|-------------|
4381
+ | Post-plan | After Plan | \`bd list --status=open\` shows Review + Compound tasks |
4382
+ | Gate 3 | After Work | \`bd list --status=in_progress\` returns empty |
4383
+ | Gate 4 | After Review | \`/implementation-reviewer\` returned APPROVED |
4384
+ | Final | After Compound | \`npx ca verify-gates <epic-id>\` passes, \`pnpm test\` and \`pnpm lint\` pass |
4385
+
4386
+ If any gate fails, LFG stops. You must fix the issue before proceeding.
4387
+
4388
+ ### Resumption
4389
+
4390
+ If interrupted, LFG can resume:
4391
+
4392
+ 1. Run \`bd show <epic-id>\` and read the notes for phase state
4393
+ 2. Re-invoke with \`from <phase>\` to skip completed phases
4394
+
4395
+ ### Phase state tracking
4396
+
4397
+ LFG persists state in \`.claude/.ca-phase-state.json\`. Useful commands:
4398
+
4399
+ \`\`\`bash
4400
+ npx ca phase-check status # See current phase state
4401
+ npx ca phase-check clean # Reset phase state (escape hatch)
4402
+ \`\`\`
4403
+
4404
+ ### Session close
4405
+
4406
+ Before saying "done", LFG runs this inviolable checklist:
4407
+
4408
+ \`\`\`bash
4409
+ git status
4410
+ git add <files>
4411
+ bd sync
4412
+ git commit -m "..."
4413
+ bd sync
4414
+ git push
4415
+ \`\`\`
4416
+ `,
4417
+ "CLI_REFERENCE.md": `---
4418
+ version: "{{VERSION}}"
4419
+ last-updated: "{{DATE}}"
4420
+ summary: "Complete CLI command reference for compound-agent"
4421
+ ---
4422
+
4423
+ # CLI Reference
4300
4424
 
4301
4425
  All commands use \`npx ca\` (or \`npx compound-agent\`). Global flags: \`-v, --verbose\` and \`-q, --quiet\`.
4302
4426
 
4303
- ### Capture commands
4427
+ ---
4428
+
4429
+ ## Capture commands
4304
4430
 
4305
4431
  \`\`\`bash
4306
- # Capture a lesson (primary command for storing knowledge)
4432
+ # Capture a lesson (primary command)
4307
4433
  npx ca learn "Always validate epic IDs before shell execution" \\
4308
4434
  --trigger "Shell injection via bd show" \\
4309
4435
  --tags "security,validation" \\
@@ -4311,7 +4437,7 @@ npx ca learn "Always validate epic IDs before shell execution" \\
4311
4437
  --type lesson
4312
4438
 
4313
4439
  # Capture a pattern (requires --pattern-bad and --pattern-good)
4314
- npx ca learn "Use execFileSync instead of execSync for external commands" \\
4440
+ npx ca learn "Use execFileSync instead of execSync" \\
4315
4441
  --type pattern \\
4316
4442
  --pattern-bad "execSync(\\\`bd show \\\${id}\\\`)" \\
4317
4443
  --pattern-good "execFileSync('bd', ['show', id])"
@@ -4327,68 +4453,44 @@ npx ca detect --input corrections.json --save --yes
4327
4453
  **Types**: \`lesson\` (default), \`solution\`, \`pattern\`, \`preference\`
4328
4454
  **Severity**: \`high\`, \`medium\`, \`low\`
4329
4455
 
4330
- ### Retrieval commands
4456
+ ## Retrieval commands
4331
4457
 
4332
4458
  \`\`\`bash
4333
- # Keyword search
4334
- npx ca search "sqlite validation"
4459
+ npx ca search "sqlite validation" # Keyword search
4335
4460
  npx ca search "security" --limit 5
4336
-
4337
- # List all memory items
4338
- npx ca list
4461
+ npx ca list # List all memory items
4339
4462
  npx ca list --limit 20
4340
- npx ca list --invalidated # Show only invalidated items
4341
-
4342
- # Semantic search against a plan
4463
+ npx ca list --invalidated # Show only invalidated items
4343
4464
  npx ca check-plan --plan "Implement git worktree integration"
4344
- echo "Add caching layer" | npx ca check-plan
4345
-
4346
- # Load high-severity lessons for session context
4347
- npx ca load-session
4465
+ echo "Add caching layer" | npx ca check-plan # Semantic search against a plan
4466
+ npx ca load-session # Load high-severity lessons
4348
4467
  npx ca load-session --json
4349
4468
  \`\`\`
4350
4469
 
4351
- ### Management commands
4470
+ ## Management commands
4352
4471
 
4353
4472
  \`\`\`bash
4354
- # View a specific item
4355
- npx ca show <id>
4473
+ npx ca show <id> # View a specific item
4356
4474
  npx ca show <id> --json
4357
-
4358
- # Update item fields
4359
- npx ca update <id> --insight "Updated insight text"
4475
+ npx ca update <id> --insight "Updated text" # Update item fields
4360
4476
  npx ca update <id> --severity high --tags "security,input-validation"
4361
-
4362
- # Soft delete (creates tombstone)
4363
- npx ca delete <id>
4477
+ npx ca delete <id> # Soft delete (creates tombstone)
4364
4478
  npx ca delete <id1> <id2> <id3>
4365
-
4366
- # Mark as invalid (excluded from retrieval but preserved)
4367
- npx ca wrong <id> --reason "This advice was incorrect"
4368
-
4369
- # Re-enable an invalidated item
4370
- npx ca validate <id>
4371
-
4372
- # Export as JSON
4373
- npx ca export
4479
+ npx ca wrong <id> --reason "Incorrect" # Mark as invalid
4480
+ npx ca validate <id> # Re-enable an invalidated item
4481
+ npx ca export # Export as JSON
4374
4482
  npx ca export --since 2026-01-01 --tags "security"
4375
-
4376
- # Import from JSONL file
4377
- npx ca import lessons-backup.jsonl
4378
-
4379
- # Database maintenance
4380
- npx ca compact # Remove tombstones and archive old items
4381
- npx ca compact --dry-run # Preview without changes
4382
- npx ca compact --force # Compact even if below threshold
4383
- npx ca rebuild # Rebuild SQLite index from JSONL
4384
- npx ca rebuild --force # Force rebuild even if unchanged
4385
- npx ca stats # Show database health and statistics
4386
-
4387
- # Context recovery
4388
- npx ca prime # Reload workflow context after compaction
4483
+ npx ca import lessons-backup.jsonl # Import from JSONL file
4484
+ npx ca compact # Remove tombstones and archive old items
4485
+ npx ca compact --dry-run
4486
+ npx ca compact --force
4487
+ npx ca rebuild # Rebuild SQLite index from JSONL
4488
+ npx ca rebuild --force
4489
+ npx ca stats # Show database health and statistics
4490
+ npx ca prime # Reload workflow context after compaction
4389
4491
  \`\`\`
4390
4492
 
4391
- ### Setup commands
4493
+ ## Setup commands
4392
4494
 
4393
4495
  \`\`\`bash
4394
4496
  npx ca init # Initialize in current repo
@@ -4396,21 +4498,18 @@ npx ca init --skip-agents # Skip AGENTS.md and template installation
4396
4498
  npx ca init --skip-hooks # Skip git hook installation
4397
4499
  npx ca init --skip-claude # Skip Claude Code hooks
4398
4500
  npx ca init --json # Output result as JSON
4399
-
4400
4501
  npx ca setup # Full setup (init + model download)
4401
4502
  npx ca setup --update # Regenerate templates (preserves user files)
4402
4503
  npx ca setup --uninstall # Remove compound-agent integration
4403
4504
  npx ca setup --status # Show installation status
4404
4505
  npx ca setup --skip-model # Skip embedding model download
4405
-
4406
4506
  npx ca setup claude # Install Claude Code hooks only
4407
4507
  npx ca setup claude --status # Check hook status
4408
-
4409
4508
  npx ca hooks # Install git hooks
4410
4509
  npx ca download-model # Download embedding model (~278MB)
4411
4510
  \`\`\`
4412
4511
 
4413
- ### Reviewer commands
4512
+ ## Reviewer commands
4414
4513
 
4415
4514
  \`\`\`bash
4416
4515
  npx ca reviewer enable gemini # Enable Gemini as external reviewer
@@ -4419,11 +4518,10 @@ npx ca reviewer disable gemini # Disable a reviewer
4419
4518
  npx ca reviewer list # List enabled reviewers
4420
4519
  \`\`\`
4421
4520
 
4422
- ### Loop command
4521
+ ## Loop command
4423
4522
 
4424
4523
  \`\`\`bash
4425
- # Generate an infinity loop script for autonomous epic processing
4426
- npx ca loop
4524
+ npx ca loop # Generate infinity loop script for autonomous processing
4427
4525
  npx ca loop --epics epic-1 epic-2
4428
4526
  npx ca loop --output my-loop.sh
4429
4527
  npx ca loop --max-retries 5
@@ -4431,22 +4529,15 @@ npx ca loop --model claude-opus-4-6
4431
4529
  npx ca loop --force # Overwrite existing script
4432
4530
  \`\`\`
4433
4531
 
4434
- ### Health and audit commands
4532
+ ## Health, audit, and verification commands
4435
4533
 
4436
4534
  \`\`\`bash
4535
+ npx ca version-show # Show version with animation and recent changelog
4437
4536
  npx ca doctor # Check external dependencies and project health
4438
4537
  npx ca audit # Run pattern, rule, and lesson quality checks
4439
4538
  npx ca rules check # Check codebase against .claude/rules.json
4440
4539
  npx ca test-summary # Run tests and output compact pass/fail summary
4441
- \`\`\`
4442
-
4443
- ### Verification commands
4444
-
4445
- \`\`\`bash
4446
- # Verify workflow gates before epic closure
4447
- npx ca verify-gates <epic-id>
4448
-
4449
- # Phase state management (used by LFG workflow)
4540
+ npx ca verify-gates <epic-id> # Verify workflow gates before epic closure
4450
4541
  npx ca phase-check init <epic-id>
4451
4542
  npx ca phase-check status
4452
4543
  npx ca phase-check start <phase>
@@ -4454,39 +4545,37 @@ npx ca phase-check gate <gate-name> # post-plan, gate-3, gate-4, final
4454
4545
  npx ca phase-check clean
4455
4546
  \`\`\`
4456
4547
 
4457
- ### Worktree commands
4548
+ ## Worktree commands
4458
4549
 
4459
4550
  \`\`\`bash
4460
- # Create an isolated worktree for an epic
4461
- npx ca worktree create <epic-id>
4462
-
4463
- # Connect merge dependencies
4464
- npx ca worktree wire-deps <epic-id>
4465
-
4466
- # Merge worktree back to main (two-phase: resolve in worktree, land on main)
4467
- npx ca worktree merge <epic-id>
4468
-
4469
- # List active worktrees
4470
- npx ca worktree list
4471
-
4472
- # Remove worktree and clean up
4473
- npx ca worktree cleanup <epic-id>
4474
- npx ca worktree cleanup <epic-id> --force # Force cleanup of dirty worktrees
4551
+ npx ca worktree create <epic-id> # Create isolated worktree
4552
+ npx ca worktree wire-deps <epic-id> # Connect merge dependencies
4553
+ npx ca worktree merge <epic-id> # Merge worktree back to main
4554
+ npx ca worktree list # List active worktrees
4555
+ npx ca worktree cleanup <epic-id> # Remove worktree and clean up
4556
+ npx ca worktree cleanup <epic-id> --force # Force cleanup of dirty worktrees
4475
4557
  \`\`\`
4476
4558
 
4477
- ### Compound command
4559
+ ## Compound command
4478
4560
 
4479
4561
  \`\`\`bash
4480
- # Synthesize cross-cutting patterns from accumulated lessons
4481
- npx ca compound
4562
+ npx ca compound # Synthesize cross-cutting patterns from accumulated lessons
4482
4563
  \`\`\`
4483
-
4564
+ `,
4565
+ "SKILLS.md": `---
4566
+ version: "{{VERSION}}"
4567
+ last-updated: "{{DATE}}"
4568
+ summary: "Phase skills and agent role skills reference"
4484
4569
  ---
4485
4570
 
4486
- ## 5. Skills reference
4571
+ # Skills Reference
4487
4572
 
4488
4573
  Skills are instructions that Claude reads before executing each phase. They live in \`.claude/skills/compound/\` and are auto-installed by \`npx ca setup\`.
4489
4574
 
4575
+ ---
4576
+
4577
+ ## Phase skills
4578
+
4490
4579
  ### \`/compound:brainstorm\`
4491
4580
 
4492
4581
  **Purpose**: Divergent-then-convergent thinking to explore the solution space.
@@ -4533,7 +4622,7 @@ Skills are instructions that Claude reads before executing each phase. They live
4533
4622
 
4534
4623
  **When invoked**: When you want to run an entire epic end-to-end.
4535
4624
 
4536
- **What it does**: Sequences all 5 phases with mandatory gates between them, tracks progress in beads notes, handles resumption after interruption.
4625
+ **What it does**: Sequences all 5 phases with mandatory gates between them, tracks progress in beads notes, handles resumption after interruption. See [WORKFLOW.md](WORKFLOW.md) for full details.
4537
4626
 
4538
4627
  ### \`/compound:set-worktree\`
4539
4628
 
@@ -4545,150 +4634,42 @@ Skills are instructions that Claude reads before executing each phase. They live
4545
4634
 
4546
4635
  ---
4547
4636
 
4548
- ## 6. The LFG workflow
4549
-
4550
- \`/compound:lfg\` chains all 5 phases with enforcement gates. Here is how it works:
4551
-
4552
- ### Invocation
4553
-
4554
- \`\`\`
4555
- /compound:lfg <epic-id>
4556
- \`\`\`
4557
-
4558
- Or with a phase skip:
4559
-
4560
- \`\`\`
4561
- /compound:lfg <epic-id> from plan
4562
- \`\`\`
4563
-
4564
- ### Phase execution protocol
4565
-
4566
- For each phase, LFG:
4567
-
4568
- 1. Announces progress: \`[Phase N/5] PHASE_NAME\`
4569
- 2. Initializes state: \`npx ca phase-check start <phase>\`
4570
- 3. Reads the phase skill file (non-negotiable -- never from memory)
4571
- 4. Runs \`npx ca search\` with the current goal
4572
- 5. Executes the phase following skill instructions
4573
- 6. Updates epic notes: \`bd update <epic-id> --notes="Phase: NAME COMPLETE | Next: NEXT"\`
4574
- 7. Verifies the phase gate before proceeding
4575
-
4576
- ### Phase gates
4577
-
4578
- | Gate | When | Verification |
4579
- |------|------|-------------|
4580
- | Post-plan | After Plan | \`bd list --status=open\` shows Review + Compound tasks |
4581
- | Gate 3 | After Work | \`bd list --status=in_progress\` returns empty |
4582
- | Gate 4 | After Review | \`/implementation-reviewer\` returned APPROVED |
4583
- | Final | After Compound | \`npx ca verify-gates <epic-id>\` passes, \`pnpm test\` and \`pnpm lint\` pass |
4584
-
4585
- If any gate fails, LFG stops. You must fix the issue before proceeding.
4586
-
4587
- ### Resumption
4588
-
4589
- If interrupted, LFG can resume:
4590
-
4591
- 1. Run \`bd show <epic-id>\` and read the notes for phase state
4592
- 2. Re-invoke with \`from <phase>\` to skip completed phases
4593
-
4594
- ### Phase state tracking
4637
+ ## Skill invocation
4595
4638
 
4596
- LFG persists state in \`.claude/.ca-phase-state.json\`. Useful commands:
4639
+ Skills are invoked as Claude Code slash commands:
4597
4640
 
4598
- \`\`\`bash
4599
- npx ca phase-check status # See current phase state
4600
- npx ca phase-check clean # Reset phase state (escape hatch)
4601
4641
  \`\`\`
4602
-
4603
- ### Session close
4604
-
4605
- Before saying "done", LFG runs this inviolable checklist:
4606
-
4607
- \`\`\`bash
4608
- git status
4609
- git add <files>
4610
- bd sync
4611
- git commit -m "..."
4612
- bd sync
4613
- git push
4642
+ /compound:brainstorm # Start brainstorm phase
4643
+ /compound:plan # Start plan phase
4644
+ /compound:work # Start work phase
4645
+ /compound:review # Start review phase
4646
+ /compound:compound # Start compound phase
4647
+ /compound:lfg <epic-id> # Run all phases end-to-end
4648
+ /compound:set-worktree <epic-id> # Set up worktree before LFG
4614
4649
  \`\`\`
4615
4650
 
4651
+ Each skill reads its SKILL.md file from \`.claude/skills/compound/<phase>/SKILL.md\` at invocation time. Skills are never executed from memory.
4652
+ `,
4653
+ "INTEGRATION.md": `---
4654
+ version: "{{VERSION}}"
4655
+ last-updated: "{{DATE}}"
4656
+ summary: "Memory system, hooks, beads integration, and agent guidance"
4616
4657
  ---
4617
4658
 
4618
- ## 7. Worktree integration
4619
-
4620
- Worktrees let you run epics in isolation, enabling parallel execution across multiple Claude Code sessions.
4621
-
4622
- ### Creating a worktree
4623
-
4624
- \`\`\`bash
4625
- npx ca worktree create <epic-id>
4626
- \`\`\`
4627
-
4628
- This:
4629
-
4630
- 1. Creates a git worktree at \`../<repo>-wt-<epic-id>\` on branch \`epic/<epic-id>\`
4631
- 2. Installs dependencies via \`pnpm install --frozen-lockfile\`
4632
- 3. Copies \`.claude/lessons/index.jsonl\` to the worktree
4633
- 4. Runs \`npx ca setup --skip-model\` in the worktree
4634
- 5. Creates a Merge beads task linked to the epic
4635
-
4636
- ### Using with LFG
4637
-
4638
- \`\`\`bash
4639
- # From main repo:
4640
- npx ca worktree create my-epic-id
4641
-
4642
- # Then in the worktree directory:
4643
- # Run /compound:lfg or /compound:set-worktree followed by /compound:lfg
4644
- \`\`\`
4645
-
4646
- Or use the skill:
4647
-
4648
- \`\`\`
4649
- /compound:set-worktree <epic-id>
4650
- \`\`\`
4651
-
4652
- ### Merging back
4653
-
4654
- When all work tasks complete, the Merge task surfaces via \`bd ready\`:
4655
-
4656
- \`\`\`bash
4657
- npx ca worktree merge <epic-id>
4658
- \`\`\`
4659
-
4660
- This runs a two-phase merge:
4659
+ # Integration
4661
4660
 
4662
- 1. Merges \`main\` into the worktree branch (resolve conflicts there)
4663
- 2. Fast-forwards \`main\` to the worktree branch (clean landing)
4664
-
4665
- ### Cleanup
4666
-
4667
- \`\`\`bash
4668
- npx ca worktree cleanup <epic-id>
4669
- npx ca worktree cleanup <epic-id> --force # For dirty worktrees
4670
- \`\`\`
4671
-
4672
- This removes the worktree directory, deletes the branch, and closes the Merge task.
4673
-
4674
- ### Listing worktrees
4675
-
4676
- \`\`\`bash
4677
- npx ca worktree list
4678
- \`\`\`
4679
-
4680
- Shows active worktrees with their epic and merge task status.
4661
+ Deep integration topics for compound-agent: memory system internals, Claude Code hooks, beads workflow, worktree integration, and agent guidance.
4681
4662
 
4682
4663
  ---
4683
4664
 
4684
- ## 8. Memory system
4665
+ ## Memory system
4685
4666
 
4686
4667
  ### Storage format
4687
4668
 
4688
4669
  Memory items are stored as newline-delimited JSON in \`.claude/lessons/index.jsonl\`. Each line is a complete JSON object:
4689
4670
 
4690
4671
  \`\`\`json
4691
- {"id":"L-abc123","type":"lesson","trigger":"Shell injection via execSync","insight":"Use execFileSync with array args to prevent shell interpretation","tags":["security"],"source":"manual","context":{"tool":"cli","intent":"manual learning"},"created":"2026-02-15T10:00:00Z","confirmed":true,"severity":"high","supersedes":[],"related":[]}
4672
+ {"id":"L-abc123","type":"lesson","trigger":"Shell injection via execSync","insight":"Use execFileSync with array args","tags":["security"],"source":"manual","context":{"tool":"cli","intent":"manual learning"},"created":"2026-02-15T10:00:00Z","confirmed":true,"severity":"high","supersedes":[],"related":[]}
4692
4673
  \`\`\`
4693
4674
 
4694
4675
  ### Indexing
@@ -4709,14 +4690,6 @@ The index is rebuilt automatically when the JSONL changes. Force rebuild with \`
4709
4690
 
4710
4691
  **Session loading** (\`npx ca load-session\`): Returns high-severity confirmed lessons for injection at session start.
4711
4692
 
4712
- ### Compounding (pattern synthesis)
4713
-
4714
- \`\`\`bash
4715
- npx ca compound
4716
- \`\`\`
4717
-
4718
- This reads all memory items, computes embeddings, clusters them by similarity, and synthesizes cross-cutting patterns into \`.claude/lessons/cct-patterns.jsonl\`. Clusters with 2+ items become patterns; single-item clusters are filtered as noise.
4719
-
4720
4693
  ### Data lifecycle
4721
4694
 
4722
4695
  | Operation | Effect |
@@ -4729,21 +4702,7 @@ This reads all memory items, computes embeddings, clusters them by similarity, a
4729
4702
 
4730
4703
  ---
4731
4704
 
4732
- ## 9. For AI agents
4733
-
4734
- ### Integrating into CLAUDE.md
4735
-
4736
- Add a reference to compound-agent in your project's \`.claude/CLAUDE.md\`:
4737
-
4738
- \`\`\`markdown
4739
- ## References
4740
-
4741
- - docs/compound/HOW_TO_COMPOUND.md -- Usage guide for humans and AI agents
4742
- \`\`\`
4743
-
4744
- The \`npx ca init\` command does this automatically.
4745
-
4746
- ### Claude Code hooks
4705
+ ## Claude Code hooks
4747
4706
 
4748
4707
  Compound-agent installs five hooks into \`.claude/settings.json\`:
4749
4708
 
@@ -4751,7 +4710,7 @@ Compound-agent installs five hooks into \`.claude/settings.json\`:
4751
4710
  |------|---------|--------|
4752
4711
  | **SessionStart** | New session or resume | Runs \`npx ca prime\` to load workflow context and high-severity lessons |
4753
4712
  | **PreCompact** | Before context compaction | Runs \`npx ca prime\` to preserve context across compaction |
4754
- | **UserPromptSubmit** | Every user message | Detects correction language ("actually", "wrong") and planning language ("implement", "build"), injects memory reminders |
4713
+ | **UserPromptSubmit** | Every user message | Detects correction/planning language, injects memory reminders |
4755
4714
  | **PostToolUseFailure** | Bash/Edit/Write failures | After 2 failures on same file or 3 total, suggests \`npx ca search\` |
4756
4715
  | **PostToolUse** | After successful tool use | Resets failure tracking; tracks skill file reads for phase guard |
4757
4716
 
@@ -4778,7 +4737,9 @@ npx ca learn "The insight" --trigger "What happened" --severity medium
4778
4737
  npx ca compound
4779
4738
  \`\`\`
4780
4739
 
4781
- ### Beads workflow integration
4740
+ ---
4741
+
4742
+ ## Beads integration
4782
4743
 
4783
4744
  Compound-agent works with beads (\`bd\`) for issue tracking:
4784
4745
 
@@ -4801,11 +4762,38 @@ Before closing an epic, verify all gates pass:
4801
4762
  npx ca verify-gates <epic-id>
4802
4763
  \`\`\`
4803
4764
 
4804
- This checks that:
4765
+ This checks that a Review task, Compound task, and (if applicable) Merge task all exist and are closed.
4766
+
4767
+ ---
4768
+
4769
+ ## Worktree integration
4770
+
4771
+ Worktrees let you run epics in isolation, enabling parallel execution across multiple Claude Code sessions.
4772
+
4773
+ \`\`\`bash
4774
+ npx ca worktree create <epic-id> # Creates worktree + installs deps + copies lessons
4775
+ npx ca worktree merge <epic-id> # Two-phase merge back to main
4776
+ npx ca worktree cleanup <epic-id> # Remove worktree, delete branch, close Merge task
4777
+ npx ca worktree list # Show active worktrees
4778
+ \`\`\`
4779
+
4780
+ See [CLI_REFERENCE.md](CLI_REFERENCE.md) for full worktree command details.
4805
4781
 
4806
- 1. A Review task exists and is closed
4807
- 2. A Compound task exists and is closed
4808
- 3. If a Merge task exists (worktree epic), it is also closed
4782
+ ---
4783
+
4784
+ ## For AI agents
4785
+
4786
+ ### Integrating into CLAUDE.md
4787
+
4788
+ Add a reference to compound-agent in your project's \`.claude/CLAUDE.md\`:
4789
+
4790
+ \`\`\`markdown
4791
+ ## References
4792
+
4793
+ - docs/compound/README.md -- Compound-agent overview and getting started
4794
+ \`\`\`
4795
+
4796
+ The \`npx ca init\` command does this automatically.
4809
4797
 
4810
4798
  ### Session completion checklist
4811
4799
 
@@ -5386,12 +5374,18 @@ Synthesize analysis results into a refined optimization plan:
5386
5374
  - Estimate impact on test suite speed and coverage
5387
5375
  - Iterate with subagents until the plan is comprehensive
5388
5376
 
5389
- ### Phase 3: Adversarial Review
5377
+ ### Phase 3: Adversarial Review (CRITICAL QUALITY GATE)
5378
+ **This is THE KEY PHASE -- the most important phase in the entire workflow. NEVER skip, NEVER rush, NEVER settle for "good enough."**
5379
+
5390
5380
  Expose the plan to two neutral reviewer subagents:
5391
5381
  - **Reviewer A** (Opus): Independent critique of the optimization plan
5392
5382
  - **Reviewer B** (Sonnet): Independent critique from a different perspective
5383
+
5393
5384
  Both reviewers challenge assumptions, identify risks, and suggest improvements.
5394
- Iterate: adapt the plan based on feedback until confident.
5385
+
5386
+ **Mandatory iteration loop**: After each reviewer pass, if ANY issues, concerns, or suggestions remain from EITHER reviewer, revise the plan and re-submit to BOTH reviewers. Repeat until BOTH reviewers explicitly approve with ZERO reservations. Do not proceed to Phase 4 until unanimous, unconditional approval is reached.
5387
+
5388
+ This is the critical quality gate. Loop as many times as needed. The test suite must be bulletproof before execution begins.
5395
5389
 
5396
5390
  ### Phase 4: Execution
5397
5391
  Apply the agreed changes:
@@ -5417,13 +5411,13 @@ Apply the agreed changes:
5417
5411
  ## Common Pitfalls
5418
5412
  - Deleting tests without verifying coverage is maintained elsewhere
5419
5413
  - Optimizing for speed at the cost of correctness
5420
- - Not running the adversarial review (skipping Phase 3)
5414
+ - Settling for partial approval or cutting the Phase 3 review loop short before BOTH reviewers approve with zero reservations
5421
5415
  - Making changes without machine-readable output
5422
5416
  - Not feeding results back into compound-agent memory
5423
5417
 
5424
5418
  ## Quality Criteria
5425
5419
  - All 5 phases completed (analysis, planning, review, execution, verification)
5426
- - Adversarial review with 2 independent reviewers was conducted
5420
+ - Both adversarial reviewers approved with zero reservations after iterative refinement
5427
5421
  - Machine-readable output format used throughout
5428
5422
  - Full test suite passes after changes
5429
5423
  - Coverage not degraded
@@ -5726,7 +5720,7 @@ async function stripHeadersRecursive(dir, dryRun = false) {
5726
5720
  return count;
5727
5721
  }
5728
5722
  async function upgradeDocVersion(repoRoot, newVersion, dryRun = false) {
5729
- const docPath = join(repoRoot, "docs", "compound", "HOW_TO_COMPOUND.md");
5723
+ const docPath = join(repoRoot, "docs", "compound", "README.md");
5730
5724
  if (!existsSync(docPath)) return false;
5731
5725
  const content = await readFile(docPath, "utf-8");
5732
5726
  const updated = content.replace(/^(version: ")([^"]+)(")/m, `$1${newVersion}$3`);
@@ -5872,6 +5866,10 @@ async function runUpdate(repoRoot, dryRun) {
5872
5866
  for (const [name, content] of Object.entries(AGENT_ROLE_SKILLS)) {
5873
5867
  await processFile(join(repoRoot, ".claude", "skills", "compound", "agents", name, "SKILL.md"), content);
5874
5868
  }
5869
+ for (const [filename, template] of Object.entries(DOC_TEMPLATES)) {
5870
+ const content = template.replace("{{VERSION}}", VERSION).replace("{{DATE}}", (/* @__PURE__ */ new Date()).toISOString().slice(0, 10));
5871
+ await processFile(join(repoRoot, "docs", "compound", filename), content);
5872
+ }
5875
5873
  for (const filename of LEGACY_ROOT_SLASH_COMMANDS) {
5876
5874
  const filePath = join(repoRoot, ".claude", "commands", filename);
5877
5875
  if (existsSync(filePath)) {
@@ -5881,6 +5879,14 @@ async function runUpdate(repoRoot, dryRun) {
5881
5879
  }
5882
5880
  }
5883
5881
  }
5882
+ const oldDocPath = join(repoRoot, "docs", "compound", "HOW_TO_COMPOUND.md");
5883
+ if (existsSync(oldDocPath)) {
5884
+ const oldContent = await readFile(oldDocPath, "utf-8");
5885
+ if (oldContent.startsWith("---\nversion:")) {
5886
+ if (!dryRun) await rm(oldDocPath);
5887
+ updated++;
5888
+ }
5889
+ }
5884
5890
  let configUpdated = false;
5885
5891
  if (!dryRun) {
5886
5892
  const { hooks } = await configureClaudeSettings();
@@ -5895,11 +5901,12 @@ var MODEL_STATUS_MSG = {
5895
5901
  already_exists: "Already exists",
5896
5902
  failed: "Download failed (run `ca download-model` manually)"
5897
5903
  };
5898
- async function printSetupResult(result, quiet) {
5904
+ async function printSetupResult(result, quiet, repoRoot) {
5899
5905
  if (!quiet) {
5900
- if (result.scope.isUserScope) console.log(` ${result.scope.message}`);
5901
- if (!result.beads.available) console.log(` ${result.beads.message}`);
5902
- if (result.upgrade?.isUpgrade) console.log(` ${result.upgrade.message}`);
5906
+ if (result.upgrade?.isUpgrade) {
5907
+ console.log(` ${result.upgrade.message}`);
5908
+ console.log(" Tip: Run with --update to regenerate managed files with latest templates.");
5909
+ }
5903
5910
  if (process.stdout.isTTY) await playInstallBanner();
5904
5911
  }
5905
5912
  out.success("Compound agent setup complete");
@@ -5910,6 +5917,9 @@ async function printSetupResult(result, quiet) {
5910
5917
  printPnpmConfigStatus(result.pnpmConfig);
5911
5918
  printGitignoreStatus(result.gitignore);
5912
5919
  console.log(` Model: ${MODEL_STATUS_MSG[result.model]}`);
5920
+ const fullBeads = runFullBeadsCheck(repoRoot);
5921
+ printBeadsFullStatus(fullBeads);
5922
+ printScopeStatus(result.scope);
5913
5923
  console.log("\nNext steps:\n 1. Restart Claude Code to load hooks\n 2. Use `npx ca search` and `npx ca learn` commands");
5914
5924
  }
5915
5925
  function registerSetupAllCommand(setupCommand) {
@@ -5931,6 +5941,7 @@ function registerSetupAllCommand(setupCommand) {
5931
5941
  return;
5932
5942
  }
5933
5943
  if (options.update) {
5944
+ if (!dryRun && process.stdout.isTTY) await playInstallBanner();
5934
5945
  const result2 = await runUpdate(repoRoot, dryRun);
5935
5946
  const prefix = dryRun ? "[dry-run] " : "";
5936
5947
  if (result2.upgrade.isUpgrade) {
@@ -5946,6 +5957,10 @@ function registerSetupAllCommand(setupCommand) {
5946
5957
  console.log(` ${prefix}.gitignore: Added [${result2.gitignore.added.join(", ")}]`);
5947
5958
  }
5948
5959
  if (result2.configUpdated) console.log(` ${prefix}Config: hooks updated`);
5960
+ const fullBeads = runFullBeadsCheck(repoRoot);
5961
+ printBeadsFullStatus(fullBeads);
5962
+ const scope = checkUserScope(repoRoot);
5963
+ printScopeStatus(scope);
5949
5964
  return;
5950
5965
  }
5951
5966
  if (options.status) {
@@ -5954,7 +5969,7 @@ function registerSetupAllCommand(setupCommand) {
5954
5969
  }
5955
5970
  const result = await runSetup({ skipModel: options.skipModel, skipHooks: options.skipHooks });
5956
5971
  const { quiet } = getGlobalOpts(this);
5957
- await printSetupResult(result, quiet);
5972
+ await printSetupResult(result, quiet, repoRoot);
5958
5973
  });
5959
5974
  }
5960
5975
  async function handleStatus(alreadyInstalled, displayPath, settingsPath, options) {
@@ -6175,18 +6190,14 @@ async function initAction(cmd, options) {
6175
6190
  const repoRoot = getRepoRoot();
6176
6191
  const { quiet } = getGlobalOpts(cmd);
6177
6192
  const scopeResult = checkUserScope(repoRoot);
6178
- if (scopeResult.isUserScope && !quiet && !options.json) {
6179
- console.log(` ${scopeResult.message}`);
6180
- }
6181
- const beadsResult = checkBeadsAvailable();
6182
- if (!beadsResult.available && !quiet && !options.json) {
6183
- console.log(` ${beadsResult.message}`);
6184
- }
6185
6193
  let upgradeResult = null;
6186
6194
  if (options.update || detectExistingInstall(repoRoot)) {
6187
6195
  upgradeResult = await runUpgrade(repoRoot);
6188
6196
  if (!quiet && !options.json && upgradeResult.isUpgrade) {
6189
6197
  console.log(` ${upgradeResult.message}`);
6198
+ if (!options.update) {
6199
+ console.log(" Tip: Run with --update to regenerate managed files with latest templates.");
6200
+ }
6190
6201
  }
6191
6202
  }
6192
6203
  if (!quiet && !options.json && process.stdout.isTTY) {
@@ -6220,8 +6231,9 @@ async function initAction(cmd, options) {
6220
6231
  claudeHooksResult = await installClaudeHooksForInit(repoRoot);
6221
6232
  }
6222
6233
  const gitignoreResult = await ensureGitignore(repoRoot);
6234
+ const fullBeads = runFullBeadsCheck(repoRoot);
6223
6235
  if (options.json) {
6224
- printInitJson({ lessonsDir, agentsMdUpdated, hookResult, claudeHooksResult, pnpmConfig, beadsResult, scopeResult, upgradeResult, gitignoreResult });
6236
+ printInitJson({ lessonsDir, agentsMdUpdated, hookResult, claudeHooksResult, pnpmConfig, fullBeads, scopeResult, upgradeResult, gitignoreResult });
6225
6237
  return;
6226
6238
  }
6227
6239
  if (quiet) return;
@@ -6232,6 +6244,8 @@ async function initAction(cmd, options) {
6232
6244
  printClaudeHooksStatus(claudeHooksResult, options.skipClaude);
6233
6245
  printPnpmConfigStatus2(pnpmConfig);
6234
6246
  printGitignoreStatus(gitignoreResult);
6247
+ printBeadsFullStatus(fullBeads);
6248
+ printScopeStatus(scopeResult);
6235
6249
  }
6236
6250
  function printInitJson(ctx) {
6237
6251
  const claudeHooksInstalled = ctx.claudeHooksResult.action === "installed";
@@ -6244,7 +6258,9 @@ function printInitJson(ctx) {
6244
6258
  hookStatus: ctx.hookResult?.status ?? "skipped",
6245
6259
  claudeHooks: claudeHooksInstalled,
6246
6260
  pnpmConfig: ctx.pnpmConfig.isPnpm ? { added: ctx.pnpmConfig.added, alreadyConfigured: ctx.pnpmConfig.alreadyConfigured } : null,
6247
- beadsAvailable: ctx.beadsResult.available,
6261
+ beadsAvailable: ctx.fullBeads.cliAvailable,
6262
+ beadsInitialized: ctx.fullBeads.initialized,
6263
+ beadsHealthy: ctx.fullBeads.healthy,
6248
6264
  userScope: ctx.scopeResult.isUserScope,
6249
6265
  upgrade: ctx.upgradeResult ? { isUpgrade: ctx.upgradeResult.isUpgrade, removedCommands: ctx.upgradeResult.removedCommands, strippedHeaders: ctx.upgradeResult.strippedHeaders } : null,
6250
6266
  gitignore: ctx.gitignoreResult.added
@@ -6514,6 +6530,17 @@ function registerCrudCommands(program2) {
6514
6530
  await deleteAction(ids, options);
6515
6531
  });
6516
6532
  }
6533
+ function checkGitignoreHealth(repoRoot) {
6534
+ const gitignorePath = join(repoRoot, ".gitignore");
6535
+ if (!existsSync(gitignorePath)) return false;
6536
+ try {
6537
+ const content = readFileSync(gitignorePath, "utf-8");
6538
+ const lines = new Set(content.split("\n").map((l) => l.trim()));
6539
+ return ["node_modules/", ".claude/.cache/"].every((p) => lines.has(p));
6540
+ } catch {
6541
+ return false;
6542
+ }
6543
+ }
6517
6544
  async function runDoctor(repoRoot) {
6518
6545
  const checks = [];
6519
6546
  const claudeDir = join(repoRoot, ".claude");
@@ -6540,20 +6567,21 @@ async function runDoctor(repoRoot) {
6540
6567
  checks.push(modelOk ? { name: "Embedding model", status: "pass" } : { name: "Embedding model", status: "warn", fix: "Run: npx ca download-model" });
6541
6568
  const beadsResult = checkBeadsAvailable();
6542
6569
  checks.push(beadsResult.available ? { name: "Beads CLI", status: "pass" } : { name: "Beads CLI", status: "warn", fix: "Install beads: https://github.com/Nathandela/beads" });
6543
- const gitignorePath = join(repoRoot, ".gitignore");
6544
- const requiredPatterns = ["node_modules/", ".claude/.cache/"];
6545
- let gitignoreOk = false;
6546
- if (existsSync(gitignorePath)) {
6570
+ checks.push(checkGitignoreHealth(repoRoot) ? { name: ".gitignore health", status: "pass" } : { name: ".gitignore health", status: "warn", fix: "Run: npx ca setup --update" });
6571
+ const docPath = join(repoRoot, "docs", "compound", "README.md");
6572
+ checks.push(existsSync(docPath) ? { name: "Usage documentation", status: "pass" } : { name: "Usage documentation", status: "warn", fix: "Run: npx ca setup" });
6573
+ const beadsDir = join(repoRoot, ".beads");
6574
+ checks.push(existsSync(beadsDir) ? { name: "Beads initialized", status: "pass" } : { name: "Beads initialized", status: "warn", fix: "Run: bd init" });
6575
+ if (beadsResult.available && existsSync(beadsDir)) {
6547
6576
  try {
6548
- const content = readFileSync(gitignorePath, "utf-8");
6549
- const lines = new Set(content.split("\n").map((l) => l.trim()));
6550
- gitignoreOk = requiredPatterns.every((p) => lines.has(p));
6577
+ execSync("bd doctor", { cwd: repoRoot, shell: "/bin/sh", stdio: "pipe" });
6578
+ checks.push({ name: "Beads healthy", status: "pass" });
6551
6579
  } catch {
6580
+ checks.push({ name: "Beads healthy", status: "warn", fix: "Run: bd doctor" });
6552
6581
  }
6553
6582
  }
6554
- checks.push(gitignoreOk ? { name: ".gitignore health", status: "pass" } : { name: ".gitignore health", status: "warn", fix: "Run: npx ca setup --update" });
6555
- const docPath = join(repoRoot, "docs", "compound", "HOW_TO_COMPOUND.md");
6556
- checks.push(existsSync(docPath) ? { name: "Usage documentation", status: "pass" } : { name: "Usage documentation", status: "warn", fix: "Run: npx ca setup" });
6583
+ const scope = checkUserScope(repoRoot);
6584
+ checks.push(!scope.isUserScope ? { name: "Codebase scope", status: "pass" } : { name: "Codebase scope", status: "warn", fix: "Install in a specific repository, not home directory" });
6557
6585
  return checks;
6558
6586
  }
6559
6587
  var STATUS_ICONS = {
@@ -7335,6 +7363,99 @@ function registerVerifyGatesCommand(program2) {
7335
7363
  }
7336
7364
  });
7337
7365
  }
7366
+
7367
+ // src/changelog-data.ts
7368
+ var CHANGELOG_RECENT = `## [1.3.1] - 2026-02-21
7369
+
7370
+ ### Added
7371
+
7372
+ - **\`ca version-show\` command**: Displays version with terminal animation (tendril growth) and recent changelog entries. Non-TTY environments get plain text output. Changelog is embedded at build time from CHANGELOG.md.
7373
+ - **3 new doctor checks**: Beads initialized (\`.beads/\` dir), beads healthy (\`bd doctor\`), codebase scope (user-scope detection)
7374
+ - **Beads + scope status in init/setup output**: Full beads health display (CLI available, initialized, healthy) and scope status shown after \`ca init\`, \`ca setup\`, and \`ca setup --update\`
7375
+ - **Banner on \`--update\`**: Terminal art animation now plays during \`ca setup --update\` and \`ca init --update\` (same TTY/quiet guards as fresh install)
7376
+
7377
+ ### Changed
7378
+
7379
+ - **Split documentation**: \`HOW_TO_COMPOUND.md\` replaced by 5 focused documents in \`docs/compound/\`: \`README.md\`, \`WORKFLOW.md\`, \`CLI_REFERENCE.md\`, \`SKILLS.md\`, \`INTEGRATION.md\`
7380
+ - **Test-cleaner Phase 3 strengthened**: Adversarial review phase now mandates iteration loop until both reviewers give unconditional approval. Heading, emphasis, and quality criteria updated.
7381
+ - **Update hint on upgrade**: When \`ca init\` or \`ca setup\` detects an existing install, displays tip to run with \`--update\` to regenerate managed files
7382
+ - **HOW_TO_COMPOUND.md migration**: \`ca setup --update\` automatically removes old monolithic \`HOW_TO_COMPOUND.md\` if it has version frontmatter (generated by compound-agent)
7383
+ - **Doctor doc check**: Now checks for \`docs/compound/README.md\` instead of \`HOW_TO_COMPOUND.md\`
7384
+
7385
+ ## [1.3.0] - 2026-02-21
7386
+
7387
+ ### Added
7388
+
7389
+ - **Setup hardening**: Four new pre-flight checks during \`ca init\` and \`ca setup\`:
7390
+ - **Beads CLI check** (\`beads-check.ts\`): Detects if \`bd\` is available, shows install URL if missing (informational, non-blocking)
7391
+ - **User-scope detection** (\`scope-check.ts\`): Warns when installing at home directory level where lessons are shared across projects
7392
+ - **.gitignore injection** (\`gitignore.ts\`): Ensures \`node_modules/\` and \`.claude/.cache/\` patterns exist in \`.gitignore\`
7393
+ - **Upgrade detection** (\`upgrade.ts\`): Detects existing installs and runs migration pipeline (deprecated command removal, header stripping, doc version update)
7394
+ - **Upgrade engine**: Automated migration from v1.2.x to v1.3.0:
7395
+ - Removes 5 deprecated CLI wrapper commands (\`search.md\`, \`list.md\`, \`show.md\`, \`stats.md\`, \`wrong.md\`)
7396
+ - Strips legacy \`<!-- generated by compound-agent -->\` headers from installed files
7397
+ - Updates \`HOW_TO_COMPOUND.md\` version during upgrade
7398
+ - **\`/compound:research\` skill**: PhD-depth research producing structured survey documents following \`TEMPLATE_FOR_RESEARCH.md\` format
7399
+ - **\`/compound:test-clean\` skill**: 5-phase test suite optimization with adversarial review (audit, design, implement, verify, report)
7400
+ - **Documentation template**: \`HOW_TO_COMPOUND.md\` deployed to \`docs/compound/\` during setup with version and date placeholders
7401
+ - **Test scripts**: \`test:segment\` (run tests for specific module), \`test:random\` (seeded random subset), \`test:critical\` (*.critical.test.ts convention)
7402
+ - **3 new doctor checks**: Beads CLI availability, \`.gitignore\` health, usage documentation presence
7403
+
7404
+ ### Fixed
7405
+
7406
+ - **\`setup --update --dry-run\` no longer mutates files**: \`runUpgrade()\` now accepts a \`dryRun\` parameter propagated to all sub-functions (removeDeprecatedCommands, stripGeneratedHeaders, upgradeDocVersion)
7407
+ - **\`setup --uninstall\` respects plugin.json ownership**: Checks \`name === "compound-agent"\` before deleting; user-owned plugin manifests are preserved
7408
+ - **Upgrade ownership guard**: \`removeDeprecatedCommands\` checks file content for compound-agent markers before deleting, preventing silent removal of user-authored files with the same name
7409
+ - **Malformed settings.json no longer silently clobbered**: On parse error, \`configureClaudeSettings\` warns and skips instead of overwriting with empty config
7410
+
7411
+ ### Changed
7412
+
7413
+ - **\`setup --update\` overhaul**: Now uses path-based file detection (compound/ = managed) instead of marker-based. Runs upgrade pipeline and \`.gitignore\` remediation during update
7414
+ - **JSON-first \`bd\` parsing in loop**: \`jq\` primary with \`python3\` fallback via \`parse_json()\` helper
7415
+ - **CLI test helpers hardened**: Replaced shell string interpolation with \`execFileSync\` for safety and reliability
7416
+ - **Beads check portable**: Uses POSIX \`command -v\` instead of non-portable \`which\`
7417
+ - **Template expansion**: Brainstorm and plan skills now cross-reference researcher skill; 9 total skills, 11 total commands
7418
+ - **Code organization**: Extracted display utilities to \`display-utils.ts\`, uninstall logic to \`uninstall.ts\`
7419
+
7420
+ ### Removed
7421
+
7422
+ - **5 deprecated CLI wrapper commands**: \`search.md\`, \`list.md\`, \`show.md\`, \`stats.md\`, \`wrong.md\` (redundant wrappers around \`npx ca <cmd>\`)
7423
+ - **\`GENERATED_MARKER\` on new installs**: New installs use path-based detection; marker retained only for backward-compatible \`--update\` detection
7424
+
7425
+ ## [1.2.11] - 2026-02-19
7426
+
7427
+ ### Added
7428
+
7429
+ - **Git worktree integration** (\`ca worktree\`): Isolate epic work in separate git worktrees for parallel execution. Five subcommands:
7430
+ - \`ca worktree create <epic-id>\` \u2014 Create worktree, install deps, copy lessons, create Merge beads task
7431
+ - \`ca worktree wire-deps <epic-id>\` \u2014 Connect Review/Compound tasks as merge blockers (graceful no-op without worktree)
7432
+ - \`ca worktree merge <epic-id>\` \u2014 Two-phase merge: resolve conflicts in worktree, then land clean on main
7433
+ - \`ca worktree list\` \u2014 Show active worktrees with epic and merge task status
7434
+ - \`ca worktree cleanup <epic-id>\` \u2014 Remove worktree, branch, and close Merge task (--force for dirty worktrees)
7435
+ - **\`/compound:set-worktree\` slash command**: Set up a worktree before running \`/compound:lfg\` for isolated epic execution
7436
+ - **Conditional Merge gate in \`verify-gates\`**: Worktree epics require the Merge task to be closed before epic closure. Non-worktree epics unaffected.
7437
+ - **Plan skill wire-deps step**: Plan phase now calls \`ca worktree wire-deps\` to connect merge dependencies when a worktree is active.
7438
+
7439
+ ### Changed
7440
+
7441
+ - **Worktree merge safety hardening**: Added branch verification (asserts main repo is on \`main\`), worktree existence guard, structured error messages with worktree paths for conflict resolution and test failures
7442
+ - **JSONL reconciliation**: Switched from ID-based to line-based deduplication to preserve last-write-wins semantics for same-ID updates and deletes
7443
+ - **Worktree cleanup safety**: Branch deletion uses \`-d\` (safe) by default; \`-D\` (force) only with \`--force\` flag
7444
+ - **Shared beads utilities**: Extracted \`validateEpicId\`, \`parseBdShowDeps\`, and \`shortId\` to \`cli-utils.ts\`, eliminating duplication between \`worktree.ts\` and \`verify-gates.ts\`
7445
+ - **Sync API**: All worktree functions are now synchronous (removed misleading \`async\` wrapper around purely synchronous \`execFileSync\` calls)`;
7446
+
7447
+ // src/commands/version-show.ts
7448
+ function registerVersionShowCommand(program2) {
7449
+ program2.command("version-show").description("Show version with animation and recent changelog").action(async () => {
7450
+ if (process.stdout.isTTY) {
7451
+ await playInstallBanner();
7452
+ } else {
7453
+ console.log(`compound-agent v${VERSION}`);
7454
+ }
7455
+ console.log("");
7456
+ console.log(CHANGELOG_RECENT);
7457
+ });
7458
+ }
7338
7459
  function parseWorktreeList(raw) {
7339
7460
  const entries = [];
7340
7461
  let currentPath = "";
@@ -8443,6 +8564,7 @@ function registerManagementCommands(program2) {
8443
8564
  registerRulesCommands(program2);
8444
8565
  registerTestSummaryCommand(program2);
8445
8566
  registerVerifyGatesCommand(program2);
8567
+ registerVersionShowCommand(program2);
8446
8568
  registerWorktreeCommands(program2);
8447
8569
  }
8448
8570