@popoverai/dotrequirements 0.23.0 → 0.24.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 (229) hide show
  1. package/README.md +167 -20
  2. package/dist/cli.js +121 -60
  3. package/dist/codebase-to-spec/budget.d.ts +53 -0
  4. package/dist/codebase-to-spec/budget.js +80 -0
  5. package/dist/codebase-to-spec/cache.d.ts +49 -0
  6. package/dist/codebase-to-spec/cache.js +54 -0
  7. package/dist/codebase-to-spec/claude.d.ts +69 -0
  8. package/dist/codebase-to-spec/claude.js +126 -0
  9. package/dist/codebase-to-spec/compose.d.ts +49 -0
  10. package/dist/codebase-to-spec/compose.js +124 -0
  11. package/dist/codebase-to-spec/edit-loop.d.ts +54 -0
  12. package/dist/codebase-to-spec/edit-loop.js +195 -0
  13. package/dist/codebase-to-spec/editor.d.ts +54 -0
  14. package/dist/codebase-to-spec/editor.js +74 -0
  15. package/dist/codebase-to-spec/exit-codes.d.ts +40 -0
  16. package/dist/codebase-to-spec/exit-codes.js +58 -0
  17. package/dist/codebase-to-spec/fan-out.d.ts +63 -0
  18. package/dist/codebase-to-spec/fan-out.js +215 -0
  19. package/dist/codebase-to-spec/interactive.d.ts +30 -0
  20. package/dist/codebase-to-spec/interactive.js +48 -0
  21. package/dist/codebase-to-spec/outline-review-loop.d.ts +51 -0
  22. package/dist/codebase-to-spec/outline-review-loop.js +187 -0
  23. package/dist/codebase-to-spec/pack.d.ts +51 -0
  24. package/dist/codebase-to-spec/pack.js +127 -0
  25. package/dist/codebase-to-spec/planner.d.ts +41 -0
  26. package/dist/codebase-to-spec/planner.js +76 -0
  27. package/dist/codebase-to-spec/present.d.ts +94 -0
  28. package/dist/codebase-to-spec/present.js +288 -0
  29. package/dist/codebase-to-spec/progress.d.ts +33 -0
  30. package/dist/codebase-to-spec/progress.js +28 -0
  31. package/dist/codebase-to-spec/prompts/editor.d.ts +13 -0
  32. package/dist/codebase-to-spec/prompts/editor.js +57 -0
  33. package/dist/codebase-to-spec/prompts/outline-reviewer.d.ts +12 -0
  34. package/dist/codebase-to-spec/prompts/outline-reviewer.js +87 -0
  35. package/dist/codebase-to-spec/prompts/planner-apply.d.ts +12 -0
  36. package/dist/codebase-to-spec/prompts/planner-apply.js +32 -0
  37. package/dist/codebase-to-spec/prompts/planner-initial.d.ts +11 -0
  38. package/dist/codebase-to-spec/prompts/planner-initial.js +125 -0
  39. package/dist/codebase-to-spec/prompts/planner-revise.d.ts +14 -0
  40. package/dist/codebase-to-spec/prompts/planner-revise.js +60 -0
  41. package/dist/codebase-to-spec/prompts/spec-reviewer.d.ts +16 -0
  42. package/dist/codebase-to-spec/prompts/spec-reviewer.js +96 -0
  43. package/dist/codebase-to-spec/prompts/specifier.d.ts +12 -0
  44. package/dist/codebase-to-spec/prompts/specifier.js +100 -0
  45. package/dist/codebase-to-spec/prompts/style-check.d.ts +12 -0
  46. package/dist/codebase-to-spec/prompts/style-check.js +78 -0
  47. package/dist/codebase-to-spec/schemas.d.ts +257 -0
  48. package/dist/codebase-to-spec/schemas.js +183 -0
  49. package/dist/codebase-to-spec/skill-install.d.ts +57 -0
  50. package/dist/codebase-to-spec/skill-install.js +79 -0
  51. package/dist/codebase-to-spec/slice.d.ts +49 -0
  52. package/dist/codebase-to-spec/slice.js +111 -0
  53. package/dist/codebase-to-spec/specifier.d.ts +60 -0
  54. package/dist/codebase-to-spec/specifier.js +79 -0
  55. package/dist/codebase-to-spec/style-check.d.ts +29 -0
  56. package/dist/codebase-to-spec/style-check.js +33 -0
  57. package/dist/codebase-to-spec/summary.d.ts +51 -0
  58. package/dist/codebase-to-spec/summary.js +183 -0
  59. package/dist/codebase-to-spec/validate.d.ts +46 -0
  60. package/dist/codebase-to-spec/validate.js +130 -0
  61. package/dist/commands/acceptance-test.d.ts +6 -0
  62. package/dist/commands/acceptance-test.js +212 -0
  63. package/dist/commands/ai-setup.d.ts +5 -0
  64. package/dist/commands/ai-setup.js +441 -0
  65. package/dist/commands/browsertest.js +34 -27
  66. package/dist/commands/codebase-to-spec/compose.d.ts +14 -0
  67. package/dist/commands/codebase-to-spec/compose.js +57 -0
  68. package/dist/commands/codebase-to-spec/edit-loop.d.ts +16 -0
  69. package/dist/commands/codebase-to-spec/edit-loop.js +83 -0
  70. package/dist/commands/codebase-to-spec/fan-out.d.ts +19 -0
  71. package/dist/commands/codebase-to-spec/fan-out.js +77 -0
  72. package/dist/commands/codebase-to-spec/index.d.ts +9 -0
  73. package/dist/commands/codebase-to-spec/index.js +135 -0
  74. package/dist/commands/codebase-to-spec/pack.d.ts +22 -0
  75. package/dist/commands/codebase-to-spec/pack.js +76 -0
  76. package/dist/commands/codebase-to-spec/plan-loop.d.ts +26 -0
  77. package/dist/commands/codebase-to-spec/plan-loop.js +105 -0
  78. package/dist/commands/codebase-to-spec/present.d.ts +21 -0
  79. package/dist/commands/codebase-to-spec/present.js +92 -0
  80. package/dist/commands/codebase-to-spec/run.d.ts +20 -0
  81. package/dist/commands/codebase-to-spec/run.js +85 -0
  82. package/dist/commands/codebase-to-spec/skill-install.d.ts +20 -0
  83. package/dist/commands/codebase-to-spec/skill-install.js +51 -0
  84. package/dist/commands/codebase-to-spec/specify-area.d.ts +18 -0
  85. package/dist/commands/codebase-to-spec/specify-area.js +82 -0
  86. package/dist/commands/codebase-to-spec/style-check.d.ts +15 -0
  87. package/dist/commands/codebase-to-spec/style-check.js +42 -0
  88. package/dist/commands/codebase-to-spec/validate.d.ts +18 -0
  89. package/dist/commands/codebase-to-spec/validate.js +38 -0
  90. package/dist/commands/create-requirement-document.d.ts +2 -0
  91. package/dist/commands/create-requirement-document.js +41 -0
  92. package/dist/commands/finalize.js +7 -7
  93. package/dist/commands/get.d.ts +2 -0
  94. package/dist/commands/get.js +55 -0
  95. package/dist/commands/init.js +132 -117
  96. package/dist/commands/link.js +27 -27
  97. package/dist/commands/list.d.ts +6 -0
  98. package/dist/commands/list.js +43 -0
  99. package/dist/commands/mcp-setup.js +159 -149
  100. package/dist/commands/mcp.js +1 -1
  101. package/dist/commands/prepare.js +4 -4
  102. package/dist/commands/pull.js +116 -121
  103. package/dist/commands/push.js +106 -112
  104. package/dist/commands/report.d.ts +6 -2
  105. package/dist/commands/report.js +177 -122
  106. package/dist/commands/requirements-for.d.ts +2 -0
  107. package/dist/commands/requirements-for.js +29 -0
  108. package/dist/commands/review-test.d.ts +2 -0
  109. package/dist/commands/review-test.js +75 -0
  110. package/dist/commands/search.d.ts +6 -0
  111. package/dist/commands/search.js +39 -0
  112. package/dist/commands/style-check.d.ts +7 -0
  113. package/dist/commands/style-check.js +75 -0
  114. package/dist/commands/test.js +53 -59
  115. package/dist/commands/tests-for.d.ts +2 -0
  116. package/dist/commands/tests-for.js +80 -0
  117. package/dist/commands/validate.d.ts +6 -0
  118. package/dist/commands/validate.js +72 -0
  119. package/dist/config.js +1 -1
  120. package/dist/convex.d.ts +34 -22
  121. package/dist/convex.js +38 -22
  122. package/dist/harness/cache.d.ts +1 -5
  123. package/dist/harness/cache.js +49 -59
  124. package/dist/harness/convexReporting.d.ts +1 -1
  125. package/dist/harness/convexReporting.js +9 -7
  126. package/dist/harness/coverageCache.js +3 -3
  127. package/dist/harness/finalize.js +59 -46
  128. package/dist/harness/index.d.ts +6 -7
  129. package/dist/harness/index.js +9 -10
  130. package/dist/harness/prepare.js +6 -5
  131. package/dist/harness/requirementsLoader.d.ts +2 -2
  132. package/dist/harness/requirementsLoader.js +13 -35
  133. package/dist/harness/tracking.js +18 -18
  134. package/dist/harness/types.d.ts +1 -1
  135. package/dist/mcp/convexClient.d.ts +0 -39
  136. package/dist/mcp/convexClient.js +2 -107
  137. package/dist/mcp/grep.d.ts +1 -1
  138. package/dist/mcp/grep.js +87 -42
  139. package/dist/mcp/handlers/authoring.d.ts +1 -1
  140. package/dist/mcp/handlers/authoring.js +30 -234
  141. package/dist/mcp/handlers/coverage.d.ts +1 -1
  142. package/dist/mcp/handlers/coverage.js +13 -15
  143. package/dist/mcp/handlers/debug.d.ts +2 -3
  144. package/dist/mcp/handlers/debug.js +10 -10
  145. package/dist/mcp/handlers/get.d.ts +1 -1
  146. package/dist/mcp/handlers/get.js +11 -10
  147. package/dist/mcp/handlers/index.d.ts +20 -20
  148. package/dist/mcp/handlers/index.js +10 -10
  149. package/dist/mcp/handlers/list.d.ts +4 -33
  150. package/dist/mcp/handlers/list.js +16 -38
  151. package/dist/mcp/handlers/push.d.ts +1 -1
  152. package/dist/mcp/handlers/push.js +28 -18
  153. package/dist/mcp/handlers/report.d.ts +16 -0
  154. package/dist/mcp/handlers/report.js +134 -0
  155. package/dist/mcp/handlers/review.d.ts +1 -1
  156. package/dist/mcp/handlers/review.js +40 -59
  157. package/dist/mcp/handlers/search.d.ts +1 -1
  158. package/dist/mcp/handlers/search.js +7 -9
  159. package/dist/mcp/handlers/test-mapping.d.ts +1 -1
  160. package/dist/mcp/handlers/test-mapping.js +14 -14
  161. package/dist/mcp/handlers/types.d.ts +3 -3
  162. package/dist/mcp/handlers/types.js +2 -2
  163. package/dist/mcp/index.d.ts +1 -1
  164. package/dist/mcp/index.js +147 -167
  165. package/dist/mcp/requirements.d.ts +2 -2
  166. package/dist/mcp/requirements.js +30 -30
  167. package/dist/mcp/testCodeExtractor.js +24 -26
  168. package/dist/mcp/types.d.ts +1 -1
  169. package/dist/push/core.d.ts +2 -2
  170. package/dist/push/core.js +20 -20
  171. package/dist/push/index.d.ts +1 -1
  172. package/dist/push/index.js +2 -2
  173. package/dist/requirements/cloud-ai.d.ts +57 -0
  174. package/dist/requirements/cloud-ai.js +104 -0
  175. package/dist/requirements/cloud-coverage.d.ts +41 -0
  176. package/dist/requirements/cloud-coverage.js +60 -0
  177. package/dist/requirements/coverage.d.ts +45 -0
  178. package/dist/requirements/coverage.js +114 -0
  179. package/dist/requirements/grep.d.ts +33 -0
  180. package/dist/requirements/grep.js +306 -0
  181. package/dist/requirements/index.d.ts +73 -0
  182. package/dist/requirements/index.js +174 -0
  183. package/dist/requirements/style-guide.d.ts +67 -0
  184. package/dist/requirements/style-guide.js +299 -0
  185. package/dist/requirements/testCodeExtractor.d.ts +22 -0
  186. package/dist/requirements/testCodeExtractor.js +150 -0
  187. package/dist/schema/browser.d.ts +8 -8
  188. package/dist/schema/browser.js +13 -15
  189. package/dist/schema/builder.d.ts +1 -1
  190. package/dist/schema/builder.js +13 -44
  191. package/dist/schema/conversions.d.ts +2 -2
  192. package/dist/schema/conversions.js +11 -11
  193. package/dist/schema/index.d.ts +9 -9
  194. package/dist/schema/index.js +15 -15
  195. package/dist/schema/parser-core.d.ts +1 -1
  196. package/dist/schema/parser-core.js +23 -22
  197. package/dist/schema/parser.d.ts +3 -3
  198. package/dist/schema/parser.js +27 -31
  199. package/dist/schema/resolver.d.ts +1 -1
  200. package/dist/schema/resolver.js +9 -9
  201. package/dist/schema/scenario.d.ts +1 -1
  202. package/dist/schema/scenario.js +1 -1
  203. package/dist/schema/schemas.d.ts +3 -3
  204. package/dist/schema/schemas.js +41 -28
  205. package/dist/schema/test-schema.js +27 -27
  206. package/dist/templates/context-file-section.md +3 -2
  207. package/dist/templates/example-requirements.js +1 -1
  208. package/dist/templates/example-requirements.ts +3 -1
  209. package/dist/templates/requirements-readme.js +1 -1
  210. package/dist/templates/requirements-readme.ts +1 -1
  211. package/dist/templates/skills/codebase-to-spec/SKILL.md +118 -0
  212. package/dist/utils/brand.js +3 -3
  213. package/dist/utils/browser-launch.js +4 -4
  214. package/dist/utils/context-file.d.ts +1 -1
  215. package/dist/utils/context-file.js +26 -26
  216. package/dist/utils/env.js +7 -7
  217. package/dist/utils/gitignore.js +7 -7
  218. package/dist/utils/oauth-callback-server.d.ts +1 -1
  219. package/dist/utils/oauth-callback-server.js +27 -25
  220. package/dist/utils/oauth-flow.js +32 -29
  221. package/dist/utils/project-discovery.d.ts +3 -3
  222. package/dist/utils/project-discovery.js +18 -17
  223. package/dist/utils/project-name.js +8 -8
  224. package/dist/utils/project-selector.d.ts +1 -1
  225. package/dist/utils/project-selector.js +24 -21
  226. package/dist/utils/project-settings.d.ts +1 -1
  227. package/dist/utils/project-settings.js +24 -22
  228. package/dist/utils/templates.js +6 -6
  229. package/package.json +2 -1
