cclaw-cli 0.11.0 → 0.12.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/README.md +4 -3
- package/dist/cli.d.ts +6 -0
- package/dist/cli.js +297 -9
- package/dist/content/core-agents.d.ts +44 -0
- package/dist/content/core-agents.js +225 -0
- package/dist/content/doctor-references.d.ts +2 -0
- package/dist/content/doctor-references.js +144 -0
- package/dist/content/examples.js +1 -1
- package/dist/content/harnesses-doc.d.ts +1 -0
- package/dist/content/harnesses-doc.js +95 -0
- package/dist/content/hook-events.d.ts +4 -0
- package/dist/content/hook-events.js +42 -0
- package/dist/content/protocols.js +34 -6
- package/dist/content/research-playbooks.d.ts +8 -0
- package/dist/content/research-playbooks.js +135 -0
- package/dist/content/skills.js +20 -0
- package/dist/content/stage-schema.d.ts +3 -1
- package/dist/content/stage-schema.js +20 -51
- package/dist/content/subagents.d.ts +1 -1
- package/dist/content/subagents.js +23 -38
- package/dist/content/templates.d.ts +1 -1
- package/dist/content/templates.js +49 -11
- package/dist/delegation.d.ts +1 -0
- package/dist/delegation.js +27 -1
- package/dist/doctor-registry.d.ts +8 -0
- package/dist/doctor-registry.js +127 -0
- package/dist/doctor.d.ts +5 -0
- package/dist/doctor.js +112 -4
- package/dist/harness-adapters.d.ts +7 -0
- package/dist/harness-adapters.js +53 -9
- package/dist/init-detect.d.ts +2 -0
- package/dist/init-detect.js +45 -0
- package/dist/install.js +63 -1
- package/dist/policy.js +5 -0
- package/package.json +2 -1
- package/dist/content/agents.d.ts +0 -48
- package/dist/content/agents.js +0 -411
|
@@ -190,6 +190,10 @@ const BRAINSTORM = {
|
|
|
190
190
|
"current behavior of affected area",
|
|
191
191
|
"business and delivery constraints"
|
|
192
192
|
],
|
|
193
|
+
researchPlaybooks: [
|
|
194
|
+
"research/repo-scan.md",
|
|
195
|
+
"research/learnings-lookup.md"
|
|
196
|
+
],
|
|
193
197
|
outputs: [
|
|
194
198
|
"approved design direction",
|
|
195
199
|
"alternatives with trade-offs",
|
|
@@ -339,6 +343,9 @@ const SCOPE = {
|
|
|
339
343
|
"existing capabilities and reusable components",
|
|
340
344
|
"delivery deadlines and risk tolerance"
|
|
341
345
|
],
|
|
346
|
+
researchPlaybooks: [
|
|
347
|
+
"research/git-history.md"
|
|
348
|
+
],
|
|
342
349
|
outputs: ["scope mode decision", "scope contract", "discretion areas list", "deferred scope list", "scope summary", "scope completion dashboard"],
|
|
343
350
|
blockers: [
|
|
344
351
|
"scope mode not selected",
|
|
@@ -553,6 +560,10 @@ const DESIGN = {
|
|
|
553
560
|
"operational constraints",
|
|
554
561
|
"security and reliability expectations"
|
|
555
562
|
],
|
|
563
|
+
researchPlaybooks: [
|
|
564
|
+
"research/framework-docs-lookup.md",
|
|
565
|
+
"research/best-practices-lookup.md"
|
|
566
|
+
],
|
|
556
567
|
outputs: [
|
|
557
568
|
"architecture lock",
|
|
558
569
|
"risk and failure map",
|
|
@@ -1266,7 +1277,7 @@ const REVIEW = {
|
|
|
1266
1277
|
checklist: [
|
|
1267
1278
|
"Diff Scope — Run `git diff` against base branch. If no diff, exit early with APPROVED (no changes to review). Scope the review to changed files unless blast-radius analysis requires wider inspection.",
|
|
1268
1279
|
"Change-Size Check — ~100 lines = normal. ~300 lines = consider splitting. ~1000+ lines = strongly recommend stacked PRs. Flag large diffs to the user.",
|
|
1269
|
-
"Adversarial Trigger Check — compute changed-line count (`git diff --shortstat <base>..HEAD`), files-touched count, and whether trust boundaries changed (auth/secrets/external inputs/permissions). If `lines > 100` OR `files > 10` OR `trust boundary changed`, **dispatch a SECOND
|
|
1280
|
+
"Adversarial Trigger Check — compute changed-line count (`git diff --shortstat <base>..HEAD`), files-touched count, and whether trust boundaries changed (auth/secrets/external inputs/permissions). If `lines > 100` OR `files > 10` OR `trust boundary changed`, **dispatch a SECOND reviewer agent with the `adversarial-review` skill loaded** and reconcile its findings into the review army (treat the conditional dispatch as mandatory whenever the trigger holds; record the trigger that fired in the dashboard).",
|
|
1270
1281
|
"Load upstream evidence — read TDD artifact (RED + GREEN + REFACTOR), spec, and plan. Verify evidence chain is unbroken.",
|
|
1271
1282
|
"Layer 1: Spec Compliance — check every acceptance criterion against implementation. Verdict: pass/fail per criterion.",
|
|
1272
1283
|
"Layer 2a: Correctness — logic errors, race conditions, boundary violations, null handling.",
|
|
@@ -1642,20 +1653,6 @@ const STAGE_AUTO_SUBAGENT_DISPATCH = {
|
|
|
1642
1653
|
when: "When request is ambiguous, multi-surface, or spans multiple modules.",
|
|
1643
1654
|
purpose: "Map scope and alternatives before direction lock.",
|
|
1644
1655
|
requiresUserGate: false
|
|
1645
|
-
},
|
|
1646
|
-
{
|
|
1647
|
-
agent: "repo-research-analyst",
|
|
1648
|
-
mode: "proactive",
|
|
1649
|
-
when: "When the user's idea touches an unfamiliar module, stack, or integration surface.",
|
|
1650
|
-
purpose: "Parallel fan-out: summarise existing code paths, tech stack, and similar features already present — feeds the alternatives list.",
|
|
1651
|
-
requiresUserGate: false
|
|
1652
|
-
},
|
|
1653
|
-
{
|
|
1654
|
-
agent: "learnings-researcher",
|
|
1655
|
-
mode: "proactive",
|
|
1656
|
-
when: "On every non-trivial brainstorm where `.cclaw/knowledge.jsonl` has entries.",
|
|
1657
|
-
purpose: "Surface prior learnings and anti-patterns that apply to the current task before direction lock.",
|
|
1658
|
-
requiresUserGate: false
|
|
1659
1656
|
}
|
|
1660
1657
|
],
|
|
1661
1658
|
scope: [
|
|
@@ -1665,13 +1662,6 @@ const STAGE_AUTO_SUBAGENT_DISPATCH = {
|
|
|
1665
1662
|
when: "Always during scope shaping.",
|
|
1666
1663
|
purpose: "Challenge premise, map alternatives, and produce explicit in/out contract.",
|
|
1667
1664
|
requiresUserGate: false
|
|
1668
|
-
},
|
|
1669
|
-
{
|
|
1670
|
-
agent: "git-history-analyzer",
|
|
1671
|
-
mode: "proactive",
|
|
1672
|
-
when: "When scope touches modules with churn, recent regressions, or unclear ownership.",
|
|
1673
|
-
purpose: "Read recent commits, PRs, and issue references for the affected paths before scope lock.",
|
|
1674
|
-
requiresUserGate: false
|
|
1675
1665
|
}
|
|
1676
1666
|
],
|
|
1677
1667
|
design: [
|
|
@@ -1688,20 +1678,6 @@ const STAGE_AUTO_SUBAGENT_DISPATCH = {
|
|
|
1688
1678
|
when: "When trust boundaries, auth, secrets, or external inputs are involved.",
|
|
1689
1679
|
purpose: "Catch design-level security risks before implementation.",
|
|
1690
1680
|
requiresUserGate: false
|
|
1691
|
-
},
|
|
1692
|
-
{
|
|
1693
|
-
agent: "framework-docs-researcher",
|
|
1694
|
-
mode: "proactive",
|
|
1695
|
-
when: "When a specific framework/library version is detected and a non-trivial API is in play.",
|
|
1696
|
-
purpose: "Retrieve version-specific docs + migration notes so the design does not rely on stale training priors.",
|
|
1697
|
-
requiresUserGate: false
|
|
1698
|
-
},
|
|
1699
|
-
{
|
|
1700
|
-
agent: "best-practices-researcher",
|
|
1701
|
-
mode: "conditional",
|
|
1702
|
-
when: "When the user flags a quality axis (performance, accessibility, reliability) as primary.",
|
|
1703
|
-
purpose: "Pull domain best-practices and contrast them with the current design choice.",
|
|
1704
|
-
requiresUserGate: false
|
|
1705
1681
|
}
|
|
1706
1682
|
],
|
|
1707
1683
|
spec: [
|
|
@@ -1713,7 +1689,7 @@ const STAGE_AUTO_SUBAGENT_DISPATCH = {
|
|
|
1713
1689
|
requiresUserGate: false
|
|
1714
1690
|
},
|
|
1715
1691
|
{
|
|
1716
|
-
agent: "
|
|
1692
|
+
agent: "reviewer",
|
|
1717
1693
|
mode: "proactive",
|
|
1718
1694
|
when: "When acceptance criteria and edge cases are drafted and need independent validation before plan stage.",
|
|
1719
1695
|
purpose: "Independent review of spec against measurability, testability, and completeness before locking the contract for plan.",
|
|
@@ -1747,17 +1723,10 @@ const STAGE_AUTO_SUBAGENT_DISPATCH = {
|
|
|
1747
1723
|
],
|
|
1748
1724
|
review: [
|
|
1749
1725
|
{
|
|
1750
|
-
agent: "
|
|
1726
|
+
agent: "reviewer",
|
|
1751
1727
|
mode: "mandatory",
|
|
1752
1728
|
when: "Always in review stage.",
|
|
1753
|
-
purpose: "
|
|
1754
|
-
requiresUserGate: false
|
|
1755
|
-
},
|
|
1756
|
-
{
|
|
1757
|
-
agent: "code-reviewer",
|
|
1758
|
-
mode: "mandatory",
|
|
1759
|
-
when: "Always in review stage.",
|
|
1760
|
-
purpose: "Assess correctness, maintainability, architecture, and ship risk.",
|
|
1729
|
+
purpose: "Run spec compliance and code-quality passes with file evidence.",
|
|
1761
1730
|
requiresUserGate: false
|
|
1762
1731
|
},
|
|
1763
1732
|
{
|
|
@@ -1769,10 +1738,10 @@ const STAGE_AUTO_SUBAGENT_DISPATCH = {
|
|
|
1769
1738
|
skill: "security-audit"
|
|
1770
1739
|
},
|
|
1771
1740
|
{
|
|
1772
|
-
agent: "
|
|
1741
|
+
agent: "reviewer",
|
|
1773
1742
|
mode: "conditional",
|
|
1774
1743
|
condition: "diff_lines_gt:100||files_touched_gt:10||trust_boundary_changed",
|
|
1775
|
-
when: "When the diff exceeds 100 changed lines, touches more than 10 files, or modifies trust boundaries — dispatch a SECOND, independent
|
|
1744
|
+
when: "When the diff exceeds 100 changed lines, touches more than 10 files, or modifies trust boundaries — dispatch a SECOND, independent reviewer with the adversarial-review skill loaded so the review army has at least two voices on a high-blast-radius change.",
|
|
1776
1745
|
purpose: "Adversarial second-opinion review on large or trust-sensitive diffs. The second reviewer treats the implementation as hostile and tries to break it (hostile-user, future-maintainer, competitor lenses) instead of sympathetically explaining it.",
|
|
1777
1746
|
requiresUserGate: false,
|
|
1778
1747
|
skill: "adversarial-review"
|
|
@@ -1787,10 +1756,10 @@ const STAGE_AUTO_SUBAGENT_DISPATCH = {
|
|
|
1787
1756
|
requiresUserGate: false
|
|
1788
1757
|
},
|
|
1789
1758
|
{
|
|
1790
|
-
agent: "
|
|
1759
|
+
agent: "security-reviewer",
|
|
1791
1760
|
mode: "proactive",
|
|
1792
|
-
when: "When release involves broad blast radius or unresolved concerns.",
|
|
1793
|
-
purpose: "Provide final
|
|
1761
|
+
when: "When release involves broad blast radius, trust-boundary movement, or unresolved security concerns.",
|
|
1762
|
+
purpose: "Provide final exploitability check before release finalization.",
|
|
1794
1763
|
requiresUserGate: false
|
|
1795
1764
|
}
|
|
1796
1765
|
]
|
|
@@ -7,7 +7,7 @@ export declare function subagentDrivenDevSkill(): string;
|
|
|
7
7
|
export declare function parallelAgentsSkill(): string;
|
|
8
8
|
/**
|
|
9
9
|
* Returns markdown fragments augmenting each specialist persona with Task tool
|
|
10
|
-
* delegation guidance. Combine with the existing `body` field from `agents.ts`.
|
|
10
|
+
* delegation guidance. Combine with the existing `body` field from `core-agents.ts`.
|
|
11
11
|
*/
|
|
12
12
|
export declare function enhancedAgentBody(agentName: string): string;
|
|
13
13
|
export declare function subagentsAgentsMdBlock(): string;
|
|
@@ -5,16 +5,10 @@
|
|
|
5
5
|
*/
|
|
6
6
|
const SUBAGENT_AGENT_NAMES = [
|
|
7
7
|
"planner",
|
|
8
|
-
"
|
|
9
|
-
"code-reviewer",
|
|
8
|
+
"reviewer",
|
|
10
9
|
"security-reviewer",
|
|
11
10
|
"test-author",
|
|
12
|
-
"doc-updater"
|
|
13
|
-
"repo-research-analyst",
|
|
14
|
-
"learnings-researcher",
|
|
15
|
-
"framework-docs-researcher",
|
|
16
|
-
"best-practices-researcher",
|
|
17
|
-
"git-history-analyzer",
|
|
11
|
+
"doc-updater"
|
|
18
12
|
];
|
|
19
13
|
export function subagentDrivenDevSkill() {
|
|
20
14
|
return `---
|
|
@@ -40,7 +34,7 @@ For cclaw flow stages, machine-only specialist work should auto-dispatch without
|
|
|
40
34
|
|
|
41
35
|
- **design/plan:** planner
|
|
42
36
|
- **tdd:** test-author
|
|
43
|
-
- **review:**
|
|
37
|
+
- **review:** reviewer + security-reviewer (security-reviewer is always mandatory; produce an explicit no-change attestation when no trust boundaries moved)
|
|
44
38
|
- **ship:** doc-updater
|
|
45
39
|
|
|
46
40
|
Human input remains mandatory only at explicit approval gates (plan approval, user challenge resolution, release finalization mode).
|
|
@@ -69,8 +63,8 @@ If delegation tooling is unavailable in the active harness, run the same control
|
|
|
69
63
|
| Tier | Use for | Example agents |
|
|
70
64
|
|---|---|---|
|
|
71
65
|
| \`deep\` | one heavy reasoning pass per stage (planner, final reconciliation) | planner |
|
|
72
|
-
| \`balanced\` | spec compliance + code/security review with enough context |
|
|
73
|
-
| \`fast\` |
|
|
66
|
+
| \`balanced\` | spec compliance + code/security review with enough context | reviewer, security-reviewer, test-author |
|
|
67
|
+
| \`fast\` | bounded maintenance updates and doc hygiene | doc-updater |
|
|
74
68
|
|
|
75
69
|
**Routing rules:**
|
|
76
70
|
- At most ONE \`deep\` agent per stage (planner OR final reconciliation, not both).
|
|
@@ -84,14 +78,14 @@ Concrete per-stage rules so the controller does not have to guess which tier fit
|
|
|
84
78
|
|
|
85
79
|
| Stage | Deep slot | Balanced slot(s) | Fast fan-out | Trigger to escalate |
|
|
86
80
|
|---|---|---|---|---|
|
|
87
|
-
| brainstorm | planner (only if ambiguity spans >1 module) | — |
|
|
88
|
-
| scope | planner (always) | — | git-history-
|
|
89
|
-
| design | planner (always) | security-reviewer (if trust boundary touched) | framework-docs-
|
|
90
|
-
| spec | — |
|
|
81
|
+
| brainstorm | planner (only if ambiguity spans >1 module) | — | run in-thread research playbooks | promote to \`balanced\` reviewer once direction locks |
|
|
82
|
+
| scope | planner (always) | — | run \`research/git-history.md\` in-thread when churn is high | promote to \`balanced\` planner if scope touches external contracts |
|
|
83
|
+
| design | planner (always) | security-reviewer (if trust boundary touched) | run \`research/framework-docs-lookup.md\` + \`research/best-practices-lookup.md\` in-thread | escalate one specialist to \`deep\` only if a failure mode is Critical-severity |
|
|
84
|
+
| spec | — | reviewer (if spec > 200 lines or multiple ACs) | — | escalate to \`deep\` only for spec ↔ design contradictions |
|
|
91
85
|
| plan | planner (solo, always) | — | — | never fan out at plan stage; one owner for dependency graph |
|
|
92
|
-
| tdd | — | test-author (each slice) ·
|
|
93
|
-
| review | — |
|
|
94
|
-
| ship | — |
|
|
86
|
+
| tdd | — | test-author (each slice) · reviewer (slice-local) | doc-updater (API surface changes) | escalate to \`deep\` only when a RED test cannot be expressed (design leak) |
|
|
87
|
+
| review | — | reviewer · security-reviewer (both mandatory) | doc-updater for release-note drift checks | escalate a \`balanced\` reviewer to \`deep\` only when two reviewers disagree on severity |
|
|
88
|
+
| ship | — | security-reviewer (if blast radius is high) | doc-updater (changelog/migration notes) | escalate to \`balanced\` reviewer only if preflight finds a regression |
|
|
95
89
|
|
|
96
90
|
**De-escalation rules (avoid over-spending):**
|
|
97
91
|
- If a \`deep\` planner run returns low-uncertainty output (single unambiguous plan), do **not** add a second \`deep\` pass in the same stage.
|
|
@@ -121,7 +115,7 @@ If you catch yourself writing “read PLAN.md Task 3” or “implement the next
|
|
|
121
115
|
2. **For each task sequentially (NEVER parallel implementation subagents — file conflicts):**
|
|
122
116
|
1. **Dispatch implementer subagent** with the **full task text pasted in** (not a file reference).
|
|
123
117
|
2. **Check return status:** \`DONE\` / \`DONE_WITH_CONCERNS\` / \`NEEDS_CONTEXT\` / \`BLOCKED\`
|
|
124
|
-
3. If \`DONE\`: dispatch **
|
|
118
|
+
3. If \`DONE\`: dispatch **reviewer** subagent to verify actual code matches spec and quality expectations.
|
|
125
119
|
4. If spec review **FAIL**: dispatch **fixer subagent** (a **new** agent — not an inline patch from the parent — to avoid context pollution).
|
|
126
120
|
5. Dispatch **code-quality reviewer** (maintainability/PR hygiene).
|
|
127
121
|
6. **Mark task complete** only after concerns are triaged or explicitly accepted with rationale.
|
|
@@ -350,7 +344,7 @@ Write a structured reconciliation artifact at \`.cclaw/artifacts/07-review-army.
|
|
|
350
344
|
"severity": "Critical|Important|Suggestion",
|
|
351
345
|
"confidence": 1,
|
|
352
346
|
"fingerprint": "hash-or-stable-key",
|
|
353
|
-
"reportedBy": ["
|
|
347
|
+
"reportedBy": ["reviewer", "security-reviewer"],
|
|
354
348
|
"status": "open|accepted|resolved",
|
|
355
349
|
"location": { "file": "path", "line": 123 },
|
|
356
350
|
"recommendation": "..."
|
|
@@ -501,7 +495,7 @@ function specReviewerEnhancedBody() {
|
|
|
501
495
|
|
|
502
496
|
## Task Tool Delegation
|
|
503
497
|
|
|
504
|
-
For
|
|
498
|
+
For review audits, use the Task tool with the following **reviewer** payload (fill placeholders in the parent session).
|
|
505
499
|
|
|
506
500
|
\`\`\`
|
|
507
501
|
You are a specification compliance reviewer (subagent).
|
|
@@ -544,6 +538,9 @@ Output format (mandatory):
|
|
|
544
538
|
|
|
545
539
|
`;
|
|
546
540
|
}
|
|
541
|
+
function reviewerEnhancedBody() {
|
|
542
|
+
return `${specReviewerEnhancedBody()}${codeReviewerEnhancedBody()}`;
|
|
543
|
+
}
|
|
547
544
|
function securityReviewerEnhancedBody() {
|
|
548
545
|
return `
|
|
549
546
|
|
|
@@ -603,7 +600,7 @@ function repoResearchAnalystEnhancedBody() {
|
|
|
603
600
|
|
|
604
601
|
## Task Tool Delegation
|
|
605
602
|
|
|
606
|
-
Launch **read-only repo exploration** at the start of brainstorm/scope/design so the primary agent plans on a grounded map, not guesses.
|
|
603
|
+
Launch **read-only repo exploration** at the start of brainstorm/scope/design so the primary agent plans on a grounded map, not guesses. Use this as an in-thread research procedure.
|
|
607
604
|
|
|
608
605
|
\`\`\`
|
|
609
606
|
You are a repo research analyst subagent.
|
|
@@ -761,32 +758,20 @@ Tasks:
|
|
|
761
758
|
}
|
|
762
759
|
/**
|
|
763
760
|
* Returns markdown fragments augmenting each specialist persona with Task tool
|
|
764
|
-
* delegation guidance. Combine with the existing `body` field from `agents.ts`.
|
|
761
|
+
* delegation guidance. Combine with the existing `body` field from `core-agents.ts`.
|
|
765
762
|
*/
|
|
766
763
|
export function enhancedAgentBody(agentName) {
|
|
767
764
|
switch (agentName) {
|
|
768
765
|
case "planner":
|
|
769
766
|
return plannerEnhancedBody();
|
|
770
|
-
case "
|
|
771
|
-
return
|
|
772
|
-
case "code-reviewer":
|
|
773
|
-
return codeReviewerEnhancedBody();
|
|
767
|
+
case "reviewer":
|
|
768
|
+
return reviewerEnhancedBody();
|
|
774
769
|
case "security-reviewer":
|
|
775
770
|
return securityReviewerEnhancedBody();
|
|
776
771
|
case "test-author":
|
|
777
772
|
return testAuthorEnhancedBody();
|
|
778
773
|
case "doc-updater":
|
|
779
774
|
return docUpdaterEnhancedBody();
|
|
780
|
-
case "repo-research-analyst":
|
|
781
|
-
return repoResearchAnalystEnhancedBody();
|
|
782
|
-
case "learnings-researcher":
|
|
783
|
-
return learningsResearcherEnhancedBody();
|
|
784
|
-
case "framework-docs-researcher":
|
|
785
|
-
return frameworkDocsResearcherEnhancedBody();
|
|
786
|
-
case "best-practices-researcher":
|
|
787
|
-
return bestPracticesResearcherEnhancedBody();
|
|
788
|
-
case "git-history-analyzer":
|
|
789
|
-
return gitHistoryAnalyzerEnhancedBody();
|
|
790
775
|
default:
|
|
791
776
|
return `
|
|
792
777
|
|
|
@@ -809,7 +794,7 @@ Status contract: DONE | DONE_WITH_CONCERNS | NEEDS_CONTEXT | BLOCKED.
|
|
|
809
794
|
|
|
810
795
|
- Controller sequentially dispatches **implementer → reviewer** loops per task.
|
|
811
796
|
- HARD-GATE: paste **self-contained task text**; never point subagents at plan files to “discover” scope.
|
|
812
|
-
- **
|
|
797
|
+
- **Review fixers** are **fresh agents** after failed review passes — avoids parent-context pollution.
|
|
813
798
|
- **Machine-only flow checks auto-dispatch** by stage (design/plan/tdd/review/ship) without asking the user to trigger each specialist manually.
|
|
814
799
|
|
|
815
800
|
### Parallel Agents (\`dispatching-parallel-agents\` skill)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const ARTIFACT_TEMPLATES: Record<string, string>;
|
|
2
2
|
export declare const RULEBOOK_MARKDOWN = "# Cclaw Rulebook\n\n## MUST_ALWAYS\n- Follow flow order: brainstorm -> scope -> design -> spec -> plan -> tdd -> review -> ship\n- Require explicit user confirmation after plan before TDD\n- Keep evidence artifacts in `.cclaw/artifacts/`\n- Enforce RED before GREEN in TDD\n- Run two-layer review (spec_compliance and code_quality) before ship\n- Validate all inputs before processing \u2014 never trust external data without sanitization\n- Prefer immutable data patterns and pure functions where the language supports them\n- Follow existing repo conventions, patterns, and directory structure \u2014 match the codebase\n- Verify claims with fresh evidence: \"tests pass\" requires running tests in this message\n- Use conventional commits: `type(scope): description` (feat, fix, refactor, test, docs, chore)\n\n## MUST_NEVER\n- Skip RED phase and jump directly to GREEN in TDD\n- Ship with critical review findings\n- Start implementation during /brainstorm\n- Modify generated cclaw files manually when CLI can regenerate them\n- Commit `.cclaw/` or generated shim files\n- Expose secrets, tokens, API keys, or absolute system paths in agent output\n- Duplicate existing functionality without explicit justification \u2014 search before building\n- Bypass security checks, linting hooks, or type checking to \"move faster\"\n- Claim success (\"Done,\" \"All good,\" \"Tests pass\") without running verification in this message\n- Make changes outside the blast radius of the current task without user consent\n\n## DELEGATION\nWhen a task requires specialist knowledge (security audit, performance profiling, database review),\ndelegate to a specialized agent or skill if the harness supports it. The primary agent should:\n1. Identify the specialist domain\n2. Provide focused context (relevant files, the specific concern)\n3. Evaluate the specialist output before acting on it \u2014 do not blindly apply recommendations\n";
|
|
3
|
-
export declare const CURSOR_WORKFLOW_RULE_MDC = "---\ndescription: cclaw workflow guardrails for Cursor agent sessions\nglobs:\n - \"**/*\"\nalwaysApply: true\n---\n\n<!-- cclaw-managed-cursor-workflow-rule -->\n\n# Cclaw Workflow Guardrails\n\n-
|
|
3
|
+
export declare const CURSOR_WORKFLOW_RULE_MDC = "---\ndescription: cclaw workflow guardrails for Cursor agent sessions\nglobs:\n - \"**/*\"\nalwaysApply: true\n---\n\n<!-- cclaw-managed-cursor-workflow-rule -->\n\n# Cclaw Workflow Guardrails\n\n## Activation Rule\n\nBefore responding to coding work:\n1. Read `.cclaw/state/flow-state.json`.\n2. Start with `/cc` or continue with `/cc-next`.\n3. If no software-stage flow applies, respond normally.\n\n## Stage Order\n\n`brainstorm -> scope -> design -> spec -> plan -> tdd -> review -> ship`\n\nTrack-specific skips are allowed only when `flow-state.track` + `skippedStages` explicitly say so.\n\n## Task Classification\n\n| Class | Route |\n|---|---|\n| non-trivial software work | `/cc <idea>` |\n| trivial software fix | `/cc <idea>` (quick or medium track) |\n| bugfix with repro | `/cc <idea>` and enforce RED-first in tdd |\n| pure question / non-software | direct answer (no stage flow) |\n\n## Command Surface\n\n- `/cc` = entry and resume.\n- `/cc-next` = only progression path.\n- `/cc-learn` = knowledge capture and recall.\n\n## Verification Discipline\n\n- No completion claim without fresh command evidence in this turn.\n- Do not mark gates passed from memory.\n- Keep evidence in `.cclaw/artifacts/`; archive only via `cclaw archive`.\n\n## Delegation And Approvals\n\n- Machine-only checks in design/plan/tdd/review/ship should auto-dispatch when tooling supports it.\n- Ask for user input only at explicit approval gates (scope mode, plan approval, challenge resolution, ship finalization).\n- If harness capabilities are partial, record waiver reasons in delegation logs.\n\n## Routing Source Of Truth\n\n- Primary router: `.cclaw/skills/using-cclaw/SKILL.md`.\n- Protocols: `.cclaw/references/protocols/*.md`.\n- Preamble budget: `.cclaw/references/protocols/ethos.md`.\n";
|
|
4
4
|
export declare function buildRulesJson(): Record<string, unknown>;
|
|
@@ -386,11 +386,11 @@ Execution rule: complete and verify each wave before starting the next wave.
|
|
|
386
386
|
|
|
387
387
|
| Pass | Status | Completed at (UTC) | Reviewer / source | Commit at review | Drift vs HEAD |
|
|
388
388
|
|---|---|---|---|---|---|
|
|
389
|
-
| Layer 1 — spec compliance | pass / fail / pending | <ISO 8601> |
|
|
390
|
-
| Layer 2 — correctness | pass / fail / pending | <ISO 8601> |
|
|
389
|
+
| Layer 1 — spec compliance | pass / fail / pending | <ISO 8601> | reviewer | <short sha> | <files changed since> |
|
|
390
|
+
| Layer 2 — correctness | pass / fail / pending | <ISO 8601> | reviewer | <short sha> | <files changed since> |
|
|
391
391
|
| Layer 2 — security | pass / fail / pending | <ISO 8601> | security-reviewer | <short sha> | <files changed since> |
|
|
392
|
-
| Layer 2 — performance | pass / fail / pending | <ISO 8601> |
|
|
393
|
-
| Layer 2 — architecture | pass / fail / pending | <ISO 8601> |
|
|
392
|
+
| Layer 2 — performance | pass / fail / pending | <ISO 8601> | reviewer | <short sha> | <files changed since> |
|
|
393
|
+
| Layer 2 — architecture | pass / fail / pending | <ISO 8601> | reviewer | <short sha> | <files changed since> |
|
|
394
394
|
| Adversarial review | pass / fail / n/a | <ISO 8601 or —> | adversarial-review skill | <short sha or —> | <drift or —> |
|
|
395
395
|
| Review army schema valid | pass / fail | <ISO 8601> | jsonschema | <short sha> | n/a |
|
|
396
396
|
|
|
@@ -531,13 +531,51 @@ alwaysApply: true
|
|
|
531
531
|
|
|
532
532
|
# Cclaw Workflow Guardrails
|
|
533
533
|
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
534
|
+
## Activation Rule
|
|
535
|
+
|
|
536
|
+
Before responding to coding work:
|
|
537
|
+
1. Read \`.cclaw/state/flow-state.json\`.
|
|
538
|
+
2. Start with \`/cc\` or continue with \`/cc-next\`.
|
|
539
|
+
3. If no software-stage flow applies, respond normally.
|
|
540
|
+
|
|
541
|
+
## Stage Order
|
|
542
|
+
|
|
543
|
+
\`brainstorm -> scope -> design -> spec -> plan -> tdd -> review -> ship\`
|
|
544
|
+
|
|
545
|
+
Track-specific skips are allowed only when \`flow-state.track\` + \`skippedStages\` explicitly say so.
|
|
546
|
+
|
|
547
|
+
## Task Classification
|
|
548
|
+
|
|
549
|
+
| Class | Route |
|
|
550
|
+
|---|---|
|
|
551
|
+
| non-trivial software work | \`/cc <idea>\` |
|
|
552
|
+
| trivial software fix | \`/cc <idea>\` (quick or medium track) |
|
|
553
|
+
| bugfix with repro | \`/cc <idea>\` and enforce RED-first in tdd |
|
|
554
|
+
| pure question / non-software | direct answer (no stage flow) |
|
|
555
|
+
|
|
556
|
+
## Command Surface
|
|
557
|
+
|
|
558
|
+
- \`/cc\` = entry and resume.
|
|
559
|
+
- \`/cc-next\` = only progression path.
|
|
560
|
+
- \`/cc-learn\` = knowledge capture and recall.
|
|
561
|
+
|
|
562
|
+
## Verification Discipline
|
|
563
|
+
|
|
564
|
+
- No completion claim without fresh command evidence in this turn.
|
|
565
|
+
- Do not mark gates passed from memory.
|
|
566
|
+
- Keep evidence in \`.cclaw/artifacts/\`; archive only via \`cclaw archive\`.
|
|
567
|
+
|
|
568
|
+
## Delegation And Approvals
|
|
569
|
+
|
|
570
|
+
- Machine-only checks in design/plan/tdd/review/ship should auto-dispatch when tooling supports it.
|
|
571
|
+
- Ask for user input only at explicit approval gates (scope mode, plan approval, challenge resolution, ship finalization).
|
|
572
|
+
- If harness capabilities are partial, record waiver reasons in delegation logs.
|
|
573
|
+
|
|
574
|
+
## Routing Source Of Truth
|
|
575
|
+
|
|
576
|
+
- Primary router: \`.cclaw/skills/using-cclaw/SKILL.md\`.
|
|
577
|
+
- Protocols: \`.cclaw/references/protocols/*.md\`.
|
|
578
|
+
- Preamble budget: \`.cclaw/references/protocols/ethos.md\`.
|
|
541
579
|
`;
|
|
542
580
|
export function buildRulesJson() {
|
|
543
581
|
return {
|
package/dist/delegation.d.ts
CHANGED
package/dist/delegation.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { RUNTIME_ROOT } from "./constants.js";
|
|
4
|
+
import { readConfig } from "./config.js";
|
|
4
5
|
import { exists, withDirectoryLock, writeFileSafe } from "./fs-utils.js";
|
|
6
|
+
import { HARNESS_ADAPTERS } from "./harness-adapters.js";
|
|
5
7
|
import { readFlowState } from "./runs.js";
|
|
6
8
|
import { stageSchema } from "./content/stage-schema.js";
|
|
7
9
|
function delegationLogPath(projectRoot) {
|
|
@@ -84,11 +86,34 @@ export async function checkMandatoryDelegations(projectRoot, stage) {
|
|
|
84
86
|
.map((e) => `${e.agent}(runId=${e.runId ?? "unknown"})`);
|
|
85
87
|
const missing = [];
|
|
86
88
|
const waived = [];
|
|
89
|
+
const autoWaived = [];
|
|
90
|
+
const config = await readConfig(projectRoot).catch(() => null);
|
|
91
|
+
const harnesses = config?.harnesses ?? [];
|
|
92
|
+
const nativeDelegationUnavailable = harnesses.length > 0 &&
|
|
93
|
+
harnesses.every((harness) => HARNESS_ADAPTERS[harness].capabilities.nativeSubagentDispatch === "none");
|
|
87
94
|
for (const agent of mandatory) {
|
|
88
95
|
const rows = forRun.filter((e) => e.agent === agent);
|
|
89
96
|
const ok = rows.some((e) => e.status === "completed" || e.status === "waived");
|
|
90
97
|
if (!ok) {
|
|
91
|
-
|
|
98
|
+
if (nativeDelegationUnavailable) {
|
|
99
|
+
const existingHarnessWaiver = rows.some((e) => e.status === "waived" && e.waiverReason === "harness_limitation");
|
|
100
|
+
if (!existingHarnessWaiver) {
|
|
101
|
+
await appendDelegation(projectRoot, {
|
|
102
|
+
stage,
|
|
103
|
+
agent,
|
|
104
|
+
mode: "mandatory",
|
|
105
|
+
status: "waived",
|
|
106
|
+
waiverReason: "harness_limitation",
|
|
107
|
+
ts: new Date().toISOString(),
|
|
108
|
+
runId: activeRunId
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
waived.push(agent);
|
|
112
|
+
autoWaived.push(agent);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
missing.push(agent);
|
|
116
|
+
}
|
|
92
117
|
}
|
|
93
118
|
else if (rows.some((e) => e.status === "waived")) {
|
|
94
119
|
waived.push(agent);
|
|
@@ -98,6 +123,7 @@ export async function checkMandatoryDelegations(projectRoot, stage) {
|
|
|
98
123
|
satisfied: missing.length === 0,
|
|
99
124
|
missing,
|
|
100
125
|
waived,
|
|
126
|
+
autoWaived,
|
|
101
127
|
staleIgnored
|
|
102
128
|
};
|
|
103
129
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type DoctorSeverity = "error" | "warning" | "info";
|
|
2
|
+
export interface DoctorCheckMetadata {
|
|
3
|
+
severity: DoctorSeverity;
|
|
4
|
+
summary: string;
|
|
5
|
+
fix: string;
|
|
6
|
+
docRef?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function doctorCheckMetadata(checkName: string): DoctorCheckMetadata;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { DOCTOR_REFERENCE_DIR } from "./content/doctor-references.js";
|
|
2
|
+
function ref(fileName) {
|
|
3
|
+
return `${DOCTOR_REFERENCE_DIR}/${fileName}`;
|
|
4
|
+
}
|
|
5
|
+
const RULES = [
|
|
6
|
+
{
|
|
7
|
+
test: /^gates:reconcile:writeback$/,
|
|
8
|
+
metadata: {
|
|
9
|
+
severity: "info",
|
|
10
|
+
summary: "Gate reconciliation status update.",
|
|
11
|
+
fix: "No action required unless subsequent gate checks fail.",
|
|
12
|
+
docRef: ref("state-and-gates.md")
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
test: /^warning:/,
|
|
17
|
+
metadata: {
|
|
18
|
+
severity: "warning",
|
|
19
|
+
summary: "Advisory signal; runtime can continue with caution.",
|
|
20
|
+
fix: "Address when possible to prevent future drift or degraded behavior.",
|
|
21
|
+
docRef: ref("README.md")
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
test: /^skill:.*:(max_lines|min_lines|canonical_sections)$/,
|
|
26
|
+
metadata: {
|
|
27
|
+
severity: "warning",
|
|
28
|
+
summary: "Stage skill quality guardrail check.",
|
|
29
|
+
fix: "Tune generated stage skill content and re-run `cclaw sync`.",
|
|
30
|
+
docRef: ref("runtime-layout.md")
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
test: /^capability:runtime:json_parser$/,
|
|
35
|
+
metadata: {
|
|
36
|
+
severity: "warning",
|
|
37
|
+
summary: "Optional JSON fallback parser availability.",
|
|
38
|
+
fix: "Install at least one of `python3` or `jq` for resilient fallback parsing.",
|
|
39
|
+
docRef: ref("tooling-capabilities.md")
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
test: /^capability:required:/,
|
|
44
|
+
metadata: {
|
|
45
|
+
severity: "error",
|
|
46
|
+
summary: "Required runtime tooling availability check.",
|
|
47
|
+
fix: "Install the missing required tool and re-run `cclaw doctor`.",
|
|
48
|
+
docRef: ref("tooling-capabilities.md")
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
test: /^(dir:|command:|utility_command:|skill:|utility_skill:|agent:|harness_tool_ref:|harness_ref:|stage_examples_ref:|doctor_ref:)/,
|
|
53
|
+
metadata: {
|
|
54
|
+
severity: "error",
|
|
55
|
+
summary: "Generated runtime surface presence check.",
|
|
56
|
+
fix: "Run `cclaw sync` to regenerate runtime files, then re-run doctor.",
|
|
57
|
+
docRef: ref("runtime-layout.md")
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
test: /^(hook:|lifecycle:|git_hooks:)/,
|
|
62
|
+
metadata: {
|
|
63
|
+
severity: "error",
|
|
64
|
+
summary: "Hook wiring and lifecycle integration check.",
|
|
65
|
+
fix: "Repair hook/plugin wiring (usually via `cclaw sync`) and validate harness config.",
|
|
66
|
+
docRef: ref("hooks-and-lifecycle.md")
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
test: /^(shim:|agents:cclaw_block|rules:cursor:workflow)/,
|
|
71
|
+
metadata: {
|
|
72
|
+
severity: "error",
|
|
73
|
+
summary: "Harness shim and routing file consistency check.",
|
|
74
|
+
fix: "Regenerate harness adapters via `cclaw sync`; confirm enabled harness list.",
|
|
75
|
+
docRef: ref("harness-and-routing.md")
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
test: /^(flow_state:|state:|contexts:|gates:)/,
|
|
80
|
+
metadata: {
|
|
81
|
+
severity: "error",
|
|
82
|
+
summary: "Flow state and gate evidence consistency check.",
|
|
83
|
+
fix: "Repair flow-state artifacts and gate evidence, then run `cclaw doctor --reconcile-gates`.",
|
|
84
|
+
docRef: ref("state-and-gates.md")
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
test: /^delegation:/,
|
|
89
|
+
metadata: {
|
|
90
|
+
severity: "error",
|
|
91
|
+
summary: "Mandatory delegation completion check.",
|
|
92
|
+
fix: "Complete or explicitly waive missing mandatory delegations in delegation log.",
|
|
93
|
+
docRef: ref("delegation-and-preamble.md")
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
test: /^trace:/,
|
|
98
|
+
metadata: {
|
|
99
|
+
severity: "error",
|
|
100
|
+
summary: "Cross-artifact traceability integrity check.",
|
|
101
|
+
fix: "Restore criterion/task/test ID mappings across spec, plan, and tdd artifacts.",
|
|
102
|
+
docRef: ref("traceability.md")
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
test: /^(config:|rules:policy_schema|language_rule_pack:|gitignore:|git:)/,
|
|
107
|
+
metadata: {
|
|
108
|
+
severity: "error",
|
|
109
|
+
summary: "Config or policy schema consistency check.",
|
|
110
|
+
fix: "Fix config/rules drift, then run `cclaw sync` and re-run doctor.",
|
|
111
|
+
docRef: ref("config-and-policy.md")
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
];
|
|
115
|
+
export function doctorCheckMetadata(checkName) {
|
|
116
|
+
for (const rule of RULES) {
|
|
117
|
+
if (rule.test.test(checkName)) {
|
|
118
|
+
return { ...rule.metadata };
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
severity: "error",
|
|
123
|
+
summary: "Doctor runtime integrity check.",
|
|
124
|
+
fix: "Inspect check details, apply the suggested remediation, and re-run `cclaw doctor`.",
|
|
125
|
+
docRef: ref("README.md")
|
|
126
|
+
};
|
|
127
|
+
}
|
package/dist/doctor.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import type { DoctorSeverity } from "./doctor-registry.js";
|
|
1
2
|
export interface DoctorCheck {
|
|
2
3
|
name: string;
|
|
3
4
|
ok: boolean;
|
|
4
5
|
details: string;
|
|
6
|
+
severity: DoctorSeverity;
|
|
7
|
+
summary: string;
|
|
8
|
+
fix: string;
|
|
9
|
+
docRef?: string;
|
|
5
10
|
}
|
|
6
11
|
export interface DoctorOptions {
|
|
7
12
|
/** When true, normalize current-stage gate catalog and persist reconciliation before checks. */
|