cclaw-cli 0.1.1 → 0.2.1

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.
Files changed (48) hide show
  1. package/dist/artifact-linter.d.ts +20 -0
  2. package/dist/artifact-linter.js +368 -0
  3. package/dist/cli.d.ts +1 -0
  4. package/dist/cli.js +8 -2
  5. package/dist/config.d.ts +4 -4
  6. package/dist/config.js +56 -5
  7. package/dist/constants.d.ts +4 -4
  8. package/dist/constants.js +6 -3
  9. package/dist/content/autoplan.js +51 -4
  10. package/dist/content/contexts.d.ts +9 -0
  11. package/dist/content/contexts.js +65 -0
  12. package/dist/content/hooks.d.ts +6 -2
  13. package/dist/content/hooks.js +448 -16
  14. package/dist/content/meta-skill.js +26 -0
  15. package/dist/content/next-command.d.ts +9 -0
  16. package/dist/content/next-command.js +138 -0
  17. package/dist/content/observe.d.ts +5 -1
  18. package/dist/content/observe.js +506 -24
  19. package/dist/content/skills.js +126 -0
  20. package/dist/content/stage-schema.d.ts +7 -0
  21. package/dist/content/stage-schema.js +70 -12
  22. package/dist/content/subagents.js +33 -0
  23. package/dist/content/templates.d.ts +1 -0
  24. package/dist/content/templates.js +182 -77
  25. package/dist/content/utility-skills.d.ts +5 -1
  26. package/dist/content/utility-skills.js +208 -2
  27. package/dist/delegation.d.ts +21 -0
  28. package/dist/delegation.js +94 -0
  29. package/dist/doctor.d.ts +5 -1
  30. package/dist/doctor.js +274 -23
  31. package/dist/fs-utils.d.ts +10 -0
  32. package/dist/fs-utils.js +47 -0
  33. package/dist/gate-evidence.d.ts +26 -0
  34. package/dist/gate-evidence.js +157 -0
  35. package/dist/harness-adapters.js +2 -0
  36. package/dist/hook-schema.d.ts +6 -0
  37. package/dist/hook-schema.js +45 -0
  38. package/dist/hook-schemas/claude-hooks.v1.json +12 -0
  39. package/dist/hook-schemas/codex-hooks.v1.json +12 -0
  40. package/dist/hook-schemas/cursor-hooks.v1.json +15 -0
  41. package/dist/install.js +431 -16
  42. package/dist/policy.d.ts +5 -1
  43. package/dist/policy.js +52 -1
  44. package/dist/runs.js +8 -3
  45. package/dist/trace-matrix.d.ts +13 -0
  46. package/dist/trace-matrix.js +182 -0
  47. package/dist/types.d.ts +11 -1
  48. package/package.json +1 -1