@@ -0,0 +1,16 @@
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
@@ -0,0 +1,83 @@
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
@@ -0,0 +1,19 @@
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
@@ -0,0 +1,77 @@
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
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Command registrar for `dotrequirements codebase-to-spec` (alias: `cts`).
3
+ *
4
+ * Subcommands route to focused handlers in this directory. Each subcommand can
5
+ * be invoked granularly (e.g., `dotrequirements cts pack`) per CTS-CLI-2.
6
+ */
7
+ import type { Command } from "commander";
8
+ export declare function registerCodebaseToSpec(program: Command): void;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,135 @@
1
+ /**
2
+ * Command registrar for `dotrequirements codebase-to-spec` (alias: `cts`).
3
+ *
4
+ * Subcommands route to focused handlers in this directory. Each subcommand can
5
+ * be invoked granularly (e.g., `dotrequirements cts pack`) per CTS-CLI-2.
6
+ */
7
+ import { composeCommand } from "./compose.js";
8
+ import { editLoopCommand } from "./edit-loop.js";
9
+ import { fanOutCommand } from "./fan-out.js";
10
+ import { packCommand } from "./pack.js";
11
+ import { planLoopCommand } from "./plan-loop.js";
12
+ import { presentCommand } from "./present.js";
13
+ import { runCommand } from "./run.js";
14
+ import { skillInstallCommand } from "./skill-install.js";
15
+ import { specifyAreaCommand } from "./specify-area.js";
16
+ import { styleCheckCommand } from "./style-check.js";
17
+ import { validateCommand } from "./validate.js";
18
+ export function registerCodebaseToSpec(program) {
19
+ const cts = program
20
+ .command("codebase-to-spec")
21
+ .alias("cts")
22
+ .description("Generate dotrequirements behavioral specifications from a codebase");
23
+ cts
24
+ .command("pack")
25
+ .description("Pack the codebase (compressed and uncompressed views) into the cache")
26
+ .option("-s, --scope <path>", "Limit to files under this path (subdir of project root)")
27
+ .option("--fresh", "Clear the cache before running")
28
+ .option("--budget <tokens>", "Override the working-context budget (in tokens)", (v) => parseInt(v, 10))
29
+ .action((opts) => packCommand({ ...opts, budgetTokens: opts.budget }));
30
+ cts
31
+ .command("plan-loop")
32
+ .description("Run the planner + outline review loop on the cached pack")
33
+ .option("--max-turns <n>", "Hard cap on review turns", (v) => parseInt(v, 10))
34
+ .option("--model <name>", "Override the model used by the planner and reviewer")
35
+ .action((opts) => planLoopCommand({
36
+ maxTurns: opts.maxTurns,
37
+ model: opts.model,
38
+ }));
39
+ cts
40
+ .command("specify-area <name>")
41
+ .description("Run the specifier for one named area from the cached outline")
42
+ .option("--model <name>", "Override the model used by the specifier")
43
+ .action((name, opts) => specifyAreaCommand(name, {
44
+ model: opts.model,
45
+ }));
46
+ cts
47
+ .command("fan-out")
48
+ .description("Run all specifiers in parallel for areas in the cached outline")
49
+ .option("-c, --concurrency <n>", "Max concurrent specifiers", (v) => parseInt(v, 10))
50
+ .option("--model <name>", "Override the model used by specifiers")
51
+ .action((opts) => fanOutCommand({
52
+ concurrency: opts.concurrency,
53
+ model: opts.model,
54
+ }));
55
+ cts
56
+ .command("validate <partial-path>")
57
+ .description("Validate the schema/syntax of a partial-spec file (deterministic, offline)")
58
+ .action((partialPath) => validateCommand(partialPath));
59
+ cts
60
+ .command("style-check <partial-path>")
61
+ .description("Run a local style-check on a partial-spec file (severity-categorized feedback)")
62
+ .option("--model <name>", "Override the model used for the check")
63
+ .action((partialPath, opts) => styleCheckCommand(partialPath, { model: opts.model }));
64
+ cts
65
+ .command("compose")
66
+ .description("Assemble per-area partials into a single composed spec")
67
+ .action(() => composeCommand());
68
+ cts
69
+ .command("edit-loop")
70
+ .description("Run the spec reviewer + editor loop on the composed spec")
71
+ .option("--max-turns <n>", "Hard cap on edit-loop turns", (v) => parseInt(v, 10))
72
+ .option("--model <name>", "Override the model used by the reviewer and editor")
73
+ .action((opts) => editLoopCommand({
74
+ maxTurns: opts.maxTurns,
75
+ model: opts.model,
76
+ }));
77
+ cts
78
+ .command("present")
79
+ .description("Write the final spec to .requirements/ and emit a pipeline summary")
80
+ .option("--interactive", "Force interactive mode (override TTY detection)")
81
+ .option("--non-interactive", "Force non-interactive mode (override TTY detection)")
82
+ .option("--overwrite", "Replace existing .requirements/ files without prompting")
83
+ .option("--skip-existing", "Leave existing .requirements/ files untouched")
84
+ .action((opts) => {
85
+ const forceMode = opts.interactive
86
+ ? "interactive"
87
+ : opts.nonInteractive
88
+ ? "non-interactive"
89
+ : undefined;
90
+ return presentCommand({
91
+ forceMode,
92
+ overwrite: opts.overwrite,
93
+ skipExisting: opts.skipExisting,
94
+ });
95
+ });
96
+ cts
97
+ .command("run")
98
+ .description("Run the full pipeline (pack → plan → specify → compose → edit → present)")
99
+ .option("-s, --scope <path>", "Limit to files under this path (subdir of project root)")
100
+ .option("--fresh", "Clear the cache before running")
101
+ .option("--budget <tokens>", "Override the working-context budget (in tokens)", (v) => parseInt(v, 10))
102
+ .option("--max-turns <n>", "Hard cap on outline review turns", (v) => parseInt(v, 10))
103
+ .option("--model <name>", "Override the model used by agent calls")
104
+ .option("--interactive", "Force interactive mode for the present stage")
105
+ .option("--non-interactive", "Force non-interactive mode for the present stage")
106
+ .option("--overwrite", "Replace existing .requirements/ files without prompting")
107
+ .option("--skip-existing", "Leave existing .requirements/ files untouched")
108
+ .action((opts) => {
109
+ const forceMode = opts.interactive
110
+ ? "interactive"
111
+ : opts.nonInteractive
112
+ ? "non-interactive"
113
+ : undefined;
114
+ return runCommand({
115
+ ...opts,
116
+ budgetTokens: opts.budget,
117
+ maxTurns: opts.maxTurns,
118
+ forceMode,
119
+ overwrite: opts.overwrite,
120
+ skipExisting: opts.skipExisting,
121
+ });
122
+ });
123
+ cts
124
+ .command("skill-install")
125
+ .description("Install the codebase-to-spec skill (SKILL.md) into the host's skills directory")
126
+ .option("--global", "Install to ~/.claude/skills/ instead of the project")
127
+ .option("--target-dir <path>", "Install into a custom skills directory (for non-Claude-Code hosts)")
128
+ .option("--overwrite", "Replace an existing SKILL.md if one is already present")
129
+ .action((opts) => skillInstallCommand({
130
+ global: opts.global,
131
+ targetDir: opts.targetDir,
132
+ overwrite: opts.overwrite,
133
+ }));
134
+ }
135
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,22 @@
1
+ /**
2
+ * `dotrequirements codebase-to-spec pack` subcommand.
3
+ *
4
+ * Packs the codebase into the cache directory and runs the budget check.
5
+ *
6
+ * Requirements covered:
7
+ * - CTS-CLI-3: Pipeline refuses to spec a codebase that exceeds the working context budget
8
+ * - CTS-PACK-1: Pack stage produces compressed and uncompressed views of the codebase
9
+ * - CTS-PACK-2: Engineer can extend the ignore list per project
10
+ * - CTS-OBSERVE-1: CLI emits structured progress as the pipeline runs
11
+ */
12
+ export interface PackOptions {
13
+ scope?: string;
14
+ fresh?: boolean;
15
+ budgetTokens?: number;
16
+ /** Override progress emitter, mainly for tests. */
17
+ progress?: import("../../codebase-to-spec/progress.js").ProgressEmitter;
18
+ /** Override the project root, mainly for tests. */
19
+ projectRoot?: string;
20
+ }
21
+ export declare function packCommand(rawOptions?: PackOptions): Promise<void>;
22
+ //# sourceMappingURL=pack.d.ts.map
@@ -0,0 +1,76 @@
1
+ /**
2
+ * `dotrequirements codebase-to-spec pack` subcommand.
3
+ *
4
+ * Packs the codebase into the cache directory and runs the budget check.
5
+ *
6
+ * Requirements covered:
7
+ * - CTS-CLI-3: Pipeline refuses to spec a codebase that exceeds the working context budget
8
+ * - CTS-PACK-1: Pack stage produces compressed and uncompressed views of the codebase
9
+ * - CTS-PACK-2: Engineer can extend the ignore list per project
10
+ * - CTS-OBSERVE-1: CLI emits structured progress as the pipeline runs
11
+ */
12
+ import { resolve } from "node:path";
13
+ import { checkBudget, countTokensInFileExact, DEFAULT_BUDGET_TOKENS, formatBudgetExceededMessage, } from "../../codebase-to-spec/budget.js";
14
+ import { clearCache, ensureCacheDir } from "../../codebase-to-spec/cache.js";
15
+ import { ExitCode } from "../../codebase-to-spec/exit-codes.js";
16
+ import { runPack } from "../../codebase-to-spec/pack.js";
17
+ import { StdoutProgress } from "../../codebase-to-spec/progress.js";
18
+ import { findProjectRoot } from "../../utils/project-settings.js";
19
+ export async function packCommand(rawOptions = {}) {
20
+ const progress = rawOptions.progress ?? new StdoutProgress();
21
+ const projectRoot = rawOptions.projectRoot ?? findProjectRoot(process.cwd()) ?? process.cwd();
22
+ const budgetTokens = rawOptions.budgetTokens ?? DEFAULT_BUDGET_TOKENS;
23
+ if (rawOptions.fresh) {
24
+ progress.emit({
25
+ stage: "pack",
26
+ step: "clear-cache",
27
+ message: "Clearing existing cache (--fresh)",
28
+ });
29
+ clearCache(projectRoot);
30
+ }
31
+ const paths = ensureCacheDir(projectRoot);
32
+ const scope = rawOptions.scope
33
+ ? resolve(projectRoot, rawOptions.scope)
34
+ : undefined;
35
+ progress.emit({
36
+ stage: "pack",
37
+ step: "start",
38
+ message: scope
39
+ ? `Packing codebase at ${scope}`
40
+ : `Packing codebase at ${projectRoot}`,
41
+ });
42
+ const packResult = await runPack({
43
+ projectRoot,
44
+ paths,
45
+ scope: rawOptions.scope,
46
+ });
47
+ progress.emit({
48
+ stage: "pack",
49
+ step: "done",
50
+ message: `Packed ${packResult.fileCount} files → ${paths.overview} (compressed), ${paths.source} (uncompressed)`,
51
+ data: { fileCount: packResult.fileCount },
52
+ });
53
+ // Budget check (CTS-CLI-3)
54
+ const measured = countTokensInFileExact(paths.overview);
55
+ const budget = checkBudget(measured, budgetTokens);
56
+ progress.emit({
57
+ stage: "pack",
58
+ step: "budget-check",
59
+ message: `Compressed pack is ${budget.measuredTokens.toLocaleString()} tokens (budget: ${budget.budgetTokens.toLocaleString()})`,
60
+ data: {
61
+ measuredTokens: budget.measuredTokens,
62
+ budgetTokens: budget.budgetTokens,
63
+ },
64
+ });
65
+ if (!budget.withinBudget) {
66
+ process.stderr.write(`${formatBudgetExceededMessage(budget)}\n`);
67
+ process.exitCode = ExitCode.BudgetExceeded;
68
+ return;
69
+ }
70
+ progress.emit({
71
+ stage: "pack",
72
+ step: "budget-ok",
73
+ message: `Budget OK. Ready for the plan stage.`,
74
+ });
75
+ }
76
+ //# sourceMappingURL=pack.js.map
@@ -0,0 +1,26 @@
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
@@ -0,0 +1,105 @@
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
@@ -0,0 +1,21 @@
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
+ projectRoot?: string;
19
+ }
20
+ export declare function presentCommand(rawOptions?: PresentCmdOptions): Promise<void>;
21
+ //# sourceMappingURL=present.d.ts.map