compound-agent 1.2.0 → 1.2.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/CHANGELOG.md CHANGED
@@ -9,6 +9,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
 
10
10
  ## [Unreleased]
11
11
 
12
+ ## [1.2.1] - 2026-02-15
13
+
14
+ ### Added
15
+
16
+ - **`ca verify-gates <epic-id>` command**: Verifies review and compound beads tasks exist and are closed before epic can be marked complete
17
+ - **Phase enforcement gates in `/compound:lfg`**: Mechanical STOP markers (`PHASE GATE 3`, `PHASE GATE 4`, `FINAL GATE`) between workflow phases prevent Claude from skipping review and compound phases
18
+ - **Per-phase MEMORY CHECK instructions**: Each of the 5 phases in lfg.md now has explicit `MEMORY CHECK` instructions for memory_search/memory_capture
19
+ - **Phase state tracking**: lfg.md tracks phase completion via `bd update --notes` with `Phase: COMPLETE` markers, surviving context compaction
20
+ - **SESSION CLOSE checklist in lfg.md**: Inviolable 8-step checklist at end of lfg workflow ensures bd sync and git push
21
+
22
+ ### Fixed
23
+
24
+ - **`ca setup --update` now ensures MCP config**: Previously only regenerated templates; now also calls `configureClaudeSettings()` to ensure `.mcp.json` and hooks are current for projects upgrading from older versions
25
+ - **`ca prime` warns when MCP server is missing**: Displays actionable warning with `Run 'npx ca setup'` when `.mcp.json` is not registered
26
+ - **work.md verification gate strengthened**: Replaced soft "Verification Gate" with `MANDATORY VERIFICATION` section requiring `/implementation-reviewer` APPROVED status
27
+ - **compound.md minimum capture requirement**: Added "At minimum, capture 1 lesson per significant decision" to prevent empty compound phases
28
+ - **plan.md post-plan verification**: Added `POST-PLAN VERIFICATION` section with grep checks for review and compound task creation
29
+
12
30
  ## [1.2.0] - 2026-02-15
13
31
 
14
32
  ### Added
@@ -438,7 +456,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
438
456
  - Vitest test suite
439
457
  - tsup build configuration
440
458
 
441
- [Unreleased]: https://github.com/Nathandela/learning_agent/compare/v1.2.0...HEAD
459
+ [Unreleased]: https://github.com/Nathandela/learning_agent/compare/v1.2.1...HEAD
460
+ [1.2.1]: https://github.com/Nathandela/learning_agent/compare/v1.2.0...v1.2.1
442
461
  [1.2.0]: https://github.com/Nathandela/learning_agent/compare/v1.1.0...v1.2.0
443
462
  [1.1.0]: https://github.com/Nathandela/learning_agent/compare/v1.0.0...v1.1.0
444
463
  [1.0.0]: https://github.com/Nathandela/learning_agent/compare/v0.2.9...v1.0.0
package/README.md CHANGED
@@ -166,6 +166,7 @@ The CLI binary is `ca` (alias: `compound-agent`).
166
166
  | `ca export` | Export items as JSON |
167
167
  | `ca import <file>` | Import items from JSONL file |
168
168
  | `ca prime` | Load workflow context (used by hooks) |
169
+ | `ca verify-gates <epic-id>` | Verify review + compound tasks exist and are closed |
169
170
  | `ca audit` | Run audit checks against the codebase |
170
171
  | `ca rules check` | Run repository-defined rule checks |
171
172
  | `ca test-summary` | Run tests and output a compact summary |
package/dist/cli.js CHANGED
@@ -2966,12 +2966,7 @@ Create a structured implementation plan enriched by semantic memory and existing
2966
2966
  5. Synthesize research findings from all agents into a coherent plan. Flag any conflicts between ADRs and proposed approach.
