cclaw-cli 7.7.0 → 8.1.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 (282) hide show
  1. package/README.md +210 -134
  2. package/dist/artifact-frontmatter.d.ts +51 -0
  3. package/dist/artifact-frontmatter.js +131 -0
  4. package/dist/artifact-paths.d.ts +7 -27
  5. package/dist/artifact-paths.js +20 -249
  6. package/dist/cancel.d.ts +16 -0
  7. package/dist/cancel.js +66 -0
  8. package/dist/cli.d.ts +2 -27
  9. package/dist/cli.js +90 -508
  10. package/dist/compound.d.ts +26 -0
  11. package/dist/compound.js +96 -0
  12. package/dist/config.d.ts +14 -51
  13. package/dist/config.js +23 -359
  14. package/dist/constants.d.ts +11 -18
  15. package/dist/constants.js +19 -106
  16. package/dist/content/antipatterns.d.ts +1 -0
  17. package/dist/content/antipatterns.js +109 -0
  18. package/dist/content/artifact-templates.d.ts +10 -0
  19. package/dist/content/artifact-templates.js +550 -0
  20. package/dist/content/cancel-command.d.ts +2 -2
  21. package/dist/content/cancel-command.js +25 -17
  22. package/dist/content/core-agents.d.ts +9 -233
  23. package/dist/content/core-agents.js +39 -766
  24. package/dist/content/decision-protocol.d.ts +1 -12
  25. package/dist/content/decision-protocol.js +27 -20
  26. package/dist/content/examples.d.ts +8 -42
  27. package/dist/content/examples.js +293 -425
  28. package/dist/content/idea-command.d.ts +2 -0
  29. package/dist/content/idea-command.js +38 -0
  30. package/dist/content/iron-laws.d.ts +4 -138
  31. package/dist/content/iron-laws.js +18 -197
  32. package/dist/content/meta-skill.d.ts +1 -3
  33. package/dist/content/meta-skill.js +57 -132
  34. package/dist/content/node-hooks.d.ts +12 -8
  35. package/dist/content/node-hooks.js +188 -838
  36. package/dist/content/recovery.d.ts +8 -0
  37. package/dist/content/recovery.js +179 -0
  38. package/dist/content/reference-patterns.d.ts +4 -13
  39. package/dist/content/reference-patterns.js +260 -389
  40. package/dist/content/research-playbooks.d.ts +8 -8
  41. package/dist/content/research-playbooks.js +108 -121
  42. package/dist/content/review-loop.d.ts +6 -192
  43. package/dist/content/review-loop.js +29 -731
  44. package/dist/content/skills.d.ts +8 -38
  45. package/dist/content/skills.js +681 -732
  46. package/dist/content/specialist-prompts/architect.d.ts +1 -0
  47. package/dist/content/specialist-prompts/architect.js +225 -0
  48. package/dist/content/specialist-prompts/brainstormer.d.ts +1 -0
  49. package/dist/content/specialist-prompts/brainstormer.js +168 -0
  50. package/dist/content/specialist-prompts/index.d.ts +2 -0
  51. package/dist/content/specialist-prompts/index.js +14 -0
  52. package/dist/content/specialist-prompts/planner.d.ts +1 -0
  53. package/dist/content/specialist-prompts/planner.js +182 -0
  54. package/dist/content/specialist-prompts/reviewer.d.ts +1 -0
  55. package/dist/content/specialist-prompts/reviewer.js +193 -0
  56. package/dist/content/specialist-prompts/security-reviewer.d.ts +1 -0
  57. package/dist/content/specialist-prompts/security-reviewer.js +133 -0
  58. package/dist/content/specialist-prompts/slice-builder.d.ts +1 -0
  59. package/dist/content/specialist-prompts/slice-builder.js +232 -0
  60. package/dist/content/stage-playbooks.d.ts +8 -0
  61. package/dist/content/stage-playbooks.js +404 -0
  62. package/dist/content/start-command.d.ts +2 -12
  63. package/dist/content/start-command.js +221 -207
  64. package/dist/flow-state.d.ts +21 -178
  65. package/dist/flow-state.js +67 -170
  66. package/dist/fs-utils.d.ts +6 -26
  67. package/dist/fs-utils.js +29 -162
  68. package/dist/gitignore.d.ts +2 -1
  69. package/dist/gitignore.js +51 -34
  70. package/dist/harness-detect.d.ts +10 -0
  71. package/dist/harness-detect.js +29 -0
  72. package/dist/install.d.ts +27 -15
  73. package/dist/install.js +230 -1342
  74. package/dist/knowledge-store.d.ts +19 -163
  75. package/dist/knowledge-store.js +56 -590
  76. package/dist/logger.d.ts +8 -3
  77. package/dist/logger.js +13 -4
  78. package/dist/orchestrator-routing.d.ts +29 -0
  79. package/dist/orchestrator-routing.js +156 -0
  80. package/dist/run-persistence.d.ts +7 -118
  81. package/dist/run-persistence.js +29 -845
  82. package/dist/runtime/run-hook.entry.d.ts +1 -3
  83. package/dist/runtime/run-hook.entry.js +19 -4
  84. package/dist/runtime/run-hook.mjs +13 -1024
  85. package/dist/types.d.ts +25 -261
  86. package/dist/types.js +8 -36
  87. package/package.json +6 -3
  88. package/dist/artifact-linter/brainstorm.d.ts +0 -2
  89. package/dist/artifact-linter/brainstorm.js +0 -353
  90. package/dist/artifact-linter/design.d.ts +0 -18
  91. package/dist/artifact-linter/design.js +0 -444
  92. package/dist/artifact-linter/findings-dedup.d.ts +0 -56
  93. package/dist/artifact-linter/findings-dedup.js +0 -232
  94. package/dist/artifact-linter/plan.d.ts +0 -2
  95. package/dist/artifact-linter/plan.js +0 -826
  96. package/dist/artifact-linter/review-army.d.ts +0 -49
  97. package/dist/artifact-linter/review-army.js +0 -520
  98. package/dist/artifact-linter/review.d.ts +0 -2
  99. package/dist/artifact-linter/review.js +0 -113
  100. package/dist/artifact-linter/scope.d.ts +0 -2
  101. package/dist/artifact-linter/scope.js +0 -158
  102. package/dist/artifact-linter/shared.d.ts +0 -637
  103. package/dist/artifact-linter/shared.js +0 -2163
  104. package/dist/artifact-linter/ship.d.ts +0 -2
  105. package/dist/artifact-linter/ship.js +0 -250
  106. package/dist/artifact-linter/spec.d.ts +0 -2
  107. package/dist/artifact-linter/spec.js +0 -176
  108. package/dist/artifact-linter/tdd.d.ts +0 -118
  109. package/dist/artifact-linter/tdd.js +0 -1404
  110. package/dist/artifact-linter.d.ts +0 -15
  111. package/dist/artifact-linter.js +0 -517
  112. package/dist/codex-feature-flag.d.ts +0 -58
  113. package/dist/codex-feature-flag.js +0 -193
  114. package/dist/content/closeout-guidance.d.ts +0 -14
  115. package/dist/content/closeout-guidance.js +0 -44
  116. package/dist/content/diff-command.d.ts +0 -1
  117. package/dist/content/diff-command.js +0 -43
  118. package/dist/content/harness-doc.d.ts +0 -1
  119. package/dist/content/harness-doc.js +0 -65
  120. package/dist/content/hook-events.d.ts +0 -9
  121. package/dist/content/hook-events.js +0 -23
  122. package/dist/content/hook-manifest.d.ts +0 -81
  123. package/dist/content/hook-manifest.js +0 -156
  124. package/dist/content/hooks.d.ts +0 -11
  125. package/dist/content/hooks.js +0 -1972
  126. package/dist/content/idea.d.ts +0 -60
  127. package/dist/content/idea.js +0 -416
  128. package/dist/content/language-policy.d.ts +0 -2
  129. package/dist/content/language-policy.js +0 -13
  130. package/dist/content/learnings.d.ts +0 -6
  131. package/dist/content/learnings.js +0 -141
  132. package/dist/content/observe.d.ts +0 -19
  133. package/dist/content/observe.js +0 -86
  134. package/dist/content/opencode-plugin.d.ts +0 -1
  135. package/dist/content/opencode-plugin.js +0 -635
  136. package/dist/content/review-prompts.d.ts +0 -1
  137. package/dist/content/review-prompts.js +0 -104
  138. package/dist/content/runtime-shared-snippets.d.ts +0 -8
  139. package/dist/content/runtime-shared-snippets.js +0 -80
  140. package/dist/content/session-hooks.d.ts +0 -7
  141. package/dist/content/session-hooks.js +0 -107
  142. package/dist/content/skills-elicitation.d.ts +0 -1
  143. package/dist/content/skills-elicitation.js +0 -167
  144. package/dist/content/stage-command.d.ts +0 -2
  145. package/dist/content/stage-command.js +0 -17
  146. package/dist/content/stage-schema.d.ts +0 -117
  147. package/dist/content/stage-schema.js +0 -955
  148. package/dist/content/stages/_lint-metadata/index.d.ts +0 -2
  149. package/dist/content/stages/_lint-metadata/index.js +0 -97
  150. package/dist/content/stages/brainstorm.d.ts +0 -2
  151. package/dist/content/stages/brainstorm.js +0 -184
  152. package/dist/content/stages/design.d.ts +0 -2
  153. package/dist/content/stages/design.js +0 -288
  154. package/dist/content/stages/index.d.ts +0 -8
  155. package/dist/content/stages/index.js +0 -11
  156. package/dist/content/stages/plan.d.ts +0 -2
  157. package/dist/content/stages/plan.js +0 -191
  158. package/dist/content/stages/review.d.ts +0 -2
  159. package/dist/content/stages/review.js +0 -240
  160. package/dist/content/stages/schema-types.d.ts +0 -203
  161. package/dist/content/stages/schema-types.js +0 -1
  162. package/dist/content/stages/scope.d.ts +0 -2
  163. package/dist/content/stages/scope.js +0 -254
  164. package/dist/content/stages/ship.d.ts +0 -2
  165. package/dist/content/stages/ship.js +0 -159
  166. package/dist/content/stages/spec.d.ts +0 -2
  167. package/dist/content/stages/spec.js +0 -170
  168. package/dist/content/stages/tdd.d.ts +0 -4
  169. package/dist/content/stages/tdd.js +0 -273
  170. package/dist/content/state-contracts.d.ts +0 -1
  171. package/dist/content/state-contracts.js +0 -63
  172. package/dist/content/status-command.d.ts +0 -4
  173. package/dist/content/status-command.js +0 -109
  174. package/dist/content/subagent-context-skills.d.ts +0 -4
  175. package/dist/content/subagent-context-skills.js +0 -279
  176. package/dist/content/subagents.d.ts +0 -3
  177. package/dist/content/subagents.js +0 -997
  178. package/dist/content/templates.d.ts +0 -26
  179. package/dist/content/templates.js +0 -1692
  180. package/dist/content/track-render-context.d.ts +0 -18
  181. package/dist/content/track-render-context.js +0 -53
  182. package/dist/content/tree-command.d.ts +0 -1
  183. package/dist/content/tree-command.js +0 -64
  184. package/dist/content/utility-skills.d.ts +0 -30
  185. package/dist/content/utility-skills.js +0 -160
  186. package/dist/content/view-command.d.ts +0 -2
  187. package/dist/content/view-command.js +0 -92
  188. package/dist/delegation.d.ts +0 -649
  189. package/dist/delegation.js +0 -1539
  190. package/dist/early-loop.d.ts +0 -70
  191. package/dist/early-loop.js +0 -302
  192. package/dist/execution-topology.d.ts +0 -36
  193. package/dist/execution-topology.js +0 -73
  194. package/dist/gate-evidence.d.ts +0 -85
  195. package/dist/gate-evidence.js +0 -631
  196. package/dist/harness-adapters.d.ts +0 -151
  197. package/dist/harness-adapters.js +0 -756
  198. package/dist/harness-selection.d.ts +0 -31
  199. package/dist/harness-selection.js +0 -214
  200. package/dist/hook-schema.d.ts +0 -6
  201. package/dist/hook-schema.js +0 -114
  202. package/dist/hook-schemas/claude-hooks.v1.json +0 -10
  203. package/dist/hook-schemas/codex-hooks.v1.json +0 -10
  204. package/dist/hook-schemas/cursor-hooks.v1.json +0 -13
  205. package/dist/init-detect.d.ts +0 -2
  206. package/dist/init-detect.js +0 -50
  207. package/dist/internal/advance-stage/advance.d.ts +0 -89
  208. package/dist/internal/advance-stage/advance.js +0 -655
  209. package/dist/internal/advance-stage/cancel-run.d.ts +0 -8
  210. package/dist/internal/advance-stage/cancel-run.js +0 -19
  211. package/dist/internal/advance-stage/flow-state-coercion.d.ts +0 -3
  212. package/dist/internal/advance-stage/flow-state-coercion.js +0 -81
  213. package/dist/internal/advance-stage/helpers.d.ts +0 -14
  214. package/dist/internal/advance-stage/helpers.js +0 -145
  215. package/dist/internal/advance-stage/hook.d.ts +0 -8
  216. package/dist/internal/advance-stage/hook.js +0 -40
  217. package/dist/internal/advance-stage/parsers.d.ts +0 -72
  218. package/dist/internal/advance-stage/parsers.js +0 -357
  219. package/dist/internal/advance-stage/proactive-delegation-trace.d.ts +0 -24
  220. package/dist/internal/advance-stage/proactive-delegation-trace.js +0 -56
  221. package/dist/internal/advance-stage/review-loop.d.ts +0 -16
  222. package/dist/internal/advance-stage/review-loop.js +0 -199
  223. package/dist/internal/advance-stage/rewind.d.ts +0 -14
  224. package/dist/internal/advance-stage/rewind.js +0 -108
  225. package/dist/internal/advance-stage/start-flow.d.ts +0 -13
  226. package/dist/internal/advance-stage/start-flow.js +0 -241
  227. package/dist/internal/advance-stage/verify.d.ts +0 -21
  228. package/dist/internal/advance-stage/verify.js +0 -185
  229. package/dist/internal/advance-stage.d.ts +0 -7
  230. package/dist/internal/advance-stage.js +0 -138
  231. package/dist/internal/cohesion-contract-stub.d.ts +0 -24
  232. package/dist/internal/cohesion-contract-stub.js +0 -148
  233. package/dist/internal/compound-readiness.d.ts +0 -23
  234. package/dist/internal/compound-readiness.js +0 -102
  235. package/dist/internal/detect-public-api-changes.d.ts +0 -5
  236. package/dist/internal/detect-public-api-changes.js +0 -45
  237. package/dist/internal/detect-supply-chain-changes.d.ts +0 -6
  238. package/dist/internal/detect-supply-chain-changes.js +0 -138
  239. package/dist/internal/early-loop-status.d.ts +0 -7
  240. package/dist/internal/early-loop-status.js +0 -93
  241. package/dist/internal/envelope-validate.d.ts +0 -7
  242. package/dist/internal/envelope-validate.js +0 -66
  243. package/dist/internal/flow-state-repair.d.ts +0 -20
  244. package/dist/internal/flow-state-repair.js +0 -104
  245. package/dist/internal/plan-split-waves.d.ts +0 -190
  246. package/dist/internal/plan-split-waves.js +0 -764
  247. package/dist/internal/runtime-integrity.d.ts +0 -7
  248. package/dist/internal/runtime-integrity.js +0 -268
  249. package/dist/internal/slice-commit.d.ts +0 -7
  250. package/dist/internal/slice-commit.js +0 -619
  251. package/dist/internal/tdd-loop-status.d.ts +0 -14
  252. package/dist/internal/tdd-loop-status.js +0 -68
  253. package/dist/internal/tdd-red-evidence.d.ts +0 -7
  254. package/dist/internal/tdd-red-evidence.js +0 -153
  255. package/dist/internal/waiver-grant.d.ts +0 -62
  256. package/dist/internal/waiver-grant.js +0 -294
  257. package/dist/internal/wave-status.d.ts +0 -63
  258. package/dist/internal/wave-status.js +0 -450
  259. package/dist/managed-resources.d.ts +0 -53
  260. package/dist/managed-resources.js +0 -313
  261. package/dist/policy.d.ts +0 -10
  262. package/dist/policy.js +0 -167
  263. package/dist/retro-gate.d.ts +0 -9
  264. package/dist/retro-gate.js +0 -47
  265. package/dist/run-archive.d.ts +0 -61
  266. package/dist/run-archive.js +0 -391
  267. package/dist/runs.d.ts +0 -2
  268. package/dist/runs.js +0 -2
  269. package/dist/stack-detection.d.ts +0 -116
  270. package/dist/stack-detection.js +0 -489
  271. package/dist/streaming/event-stream.d.ts +0 -31
  272. package/dist/streaming/event-stream.js +0 -114
  273. package/dist/tdd-cycle.d.ts +0 -107
  274. package/dist/tdd-cycle.js +0 -289
  275. package/dist/tdd-verification-evidence.d.ts +0 -17
  276. package/dist/tdd-verification-evidence.js +0 -122
  277. package/dist/track-heuristics.d.ts +0 -27
  278. package/dist/track-heuristics.js +0 -154
  279. package/dist/util/slice-id.d.ts +0 -58
  280. package/dist/util/slice-id.js +0 -89
  281. package/dist/worktree-manager.d.ts +0 -20
  282. package/dist/worktree-manager.js +0 -108
