cclaw-cli 0.5.17 → 0.7.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.
@@ -0,0 +1,154 @@
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
+ function contextModePath() {
14
+ return `${RUNTIME_ROOT}/state/context-mode.json`;
15
+ }
16
+ function checkpointPath() {
17
+ return `${RUNTIME_ROOT}/state/checkpoint.json`;
18
+ }
19
+ function stageActivityPath() {
20
+ return `${RUNTIME_ROOT}/state/stage-activity.jsonl`;
21
+ }
22
+ /**
23
+ * Command contract for /cc-status — a read-only snapshot command.
24
+ * Does not mutate state. Always safe to run.
25
+ */
26
+ export function statusCommandContract() {
27
+ const flowPath = flowStatePath();
28
+ const delegationPath = delegationLogPath();
29
+ return `# /cc-status
30
+
31
+ ## Purpose
32
+
33
+ **Read-only snapshot of the cclaw run.** Shows track, current stage, completed stages,
34
+ gate coverage, mandatory delegations, and the top 3 knowledge highlights.
35
+
36
+ This command **never mutates state**. Use it at session start to orient, or at any
37
+ time to answer "where are we?" without advancing the flow.
38
+
39
+ ## HARD-GATE
40
+
41
+ - **Do not** use \`/cc-status\` output to infer gate completion for decisions — cite
42
+ artifact evidence via \`/cc-next\` when advancing.
43
+ - **Do not** mutate \`${flowPath}\` or delegation log from this command.
44
+
45
+ ## Algorithm
46
+
47
+ 1. Read **\`${flowPath}\`** — capture \`track\`, \`currentStage\`, \`completedStages\`,
48
+ \`skippedStages\`, and per-stage gate catalog.
49
+ 2. Read **\`${delegationPath}\`** — count delegated / completed / waived / pending entries
50
+ for the current stage's \`mandatoryDelegations\`.
51
+ 3. Read **\`${contextModePath()}\`** — surface \`activeMode\` (default if missing).
52
+ 4. Compute **time in current stage** from the most recent stage-entry signal:
53
+ - Prefer \`${checkpointPath()}\`'s \`timestamp\` when its \`stage\` matches \`currentStage\`.
54
+ - Otherwise scan \`${stageActivityPath()}\` from the end for the first entry whose \`stage\` matches \`currentStage\` and use its \`ts\`.
55
+ - Compute the duration as \`now - signalTimestamp\` and render compactly: \`<X>m\`, \`<X>h<Y>m\`, or \`<X>d<Y>h\`.
56
+ - If no signal exists, render \`(unknown)\`.
57
+ 5. Read the top of **\`${knowledgePath}\`** — surface up to 3 most recent entries
58
+ (by trailing timestamp or source marker).
59
+ 6. Emit the status block described below. Do **not** load any stage skill.
60
+
61
+ ## Status Block Format
62
+
63
+ \`\`\`
64
+ cclaw status
65
+ track: <quick|standard>
66
+ current stage: <stage> (<N>/<total> in track)
67
+ time in stage: <Xd Yh | Yh Zm | Zm | unknown>
68
+ context mode: <activeMode> (default | execution | review | incident | …)
69
+ completed stages: <list or "none">
70
+ skipped stages: <list or "none">
71
+
72
+ gates:
73
+ passed: <count> of <required>
74
+ blocked: <count>
75
+ unmet: <list of gate ids>
76
+
77
+ delegations (current stage):
78
+ required: <list>
79
+ completed: <list>
80
+ pending: <list>
81
+
82
+ knowledge highlights:
83
+ - <latest entry summary line>
84
+ - <second entry summary line>
85
+ - <third entry summary line>
86
+
87
+ next action:
88
+ /cc-next (advance or resume current stage)
89
+ \`\`\`
90
+
91
+ ## Anti-patterns
92
+
93
+ - Inventing gate status without reading \`${flowPath}\`.
94
+ - Reporting delegations as satisfied when the log says \`pending\`.
95
+ - Advancing the stage from \`/cc-status\` — progression belongs to \`/cc-next\`.
96
+
97
+ ## Primary skill
98
+
99
+ **${RUNTIME_ROOT}/skills/${STATUS_SKILL_FOLDER}/SKILL.md**
100
+ `;
101
+ }
102
+ /**
103
+ * Skill body for /cc-status — read-only status snapshot.
104
+ */
105
+ export function statusCommandSkillMarkdown() {
106
+ const flowPath = flowStatePath();
107
+ const delegationPath = delegationLogPath();
108
+ return `---
109
+ name: ${STATUS_SKILL_NAME}
110
+ description: "Read-only snapshot of the cclaw flow: track, stage, gate coverage, delegations, knowledge highlights. Never mutates state."
111
+ ---
112
+
113
+ # /cc-status — Flow Status Snapshot
114
+
115
+ ## Overview
116
+
117
+ \`/cc-status\` is the quickest way to answer "where are we in the flow?" without
118
+ advancing or mutating anything. Safe to run at any point.
119
+
120
+ ## HARD-GATE
121
+
122
+ Do **not** mutate \`${flowPath}\` or \`${delegationPath}\` from this skill. This is
123
+ a read-only command.
124
+
125
+ ## Algorithm
126
+
127
+ 1. Read \`${flowPath}\`. If missing → report **BLOCKED: flow state absent** and suggest \`cclaw init\`.
128
+ 2. Read \`${delegationPath}\`. Missing → treat all mandatory delegations as pending.
129
+ 3. Read \`${contextModePath()}\` for \`activeMode\`. Missing → render \`activeMode = default\`.
130
+ 4. Compute **time in stage**:
131
+ - Prefer \`${checkpointPath()}\` when \`stage === currentStage\` and \`timestamp\` parses as ISO 8601.
132
+ - Else scan \`${stageActivityPath()}\` from tail for the most recent entry whose \`stage === currentStage\`; use its \`ts\`.
133
+ - Render \`<X>d<Y>h\`, \`<X>h<Y>m\`, \`<X>m\`, or \`(unknown)\`.
134
+ 5. Read \`${RUNTIME_ROOT}/knowledge.md\`. If missing or empty → knowledge highlights are \`(none recorded)\`.
135
+ 6. For each gate in \`stageGateCatalog[currentStage].required\`:
136
+ - Satisfied if present in \`passed\` and absent from \`blocked\`.
137
+ 7. Build and print the status block (see command contract for layout).
138
+ 8. Suggest the next action:
139
+ - If current stage has unmet gates → \`/cc-next\` to resume.
140
+ - If current stage is complete → \`/cc-next\` to advance (or report "Flow complete" if terminal).
141
+
142
+ ## Output Guidelines
143
+
144
+ - Keep output compact (≤ 25 lines) — status, not narrative.
145
+ - Report counts, not full artifact contents.
146
+ - If any data source is missing or corrupt, say so explicitly rather than guessing.
147
+
148
+ ## Anti-patterns
149
+
150
+ - Rebuilding trace-matrix or running doctor from \`/cc-status\` — those belong to dedicated tools.
151
+ - Treating absence of delegation log as "all delegations complete".
152
+ - Mutating state to "clean up" during a status check.
153
+ `;
154
+ }
@@ -345,11 +345,41 @@ Execution rule: complete and verify each wave before starting the next wave.
345
345
  - Reconciliation summary:
