cclaw-cli 0.5.16 → 0.6.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.
@@ -20,6 +20,7 @@ Use it to keep durable knowledge that should survive sessions:
20
20
  - **rule**: hard constraint to follow every time
21
21
  - **pattern**: repeatable way that works well in this project
22
22
  - **lesson**: non-obvious outcome from a failure or trade-off
23
+ - **compound**: post-ship insight about how to make the *next* feature faster (process accelerator, not domain rule)
23
24
 
24
25
  ## HARD-GATE
25
26
 
@@ -33,12 +34,25 @@ Under \`/cc-learn\`, only modify the knowledge store (\`${KNOWLEDGE_PATH}\`) or
33
34
  - Context: one short line
34
35
  - Insight: one short line
35
36
  - Reuse: one short line
37
+ - Confidence: high | medium | low (optional)
38
+ - Domain: api | infra | ui | testing | … (optional)
39
+ - Project: <repo or scope name> (optional)
36
40
  \`\`\`
37
41
 
38
42
  Rules:
39
- - Type must be exactly one of \`rule\`, \`pattern\`, \`lesson\` (lowercase).
40
- - Never rewrite history silently; append a newer correction entry instead.
43
+ - Type must be exactly one of \`rule\`, \`pattern\`, \`lesson\`, \`compound\` (lowercase).
44
+ - Never rewrite history silently; append a newer correction entry instead. To replace, prefix the new entry with \`Supersedes: <old-title>\`.
41
45
  - Keep entries concise and actionable.
46
+ - Optional fields (\`Confidence\`, \`Domain\`, \`Project\`) are forward-compatible and used by the **knowledge-curation** skill — fill them when known.
47
+
48
+ ## Curation policy (target: ≤ 50 active entries)
49
+
50
+ The knowledge file is append-only, but entries can be **superseded** rather than deleted:
51
+
52
+ - When you discover a more correct rule, append a new entry with \`Supersedes: <old-title>\`.
53
+ - During \`/cc-learn curate\`, the assistant surfaces candidates for soft-archive (move to \`.cclaw/knowledge.archive.md\`) when the active file exceeds 50 entries or contains stale/duplicate entries.
54
+
55
+ See the **knowledge-curation** utility skill for the full curation protocol.
42
56
 
43
57
  ## Subcommands
44
58
 
@@ -52,8 +66,13 @@ Rules:
52
66
 
53
67
  ### \`/cc-learn add\`
54
68
  - Ask for: \`type\`, \`short title\`, \`context\`, \`insight\`, \`reuse\`.
69
+ - Optionally ask for: \`confidence\`, \`domain\`, \`project\`.
55
70
  - Append one entry using current UTC timestamp.
56
71
  - Re-read the file tail and confirm the entry was written.
72
+
73
+ ### \`/cc-learn curate\`
74
+ - Hand off to the **knowledge-curation** skill (read-only audit + soft-archive plan).
75
+ - Never deletes from \`${KNOWLEDGE_PATH}\` without an explicit user-approved archive plan.
57
76
  `;
58
77
  }
59
78
  export function learnCommandContract() {
@@ -73,7 +92,8 @@ Do not edit source code from this command. Only operate on \`${KNOWLEDGE_PATH}\`
73
92
  |---|---|---|
74
93
  | (default) | — | Show recent knowledge entries (tail view). |
75
94
  | \`search\` | \`<query>\` | Search knowledge text for relevant prior rules/patterns/lessons. |
76
- | \`add\` | — | Append a new entry with type \`rule\` / \`pattern\` / \`lesson\`. |
95
+ | \`add\` | — | Append a new entry with type \`rule\` / \`pattern\` / \`lesson\` / \`compound\`. |
96
+ | \`curate\` | — | Hand off to the **knowledge-curation** skill: read-only audit + soft-archive plan when the active file exceeds the curation threshold. |
77
97
  `;
78
98
  }
