cclaw-cli 0.7.0 → 0.8.0
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/content/agents.d.ts +9 -0
- package/dist/content/agents.js +177 -6
- package/dist/content/contracts.js +1 -1
- package/dist/content/examples.d.ts +1 -0
- package/dist/content/examples.js +63 -0
- package/dist/content/hooks.js +6 -6
- package/dist/content/learnings.d.ts +5 -0
- package/dist/content/learnings.js +88 -104
- package/dist/content/meta-skill.js +155 -44
- package/dist/content/session-hooks.js +2 -2
- package/dist/content/skills.js +46 -11
- package/dist/content/stage-schema.js +36 -10
- package/dist/content/start-command.js +63 -17
- package/dist/content/status-command.js +2 -2
- package/dist/content/subagents.js +169 -0
- package/dist/content/templates.js +32 -4
- package/dist/content/utility-skills.d.ts +23 -5
- package/dist/content/utility-skills.js +204 -42
- package/dist/doctor.js +33 -9
- package/dist/harness-adapters.js +55 -16
- package/dist/install.js +21 -7
- package/dist/policy.js +3 -2
- package/dist/runs.d.ts +4 -5
- package/dist/runs.js +19 -11
- package/dist/types.d.ts +4 -4
- package/package.json +1 -1
package/dist/content/skills.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RUNTIME_ROOT } from "../constants.js";
|
|
2
|
-
import { stageExamples } from "./examples.js";
|
|
2
|
+
import { stageExamples, stageGoodBadExamples } from "./examples.js";
|
|
3
3
|
import { selfImprovementBlock } from "./learnings.js";
|
|
4
|
-
import {
|
|
4
|
+
import { stageAutoSubagentDispatch, stageSchema } from "./stage-schema.js";
|
|
5
5
|
function rationalizationTable(stage) {
|
|
6
6
|
const schema = stageSchema(stage);
|
|
7
7
|
return `| Rationalization | Reality |
|
|
@@ -67,6 +67,25 @@ function decisionRecordBlock(stage) {
|
|
|
67
67
|
return "";
|
|
68
68
|
return `## Decision Record Template\n\nUse this format for every non-trivial architecture or scope decision made during this stage:\n\n\`\`\`\n${fmt}\n\`\`\`\n`;
|
|
69
69
|
}
|
|
70
|
+
function visualCommunicationBlock(stage) {
|
|
71
|
+
if (stage !== "design")
|
|
72
|
+
return "";
|
|
73
|
+
return `## Visual Communication Rules
|
|
74
|
+
|
|
75
|
+
Diagrams are load-bearing artifacts in the design stage, not decoration. A diagram that encodes structure wrongly (or hides structure behind generic labels) misleads every downstream reader. Apply these rules to **every** diagram in the design artifact:
|
|
76
|
+
|
|
77
|
+
1. **Concrete names, never generic.** "Service A → Service B" is not a diagram; it is a shape. Every node must name a real component the team will build or touch (\`NotificationPublisher\`, \`FeedReadModel\`, \`Stripe webhook handler\`). If you cannot name it concretely, the design is not ready.
|
|
78
|
+
2. **Every arrow is labeled.** Label with the message, action, or protocol it carries (\`publishEvent(user_id, payload)\`, \`GET /snapshot\`, \`dedupe-key upsert\`). Unlabeled arrows silently lose the contract between components.
|
|
79
|
+
3. **Direction is explicit.** Use arrowheads, not bare lines; draw the flow of *data* (not "dependency") unless the diagram type is explicitly a dependency graph, in which case say so in a one-line caption.
|
|
80
|
+
4. **Distinguish sync vs async.** Use a convention and state it once in a legend: e.g. solid arrow = synchronous request/response, dashed arrow = async message via queue/bus, double arrow = two-way. Async edges always name the queue or topic.
|
|
81
|
+
5. **Show at least one failure edge.** Every non-trivial diagram needs one branch that represents the degraded or error path (timeout, reconnect, fallback to cache, poison-message routing). A diagram with only the happy path hides the interesting half of the design.
|
|
82
|
+
6. **One level of detail per diagram.** Do not mix "service-level" and "class-level" on the same canvas. If you need both, produce two diagrams — one at the system boundary, one at the internal module — and cross-reference them.
|
|
83
|
+
7. **Caption, not decoration.** Each diagram gets a one-sentence caption below it stating what the reader should take away ("*Publish path with idempotent outbox; SSE stream reads the projection, not the bus directly*"). If you cannot write the caption in one sentence, the diagram is doing two things at once.
|
|
84
|
+
8. **Prefer text-based formats** (Mermaid, ASCII) over binary images in \`.cclaw/artifacts/\` so diffs stay reviewable. Binary/SVG is allowed when the diagram is already the source of truth elsewhere (e.g. \`docs/architecture/\`) and the artifact embeds a link plus a text-based summary.
|
|
85
|
+
|
|
86
|
+
If a diagram cannot satisfy rules 1–5, do NOT include it — a missing diagram is honest; a misleading diagram is worse. Surface the gap in **Unresolved Decisions** and proceed without the diagram until the decisions that would populate it are locked.
|
|
87
|
+
`;
|
|
88
|
+
}
|
|
70
89
|
function contextLoadingBlock(stage) {
|
|
71
90
|
const trace = stageSchema(stage).crossStageTrace;
|
|
72
91
|
const readLines = trace.readsFrom.length > 0
|
|
@@ -81,7 +100,7 @@ Before starting stage execution:
|
|
|
81
100
|
2. Resolve active artifact root: \`.cclaw/artifacts/\`.
|
|
82
101
|
3. Load upstream artifacts required by this stage:
|
|
83
102
|
${readLines}
|
|
84
|
-
4.
|
|
103
|
+
4. Stream \`.cclaw/knowledge.jsonl\` (strict-JSONL knowledge store) and apply relevant entries before making decisions.
|
|
85
104
|
`;
|
|
86
105
|
}
|
|
87
106
|
function whenNotToUseBlock(stage) {
|
|
@@ -236,7 +255,7 @@ function progressiveDisclosureBlock(stage) {
|
|
|
236
255
|
- Primary stage procedure (this file): \`.cclaw/skills/${schema.skillFolder}/SKILL.md\`
|
|
237
256
|
- Orchestrator contract (gate language and handoff): \`.cclaw/commands/${stage}.md\`
|
|
238
257
|
- Artifact structure baseline: \`.cclaw/templates/${schema.artifactFile}\`
|
|
239
|
-
- Runtime state truth source: \`.cclaw/state/flow-state.json\` + \`.cclaw/artifacts/\` + \`.cclaw/knowledge.
|
|
258
|
+
- Runtime state truth source: \`.cclaw/state/flow-state.json\` + \`.cclaw/artifacts/\` + \`.cclaw/knowledge.jsonl\`
|
|
240
259
|
|
|
241
260
|
### See also
|
|
242
261
|
- Meta routing and activation rules: \`.cclaw/skills/using-cclaw/SKILL.md\`
|
|
@@ -344,15 +363,14 @@ You MUST complete these steps in order:
|
|
|
344
363
|
|
|
345
364
|
${checklistItems}
|
|
346
365
|
|
|
366
|
+
${stageGoodBadExamples(stage)}
|
|
347
367
|
${stageExamples(stage)}
|
|
348
368
|
${namedAntiPatternBlock(stage)}
|
|
349
369
|
${cognitivePatternsList(stage)}
|
|
350
370
|
## Interaction Protocol
|
|
351
371
|
${schema.interactionProtocol.map((item, i) => `${i + 1}. ${item}`).join("\n")}
|
|
352
372
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
${ERROR_BUDGET_SPEC}
|
|
373
|
+
**See \`.cclaw/skills/using-cclaw/SKILL.md\` "Shared Decision + Tool-Use Protocol"** for the full AskUserQuestion format, error/retry budget, and the 3-attempt escalation rule. Do not duplicate those rules here — apply them verbatim.
|
|
356
374
|
|
|
357
375
|
${waveExecutionModeBlock(stage)}
|
|
358
376
|
## Required Gates
|
|
@@ -368,15 +386,13 @@ ${reviewSectionsBlock(stage)}
|
|
|
368
386
|
${verificationBlock(stage)}
|
|
369
387
|
${crossStageTraceBlock(stage)}
|
|
370
388
|
${artifactValidationBlock(stage)}
|
|
389
|
+
${visualCommunicationBlock(stage)}
|
|
371
390
|
${decisionRecordBlock(stage)}
|
|
372
391
|
## Common Rationalizations
|
|
373
392
|
${rationalizationTable(stage)}
|
|
374
393
|
|
|
375
|
-
## Blockers
|
|
376
|
-
${schema.blockers.length > 0 ? schema.blockers.map((item) => `- ${item}`).join("\n") : "- None — stage can always proceed"}
|
|
377
|
-
|
|
378
394
|
## Anti-Patterns
|
|
379
|
-
${schema.antiPatterns.map((item) => `- ${item}`).join("\n")}
|
|
395
|
+
${[...schema.antiPatterns, ...schema.blockers].map((item) => `- ${item}`).join("\n")}
|
|
380
396
|
|
|
381
397
|
## Red Flags
|
|
382
398
|
${schema.redFlags.map((item) => `- ${item}`).join("\n")}
|
|
@@ -389,6 +405,25 @@ ${stageTransitionAutoAdvanceBlock(schema)}
|
|
|
389
405
|
${progressiveDisclosureBlock(stage)}
|
|
390
406
|
${selfImprovementBlock(stage)}
|
|
391
407
|
## Handoff
|
|
408
|
+
|
|
409
|
+
Before closing the stage, announce the handoff explicitly so the user can steer. Use the **Handoff Menu** below; never auto-advance silently, even when \`/cc-next\` is available.
|
|
410
|
+
|
|
411
|
+
### Handoff Menu
|
|
412
|
+
|
|
413
|
+
Offer the user a lettered choice at the end of the stage (use \`AskUserQuestion\` / \`AskQuestion\` when the harness supports it, otherwise plain lettered text):
|
|
414
|
+
|
|
415
|
+
- **A) Advance** — run \`/cc-next\` and continue to the next stage. Default when all gates are satisfied and there are no open concerns.
|
|
416
|
+
- **B) Revise this stage** — stay on the current stage; apply the user's feedback, then re-ask for handoff.
|
|
417
|
+
- **C) Pause / park** — save state; stop here. Useful when the user wants to share the artifact with a human reviewer before continuing.
|
|
418
|
+
- **D) Rewind** — move to a prior stage (user names which). Use when downstream work revealed that an earlier stage was wrong.
|
|
419
|
+
- **E) Abandon** — mark the flow as cancelled; no further stages will run. Artifacts remain on disk.
|
|
420
|
+
|
|
421
|
+
Recommendation rules:
|
|
422
|
+
- If all required gates are satisfied AND the stage's completion status is \`DONE\`, recommend **A (Advance)**.
|
|
423
|
+
- If completion status is \`DONE_WITH_CONCERNS\`, recommend **B (Revise)** and name the concern.
|
|
424
|
+
- If completion status is \`BLOCKED\`, recommend **B (Revise)** or **C (Pause)** depending on whether the blocker is internal or external.
|
|
425
|
+
|
|
426
|
+
Reference data for the user:
|
|
392
427
|
- Next command: \`/cc-next\` (loads whatever stage is current in flow-state)
|
|
393
428
|
- Required artifact: \`.cclaw/artifacts/${schema.artifactFile}\`
|
|
394
429
|
- Stage stays blocked if any required gate is unsatisfied
|
|
@@ -195,7 +195,7 @@ const SCOPE = {
|
|
|
195
195
|
"**Error and Rescue Registry** — For each capability: what breaks, how detected, what fallback."
|
|
196
196
|
],
|
|
197
197
|
interactionProtocol: [
|
|
198
|
-
"For scope mode selection: use the Decision Protocol — present expand/selective/hold/reduce as labeled options with trade-offs and mark one as (recommended).
|
|
198
|
+
"For scope mode selection: use the Decision Protocol — present expand/selective/hold/reduce as labeled options with trade-offs and mark one as (recommended). Do NOT use a numeric Completeness rubric; recommend the option that best covers the prime-directive failure modes, four data-flow paths, observability, and deferred handling for the in-scope set with the smallest blast radius. Base your recommendation on default heuristics: greenfield -> expand, enhancement -> selective, bugfix/hotfix/refactor -> hold, broad blast radius -> reduce. If AskQuestion/AskUserQuestion is available, send exactly ONE question per call, validate fields against runtime schema, and on schema error immediately fall back to plain-text question instead of retrying guessed payloads.",
|
|
199
199
|
"Walk through the scope checklist interactively. Each checklist item that surfaces a decision should be presented to the user as a question, not as a monologue. Do not dump all items at once.",
|
|
200
200
|
"Challenge premise and verify the problem framing before anything else.",
|
|
201
201
|
"Take a position on every scope decision. Avoid hedging phrases like 'this could work' or 'there are many ways'; state your recommendation and one concrete condition that would change it.",
|
|
@@ -350,6 +350,7 @@ const SCOPE = {
|
|
|
350
350
|
artifactValidation: [
|
|
351
351
|
{ section: "Prime Directives", required: true, validationRule: "For each scoped capability: named failure modes, explicit error surface, four data-flow paths, interaction edge cases, observability expectations, and deferred-item handling." },
|
|
352
352
|
{ section: "Premise Challenge", required: true, validationRule: "Must contain explicit answers to: right problem? direct path? what if nothing?" },
|
|
353
|
+
{ section: "Requirements", required: true, validationRule: "Table of stable requirement IDs (R1, R2, R3…) one per row with observable outcome, priority, and source. IDs are assigned once and never renumbered across scope/design/spec/plan/review; dropped requirements stay with Priority `DROPPED`." },
|
|
353
354
|
{ section: "Implementation Alternatives", required: true, validationRule: "2-3 options with Name, Summary, Effort, Risk, Pros, Cons, and Reuses. Must include minimal viable and ideal architecture options." },
|
|
354
355
|
{ section: "Scope Mode", required: true, validationRule: "Must state selected mode and rationale with default heuristic justification." },
|
|
355
356
|
{ section: "Mode-Specific Analysis", required: true, validationRule: "Must document the analysis matching the selected scope mode: EXPAND (10x and delight opportunities), SELECTIVE (hold-scope baseline then cherry-picked expansions), HOLD (minimum-change-set hardening), REDUCE (ruthless cuts and follow-up split)." },
|
|
@@ -393,7 +394,7 @@ const DESIGN = {
|
|
|
393
394
|
"Codebase Investigation — Before any design decision, read the actual code in the blast radius. List every file that will be touched, its current responsibilities, and existing patterns (error handling, naming, test style). Design must conform to discovered patterns, not impose new ones without justification.",
|
|
394
395
|
"Step 0: Scope Challenge — what existing code solves sub-problems? Minimum change set? Complexity check: 8+ files or 2+ new services = complexity smell → flag for possible scope reduction.",
|
|
395
396
|
"Search Before Building — For each technical choice (library, pattern, architecture), search for existing solutions. Label findings: Layer 1 (exact match), Layer 2 (partial match, needs adaptation), Layer 3 (inspiration only), EUREKA (unexpected perfect solution). Default to existing before custom.",
|
|
396
|
-
"Architecture Review — system design, component boundaries, data flow, scaling, security architecture. For each new codepath: one realistic production failure scenario. **Mandatory:** produce at least one architecture diagram (ASCII, Mermaid, or tool-generated) showing component boundaries and data flow direction.",
|
|
397
|
+
"Architecture Review — system design, component boundaries, data flow, scaling, security architecture. For each new codepath: one realistic production failure scenario. **Mandatory:** produce at least one architecture diagram (ASCII, Mermaid, or tool-generated) showing component boundaries and data flow direction. Apply the **Visual Communication rules** (see below) — an unlabeled or generic diagram is worse than no diagram, because it pretends to encode decisions it does not.",
|
|
397
398
|
"Code Quality Review — code organization, DRY violations, error handling patterns, over/under-engineering assessment.",
|
|
398
399
|
"Test Review — diagram every new flow, data path, error path. For each: what test type covers it? Does one exist? What is the gap? Produce test plan artifact.",
|
|
399
400
|
"Performance Review — N+1 queries, memory concerns, caching opportunities, slow code paths. What breaks at 10x load? At 100x?",
|
|
@@ -405,7 +406,7 @@ const DESIGN = {
|
|
|
405
406
|
interactionProtocol: [
|
|
406
407
|
"Review architecture decisions section-by-section.",
|
|
407
408
|
"For EACH issue found in a review section, present it ONE AT A TIME. Do NOT batch multiple issues.",
|
|
408
|
-
"For each issue: use the Decision Protocol — describe concretely with file/line references, present labeled options (A/B/C) with trade-offs, effort estimate (S/M/L/XL), risk level (Low/Med/High),
|
|
409
|
+
"For each issue: use the Decision Protocol — describe concretely with file/line references, present labeled options (A/B/C) with trade-offs, effort estimate (S/M/L/XL), risk level (Low/Med/High), and mark one as (recommended). Do NOT use a numeric Completeness rubric; recommend the option that best covers architecture, data-flow, failure-modes, test, and perf review concerns for the issue with the lowest risk. If AskQuestion/AskUserQuestion is available, send exactly ONE question per call, validate fields against runtime schema, and on schema error immediately fall back to plain-text question instead of retrying guessed payloads.",
|
|
409
410
|
"Only proceed to the next review section after ALL issues in the current section are resolved.",
|
|
410
411
|
"If a section has no issues, say 'No issues found' and move on.",
|
|
411
412
|
"Do not skip failure-mode mapping.",
|
|
@@ -583,7 +584,7 @@ const DESIGN = {
|
|
|
583
584
|
{ section: "Codebase Investigation", required: true, validationRule: "Must list blast-radius files with current responsibilities and discovered patterns." },
|
|
584
585
|
{ section: "Search Before Building", required: true, validationRule: "For each technical choice: Layer 1 (exact match), Layer 2 (partial match), Layer 3 (inspiration), EUREKA labels with reuse-first default." },
|
|
585
586
|
{ section: "Architecture Boundaries", required: true, validationRule: "Must list component boundaries with ownership." },
|
|
586
|
-
{ section: "Architecture Diagram", required: true, validationRule: "At least one diagram (ASCII, Mermaid, or image) showing component boundaries and data flow direction." },
|
|
587
|
+
{ section: "Architecture Diagram", required: true, validationRule: "At least one diagram (ASCII, Mermaid, or image) showing component boundaries and data flow direction. Diagram must: (1) label every node with a concrete component name (no generic 'Service A/B'), (2) label every arrow with the action or message (no unlabeled arrows), (3) mark direction of data flow explicitly, (4) distinguish synchronous from asynchronous edges (e.g. solid vs dashed, or `sync:` / `async:` prefix), (5) show at least one failure edge or degraded-mode branch when the system has one." },
|
|
587
588
|
{ section: "Data Flow", required: true, validationRule: "Must include happy path, nil input, empty input, upstream error paths." },
|
|
588
589
|
{ section: "Failure Mode Table", required: true, validationRule: "Each failure mode has: trigger, detection, mitigation, user impact." },
|
|
589
590
|
{ section: "Test Strategy", required: true, validationRule: "Must define unit/integration/e2e expectations with coverage targets." },
|
|
@@ -748,7 +749,7 @@ const SPEC = {
|
|
|
748
749
|
traceabilityRule: "Every acceptance criterion must trace to a design decision. Every downstream plan task must trace to a spec criterion."
|
|
749
750
|
},
|
|
750
751
|
artifactValidation: [
|
|
751
|
-
{ section: "Acceptance Criteria", required: true, validationRule: "Each criterion is observable, measurable, and falsifiable. Table
|
|
752
|
+
{ section: "Acceptance Criteria", required: true, validationRule: "Each criterion is observable, measurable, and falsifiable. Table must include a Requirement Ref column linking to R# IDs in 02-scope.md and a Design Decision Ref column tracing back to design artifact. AC IDs (AC-1, AC-2…) are stable across revisions — dropped ACs stay with Priority `DROPPED`." },
|
|
752
753
|
{ section: "Edge Cases", required: true, validationRule: "At least one boundary and one error condition per criterion." },
|
|
753
754
|
{ section: "Constraints and Assumptions", required: true, validationRule: "All implicit assumptions surfaced. Constraints have sources." },
|
|
754
755
|
{ section: "Testability Map", required: true, validationRule: "Each criterion maps to a concrete test description with verification approach (unit, integration, e2e, manual) and command or manual steps." },
|
|
@@ -1037,7 +1038,10 @@ const TDD = {
|
|
|
1037
1038
|
{ name: "Regression Paranoia", description: "Assume every change breaks something until the full suite proves otherwise. Partial test runs are lies of omission." },
|
|
1038
1039
|
{ name: "Refactor-as-Hygiene", description: "Refactoring is not optional cleanup — it is the third leg of TDD. GREEN without REFACTOR accumulates mess. REFACTOR without GREEN breaks things." },
|
|
1039
1040
|
{ name: "Evidence Over Anecdote", description: "Every claim about test state must be backed by captured output. 'It passed' without terminal evidence is not evidence. 'I saw it fail' without the failure output is not RED. Capture commands, outputs, and results — not summaries from memory." },
|
|
1040
|
-
{ name: "Characterization First", description: "Before changing existing behavior, write characterization tests that capture current behavior as-is. These tests document what the system does today — even if that behavior is wrong. Only after the characterization suite is green do you add the new RED test for the desired change. This prevents accidental behavior destruction during refactoring." }
|
|
1041
|
+
{ name: "Characterization First", description: "Before changing existing behavior, write characterization tests that capture current behavior as-is. These tests document what the system does today — even if that behavior is wrong. Only after the characterization suite is green do you add the new RED test for the desired change. This prevents accidental behavior destruction during refactoring." },
|
|
1042
|
+
{ name: "Test Pyramid Shape", description: "Healthy test suites look like a pyramid: many small fast tests at the base, fewer medium integration tests in the middle, few large end-to-end tests at the top. Each layer catches a different class of bug; none of them substitutes for another. If your suite is top-heavy (mostly E2E) it is slow and flaky; if it is base-only it misses integration contracts. During TDD, default to the smallest layer that can prove the behavior." },
|
|
1043
|
+
{ name: "Prove-It Pattern (bug fixes)", description: "For any reported regression or hotfix, the FIRST test is a reproduction — it must fail without your fix, pass with your fix, and fail again if the fix is reverted. This is the only way to prove you fixed the reported bug and not a superficially similar one. Skipping this step is how bugs come back two releases later wearing a different name." },
|
|
1044
|
+
{ name: "Test Size Model", description: "Size tests by scope, not by name: Small = pure logic, no I/O, <50ms; Medium = one process boundary, possibly filesystem or an in-memory DB; Large = multi-process / network / real external service. Small tests are the default; escalate to Medium only when a real boundary must be exercised, and to Large only for end-to-end user journeys. Record the size class in the TDD artifact so reviewers can sanity-check the pyramid shape." }
|
|
1041
1045
|
],
|
|
1042
1046
|
reviewSections: [
|
|
1043
1047
|
{
|
|
@@ -1061,6 +1065,26 @@ const TDD = {
|
|
|
1061
1065
|
"Is traceability complete: every change links to plan task ID and spec criterion?"
|
|
1062
1066
|
],
|
|
1063
1067
|
stopGate: true
|
|
1068
|
+
},
|
|
1069
|
+
{
|
|
1070
|
+
title: "Test Pyramid + Size Audit",
|
|
1071
|
+
evaluationPoints: [
|
|
1072
|
+
"Is the tests-added count skewed toward Small (unit) tests, with Medium and Large used only when a real boundary justifies the cost?",
|
|
1073
|
+
"Does every newly added test declare a size class (Small / Medium / Large) — either inline in the test file or in the TDD artifact table?",
|
|
1074
|
+
"Are Large tests reserved for genuine end-to-end user journeys (not substitutes for unit coverage)?",
|
|
1075
|
+
"Has the slice avoided using Medium/Large tests to paper over testability problems that should be fixed at the design layer?"
|
|
1076
|
+
],
|
|
1077
|
+
stopGate: false
|
|
1078
|
+
},
|
|
1079
|
+
{
|
|
1080
|
+
title: "Prove-It Reproduction (bug-fix slices)",
|
|
1081
|
+
evaluationPoints: [
|
|
1082
|
+
"Does the artifact identify this slice as a bug fix, and if so, include a reproduction test checked in alongside the fix?",
|
|
1083
|
+
"Is there captured RED evidence from running the reproduction WITHOUT the fix applied?",
|
|
1084
|
+
"Is there captured GREEN evidence from the same reproduction AFTER the fix was applied?",
|
|
1085
|
+
"Is there a note confirming the reproduction test fails again if the fix is reverted (or equivalent evidence that the test is actually pinned to this fix)?"
|
|
1086
|
+
],
|
|
1087
|
+
stopGate: false
|
|
1064
1088
|
}
|
|
1065
1089
|
],
|
|
1066
1090
|
completionStatus: ["DONE", "DONE_WITH_CONCERNS", "BLOCKED"],
|
|
@@ -1077,7 +1101,9 @@ const TDD = {
|
|
|
1077
1101
|
{ section: "REFACTOR Notes", required: true, validationRule: "What changed, why, behavior preservation confirmed." },
|
|
1078
1102
|
{ section: "Traceability", required: true, validationRule: "Plan task ID and spec criterion linked." },
|
|
1079
1103
|
{ section: "Verification Ladder", required: false, validationRule: "If present: per-slice verification tier (static, command, behavioral, human) with evidence for highest tier reached." },
|
|
1080
|
-
{ section: "Coverage Targets", required: false, validationRule: "If present: per-module or per-code-type coverage thresholds with current values and measurement commands." }
|
|
1104
|
+
{ section: "Coverage Targets", required: false, validationRule: "If present: per-module or per-code-type coverage thresholds with current values and measurement commands." },
|
|
1105
|
+
{ section: "Test Pyramid Shape", required: false, validationRule: "If present: per-slice count of Small/Medium/Large tests added, to let reviewers verify the suite is not drifting top-heavy." },
|
|
1106
|
+
{ section: "Prove-It Reproduction", required: false, validationRule: "Required for bug-fix slices: original failing reproduction test (RED without fix), passing output with fix (GREEN), and a note confirming the test fails again if the fix is reverted." }
|
|
1081
1107
|
],
|
|
1082
1108
|
namedAntiPattern: {
|
|
1083
1109
|
title: "Code Before Failing Test",
|
|
@@ -1125,7 +1151,7 @@ const REVIEW = {
|
|
|
1125
1151
|
"Run Layer 1 (spec compliance) completely before starting Layer 2.",
|
|
1126
1152
|
"In each review section, present findings ONE AT A TIME. Do NOT batch.",
|
|
1127
1153
|
"Classify every finding as Critical, Important, or Suggestion.",
|
|
1128
|
-
"For each Critical finding: use the Decision Protocol — present resolution options (A/B/C) with trade-offs,
|
|
1154
|
+
"For each Critical finding: use the Decision Protocol — present resolution options (A/B/C) with trade-offs, and mark one as (recommended). Do NOT use a numeric Completeness rubric; recommend the option that fully closes the finding with no carry-over risk and the smallest blast radius. If AskQuestion/AskUserQuestion is available, send exactly ONE question per call, validate fields against runtime schema, and on schema error immediately fall back to plain-text question instead of retrying guessed payloads.",
|
|
1129
1155
|
"Resolve all critical blockers before ship.",
|
|
1130
1156
|
"For final verdict: use AskQuestion/AskUserQuestion only if runtime schema is confirmed; otherwise collect verdict with a plain-text single-choice prompt (APPROVED / APPROVED_WITH_CONCERNS / BLOCKED).",
|
|
1131
1157
|
"**STOP.** Do NOT proceed to ship until the user provides an explicit verdict."
|
|
@@ -1336,7 +1362,7 @@ const SHIP = {
|
|
|
1336
1362
|
interactionProtocol: [
|
|
1337
1363
|
"Run preflight checks before any release action.",
|
|
1338
1364
|
"Document release notes and rollback plan explicitly.",
|
|
1339
|
-
"For finalization mode: use the Decision Protocol — present modes as labeled options (A/B/C/D) with consequences,
|
|
1365
|
+
"For finalization mode: use the Decision Protocol — present modes as labeled options (A/B/C/D) with consequences, and mark one as (recommended). Do NOT use a numeric Completeness rubric; recommend the mode that best addresses release blast-radius, rollback readiness, observability, and stakeholder communication — ties go to the most reversible option. If AskQuestion/AskUserQuestion is available, send exactly ONE question per call, validate fields against runtime schema, and on schema error immediately fall back to plain-text question instead of retrying guessed payloads.",
|
|
1340
1366
|
"Do not proceed if critical blockers remain from review.",
|
|
1341
1367
|
"**STOP.** Present finalization options and wait for user selection before executing any finalization action."
|
|
1342
1368
|
],
|
|
@@ -1455,7 +1481,7 @@ const SHIP = {
|
|
|
1455
1481
|
{ section: "Monitoring", required: false, validationRule: "If applicable: what metrics/logs to watch post-deploy. Risk note if no monitoring." },
|
|
1456
1482
|
{ section: "Finalization", required: true, validationRule: "Exactly one finalization enum token selected. Execution result documented. Worktree cleaned if applicable." },
|
|
1457
1483
|
{ section: "Completion Status", required: false, validationRule: "If present: exactly one of SHIPPED, SHIPPED_WITH_EXCEPTIONS, BLOCKED. Exceptions documented when applicable." },
|
|
1458
|
-
{ section: "Compound Step", required: false, validationRule: "Optional retrospective: at least one bullet of the form 'Insight: ... | Action: append [compound] entry to .cclaw/knowledge.
|
|
1484
|
+
{ section: "Compound Step", required: false, validationRule: "Optional retrospective: at least one bullet of the form 'Insight: ... | Action: append [compound] entry to .cclaw/knowledge.jsonl', or an explicit 'No compound insight this run.' line." }
|
|
1459
1485
|
],
|
|
1460
1486
|
namedAntiPattern: {
|
|
1461
1487
|
title: "Green CI Means Safe to Merge",
|
|
@@ -25,30 +25,69 @@ This is the **recommended way to start** working with cclaw. Use \`/cc-next\` fo
|
|
|
25
25
|
## HARD-GATE
|
|
26
26
|
|
|
27
27
|
- **Do not** skip reading \`${flowPath}\` — always check current state before acting.
|
|
28
|
-
- **Do not** start implementation stages directly from \`/cc <prompt>\` — always begin at brainstorm.
|
|
28
|
+
- **Do not** start implementation stages directly from \`/cc <prompt>\` — always begin at the first stage of the resolved track (brainstorm for standard, spec for quick).
|
|
29
|
+
- **Do not** start a stage pipeline for a task that is not a software change (pure question, non-software task, conversation).
|
|
29
30
|
|
|
30
31
|
## Algorithm
|
|
31
32
|
|
|
32
33
|
### With prompt (\`/cc <text>\`)
|
|
33
34
|
|
|
34
|
-
1.
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
1. **Phase 0 — Task classification.** Before any stage routing, classify the prompt:
|
|
36
|
+
|
|
37
|
+
| Class | Signals | Action |
|
|
38
|
+
|---|---|---|
|
|
39
|
+
| **non-software** | legal text / docs / marketing copy / meeting notes / therapy-style conversation | Respond directly, do NOT open a stage, do NOT mutate flow state. |
|
|
40
|
+
| **pure-question** | "how does X work?", "explain Y", "what are the trade-offs of Z?" | Answer directly, do NOT open a stage. |
|
|
41
|
+
| **trivial** | typo, one-liner, rename, config tweak, copy change, version bump with zero behavior change | Fast-path: skip \`brainstorm\` and \`scope\`, seed \`00-idea.md\`, move straight to \`design\` or \`spec\` depending on whether an interface change is involved. |
|
|
42
|
+
| **software — bug fix with repro** | regression / hotfix / named symptom + repro steps | Fast-path: set track to \`quick\`, seed \`04-spec.md\` with the reproduction, enter \`tdd\` with a RED reproduction test first. |
|
|
43
|
+
| **software — standard** | feature, refactor, migration, integration, architecture change | Full 8-stage flow starting at \`brainstorm\`. |
|
|
44
|
+
|
|
45
|
+
Record the chosen class in \`.cclaw/artifacts/00-idea.md\` on the \`Class:\` line. Do NOT silently treat a non-software task as software.
|
|
46
|
+
|
|
47
|
+
2. **Phase 1 — Origin-document discovery.** Before asking the user for context, scan for existing requirements/plan artifacts and merge them into initial context:
|
|
48
|
+
- \`.cclaw/artifacts/00-idea.md\` if it already exists (resumed flow).
|
|
49
|
+
- Common origin locations: \`docs/prd/**\`, \`docs/rfcs/**\`, \`docs/adr/**\`, \`docs/design/**\`, \`specs/**\`, \`prd/**\`, \`rfc/**\`, \`design/**\`, root-level \`PRD.md\` / \`SPEC.md\` / \`DESIGN.md\` / \`REQUIREMENTS.md\` / \`ROADMAP.md\`.
|
|
50
|
+
- Summarize each discovered doc in \`00-idea.md\` under a \`Discovered context\` section with path + 1-line summary.
|
|
51
|
+
- If an origin doc contradicts the prompt, surface the conflict to the user before routing.
|
|
52
|
+
|
|
53
|
+
3. **Phase 2 — Tech-stack + version detection.** Sniff the repo for stack + language versions and record under \`Stack:\`:
|
|
54
|
+
- Node: \`package.json\` \`engines\` / \`volta\` / \`packageManager\` / \`devDependencies\`.
|
|
55
|
+
- Python: \`pyproject.toml\` / \`requirements*.txt\` / \`.python-version\`.
|
|
56
|
+
- Go: \`go.mod\` (module + Go version).
|
|
57
|
+
- Rust: \`Cargo.toml\` (\`[package]\` + \`rust-version\`).
|
|
58
|
+
- Java/Kotlin: \`pom.xml\` / \`build.gradle*\` + toolchain version.
|
|
59
|
+
- Containers: \`Dockerfile\`, \`docker-compose*.yml\`.
|
|
60
|
+
- CI: \`.github/workflows\`, \`.gitlab-ci.yml\`.
|
|
61
|
+
Skip detection quietly if no markers are found — do NOT invent a stack.
|
|
62
|
+
|
|
63
|
+
4. Read \`${flowPath}\`.
|
|
64
|
+
5. If flow already has completed stages beyond brainstorm, warn the user that starting a new brainstorm will reset progress. Ask for confirmation before proceeding.
|
|
65
|
+
6. **Track heuristic** — classify the idea text and **recommend** a track (the user can override before any state mutation):
|
|
37
66
|
- **quick** (\`spec → tdd → review → ship\`) — single-purpose work where the spec is essentially already known.
|
|
38
67
|
Triggers (case-insensitive substring or close variant): \`bug\`, \`bugfix\`, \`fix\`, \`hotfix\`, \`patch\`, \`typo\`, \`regression\`, \`copy change\`, \`rename\`, \`bump\`, \`upgrade dep\`, \`config tweak\`, \`docs only\`, \`comment\`, \`lint\`, \`format\`, \`small\`, \`tiny\`, \`one-liner\`, \`revert\`.
|
|
39
68
|
- **standard** (full 8 stages — default) — anything that introduces a new capability, touches multiple modules, or has unclear scope.
|
|
40
69
|
Triggers: \`new feature\`, \`add\`, \`build\`, \`design\`, \`refactor\`, \`migration\`, \`platform\`, \`architecture\`, \`endpoint\`, \`schema\`, \`api\`, \`integrate\`, \`workflow\`, \`onboarding\`, or any prompt that does not match quick triggers.
|
|
41
70
|
- When triggers conflict (e.g. "small refactor that touches 5 modules") prefer **standard** — quick is opt-in and only safe when scope is genuinely tiny.
|
|
42
|
-
|
|
71
|
+
7. Present the recommendation as a single decision with explicit options:
|
|
43
72
|
> \`Recommended track: <quick|standard>\` because \`<one-line reason citing matched triggers>\`.
|
|
44
73
|
> Override? (A) keep \`<recommended>\` (B) switch to \`<other>\` (C) cancel.
|
|
45
74
|
If \`AskQuestion\`/\`AskUserQuestion\` is available, send exactly ONE question; on schema error, fall back to plain text.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
75
|
+
8. Persist the chosen track to \`${flowPath}\` (\`track\` field). Compute \`skippedStages\` from the track and write that too. Use the **first stage of the chosen track** as \`currentStage\` (quick → \`spec\`, standard → \`brainstorm\`, trivial fast-path → \`design\` or \`spec\` per Phase 0).
|
|
76
|
+
9. Write the prompt to \`.cclaw/artifacts/00-idea.md\` with the following header lines: \`Class:\` (from Phase 0), \`Track:\` (chosen track + matched heuristic), \`Stack:\` (from Phase 2 detection, or \`unknown\`), and a \`Discovered context\` section if Phase 1 found origin docs.
|
|
77
|
+
10. Load the **first-stage skill for the chosen track** and its command file:
|
|
78
|
+
- quick → \`.cclaw/skills/specification-authoring/SKILL.md\` + \`.cclaw/commands/spec.md\`
|
|
79
|
+
- standard → \`.cclaw/skills/brainstorming/SKILL.md\` + \`.cclaw/commands/brainstorm.md\`
|
|
80
|
+
- trivial fast-path → design or spec skill per Phase 0 decision.
|
|
81
|
+
11. Execute that stage with the prompt + Phase 1/Phase 2 context as initial input.
|
|
82
|
+
|
|
83
|
+
### Reclassification on discovery
|
|
84
|
+
|
|
85
|
+
If during any stage the agent discovers evidence that contradicts the initial Phase 0 / track decision (e.g. a supposedly \`trivial\` change turns out to require schema migration, a \`quick\` bug fix turns out to need design discussion, an origin doc reveals scope 3× larger than the prompt), STOP and re-classify:
|
|
86
|
+
|
|
87
|
+
1. Surface the new evidence in plain text.
|
|
88
|
+
2. Propose the updated \`Class\` + \`Track\` with a one-line reason.
|
|
89
|
+
3. Use the Decision Protocol to let the user accept, override, or cancel.
|
|
90
|
+
4. On acceptance: update \`00-idea.md\` with a \`Reclassification:\` entry (old → new, reason, ISO timestamp) and update \`flow-state.json\` accordingly — do NOT rewrite prior artifacts, they stay as history.
|
|
52
91
|
|
|
53
92
|
### Without prompt (\`/cc\`)
|
|
54
93
|
|
|
@@ -88,12 +127,15 @@ Do **not** silently discard an existing flow when the user provides a prompt. If
|
|
|
88
127
|
|
|
89
128
|
### Path A: \`/cc <prompt>\`
|
|
90
129
|
|
|
91
|
-
1.
|
|
92
|
-
2.
|
|
130
|
+
1. **Task classification (Phase 0).** Decide whether the prompt is \`software-standard\`, \`software-trivial\`, \`software-bugfix\`, \`pure-question\`, or \`non-software\`. Non-software and pure-question exit immediately — answer directly, do not open a stage.
|
|
131
|
+
2. **Origin-document discovery (Phase 1).** Scan for \`docs/prd/**\`, \`docs/rfcs/**\`, \`docs/adr/**\`, \`docs/design/**\`, \`specs/**\`, root-level \`PRD.md\` / \`SPEC.md\` / \`DESIGN.md\` / \`REQUIREMENTS.md\`. Summarize any hits in \`00-idea.md\` under \`Discovered context\`. Surface conflicts with the prompt before routing.
|
|
132
|
+
3. **Stack detection (Phase 2).** Inspect \`package.json\` engines, \`pyproject.toml\`, \`go.mod\`, \`Cargo.toml\`, \`pom.xml\`, \`build.gradle*\`, \`Dockerfile\`, \`docker-compose*.yml\`, and CI configs. Record stack + versions on the \`Stack:\` line. Do not invent stack details.
|
|
133
|
+
4. Read \`${flowPath}\`.
|
|
134
|
+
5. If \`completedStages\` is non-empty:
|
|
93
135
|
- Inform: "You have an active flow at stage **{currentStage}** with {N} completed stages. Starting a new brainstorm will reset progress."
|
|
94
136
|
- Ask: "Continue with reset? (A) Yes, start fresh (B) No, resume current flow"
|
|
95
137
|
- If (B) → switch to Path B behavior.
|
|
96
|
-
|
|
138
|
+
6. **Classify the idea** using the heuristic below and present a single track recommendation. Wait for explicit confirmation or override before mutating any state.
|
|
97
139
|
|
|
98
140
|
**Track heuristic** (lowercase substring match against the user prompt):
|
|
99
141
|
|
|
@@ -104,9 +146,13 @@ Do **not** silently discard an existing flow when the user provides a prompt. If
|
|
|
104
146
|
|
|
105
147
|
- On conflict, prefer \`standard\` (quick is opt-in for genuinely tiny work).
|
|
106
148
|
- Always state the recommendation as a one-line reason citing the matched trigger.
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
149
|
+
7. Persist the chosen track in \`${flowPath}\` (\`track\` + \`skippedStages\`). Set \`currentStage\` to the first stage of the chosen track (\`quick\` → \`spec\`, \`standard\` → \`brainstorm\`, trivial fast-path → \`design\` or \`spec\`). Reset gate catalog.
|
|
150
|
+
8. Write \`${RUNTIME_ROOT}/artifacts/00-idea.md\` with the user's prompt plus header lines: \`Class:\`, \`Track:\`, \`Stack:\`, and a \`Discovered context\` section from Phase 1.
|
|
151
|
+
9. Load and execute the **first stage skill of the chosen track** (\`brainstorming\` for standard, \`specification-authoring\` for quick) plus its matching command file.
|
|
152
|
+
|
|
153
|
+
### Reclassification on discovery
|
|
154
|
+
|
|
155
|
+
If mid-stage evidence contradicts the initial Class/Track decision (the "trivial" change needs a migration, the "quick" bug fix needs architecture work, an origin doc multiplies scope), STOP and re-classify using the Decision Protocol. Record \`Reclassification:\` in \`00-idea.md\` with old/new class and a one-line reason. Do NOT rewrite prior artifacts — they stay as history.
|
|
110
156
|
|
|
111
157
|
### Path B: \`/cc\` (no arguments)
|
|
112
158
|
|
|
@@ -8,7 +8,7 @@ function delegationLogPath() {
|
|
|
8
8
|
return `${RUNTIME_ROOT}/state/delegation-log.json`;
|
|
9
9
|
}
|
|
10
10
|
function knowledgePath() {
|
|
11
|
-
return `${RUNTIME_ROOT}/knowledge.
|
|
11
|
+
return `${RUNTIME_ROOT}/knowledge.jsonl`;
|
|
12
12
|
}
|
|
13
13
|
function contextModePath() {
|
|
14
14
|
return `${RUNTIME_ROOT}/state/context-mode.json`;
|
|
@@ -131,7 +131,7 @@ a read-only command.
|
|
|
131
131
|
- Prefer \`${checkpointPath()}\` when \`stage === currentStage\` and \`timestamp\` parses as ISO 8601.
|
|
132
132
|
- Else scan \`${stageActivityPath()}\` from tail for the most recent entry whose \`stage === currentStage\`; use its \`ts\`.
|
|
133
133
|
- Render \`<X>d<Y>h\`, \`<X>h<Y>m\`, \`<X>m\`, or \`(unknown)\`.
|
|
134
|
-
5. Read \`${RUNTIME_ROOT}/knowledge.
|
|
134
|
+
5. Read \`${RUNTIME_ROOT}/knowledge.jsonl\`. If missing or empty → knowledge highlights are \`(none recorded)\`. Parse each line as JSON and surface its \`trigger\`/\`action\`.
|
|
135
135
|
6. For each gate in \`stageGateCatalog[currentStage].required\`:
|
|
136
136
|
- Satisfied if present in \`passed\` and absent from \`blocked\`.
|
|
137
137
|
7. Build and print the status block (see command contract for layout).
|
|
@@ -10,6 +10,11 @@ const SUBAGENT_AGENT_NAMES = [
|
|
|
10
10
|
"security-reviewer",
|
|
11
11
|
"test-author",
|
|
12
12
|
"doc-updater",
|
|
13
|
+
"repo-research-analyst",
|
|
14
|
+
"learnings-researcher",
|
|
15
|
+
"framework-docs-researcher",
|
|
16
|
+
"best-practices-researcher",
|
|
17
|
+
"git-history-analyzer",
|
|
13
18
|
];
|
|
14
19
|
export function subagentDrivenDevSkill() {
|
|
15
20
|
return `---
|
|
@@ -59,6 +64,20 @@ If delegation tooling is unavailable in the active harness, run the same control
|
|
|
59
64
|
- **Use a more capable model** for high-ambiguity or high-risk analysis (security review, architecture conflicts, spec contradiction resolution).
|
|
60
65
|
- During review-heavy stages, prefer **mixed routing**: faster first-pass triage + escalate only high-severity/low-confidence findings.
|
|
61
66
|
|
|
67
|
+
### Cost-aware routing (tier table)
|
|
68
|
+
|
|
69
|
+
| Tier | Use for | Example agents |
|
|
70
|
+
|---|---|---|
|
|
71
|
+
| \`deep\` | one heavy reasoning pass per stage (planner, final reconciliation) | planner |
|
|
72
|
+
| \`balanced\` | spec compliance + code/security review with enough context | spec-reviewer, code-reviewer, security-reviewer, test-author |
|
|
73
|
+
| \`fast\` | read-only research / narrow machine checks / docs updates — safe to fan out | repo-research-analyst, learnings-researcher, framework-docs-researcher, best-practices-researcher, git-history-analyzer, doc-updater |
|
|
74
|
+
|
|
75
|
+
**Routing rules:**
|
|
76
|
+
- At most ONE \`deep\` agent per stage (planner OR final reconciliation, not both).
|
|
77
|
+
- \`balanced\` agents are default for review-stage specialists.
|
|
78
|
+
- \`fast\` agents are the only tier you should fan out in parallel (3-5 at a time is fine).
|
|
79
|
+
- Never escalate a \`fast\` agent's output directly to ship decisions — always have a \`balanced\` reviewer consume the evidence first.
|
|
80
|
+
|
|
62
81
|
## HARD-GATE
|
|
63
82
|
|
|
64
83
|
**Never dispatch a subagent without a concrete, self-contained task description pasted into the prompt. Do not pass file references the subagent must read to understand its task.**
|
|
@@ -556,6 +575,146 @@ Process (mandatory):
|
|
|
556
575
|
- Report: FILES_EDITED, GREEN_COMMAND_RUN, REFACTOR_NOTES, STATUS: DONE|BLOCKED.
|
|
557
576
|
\`\`\`
|
|
558
577
|
|
|
578
|
+
`;
|
|
579
|
+
}
|
|
580
|
+
function repoResearchAnalystEnhancedBody() {
|
|
581
|
+
return `
|
|
582
|
+
|
|
583
|
+
## Task Tool Delegation
|
|
584
|
+
|
|
585
|
+
Launch **read-only repo exploration** at the start of brainstorm/scope/design so the primary agent plans on a grounded map, not guesses. Run as a \`fast\` tier agent — cheap to fan out alongside learnings-researcher and best-practices-researcher.
|
|
586
|
+
|
|
587
|
+
\`\`\`
|
|
588
|
+
You are a repo research analyst subagent.
|
|
589
|
+
|
|
590
|
+
TASK DOMAIN: {1-sentence description of the feature/fix/refactor being planned}
|
|
591
|
+
REPO HINTS: {known directories, module names, patterns the primary agent already knows}
|
|
592
|
+
OUT OF SCOPE: {paths not to read (large vendor dirs, generated code)}
|
|
593
|
+
|
|
594
|
+
Deliverables:
|
|
595
|
+
- Relevant modules: list of \`path — purpose\` (cite file:line on ambiguous claims).
|
|
596
|
+
- Reuse candidates: list of \`file:line — why this absorbs the change\`.
|
|
597
|
+
- Ownership hints: CODEOWNERS / README / comment signals.
|
|
598
|
+
- Gaps: capabilities NOT yet present that the task would need.
|
|
599
|
+
|
|
600
|
+
Rules:
|
|
601
|
+
- Read-only. Do NOT edit files.
|
|
602
|
+
- Cite file:line for every claim; never invent paths.
|
|
603
|
+
- If the scope is too large to fully explore, say so and bound your search.
|
|
604
|
+
\`\`\`
|
|
605
|
+
|
|
606
|
+
`;
|
|
607
|
+
}
|
|
608
|
+
function learningsResearcherEnhancedBody() {
|
|
609
|
+
return `
|
|
610
|
+
|
|
611
|
+
## Task Tool Delegation
|
|
612
|
+
|
|
613
|
+
Dispatch before any non-trivial stage to stream \`.cclaw/knowledge.jsonl\` and surface prior learnings. Cheap \`fast\` tier — fan out with other research agents.
|
|
614
|
+
|
|
615
|
+
\`\`\`
|
|
616
|
+
You are a learnings researcher subagent.
|
|
617
|
+
|
|
618
|
+
TASK DESCRIPTION: {verbatim prompt + current stage}
|
|
619
|
+
DOMAIN HINTS: {keywords from Task Classification / Origin Docs}
|
|
620
|
+
|
|
621
|
+
Deliverables:
|
|
622
|
+
- Matched rules: list of \`trigger → action (confidence)\`.
|
|
623
|
+
- Matched patterns: list of \`trigger → action (confidence)\`.
|
|
624
|
+
- Matched lessons: list of \`trigger → action (confidence)\`.
|
|
625
|
+
- Matched compounds: list of \`trigger → action (confidence)\`.
|
|
626
|
+
- No-match note (if nothing relevant exists).
|
|
627
|
+
|
|
628
|
+
Rules:
|
|
629
|
+
- Read-only; NEVER rewrite or delete entries.
|
|
630
|
+
- Return at most 10 entries, ranked by confidence then recency.
|
|
631
|
+
- Quote the entries verbatim — do NOT paraphrase.
|
|
632
|
+
\`\`\`
|
|
633
|
+
|
|
634
|
+
`;
|
|
635
|
+
}
|
|
636
|
+
function frameworkDocsResearcherEnhancedBody() {
|
|
637
|
+
return `
|
|
638
|
+
|
|
639
|
+
## Task Tool Delegation
|
|
640
|
+
|
|
641
|
+
Use for any task that depends on a specific framework/library/SDK/CLI. Prefer context7 MCP when available for version-accurate docs; otherwise WebSearch/WebFetch official sources.
|
|
642
|
+
|
|
643
|
+
\`\`\`
|
|
644
|
+
You are a framework documentation researcher subagent.
|
|
645
|
+
|
|
646
|
+
LIBRARY + VERSION: {name + resolved version from lockfile / pyproject / go.mod / Cargo.toml / pom.xml / build.gradle}
|
|
647
|
+
TASK USAGE: {which APIs the task will actually call}
|
|
648
|
+
CONTEXT7: {"available" | "not available"}
|
|
649
|
+
|
|
650
|
+
Deliverables:
|
|
651
|
+
- Key APIs: list of signatures the task will touch.
|
|
652
|
+
- Breaking changes since the last major release relevant to the task.
|
|
653
|
+
- Gotchas: deprecated paths, version-gated flags, platform caveats.
|
|
654
|
+
- Source: URL(s) or MCP reference used.
|
|
655
|
+
|
|
656
|
+
Rules:
|
|
657
|
+
- Never invent APIs. Prefer silence + UNKNOWN over speculation.
|
|
658
|
+
- Tie every statement to an authoritative source; avoid blog posts when official docs exist.
|
|
659
|
+
\`\`\`
|
|
660
|
+
|
|
661
|
+
`;
|
|
662
|
+
}
|
|
663
|
+
function bestPracticesResearcherEnhancedBody() {
|
|
664
|
+
return `
|
|
665
|
+
|
|
666
|
+
## Task Tool Delegation
|
|
667
|
+
|
|
668
|
+
Use when the task touches a well-known domain (auth, caching, rate limiting, observability, accessibility, etc.) and the primary agent needs a short, citable best-practice summary.
|
|
669
|
+
|
|
670
|
+
\`\`\`
|
|
671
|
+
You are a best-practices researcher subagent.
|
|
672
|
+
|
|
673
|
+
DOMAIN: {one word, e.g. auth, caching, rate-limiting, a11y, observability, retries}
|
|
674
|
+
SUB-PROBLEM: {narrow one-sentence statement of what the task is actually deciding}
|
|
675
|
+
|
|
676
|
+
Deliverables:
|
|
677
|
+
- Recommended practices: 5-8 entries of \`practice — rationale — source\`.
|
|
678
|
+
- Common traps / anti-patterns: list of \`trap — why it fails — source\`.
|
|
679
|
+
- Decision hooks: 1-3 explicit questions the primary agent must answer.
|
|
680
|
+
|
|
681
|
+
Rules:
|
|
682
|
+
- Cite 3-5 authoritative sources (official docs, IETF/W3C/OWASP, well-known standards).
|
|
683
|
+
- If the domain has no authoritative answer, say so; do NOT substitute opinion.
|
|
684
|
+
\`\`\`
|
|
685
|
+
|
|
686
|
+
`;
|
|
687
|
+
}
|
|
688
|
+
function gitHistoryAnalyzerEnhancedBody() {
|
|
689
|
+
return `
|
|
690
|
+
|
|
691
|
+
## Task Tool Delegation
|
|
692
|
+
|
|
693
|
+
Use when the task touches existing code, so the primary agent can see prior attempts, reverts, and owners before proposing changes.
|
|
694
|
+
|
|
695
|
+
\`\`\`
|
|
696
|
+
You are a git history analyzer subagent.
|
|
697
|
+
|
|
698
|
+
IMPACTED PATHS: {list of files/directories the task plans to touch}
|
|
699
|
+
WINDOW: {default 90 days; adjust only if explicitly needed}
|
|
700
|
+
|
|
701
|
+
Commands to run (read-only):
|
|
702
|
+
- git log --follow -n 20 -- <path>
|
|
703
|
+
- git blame <path>
|
|
704
|
+
- git log --since="<window>" --grep="revert|regression" -- <path>
|
|
705
|
+
- git log --since="<window>" --format="%an" -- <path> | sort | uniq -c | sort -nr
|
|
706
|
+
|
|
707
|
+
Deliverables:
|
|
708
|
+
- Recent themes: 3-5 bullets on what changed lately per path.
|
|
709
|
+
- Revert/regression signals: list with commit SHAs.
|
|
710
|
+
- Owners: best-guess from blame + committer frequency.
|
|
711
|
+
- Collision risks: in-flight refactors/migrations visible in log.
|
|
712
|
+
|
|
713
|
+
Rules:
|
|
714
|
+
- Read-only. Never amend history, never git push.
|
|
715
|
+
- If a path is new (no history), say so explicitly rather than fabricating context.
|
|
716
|
+
\`\`\`
|
|
717
|
+
|
|
559
718
|
`;
|
|
560
719
|
}
|
|
561
720
|
function docUpdaterEnhancedBody() {
|
|
@@ -597,6 +756,16 @@ export function enhancedAgentBody(agentName) {
|
|
|
597
756
|
return testAuthorEnhancedBody();
|
|
598
757
|
case "doc-updater":
|
|
599
758
|
return docUpdaterEnhancedBody();
|
|
759
|
+
case "repo-research-analyst":
|
|
760
|
+
return repoResearchAnalystEnhancedBody();
|
|
761
|
+
case "learnings-researcher":
|
|
762
|
+
return learningsResearcherEnhancedBody();
|
|
763
|
+
case "framework-docs-researcher":
|
|
764
|
+
return frameworkDocsResearcherEnhancedBody();
|
|
765
|
+
case "best-practices-researcher":
|
|
766
|
+
return bestPracticesResearcherEnhancedBody();
|
|
767
|
+
case "git-history-analyzer":
|
|
768
|
+
return gitHistoryAnalyzerEnhancedBody();
|
|
600
769
|
default:
|
|
601
770
|
return `
|
|
602
771
|
|