346
346
 
347
347
  ## Review Readiness Dashboard
348
- - Layer 1 complete:
349
- - Layer 2 complete:
350
- - Review army schema valid:
351
- - Open critical blockers:
352
- - Ship recommendation:
348
+
349
+ | Pass | Status | Completed at (UTC) | Reviewer / source | Commit at review | Drift vs HEAD |
350
+ |---|---|---|---|---|---|
351
+ | Layer 1 — spec compliance | pass / fail / pending | <ISO 8601> | spec-reviewer | <short sha> | <files changed since> |
352
+ | Layer 2 — correctness | pass / fail / pending | <ISO 8601> | code-reviewer | <short sha> | <files changed since> |
353
+ | Layer 2 — security | pass / fail / pending | <ISO 8601> | security-reviewer | <short sha> | <files changed since> |
354
+ | Layer 2 — performance | pass / fail / pending | <ISO 8601> | code-reviewer | <short sha> | <files changed since> |
355
+ | Layer 2 — architecture | pass / fail / pending | <ISO 8601> | code-reviewer | <short sha> | <files changed since> |
356
+ | Adversarial review | pass / fail / n/a | <ISO 8601 or —> | adversarial-review skill | <short sha or —> | <drift or —> |
357
+ | Review army schema valid | pass / fail | <ISO 8601> | jsonschema | <short sha> | n/a |
358
+
359
+ ### Delegation log snapshot (current run, current stage)
360
+ - Path: \`.cclaw/state/delegation-log.json\`
361
+ - Required: <list of mandatory specialists>
362
+ - Completed: <list with timestamps>
363
+ - Waived (with reason): <list or "none">
364
+ - Pending: <list or "none">
365
+
366
+ ### Staleness signal
367
+ - Worktree commit at last review pass: \`<short sha>\`
368
+ - Worktree commit now: \`<short sha>\`
369
+ - Files changed since last review pass: \`<count>\` (run \`git diff --stat <sha>..HEAD\` to inspect)
370
+ - If drift > 0 lines, mark Layer 1 / Layer 2 results as **STALE — re-run before ship**.
371
+
372
+ ### Headline
373
+ - Open critical blockers: <count>
374
+ - Adversarial review pass: pass / fail / n/a
375
+ - Ship recommendation: APPROVED | APPROVED_WITH_CONCERNS | BLOCKED
376
+
377
+ ## Completeness Score
378
+ - AC coverage: <N>/<M> (<percent>%)
379
+ - Task coverage (tasks backed by ≥1 test slice): <N>/<M>
380
+ - Slice coverage (slices linked to ≥1 AC): <N>/<M>
381
+ - Adversarial review pass: true | false
382
+ - Overall score: <0-100>
353
383
 
354
384
  ## Severity Summary
355
385
  - Critical:
@@ -411,6 +441,12 @@ Execution rule: complete and verify each wave before starting the next wave.
411
441
  ## Completion Status
412
442
  - SHIPPED | SHIPPED_WITH_EXCEPTIONS | BLOCKED
413
443
  - Exceptions (if any):
444
+
445
+ ## Compound Step
446
+ _Optional retrospective. The goal is to make the **next** feature faster, not to evaluate this one._
447
+ _If you have nothing to add, write the explicit line: \`No compound insight this run.\`_
448
+ - Insight: <one short line about what should accelerate the next run>
449
+ - Action: append \`[compound]\` entry to \`.cclaw/knowledge.md\` capturing the insight
414
450
  `
415
451
  };
416
452
  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,19 @@ 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 function retrospectiveSkill(): string;
20
+ export declare function languageTypescriptSkill(): string;
21
+ export declare function languagePythonSkill(): string;
22
+ export declare function languageGoSkill(): string;
23
+ export declare const LANGUAGE_RULE_PACK_FOLDERS: {
24
+ readonly typescript: "language-typescript";
25
+ readonly python: "language-python";
26
+ readonly go: "language-go";
27
+ };
28
+ export declare const LANGUAGE_RULE_PACK_GENERATORS: Record<string, () => string>;
29
+ 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", "retrospective"];
16
30
  export declare const UTILITY_SKILL_MAP: Record<string, () => string>;