2967
2967
  6. Use \`AskUserQuestion\` to resolve ambiguities: unclear requirements, conflicting ADRs, or priority trade-offs that need user input before decomposing.
2968
2968
  7. Break the goal into concrete, ordered tasks with clear acceptance criteria.
2969
- 8. Create beads issues and map dependencies:
2970
- \`\`\`bash
2971
- bd create --title="<task>" --type=task --priority=<1-4>
2972
- bd dep add <dependent-task> <blocking-task>
2973
- \`\`\`
2974
- 9. **Create review and compound blocking tasks** so they survive compaction:
2969
+ 8. **Create review and compound blocking tasks** so they survive compaction:
2975
2970
  \`\`\`bash
2976
2971
  bd create --title="Review: /compound:review" --type=task --priority=1
2977
2972
  bd create --title="Compound: /compound:compound" --type=task --priority=1
@@ -2979,8 +2974,21 @@ Create a structured implementation plan enriched by semantic memory and existing
2979
2974
  bd dep add <compound-id> <review-id> # compound depends on review
2980
2975
  \`\`\`
2981
2976
  These tasks surface via \`bd ready\` after work completes, ensuring review and compound phases are never skipped \u2014 even after context compaction.
2977
+ 9. Create beads issues and map dependencies:
2978
+ \`\`\`bash
2979
+ bd create --title="<task>" --type=task --priority=<1-4>
2980
+ bd dep add <dependent-task> <blocking-task>
2981
+ \`\`\`
2982
2982
  10. Output the plan as a structured list with task IDs and dependency graph.
2983
2983
 
2984
+ ## POST-PLAN VERIFICATION -- MANDATORY
2985
+ After creating all tasks, verify review and compound tasks exist:
2986
+ \`\`\`bash
2987
+ bd list --status=open | grep 'Review:' # Must show a result
2988
+ bd list --status=open | grep 'Compound:' # Must show a result
2989
+ \`\`\`
2990
+ If either is missing, CREATE THEM NOW. The plan is NOT complete without these gates.
2991
+
2984
2992
  ## Memory Integration
2985
2993
  - Call \`memory_search\` before planning to learn from past approaches.
2986
2994
  - Search for architectural patterns relevant to the goal.
@@ -3007,7 +3015,7 @@ Execute implementation by delegating to an agent team. The lead coordinates and
3007
3015
  ## Workflow
3008
3016
  1. Parse task from \`$ARGUMENTS\`. If empty, run \`bd ready\` to find available tasks.
3009
3017
  2. Mark task in progress: \`bd update <id> --status=in_progress\`.
3010
- 3. Call \`memory_search\` with the task description to retrieve relevant lessons. Run \`memory_search\` per agent/subtask so each gets targeted context.
3018
+ 3. Call \`memory_search\` with the task description to retrieve relevant lessons. Run \`memory_search\` per agent/subtask so each gets targeted context. Display retrieved lessons in your response. Do not silently discard memory results.
3011
3019
  4. Assess complexity to determine team strategy.
3012
3020
  5. If **trivial** (config changes, typos, one-line fixes): handle directly with a single subagent. No AgentTeam needed. Proceed to step 10.
3013
3021
  6. If **simple** or **complex**, create an AgentTeam:
@@ -3034,9 +3042,16 @@ Execute implementation by delegating to an agent team. The lead coordinates and
3034
3042
  14. Run the full test suite to check for regressions.
3035
3043
  15. Close the task: \`bd close <id>\`.
3036
3044
 
3037
- ## Verification Gate
3038
- Before marking work complete, run the 8-step TDD verification pipeline:
3039
- 1. /invariant-designer \u2192 2. /cct-subagent \u2192 3. /test-first-enforcer \u2192 4. /property-test-generator \u2192 5. /anti-cargo-cult-reviewer \u2192 6. /module-boundary-reviewer \u2192 7. /drift-detector \u2192 8. /implementation-reviewer
3045
+ ## MANDATORY VERIFICATION -- DO NOT CLOSE TASK WITHOUT THIS
3046
+ STOP. Before running \`bd close\`, you MUST:
3047
+ 1. Run \`pnpm test && pnpm lint\` (quality gates)
3048
+ 2. Run /implementation-reviewer on the changed code
3049
+ 3. Wait for APPROVED status
3050
+ If /implementation-reviewer returns REJECTED: fix ALL issues, re-run tests, resubmit.
3051
+ DO NOT close the task until approved. This is INVIOLABLE per CLAUDE.md.
3052
+
3053
+ The full 8-step pipeline (invariant-designer through implementation-reviewer) is recommended
3054
+ for complex changes. For all changes, /implementation-reviewer is the minimum required gate.
3040
3055
 
3041
3056
  ## Memory Integration
3042
3057
  - Call \`memory_search\` per delegated subtask with the subtask's specific description, not one shared query.
@@ -3135,6 +3150,7 @@ Multi-agent analysis to capture high-quality lessons from completed work into th
3135
3150
  - **Medium**: workflow changes, pattern corrections, tooling preferences
3136
3151
  - **Low**: style preferences, minor optimizations, reinforcements
3137
3152
  7. For approved items, store via \`memory_capture\` with supersedes/related linking to connect with existing memory.
3153
+ At minimum, capture 1 lesson per significant decision made during this cycle.
3138
3154
  8. After storing new items, delegate to the **compounding** subagent to run compounding synthesis:
3139
3155
  - Read all lessons from \`.claude/lessons/index.jsonl\`
3140
3156
  - Cluster by embedding similarity (threshold 0.75)
@@ -3164,42 +3180,73 @@ Chain all phases: brainstorm, plan, work, review, compound. End-to-end delivery.
3164
3180
 
3165
3181
  ## Workflow
3166
3182
  1. **Brainstorm phase**: Explore the goal from \`$ARGUMENTS\`.
3183
+ - MEMORY CHECK: Call \`memory_search\` with the current goal/task. Display results to user. If relevant items found, state which ones apply and why. If none found, state "No relevant lessons found."
3167
3184
  - Call \`memory_search\` with the goal.
3168
3185
  - \`TeamCreate\` team "brainstorm-<slug>", spawn docs-explorer + code-explorer as parallel teammates.
3169
3186
  - Ask clarifying questions via \`AskUserQuestion\`, explore alternatives.
3170
3187
  - Auto-create ADRs for significant decisions in \`docs/decisions/\`.
3171
3188
  - Create a beads epic from conclusions with \`bd create --type=feature\`.
3172
3189
  - Shut down brainstorm team before next phase.
3190
+ - Update epic phase state: \`bd update <epic-id> --notes="Phase: brainstorm COMPLETE | Next: plan"\`
3173
3191
 
3174
3192
  2. **Plan phase**: Structure the work.
3193
+ - MEMORY CHECK: Call \`memory_search\` with the current goal/task. Display results to user. If relevant items found, state which ones apply and why. If none found, state "No relevant lessons found."
3175
3194
  - Check for brainstorm epic via \`bd list\`.
3176
3195
  - \`TeamCreate\` team "plan-<slug>", spawn docs-analyst + repo-analyst + memory-analyst as parallel teammates.
3177
3196
  - Break into tasks with dependencies and acceptance criteria.
3178
3197
  - Create beads issues with \`bd create\` and map dependencies with \`bd dep add\`.
3179
3198
  - Create review and compound blocking tasks (\`bd create\` + \`bd dep add\`) so they survive compaction and surface via \`bd ready\` after work completes.
3180
3199
  - Shut down plan team before next phase.
3200
+ - Update epic phase state: \`bd update <epic-id> --notes="Phase: plan COMPLETE | Next: work"\`
3181
3201
 
3182
3202
  3. **Work phase**: Implement with adaptive TDD.
3203
+ - MEMORY CHECK: Call \`memory_search\` with the current goal/task. Display results to user. If relevant items found, state which ones apply and why. If none found, state "No relevant lessons found."
3183
3204
  - Assess complexity (trivial/simple/complex) to choose strategy.
3184
3205
  - Trivial: single subagent, no team. Simple/complex: \`TeamCreate\` team "work-<task-id>".
3185
3206
  - Spawn test-analyst first, then test-writer + implementer as teammates.
3186
3207
  - Call \`memory_search\` per subtask; \`memory_capture\` after corrections.
3187
3208
  - Commit incrementally. Close tasks as they complete.
3188
3209
  - Run verification gate before marking complete. Shut down work team.
3210
+ - Update epic phase state: \`bd update <epic-id> --notes="Phase: work COMPLETE | Next: review"\`
3211
+
3212
+ ## PHASE GATE 3->4 -- MANDATORY
3213
+ Before starting Review, verify ALL work tasks are closed:
3214
+ - Run \`bd list --status=in_progress\` \u2014 must return empty
3215
+ - Run \`bd list --status=open\` \u2014 only Review and Compound tasks should remain
3216
+ If any work tasks remain open, DO NOT proceed. Complete them first.
3217
+ Update epic phase: \`bd update <epic-id> --notes="Phase: work COMPLETE | Next: review"\`
3189
3218
 
3190
3219
  4. **Review phase**: 11-agent review with severity classification.
3220
+ - MEMORY CHECK: Call \`memory_search\` with the current goal/task. Display results to user. If relevant items found, state which ones apply and why. If none found, state "No relevant lessons found."
3191
3221
  - Run quality gates first: \`pnpm test && pnpm lint\`.
3192
3222
  - \`TeamCreate\` team "review-<slug>", spawn all 11 reviewers as parallel teammates.
3193
3223
  - Classify findings as P1 (critical/blocking), P2 (important), P3 (minor).
3194
3224
  - P1 findings must be fixed before proceeding \u2014 they block completion.
3195
3225
  - Submit to \`/implementation-reviewer\` as the mandatory gate. Shut down review team.
3226
+ - Update epic phase state: \`bd update <epic-id> --notes="Phase: review COMPLETE | Next: compound"\`
3227
+
3228
+ ## PHASE GATE 4->5 -- MANDATORY
3229
+ Before starting Compound, verify review is complete:
3230
+ - /implementation-reviewer must have returned APPROVED
3231
+ - All P1 findings must be resolved
3232
+ Update epic phase: \`bd update <epic-id> --notes="Phase: review COMPLETE | Next: compound"\`
3196
3233
 
3197
3234
  5. **Compound phase**: Capture learnings.
3235
+ - MEMORY CHECK: Call \`memory_search\` with the current goal/task. Display results to user. If relevant items found, state which ones apply and why. If none found, state "No relevant lessons found."
3198
3236
  - \`TeamCreate\` team "compound-<slug>", spawn 6 analysis agents as parallel teammates.
3199
3237
  - Search first with \`memory_search\` to avoid duplicates. Apply quality filters (novelty + specificity).
3200
3238
  - Store novel insights via \`memory_capture\` with supersedes/related links.
3201
3239
  - Update outdated docs and deprecate superseded ADRs.
3202
3240
  - Use \`AskUserQuestion\` to confirm high-severity items. Shut down compound team.
3241
+ - Update epic phase state: \`bd update <epic-id> --notes="Phase: compound COMPLETE | Next: close"\`
3242
+
3243
+ ## FINAL GATE -- EPIC CLOSURE
3244
+ Before closing the epic:
3245
+ - Run \`ca verify-gates <epic-id>\` \u2014 must return PASS for both gates
3246
+ - Run \`pnpm test\` \u2014 must pass
3247
+ - Run \`pnpm lint\` \u2014 must pass
3248
+ If verify-gates fails, the missing phase was SKIPPED. Go back and complete it.
3249
+ CRITICAL: 3/5 phases is NOT success. All 5 phases are required.
3203
3250
 
3204
3251
  ## Agent Team Pattern
3205
3252
  Each phase creates its own AgentTeam via \`TeamCreate\`, spawns teammates via \`Task\` tool with \`team_name\`, coordinates via \`SendMessage\`, and shuts down with \`shutdown_request\` before the next phase starts. Use subagents (Task without team_name) only for quick lookups like \`memory_search\` or \`bd\` commands.
@@ -3208,7 +3255,7 @@ Each phase creates its own AgentTeam via \`TeamCreate\`, spawns teammates via \`
3208
3255
  - **Skip phases**: Parse \`$ARGUMENTS\` for "from <phase>" (e.g., "from plan"). Skip all phases before the named one.
3209
3256
  - **Progress**: Announce the current phase before starting it (e.g., "[Phase 2/5] Plan").
3210
3257
  - **Retry**: If a phase fails, report the failure and ask the user whether to retry, skip, or abort.
3211
- - **Resume**: After interruption, check \`bd list --status=in_progress\` to find where work stopped and resume from that phase.
3258
+ - **Resume**: After interruption, run \`bd show <epic-id>\` and read the notes field for current phase state. Resume from that phase. If no phase state, check \`bd list --status=in_progress\` to infer.
3212
3259
 
3213
3260
  ## Stop Conditions
3214
3261
  - Stop if brainstorm reveals the goal is unclear (ask user).
@@ -3218,6 +3265,18 @@ Each phase creates its own AgentTeam via \`TeamCreate\`, spawns teammates via \`
3218
3265
  ## Memory Integration
3219
3266
  - \`memory_search\` is called in brainstorm, work, and compound phases.
3220
3267
  - \`memory_capture\` is called in work and compound phases.
3268
+
3269
+ ## SESSION CLOSE -- INVIOLABLE
3270
+ Before saying "done" or "complete", ALL of these must pass:
3271
+ 1. \`ca verify-gates <epic-id>\` -- All workflow gates satisfied
3272
+ 2. \`pnpm test && pnpm lint\` -- Quality gates green
3273
+ 3. \`git status\` -- Review changes
3274
+ 4. \`git add <specific-files>\` -- Stage (never git add .)
3275
+ 5. \`bd sync\` -- Sync beads
3276
+ 6. \`git commit -m "..."\` -- Commit
3277
+ 7. \`bd sync\` -- Post-commit sync
3278
+ 8. \`git push\` -- Push to remote
3279
+ If ANY step fails, fix it. Work is NOT done until git push succeeds.
3221
3280
  `,
