cclaw-cli 7.7.1 → 8.1.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 (284) hide show
  1. package/README.md +211 -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 +107 -511
  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 -768
  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 -134
  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/harness-prompt.d.ts +26 -0
  73. package/dist/harness-prompt.js +142 -0
  74. package/dist/install.d.ts +35 -15
  75. package/dist/install.js +238 -1347
  76. package/dist/knowledge-store.d.ts +19 -163
  77. package/dist/knowledge-store.js +56 -590
  78. package/dist/logger.d.ts +8 -3
  79. package/dist/logger.js +13 -4
  80. package/dist/orchestrator-routing.d.ts +29 -0
  81. package/dist/orchestrator-routing.js +156 -0
  82. package/dist/run-persistence.d.ts +7 -118
  83. package/dist/run-persistence.js +29 -845
  84. package/dist/runtime/run-hook.entry.d.ts +1 -3
  85. package/dist/runtime/run-hook.entry.js +19 -4
  86. package/dist/runtime/run-hook.mjs +13 -1024
  87. package/dist/types.d.ts +25 -261
  88. package/dist/types.js +8 -36
  89. package/package.json +6 -3
  90. package/dist/artifact-linter/brainstorm.d.ts +0 -2
  91. package/dist/artifact-linter/brainstorm.js +0 -353
  92. package/dist/artifact-linter/design.d.ts +0 -18
  93. package/dist/artifact-linter/design.js +0 -444
  94. package/dist/artifact-linter/findings-dedup.d.ts +0 -56
  95. package/dist/artifact-linter/findings-dedup.js +0 -232
  96. package/dist/artifact-linter/plan.d.ts +0 -2
  97. package/dist/artifact-linter/plan.js +0 -826
  98. package/dist/artifact-linter/review-army.d.ts +0 -49
  99. package/dist/artifact-linter/review-army.js +0 -520
  100. package/dist/artifact-linter/review.d.ts +0 -2
  101. package/dist/artifact-linter/review.js +0 -113
  102. package/dist/artifact-linter/scope.d.ts +0 -2
  103. package/dist/artifact-linter/scope.js +0 -158
  104. package/dist/artifact-linter/shared.d.ts +0 -637
  105. package/dist/artifact-linter/shared.js +0 -2163
  106. package/dist/artifact-linter/ship.d.ts +0 -2
  107. package/dist/artifact-linter/ship.js +0 -250
  108. package/dist/artifact-linter/spec.d.ts +0 -2
  109. package/dist/artifact-linter/spec.js +0 -176
  110. package/dist/artifact-linter/tdd.d.ts +0 -118
  111. package/dist/artifact-linter/tdd.js +0 -1404
  112. package/dist/artifact-linter.d.ts +0 -15
  113. package/dist/artifact-linter.js +0 -517
  114. package/dist/codex-feature-flag.d.ts +0 -58
  115. package/dist/codex-feature-flag.js +0 -193
  116. package/dist/content/closeout-guidance.d.ts +0 -14
  117. package/dist/content/closeout-guidance.js +0 -44
  118. package/dist/content/diff-command.d.ts +0 -1
  119. package/dist/content/diff-command.js +0 -43
  120. package/dist/content/harness-doc.d.ts +0 -1
  121. package/dist/content/harness-doc.js +0 -65
  122. package/dist/content/hook-events.d.ts +0 -9
  123. package/dist/content/hook-events.js +0 -23
  124. package/dist/content/hook-manifest.d.ts +0 -81
  125. package/dist/content/hook-manifest.js +0 -156
  126. package/dist/content/hooks.d.ts +0 -11
  127. package/dist/content/hooks.js +0 -1972
  128. package/dist/content/idea.d.ts +0 -60
  129. package/dist/content/idea.js +0 -416
  130. package/dist/content/language-policy.d.ts +0 -2
  131. package/dist/content/language-policy.js +0 -13
  132. package/dist/content/learnings.d.ts +0 -6
  133. package/dist/content/learnings.js +0 -141
  134. package/dist/content/observe.d.ts +0 -19
  135. package/dist/content/observe.js +0 -86
  136. package/dist/content/opencode-plugin.d.ts +0 -1
  137. package/dist/content/opencode-plugin.js +0 -635
  138. package/dist/content/review-prompts.d.ts +0 -1
  139. package/dist/content/review-prompts.js +0 -104
  140. package/dist/content/runtime-shared-snippets.d.ts +0 -8
  141. package/dist/content/runtime-shared-snippets.js +0 -80
  142. package/dist/content/session-hooks.d.ts +0 -7
  143. package/dist/content/session-hooks.js +0 -107
  144. package/dist/content/skills-elicitation.d.ts +0 -1
  145. package/dist/content/skills-elicitation.js +0 -167
  146. package/dist/content/stage-command.d.ts +0 -2
  147. package/dist/content/stage-command.js +0 -17
  148. package/dist/content/stage-schema.d.ts +0 -117
  149. package/dist/content/stage-schema.js +0 -955
  150. package/dist/content/stages/_lint-metadata/index.d.ts +0 -2
  151. package/dist/content/stages/_lint-metadata/index.js +0 -97
  152. package/dist/content/stages/brainstorm.d.ts +0 -2
  153. package/dist/content/stages/brainstorm.js +0 -184
  154. package/dist/content/stages/design.d.ts +0 -2
  155. package/dist/content/stages/design.js +0 -288
  156. package/dist/content/stages/index.d.ts +0 -8
  157. package/dist/content/stages/index.js +0 -11
  158. package/dist/content/stages/plan.d.ts +0 -2
  159. package/dist/content/stages/plan.js +0 -191
  160. package/dist/content/stages/review.d.ts +0 -2
  161. package/dist/content/stages/review.js +0 -240
  162. package/dist/content/stages/schema-types.d.ts +0 -203
  163. package/dist/content/stages/schema-types.js +0 -1
  164. package/dist/content/stages/scope.d.ts +0 -2
  165. package/dist/content/stages/scope.js +0 -254
  166. package/dist/content/stages/ship.d.ts +0 -2
  167. package/dist/content/stages/ship.js +0 -159
  168. package/dist/content/stages/spec.d.ts +0 -2
  169. package/dist/content/stages/spec.js +0 -170
  170. package/dist/content/stages/tdd.d.ts +0 -4
  171. package/dist/content/stages/tdd.js +0 -273
  172. package/dist/content/state-contracts.d.ts +0 -1
  173. package/dist/content/state-contracts.js +0 -63
  174. package/dist/content/status-command.d.ts +0 -4
  175. package/dist/content/status-command.js +0 -109
  176. package/dist/content/subagent-context-skills.d.ts +0 -4
  177. package/dist/content/subagent-context-skills.js +0 -279
  178. package/dist/content/subagents.d.ts +0 -3
  179. package/dist/content/subagents.js +0 -997
  180. package/dist/content/templates.d.ts +0 -26
  181. package/dist/content/templates.js +0 -1692
  182. package/dist/content/track-render-context.d.ts +0 -18
  183. package/dist/content/track-render-context.js +0 -53
  184. package/dist/content/tree-command.d.ts +0 -1
  185. package/dist/content/tree-command.js +0 -64
  186. package/dist/content/utility-skills.d.ts +0 -30
  187. package/dist/content/utility-skills.js +0 -160
  188. package/dist/content/view-command.d.ts +0 -2
  189. package/dist/content/view-command.js +0 -92
  190. package/dist/delegation.d.ts +0 -649
  191. package/dist/delegation.js +0 -1539
  192. package/dist/early-loop.d.ts +0 -70
  193. package/dist/early-loop.js +0 -302
  194. package/dist/execution-topology.d.ts +0 -44
  195. package/dist/execution-topology.js +0 -95
  196. package/dist/gate-evidence.d.ts +0 -85
  197. package/dist/gate-evidence.js +0 -631
  198. package/dist/harness-adapters.d.ts +0 -151
  199. package/dist/harness-adapters.js +0 -756
  200. package/dist/harness-selection.d.ts +0 -31
  201. package/dist/harness-selection.js +0 -214
  202. package/dist/hook-schema.d.ts +0 -6
  203. package/dist/hook-schema.js +0 -114
  204. package/dist/hook-schemas/claude-hooks.v1.json +0 -10
  205. package/dist/hook-schemas/codex-hooks.v1.json +0 -10
  206. package/dist/hook-schemas/cursor-hooks.v1.json +0 -13
  207. package/dist/init-detect.d.ts +0 -2
  208. package/dist/init-detect.js +0 -50
  209. package/dist/internal/advance-stage/advance.d.ts +0 -89
  210. package/dist/internal/advance-stage/advance.js +0 -655
  211. package/dist/internal/advance-stage/cancel-run.d.ts +0 -8
  212. package/dist/internal/advance-stage/cancel-run.js +0 -19
  213. package/dist/internal/advance-stage/flow-state-coercion.d.ts +0 -3
  214. package/dist/internal/advance-stage/flow-state-coercion.js +0 -81
  215. package/dist/internal/advance-stage/helpers.d.ts +0 -14
  216. package/dist/internal/advance-stage/helpers.js +0 -145
  217. package/dist/internal/advance-stage/hook.d.ts +0 -8
  218. package/dist/internal/advance-stage/hook.js +0 -40
  219. package/dist/internal/advance-stage/parsers.d.ts +0 -72
  220. package/dist/internal/advance-stage/parsers.js +0 -357
  221. package/dist/internal/advance-stage/proactive-delegation-trace.d.ts +0 -24
  222. package/dist/internal/advance-stage/proactive-delegation-trace.js +0 -56
  223. package/dist/internal/advance-stage/review-loop.d.ts +0 -16
  224. package/dist/internal/advance-stage/review-loop.js +0 -199
  225. package/dist/internal/advance-stage/rewind.d.ts +0 -14
  226. package/dist/internal/advance-stage/rewind.js +0 -108
  227. package/dist/internal/advance-stage/start-flow.d.ts +0 -13
  228. package/dist/internal/advance-stage/start-flow.js +0 -241
  229. package/dist/internal/advance-stage/verify.d.ts +0 -21
  230. package/dist/internal/advance-stage/verify.js +0 -185
  231. package/dist/internal/advance-stage.d.ts +0 -7
  232. package/dist/internal/advance-stage.js +0 -138
  233. package/dist/internal/cohesion-contract-stub.d.ts +0 -24
  234. package/dist/internal/cohesion-contract-stub.js +0 -148
  235. package/dist/internal/compound-readiness.d.ts +0 -23
  236. package/dist/internal/compound-readiness.js +0 -102
  237. package/dist/internal/detect-public-api-changes.d.ts +0 -5
  238. package/dist/internal/detect-public-api-changes.js +0 -45
  239. package/dist/internal/detect-supply-chain-changes.d.ts +0 -6
  240. package/dist/internal/detect-supply-chain-changes.js +0 -138
  241. package/dist/internal/early-loop-status.d.ts +0 -7
  242. package/dist/internal/early-loop-status.js +0 -93
  243. package/dist/internal/envelope-validate.d.ts +0 -7
  244. package/dist/internal/envelope-validate.js +0 -66
  245. package/dist/internal/flow-state-repair.d.ts +0 -20
  246. package/dist/internal/flow-state-repair.js +0 -104
  247. package/dist/internal/plan-split-waves.d.ts +0 -190
  248. package/dist/internal/plan-split-waves.js +0 -764
  249. package/dist/internal/runtime-integrity.d.ts +0 -7
  250. package/dist/internal/runtime-integrity.js +0 -268
  251. package/dist/internal/slice-commit.d.ts +0 -7
  252. package/dist/internal/slice-commit.js +0 -619
  253. package/dist/internal/tdd-loop-status.d.ts +0 -14
  254. package/dist/internal/tdd-loop-status.js +0 -68
  255. package/dist/internal/tdd-red-evidence.d.ts +0 -7
  256. package/dist/internal/tdd-red-evidence.js +0 -153
  257. package/dist/internal/waiver-grant.d.ts +0 -62
  258. package/dist/internal/waiver-grant.js +0 -294
  259. package/dist/internal/wave-status.d.ts +0 -74
  260. package/dist/internal/wave-status.js +0 -506
  261. package/dist/managed-resources.d.ts +0 -53
  262. package/dist/managed-resources.js +0 -313
  263. package/dist/policy.d.ts +0 -10
  264. package/dist/policy.js +0 -167
  265. package/dist/retro-gate.d.ts +0 -9
  266. package/dist/retro-gate.js +0 -47
  267. package/dist/run-archive.d.ts +0 -61
  268. package/dist/run-archive.js +0 -391
  269. package/dist/runs.d.ts +0 -2
  270. package/dist/runs.js +0 -2
  271. package/dist/stack-detection.d.ts +0 -116
  272. package/dist/stack-detection.js +0 -489
  273. package/dist/streaming/event-stream.d.ts +0 -31
  274. package/dist/streaming/event-stream.js +0 -114
  275. package/dist/tdd-cycle.d.ts +0 -107
  276. package/dist/tdd-cycle.js +0 -289
  277. package/dist/tdd-verification-evidence.d.ts +0 -17
  278. package/dist/tdd-verification-evidence.js +0 -122
  279. package/dist/track-heuristics.d.ts +0 -27
  280. package/dist/track-heuristics.js +0 -154
  281. package/dist/util/slice-id.d.ts +0 -58
  282. package/dist/util/slice-id.js +0 -89
  283. package/dist/worktree-manager.d.ts +0 -20
  284. package/dist/worktree-manager.js +0 -108