79
99
  export function selfImprovementBlock(stageName) {
@@ -96,7 +116,7 @@ cat >> ${KNOWLEDGE_PATH} <<EOF
96
116
  EOF
97
117
  \`\`\`
98
118
 
99
- Type must be exactly one of: \`rule\`, \`pattern\`, \`lesson\`.
119
+ Type must be exactly one of: \`rule\`, \`pattern\`, \`lesson\`, \`compound\`.
100
120
  `;
101
121
  }
102
122
  export function learningsSearchPreamble(stage) {
@@ -110,7 +130,7 @@ If the file is empty, continue normally.
110
130
  export function learningsAgentsMdBlock() {
111
131
  return `### Knowledge Store
112
132
 
113
- \`${KNOWLEDGE_PATH}\` — append-only markdown memory with entry types \`rule\`, \`pattern\`, \`lesson\`.
133
+ \`${KNOWLEDGE_PATH}\` — append-only markdown memory with entry types \`rule\`, \`pattern\`, \`lesson\`, \`compound\`.
114
134
  At session start and stage transitions, load recent entries and apply relevant ones.
115
135
  If a non-obvious reusable rule/pattern/lesson is discovered, append a new entry.
116
136
  `;
@@ -89,6 +89,18 @@ These skills live in \`.cclaw/skills/\` but have no slash commands. They activat
89
89
 
90
90
  **Activation rule:** When a contextual skill applies, read its SKILL.md and follow it as a supplementary lens alongside the current stage. Do not skip the stage workflow — the contextual skill adds depth, not a detour.
91
91
 
92
+ ## Custom Skills (project-owned, sync-safe)
93
+
94
+ \`.cclaw/custom-skills/\` is a sync-safe directory. \`cclaw sync\` and \`cclaw upgrade\` **never overwrite** files there.
95
+
96
+ Use it to add **project-specific** skills that complement the managed library:
97
+
98
+ - Each skill: \`.cclaw/custom-skills/<folder>/SKILL.md\` with the same frontmatter format as managed skills (\`name\` + \`description\` triggering routing).
99
+ - Activate by mentioning the skill name explicitly, or rely on semantic routing from the description.
100
+ - See \`.cclaw/custom-skills/README.md\` for the full convention and a starter template under \`.cclaw/custom-skills/example/\`.
101
+
102
+ If a custom skill turns out to generalize (e.g. another project would want the same lens), promote it to a managed skill via a contribution to the cclaw repo — managed skills get versioning and maintenance.
103
+
92
104
  ## Progressive Disclosure (Depth / See Also)
93
105
 
94
106
  Use this loading order to keep context lean while preserving depth:
@@ -56,6 +56,14 @@ This is the only progression command the user needs to drive the entire flow. St
56
56
  → If current stage's \`next\` is **\`done\`**: report **"Flow complete. All stages finished."** and stop.
57
57
  → Otherwise: load **\`${RUNTIME_ROOT}/skills/<skillFolder>/SKILL.md\`** and **\`${RUNTIME_ROOT}/commands/<nextStage>.md\`** for the successor stage. Execute that stage's protocol.
58
58
 
59
+ ### Track-aware successor resolution
60
+
61
+ \`flow-state.json\` carries a \`track\` field (\`"quick"\` or \`"standard"\`) and a \`skippedStages\` array.
62
+
63
+ - If \`track === "quick"\`, the critical path is **spec → tdd → review → ship**. When advancing, skip any stage listed in \`skippedStages\` — i.e. after the current stage completes, pick the next stage that is NOT in \`skippedStages\`.
64
+ - If \`track === "standard"\`, advance through all 8 stages in their natural order.
65
+ - Never reintroduce a skipped stage mid-run. If the user wants upstream scoping work, they must archive the run and start a new one with \`track: "standard"\`.
66
+
59
67
  ## Resume Semantics
60
68
 
61
69
  \`/cc-next\` in a **new session** = resume from where you left off:
@@ -1613,6 +1613,14 @@ export function claudeHooksJsonWithObservation() {
1613
1613
  command: `bash ${RUNTIME_ROOT}/hooks/stop-checkpoint.sh`,
1614
1614
  timeout: 10
1615
1615
  }]
1616
+ }],
1617
+ PreCompact: [{
1618
+ matcher: "manual|auto",
1619
+ hooks: [{
1620
+ type: "command",
1621
+ command: `bash ${RUNTIME_ROOT}/hooks/pre-compact.sh`,
1622
+ timeout: 10
1623
+ }]
1616
1624
  }]
1617
1625
  }
1618
1626
  }, null, 2);
@@ -1632,6 +1640,8 @@ export function cursorHooksJsonWithObservation() {
1632
1640
  command: `bash ${RUNTIME_ROOT}/hooks/session-start.sh`
1633
1641
  }],
1634
1642
  sessionCompact: [{
1643
+ command: `bash ${RUNTIME_ROOT}/hooks/pre-compact.sh`
1644
+ }, {
1635
1645
  command: `bash ${RUNTIME_ROOT}/hooks/session-start.sh`
1636
1646
  }],
1637
1647
  preToolUse: [{
@@ -1684,6 +1694,14 @@ export function codexHooksJsonWithObservation() {
1684
1694
  command: `bash ${RUNTIME_ROOT}/hooks/stop-checkpoint.sh`,
1685
1695
  timeout: 10
1686
1696
  }]
1697
+ }],
1698
+ PreCompact: [{
1699
+ matcher: "manual|auto",
1700
+ hooks: [{
1701
+ type: "command",
1702
+ command: `bash ${RUNTIME_ROOT}/hooks/pre-compact.sh`,
1703
+ timeout: 10
1704
+ }]
1687
1705
  }]
1688
1706
  }
1689
1707
  }, null, 2);
@@ -34,7 +34,7 @@ When a new session begins in any harness:
34
34
  ### What to show the user at session start
35
35
 
36
36
  \`\`\`
37
- Cclaw flow state: [current stage] ([N] of 9 stages completed)
37
+ Cclaw flow state: [current stage] ([N] of 8 stages completed)
38
38
  Knowledge highlights: [rule/pattern 1], [rule/pattern 2], [rule/pattern 3]
39
39
  Next action: /cc-[stage] to continue, or describe what you'd like to do.
40
40
  \`\`\`
@@ -1147,7 +1147,8 @@ const REVIEW = {
1147
1147
  { id: "review_layer2_architecture", description: "Architecture fit review completed." },
1148
1148
  { id: "review_severity_classified", description: "All findings are severity-tagged." },
1149
1149
  { id: "review_criticals_resolved", description: "No unresolved critical blockers remain." },
1150
- { id: "review_army_json_valid", description: "07-review-army.json passes schema validation (validateReviewArmy)." }
1150
+ { id: "review_army_json_valid", description: "07-review-army.json passes schema validation (validateReviewArmy)." },
1151
+ { id: "review_completeness_scored", description: "Completeness score is computed and recorded (AC coverage, task coverage, slice coverage, adversarial pass)." }
1151
1152
  ],
1152
1153
  requiredEvidence: [
1153
1154
  "Artifact written to `.cclaw/artifacts/07-review.md`.",
@@ -1289,6 +1290,7 @@ const REVIEW = {
1289
1290
  { section: "Layer 2 Findings", required: true, validationRule: "Each finding has severity, description, and resolution status." },
1290
1291
  { section: "Review Army Contract", required: true, validationRule: "Structured findings include id/severity/confidence/fingerprint/reportedBy/status with dedup reconciliation summary." },
1291
1292
  { section: "Review Readiness Dashboard", required: true, validationRule: "At least 4 readiness checklist lines including blocker and recommendation status." },
1293
+ { section: "Completeness Score", required: true, validationRule: "Records AC coverage, task coverage, test-slice coverage, and adversarial-review pass status as numeric or boolean values. At minimum, a line like 'AC coverage: N/M' or 'AC coverage: 100%'." },
1292
1294
  { section: "Severity Summary", required: true, validationRule: "Per-severity count lines for critical, important, and suggestion buckets." },
1293
1295
  { section: "Final Verdict", required: true, validationRule: "Exactly one of: APPROVED, APPROVED_WITH_CONCERNS, BLOCKED." }
1294
1296
  ],
@@ -1450,7 +1452,8 @@ const SHIP = {
1450
1452
  { section: "Rollback Plan", required: true, validationRule: "Trigger conditions, rollback steps (exact commands), verification steps." },
1451
1453
  { section: "Monitoring", required: false, validationRule: "If applicable: what metrics/logs to watch post-deploy. Risk note if no monitoring." },
1452
1454
  { section: "Finalization", required: true, validationRule: "Exactly one finalization enum token selected. Execution result documented. Worktree cleaned if applicable." },
1453
- { section: "Completion Status", required: false, validationRule: "If present: exactly one of SHIPPED, SHIPPED_WITH_EXCEPTIONS, BLOCKED. Exceptions documented when applicable." }
1455
+ { section: "Completion Status", required: false, validationRule: "If present: exactly one of SHIPPED, SHIPPED_WITH_EXCEPTIONS, BLOCKED. Exceptions documented when applicable." },
1456
+ { section: "Compound Step", required: false, validationRule: "Optional retrospective: at least one bullet of the form 'Insight: ... | Action: append [compound] entry to .cclaw/knowledge.md', or an explicit 'No compound insight this run.' line." }
1454
1457
  ],
1455
1458
  namedAntiPattern: {
1456
1459
  title: "Green CI Means Safe to Merge",
@@ -1512,6 +1515,13 @@ const STAGE_AUTO_SUBAGENT_DISPATCH = {
1512
1515
  when: "When acceptance criteria are unclear or constraints conflict.",
1513
1516
  purpose: "Normalize measurable criteria and testability mapping.",
1514
1517
  requiresUserGate: false
1518
+ },
1519
+ {
1520
+ agent: "spec-reviewer",
1521
+ mode: "proactive",
1522
+ when: "When acceptance criteria and edge cases are drafted and need independent validation before plan stage.",
1523
+ purpose: "Independent review of spec against measurability, testability, and completeness before locking the contract for plan.",
1524
+ requiresUserGate: false
1515
1525
  }
1516
1526
  ],
1517
1527
  plan: [
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Command contract for /cc-status — a read-only snapshot command.
3
+ * Does not mutate state. Always safe to run.
4
+ */
5
+ export declare function statusCommandContract(): string;
6
+ /**
7
+ * Skill body for /cc-status — read-only status snapshot.
8
+ */
9
+ export declare function statusCommandSkillMarkdown(): string;
@@ -0,0 +1,132 @@
1
+ import { RUNTIME_ROOT } from "../constants.js";
2
+ const STATUS_SKILL_FOLDER = "flow-status";
3
+ const STATUS_SKILL_NAME = "flow-status";
4
+ function flowStatePath() {
5
+ return `${RUNTIME_ROOT}/state/flow-state.json`;
6
+ }
7
+ function delegationLogPath() {
8
+ return `${RUNTIME_ROOT}/state/delegation-log.json`;
9
+ }
10
+ function knowledgePath() {
11
+ return `${RUNTIME_ROOT}/knowledge.md`;
12
+ }
13
+ /**
14
+ * Command contract for /cc-status — a read-only snapshot command.
15
+ * Does not mutate state. Always safe to run.
16
+ */
17
+ export function statusCommandContract() {
18
+ const flowPath = flowStatePath();
19
+ const delegationPath = delegationLogPath();
20
+ return `# /cc-status
21
+
22
+ ## Purpose
23
+
24
+ **Read-only snapshot of the cclaw run.** Shows track, current stage, completed stages,
25
+ gate coverage, mandatory delegations, and the top 3 knowledge highlights.
26
+
27
+ This command **never mutates state**. Use it at session start to orient, or at any
28
+ time to answer "where are we?" without advancing the flow.
29
+
30
+ ## HARD-GATE
31
+
32
+ - **Do not** use \`/cc-status\` output to infer gate completion for decisions — cite
33
+ artifact evidence via \`/cc-next\` when advancing.
34
+ - **Do not** mutate \`${flowPath}\` or delegation log from this command.
35
+
36
+ ## Algorithm
37
+
38
+ 1. Read **\`${flowPath}\`** — capture \`track\`, \`currentStage\`, \`completedStages\`,
39
+ \`skippedStages\`, and per-stage gate catalog.
40
+ 2. Read **\`${delegationPath}\`** — count delegated / completed / waived / pending entries
41
+ for the current stage's \`mandatoryDelegations\`.
42
+ 3. Read the top of **\`${knowledgePath}\`** — surface up to 3 most recent entries
43
+ (by trailing timestamp or source marker).
44
+ 4. Emit the status block described below. Do **not** load any stage skill.
45
+
46
+ ## Status Block Format
47
+
48
+ \`\`\`
49
+ cclaw status
50
+ track: <quick|standard>
51
+ current stage: <stage> (<N>/<total> in track)
52
+ completed stages: <list or "none">
53
+ skipped stages: <list or "none">
54
+
55
+ gates:
56
+ passed: <count> of <required>
57
+ blocked: <count>
58
+ unmet: <list of gate ids>
59
+
60
+ delegations (current stage):
61
+ required: <list>
62
+ completed: <list>
63
+ pending: <list>
64
+
65
+ knowledge highlights:
66
+ - <latest entry summary line>
67
+ - <second entry summary line>
68
+ - <third entry summary line>
69
+
70
+ next action:
71
+ /cc-next (advance or resume current stage)
72
+ \`\`\`
73
+
74
+ ## Anti-patterns
75
+
76
+ - Inventing gate status without reading \`${flowPath}\`.
77
+ - Reporting delegations as satisfied when the log says \`pending\`.
78
+ - Advancing the stage from \`/cc-status\` — progression belongs to \`/cc-next\`.
79
+
80
+ ## Primary skill
81
+
82
+ **${RUNTIME_ROOT}/skills/${STATUS_SKILL_FOLDER}/SKILL.md**
83
+ `;
84
+ }
85
+ /**
86
+ * Skill body for /cc-status — read-only status snapshot.
87
+ */
88
+ export function statusCommandSkillMarkdown() {
89
+ const flowPath = flowStatePath();
90
+ const delegationPath = delegationLogPath();
91
+ return `---
92
+ name: ${STATUS_SKILL_NAME}
93
+ description: "Read-only snapshot of the cclaw flow: track, stage, gate coverage, delegations, knowledge highlights. Never mutates state."
94
+ ---
95
+
96
+ # /cc-status — Flow Status Snapshot
97
+
98
+ ## Overview
99
+
100
+ \`/cc-status\` is the quickest way to answer "where are we in the flow?" without
101
+ advancing or mutating anything. Safe to run at any point.
102
+
103
+ ## HARD-GATE
104
+
105
+ Do **not** mutate \`${flowPath}\` or \`${delegationPath}\` from this skill. This is
106
+ a read-only command.
107
+
108
+ ## Algorithm
109
+
110
+ 1. Read \`${flowPath}\`. If missing → report **BLOCKED: flow state absent** and suggest \`cclaw init\`.
111
+ 2. Read \`${delegationPath}\`. Missing → treat all mandatory delegations as pending.
112
+ 3. Read \`${RUNTIME_ROOT}/knowledge.md\`. If missing or empty → knowledge highlights are \`(none recorded)\`.
113
+ 4. For each gate in \`stageGateCatalog[currentStage].required\`:
114
+ - Satisfied if present in \`passed\` and absent from \`blocked\`.
115
+ 5. Build and print the status block (see command contract for layout).
116
+ 6. Suggest the next action:
117
+ - If current stage has unmet gates → \`/cc-next\` to resume.
118
+ - If current stage is complete → \`/cc-next\` to advance (or report "Flow complete" if terminal).
119
+
120
+ ## Output Guidelines
121
+
122
+ - Keep output compact (≤ 25 lines) — status, not narrative.
123
+ - Report counts, not full artifact contents.
124
+ - If any data source is missing or corrupt, say so explicitly rather than guessing.
125
+
126
+ ## Anti-patterns
127
+
128
+ - Rebuilding trace-matrix or running doctor from \`/cc-status\` — those belong to dedicated tools.
129
+ - Treating absence of delegation log as "all delegations complete".
130
+ - Mutating state to "clean up" during a status check.
131
+ `;
132
+ }
@@ -349,8 +349,16 @@ Execution rule: complete and verify each wave before starting the next wave.
349
349
  - Layer 2 complete:
350
350
  - Review army schema valid:
351
351
  - Open critical blockers:
352
+ - Adversarial review pass:
352
353
  - Ship recommendation:
353
354
 
355
+ ## Completeness Score
356
+ - AC coverage: <N>/<M> (<percent>%)
357
+ - Task coverage (tasks backed by ≥1 test slice): <N>/<M>
358
+ - Slice coverage (slices linked to ≥1 AC): <N>/<M>
359
+ - Adversarial review pass: true | false
360
+ - Overall score: <0-100>
361
+
354
362
  ## Severity Summary
355
363
  - Critical:
356
364
  - Important:
@@ -361,28 +369,13 @@ Execution rule: complete and verify each wave before starting the next wave.
361
369
  `,
362
370
  "07-review-army.json": `{
363
371
  "version": 1,
364
- "generatedAt": "",
372
+ "generatedAt": "<ISO 8601 timestamp, e.g. 2026-04-14T12:00:00Z>",
365
373
  "scope": {
366
- "base": "",
367
- "head": "",
374
+ "base": "<base branch or ref>",
375
+ "head": "<head branch or ref>",
368
376
  "files": []
369
377
  },
370
- "findings": [
371
- {
372
- "id": "",
373
- "title": "",
374
- "severity": "Critical",
375
- "confidence": 7,
376
- "category": "correctness",
377
- "location": {
378
- "file": ""
379
- },
380
- "fingerprint": "",
381
- "reportedBy": [],
382
- "status": "open",
383
- "recommendation": ""
384
- }
385
- ],
378
+ "findings": [],
386
379
  "reconciliation": {
387
380
  "duplicatesCollapsed": 0,
388
381
  "conflicts": [],
@@ -426,6 +419,12 @@ Execution rule: complete and verify each wave before starting the next wave.
426
419
  ## Completion Status
427
420
  - SHIPPED | SHIPPED_WITH_EXCEPTIONS | BLOCKED
428
421
  - Exceptions (if any):
422
+
423
+ ## Compound Step
424
+ _Optional retrospective. The goal is to make the **next** feature faster, not to evaluate this one._
425
+ _If you have nothing to add, write the explicit line: \`No compound insight this run.\`_
426
+ - Insight: <one short line about what should accelerate the next run>
427
+ - Action: append \`[compound]\` entry to \`.cclaw/knowledge.md\` capturing the insight
429
428
  `
430
429
  };
431
430
  export const RULEBOOK_MARKDOWN = `# Cclaw Rulebook
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Utility skills that complement the 9 flow stages.
2
+ * Utility skills that complement the 8 flow stages.
3
3
  * These are contextual lenses, not flow stages.
4
4
  * Each skill: ~120-180 lines, under the 500-line progressive disclosure guideline.
5
5
  */
@@ -12,5 +12,9 @@ export declare function executingPlansSkill(): string;
12
12
  export declare function contextEngineeringSkill(): string;
13
13
  export declare function sourceDrivenDevelopmentSkill(): string;
14
14
  export declare function frontendAccessibilitySkill(): string;
15
- export declare const UTILITY_SKILL_FOLDERS: readonly ["security", "debugging", "performance", "ci-cd", "docs", "executing-plans", "context-engineering", "source-driven-development", "frontend-accessibility"];
15
+ export declare function landscapeCheckSkill(): string;
16
+ export declare function knowledgeCurationSkill(): string;
17
+ export declare function securityAuditSkill(): string;
18
+ export declare function adversarialReviewSkill(): string;
19
+ export declare const UTILITY_SKILL_FOLDERS: readonly ["security", "debugging", "performance", "ci-cd", "docs", "executing-plans", "context-engineering", "source-driven-development", "frontend-accessibility", "landscape-check", "adversarial-review", "security-audit", "knowledge-curation"];
16
20
  export declare const UTILITY_SKILL_MAP: Record<string, () => string>;