@@ -0,0 +1,138 @@
1
+ import { RUNTIME_ROOT } from "../constants.js";
2
+ import { stageSchema } from "./stage-schema.js";
3
+ import { stageSkillFolder } from "./skills.js";
4
+ const NEXT_SKILL_FOLDER = "flow-next-step";
5
+ const NEXT_SKILL_NAME = "flow-next-step";
6
+ function flowStatePath() {
7
+ return `${RUNTIME_ROOT}/state/flow-state.json`;
8
+ }
9
+ function configPathLine() {
10
+ return `${RUNTIME_ROOT}/config.yaml`;
11
+ }
12
+ function delegationLogPathLine() {
13
+ return `${RUNTIME_ROOT}/runs/<activeRunId>/delegation-log.json`;
14
+ }
15
+ /**
16
+ * Command contract for /cc-next - agent reads flow state, evaluates gates, advances or reports blockers.
17
+ * Wire into install (write to `.cclaw/commands/next.md` + harness shim `cc-next.md`) in a follow-up; not invoked by CLI.
18
+ */
19
+ export function nextCommandContract() {
20
+ const flowPath = flowStatePath();
21
+ const skillRel = `${RUNTIME_ROOT}/skills/${NEXT_SKILL_FOLDER}/SKILL.md`;
22
+ const delegationPath = delegationLogPathLine();
23
+ return `# /cc-next
24
+
25
+ ## Purpose
26
+
27
+ Single **continue** command: read flow state, verify **current stage** gate satisfaction, verify any **mandatory delegations**, then either **hand off to the next stage** (load its skill and proceed) or **list blocking gates / pauses** so the user knows what to finish first.
28
+
29
+ ## HARD-GATE
30
+
31
+ - **Do not** invent gate completion: use only \`${flowPath}\` plus observable evidence in repo artifacts.
32
+ - **Do not** skip stages: the only valid advance is from \`currentStage\` to that stage's configured successor in the flow schema (same order as \`/cc-brainstorm\` -> \`/cc-ship\`).
33
+ - **Do not** treat \`/cc-next\`, \`autoAdvance\`, or user impatience as permission to bypass \`WAIT_FOR_CONFIRM\`, \`Do NOT auto-advance\`, explicit approval pauses, or mandatory delegation requirements from the current stage skill.
34
+ - If the flow is already at the terminal stage with all ship gates satisfied, **report completion** instead of advancing.
35
+
36
+ ## Algorithm (mandatory)
37
+
38
+ 1. Read **\`${flowPath}\`** (create parent dirs only if you are also initializing a broken install - otherwise treat missing file as **BLOCKED**: state missing).
39
+ 2. Parse JSON. Capture \`currentStage\`, \`activeRunId\` (must be present), and the current run-scoped context.
40
+ 3. Load **\`${skillRel}\`** - canonical semantics for gate evaluation and continuation live there.
41
+ 4. Let \`G\` = \`requiredGates\` for **\`currentStage\`** from the stage schema (authoritative list of gate ids).
42
+ 5. Let \`catalog\` = \`stageGateCatalog[currentStage]\` from flow state (if missing, treat all gates as unmet).
43
+ 6. **Satisfied** for gate id \`g\`: \`g\` in \`catalog.passed\` and \`g\` not in \`catalog.blocked\`.
44
+ 7. **Unmet** = gates in \`G\` that are not satisfied **or** appear in \`catalog.blocked\`.
45
+ 8. Let \`M\` = \`mandatoryDelegations\` for **\`currentStage\`** from the stage schema.
46
+ 9. If \`M\` is non-empty, inspect **\`${delegationPath}\`**. A mandatory delegation counts only if that agent is recorded as **completed** or explicitly **waived** by the user. Missing or in-progress entries are blocking.
47
+ 10. Respect explicit pause rules from the current stage skill (for example \`WAIT_FOR_CONFIRM\`, \`Do NOT auto-advance\`, or "wait for explicit approval"). \`/cc-next\` is a convenience command, not authorization to bypass confirmation gates.
48
+ 11. If **any** unmet gates, blocking pause rules, or missing mandatory delegations remain: print a short **Blocking gates** list (id + human description from schema \`requiredGates\`, plus any missing delegation or approval requirement). Do **not** invoke the next stage skill yet.
49
+ 12. If **all** required gates and mandatory delegations are satisfied:
50
+ - If current stage's \`next\` is **\`done\`**: report **flow complete**; stop.
51
+ - Otherwise let \`nextStage\` be the schema successor of \`currentStage\`. Load **\`${RUNTIME_ROOT}/skills/<skillFolder>/SKILL.md\`** and **\`${RUNTIME_ROOT}/commands/<nextStage>.md\`** using the real \`skillFolder\` and stage id from the schema for \`nextStage\`, then run that stage's protocol in-agent (equivalent to invoking \`/cc-\` + \`nextStage\`) without asking the user to re-type the slash-command. While doing so, obey the current and next stage skills' explicit pause rules; if either skill says to pause, stop and report readiness instead of auto-continuing through that gate.
52
+
53
+ ## Primary skill
54
+
55
+ **${skillRel}** - full protocol, gate/flow tie-in, and interaction with \`autoAdvance\` in **\`${configPathLine()}\`**.
56
+ `;
57
+ }
58
+ /**
59
+ * Skill body for /cc-next - flow logic and continue semantics.
60
+ */
61
+ export function nextCommandSkillMarkdown() {
62
+ const flowPath = flowStatePath();
63
+ const cfgPath = configPathLine();
64
+ const delegationPath = delegationLogPathLine();
65
+ const stageRows = ["brainstorm", "scope", "design", "spec", "plan", "test", "build", "review", "ship"]
66
+ .map((stage) => {
67
+ const schema = stageSchema(stage);
68
+ const next = schema.next === "done" ? "(terminal)" : `/cc-${schema.next}`;
69
+ const skillMd = `${RUNTIME_ROOT}/skills/${stageSkillFolder(stage)}/SKILL.md`;
70
+ return `| \`${stage}\` | ${next} | \`${skillMd}\` |`;
71
+ })
72
+ .join("\n");
73
+ return `---
74
+ name: ${NEXT_SKILL_NAME}
75
+ description: "Evaluate current stage gates from flow state; advance to the next /cc-* stage or list blockers."
76
+ ---
77
+
78
+ # Flow: /cc-next (gate-aware continuation)
79
+
80
+ ## When to use
81
+
82
+ - You want **one command** instead of manually typing the next \`/cc-*\` after a stage.
83
+ - You are unsure whether **current stage gates** are satisfied.
84
+ - The user said **continue**, **next**, or **pick up where we left off**.
85
+
86
+ ## HARD-GATE
87
+
88
+ Do **not** mark gates satisfied from memory alone. Cite **artifact evidence** (paths, excerpts) consistent with \`requiredGates\` for \`currentStage\`. If evidence is missing, list the gate as **unmet**. Also treat missing mandatory delegations or unresolved confirmation pauses as blockers even if someone claims the stage is "basically done."
89
+
90
+ ## Read flow state
91
+
92
+ 1. Open **\`${flowPath}\`**.
93
+ 2. Record \`currentStage\`, \`activeRunId\`, and \`stageGateCatalog[currentStage]\` (\`required\`, \`passed\`, \`blocked\` arrays).
94
+ 3. If the file is missing or invalid JSON -> **BLOCKED** (report; do not advance).
95
+ 4. Resolve the current delegation ledger at **\`${delegationPath}\`** using the recorded \`activeRunId\`.
96
+
97
+ ## Evaluate gates for \`currentStage\`
98
+
99
+ For each gate id in the stage schema's \`requiredGates\` for \`currentStage\`:
100
+
101
+ - **Met** if the id is in \`catalog.passed\` and **not** in \`catalog.blocked\`.
102
+ - **Blocked** if the id is in \`catalog.blocked\` (always list these first).
103
+ - **Unmet** if not met (explain what evidence or artifact action is still needed, using the gate's description from the schema).
104
+
105
+ Also evaluate stage-level transition blockers:
106
+
107
+ - Read \`mandatoryDelegations\` from the current stage schema.
108
+ - If any mandatory agent is required, inspect **\`${delegationPath}\`**. Treat that agent as satisfied only if the ledger records it as **completed** or explicitly **waived** by the user.
109
+ - Treat explicit pause rules from the current stage skill (for example \`WAIT_FOR_CONFIRM\`, \`Do NOT auto-advance\`, or "wait for explicit approval") as authoritative. **/cc-next** does not override them.
110
+
111
+ If **any** gate is unmet or blocked, or any mandatory delegation / confirmation pause remains unresolved -> output **Blocking gates** (bulleted: \`id\` or agent name - reason). **Stop** without loading the next stage skill.
112
+
113
+ ## Advance (all gates satisfied)
114
+
115
+ 1. Look up \`currentStage\` in the transition table below. If next is **terminal**, print **Flow complete** and stop.
116
+ 2. Let \`nextStage\` be the \`To\` stage. Read **\`${RUNTIME_ROOT}/commands/<nextStage>.md\`** and **\`${RUNTIME_ROOT}/skills/<folder>/SKILL.md\`** for that row.
117
+ 3. **Continue semantics:** execute that stage's protocol **in the same session** as a natural handoff (you are now "in" \`nextStage\` until it completes or blocks).
118
+ 4. Honor **\`${cfgPath}\`**: \`autoAdvance\` only applies where the stage skill allows it. Explicit pause / confirmation rules in either the current or next stage always win.
119
+ 5. If the next stage reaches a confirmation gate or a "do not auto-advance" boundary, stop there and report readiness instead of claiming automatic advancement through that gate.
120
+
121
+ ## Stage order (reference)
122
+
123
+ | Stage | Next command | Skill path |
124
+ |---|---|---|
125
+ ${stageRows}
126
+
127
+ ## Relation to per-stage skills
128
+
129
+ Wave auto-execute (\`waveExecutionAllowed\`) applies only to **test** and **build** skills after plan approval - see those SKILL.md files. **/cc-next** does not replace RED/GREEN/REFACTOR discipline; it only removes friction **between** stages.
130
+
131
+ ## Anti-patterns
132
+
133
+ - Advancing when \`blocked\` is non-empty for the current stage.
134
+ - Treating \`passed\` as trusted when artifact evidence contradicts it.
135
+ - Using **/cc-next** to bypass \`WAIT_FOR_CONFIRM\`, explicit approval pauses, or missing mandatory delegations.
136
+ - Skipping **review** or **ship** because "the code looks fine".
137
+ `;
138
+ }
@@ -8,7 +8,11 @@
8
8
  * summarize-observations.sh: run at session stop, reads recent observations,
9
9
  * identifies patterns, and appends new learnings to .cclaw/learnings.jsonl.
10
10
  */
11
- export declare function promptGuardScript(): string;
11
+ export interface PromptGuardOptions {
12
+ strictMode?: boolean;
13
+ }
14
+ export declare function promptGuardScript(options?: PromptGuardOptions): string;
15
+ export declare function workflowGuardScript(): string;
12
16
  export declare function observeScript(): string;
13
17
  export declare function contextMonitorScript(): string;
14
18
  export declare function summarizeObservationsRuntimeModule(): string;