@@ -1,31 +0,0 @@
1
- import { type CliContext, type HarnessId } from "./types.js";
2
- export type HarnessSelectionAnswer = {
3
- kind: "accept";
4
- } | {
5
- kind: "all";
6
- } | {
7
- kind: "toggle";
8
- indexes: number[];
9
- } | {
10
- kind: "invalid";
11
- message: string;
12
- };
13
- export interface HarnessChecklistState {
14
- choices: readonly HarnessId[];
15
- selected: readonly HarnessId[];
16
- cursor: number;
17
- message?: string;
18
- }
19
- export type HarnessChecklistOutcome = "confirm" | "cancel";
20
- export interface HarnessChecklistUpdate {
21
- state: HarnessChecklistState;
22
- outcome?: HarnessChecklistOutcome;
23
- }
24
- export declare function parseHarnessSelectionAnswer(raw: string, total?: 4): HarnessSelectionAnswer;
25
- export declare function createHarnessChecklistState(selected: readonly HarnessId[], choices?: readonly HarnessId[]): HarnessChecklistState;
26
- export declare function updateHarnessChecklistState(state: HarnessChecklistState, key: string): HarnessChecklistUpdate;
27
- export declare function promptHarnessSelectionChecklist(defaults: {
28
- harnesses: HarnessId[];
29
- detectedHarnesses?: HarnessId[];
30
- currentHarnesses?: HarnessId[];
31
- }, ctx: CliContext, label?: string): Promise<HarnessId[]>;
@@ -1,214 +0,0 @@
1
- import { createInterface } from "node:readline/promises";
2
- import process from "node:process";
3
- import { HARNESS_ADAPTERS } from "./harness-adapters.js";
4
- import { HARNESS_IDS } from "./types.js";
5
- export function parseHarnessSelectionAnswer(raw, total = HARNESS_IDS.length) {
6
- const answer = raw.trim().toLowerCase();
7
- if (answer.length === 0)
8
- return { kind: "accept" };
9
- if (answer === "all")
10
- return { kind: "all" };
11
- if (answer === "none") {
12
- return { kind: "invalid", message: "Zero harnesses is not supported. Select at least one harness." };
13
- }
14
- const parts = answer.split(",").map((part) => part.trim()).filter(Boolean);
15
- const indexes = parts.map((part) => Number.parseInt(part, 10));
16
- if (indexes.some((value) => !Number.isInteger(value) || value < 1 || value > total)) {
17
- return { kind: "invalid", message: `Invalid selection. Use numbers 1-${total}, comma-separated.` };
18
- }
19
- return { kind: "toggle", indexes };
20
- }
21
- export function createHarnessChecklistState(selected, choices = HARNESS_IDS) {
22
- const validSelected = choices.filter((harness) => selected.includes(harness));
23
- return {
24
- choices,
25
- selected: validSelected.length > 0 ? validSelected : choices.slice(),
26
- cursor: 0
27
- };
28
- }
29
- function moveCursor(state, delta) {
30
- const next = (state.cursor + delta + state.choices.length) % state.choices.length;
31
- return { ...state, cursor: next, message: undefined };
32
- }
33
- function toggleCurrent(state) {
34
- const current = state.choices[state.cursor];
35
- if (!current)
36
- return state;
37
- const selected = state.selected.includes(current)
38
- ? state.selected.filter((harness) => harness !== current)
39
- : [...state.selected, current];
40
- return { ...state, selected: state.choices.filter((harness) => selected.includes(harness)), message: undefined };
41
- }
42
- export function updateHarnessChecklistState(state, key) {
43
- if (key === "\u0003" || key === "\u001b") {
44
- return { state: { ...state, message: "Cancelled." }, outcome: "cancel" };
45
- }
46
- if (key === "\u001b[A" || key === "k" || key === "K") {
47
- return { state: moveCursor(state, -1) };
48
- }
49
- if (key === "\u001b[B" || key === "j" || key === "J") {
50
- return { state: moveCursor(state, 1) };
51
- }
52
- if (key === " ") {
53
- return { state: toggleCurrent(state) };
54
- }
55
- if (key === "a" || key === "A") {
56
- return { state: { ...state, selected: state.choices.slice(), message: undefined } };
57
- }
58
- if (key === "\r" || key === "\n") {
59
- if (state.selected.length === 0) {
60
- return { state: { ...state, message: "Select at least one harness." } };
61
- }
62
- return { state, outcome: "confirm" };
63
- }
64
- return { state };
65
- }
66
- function selectedHarnessPreview(harnesses) {
67
- return harnesses.length > 0 ? harnesses.join(", ") : "none";
68
- }
69
- function harnessLabel(harness) {
70
- const adapter = HARNESS_ADAPTERS[harness];
71
- const tier = adapter ? `${adapter.reality.declaredSupport}, ${adapter.capabilities.hookSurface} hooks` : "supported";
72
- return `${harness} (${tier})`;
73
- }
74
- function renderChecklist(state, defaults, ctx, label) {
75
- const detected = new Set(defaults.detectedHarnesses ?? []);
76
- const current = new Set(defaults.currentHarnesses ?? []);
77
- const defaultSet = new Set(defaults.defaultHarnesses ?? []);
78
- ctx.stdout.write("\x1b[2J\x1b[H");
79
- ctx.stdout.write(`${label}\n`);
80
- ctx.stdout.write(`Detected: ${selectedHarnessPreview(defaults.detectedHarnesses ?? [])}\n`);
81
- ctx.stdout.write(`Current: ${selectedHarnessPreview(defaults.currentHarnesses ?? [])}\n`);
82
- ctx.stdout.write("Use Up/Down or k/j to move, Space to toggle, a to select all, Enter to confirm, Esc to cancel.\n\n");
83
- state.choices.forEach((harness, index) => {
84
- const adapter = HARNESS_ADAPTERS[harness];
85
- const markers = [
86
- detected.has(harness) ? "detected" : "",
87
- current.has(harness) ? "current" : "",
88
- defaultSet.has(harness) ? "default" : ""
89
- ].filter(Boolean).join(", ");
90
- const pointer = index === state.cursor ? ">" : " ";
91
- const checked = state.selected.includes(harness) ? "x" : " ";
92
- ctx.stdout.write(`${pointer} [${checked}] ${harnessLabel(harness)} -> ${adapter.commandDir}${markers ? ` (${markers})` : ""}\n`);
93
- });
94
- if (state.message) {
95
- ctx.stdout.write(`\n${state.message}\n`);
96
- }
97
- }
98
- function rawModeAvailable(ctx) {
99
- return Boolean(process.stdin.isTTY &&
100
- ctx.stdout.isTTY &&
101
- typeof process.stdin.setRawMode === "function");
102
- }
103
- async function promptHarnessSelectionRaw(defaults, ctx, label) {
104
- let state = createHarnessChecklistState(defaults.harnesses);
105
- const input = process.stdin;
106
- const wasRaw = Boolean(input.isRaw);
107
- let settle;
108
- let rejectSelection;
109
- const done = new Promise((resolve, reject) => {
110
- settle = resolve;
111
- rejectSelection = reject;
112
- });
113
- const onData = (chunk) => {
114
- const key = chunk.toString("utf8");
115
- const update = updateHarnessChecklistState(state, key);
116
- state = update.state;
117
- renderChecklist(state, {
118
- detectedHarnesses: defaults.detectedHarnesses,
119
- currentHarnesses: defaults.currentHarnesses,
120
- defaultHarnesses: defaults.harnesses
121
- }, ctx, label);
122
- if (update.outcome === "confirm") {
123
- settle?.(HARNESS_IDS.filter((harness) => state.selected.includes(harness)));
124
- }
125
- else if (update.outcome === "cancel") {
126
- rejectSelection?.(new Error("Harness selection cancelled."));
127
- }
128
- };
129
- try {
130
- input.setRawMode?.(true);
131
- input.resume();
132
- input.on("data", onData);
133
- renderChecklist(state, {
134
- detectedHarnesses: defaults.detectedHarnesses,
135
- currentHarnesses: defaults.currentHarnesses,
136
- defaultHarnesses: defaults.harnesses
137
- }, ctx, label);
138
- return await done;
139
- }
140
- finally {
141
- input.off("data", onData);
142
- input.setRawMode?.(wasRaw);
143
- if (!wasRaw)
144
- input.pause();
145
- ctx.stdout.write("\n");
146
- }
147
- }
148
- async function promptHarnessSelectionText(defaults, ctx, label) {
149
- const rl = createInterface({
150
- input: process.stdin,
151
- output: ctx.stdout
152
- });
153
- const defaultSet = new Set(defaults.harnesses);
154
- const selected = new Set(defaults.harnesses.length > 0 ? defaults.harnesses : HARNESS_IDS);
155
- const detected = new Set(defaults.detectedHarnesses ?? []);
156
- const current = new Set(defaults.currentHarnesses ?? []);
157
- const printMenu = () => {
158
- ctx.stdout.write(`\n${label}\n`);
159
- ctx.stdout.write(`Detected: ${selectedHarnessPreview(defaults.detectedHarnesses ?? [])}\n`);
160
- ctx.stdout.write(`Current: ${selectedHarnessPreview(defaults.currentHarnesses ?? [])}\n`);
161
- ctx.stdout.write("Supported harnesses and target paths:\n");
162
- HARNESS_IDS.forEach((harness, index) => {
163
- const adapter = HARNESS_ADAPTERS[harness];
164
- const markers = [
165
- detected.has(harness) ? "detected" : "",
166
- current.has(harness) ? "current" : "",
167
- defaultSet.has(harness) ? "default" : ""
168
- ].filter(Boolean).join(", ");
169
- const checked = selected.has(harness) ? "x" : " ";
170
- ctx.stdout.write(` ${index + 1}. [${checked}] ${harnessLabel(harness)} -> ${adapter.commandDir}${markers ? ` (${markers})` : ""}\n`);
171
- });
172
- ctx.stdout.write("Enter numbers to toggle (for example 1,3), 'all', or press Enter to accept.\n");
173
- };
174
- try {
175
- while (true) {
176
- printMenu();
177
- const answer = await rl.question(`Selected [${[...selected].join(",") || "select at least one"}]: `);
178
- const parsedAnswer = parseHarnessSelectionAnswer(answer);
179
- if (parsedAnswer.kind === "accept") {
180
- if (selected.size === 0) {
181
- ctx.stdout.write("Select at least one harness.\n");
182
- continue;
183
- }
184
- return HARNESS_IDS.filter((harness) => selected.has(harness));
185
- }
186
- if (parsedAnswer.kind === "all") {
187
- HARNESS_IDS.forEach((harness) => selected.add(harness));
188
- continue;
189
- }
190
- if (parsedAnswer.kind === "invalid") {
191
- ctx.stdout.write(`${parsedAnswer.message}\n`);
192
- continue;
193
- }
194
- for (const index of parsedAnswer.indexes) {
195
- const harness = HARNESS_IDS[index - 1];
196
- if (!harness)
197
- continue;
198
- if (selected.has(harness))
199
- selected.delete(harness);
200
- else
201
- selected.add(harness);
202
- }
203
- }
204
- }
205
- finally {
206
- rl.close();
207
- }
208
- }
209
- export async function promptHarnessSelectionChecklist(defaults, ctx, label = "Harness selection") {
210
- if (rawModeAvailable(ctx)) {
211
- return promptHarnessSelectionRaw(defaults, ctx, label);
212
- }
213
- return promptHarnessSelectionText(defaults, ctx, label);
214
- }
@@ -1,6 +0,0 @@
1
- export type HookSchemaHarness = "claude" | "cursor" | "codex";
2
- export interface HookSchemaValidationResult {
3
- ok: boolean;
4
- errors: string[];
5
- }
6
- export declare function validateHookDocument(harness: HookSchemaHarness, document: unknown): HookSchemaValidationResult;
@@ -1,114 +0,0 @@
1
- import claudeHooksSchema from "./hook-schemas/claude-hooks.v1.json" with { type: "json" };
2
- import codexHooksSchema from "./hook-schemas/codex-hooks.v1.json" with { type: "json" };
3
- import cursorHooksSchema from "./hook-schemas/cursor-hooks.v1.json" with { type: "json" };
4
- const SCHEMA_MAP = {
5
- claude: claudeHooksSchema,
6
- cursor: cursorHooksSchema,
7
- codex: codexHooksSchema
8
- };
9
- function toObject(value) {
10
- if (!value || typeof value !== "object" || Array.isArray(value)) {
11
- return null;
12
- }
13
- return value;
14
- }
15
- function isNonEmptyString(value) {
16
- return typeof value === "string" && value.trim().length > 0;
17
- }
18
- function isPositiveNumber(value) {
19
- return typeof value === "number" && Number.isFinite(value) && value > 0;
20
- }
21
- function validateCursorEvent(eventName, eventEntries, errors) {
22
- for (let index = 0; index < eventEntries.length; index += 1) {
23
- const rawEntry = eventEntries[index];
24
- const entry = toObject(rawEntry);
25
- if (!entry) {
26
- errors.push(`hooks.${eventName}[${index}] must be an object`);
27
- continue;
28
- }
29
- if (!isNonEmptyString(entry.command)) {
30
- errors.push(`hooks.${eventName}[${index}].command must be a non-empty string`);
31
- }
32
- if (entry.matcher !== undefined && typeof entry.matcher !== "string") {
33
- errors.push(`hooks.${eventName}[${index}].matcher must be a string when present`);
34
- }
35
- if (entry.timeout !== undefined && !isPositiveNumber(entry.timeout)) {
36
- errors.push(`hooks.${eventName}[${index}].timeout must be a positive number when present`);
37
- }
38
- }
39
- }
40
- function validateClaudeLikeEvent(eventName, eventEntries, errors) {
41
- for (let index = 0; index < eventEntries.length; index += 1) {
42
- const rawEntry = eventEntries[index];
43
- const entry = toObject(rawEntry);
44
- if (!entry) {
45
- errors.push(`hooks.${eventName}[${index}] must be an object`);
46
- continue;
47
- }
48
- if (entry.matcher !== undefined && typeof entry.matcher !== "string") {
49
- errors.push(`hooks.${eventName}[${index}].matcher must be a string when present`);
50
- }
51
- if (!Array.isArray(entry.hooks) || entry.hooks.length === 0) {
52
- errors.push(`hooks.${eventName}[${index}].hooks must be a non-empty array`);
53
- continue;
54
- }
55
- for (let hookIndex = 0; hookIndex < entry.hooks.length; hookIndex += 1) {
56
- const rawHook = entry.hooks[hookIndex];
57
- const hook = toObject(rawHook);
58
- if (!hook) {
59
- errors.push(`hooks.${eventName}[${index}].hooks[${hookIndex}] must be an object`);
60
- continue;
61
- }
62
- if (hook.type !== "command") {
63
- errors.push(`hooks.${eventName}[${index}].hooks[${hookIndex}].type must be "command"`);
64
- }
65
- if (!isNonEmptyString(hook.command)) {
66
- errors.push(`hooks.${eventName}[${index}].hooks[${hookIndex}].command must be a non-empty string`);
67
- }
68
- if (hook.timeout !== undefined && !isPositiveNumber(hook.timeout)) {
69
- errors.push(`hooks.${eventName}[${index}].hooks[${hookIndex}].timeout must be a positive number when present`);
70
- }
71
- if (hook.statusMessage !== undefined && !isNonEmptyString(hook.statusMessage)) {
72
- errors.push(`hooks.${eventName}[${index}].hooks[${hookIndex}].statusMessage must be a non-empty string when present`);
73
- }
74
- }
75
- }
76
- }
77
- export function validateHookDocument(harness, document) {
78
- const descriptor = SCHEMA_MAP[harness];
79
- const root = toObject(document);
80
- if (!root) {
81
- return { ok: false, errors: ["hook document must be a JSON object"] };
82
- }
83
- const errors = [];
84
- const version = root.cclawHookSchemaVersion;
85
- if (version !== descriptor.schemaVersion) {
86
- errors.push(`expected cclawHookSchemaVersion=${descriptor.schemaVersion}, got ${JSON.stringify(version)}`);
87
- }
88
- if (harness === "cursor" && root.version !== 1) {
89
- errors.push(`cursor hooks require version=1, got ${JSON.stringify(root.version)}`);
90
- }
91
- const hooks = toObject(root.hooks);
92
- if (!hooks) {
93
- errors.push("missing hooks object");
94
- }
95
- else {
96
- for (const eventName of descriptor.requiredEvents) {
97
- const eventValue = hooks[eventName];
98
- if (!Array.isArray(eventValue) || eventValue.length === 0) {
99
- errors.push(`missing required event array "${eventName}"`);
100
- continue;
101
- }
102
- if (harness === "cursor") {
103
- validateCursorEvent(eventName, eventValue, errors);
104
- }
105
- else {
106
- validateClaudeLikeEvent(eventName, eventValue, errors);
107
- }
108
- }
109
- }
110
- return {
111
- ok: errors.length === 0,
112
- errors
113
- };
114
- }
@@ -1,10 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "cclaw://hooks/claude/v1",
4
- "harness": "claude",
5
- "schemaVersion": 2,
6
- "requiredEvents": [
7
- "SessionStart",
8
- "Stop"
9
- ]
10
- }
@@ -1,10 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "cclaw://hooks/codex/v1",
4
- "harness": "codex",
5
- "schemaVersion": 2,
6
- "requiredEvents": [
7
- "SessionStart",
8
- "Stop"
9
- ]
10
- }
@@ -1,13 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "cclaw://hooks/cursor/v1",
4
- "harness": "cursor",
5
- "schemaVersion": 2,
6
- "requiredEvents": [
7
- "sessionStart",
8
- "sessionResume",
9
- "sessionClear",
10
- "sessionCompact",
11
- "stop"
12
- ]
13
- }
@@ -1,2 +0,0 @@
1
- import type { HarnessId } from "./types.js";
2
- export declare function detectHarnesses(projectRoot: string): Promise<HarnessId[]>;
@@ -1,50 +0,0 @@
1
- import path from "node:path";
2
- import { exists } from "./fs-utils.js";
3
- export async function detectHarnesses(projectRoot) {
4
- const detected = [];
5
- const claudeHints = [
6
- path.join(projectRoot, ".claude"),
7
- path.join(projectRoot, "CLAUDE.md")
8
- ];
9
- if (await anyExists(claudeHints)) {
10
- detected.push("claude");
11
- }
12
- const cursorHints = [
13
- path.join(projectRoot, ".cursor"),
14
- path.join(projectRoot, ".cursor/rules")
15
- ];
16
- if (await anyExists(cursorHints)) {
17
- detected.push("cursor");
18
- }
19
- const opencodeHints = [
20
- path.join(projectRoot, ".opencode"),
21
- path.join(projectRoot, "opencode.json"),
22
- path.join(projectRoot, "opencode.jsonc"),
23
- path.join(projectRoot, ".opencode/opencode.json"),
24
- path.join(projectRoot, ".opencode/opencode.jsonc")
25
- ];
26
- if (await anyExists(opencodeHints)) {
27
- detected.push("opencode");
28
- }
29
- // Codex CLI doesn't require a persistent per-project directory. We
30
- // detect via `.agents/skills/` (the universal path Codex 0.89+ reads;
31
- // Jan 2026) or the legacy `.codex/` marker left by pre-v0.39 cclaw.
32
- // AGENTS.md is intentionally *not* a codex hint because every other
33
- // harness in cclaw's list also reads AGENTS.md.
34
- const codexHints = [
35
- path.join(projectRoot, ".agents/skills"),
36
- path.join(projectRoot, ".codex")
37
- ];
38
- if (await anyExists(codexHints)) {
39
- detected.push("codex");
40
- }
41
- return detected;
42
- }
43
- async function anyExists(paths) {
44
- for (const candidate of paths) {
45
- if (await exists(candidate)) {
46
- return true;
47
- }
48
- }
49
- return false;
50
- }
@@ -1,89 +0,0 @@
1
- import { type FlowState } from "../../flow-state.js";
2
- import { type FlowStage } from "../../types.js";
3
- import type { AdvanceStageArgs } from "./parsers.js";
4
- import type { Writable } from "node:stream";
5
- interface InternalIo {
6
- stdout: Writable;
7
- stderr: Writable;
8
- }
9
- interface InternalValidationReport {
10
- ok: boolean;
11
- stage: FlowStage;
12
- delegation: {
13
- satisfied: boolean;
14
- missing: string[];
15
- waived: string[];
16
- missingEvidence: string[];
17
- missingDispatchProof: string[];
18
- legacyInferredCompletions: string[];
19
- corruptEventLines: number[];
20
- staleWorkers: string[];
21
- expectedMode: string;
22
- /** True when mandatoryAgentsFor returned [] for the run's track / taskClass. */
23
- skippedByTrack: boolean;
24
- };
25
- gates: {
26
- ok: boolean;
27
- complete: boolean;
28
- issues: string[];
29
- missingRequired: string[];
30
- missingTriggeredConditional: string[];
31
- };
32
- completedStages: {
33
- ok: boolean;
34
- issues: string[];
35
- };
36
- }
37
- /**
38
- * entry point — auto-hydrate evidence for an auto-hydratable
39
- * gate that the agent already included in --passed but for which they
40
- * forgot to provide --evidence-json. Returns silently when no
41
- * hydration is possible (no auto-hydratable gate, no artifact, no
42
- * envelope, etc.).
43
- *
44
- * layered `tryAutoHydrateAndSelectReviewLoopGate` on
45
- * top of this so the gate is also auto-included in selectedGateIds
46
- * when the artifact yields a valid envelope. Together the two helpers
47
- * remove the contradiction:
48
- * - "omit this gate from --evidence-json so stage-complete can
49
- * auto-hydrate it" → "missing --evidence-json entries for passed
50
- * gates: design_diagram_freshness".
51
- */
52
- export declare function hydrateReviewLoopEvidenceFromArtifact(projectRoot: string, stage: FlowStage, track: FlowState["track"], selectedGateIds: string[], evidenceByGate: Record<string, string>): Promise<void>;
53
- /**
54
- * auto-include an auto-hydratable review-loop gate
55
- * in `selectedGateIds` when:
56
- * - The stage has an auto-hydratable gate registered via
57
- * `AUTO_REVIEW_LOOP_GATE_BY_STAGE` (currently `design`).
58
- * - The artifact yields a valid review-loop envelope via
59
- * `extractReviewLoopEnvelopeFromArtifact`.
60
- * - The gate is required for the active track.
61
- * - The agent has NOT passed the gate yet (so we don't double-add).
62
- *
63
- * Returns the (possibly extended) array of selected gate IDs and
64
- * mutates `evidenceByGate` to include the hydrated envelope.
65
- *
66
- * Together with `hydrateReviewLoopEvidenceFromArtifact` this makes the
67
- * flow consistent: if the artifact contains the envelope, the agent
68
- * neither has to include the gate in --passed nor pass --evidence-json
69
- * for it. If the artifact does NOT contain the envelope, the agent
70
- * gets a clear error pointing at the artifact section to add (via
71
- * `reviewLoopArtifactFixHint`).
72
- */
73
- export declare function tryAutoHydrateAndSelectReviewLoopGate(projectRoot: string, stage: FlowStage, track: FlowState["track"], requiredGateIds: string[], selectedGateIds: string[], evidenceByGate: Record<string, string>): Promise<string[]>;
74
- export declare function buildValidationReport(projectRoot: string, flowState: FlowState, options?: {
75
- allowBlockedReviewRoute?: boolean;
76
- extraStageFlags?: string[];
77
- }): Promise<InternalValidationReport>;
78
- interface HarvestLearningsResult {
79
- ok: boolean;
80
- markerWritten: boolean;
81
- parsedEntries: number;
82
- appendedEntries: number;
83
- skippedDuplicates: number;
84
- details: string;
85
- }
86
- export declare function withLearningsHarvestMarker(artifactMarkdown: string, appendedEntries: number, skippedDuplicates: number): string;
87
- export declare function harvestStageLearnings(projectRoot: string, stage: FlowStage, track: FlowState["track"]): Promise<HarvestLearningsResult>;
88
- export declare function runAdvanceStage(projectRoot: string, args: AdvanceStageArgs, io: InternalIo): Promise<number>;
89
- export {};