cclaw-cli 7.7.1 → 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 -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/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 -44
  193. package/dist/execution-topology.js +0 -95
  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 -74
  258. package/dist/internal/wave-status.js +0 -506
  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,489 +0,0 @@
1
- import fs from "node:fs/promises";
2
- import path from "node:path";
3
- export const STACK_REVIEW_ROUTE_PROFILES = [
4
- {
5
- stack: "TypeScript/JavaScript",
6
- reviewSignals: ["package.json", "tsconfig.json"],
7
- discoveryMarkers: ["package.json", "tsconfig.json", "jsconfig.json"],
8
- focus: "type safety, package scripts, build/test config, dependency boundaries"
9
- },
10
- {
11
- stack: "Python",
12
- reviewSignals: ["pyproject.toml", "requirements.txt"],
13
- discoveryMarkers: ["pyproject.toml", "requirements.txt", "requirements-dev.txt", ".python-version"],
14
- focus: "packaging, virtualenv assumptions, typing, pytest or unittest evidence"
15
- },
16
- {
17
- stack: "Ruby/Rails",
18
- reviewSignals: ["Gemfile", "config/"],
19
- discoveryMarkers: ["Gemfile"],
20
- focus: "Rails conventions, migrations, routes/controllers, RSpec or Minitest evidence"
21
- },
22
- {
23
- stack: "Go",
24
- reviewSignals: ["go.mod"],
25
- discoveryMarkers: ["go.mod"],
26
- focus: "interfaces, concurrency, error handling, go test coverage"
27
- },
28
- {
29
- stack: "Rust",
30
- reviewSignals: ["Cargo.toml"],
31
- discoveryMarkers: ["Cargo.toml"],
32
- focus: "ownership, error/result handling, feature flags, cargo test coverage"
33
- }
34
- ];
35
- const EXTRA_DISCOVERY_MARKERS = [
36
- "pom.xml",
37
- "build.gradle",
38
- "build.gradle.kts",
39
- "Dockerfile",
40
- "docker-compose.yml",
41
- "docker-compose.yaml",
42
- ".gitlab-ci.yml"
43
- ];
44
- /**
45
- * Unified root-marker list used by start-flow context discovery.
46
- * Keep this in one place so stage skill routing and start-flow scanning
47
- * evolve together.
48
- */
49
- export const STACK_DISCOVERY_MARKERS = [
50
- ...new Set([
51
- ...STACK_REVIEW_ROUTE_PROFILES.flatMap((profile) => profile.discoveryMarkers),
52
- ...EXTRA_DISCOVERY_MARKERS
53
- ])
54
- ];
55
- /**
56
- * Directory markers (checked with pathExists) for stack discovery.
57
- */
58
- export const STACK_DISCOVERY_DIR_MARKERS = [
59
- ".github/workflows"
60
- ];
61
- const STACK_ADAPTER_FACTORIES = [
62
- {
63
- id: "rust",
64
- displayName: "Rust",
65
- async detect({ fileExists }) {
66
- return await fileExists("Cargo.toml");
67
- },
68
- async build() {
69
- return {
70
- id: "rust",
71
- displayName: "Rust",
72
- manifestGlobs: ["Cargo.toml", "**/Cargo.toml"],
73
- lockfileTwins: [
74
- { manifestGlob: "Cargo.toml", lockfileGlob: "Cargo.lock" }
75
- ],
76
- testCommandHints: ["cargo test", "cargo nextest run"],
77
- wiringAggregator: rustWiringAggregator()
78
- };
79
- }
80
- },
81
- {
82
- id: "node",
83
- displayName: "Node/TypeScript",
84
- async detect({ fileExists }) {
85
- return await fileExists("package.json");
86
- },
87
- async build({ fileExists }) {
88
- const lockfileTwins = [];
89
- const candidates = [
90
- { manifestGlob: "package.json", lockfileGlob: "package-lock.json" },
91
- { manifestGlob: "package.json", lockfileGlob: "yarn.lock" },
92
- { manifestGlob: "package.json", lockfileGlob: "pnpm-lock.yaml" }
93
- ];
94
- let detectedAny = false;
95
- for (const candidate of candidates) {
96
- if (await fileExists(candidate.lockfileGlob)) {
97
- lockfileTwins.push(candidate);
98
- detectedAny = true;
99
- }
100
- }
101
- // Conservative default when no lockfile is on disk: assume npm.
102
- // Slice-commit uses lockfileTwins to know which file to auto-include
103
- // when the manifest is in claim and the lockfile drifted; a stale
104
- // npm-style guess is harmless on a yarn project because we only
105
- // act on actual on-disk drift.
106
- if (!detectedAny) {
107
- lockfileTwins.push({
108
- manifestGlob: "package.json",
109
- lockfileGlob: "package-lock.json"
110
- });
111
- }
112
- return {
113
- id: "node",
114
- displayName: "Node/TypeScript",
115
- manifestGlobs: ["package.json", "**/package.json"],
116
- lockfileTwins,
117
- testCommandHints: [
118
- "npm test",
119
- "pnpm test",
120
- "yarn test",
121
- "npx vitest run",
122
- "npx jest"
123
- ],
124
- wiringAggregator: nodeTsWiringAggregator()
125
- };
126
- }
127
- },
128
- {
129
- id: "python",
130
- displayName: "Python",
131
- async detect({ fileExists }) {
132
- return ((await fileExists("pyproject.toml")) ||
133
- (await fileExists("requirements.txt")) ||
134
- (await fileExists("Pipfile")) ||
135
- (await fileExists("setup.py")));
136
- },
137
- async build({ fileExists }) {
138
- const lockfileTwins = [];
139
- const pyprojectCandidates = [
140
- { manifestGlob: "pyproject.toml", lockfileGlob: "poetry.lock" },
141
- { manifestGlob: "pyproject.toml", lockfileGlob: "uv.lock" },
142
- { manifestGlob: "pyproject.toml", lockfileGlob: "pdm.lock" }
143
- ];
144
- let pyprojectAny = false;
145
- if (await fileExists("pyproject.toml")) {
146
- for (const candidate of pyprojectCandidates) {
147
- if (await fileExists(candidate.lockfileGlob)) {
148
- lockfileTwins.push(candidate);
149
- pyprojectAny = true;
150
- }
151
- }
152
- if (!pyprojectAny) {
153
- // Default guess for projects that don't yet have a lockfile.
154
- lockfileTwins.push({
155
- manifestGlob: "pyproject.toml",
156
- lockfileGlob: "poetry.lock"
157
- });
158
- }
159
- }
160
- if (await fileExists("Pipfile")) {
161
- lockfileTwins.push({ manifestGlob: "Pipfile", lockfileGlob: "Pipfile.lock" });
162
- }
163
- return {
164
- id: "python",
165
- displayName: "Python",
166
- manifestGlobs: [
167
- "pyproject.toml",
168
- "Pipfile",
169
- "requirements.txt",
170
- "requirements-dev.txt",
171
- "setup.py",
172
- "setup.cfg"
173
- ],
174
- lockfileTwins,
175
- testCommandHints: ["pytest", "python -m pytest", "python -m unittest"],
176
- wiringAggregator: pythonWiringAggregator()
177
- };
178
- }
179
- },
180
- {
181
- id: "go",
182
- displayName: "Go",
183
- async detect({ fileExists }) {
184
- return await fileExists("go.mod");
185
- },
186
- async build() {
187
- return {
188
- id: "go",
189
- displayName: "Go",
190
- manifestGlobs: ["go.mod", "**/go.mod"],
191
- lockfileTwins: [
192
- { manifestGlob: "go.mod", lockfileGlob: "go.sum" }
193
- ],
194
- testCommandHints: ["go test ./...", "go test"]
195
- };
196
- }
197
- },
198
- {
199
- id: "ruby",
200
- displayName: "Ruby",
201
- async detect({ fileExists }) {
202
- return await fileExists("Gemfile");
203
- },
204
- async build() {
205
- return {
206
- id: "ruby",
207
- displayName: "Ruby",
208
- manifestGlobs: ["Gemfile", "**/Gemfile"],
209
- lockfileTwins: [
210
- { manifestGlob: "Gemfile", lockfileGlob: "Gemfile.lock" }
211
- ],
212
- testCommandHints: ["bundle exec rspec", "bundle exec rake test"]
213
- };
214
- }
215
- },
216
- {
217
- id: "php",
218
- displayName: "PHP",
219
- async detect({ fileExists }) {
220
- return await fileExists("composer.json");
221
- },
222
- async build() {
223
- return {
224
- id: "php",
225
- displayName: "PHP",
226
- manifestGlobs: ["composer.json", "**/composer.json"],
227
- lockfileTwins: [
228
- { manifestGlob: "composer.json", lockfileGlob: "composer.lock" }
229
- ],
230
- testCommandHints: ["composer test", "vendor/bin/phpunit"]
231
- };
232
- }
233
- },
234
- {
235
- id: "swift",
236
- displayName: "Swift",
237
- async detect({ fileExists }) {
238
- return await fileExists("Package.swift");
239
- },
240
- async build() {
241
- return {
242
- id: "swift",
243
- displayName: "Swift",
244
- manifestGlobs: ["Package.swift", "**/Package.swift"],
245
- lockfileTwins: [
246
- { manifestGlob: "Package.swift", lockfileGlob: "Package.resolved" }
247
- ],
248
- testCommandHints: ["swift test"]
249
- };
250
- }
251
- },
252
- {
253
- id: "dotnet",
254
- displayName: ".NET",
255
- async detect({ fileExists }) {
256
- return ((await fileExists("global.json")) ||
257
- (await fileExists("Directory.Build.props")));
258
- },
259
- async build() {
260
- return {
261
- id: "dotnet",
262
- displayName: ".NET",
263
- manifestGlobs: ["**/*.csproj", "**/*.fsproj", "**/*.vbproj"],
264
- lockfileTwins: [
265
- { manifestGlob: "**/*.csproj", lockfileGlob: "**/packages.lock.json" }
266
- ],
267
- testCommandHints: ["dotnet test"]
268
- };
269
- }
270
- },
271
- {
272
- id: "elixir",
273
- displayName: "Elixir",
274
- async detect({ fileExists }) {
275
- return await fileExists("mix.exs");
276
- },
277
- async build() {
278
- return {
279
- id: "elixir",
280
- displayName: "Elixir",
281
- manifestGlobs: ["mix.exs", "**/mix.exs"],
282
- lockfileTwins: [
283
- { manifestGlob: "mix.exs", lockfileGlob: "mix.lock" }
284
- ],
285
- testCommandHints: ["mix test"]
286
- };
287
- }
288
- },
289
- {
290
- id: "java",
291
- displayName: "Java/JVM",
292
- async detect({ fileExists }) {
293
- return ((await fileExists("pom.xml")) ||
294
- (await fileExists("build.gradle")) ||
295
- (await fileExists("build.gradle.kts")));
296
- },
297
- async build({ fileExists }) {
298
- const manifestGlobs = [];
299
- if (await fileExists("pom.xml"))
300
- manifestGlobs.push("pom.xml");
301
- if (await fileExists("build.gradle"))
302
- manifestGlobs.push("build.gradle");
303
- if (await fileExists("build.gradle.kts"))
304
- manifestGlobs.push("build.gradle.kts");
305
- // Java/Gradle/Maven do not have a single canonical lockfile in
306
- // common usage. Leave lockfileTwins empty (no-op for slice-commit
307
- // auto-include). Projects that want lockfiles wire them via the
308
- // local config or wrapper rather than at the adapter layer.
309
- return {
310
- id: "java",
311
- displayName: "Java/JVM",
312
- manifestGlobs: manifestGlobs.length > 0 ? manifestGlobs : ["pom.xml"],
313
- lockfileTwins: [],
314
- testCommandHints: ["mvn test", "gradle test", "./gradlew test"]
315
- };
316
- }
317
- }
318
- ];
319
- const UNKNOWN_STACK_ADAPTER = {
320
- id: "unknown",
321
- displayName: "current stack",
322
- manifestGlobs: [],
323
- lockfileTwins: [],
324
- testCommandHints: []
325
- };
326
- /**
327
- * Load the stack-adapter for a project. Walks the registered factories
328
- * in order; the first detector that returns true wins. Returns the
329
- * `unknown` adapter (no-op) when no detector matches.
330
- *
331
- * Adapter init reads the filesystem to auto-detect lockfile twins
332
- * (e.g. yarn.lock vs package-lock.json). Callers should cache the
333
- * adapter for the lifetime of the operation rather than calling this
334
- * per-row.
335
- */
336
- export async function loadStackAdapter(projectRoot, options = {}) {
337
- const root = options.projectRoot ?? projectRoot;
338
- const fileExists = async (relPath) => {
339
- if (relPath.includes("*")) {
340
- // We never glob in the detection path; concrete probes only.
341
- return false;
342
- }
343
- try {
344
- await fs.access(path.join(root, relPath));
345
- return true;
346
- }
347
- catch {
348
- return false;
349
- }
350
- };
351
- const factoryInput = { fileExists };
352
- for (const factory of STACK_ADAPTER_FACTORIES) {
353
- if (await factory.detect(factoryInput)) {
354
- return factory.build(factoryInput);
355
- }
356
- }
357
- return UNKNOWN_STACK_ADAPTER;
358
- }
359
- /**
360
- * Synthesize a stack adapter from explicit lockfile-twin overrides.
361
- * Useful in tests that want to pin twins without a real filesystem
362
- * scan, and for the linter test suite.
363
- */
364
- export function buildStackAdapterForTests(partial) {
365
- return {
366
- manifestGlobs: [],
367
- lockfileTwins: [],
368
- testCommandHints: [],
369
- ...partial
370
- };
371
- }
372
- export const UNKNOWN_STACK = UNKNOWN_STACK_ADAPTER;
373
- // ---------------------------------------------------------------------------
374
- // Wiring aggregator helpers (per stack).
375
- // ---------------------------------------------------------------------------
376
- function rustWiringAggregator() {
377
- return {
378
- aggregatorPattern: "src/lib.rs | src/main.rs | mod.rs (parent module)",
379
- resolveAggregatorFor(filePath) {
380
- const normalized = normalizeRel(filePath);
381
- if (!/\.rs$/u.test(normalized))
382
- return null;
383
- // The file IS itself an aggregator: nothing to do.
384
- const basename = baseName(normalized);
385
- if (basename === "lib.rs" || basename === "main.rs" || basename === "mod.rs") {
386
- return null;
387
- }
388
- // Find the nearest `src/` ancestor and target its `lib.rs` (or main).
389
- // We default to lib.rs because most workspaces expose a library
390
- // crate; binaries can override by carrying main.rs in the claim
391
- // alongside lib.rs.
392
- const segments = normalized.split("/");
393
- const srcIdx = segments.lastIndexOf("src");
394
- if (srcIdx < 0) {
395
- // No conventional layout — fall back to parent dir mod.rs.
396
- const parent = segments.slice(0, -1).join("/");
397
- if (parent.length === 0)
398
- return null;
399
- return `${parent}/mod.rs`;
400
- }
401
- const srcRoot = segments.slice(0, srcIdx + 1).join("/");
402
- // If file lives directly under src/ (e.g. src/foo.rs), it must be
403
- // declared in src/lib.rs (or src/main.rs).
404
- if (srcIdx === segments.length - 2) {
405
- return `${srcRoot}/lib.rs`;
406
- }
407
- // Otherwise, the parent module's mod.rs is the wiring point.
408
- const parentSegments = segments.slice(0, -1);
409
- return `${parentSegments.join("/")}/mod.rs`;
410
- }
411
- };
412
- }
413
- function nodeTsWiringAggregator() {
414
- const candidateBasenames = ["index.ts", "index.tsx", "index.js", "index.jsx"];
415
- return {
416
- aggregatorPattern: "parent-dir index.{ts,tsx,js,jsx} (only when an index.* already exists in the parent dir)",
417
- resolveAggregatorFor(filePath, repoState) {
418
- const normalized = normalizeRel(filePath);
419
- if (!/\.(ts|tsx|js|jsx|mjs|cjs)$/u.test(normalized))
420
- return null;
421
- const basename = baseName(normalized);
422
- if (candidateBasenames.includes(basename))
423
- return null;
424
- const segments = normalized.split("/");
425
- if (segments.length < 2)
426
- return null;
427
- const parentDir = segments.slice(0, -1).join("/");
428
- const headFiles = repoState?.headFiles;
429
- // node-ts wiring is opt-in: if the parent dir already has an
430
- // index.* file at HEAD, the project uses barrel exports and the
431
- // new file must be added to the barrel. Without an index.* file,
432
- // we treat the project as not using barrels and emit no
433
- // requirement.
434
- if (!headFiles)
435
- return null;
436
- for (const candidate of candidateBasenames) {
437
- const indexPath = `${parentDir}/${candidate}`;
438
- if (headFiles.has(indexPath)) {
439
- return indexPath;
440
- }
441
- }
442
- return null;
443
- }
444
- };
445
- }
446
- function pythonWiringAggregator() {
447
- return {
448
- aggregatorPattern: "parent-dir __init__.py (skipped when sibling __init__.py absent — PEP 420 namespace package)",
449
- resolveAggregatorFor(filePath, repoState) {
450
- const normalized = normalizeRel(filePath);
451
- if (!/\.py$/u.test(normalized))
452
- return null;
453
- const basename = baseName(normalized);
454
- if (basename === "__init__.py")
455
- return null;
456
- const segments = normalized.split("/");
457
- if (segments.length < 2)
458
- return null;
459
- const parentDir = segments.slice(0, -1).join("/");
460
- const candidate = `${parentDir}/__init__.py`;
461
- // PEP 420 namespace packages skip __init__.py entirely. We detect
462
- // the layout by checking whether the parent dir already has an
463
- // __init__.py at HEAD; if it doesn't, treat the dir as namespace
464
- // and skip the requirement.
465
- const headFiles = repoState?.headFiles;
466
- if (!headFiles) {
467
- // No state: be conservative and emit the requirement so authors
468
- // either include the aggregator or migrate to PEP 420 with a
469
- // claimedPaths note.
470
- return candidate;
471
- }
472
- if (headFiles.has(candidate)) {
473
- return candidate;
474
- }
475
- // Sibling __init__.py absent — namespace package layout. No-op.
476
- return null;
477
- }
478
- };
479
- }
480
- // ---------------------------------------------------------------------------
481
- // Path helpers shared by aggregator resolvers.
482
- // ---------------------------------------------------------------------------
483
- function normalizeRel(value) {
484
- return value.trim().replace(/\\/gu, "/").replace(/^\.\//u, "").replace(/\/+$/u, "");
485
- }
486
- function baseName(rel) {
487
- const idx = rel.lastIndexOf("/");
488
- return idx >= 0 ? rel.slice(idx + 1) : rel;
489
- }
@@ -1,31 +0,0 @@
1
- export declare const DEFAULT_SLICE_STREAM_REL_PATH = ".cclaw/state/slice-builder-stream.jsonl";
2
- export interface SliceBuilderPhaseEvent {
3
- event: "phase-completed";
4
- runId?: string;
5
- stage?: string;
6
- sliceId: string;
7
- phase: string;
8
- spanId?: string;
9
- refactorOutcome?: {
10
- mode?: string;
11
- };
12
- }
13
- export interface EventStreamParseResult {
14
- events: SliceBuilderPhaseEvent[];
15
- droppedLines: number;
16
- }
17
- /**
18
- * Incremental JSONL parser with bounded in-memory buffer. If chunks arrive
19
- * faster than the consumer drains complete lines, we trim the oldest partial
20
- * payload once maxBufferBytes is exceeded instead of letting memory grow
21
- * unbounded.
22
- */
23
- export declare class EventStreamLineBuffer {
24
- private readonly maxBufferBytes;
25
- private buffer;
26
- constructor(maxBufferBytes?: number);
27
- push(chunk: string | Buffer): EventStreamParseResult;
28
- flush(): EventStreamParseResult;
29
- }
30
- export declare function parseEventStreamText(raw: string): EventStreamParseResult;
31
- export declare function readEventStreamFile(absPath: string): Promise<EventStreamParseResult>;
@@ -1,114 +0,0 @@
1
- import fs from "node:fs/promises";
2
- export const DEFAULT_SLICE_STREAM_REL_PATH = ".cclaw/state/slice-builder-stream.jsonl";
3
- function isRecord(value) {
4
- return typeof value === "object" && value !== null && !Array.isArray(value);
5
- }
6
- function asString(value) {
7
- return typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
8
- }
9
- function parseEventLine(rawLine) {
10
- let parsed;
11
- try {
12
- parsed = JSON.parse(rawLine);
13
- }
14
- catch {
15
- return null;
16
- }
17
- if (!isRecord(parsed))
18
- return null;
19
- if (parsed.event !== "phase-completed")
20
- return null;
21
- const sliceId = asString(parsed.sliceId);
22
- const phase = asString(parsed.phase);
23
- if (!sliceId || !phase)
24
- return null;
25
- const stage = asString(parsed.stage);
26
- const runId = asString(parsed.runId);
27
- const spanId = asString(parsed.spanId);
28
- const refactorOutcome = isRecord(parsed.refactorOutcome)
29
- ? { mode: asString(parsed.refactorOutcome.mode) }
30
- : undefined;
31
- return {
32
- event: "phase-completed",
33
- ...(runId ? { runId } : {}),
34
- ...(stage ? { stage } : {}),
35
- sliceId,
36
- phase,
37
- ...(spanId ? { spanId } : {}),
38
- ...(refactorOutcome ? { refactorOutcome } : {})
39
- };
40
- }
41
- /**
42
- * Incremental JSONL parser with bounded in-memory buffer. If chunks arrive
43
- * faster than the consumer drains complete lines, we trim the oldest partial
44
- * payload once maxBufferBytes is exceeded instead of letting memory grow
45
- * unbounded.
46
- */
47
- export class EventStreamLineBuffer {
48
- maxBufferBytes;
49
- buffer = "";
50
- constructor(maxBufferBytes = 256 * 1024) {
51
- this.maxBufferBytes = maxBufferBytes;
52
- }
53
- push(chunk) {
54
- this.buffer += typeof chunk === "string" ? chunk : chunk.toString("utf8");
55
- let droppedLines = 0;
56
- if (this.buffer.length > this.maxBufferBytes) {
57
- const overflowStart = this.buffer.length - this.maxBufferBytes;
58
- const nextBreak = this.buffer.indexOf("\n", overflowStart);
59
- if (nextBreak >= 0) {
60
- this.buffer = this.buffer.slice(nextBreak + 1);
61
- }
62
- else {
63
- this.buffer = "";
64
- }
65
- droppedLines += 1;
66
- }
67
- const events = [];
68
- let newlineIdx = this.buffer.indexOf("\n");
69
- while (newlineIdx >= 0) {
70
- const line = this.buffer.slice(0, newlineIdx).trim();
71
- this.buffer = this.buffer.slice(newlineIdx + 1);
72
- if (line.length > 0) {
73
- const parsed = parseEventLine(line);
74
- if (parsed)
75
- events.push(parsed);
76
- else
77
- droppedLines += 1;
78
- }
79
- newlineIdx = this.buffer.indexOf("\n");
80
- }
81
- return { events, droppedLines };
82
- }
83
- flush() {
84
- if (this.buffer.trim().length === 0) {
85
- this.buffer = "";
86
- return { events: [], droppedLines: 0 };
87
- }
88
- const parsed = parseEventLine(this.buffer.trim());
89
- this.buffer = "";
90
- if (parsed) {
91
- return { events: [parsed], droppedLines: 0 };
92
- }
93
- return { events: [], droppedLines: 1 };
94
- }
95
- }
96
- export function parseEventStreamText(raw) {
97
- const buffer = new EventStreamLineBuffer();
98
- const pushed = buffer.push(raw);
99
- const flushed = buffer.flush();
100
- return {
101
- events: [...pushed.events, ...flushed.events],
102
- droppedLines: pushed.droppedLines + flushed.droppedLines
103
- };
104
- }
105
- export async function readEventStreamFile(absPath) {
106
- let raw = "";
107
- try {
108
- raw = await fs.readFile(absPath, "utf8");
109
- }
110
- catch {
111
- return { events: [], droppedLines: 0 };
112
- }
113
- return parseEventStreamText(raw);
114
- }