@popoverai/dotrequirements 0.26.0 → 0.26.2
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/dist/codebase-to-spec/area-name.d.ts +13 -0
- package/dist/codebase-to-spec/area-name.js +18 -0
- package/dist/codebase-to-spec/cache.d.ts +31 -0
- package/dist/codebase-to-spec/cache.js +29 -1
- package/dist/codebase-to-spec/compose.d.ts +7 -4
- package/dist/codebase-to-spec/compose.js +10 -21
- package/dist/codebase-to-spec/dispatch.js +1 -1
- package/dist/codebase-to-spec/present.js +11 -7
- package/dist/codebase-to-spec/prompts/planner-initial.d.ts +3 -2
- package/dist/codebase-to-spec/prompts/planner-initial.js +3 -2
- package/dist/codebase-to-spec/renumber.d.ts +52 -0
- package/dist/codebase-to-spec/renumber.js +105 -0
- package/dist/codebase-to-spec/schemas.d.ts +35 -240
- package/dist/codebase-to-spec/schemas.js +5 -173
- package/dist/codebase-to-spec/validate.js +3 -2
- package/dist/commands/acceptance-test.js +4 -2
- package/dist/commands/ai-setup.js +97 -59
- package/dist/commands/codebase-to-spec/dispatch-editor.js +1 -1
- package/dist/commands/codebase-to-spec/dispatch-spec.js +1 -1
- package/dist/commands/codebase-to-spec/index.js +7 -103
- package/dist/commands/codebase-to-spec/pack.js +8 -1
- package/dist/commands/codebase-to-spec/present-orchestrator.d.ts +3 -1
- package/dist/commands/codebase-to-spec/present-orchestrator.js +11 -4
- package/dist/commands/get.js +6 -2
- package/dist/commands/init.js +7 -5
- package/dist/commands/link-resolution.d.ts +3 -1
- package/dist/commands/link-resolution.js +4 -2
- package/dist/commands/pull.js +36 -3
- package/dist/commands/push.js +54 -16
- package/dist/commands/report.js +18 -3
- package/dist/commands/review-test.js +16 -8
- package/dist/commands/tests-for.js +13 -13
- package/dist/commands/validate.js +14 -14
- package/dist/harness/cache.d.ts +19 -3
- package/dist/harness/cache.js +38 -12
- package/dist/harness/finalize.js +33 -1
- package/dist/harness/index.js +16 -9
- package/dist/harness/requirementsLoader.js +12 -0
- package/dist/harness/tracking.d.ts +17 -2
- package/dist/harness/tracking.js +83 -9
- package/dist/mcp/handlers/authoring.js +13 -4
- package/dist/mcp/handlers/get.js +7 -3
- package/dist/mcp/handlers/push.js +59 -13
- package/dist/mcp/handlers/review.d.ts +1 -0
- package/dist/mcp/handlers/review.js +58 -15
- package/dist/mcp/handlers/test-mapping.js +47 -12
- package/dist/mcp/handlers/types.d.ts +14 -0
- package/dist/mcp/handlers/types.js +27 -0
- package/dist/mcp/index.js +4 -0
- package/dist/push/core.d.ts +50 -0
- package/dist/push/core.js +149 -11
- package/dist/push/index.d.ts +1 -1
- package/dist/push/index.js +1 -1
- package/dist/requirements/cloud-coverage.d.ts +12 -2
- package/dist/requirements/cloud-coverage.js +30 -3
- package/dist/requirements/grep.d.ts +7 -2
- package/dist/requirements/grep.js +75 -47
- package/dist/schema/builder.d.ts +1 -1
- package/dist/schema/builder.js +13 -0
- package/dist/schema/conversions.d.ts +7 -2
- package/dist/schema/conversions.js +13 -4
- package/dist/schema/parser-core.d.ts +28 -0
- package/dist/schema/parser-core.js +80 -9
- package/dist/schema/parser.d.ts +8 -26
- package/dist/schema/parser.js +23 -251
- package/dist/schema/resolver.js +18 -8
- package/dist/templates/skills/codebase-to-spec/SKILL.md +10 -4
- package/dist/utils/env.js +17 -1
- package/dist/utils/oauth-flow.js +8 -0
- package/dist/utils/project-settings.d.ts +4 -0
- package/dist/utils/project-settings.js +14 -1
- package/package.json +1 -1
- package/dist/codebase-to-spec/edit-loop.d.ts +0 -54
- package/dist/codebase-to-spec/edit-loop.js +0 -195
- package/dist/codebase-to-spec/editor.d.ts +0 -54
- package/dist/codebase-to-spec/editor.js +0 -74
- package/dist/codebase-to-spec/fan-out.d.ts +0 -63
- package/dist/codebase-to-spec/fan-out.js +0 -215
- package/dist/codebase-to-spec/outline-review-loop.d.ts +0 -51
- package/dist/codebase-to-spec/outline-review-loop.js +0 -187
- package/dist/codebase-to-spec/planner.d.ts +0 -41
- package/dist/codebase-to-spec/planner.js +0 -76
- package/dist/codebase-to-spec/prompts/outline-reviewer.d.ts +0 -12
- package/dist/codebase-to-spec/prompts/outline-reviewer.js +0 -89
- package/dist/codebase-to-spec/slice.d.ts +0 -49
- package/dist/codebase-to-spec/slice.js +0 -111
- package/dist/codebase-to-spec/specifier.d.ts +0 -60
- package/dist/codebase-to-spec/specifier.js +0 -85
- package/dist/codebase-to-spec/summary.d.ts +0 -51
- package/dist/codebase-to-spec/summary.js +0 -183
- package/dist/commands/codebase-to-spec/compose.d.ts +0 -14
- package/dist/commands/codebase-to-spec/compose.js +0 -57
- package/dist/commands/codebase-to-spec/edit-loop.d.ts +0 -16
- package/dist/commands/codebase-to-spec/edit-loop.js +0 -83
- package/dist/commands/codebase-to-spec/fan-out.d.ts +0 -19
- package/dist/commands/codebase-to-spec/fan-out.js +0 -77
- package/dist/commands/codebase-to-spec/plan-loop.d.ts +0 -26
- package/dist/commands/codebase-to-spec/plan-loop.js +0 -105
- package/dist/commands/codebase-to-spec/present.d.ts +0 -26
- package/dist/commands/codebase-to-spec/present.js +0 -97
- package/dist/commands/codebase-to-spec/run.d.ts +0 -20
- package/dist/commands/codebase-to-spec/run.js +0 -86
- package/dist/commands/codebase-to-spec/specify-area.d.ts +0 -18
- package/dist/commands/codebase-to-spec/specify-area.js +0 -82
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `dotrequirements codebase-to-spec compose` subcommand.
|
|
3
|
-
*
|
|
4
|
-
* Assembles per-area partials into a single composed Markdown document.
|
|
5
|
-
*
|
|
6
|
-
* Requirements covered:
|
|
7
|
-
* - CTS-CLI-2: granular `compose` subcommand
|
|
8
|
-
* - CTS-COMPOSE-1, CTS-COMPOSE-2
|
|
9
|
-
*/
|
|
10
|
-
import { existsSync } from "node:fs";
|
|
11
|
-
import { cachePaths } from "../../codebase-to-spec/cache.js";
|
|
12
|
-
import { runCompose } from "../../codebase-to-spec/compose.js";
|
|
13
|
-
import { ExitCode } from "../../codebase-to-spec/exit-codes.js";
|
|
14
|
-
import { StdoutProgress } from "../../codebase-to-spec/progress.js";
|
|
15
|
-
import { findProjectRoot } from "../../utils/project-settings.js";
|
|
16
|
-
import { readFinalOutline } from "./plan-loop.js";
|
|
17
|
-
export async function composeCommand(options = {}) {
|
|
18
|
-
const progress = new StdoutProgress();
|
|
19
|
-
const projectRoot = options.projectRoot ?? findProjectRoot(process.cwd()) ?? process.cwd();
|
|
20
|
-
const paths = cachePaths(projectRoot);
|
|
21
|
-
if (!existsSync(paths.outlineFinal)) {
|
|
22
|
-
process.stderr.write(`Missing outline at ${paths.outlineFinal}. Run \`dotrequirements cts plan-loop\` first.\n`);
|
|
23
|
-
process.exitCode = ExitCode.MissingInput;
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
const outline = readFinalOutline(projectRoot);
|
|
27
|
-
progress.emit({
|
|
28
|
-
stage: "compose",
|
|
29
|
-
step: "start",
|
|
30
|
-
message: `Composing spec from ${outline.areas.length} area partials`,
|
|
31
|
-
});
|
|
32
|
-
const result = runCompose({
|
|
33
|
-
outline,
|
|
34
|
-
partialPathFor: (sanitized) => paths.partial(sanitized),
|
|
35
|
-
composedPath: paths.composedSpec,
|
|
36
|
-
});
|
|
37
|
-
progress.emit({
|
|
38
|
-
stage: "compose",
|
|
39
|
-
step: "done",
|
|
40
|
-
message: `Composed spec → ${result.composedPath} (${result.partialsIncluded} partials included, ${result.partialsMissing} missing)`,
|
|
41
|
-
data: {
|
|
42
|
-
partialsIncluded: result.partialsIncluded,
|
|
43
|
-
partialsMissing: result.partialsMissing,
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
if (result.validationError) {
|
|
47
|
-
process.stderr.write(`Composed spec failed validation:\n${result.validationError}\n`);
|
|
48
|
-
process.exitCode = ExitCode.StageFailed;
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
progress.emit({
|
|
52
|
-
stage: "compose",
|
|
53
|
-
step: "validation-ok",
|
|
54
|
-
message: "Composed spec passed schema validation",
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=compose.js.map
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `dotrequirements codebase-to-spec edit-loop` subcommand.
|
|
3
|
-
*
|
|
4
|
-
* Runs the spec review + editor loop over the composed spec.
|
|
5
|
-
*
|
|
6
|
-
* Requirements covered:
|
|
7
|
-
* - CTS-CLI-2: granular `edit-loop` subcommand
|
|
8
|
-
* - CTS-EDIT-1..6: end-to-end loop behavior
|
|
9
|
-
*/
|
|
10
|
-
export interface EditLoopCmdOptions {
|
|
11
|
-
maxTurns?: number;
|
|
12
|
-
model?: string;
|
|
13
|
-
projectRoot?: string;
|
|
14
|
-
}
|
|
15
|
-
export declare function editLoopCommand(rawOptions?: EditLoopCmdOptions): Promise<void>;
|
|
16
|
-
//# sourceMappingURL=edit-loop.d.ts.map
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `dotrequirements codebase-to-spec edit-loop` subcommand.
|
|
3
|
-
*
|
|
4
|
-
* Runs the spec review + editor loop over the composed spec.
|
|
5
|
-
*
|
|
6
|
-
* Requirements covered:
|
|
7
|
-
* - CTS-CLI-2: granular `edit-loop` subcommand
|
|
8
|
-
* - CTS-EDIT-1..6: end-to-end loop behavior
|
|
9
|
-
*/
|
|
10
|
-
import { copyFileSync, existsSync, writeFileSync } from "node:fs";
|
|
11
|
-
import { cachePaths } from "../../codebase-to-spec/cache.js";
|
|
12
|
-
import { DEFAULT_EDIT_LOOP_MAX_TURNS, runEditLoop, } from "../../codebase-to-spec/edit-loop.js";
|
|
13
|
-
import { ExitCode } from "../../codebase-to-spec/exit-codes.js";
|
|
14
|
-
import { StdoutProgress } from "../../codebase-to-spec/progress.js";
|
|
15
|
-
import { findProjectRoot } from "../../utils/project-settings.js";
|
|
16
|
-
export async function editLoopCommand(rawOptions = {}) {
|
|
17
|
-
const progress = new StdoutProgress();
|
|
18
|
-
const projectRoot = rawOptions.projectRoot ?? findProjectRoot(process.cwd()) ?? process.cwd();
|
|
19
|
-
const paths = cachePaths(projectRoot);
|
|
20
|
-
const maxTurns = rawOptions.maxTurns ?? DEFAULT_EDIT_LOOP_MAX_TURNS;
|
|
21
|
-
if (!existsSync(paths.composedSpec)) {
|
|
22
|
-
process.stderr.write(`Missing composed spec at ${paths.composedSpec}. Run \`dotrequirements cts compose\` first.\n`);
|
|
23
|
-
process.exitCode = ExitCode.MissingInput;
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
if (!existsSync(paths.source)) {
|
|
27
|
-
process.stderr.write(`Missing uncompressed pack at ${paths.source}. Run \`dotrequirements cts pack\` first.\n`);
|
|
28
|
-
process.exitCode = ExitCode.MissingInput;
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
progress.emit({
|
|
32
|
-
stage: "spec-review",
|
|
33
|
-
step: "start",
|
|
34
|
-
message: `Starting spec review + edit loop (max-turns=${maxTurns})`,
|
|
35
|
-
});
|
|
36
|
-
let result;
|
|
37
|
-
try {
|
|
38
|
-
result = await runEditLoop({
|
|
39
|
-
composedSpecPath: paths.composedSpec,
|
|
40
|
-
specVersionFor: (turn) => paths.specVersion(turn),
|
|
41
|
-
fullPackPath: paths.source,
|
|
42
|
-
addDirs: [paths.root],
|
|
43
|
-
maxTurns,
|
|
44
|
-
model: rawOptions.model,
|
|
45
|
-
progress,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
catch (err) {
|
|
49
|
-
process.stderr.write(`\nEdit loop failed: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
50
|
-
process.exitCode = ExitCode.StageFailed;
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
// Persist per-turn reviewer output (JSON).
|
|
54
|
-
result.reviewsByTurn.forEach((review, idx) => {
|
|
55
|
-
writeFileSync(paths.specReviewTurn(idx + 1), `${JSON.stringify(review, null, 2)}\n`, "utf-8");
|
|
56
|
-
});
|
|
57
|
-
if (result.hitMaxTurns) {
|
|
58
|
-
progress.emit({
|
|
59
|
-
stage: "spec-review",
|
|
60
|
-
step: "max-turns-hit",
|
|
61
|
-
message: `Loop hit max-turns (${maxTurns}) without converging. Using latest spec anyway.`,
|
|
62
|
-
data: { turnsUsed: result.turnsUsed, finalVerdict: result.finalVerdict },
|
|
63
|
-
});
|
|
64
|
-
process.exitCode = ExitCode.MaxTurnsHit;
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
progress.emit({
|
|
68
|
-
stage: "spec-review",
|
|
69
|
-
step: "done",
|
|
70
|
-
message: `Edit loop converged at turn ${result.turnsUsed} with verdict: ${result.finalVerdict}`,
|
|
71
|
-
data: { turnsUsed: result.turnsUsed, finalVerdict: result.finalVerdict },
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
// Copy the final post-edit spec to a stable path so downstream stages
|
|
75
|
-
// (present) and external tooling have a predictable location.
|
|
76
|
-
copyFileSync(result.finalSpecPath, paths.specFinal);
|
|
77
|
-
progress.emit({
|
|
78
|
-
stage: "spec-review",
|
|
79
|
-
step: "final-spec",
|
|
80
|
-
message: `Final spec → ${paths.specFinal}`,
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
//# sourceMappingURL=edit-loop.js.map
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `dotrequirements codebase-to-spec fan-out` subcommand.
|
|
3
|
-
*
|
|
4
|
-
* Runs the specifier for every area in the cached outline, in parallel up to
|
|
5
|
-
* a bounded concurrency limit, with retry-once on failure.
|
|
6
|
-
*
|
|
7
|
-
* Requirements covered:
|
|
8
|
-
* - CTS-CLI-2: granular `fan-out` subcommand
|
|
9
|
-
* - CTS-SPEC-1.2: bounded concurrent execution
|
|
10
|
-
* - CTS-SPEC-5: failure detection + retry + non-blocking continuation
|
|
11
|
-
*/
|
|
12
|
-
export interface FanOutCmdOptions {
|
|
13
|
-
concurrency?: number;
|
|
14
|
-
model?: string;
|
|
15
|
-
cliBinary?: string;
|
|
16
|
-
projectRoot?: string;
|
|
17
|
-
}
|
|
18
|
-
export declare function fanOutCommand(options?: FanOutCmdOptions): Promise<void>;
|
|
19
|
-
//# sourceMappingURL=fan-out.d.ts.map
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `dotrequirements codebase-to-spec fan-out` subcommand.
|
|
3
|
-
*
|
|
4
|
-
* Runs the specifier for every area in the cached outline, in parallel up to
|
|
5
|
-
* a bounded concurrency limit, with retry-once on failure.
|
|
6
|
-
*
|
|
7
|
-
* Requirements covered:
|
|
8
|
-
* - CTS-CLI-2: granular `fan-out` subcommand
|
|
9
|
-
* - CTS-SPEC-1.2: bounded concurrent execution
|
|
10
|
-
* - CTS-SPEC-5: failure detection + retry + non-blocking continuation
|
|
11
|
-
*/
|
|
12
|
-
import { existsSync } from "node:fs";
|
|
13
|
-
import { cachePaths } from "../../codebase-to-spec/cache.js";
|
|
14
|
-
import { ExitCode } from "../../codebase-to-spec/exit-codes.js";
|
|
15
|
-
import { DEFAULT_FAN_OUT_CONCURRENCY, runFanOut, } from "../../codebase-to-spec/fan-out.js";
|
|
16
|
-
import { StdoutProgress } from "../../codebase-to-spec/progress.js";
|
|
17
|
-
import { findProjectRoot } from "../../utils/project-settings.js";
|
|
18
|
-
import { readFinalOutline } from "./plan-loop.js";
|
|
19
|
-
export async function fanOutCommand(options = {}) {
|
|
20
|
-
const progress = new StdoutProgress();
|
|
21
|
-
const projectRoot = options.projectRoot ?? findProjectRoot(process.cwd()) ?? process.cwd();
|
|
22
|
-
const paths = cachePaths(projectRoot);
|
|
23
|
-
const cliBinary = options.cliBinary ?? "dotrequirements";
|
|
24
|
-
if (!existsSync(paths.outlineFinal)) {
|
|
25
|
-
process.stderr.write(`Missing outline at ${paths.outlineFinal}. Run \`dotrequirements cts plan-loop\` first.\n`);
|
|
26
|
-
process.exitCode = ExitCode.MissingInput;
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
if (!existsSync(paths.source)) {
|
|
30
|
-
process.stderr.write(`Missing uncompressed pack at ${paths.source}. Run \`dotrequirements cts pack\` first.\n`);
|
|
31
|
-
process.exitCode = ExitCode.MissingInput;
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
const outline = readFinalOutline(projectRoot);
|
|
35
|
-
const concurrency = options.concurrency ?? DEFAULT_FAN_OUT_CONCURRENCY;
|
|
36
|
-
progress.emit({
|
|
37
|
-
stage: "specify",
|
|
38
|
-
step: "start",
|
|
39
|
-
message: `Fan-out: ${outline.areas.length} areas (concurrency=${concurrency})`,
|
|
40
|
-
});
|
|
41
|
-
const result = await runFanOut({
|
|
42
|
-
outline,
|
|
43
|
-
fullPackPath: paths.source,
|
|
44
|
-
partialPathFor: (sanitized) => paths.partial(sanitized),
|
|
45
|
-
slicePathFor: (sanitized) => `${paths.partialsDir}/slice-${sanitized}.txt`,
|
|
46
|
-
validateCommand: `${cliBinary} cts validate`,
|
|
47
|
-
styleCheckCommand: `${cliBinary} cts style-check`,
|
|
48
|
-
addDirs: [paths.root],
|
|
49
|
-
concurrency,
|
|
50
|
-
model: options.model,
|
|
51
|
-
progress,
|
|
52
|
-
});
|
|
53
|
-
// Summary
|
|
54
|
-
const failed = result.outcomes.filter((o) => o.status === "failed");
|
|
55
|
-
const completed = result.outcomes.filter((o) => o.status === "completed");
|
|
56
|
-
const skipped = result.outcomes.filter((o) => o.status === "skipped-resume");
|
|
57
|
-
progress.emit({
|
|
58
|
-
stage: "specify",
|
|
59
|
-
step: "summary",
|
|
60
|
-
message: `Completed: ${completed.length} / Skipped (resume): ${skipped.length} / Failed: ${failed.length}`,
|
|
61
|
-
data: {
|
|
62
|
-
completed: completed.length,
|
|
63
|
-
skipped: skipped.length,
|
|
64
|
-
failed: failed.length,
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
if (failed.length > 0) {
|
|
68
|
-
for (const o of failed) {
|
|
69
|
-
process.stderr.write(` failed: ${o.area.name} (${o.area.prefix}) — ${o.failureCause ?? "unknown"}\n`);
|
|
70
|
-
}
|
|
71
|
-
// Per CTS-SPEC-5, a failed specifier does not block the rest of the
|
|
72
|
-
// pipeline; we still let the caller decide. Surface non-zero so wrappers
|
|
73
|
-
// can react if they care.
|
|
74
|
-
process.exitCode = ExitCode.StageFailed;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
//# sourceMappingURL=fan-out.js.map
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `dotrequirements codebase-to-spec plan-loop` subcommand.
|
|
3
|
-
*
|
|
4
|
-
* Reads the compressed pack from the cache and runs the outline review loop
|
|
5
|
-
* (planner → reviewer → revise → ... → approved). Writes per-turn artifacts
|
|
6
|
-
* and the final outline.
|
|
7
|
-
*
|
|
8
|
-
* Requirements covered:
|
|
9
|
-
* - CTS-CLI-2: `dotrequirements cts plan-loop` runs only the outline review loop and exits
|
|
10
|
-
* - CTS-PLAN-1..6: end-to-end loop behavior
|
|
11
|
-
* - CTS-RESUME-1.1: skip loop if outline-final.json exists
|
|
12
|
-
* - CTS-OBSERVE-1, CTS-OBSERVE-2: progress + failure observability
|
|
13
|
-
*/
|
|
14
|
-
import type { Outline } from "../../codebase-to-spec/schemas.js";
|
|
15
|
-
export interface PlanLoopOptions {
|
|
16
|
-
maxTurns?: number;
|
|
17
|
-
model?: string;
|
|
18
|
-
progress?: import("../../codebase-to-spec/progress.js").ProgressEmitter;
|
|
19
|
-
projectRoot?: string;
|
|
20
|
-
}
|
|
21
|
-
export declare function planLoopCommand(rawOptions?: PlanLoopOptions): Promise<void>;
|
|
22
|
-
/**
|
|
23
|
-
* Helper used by `cts run` and tests to consume the outline that plan-loop wrote.
|
|
24
|
-
*/
|
|
25
|
-
export declare function readFinalOutline(projectRoot: string): Outline;
|
|
26
|
-
//# sourceMappingURL=plan-loop.d.ts.map
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `dotrequirements codebase-to-spec plan-loop` subcommand.
|
|
3
|
-
*
|
|
4
|
-
* Reads the compressed pack from the cache and runs the outline review loop
|
|
5
|
-
* (planner → reviewer → revise → ... → approved). Writes per-turn artifacts
|
|
6
|
-
* and the final outline.
|
|
7
|
-
*
|
|
8
|
-
* Requirements covered:
|
|
9
|
-
* - CTS-CLI-2: `dotrequirements cts plan-loop` runs only the outline review loop and exits
|
|
10
|
-
* - CTS-PLAN-1..6: end-to-end loop behavior
|
|
11
|
-
* - CTS-RESUME-1.1: skip loop if outline-final.json exists
|
|
12
|
-
* - CTS-OBSERVE-1, CTS-OBSERVE-2: progress + failure observability
|
|
13
|
-
*/
|
|
14
|
-
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
15
|
-
import { cachePaths } from "../../codebase-to-spec/cache.js";
|
|
16
|
-
import { ExitCode } from "../../codebase-to-spec/exit-codes.js";
|
|
17
|
-
import { DEFAULT_OUTLINE_LOOP_MAX_TURNS, runOutlineReviewLoop, } from "../../codebase-to-spec/outline-review-loop.js";
|
|
18
|
-
import { StdoutProgress } from "../../codebase-to-spec/progress.js";
|
|
19
|
-
import { findProjectRoot } from "../../utils/project-settings.js";
|
|
20
|
-
export async function planLoopCommand(rawOptions = {}) {
|
|
21
|
-
const progress = rawOptions.progress ?? new StdoutProgress();
|
|
22
|
-
const projectRoot = rawOptions.projectRoot ?? findProjectRoot(process.cwd()) ?? process.cwd();
|
|
23
|
-
const paths = cachePaths(projectRoot);
|
|
24
|
-
const maxTurns = rawOptions.maxTurns ?? DEFAULT_OUTLINE_LOOP_MAX_TURNS;
|
|
25
|
-
// Resume — if outline-final.json already exists, skip the loop entirely.
|
|
26
|
-
if (existsSync(paths.outlineFinal)) {
|
|
27
|
-
progress.emit({
|
|
28
|
-
stage: "plan",
|
|
29
|
-
step: "resume-skip",
|
|
30
|
-
message: `outline-final.json exists at ${paths.outlineFinal}; skipping plan loop`,
|
|
31
|
-
});
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
// Require the compressed pack from the prior stage.
|
|
35
|
-
if (!existsSync(paths.overview)) {
|
|
36
|
-
process.stderr.write(`Missing compressed pack at ${paths.overview}. Run \`dotrequirements cts pack\` first.\n`);
|
|
37
|
-
process.exitCode = ExitCode.MissingInput;
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
progress.emit({
|
|
41
|
-
stage: "plan",
|
|
42
|
-
step: "start",
|
|
43
|
-
message: `Starting plan + outline review loop (max-turns=${maxTurns})`,
|
|
44
|
-
});
|
|
45
|
-
let result;
|
|
46
|
-
try {
|
|
47
|
-
result = await runOutlineReviewLoop({
|
|
48
|
-
overviewPath: paths.overview,
|
|
49
|
-
addDirs: [paths.root],
|
|
50
|
-
maxTurns,
|
|
51
|
-
model: rawOptions.model,
|
|
52
|
-
progress,
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
catch (err) {
|
|
56
|
-
process.stderr.write(`\nPlan loop failed: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
57
|
-
process.exitCode = ExitCode.StageFailed;
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
// Persist per-turn artifacts (one outline per turn, one review per turn) so
|
|
61
|
-
// we have full evidence and resumability.
|
|
62
|
-
result.outlinesByTurn.forEach((outline, idx) => {
|
|
63
|
-
const path = paths.outlineTurn(idx + 1);
|
|
64
|
-
writeFileSync(path, `${JSON.stringify(outline, null, 2)}\n`, "utf-8");
|
|
65
|
-
});
|
|
66
|
-
result.reviewsByTurn.forEach((review, idx) => {
|
|
67
|
-
const path = paths.outlineReviewTurn(idx + 1);
|
|
68
|
-
writeFileSync(path, `${JSON.stringify(review, null, 2)}\n`, "utf-8");
|
|
69
|
-
});
|
|
70
|
-
// Write the final outline.
|
|
71
|
-
writeFileSync(paths.outlineFinal, `${JSON.stringify(result.outline, null, 2)}\n`, "utf-8");
|
|
72
|
-
if (result.hitMaxTurns) {
|
|
73
|
-
progress.emit({
|
|
74
|
-
stage: "plan",
|
|
75
|
-
step: "max-turns-hit",
|
|
76
|
-
message: `Loop hit max-turns (${maxTurns}) without converging. Using latest outline anyway.`,
|
|
77
|
-
data: { turnsUsed: result.turnsUsed, finalVerdict: result.finalVerdict },
|
|
78
|
-
});
|
|
79
|
-
process.exitCode = ExitCode.MaxTurnsHit;
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
progress.emit({
|
|
83
|
-
stage: "plan",
|
|
84
|
-
step: "done",
|
|
85
|
-
message: `Plan loop converged at turn ${result.turnsUsed} with verdict: ${result.finalVerdict}`,
|
|
86
|
-
data: { turnsUsed: result.turnsUsed, finalVerdict: result.finalVerdict },
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
progress.emit({
|
|
90
|
-
stage: "plan",
|
|
91
|
-
step: "outline-written",
|
|
92
|
-
message: `Final outline → ${paths.outlineFinal} (${result.outline.areas.length} areas)`,
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Helper used by `cts run` and tests to consume the outline that plan-loop wrote.
|
|
97
|
-
*/
|
|
98
|
-
export function readFinalOutline(projectRoot) {
|
|
99
|
-
const paths = cachePaths(projectRoot);
|
|
100
|
-
if (!existsSync(paths.outlineFinal)) {
|
|
101
|
-
throw new Error(`Missing ${paths.outlineFinal}. Run \`cts plan-loop\` first.`);
|
|
102
|
-
}
|
|
103
|
-
return JSON.parse(readFileSync(paths.outlineFinal, "utf-8"));
|
|
104
|
-
}
|
|
105
|
-
//# sourceMappingURL=plan-loop.js.map
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `dotrequirements codebase-to-spec present` subcommand.
|
|
3
|
-
*
|
|
4
|
-
* Writes the final spec to `.requirements/` and emits a pipeline summary.
|
|
5
|
-
*
|
|
6
|
-
* Requirements covered:
|
|
7
|
-
* - CTS-CLI-2: granular `present` subcommand
|
|
8
|
-
* - CTS-CLI-4: TTY-driven interactive/non-interactive selection
|
|
9
|
-
* - CTS-PRESENT-1..4
|
|
10
|
-
*/
|
|
11
|
-
export interface PresentCmdOptions {
|
|
12
|
-
/** Force --interactive or --non-interactive (overrides TTY detection). */
|
|
13
|
-
forceMode?: "interactive" | "non-interactive";
|
|
14
|
-
/** Replace existing .requirements/ files without prompting (non-interactive). */
|
|
15
|
-
overwrite?: boolean;
|
|
16
|
-
/** Skip writing files that would conflict (non-interactive). */
|
|
17
|
-
skipExisting?: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* When true, write output under `.requirements/cts/` instead of
|
|
20
|
-
* `.requirements/`. See CTS-PRESENT-5.
|
|
21
|
-
*/
|
|
22
|
-
ignoreRequirements?: boolean;
|
|
23
|
-
projectRoot?: string;
|
|
24
|
-
}
|
|
25
|
-
export declare function presentCommand(rawOptions?: PresentCmdOptions): Promise<void>;
|
|
26
|
-
//# sourceMappingURL=present.d.ts.map
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `dotrequirements codebase-to-spec present` subcommand.
|
|
3
|
-
*
|
|
4
|
-
* Writes the final spec to `.requirements/` and emits a pipeline summary.
|
|
5
|
-
*
|
|
6
|
-
* Requirements covered:
|
|
7
|
-
* - CTS-CLI-2: granular `present` subcommand
|
|
8
|
-
* - CTS-CLI-4: TTY-driven interactive/non-interactive selection
|
|
9
|
-
* - CTS-PRESENT-1..4
|
|
10
|
-
*/
|
|
11
|
-
import { existsSync, writeFileSync } from "node:fs";
|
|
12
|
-
import { cachePaths } from "../../codebase-to-spec/cache.js";
|
|
13
|
-
import { ExitCode } from "../../codebase-to-spec/exit-codes.js";
|
|
14
|
-
import { detectMode } from "../../codebase-to-spec/interactive.js";
|
|
15
|
-
import { runPresent, } from "../../codebase-to-spec/present.js";
|
|
16
|
-
import { StdoutProgress } from "../../codebase-to-spec/progress.js";
|
|
17
|
-
import { buildPipelineSummary, renderSummaryText, } from "../../codebase-to-spec/summary.js";
|
|
18
|
-
import { findProjectRoot } from "../../utils/project-settings.js";
|
|
19
|
-
import { readFinalOutline } from "./plan-loop.js";
|
|
20
|
-
function resolveOverwritePolicy(isInteractive, options) {
|
|
21
|
-
if (options.overwrite && options.skipExisting) {
|
|
22
|
-
return { error: "--overwrite and --skip-existing are mutually exclusive." };
|
|
23
|
-
}
|
|
24
|
-
if (options.overwrite)
|
|
25
|
-
return "overwrite";
|
|
26
|
-
if (options.skipExisting)
|
|
27
|
-
return "skip-existing";
|
|
28
|
-
if (isInteractive)
|
|
29
|
-
return "prompt";
|
|
30
|
-
return "fail-fast";
|
|
31
|
-
}
|
|
32
|
-
export async function presentCommand(rawOptions = {}) {
|
|
33
|
-
const progress = new StdoutProgress();
|
|
34
|
-
const projectRoot = rawOptions.projectRoot ?? findProjectRoot(process.cwd()) ?? process.cwd();
|
|
35
|
-
const paths = cachePaths(projectRoot);
|
|
36
|
-
if (!existsSync(paths.outlineFinal)) {
|
|
37
|
-
process.stderr.write(`Missing outline at ${paths.outlineFinal}. Run \`dotrequirements cts plan-loop\` first.\n`);
|
|
38
|
-
process.exitCode = ExitCode.MissingInput;
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
if (!existsSync(paths.specFinal)) {
|
|
42
|
-
process.stderr.write(`Missing final spec at ${paths.specFinal}. Run \`dotrequirements cts edit-loop\` first.\n`);
|
|
43
|
-
process.exitCode = ExitCode.MissingInput;
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
const outline = readFinalOutline(projectRoot);
|
|
47
|
-
const { isInteractive } = detectMode(rawOptions.forceMode);
|
|
48
|
-
const policy = resolveOverwritePolicy(isInteractive, rawOptions);
|
|
49
|
-
if (typeof policy === "object") {
|
|
50
|
-
process.stderr.write(`${policy.error}\n`);
|
|
51
|
-
process.exitCode = ExitCode.InvalidFlags;
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
const outputSubdir = rawOptions.ignoreRequirements ? "cts" : undefined;
|
|
55
|
-
const outputDirLabel = outputSubdir
|
|
56
|
-
? `.requirements/${outputSubdir}/`
|
|
57
|
-
: ".requirements/";
|
|
58
|
-
progress.emit({
|
|
59
|
-
stage: "present",
|
|
60
|
-
step: "start",
|
|
61
|
-
message: `Writing final spec to ${outputDirLabel} (mode: ${isInteractive ? "interactive" : "non-interactive"}, policy: ${policy})`,
|
|
62
|
-
});
|
|
63
|
-
const result = await runPresent({
|
|
64
|
-
outline,
|
|
65
|
-
finalSpecPath: paths.specFinal,
|
|
66
|
-
projectRoot,
|
|
67
|
-
overwritePolicy: policy,
|
|
68
|
-
outputSubdir,
|
|
69
|
-
});
|
|
70
|
-
// Per-file outcome announcements.
|
|
71
|
-
for (const action of result.actions) {
|
|
72
|
-
progress.emit({
|
|
73
|
-
stage: "present",
|
|
74
|
-
step: action.action,
|
|
75
|
-
message: `${action.action}: ${action.path}`,
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
if (!result.allWritten) {
|
|
79
|
-
if (result.conflictPath) {
|
|
80
|
-
// fail-fast bailed before any write.
|
|
81
|
-
process.stderr.write(`Refusing to overwrite ${result.conflictPath}. Re-run with --overwrite or --skip-existing, or run in interactive mode.\n`);
|
|
82
|
-
process.exitCode = ExitCode.OverwriteRefused;
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
// Other partial failures (validation, merge conflict, etc.).
|
|
86
|
-
process.exitCode = ExitCode.StageFailed;
|
|
87
|
-
}
|
|
88
|
-
// Emit the pipeline summary.
|
|
89
|
-
const summary = buildPipelineSummary({
|
|
90
|
-
outline,
|
|
91
|
-
paths,
|
|
92
|
-
outputPaths: result.outputPaths,
|
|
93
|
-
});
|
|
94
|
-
writeFileSync(paths.pipelineSummary, `${JSON.stringify(summary, null, 2)}\n`, "utf-8");
|
|
95
|
-
process.stdout.write(`\n${renderSummaryText(summary)}\n`);
|
|
96
|
-
}
|
|
97
|
-
//# sourceMappingURL=present.js.map
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `dotrequirements codebase-to-spec run` subcommand.
|
|
3
|
-
*
|
|
4
|
-
* Chains the pipeline stages. Currently: pack → plan-loop. Subsequent
|
|
5
|
-
* increments will chain specify → compose → edit → present.
|
|
6
|
-
*
|
|
7
|
-
* Requirements covered (incrementally):
|
|
8
|
-
* - CTS-CLI-1: User can run the pipeline end-to-end with a single command
|
|
9
|
-
*/
|
|
10
|
-
import { type PackOptions } from "./pack.js";
|
|
11
|
-
export interface RunOptions extends PackOptions {
|
|
12
|
-
maxTurns?: number;
|
|
13
|
-
model?: string;
|
|
14
|
-
concurrency?: number;
|
|
15
|
-
forceMode?: "interactive" | "non-interactive";
|
|
16
|
-
overwrite?: boolean;
|
|
17
|
-
skipExisting?: boolean;
|
|
18
|
-
}
|
|
19
|
-
export declare function runCommand(options?: RunOptions): Promise<void>;
|
|
20
|
-
//# sourceMappingURL=run.d.ts.map
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `dotrequirements codebase-to-spec run` subcommand.
|
|
3
|
-
*
|
|
4
|
-
* Chains the pipeline stages. Currently: pack → plan-loop. Subsequent
|
|
5
|
-
* increments will chain specify → compose → edit → present.
|
|
6
|
-
*
|
|
7
|
-
* Requirements covered (incrementally):
|
|
8
|
-
* - CTS-CLI-1: User can run the pipeline end-to-end with a single command
|
|
9
|
-
*/
|
|
10
|
-
import { ExitCode } from "../../codebase-to-spec/exit-codes.js";
|
|
11
|
-
import { composeCommand } from "./compose.js";
|
|
12
|
-
import { editLoopCommand } from "./edit-loop.js";
|
|
13
|
-
import { fanOutCommand } from "./fan-out.js";
|
|
14
|
-
import { packCommand } from "./pack.js";
|
|
15
|
-
import { planLoopCommand } from "./plan-loop.js";
|
|
16
|
-
import { presentCommand } from "./present.js";
|
|
17
|
-
export async function runCommand(options = {}) {
|
|
18
|
-
// Stage 1 — Pack
|
|
19
|
-
await packCommand(options);
|
|
20
|
-
if (process.exitCode && process.exitCode !== 0) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
// Stage 2 — Plan + outline review loop
|
|
24
|
-
await planLoopCommand({
|
|
25
|
-
maxTurns: options.maxTurns,
|
|
26
|
-
model: options.model,
|
|
27
|
-
progress: options.progress,
|
|
28
|
-
projectRoot: options.projectRoot,
|
|
29
|
-
});
|
|
30
|
-
if (process.exitCode &&
|
|
31
|
-
process.exitCode !== 0 &&
|
|
32
|
-
process.exitCode !== ExitCode.MaxTurnsHit) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
// Reset exit code from MaxTurnsHit so downstream stages can still proceed
|
|
36
|
-
// (we use the latest outline anyway per CTS-PLAN-6).
|
|
37
|
-
if (process.exitCode === ExitCode.MaxTurnsHit) {
|
|
38
|
-
process.exitCode = 0;
|
|
39
|
-
}
|
|
40
|
-
// Stage 3 — Specifier fan-out
|
|
41
|
-
await fanOutCommand({
|
|
42
|
-
concurrency: options.concurrency,
|
|
43
|
-
model: options.model,
|
|
44
|
-
projectRoot: options.projectRoot,
|
|
45
|
-
});
|
|
46
|
-
if (process.exitCode &&
|
|
47
|
-
process.exitCode !== 0 &&
|
|
48
|
-
process.exitCode !== ExitCode.StageFailed) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
// StageFailed from fan-out means some specifiers failed; per CTS-SPEC-5 the
|
|
52
|
-
// pipeline continues. Other areas still produced partials.
|
|
53
|
-
if (process.exitCode === ExitCode.StageFailed) {
|
|
54
|
-
process.exitCode = 0;
|
|
55
|
-
}
|
|
56
|
-
// Stage 4 — Compose
|
|
57
|
-
await composeCommand({ projectRoot: options.projectRoot });
|
|
58
|
-
if (process.exitCode && process.exitCode !== 0) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
// Stage 5 — Spec review + edit loop
|
|
62
|
-
await editLoopCommand({
|
|
63
|
-
maxTurns: options.maxTurns,
|
|
64
|
-
model: options.model,
|
|
65
|
-
projectRoot: options.projectRoot,
|
|
66
|
-
});
|
|
67
|
-
if (process.exitCode &&
|
|
68
|
-
process.exitCode !== 0 &&
|
|
69
|
-
process.exitCode !== ExitCode.MaxTurnsHit) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
if (process.exitCode === ExitCode.MaxTurnsHit) {
|
|
73
|
-
process.exitCode = 0;
|
|
74
|
-
}
|
|
75
|
-
// Stage 6 — Present (write final spec to .requirements/ + emit summary)
|
|
76
|
-
await presentCommand({
|
|
77
|
-
forceMode: options.forceMode,
|
|
78
|
-
overwrite: options.overwrite,
|
|
79
|
-
skipExisting: options.skipExisting,
|
|
80
|
-
ignoreRequirements: options.ignoreRequirements,
|
|
81
|
-
projectRoot: options.projectRoot,
|
|
82
|
-
});
|
|
83
|
-
// Present sets a non-zero exit code on overwrite refusal or validation
|
|
84
|
-
// failure; let it propagate.
|
|
85
|
-
}
|
|
86
|
-
//# sourceMappingURL=run.js.map
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `dotrequirements codebase-to-spec specify-area <name>` subcommand.
|
|
3
|
-
*
|
|
4
|
-
* Runs a single specifier for one named area from the cached outline. Useful
|
|
5
|
-
* for retrying a single failed area, or for scripting.
|
|
6
|
-
*
|
|
7
|
-
* Requirements covered:
|
|
8
|
-
* - CTS-CLI-2: granular `specify-area` subcommand
|
|
9
|
-
* - CTS-SPEC-1..4: per-area specifier behavior
|
|
10
|
-
*/
|
|
11
|
-
export interface SpecifyAreaOptions {
|
|
12
|
-
model?: string;
|
|
13
|
-
/** Path to the CLI binary (defaults to `dotrequirements`). */
|
|
14
|
-
cliBinary?: string;
|
|
15
|
-
projectRoot?: string;
|
|
16
|
-
}
|
|
17
|
-
export declare function specifyAreaCommand(areaName: string, options?: SpecifyAreaOptions): Promise<void>;
|
|
18
|
-
//# sourceMappingURL=specify-area.d.ts.map
|