cclaw-cli 0.51.30 → 1.0.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.
Files changed (160) hide show
  1. package/README.md +24 -18
  2. package/dist/artifact-linter/brainstorm.d.ts +2 -0
  3. package/dist/artifact-linter/brainstorm.js +289 -0
  4. package/dist/artifact-linter/design.d.ts +2 -0
  5. package/dist/artifact-linter/design.js +354 -0
  6. package/dist/artifact-linter/plan.d.ts +2 -0
  7. package/dist/artifact-linter/plan.js +183 -0
  8. package/dist/artifact-linter/review-army.d.ts +24 -0
  9. package/dist/artifact-linter/review-army.js +365 -0
  10. package/dist/artifact-linter/review.d.ts +2 -0
  11. package/dist/artifact-linter/review.js +99 -0
  12. package/dist/artifact-linter/scope.d.ts +2 -0
  13. package/dist/artifact-linter/scope.js +125 -0
  14. package/dist/artifact-linter/shared.d.ts +247 -0
  15. package/dist/artifact-linter/shared.js +1517 -0
  16. package/dist/artifact-linter/ship.d.ts +2 -0
  17. package/dist/artifact-linter/ship.js +82 -0
  18. package/dist/artifact-linter/spec.d.ts +2 -0
  19. package/dist/artifact-linter/spec.js +130 -0
  20. package/dist/artifact-linter/tdd.d.ts +2 -0
  21. package/dist/artifact-linter/tdd.js +198 -0
  22. package/dist/artifact-linter.d.ts +4 -76
  23. package/dist/artifact-linter.js +56 -2949
  24. package/dist/cli.d.ts +1 -6
  25. package/dist/cli.js +4 -159
  26. package/dist/codex-feature-flag.d.ts +1 -1
  27. package/dist/codex-feature-flag.js +1 -1
  28. package/dist/config.d.ts +3 -2
  29. package/dist/config.js +67 -3
  30. package/dist/constants.d.ts +1 -7
  31. package/dist/constants.js +10 -15
  32. package/dist/content/cancel-command.js +2 -2
  33. package/dist/content/closeout-guidance.d.ts +1 -1
  34. package/dist/content/closeout-guidance.js +15 -13
  35. package/dist/content/core-agents.d.ts +46 -29
  36. package/dist/content/core-agents.js +216 -82
  37. package/dist/content/decision-protocol.d.ts +1 -1
  38. package/dist/content/decision-protocol.js +1 -1
  39. package/dist/content/diff-command.js +1 -1
  40. package/dist/content/examples.d.ts +0 -3
  41. package/dist/content/examples.js +197 -752
  42. package/dist/content/harness-doc.js +20 -2
  43. package/dist/content/hook-manifest.d.ts +2 -2
  44. package/dist/content/hook-manifest.js +2 -2
  45. package/dist/content/hooks.d.ts +1 -0
  46. package/dist/content/hooks.js +32 -137
  47. package/dist/content/idea.d.ts +60 -0
  48. package/dist/content/idea.js +404 -0
  49. package/dist/content/iron-laws.d.ts +0 -1
  50. package/dist/content/iron-laws.js +31 -16
  51. package/dist/content/learnings.d.ts +2 -4
  52. package/dist/content/learnings.js +11 -27
  53. package/dist/content/meta-skill.js +7 -7
  54. package/dist/content/node-hooks.d.ts +10 -0
  55. package/dist/content/node-hooks.js +163 -95
  56. package/dist/content/opencode-plugin.js +15 -29
  57. package/dist/content/reference-patterns.js +2 -2
  58. package/dist/content/runtime-shared-snippets.d.ts +8 -0
  59. package/dist/content/runtime-shared-snippets.js +80 -0
  60. package/dist/content/session-hooks.js +1 -1
  61. package/dist/content/skills.d.ts +1 -0
  62. package/dist/content/skills.js +69 -7
  63. package/dist/content/stage-schema.js +147 -61
  64. package/dist/content/stages/_lint-metadata/index.js +26 -2
  65. package/dist/content/stages/brainstorm.js +13 -7
  66. package/dist/content/stages/design.js +16 -11
  67. package/dist/content/stages/plan.js +7 -4
  68. package/dist/content/stages/review.js +12 -12
  69. package/dist/content/stages/schema-types.d.ts +2 -2
  70. package/dist/content/stages/scope.js +15 -12
  71. package/dist/content/stages/ship.js +3 -3
  72. package/dist/content/stages/spec.js +9 -3
  73. package/dist/content/stages/tdd.js +14 -4
  74. package/dist/content/start-command.js +11 -10
  75. package/dist/content/status-command.js +5 -5
  76. package/dist/content/subagent-context-skills.js +156 -1
  77. package/dist/content/subagents.d.ts +0 -5
  78. package/dist/content/subagents.js +65 -81
  79. package/dist/content/templates.d.ts +1 -1
  80. package/dist/content/templates.js +187 -154
  81. package/dist/content/tree-command.js +2 -2
  82. package/dist/content/utility-skills.d.ts +2 -2
  83. package/dist/content/utility-skills.js +28 -99
  84. package/dist/content/view-command.js +4 -2
  85. package/dist/delegation.d.ts +2 -0
  86. package/dist/delegation.js +2 -1
  87. package/dist/early-loop.d.ts +66 -0
  88. package/dist/early-loop.js +275 -0
  89. package/dist/flow-state.d.ts +5 -6
  90. package/dist/flow-state.js +4 -6
  91. package/dist/gate-evidence.d.ts +0 -23
  92. package/dist/gate-evidence.js +111 -153
  93. package/dist/harness-adapters.d.ts +2 -2
  94. package/dist/harness-adapters.js +48 -19
  95. package/dist/install.js +190 -32
  96. package/dist/internal/advance-stage/advance.d.ts +50 -0
  97. package/dist/internal/advance-stage/advance.js +479 -0
  98. package/dist/internal/advance-stage/cancel-run.d.ts +8 -0
  99. package/dist/internal/advance-stage/cancel-run.js +19 -0
  100. package/dist/internal/advance-stage/flow-state-coercion.d.ts +3 -0
  101. package/dist/internal/advance-stage/flow-state-coercion.js +81 -0
  102. package/dist/internal/advance-stage/helpers.d.ts +14 -0
  103. package/dist/internal/advance-stage/helpers.js +145 -0
  104. package/dist/internal/advance-stage/hook.d.ts +8 -0
  105. package/dist/internal/advance-stage/hook.js +40 -0
  106. package/dist/internal/advance-stage/parsers.d.ts +54 -0
  107. package/dist/internal/advance-stage/parsers.js +307 -0
  108. package/dist/internal/advance-stage/review-loop.d.ts +7 -0
  109. package/dist/internal/advance-stage/review-loop.js +161 -0
  110. package/dist/internal/advance-stage/rewind.d.ts +14 -0
  111. package/dist/internal/advance-stage/rewind.js +108 -0
  112. package/dist/internal/advance-stage/start-flow.d.ts +11 -0
  113. package/dist/internal/advance-stage/start-flow.js +136 -0
  114. package/dist/internal/advance-stage/verify.d.ts +29 -0
  115. package/dist/internal/advance-stage/verify.js +225 -0
  116. package/dist/internal/advance-stage.js +21 -1470
  117. package/dist/internal/compound-readiness.d.ts +1 -1
  118. package/dist/internal/compound-readiness.js +2 -2
  119. package/dist/internal/early-loop-status.d.ts +7 -0
  120. package/dist/internal/early-loop-status.js +90 -0
  121. package/dist/internal/runtime-integrity.d.ts +7 -0
  122. package/dist/internal/runtime-integrity.js +288 -0
  123. package/dist/internal/tdd-red-evidence.js +1 -1
  124. package/dist/knowledge-store.d.ts +5 -28
  125. package/dist/knowledge-store.js +57 -84
  126. package/dist/managed-resources.js +24 -2
  127. package/dist/policy.js +7 -9
  128. package/dist/retro-gate.js +8 -90
  129. package/dist/run-archive.d.ts +1 -1
  130. package/dist/run-archive.js +13 -16
  131. package/dist/run-persistence.js +20 -15
  132. package/dist/runtime/run-hook.entry.d.ts +3 -0
  133. package/dist/runtime/run-hook.entry.js +5 -0
  134. package/dist/runtime/run-hook.mjs +9477 -0
  135. package/dist/tdd-cycle.d.ts +3 -3
  136. package/dist/tdd-cycle.js +1 -1
  137. package/dist/types.d.ts +18 -10
  138. package/package.json +4 -2
  139. package/dist/content/hook-inline-snippets.d.ts +0 -83
  140. package/dist/content/hook-inline-snippets.js +0 -302
  141. package/dist/content/ideate-command.d.ts +0 -8
  142. package/dist/content/ideate-command.js +0 -315
  143. package/dist/content/ideate-frames.d.ts +0 -31
  144. package/dist/content/ideate-frames.js +0 -140
  145. package/dist/content/ideate-ranking.d.ts +0 -25
  146. package/dist/content/ideate-ranking.js +0 -65
  147. package/dist/content/next-command.d.ts +0 -20
  148. package/dist/content/next-command.js +0 -298
  149. package/dist/content/seed-shelf.d.ts +0 -36
  150. package/dist/content/seed-shelf.js +0 -301
  151. package/dist/content/stage-common-guidance.d.ts +0 -1
  152. package/dist/content/stage-common-guidance.js +0 -106
  153. package/dist/doctor-registry.d.ts +0 -10
  154. package/dist/doctor-registry.js +0 -186
  155. package/dist/doctor.d.ts +0 -17
  156. package/dist/doctor.js +0 -2201
  157. package/dist/internal/hook-manifest.d.ts +0 -16
  158. package/dist/internal/hook-manifest.js +0 -77
  159. package/dist/trace-matrix.d.ts +0 -27
  160. package/dist/trace-matrix.js +0 -226