@@ -1,19 +0,0 @@
1
- import { archiveRun } from "../../runs.js";
2
- export async function runCancelRun(projectRoot, args, io) {
3
- const archived = await archiveRun(projectRoot, args.name, {
4
- disposition: args.disposition,
5
- dispositionReason: args.reason
6
- });
7
- if (!args.quiet) {
8
- io.stdout.write(`${JSON.stringify({
9
- ok: true,
10
- command: "cancel-run",
11
- disposition: archived.disposition,
12
- reason: archived.dispositionReason ?? args.reason,
13
- archiveId: archived.archiveId,
14
- archivePath: archived.archivePath,
15
- resetRunId: archived.resetState.activeRunId
16
- }, null, 2)}\n`);
17
- }
18
- return 0;
19
- }
@@ -1,3 +0,0 @@
1
- import { type FlowState } from "../../flow-state.js";
2
- export declare function parseCandidateGateCatalog(value: unknown, fallback: FlowState["stageGateCatalog"]): FlowState["stageGateCatalog"];
3
- export declare function coerceCandidateFlowState(raw: unknown, fallback: FlowState): FlowState;
@@ -1,81 +0,0 @@
1
- import { FLOW_STAGES } from "../../types.js";
2
- import { isFlowTrack } from "../../flow-state.js";
3
- import { emptyGateState, isFlowStageValue, parseGuardEvidence, parseStringList, unique } from "./helpers.js";
4
- export function parseCandidateGateCatalog(value, fallback) {
5
- const next = {};
6
- for (const stage of FLOW_STAGES) {
7
- // Guard against stale on-disk flow-state files that persisted a partial
8
- // stageGateCatalog (missing a stage key). Previously `fallback[stage]`
9
- // could be undefined and the spread below would throw at runtime.
10
- const base = fallback[stage] ?? emptyGateState();
11
- next[stage] = {
12
- required: [...base.required],
13
- recommended: [...base.recommended],
14
- conditional: [...base.conditional],
15
- triggered: [...base.triggered],
16
- passed: [...base.passed],
17
- blocked: [...base.blocked]
18
- };
19
- }
20
- if (!value || typeof value !== "object" || Array.isArray(value)) {
21
- return next;
22
- }
23
- const rawCatalog = value;
24
- for (const stage of FLOW_STAGES) {
25
- const rawStage = rawCatalog[stage];
26
- if (!rawStage || typeof rawStage !== "object" || Array.isArray(rawStage)) {
27
- continue;
28
- }
29
- const typed = rawStage;
30
- const base = fallback[stage] ?? emptyGateState();
31
- const allowed = new Set([...base.required, ...base.recommended, ...base.conditional]);
32
- const conditional = new Set(base.conditional);
33
- const passed = unique(parseStringList(typed.passed)).filter((gateId) => allowed.has(gateId));
34
- const blocked = unique(parseStringList(typed.blocked)).filter((gateId) => allowed.has(gateId));
35
- const triggered = unique([
36
- ...parseStringList(typed.triggered).filter((gateId) => conditional.has(gateId)),
37
- ...passed.filter((gateId) => conditional.has(gateId)),
38
- ...blocked.filter((gateId) => conditional.has(gateId))
39
- ]);
40
- next[stage] = {
41
- required: [...base.required],
42
- recommended: [...base.recommended],
43
- conditional: [...base.conditional],
44
- triggered,
45
- passed,
46
- blocked
47
- };
48
- }
49
- return next;
50
- }
51
- export function coerceCandidateFlowState(raw, fallback) {
52
- if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
53
- return fallback;
54
- }
55
- const typed = raw;
56
- const track = isFlowTrack(typed.track) ? typed.track : fallback.track;
57
- const currentStage = isFlowStageValue(typed.currentStage)
58
- ? typed.currentStage
59
- : fallback.currentStage;
60
- const completedStages = unique(parseStringList(typed.completedStages).filter((stage) => isFlowStageValue(stage)));
61
- const skippedStagesRaw = parseStringList(typed.skippedStages).filter((stage) => isFlowStageValue(stage));
62
- const skippedStages = skippedStagesRaw.length > 0 ? skippedStagesRaw : fallback.skippedStages;
63
- // When the candidate payload omits `guardEvidence` entirely we must keep
64
- // the on-disk fallback — otherwise a partial update (e.g. a tooling call
65
- // that only passes stage + passedGateIds) would silently wipe every
66
- // previously recorded evidence string and fail the next
67
- // `verifyCurrentStageGateEvidence` check.
68
- const candidateEvidence = parseGuardEvidence(typed.guardEvidence);
69
- const guardEvidence = typed.guardEvidence === undefined
70
- ? { ...fallback.guardEvidence }
71
- : candidateEvidence;
72
- return {
73
- ...fallback,
74
- currentStage,
75
- completedStages,
76
- track,
77
- skippedStages,
78
- guardEvidence,
79
- stageGateCatalog: parseCandidateGateCatalog(typed.stageGateCatalog, fallback.stageGateCatalog)
80
- };
81
- }
@@ -1,14 +0,0 @@
1
- import { type FlowStage } from "../../types.js";
2
- import { type StageGateState } from "../../flow-state.js";
3
- export declare function unique<T extends string>(values: T[]): T[];
4
- export declare function asRecord(value: unknown): Record<string, unknown> | null;
5
- export declare function parseStringList(raw: unknown): string[];
6
- export declare function isFlowStageValue(value: unknown): value is FlowStage;
7
- export declare function parseGuardEvidence(value: unknown): Record<string, string>;
8
- export declare function emptyGateState(): StageGateState;
9
- export declare function stringifyGateEvidenceValue(value: unknown): string;
10
- export declare function parseEvidenceByGate(raw: string | undefined): Record<string, string>;
11
- export declare function parseCsv(raw: string | undefined): string[];
12
- export declare function pathExists(projectRoot: string, relPath: string): Promise<boolean>;
13
- export declare function listExistingFiles(projectRoot: string, relPaths: string[]): Promise<string[]>;
14
- export declare function listFilesUnder(projectRoot: string, relDir: string, limit?: number): Promise<string[]>;
@@ -1,145 +0,0 @@
1
- import fs from "node:fs/promises";
2
- import path from "node:path";
3
- import { FLOW_STAGES } from "../../types.js";
4
- export function unique(values) {
5
- return [...new Set(values)];
6
- }
7
- export function asRecord(value) {
8
- if (!value || typeof value !== "object" || Array.isArray(value)) {
9
- return null;
10
- }
11
- return value;
12
- }
13
- export function parseStringList(raw) {
14
- if (!Array.isArray(raw))
15
- return [];
16
- return raw
17
- .filter((item) => typeof item === "string")
18
- .map((item) => item.trim())
19
- .filter((item) => item.length > 0);
20
- }
21
- export function isFlowStageValue(value) {
22
- return typeof value === "string" && FLOW_STAGES.includes(value);
23
- }
24
- export function parseGuardEvidence(value) {
25
- if (!value || typeof value !== "object" || Array.isArray(value)) {
26
- return {};
27
- }
28
- const next = {};
29
- for (const [key, raw] of Object.entries(value)) {
30
- if (typeof raw !== "string")
31
- continue;
32
- const trimmed = raw.trim();
33
- if (trimmed.length === 0)
34
- continue;
35
- next[key] = trimmed;
36
- }
37
- return next;
38
- }
39
- export function emptyGateState() {
40
- return {
41
- required: [],
42
- recommended: [],
43
- conditional: [],
44
- triggered: [],
45
- passed: [],
46
- blocked: []
47
- };
48
- }
49
- export function stringifyGateEvidenceValue(value) {
50
- if (typeof value === "string")
51
- return value;
52
- if (typeof value === "boolean")
53
- return value ? "passed" : "failed";
54
- if (typeof value === "number" || typeof value === "bigint")
55
- return String(value);
56
- if (value === null || value === undefined)
57
- return "";
58
- if (typeof value === "object")
59
- return JSON.stringify(value);
60
- return String(value);
61
- }
62
- export function parseEvidenceByGate(raw) {
63
- if (!raw || raw.trim().length === 0) {
64
- return {};
65
- }
66
- let parsed;
67
- try {
68
- parsed = JSON.parse(raw);
69
- }
70
- catch (err) {
71
- throw new Error(`--evidence-json must be valid JSON object: ${err instanceof Error ? err.message : String(err)}`);
72
- }
73
- if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
74
- throw new Error("--evidence-json must deserialize to an object.");
75
- }
76
- const next = {};
77
- for (const [key, value] of Object.entries(parsed)) {
78
- const normalized = stringifyGateEvidenceValue(value).trim();
79
- if (normalized.length === 0)
80
- continue;
81
- next[key] = normalized;
82
- }
83
- return next;
84
- }
85
- export function parseCsv(raw) {
86
- if (!raw)
87
- return [];
88
- return raw
89
- .split(",")
90
- .map((item) => item.trim())
91
- .filter((item) => item.length > 0);
92
- }
93
- export async function pathExists(projectRoot, relPath) {
94
- try {
95
- await fs.stat(path.join(projectRoot, relPath));
96
- return true;
97
- }
98
- catch {
99
- return false;
100
- }
101
- }
102
- export async function listExistingFiles(projectRoot, relPaths) {
103
- const matches = [];
104
- for (const relPath of relPaths) {
105
- try {
106
- const stat = await fs.stat(path.join(projectRoot, relPath));
107
- if (stat.isFile())
108
- matches.push(relPath);
109
- }
110
- catch {
111
- // continue
112
- }
113
- }
114
- return matches;
115
- }
116
- export async function listFilesUnder(projectRoot, relDir, limit = 20) {
117
- const root = path.join(projectRoot, relDir);
118
- const out = [];
119
- async function walk(absDir) {
120
- if (out.length >= limit)
121
- return;
122
- let entries;
123
- try {
124
- entries = await fs.readdir(absDir, { withFileTypes: true });
125
- }
126
- catch {
127
- return;
128
- }
129
- for (const entry of entries) {
130
- if (out.length >= limit)
131
- return;
132
- if (entry.name.startsWith("."))
133
- continue;
134
- const abs = path.join(absDir, entry.name);
135
- if (entry.isDirectory()) {
136
- await walk(abs);
137
- }
138
- else if (entry.isFile()) {
139
- out.push(path.relative(projectRoot, abs).split(path.sep).join("/"));
140
- }
141
- }
142
- }
143
- await walk(root);
144
- return out;
145
- }
@@ -1,8 +0,0 @@
1
- import type { HookArgs } from "./parsers.js";
2
- import type { Writable } from "node:stream";
3
- interface InternalIo {
4
- stdout: Writable;
5
- stderr: Writable;
6
- }
7
- export declare function runHookCommand(projectRoot: string, args: HookArgs, io: InternalIo): Promise<number>;
8
- export {};
@@ -1,40 +0,0 @@
1
- import fs from "node:fs/promises";
2
- import path from "node:path";
3
- import { spawn } from "node:child_process";
4
- import process from "node:process";
5
- import { RUNTIME_ROOT } from "../../constants.js";
6
- export async function runHookCommand(projectRoot, args, io) {
7
- const runHookPath = path.join(projectRoot, RUNTIME_ROOT, "hooks", "run-hook.mjs");
8
- try {
9
- await fs.access(runHookPath);
10
- }
11
- catch {
12
- io.stderr.write(`cclaw internal hook: missing hook runtime at ${runHookPath}. Run \`cclaw sync\` first.\n`);
13
- return 1;
14
- }
15
- return await new Promise((resolve) => {
16
- const child = spawn(process.execPath, [runHookPath, args.hookName], {
17
- cwd: projectRoot,
18
- env: process.env,
19
- stdio: ["inherit", "pipe", "pipe"]
20
- });
21
- child.stdout.on("data", (chunk) => {
22
- io.stdout.write(chunk);
23
- });
24
- child.stderr.on("data", (chunk) => {
25
- io.stderr.write(chunk);
26
- });
27
- child.on("error", (err) => {
28
- io.stderr.write(`cclaw internal hook: failed to launch runtime (${err instanceof Error ? err.message : String(err)}).\n`);
29
- resolve(1);
30
- });
31
- child.on("close", (code, signal) => {
32
- if (signal) {
33
- io.stderr.write(`cclaw internal hook: runtime terminated by signal ${signal}.\n`);
34
- resolve(1);
35
- return;
36
- }
37
- resolve(typeof code === "number" ? code : 1);
38
- });
39
- });
40
- }
@@ -1,72 +0,0 @@
1
- import { type DiscoveryMode, type FlowStage, type FlowTrack } from "../../types.js";
2
- import type { ArchiveDisposition } from "../../runs.js";
3
- export interface AdvanceStageArgs {
4
- stage: FlowStage;
5
- passedGateIds: string[];
6
- evidenceByGate: Record<string, string>;
7
- waiveDelegations: string[];
8
- waiverReason?: string;
9
- acceptProactiveWaiver: boolean;
10
- acceptProactiveWaiverReason?: string;
11
- /**
12
- * Approval token issued by `cclaw-cli internal waiver-grant`. Required
13
- * (via `--accept-proactive-waiver=<token>`) whenever the caller asserts
14
- * `acceptProactiveWaiver`. Legacy `--accept-proactive-waiver` without a
15
- * token is still parsed but rejected downstream by the advance-stage
16
- * handler so operators see the error at runtime.
17
- */
18
- acceptProactiveWaiverToken?: string;
19
- skipQuestions: boolean;
20
- quiet: boolean;
21
- json: boolean;
22
- }
23
- export interface VerifyFlowStateDiffArgs {
24
- afterJson?: string;
25
- afterFile?: string;
26
- quiet: boolean;
27
- }
28
- export interface VerifyCurrentStateArgs {
29
- quiet: boolean;
30
- }
31
- export interface HookArgs {
32
- hookName: string;
33
- }
34
- export interface RewindArgs {
35
- mode: "rewind" | "ack";
36
- targetStage: FlowStage;
37
- reason?: string;
38
- quiet: boolean;
39
- json: boolean;
40
- }
41
- export interface StartFlowArgs {
42
- track: FlowTrack;
43
- discoveryMode: DiscoveryMode;
44
- className?: string;
45
- prompt?: string;
46
- reason?: string;
47
- stack?: string;
48
- forceReset: boolean;
49
- reclassify: boolean;
50
- quiet: boolean;
51
- /**
52
- * `/cc-ideate` handoff carry-forward.
53
- * Workspace-relative POSIX path to `.cclaw/ideas/idea-YYYY-MM-DD-<slug>.md`
54
- * (or wherever `/cc-ideate` wrote its artifact).
55
- */
56
- fromIdeaArtifact?: string;
57
- /** Optional `I-#` row id chosen from the idea artifact's ranked list. */
58
- fromIdeaCandidateId?: string;
59
- }
60
- export interface CancelRunArgs {
61
- reason: string;
62
- disposition: Extract<ArchiveDisposition, "cancelled" | "abandoned">;
63
- name?: string;
64
- quiet: boolean;
65
- }
66
- export declare function parseAdvanceStageArgs(tokens: string[]): AdvanceStageArgs;
67
- export declare function parseVerifyFlowStateDiffArgs(tokens: string[]): VerifyFlowStateDiffArgs;
68
- export declare function parseVerifyCurrentStateArgs(tokens: string[]): VerifyCurrentStateArgs;
69
- export declare function parseRewindArgs(tokens: string[]): RewindArgs;
70
- export declare function parseHookArgs(tokens: string[]): HookArgs;
71
- export declare function parseStartFlowArgs(tokens: string[]): StartFlowArgs;
72
- export declare function parseCancelRunArgs(tokens: string[]): CancelRunArgs;