cclaw-cli 7.5.0 → 7.7.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.
- package/README.md +2 -1
- package/dist/artifact-linter/plan.js +238 -26
- package/dist/artifact-linter/tdd.js +4 -3
- package/dist/config.d.ts +18 -1
- package/dist/config.js +176 -5
- package/dist/content/core-agents.d.ts +1 -1
- package/dist/content/core-agents.js +17 -2
- package/dist/content/hooks.js +37 -0
- package/dist/content/meta-skill.js +4 -4
- package/dist/content/skills.js +12 -8
- package/dist/content/stage-schema.js +3 -2
- package/dist/content/stages/plan.js +18 -17
- package/dist/content/stages/tdd.js +13 -10
- package/dist/content/start-command.js +3 -3
- package/dist/content/subagent-context-skills.js +2 -2
- package/dist/content/subagents.js +6 -6
- package/dist/content/templates.js +12 -7
- package/dist/delegation.d.ts +43 -3
- package/dist/delegation.js +80 -9
- package/dist/execution-topology.d.ts +36 -0
- package/dist/execution-topology.js +73 -0
- package/dist/gate-evidence.js +10 -12
- package/dist/internal/advance-stage/start-flow.js +13 -4
- package/dist/internal/cohesion-contract-stub.js +2 -14
- package/dist/internal/plan-split-waves.d.ts +5 -2
- package/dist/internal/plan-split-waves.js +27 -16
- package/dist/internal/slice-commit.js +161 -7
- package/dist/internal/wave-status.d.ts +4 -0
- package/dist/internal/wave-status.js +50 -9
- package/dist/stack-detection.d.ts +94 -0
- package/dist/stack-detection.js +431 -0
- package/dist/tdd-cycle.js +7 -5
- package/dist/types.d.ts +67 -0
- package/dist/util/slice-id.d.ts +58 -0
- package/dist/util/slice-id.js +89 -0
- package/package.json +1 -1
package/dist/stack-detection.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
1
3
|
export const STACK_REVIEW_ROUTE_PROFILES = [
|
|
2
4
|
{
|
|
3
5
|
stack: "TypeScript/JavaScript",
|
|
@@ -56,3 +58,432 @@ export const STACK_DISCOVERY_MARKERS = [
|
|
|
56
58
|
export const STACK_DISCOVERY_DIR_MARKERS = [
|
|
57
59
|
".github/workflows"
|
|
58
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
|
+
}
|
package/dist/tdd-cycle.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isSliceId } from "./util/slice-id.js";
|
|
1
2
|
export function parseTddCycleLog(text, options = {}) {
|
|
2
3
|
const issues = options.issues;
|
|
3
4
|
const strict = options.strict === true;
|
|
@@ -75,7 +76,6 @@ export function parseTddCycleLog(text, options = {}) {
|
|
|
75
76
|
}
|
|
76
77
|
return out;
|
|
77
78
|
}
|
|
78
|
-
const SLICE_ID_PATTERN = /^S-\d+$/u;
|
|
79
79
|
export function validateTddCycleOrder(entries, options = {}) {
|
|
80
80
|
const targetRun = options.runId;
|
|
81
81
|
const filtered = targetRun
|
|
@@ -89,13 +89,15 @@ export function validateTddCycleOrder(entries, options = {}) {
|
|
|
89
89
|
}
|
|
90
90
|
const issues = [];
|
|
91
91
|
const openRedSlices = [];
|
|
92
|
-
// Reject slices whose ID does not match the stable
|
|
92
|
+
// Reject slices whose ID does not match the stable slice-id contract.
|
|
93
93
|
// Entries that drop the slice field entirely were previously coerced to
|
|
94
94
|
// `S-unknown` and silently bucketed together, which means multiple distinct
|
|
95
|
-
// cycles could appear to share a RED/GREEN pair.
|
|
95
|
+
// cycles could appear to share a RED/GREEN pair. 7.6.0 relaxed the shape
|
|
96
|
+
// to allow lettered sub-slice ids (e.g. `S-36a`) so plan amendments can
|
|
97
|
+
// insert work between numeric slices without renumbering.
|
|
96
98
|
for (const slice of bySlice.keys()) {
|
|
97
|
-
if (!
|
|
98
|
-
issues.push(`slice "${slice}": id must match
|
|
99
|
+
if (!isSliceId(slice)) {
|
|
100
|
+
issues.push(`slice "${slice}": id must match S-<number>(<letter><suffix>)? (e.g. S-1, S-36a); repair by re-logging RED/GREEN/REFACTOR with a stable slice id.`);
|
|
99
101
|
}
|
|
100
102
|
}
|
|
101
103
|
for (const [slice, sliceEntries] of bySlice.entries()) {
|
package/dist/types.d.ts
CHANGED
|
@@ -163,6 +163,25 @@ export interface ReviewLoopConfig {
|
|
|
163
163
|
export type VcsMode = "git-with-remote" | "git-local-only" | "none";
|
|
164
164
|
export type TddCommitMode = "managed-per-slice" | "agent-required" | "checkpoint-only" | "off";
|
|
165
165
|
export type TddIsolationMode = "worktree" | "in-place" | "auto";
|
|
166
|
+
export type ExecutionTopology = "auto" | "inline" | "single-builder" | "parallel-builders" | "strict-micro";
|
|
167
|
+
export type ExecutionStrictnessProfile = "fast" | "balanced" | "strict";
|
|
168
|
+
export type PlanSliceGranularity = "feature-atomic" | "strict-micro";
|
|
169
|
+
export type PlanMicroTaskPolicy = "advisory" | "strict";
|
|
170
|
+
/**
|
|
171
|
+
* 7.6.0 — what slice-commit does when a manifest in the slice's
|
|
172
|
+
* claim drifts its corresponding lockfile twin (e.g. Cargo.toml +
|
|
173
|
+
* Cargo.lock; package.json + package-lock.json; pyproject.toml +
|
|
174
|
+
* poetry.lock; etc).
|
|
175
|
+
*
|
|
176
|
+
* - `auto-include` (default) — fold the lockfile drift into the slice
|
|
177
|
+
* commit so the manifest + lockfile land atomically.
|
|
178
|
+
* - `auto-revert` — revert the lockfile drift before commit so the
|
|
179
|
+
* slice ships only the manifest change; the next CI/test run will
|
|
180
|
+
* regenerate the lockfile.
|
|
181
|
+
* - `strict-fence` — reject the lockfile drift as
|
|
182
|
+
* `slice_commit_path_drift` (pre-7.6.0 behavior).
|
|
183
|
+
*/
|
|
184
|
+
export type LockfileTwinPolicy = "auto-include" | "auto-revert" | "strict-fence";
|
|
166
185
|
export interface TddConfig {
|
|
167
186
|
/**
|
|
168
187
|
* Commit ownership model for closed TDD slices.
|
|
@@ -183,12 +202,60 @@ export interface TddConfig {
|
|
|
183
202
|
* Repo-relative root used for managed slice worktrees.
|
|
184
203
|
*/
|
|
185
204
|
worktreeRoot?: string;
|
|
205
|
+
/**
|
|
206
|
+
* 7.6.0 — slice-commit policy when a manifest claim drifts its lockfile
|
|
207
|
+
* twin (Cargo.toml/Cargo.lock, package.json/package-lock.json, etc).
|
|
208
|
+
* Defaults to `auto-include` so the manifest + regenerated lockfile
|
|
209
|
+
* land in the same managed commit instead of failing on drift.
|
|
210
|
+
*/
|
|
211
|
+
lockfileTwinPolicy?: LockfileTwinPolicy;
|
|
212
|
+
}
|
|
213
|
+
export interface ExecutionConfig {
|
|
214
|
+
/**
|
|
215
|
+
* 7.7.0 — adaptive execution topology for implementation units.
|
|
216
|
+
*
|
|
217
|
+
* - `auto` (default): choose the cheapest safe route from plan shape.
|
|
218
|
+
* - `inline`: controller may execute a low-risk unit inline while still
|
|
219
|
+
* recording RED/GREEN/REFACTOR evidence.
|
|
220
|
+
* - `single-builder`: one slice-builder owns a feature-atomic unit.
|
|
221
|
+
* - `parallel-builders`: fan out independent substantial units only.
|
|
222
|
+
* - `strict-micro`: preserve the pre-7.7 posture where each tiny task is
|
|
223
|
+
* its own schedulable slice.
|
|
224
|
+
*/
|
|
225
|
+
topology?: ExecutionTopology;
|
|
226
|
+
/**
|
|
227
|
+
* 7.7.0 — default calibration for topology and plan-shape advisories.
|
|
228
|
+
* `balanced` is the default: prefer feature-atomic units with internal
|
|
229
|
+
* 2-5 minute TDD steps, warning on microtask-only plans without blocking.
|
|
230
|
+
*/
|
|
231
|
+
strictness?: ExecutionStrictnessProfile;
|
|
232
|
+
/**
|
|
233
|
+
* 7.7.0 — upper bound for simultaneous slice-builder workers when the
|
|
234
|
+
* router selects `parallel-builders`.
|
|
235
|
+
*/
|
|
236
|
+
maxBuilders?: number;
|
|
237
|
+
}
|
|
238
|
+
export interface PlanConfig {
|
|
239
|
+
/**
|
|
240
|
+
* 7.7.0 — default schedulable surface for plan authoring.
|
|
241
|
+
* - feature-atomic: U-* slices contain internal 2-5 minute TDD steps.
|
|
242
|
+
* - strict-micro: one tiny task can remain one schedulable slice.
|
|
243
|
+
*/
|
|
244
|
+
sliceGranularity?: PlanSliceGranularity;
|
|
245
|
+
/**
|
|
246
|
+
* 7.7.0 — how strongly the plan linter reacts to microtask-only plans.
|
|
247
|
+
* `advisory` warns in fast/balanced execution; `strict` treats strict
|
|
248
|
+
* microtask planning as intentional.
|
|
249
|
+
*/
|
|
250
|
+
microTaskPolicy?: PlanMicroTaskPolicy;
|
|
186
251
|
}
|
|
187
252
|
export interface CclawConfig {
|
|
188
253
|
version: string;
|
|
189
254
|
flowVersion: string;
|
|
190
255
|
harnesses: HarnessId[];
|
|
191
256
|
tdd?: TddConfig;
|
|
257
|
+
execution?: ExecutionConfig;
|
|
258
|
+
plan?: PlanConfig;
|
|
192
259
|
}
|
|
193
260
|
export interface TransitionRule {
|
|
194
261
|
from: FlowStage;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slice-ID helpers.
|
|
3
|
+
*
|
|
4
|
+
* 7.6.0 — relaxed strict `/^S-\d+$/` to allow lettered sub-slices
|
|
5
|
+
* (`S-36a`, `S-36b`, …) so plan amendments can insert work between
|
|
6
|
+
* existing numeric slices without renumbering.
|
|
7
|
+
*
|
|
8
|
+
* Canonical shape: `S-<integer>(<lowercase-letter>[<lowercase-or-digit>...])?`
|
|
9
|
+
*
|
|
10
|
+
* Sort order (used everywhere we list slice ids):
|
|
11
|
+
* 1. numeric chunk ascending
|
|
12
|
+
* 2. lexical suffix ascending (no suffix sorts before any suffix)
|
|
13
|
+
*
|
|
14
|
+
* So: `S-1 < S-2 < S-10 < S-36 < S-36a < S-36b < S-37`.
|
|
15
|
+
*
|
|
16
|
+
* Surface:
|
|
17
|
+
* - `SLICE_ID_PATTERN` — anchored regex source string for embedding
|
|
18
|
+
* - `SLICE_ID_REGEX` — anchored RegExp for tests
|
|
19
|
+
* - `parseSliceId` — strict parse → `{ numeric, suffix }` or null
|
|
20
|
+
* - `isSliceId` — boolean shape check
|
|
21
|
+
* - `compareSliceIds` — sort comparator
|
|
22
|
+
* - `sortSliceIds` — convenience wrapper around `compareSliceIds`
|
|
23
|
+
*/
|
|
24
|
+
/** Anchored, case-insensitive regex source for slice ids. */
|
|
25
|
+
export declare const SLICE_ID_PATTERN = "^S-(\\d+)([a-z][a-z0-9]*)?$";
|
|
26
|
+
/** Anchored, case-insensitive RegExp instance for slice ids. */
|
|
27
|
+
export declare const SLICE_ID_REGEX: RegExp;
|
|
28
|
+
export interface ParsedSliceId {
|
|
29
|
+
/** Canonical normalized form, e.g. `S-36a`. */
|
|
30
|
+
id: string;
|
|
31
|
+
/** Numeric chunk as a number (e.g. `S-36a` → `36`). */
|
|
32
|
+
numeric: number;
|
|
33
|
+
/** Lowercase suffix (e.g. `S-36a` → `"a"`). Empty string when absent. */
|
|
34
|
+
suffix: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Strict parse of a slice id token.
|
|
38
|
+
*
|
|
39
|
+
* Returns `null` when the input is not a slice id. Whitespace and
|
|
40
|
+
* surrounding markdown decorations (backticks, brackets, quotes) are
|
|
41
|
+
* stripped before parsing so callers can pass cells from markdown
|
|
42
|
+
* tables verbatim.
|
|
43
|
+
*/
|
|
44
|
+
export declare function parseSliceId(raw: unknown): ParsedSliceId | null;
|
|
45
|
+
/**
|
|
46
|
+
* Boolean shape check. Lowercase-or-uppercase `S-` prefix accepted; the
|
|
47
|
+
* canonical form is uppercase.
|
|
48
|
+
*/
|
|
49
|
+
export declare function isSliceId(raw: unknown): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Comparator that orders slice ids by numeric chunk first, then by
|
|
52
|
+
* suffix (no-suffix sorts before any suffix). Non-slice tokens fall
|
|
53
|
+
* back to a stable lexical comparison so callers can pass mixed input
|
|
54
|
+
* without crashing.
|
|
55
|
+
*/
|
|
56
|
+
export declare function compareSliceIds(a: string, b: string): number;
|
|
57
|
+
/** Convenience wrapper: returns a new sorted array using `compareSliceIds`. */
|
|
58
|
+
export declare function sortSliceIds(ids: readonly string[]): string[];
|