@@ -1,16 +0,0 @@
1
- import type { Writable } from "node:stream";
2
- interface InternalIo {
3
- stdout: Writable;
4
- stderr: Writable;
5
- }
6
- /**
7
- * `cclaw internal hook-manifest` — diagnostic command that prints
8
- * the resolved manifest. Primary use cases:
9
- *
10
- * - debugging "which handler fires for event X on harness Y",
11
- * - migration tooling that needs a machine-readable view,
12
- * - parity verification between the source-of-truth manifest and
13
- * per-harness generated documents.
14
- */
15
- export declare function runHookManifestCommand(_projectRoot: string, argv: string[], io: InternalIo): Promise<number>;
16
- export {};
@@ -1,77 +0,0 @@
1
- import { HOOK_MANIFEST, HOOK_MANIFEST_HARNESSES, groupBindingsByEvent, requiredEventsFor } from "../content/hook-manifest.js";
2
- function parseArgs(tokens) {
3
- const args = { json: false };
4
- for (let i = 0; i < tokens.length; i += 1) {
5
- const token = tokens[i];
6
- if (token === "--json")
7
- args.json = true;
8
- else if (token === "--harness") {
9
- const value = tokens[i + 1];
10
- if (value !== "claude" && value !== "cursor" && value !== "codex") {
11
- throw new Error(`--harness must be one of claude|cursor|codex, got ${String(value)}`);
12
- }
13
- args.harness = value;
14
- i += 1;
15
- }
16
- else {
17
- throw new Error(`Unknown hook-manifest flag: ${token}`);
18
- }
19
- }
20
- return args;
21
- }
22
- /**
23
- * `cclaw internal hook-manifest` — diagnostic command that prints
24
- * the resolved manifest. Primary use cases:
25
- *
26
- * - debugging "which handler fires for event X on harness Y",
27
- * - migration tooling that needs a machine-readable view,
28
- * - parity verification between the source-of-truth manifest and
29
- * per-harness generated documents.
30
- */
31
- export async function runHookManifestCommand(_projectRoot, argv, io) {
32
- const args = parseArgs(argv);
33
- const harnesses = args.harness ? [args.harness] : [...HOOK_MANIFEST_HARNESSES];
34
- if (args.json) {
35
- const payload = {
36
- handlers: HOOK_MANIFEST.map((spec) => ({
37
- handler: spec.handler,
38
- description: spec.description,
39
- semantic: spec.semantic,
40
- bindings: spec.bindings
41
- })),
42
- byHarness: Object.fromEntries(harnesses.map((harness) => [
43
- harness,
44
- {
45
- requiredEvents: requiredEventsFor(harness),
46
- events: groupBindingsByEvent(harness)
47
- }
48
- ]))
49
- };
50
- io.stdout.write(`${JSON.stringify(payload, null, 2)}\n`);
51
- return 0;
52
- }
53
- const lines = [];
54
- lines.push("cclaw hook manifest");
55
- for (const harness of harnesses) {
56
- lines.push("");
57
- lines.push(`## ${harness}`);
58
- const groups = groupBindingsByEvent(harness);
59
- if (groups.length === 0) {
60
- lines.push(" (no bindings)");
61
- continue;
62
- }
63
- for (const group of groups) {
64
- lines.push(` ${group.event}:`);
65
- for (const entry of group.entries) {
66
- const parts = [entry.handler];
67
- if (entry.matcher)
68
- parts.push(`matcher=${entry.matcher}`);
69
- if (entry.timeout)
70
- parts.push(`timeout=${entry.timeout}s`);
71
- lines.push(` - ${parts.join(" ")}`);
72
- }
73
- }
74
- }
75
- io.stdout.write(`${lines.join("\n")}\n`);
76
- return 0;
77
- }
@@ -1,27 +0,0 @@
1
- export interface TraceEntry {
2
- criterionId: string;
3
- taskIds: string[];
4
- testSlices: string[];
5
- reviewFindings: string[];
6
- }
7
- export interface ReviewLoopTraceEntry {
8
- stage: "scope" | "design";
9
- artifactPath: string;
10
- targetScore: number;
11
- maxIterations: number;
12
- stopReason: "quality_threshold_met" | "max_iterations_reached" | "user_opt_out";
13
- finalScore: number;
14
- iterations: Array<{
15
- iteration: number;
16
- qualityScore: number;
17
- findingsCount: number;
18
- }>;
19
- }
20
- export interface TraceMatrix {
21
- entries: TraceEntry[];
22
- orphanedCriteria: string[];
23
- orphanedTasks: string[];
24
- orphanedTests: string[];
25
- reviewLoops: ReviewLoopTraceEntry[];
26
- }
27
- export declare function buildTraceMatrix(projectRoot: string): Promise<TraceMatrix>;
@@ -1,226 +0,0 @@
1
- import fs from "node:fs/promises";
2
- import path from "node:path";
3
- import { resolveArtifactPath } from "./artifact-paths.js";
4
- import { RUNTIME_ROOT } from "./constants.js";
5
- import { extractReviewLoopEnvelopeFromArtifact } from "./content/review-loop.js";
6
- import { exists } from "./fs-utils.js";
7
- function activeArtifactPath(projectRoot, name) {
8
- return path.join(projectRoot, RUNTIME_ROOT, "artifacts", name);
9
- }
10
- async function readArtifact(projectRoot, name) {
11
- const candidate = activeArtifactPath(projectRoot, name);
12
- if (await exists(candidate)) {
13
- return fs.readFile(candidate, "utf8");
14
- }
15
- return null;
16
- }
17
- function uniqPreserve(ids) {
18
- const seen = new Set();
19
- const out = [];
20
- for (const id of ids) {
21
- if (!seen.has(id)) {
22
- seen.add(id);
23
- out.push(id);
24
- }
25
- }
26
- return out;
27
- }
28
- function criterionTokens(text) {
29
- return text.match(/\bAC-\d+\b/g) ?? [];
30
- }
31
- /** AC-1, AC-12, etc. */
32
- function parseAcceptanceCriterionIds(specMd) {
33
- return uniqPreserve(criterionTokens(specMd));
34
- }
35
- /** Map task id -> AC ids mentioned on same table row or bullet line as the task. */
36
- function parsePlanTaskAcLinks(planMd) {
37
- const map = new Map();
38
- const lines = planMd.split(/\r?\n/);
39
- const taskRe = /\b(T-\d+)\b/;
40
- const acRe = /\b(AC-\d+)\b/g;
41
- for (const line of lines) {
42
- const tm = taskRe.exec(line);
43
- if (!tm) {
44
- continue;
45
- }
46
- const taskId = tm[1];
47
- const acs = [...line.matchAll(acRe)].map((m) => m[0]);
48
- if (acs.length === 0) {
49
- continue;
50
- }
51
- const prev = map.get(taskId) ?? [];
52
- map.set(taskId, uniqPreserve([...prev, ...acs]));
53
- }
54
- return map;
55
- }
56
- /** All T-N ids appearing in the plan (best-effort). */
57
- function parsePlanTaskIds(planMd) {
58
- const re = /\bT-\d+\b/g;
59
- return uniqPreserve(planMd.match(re) ?? []);
60
- }
61
- /** Map slice id -> task ids on same line. */
62
- function parseTddSliceTaskLinks(tddMd) {
63
- const map = new Map();
64
- const sliceRe = /\b(S-\d+)\b/g;
65
- const taskRe = /\b(T-\d+)\b/g;
66
- const lines = tddMd.split(/\r?\n/);
67
- for (const line of lines) {
68
- const slices = [...line.matchAll(sliceRe)].map((m) => m[1]);
69
- if (slices.length === 0) {
70
- continue;
71
- }
72
- const tasks = [...line.matchAll(taskRe)].map((m) => m[1]);
73
- for (const s of slices) {
74
- const prev = map.get(s) ?? [];
75
- map.set(s, uniqPreserve([...prev, ...tasks]));
76
- }
77
- }
78
- return map;
79
- }
80
- function parseTddSliceIds(tddMd) {
81
- return uniqPreserve(tddMd.match(/\bS-\d+\b/g) ?? []);
82
- }
83
- /** Body of Layer 1 spec compliance section in 07-review.md */
84
- function extractLayer1Section(reviewMd) {
85
- const lines = reviewMd.split(/\r?\n/);
86
- let start = -1;
87
- for (let i = 0; i < lines.length; i++) {
88
- if (/^##\s+Layer\s*1/i.test(lines[i])) {
89
- start = i + 1;
90
- break;
91
- }
92
- }
93
- if (start < 0) {
94
- return "";
95
- }
96
- const buf = [];
97
- for (let i = start; i < lines.length; i++) {
98
- const line = lines[i];
99
- if (/^##\s+/.test(line)) {
100
- break;
101
- }
102
- buf.push(line);
103
- }
104
- return buf.join("\n");
105
- }
106
- function layer1LinesForCriterion(layer1, criterionId) {
107
- const out = [];
108
- for (const line of layer1.split(/\r?\n/)) {
109
- if (criterionTokens(line).includes(criterionId)) {
110
- out.push(line.trim());
111
- }
112
- }
113
- return out;
114
- }
115
- async function readStageArtifact(projectRoot, stage) {
116
- let resolved = null;
117
- try {
118
- resolved = await resolveArtifactPath(stage, {
119
- projectRoot,
120
- intent: "read"
121
- });
122
- }
123
- catch {
124
- resolved = null;
125
- }
126
- if (!resolved || !(await exists(resolved.absPath))) {
127
- return null;
128
- }
129
- try {
130
- const markdown = await fs.readFile(resolved.absPath, "utf8");
131
- return { markdown, relPath: resolved.relPath };
132
- }
133
- catch {
134
- return null;
135
- }
136
- }
137
- async function collectReviewLoopTraceEntries(projectRoot) {
138
- const entries = [];
139
- for (const stage of ["scope", "design"]) {
140
- const artifact = await readStageArtifact(projectRoot, stage);
141
- if (!artifact)
142
- continue;
143
- const envelope = extractReviewLoopEnvelopeFromArtifact(artifact.markdown, stage, artifact.relPath);
144
- if (!envelope)
145
- continue;
146
- const finalScore = envelope.iterations.length > 0
147
- ? envelope.iterations[envelope.iterations.length - 1].qualityScore
148
- : 0;
149
- entries.push({
150
- stage,
151
- artifactPath: artifact.relPath,
152
- targetScore: envelope.targetScore,
153
- maxIterations: envelope.maxIterations,
154
- stopReason: envelope.stopReason,
155
- finalScore,
156
- iterations: envelope.iterations.map((row) => ({
157
- iteration: row.iteration,
158
- qualityScore: row.qualityScore,
159
- findingsCount: row.findingsCount
160
- }))
161
- });
162
- }
163
- return entries;
164
- }
165
- export async function buildTraceMatrix(projectRoot) {
166
- const spec = await readArtifact(projectRoot, "04-spec.md");
167
- const plan = await readArtifact(projectRoot, "05-plan.md");
168
- const tdd = await readArtifact(projectRoot, "06-tdd.md");
169
- const review = await readArtifact(projectRoot, "07-review.md");
170
- const criterionIds = spec ? parseAcceptanceCriterionIds(spec) : [];
171
- const taskToAcs = plan ? parsePlanTaskAcLinks(plan) : new Map();
172
- const allTaskIds = plan ? parsePlanTaskIds(plan) : [];
173
- const sliceToTasks = tdd ? parseTddSliceTaskLinks(tdd) : new Map();
174
- const allSliceIds = tdd ? parseTddSliceIds(tdd) : [];
175
- const layer1 = review ? extractLayer1Section(review) : "";
176
- const acToTasks = new Map();
177
- for (const [task, acs] of taskToAcs) {
178
- for (const ac of acs) {
179
- const prev = acToTasks.get(ac) ?? new Set();
180
- prev.add(task);
181
- acToTasks.set(ac, prev);
182
- }
183
- }
184
- const entries = criterionIds.map((criterionId) => {
185
- const taskIds = [...(acToTasks.get(criterionId) ?? new Set())];
186
- const taskIdSet = new Set(taskIds);
187
- const testSlices = [];
188
- for (const [slice, tasks] of sliceToTasks) {
189
- if (tasks.some((t) => taskIdSet.has(t))) {
190
- testSlices.push(slice);
191
- }
192
- }
193
- return {
194
- criterionId,
195
- taskIds: uniqPreserve(taskIds),
196
- testSlices: uniqPreserve(testSlices),
197
- reviewFindings: layer1LinesForCriterion(layer1, criterionId)
198
- };
199
- });
200
- const orphanedCriteria = criterionIds.filter((ac) => (acToTasks.get(ac)?.size ?? 0) === 0);
201
- const tasksWithSlice = new Set();
202
- for (const tasks of sliceToTasks.values()) {
203
- for (const t of tasks) {
204
- tasksWithSlice.add(t);
205
- }
206
- }
207
- const orphanedTasks = allTaskIds.filter((t) => !tasksWithSlice.has(t));
208
- const orphanedTests = allSliceIds.filter((s) => {
209
- const tasks = sliceToTasks.get(s) ?? [];
210
- if (tasks.length === 0) {
211
- return true;
212
- }
213
- return tasks.every((t) => {
214
- const acs = taskToAcs.get(t);
215
- return !acs || acs.length === 0;
216
- });
217
- });
218
- const reviewLoops = await collectReviewLoopTraceEntries(projectRoot);
219
- return {
220
- entries,
221
- orphanedCriteria,
222
- orphanedTasks,
223
- orphanedTests,
224
- reviewLoops
225
- };
226
- }