3222
3281
  // =========================================================================
3223
3282
  // Utility commands (CLI wrappers)
@@ -3820,7 +3879,12 @@ async function runUpdate(repoRoot, dryRun) {
3820
3879
  }
3821
3880
  }
3822
3881
  }
3823
- return { updated, added, skipped };
3882
+ let configUpdated = false;
3883
+ if (!dryRun) {
3884
+ const { hooks, mcpServer } = await configureClaudeSettings(repoRoot);
3885
+ configUpdated = hooks || mcpServer;
3886
+ }
3887
+ return { updated, added, skipped, configUpdated };
3824
3888
  }
3825
3889
  async function runStatus(repoRoot) {
3826
3890
  const agentsDir = join(repoRoot, ".claude", "agents", "compound");
@@ -3871,6 +3935,7 @@ function registerSetupAllCommand(setupCommand) {
3871
3935
  if (result2.added > 0) console.log(` ${prefix}Added: ${result2.added} file(s)`);
3872
3936
  }
3873
3937
  if (result2.skipped > 0) console.log(` Skipped: ${result2.skipped} user-customized file(s)`);
3938
+ if (result2.configUpdated) console.log(` ${prefix}Config: hooks/MCP updated`);
3874
3939
  return;
3875
3940
  }
3876
3941
  if (options.status) {
@@ -5065,6 +5130,13 @@ async function getPrimeContext(repoRoot) {
5065
5130
  }
5066
5131
  const lessons = await loadSessionLessons(root, 5);
5067
5132
  let output = TRUST_LANGUAGE_TEMPLATE;
5133
+ const hasMcp = await hasMcpServerInMcpJson(root);
5134
+ if (!hasMcp) {
5135
+ output += `
5136
+ WARNING: MCP server not registered. Run 'npx ca setup' to enable memory_search/memory_capture tools.
5137
+
5138
+ `;
5139
+ }
5068
5140
  if (lessons.length > 0) {
5069
5141
  const formattedLessons = lessons.map(formatLessonForPrime).join("\n\n");
5070
5142
  output += `
@@ -5381,6 +5453,79 @@ function registerTestSummaryCommand(program2) {
5381
5453
  process.exit(exitCode);
5382
5454
  });
5383
5455
  }
5456
+ function parseDeps(output) {
5457
+ const deps = [];
5458
+ const lines = output.split("\n");
5459
+ let inDeps = false;
5460
+ for (const line of lines) {
5461
+ if (line.trim() === "DEPENDS ON") {
5462
+ inDeps = true;
5463
+ continue;
5464
+ }
5465
+ if (inDeps) {
5466
+ const match = line.match(
5467
+ /^\s+→\s+(✓|○)\s+\S+-\S+:\s+(.+?)\s+●/
5468
+ );
5469
+ if (match && match[1] && match[2]) {
5470
+ deps.push({ closed: match[1] === "\u2713", title: match[2] });
5471
+ } else if (line.trim() !== "" && !line.startsWith(" ")) {
5472
+ break;
5473
+ }
5474
+ }
5475
+ }
5476
+ return deps;
5477
+ }
5478
+ function checkGate(deps, prefix, gateName) {
5479
+ const task = deps.find((d) => d.title.startsWith(prefix));
5480
+ if (!task) {
5481
+ return { name: gateName, status: "fail", detail: `No ${gateName.toLowerCase()} found (missing)` };
5482
+ }
5483
+ if (!task.closed) {
5484
+ return { name: gateName, status: "fail", detail: `${gateName} exists but is not closed` };
5485
+ }
5486
+ return { name: gateName, status: "pass" };
5487
+ }
5488
+ async function runVerifyGates(epicId) {
5489
+ const raw = execSync(`bd show ${epicId}`, { encoding: "utf-8" });
5490
+ const deps = parseDeps(raw);
5491
+ return [
5492
+ checkGate(deps, "Review:", "Review task"),
5493
+ checkGate(deps, "Compound:", "Compound task")
5494
+ ];
5495
+ }
5496
+ var STATUS_LABEL = {
5497
+ pass: "PASS",
5498
+ fail: "FAIL"
5499
+ };
5500
+ function registerVerifyGatesCommand(program2) {
5501
+ program2.command("verify-gates <epic-id>").description("Verify workflow gates are satisfied before epic closure").action(async (epicId) => {
5502
+ try {
5503
+ const checks = await runVerifyGates(epicId);
5504
+ console.log(`Gate checks for epic ${epicId}:
5505
+ `);
5506
+ for (const check of checks) {
5507
+ const label = STATUS_LABEL[check.status];
5508
+ console.log(` [${label}] ${check.name}`);
5509
+ if (check.detail) {
5510
+ console.log(` ${check.detail}`);
5511
+ }
5512
+ }
5513
+ const failures = checks.filter((c) => c.status === "fail");
5514
+ console.log("");
5515
+ if (failures.length === 0) {
5516
+ console.log("All gates passed.");
5517
+ } else {
5518
+ console.log(`${failures.length} gate(s) failed.`);
5519
+ process.exitCode = 1;
5520
+ }
5521
+ } catch (err) {
5522
+ console.error(
5523
+ `Error: ${err instanceof Error ? err.message : String(err)}`
5524
+ );
5525
+ process.exitCode = 1;
5526
+ }
5527
+ });
5528
+ }
5384
5529
 
5385
5530
  // src/commands/capture.ts
5386
5531
  function createLessonFromFlags(trigger, insight, confirmed) {
@@ -6145,6 +6290,7 @@ function registerManagementCommands(program2) {
6145
6290
  registerReviewerCommand(program2);
6146
6291
  registerRulesCommands(program2);
6147
6292
  registerTestSummaryCommand(program2);
6293
+ registerVerifyGatesCommand(program2);
6148
6294
  }
6149
6295
 
6150
6296
  // src/cli.ts