@popoverai/dotrequirements 0.23.0 → 0.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (235) hide show
  1. package/README.md +169 -22
  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-initial.d.ts +11 -0
  36. package/dist/codebase-to-spec/prompts/planner-initial.js +125 -0
  37. package/dist/codebase-to-spec/prompts/planner-revise.d.ts +14 -0
  38. package/dist/codebase-to-spec/prompts/planner-revise.js +60 -0
  39. package/dist/codebase-to-spec/prompts/spec-reviewer.d.ts +16 -0
  40. package/dist/codebase-to-spec/prompts/spec-reviewer.js +96 -0
  41. package/dist/codebase-to-spec/prompts/specifier.d.ts +12 -0
  42. package/dist/codebase-to-spec/prompts/specifier.js +100 -0
  43. package/dist/codebase-to-spec/prompts/style-check.d.ts +12 -0
  44. package/dist/codebase-to-spec/prompts/style-check.js +78 -0
  45. package/dist/codebase-to-spec/schemas.d.ts +257 -0
  46. package/dist/codebase-to-spec/schemas.js +183 -0
  47. package/dist/codebase-to-spec/skill-install.d.ts +57 -0
  48. package/dist/codebase-to-spec/skill-install.js +79 -0
  49. package/dist/codebase-to-spec/slice.d.ts +49 -0
  50. package/dist/codebase-to-spec/slice.js +111 -0
  51. package/dist/codebase-to-spec/specifier.d.ts +60 -0
  52. package/dist/codebase-to-spec/specifier.js +79 -0
  53. package/dist/codebase-to-spec/style-check.d.ts +29 -0
  54. package/dist/codebase-to-spec/style-check.js +33 -0
  55. package/dist/codebase-to-spec/summary.d.ts +51 -0
  56. package/dist/codebase-to-spec/summary.js +183 -0
  57. package/dist/codebase-to-spec/validate.d.ts +46 -0
  58. package/dist/codebase-to-spec/validate.js +130 -0
  59. package/dist/commands/acceptance-test.d.ts +6 -0
  60. package/dist/commands/{browsertest.js → acceptance-test.js} +36 -29
  61. package/dist/commands/ai-setup.d.ts +5 -0
  62. package/dist/commands/ai-setup.js +441 -0
  63. package/dist/commands/codebase-to-spec/compose.d.ts +14 -0
  64. package/dist/commands/codebase-to-spec/compose.js +57 -0
  65. package/dist/commands/codebase-to-spec/edit-loop.d.ts +16 -0
  66. package/dist/commands/codebase-to-spec/edit-loop.js +83 -0
  67. package/dist/commands/codebase-to-spec/fan-out.d.ts +19 -0
  68. package/dist/commands/codebase-to-spec/fan-out.js +77 -0
  69. package/dist/commands/codebase-to-spec/index.d.ts +9 -0
  70. package/dist/commands/codebase-to-spec/index.js +135 -0
  71. package/dist/commands/codebase-to-spec/pack.d.ts +22 -0
  72. package/dist/commands/codebase-to-spec/pack.js +76 -0
  73. package/dist/commands/codebase-to-spec/plan-loop.d.ts +26 -0
  74. package/dist/commands/codebase-to-spec/plan-loop.js +105 -0
  75. package/dist/commands/codebase-to-spec/present.d.ts +21 -0
  76. package/dist/commands/codebase-to-spec/present.js +92 -0
  77. package/dist/commands/codebase-to-spec/run.d.ts +20 -0
  78. package/dist/commands/codebase-to-spec/run.js +85 -0
  79. package/dist/commands/codebase-to-spec/skill-install.d.ts +20 -0
  80. package/dist/commands/codebase-to-spec/skill-install.js +51 -0
  81. package/dist/commands/codebase-to-spec/specify-area.d.ts +18 -0
  82. package/dist/commands/codebase-to-spec/specify-area.js +82 -0
  83. package/dist/commands/codebase-to-spec/style-check.d.ts +15 -0
  84. package/dist/commands/codebase-to-spec/style-check.js +42 -0
  85. package/dist/commands/codebase-to-spec/validate.d.ts +18 -0
  86. package/dist/commands/codebase-to-spec/validate.js +38 -0
  87. package/dist/commands/create-requirement-document.d.ts +2 -0
  88. package/dist/commands/create-requirement-document.js +41 -0
  89. package/dist/commands/finalize.js +7 -7
  90. package/dist/commands/get.d.ts +2 -0
  91. package/dist/commands/get.js +55 -0
  92. package/dist/commands/init.js +132 -117
  93. package/dist/commands/link.js +27 -27
  94. package/dist/commands/list.d.ts +6 -0
  95. package/dist/commands/list.js +43 -0
  96. package/dist/commands/mcp.js +1 -1
  97. package/dist/commands/prepare.js +4 -4
  98. package/dist/commands/pull.js +116 -121
  99. package/dist/commands/push.js +106 -112
  100. package/dist/commands/report.d.ts +6 -2
  101. package/dist/commands/report.js +177 -122
  102. package/dist/commands/requirements-for.d.ts +2 -0
  103. package/dist/commands/requirements-for.js +29 -0
  104. package/dist/commands/review-test.d.ts +2 -0
  105. package/dist/commands/review-test.js +75 -0
  106. package/dist/commands/search.d.ts +6 -0
  107. package/dist/commands/search.js +39 -0
  108. package/dist/commands/style-check.d.ts +7 -0
  109. package/dist/commands/style-check.js +75 -0
  110. package/dist/commands/tests-for.d.ts +2 -0
  111. package/dist/commands/tests-for.js +80 -0
  112. package/dist/commands/validate.d.ts +6 -0
  113. package/dist/commands/validate.js +72 -0
  114. package/dist/config.js +1 -1
  115. package/dist/convex.d.ts +34 -22
  116. package/dist/convex.js +38 -22
  117. package/dist/harness/cache.d.ts +1 -5
  118. package/dist/harness/cache.js +49 -59
  119. package/dist/harness/convexReporting.d.ts +1 -1
  120. package/dist/harness/convexReporting.js +9 -7
  121. package/dist/harness/coverageCache.js +3 -3
  122. package/dist/harness/finalize.js +59 -46
  123. package/dist/harness/index.d.ts +6 -7
  124. package/dist/harness/index.js +9 -10
  125. package/dist/harness/prepare.js +6 -5
  126. package/dist/harness/requirementsLoader.d.ts +2 -2
  127. package/dist/harness/requirementsLoader.js +13 -35
  128. package/dist/harness/tracking.js +18 -18
  129. package/dist/harness/types.d.ts +1 -1
  130. package/dist/mcp/convexClient.d.ts +0 -39
  131. package/dist/mcp/convexClient.js +2 -107
  132. package/dist/mcp/handlers/authoring.d.ts +1 -1
  133. package/dist/mcp/handlers/authoring.js +30 -234
  134. package/dist/mcp/handlers/debug.d.ts +2 -3
  135. package/dist/mcp/handlers/debug.js +10 -10
  136. package/dist/mcp/handlers/get.d.ts +1 -1
  137. package/dist/mcp/handlers/get.js +11 -10
  138. package/dist/mcp/handlers/index.d.ts +20 -20
  139. package/dist/mcp/handlers/index.js +10 -10
  140. package/dist/mcp/handlers/list.d.ts +4 -33
  141. package/dist/mcp/handlers/list.js +16 -38
  142. package/dist/mcp/handlers/push.d.ts +1 -1
  143. package/dist/mcp/handlers/push.js +28 -18
  144. package/dist/mcp/handlers/report.d.ts +16 -0
  145. package/dist/mcp/handlers/report.js +134 -0
  146. package/dist/mcp/handlers/review.d.ts +1 -1
  147. package/dist/mcp/handlers/review.js +40 -59
  148. package/dist/mcp/handlers/search.d.ts +1 -1
  149. package/dist/mcp/handlers/search.js +7 -9
  150. package/dist/mcp/handlers/test-mapping.d.ts +1 -1
  151. package/dist/mcp/handlers/test-mapping.js +14 -14
  152. package/dist/mcp/handlers/types.d.ts +3 -3
  153. package/dist/mcp/handlers/types.js +2 -2
  154. package/dist/mcp/index.d.ts +1 -1
  155. package/dist/mcp/index.js +147 -167
  156. package/dist/push/core.d.ts +2 -2
  157. package/dist/push/core.js +20 -20
  158. package/dist/push/index.d.ts +1 -1
  159. package/dist/push/index.js +2 -2
  160. package/dist/requirements/cloud-ai.d.ts +57 -0
  161. package/dist/requirements/cloud-ai.js +104 -0
  162. package/dist/requirements/cloud-coverage.d.ts +41 -0
  163. package/dist/requirements/cloud-coverage.js +60 -0
  164. package/dist/requirements/coverage.d.ts +45 -0
  165. package/dist/requirements/coverage.js +114 -0
  166. package/dist/{mcp → requirements}/grep.d.ts +10 -1
  167. package/dist/{mcp → requirements}/grep.js +89 -44
  168. package/dist/{mcp/requirements.d.ts → requirements/index.d.ts} +19 -3
  169. package/dist/{mcp/requirements.js → requirements/index.js} +54 -35
  170. package/dist/requirements/style-guide.d.ts +67 -0
  171. package/dist/requirements/style-guide.js +299 -0
  172. package/dist/{mcp → requirements}/testCodeExtractor.js +24 -26
  173. package/dist/schema/browser.d.ts +8 -8
  174. package/dist/schema/browser.js +13 -15
  175. package/dist/schema/builder.d.ts +1 -1
  176. package/dist/schema/builder.js +13 -44
  177. package/dist/schema/conversions.d.ts +2 -2
  178. package/dist/schema/conversions.js +11 -11
  179. package/dist/schema/index.d.ts +9 -9
  180. package/dist/schema/index.js +15 -15
  181. package/dist/schema/parser-core.d.ts +1 -1
  182. package/dist/schema/parser-core.js +23 -22
  183. package/dist/schema/parser.d.ts +3 -3
  184. package/dist/schema/parser.js +27 -31
  185. package/dist/schema/resolver.d.ts +1 -1
  186. package/dist/schema/resolver.js +9 -9
  187. package/dist/schema/scenario.d.ts +1 -1
  188. package/dist/schema/scenario.js +1 -1
  189. package/dist/schema/schemas.d.ts +3 -3
  190. package/dist/schema/schemas.js +41 -28
  191. package/dist/schema/test-schema.js +27 -27
  192. package/dist/templates/context-file-section.md +3 -2
  193. package/dist/templates/example-requirements.js +1 -1
  194. package/dist/templates/example-requirements.ts +3 -1
  195. package/dist/templates/requirements-readme.js +1 -1
  196. package/dist/templates/requirements-readme.ts +1 -1
  197. package/dist/templates/skills/codebase-to-spec/SKILL.md +118 -0
  198. package/dist/utils/brand.js +3 -3
  199. package/dist/utils/browser-launch.js +4 -4
  200. package/dist/utils/context-file.d.ts +1 -1
  201. package/dist/utils/context-file.js +26 -26
  202. package/dist/utils/env.js +7 -7
  203. package/dist/utils/gitignore.js +7 -7
  204. package/dist/utils/oauth-callback-server.d.ts +1 -1
  205. package/dist/utils/oauth-callback-server.js +27 -25
  206. package/dist/utils/oauth-flow.js +32 -29
  207. package/dist/utils/project-discovery.d.ts +3 -3
  208. package/dist/utils/project-discovery.js +18 -17
  209. package/dist/utils/project-name.js +8 -8
  210. package/dist/utils/project-selector.d.ts +1 -1
  211. package/dist/utils/project-selector.js +24 -21
  212. package/dist/utils/project-settings.d.ts +1 -1
  213. package/dist/utils/project-settings.js +24 -22
  214. package/dist/utils/templates.js +6 -6
  215. package/package.json +3 -2
  216. package/dist/commands/browsertest.d.ts +0 -6
  217. package/dist/commands/login.d.ts +0 -12
  218. package/dist/commands/login.js +0 -117
  219. package/dist/commands/logout.d.ts +0 -5
  220. package/dist/commands/logout.js +0 -17
  221. package/dist/commands/mcp-setup.d.ts +0 -5
  222. package/dist/commands/mcp-setup.js +0 -431
  223. package/dist/commands/test.d.ts +0 -6
  224. package/dist/commands/test.js +0 -78
  225. package/dist/mcp/handlers/coverage.d.ts +0 -44
  226. package/dist/mcp/handlers/coverage.js +0 -105
  227. package/dist/mcp/types.d.ts +0 -27
  228. package/dist/mcp/types.js +0 -2
  229. package/dist/utils/local-project.d.ts +0 -31
  230. package/dist/utils/local-project.js +0 -33
  231. package/dist/utils/token-refresh.d.ts +0 -24
  232. package/dist/utils/token-refresh.js +0 -69
  233. package/dist/utils/token-storage.d.ts +0 -31
  234. package/dist/utils/token-storage.js +0 -57
  235. /package/dist/{mcp → requirements}/testCodeExtractor.d.ts +0 -0
@@ -0,0 +1,20 @@
1
+ /**
2
+ * `dotrequirements codebase-to-spec skill-install` subcommand.
3
+ *
4
+ * Installs the codebase-to-spec SKILL.md into the host's skill directory.
5
+ * Defaults to the project's `.claude/skills/` (Claude Code convention);
6
+ * `--global` installs into `~/.claude/skills/`; `--target-dir <dir>` writes
7
+ * to a custom location for other hosts.
8
+ *
9
+ * Requirements covered:
10
+ * - CTS-CLI-2: granular subcommand
11
+ * - CTS-SKILL-1, CTS-SKILL-5: install the skill artifact in a host-agnostic way
12
+ */
13
+ export interface SkillInstallCmdOptions {
14
+ global?: boolean;
15
+ targetDir?: string;
16
+ overwrite?: boolean;
17
+ projectRoot?: string;
18
+ }
19
+ export declare function skillInstallCommand(options?: SkillInstallCmdOptions): Promise<void>;
20
+ //# sourceMappingURL=skill-install.d.ts.map
@@ -0,0 +1,51 @@
1
+ /**
2
+ * `dotrequirements codebase-to-spec skill-install` subcommand.
3
+ *
4
+ * Installs the codebase-to-spec SKILL.md into the host's skill directory.
5
+ * Defaults to the project's `.claude/skills/` (Claude Code convention);
6
+ * `--global` installs into `~/.claude/skills/`; `--target-dir <dir>` writes
7
+ * to a custom location for other hosts.
8
+ *
9
+ * Requirements covered:
10
+ * - CTS-CLI-2: granular subcommand
11
+ * - CTS-SKILL-1, CTS-SKILL-5: install the skill artifact in a host-agnostic way
12
+ */
13
+ import { ExitCode } from "../../codebase-to-spec/exit-codes.js";
14
+ import { installSkill, } from "../../codebase-to-spec/skill-install.js";
15
+ import { findProjectRoot } from "../../utils/project-settings.js";
16
+ export async function skillInstallCommand(options = {}) {
17
+ if (options.global && options.targetDir) {
18
+ process.stderr.write("--global and --target-dir cannot be combined. Pick one.\n");
19
+ process.exitCode = ExitCode.InvalidFlags;
20
+ return;
21
+ }
22
+ const scope = options.targetDir
23
+ ? "custom"
24
+ : options.global
25
+ ? "global"
26
+ : "project";
27
+ const projectRoot = options.projectRoot ?? findProjectRoot(process.cwd()) ?? process.cwd();
28
+ try {
29
+ const result = installSkill({
30
+ scope,
31
+ targetDir: options.targetDir,
32
+ projectRoot,
33
+ overwrite: options.overwrite,
34
+ });
35
+ if (result.installed && result.overwrote) {
36
+ process.stdout.write(`Replaced SKILL.md at ${result.installedPath}\n`);
37
+ }
38
+ else if (result.installed) {
39
+ process.stdout.write(`Installed SKILL.md at ${result.installedPath}\n`);
40
+ }
41
+ else {
42
+ process.stdout.write(`SKILL.md already up to date at ${result.installedPath}\n`);
43
+ }
44
+ process.stdout.write("Skill ready. In Claude Code, invoke it with `/codebase-to-spec` (or via natural language).\n");
45
+ }
46
+ catch (err) {
47
+ process.stderr.write(`${err instanceof Error ? err.message : String(err)}\n`);
48
+ process.exitCode = ExitCode.StageFailed;
49
+ }
50
+ }
51
+ //# sourceMappingURL=skill-install.js.map
@@ -0,0 +1,18 @@
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
@@ -0,0 +1,82 @@
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
+ import { existsSync } from "node:fs";
12
+ import { cachePaths } from "../../codebase-to-spec/cache.js";
13
+ import { ExitCode } from "../../codebase-to-spec/exit-codes.js";
14
+ import { sanitizeAreaName } from "../../codebase-to-spec/fan-out.js";
15
+ import { StdoutProgress } from "../../codebase-to-spec/progress.js";
16
+ import { extractSlice } from "../../codebase-to-spec/slice.js";
17
+ import { runSpecifier } from "../../codebase-to-spec/specifier.js";
18
+ import { findProjectRoot } from "../../utils/project-settings.js";
19
+ import { readFinalOutline } from "./plan-loop.js";
20
+ export async function specifyAreaCommand(areaName, options = {}) {
21
+ const progress = new StdoutProgress();
22
+ const projectRoot = options.projectRoot ?? findProjectRoot(process.cwd()) ?? process.cwd();
23
+ const paths = cachePaths(projectRoot);
24
+ const cliBinary = options.cliBinary ?? "dotrequirements";
25
+ if (!existsSync(paths.outlineFinal)) {
26
+ process.stderr.write(`Missing outline at ${paths.outlineFinal}. Run \`dotrequirements cts plan-loop\` first.\n`);
27
+ process.exitCode = ExitCode.MissingInput;
28
+ return;
29
+ }
30
+ if (!existsSync(paths.source)) {
31
+ process.stderr.write(`Missing uncompressed pack at ${paths.source}. Run \`dotrequirements cts pack\` first.\n`);
32
+ process.exitCode = ExitCode.MissingInput;
33
+ return;
34
+ }
35
+ const outline = readFinalOutline(projectRoot);
36
+ const area = outline.areas.find((a) => a.name === areaName ||
37
+ a.prefix === areaName ||
38
+ sanitizeAreaName(a.name) === sanitizeAreaName(areaName));
39
+ if (!area) {
40
+ process.stderr.write(`No area named "${areaName}" in outline. Available areas:\n${outline.areas
41
+ .map((a) => ` - ${a.name} (prefix: ${a.prefix})`)
42
+ .join("\n")}\n`);
43
+ process.exitCode = ExitCode.MissingInput;
44
+ return;
45
+ }
46
+ const sanitized = sanitizeAreaName(area.name);
47
+ const slicePath = `${paths.partialsDir}/slice-${sanitized}.txt`;
48
+ const partialPath = paths.partial(sanitized);
49
+ progress.emit({
50
+ stage: "specify",
51
+ step: area.prefix,
52
+ message: `Extracting slice for ${area.name}`,
53
+ });
54
+ extractSlice(paths.source, slicePath, area.files);
55
+ progress.emit({
56
+ stage: "specify",
57
+ step: area.prefix,
58
+ message: `Running specifier for ${area.name}`,
59
+ });
60
+ const result = await runSpecifier({
61
+ outline,
62
+ area,
63
+ slicePath,
64
+ fullPackPath: paths.source,
65
+ partialPath,
66
+ validateCommand: `${cliBinary} cts validate`,
67
+ styleCheckCommand: `${cliBinary} cts style-check`,
68
+ addDirs: [paths.root],
69
+ model: options.model,
70
+ });
71
+ if (!result.wrotePartial) {
72
+ process.stderr.write(`Specifier for ${area.name} produced no partial (exit ${result.exitCode}).\n${result.stderr}\n`);
73
+ process.exitCode = ExitCode.StageFailed;
74
+ return;
75
+ }
76
+ progress.emit({
77
+ stage: "specify",
78
+ step: area.prefix,
79
+ message: `Done. Partial saved to ${partialPath} (${result.partialBytes} bytes)`,
80
+ });
81
+ }
82
+ //# sourceMappingURL=specify-area.js.map
@@ -0,0 +1,15 @@
1
+ /**
2
+ * `dotrequirements codebase-to-spec style-check <path>` subcommand.
3
+ *
4
+ * Invoked by specifier workers via Bash to get severity-categorized feedback
5
+ * on their own partial drafts. Stateless — fresh claude -p call.
6
+ *
7
+ * Requirements covered:
8
+ * - CTS-SPEC-3: local style-check tool runs offline without cloud credentials
9
+ * - CTS-CLI-2: granular subcommand
10
+ */
11
+ export interface StyleCheckCmdOptions {
12
+ model?: string;
13
+ }
14
+ export declare function styleCheckCommand(partialPath: string, options?: StyleCheckCmdOptions): Promise<void>;
15
+ //# sourceMappingURL=style-check.d.ts.map
@@ -0,0 +1,42 @@
1
+ /**
2
+ * `dotrequirements codebase-to-spec style-check <path>` subcommand.
3
+ *
4
+ * Invoked by specifier workers via Bash to get severity-categorized feedback
5
+ * on their own partial drafts. Stateless — fresh claude -p call.
6
+ *
7
+ * Requirements covered:
8
+ * - CTS-SPEC-3: local style-check tool runs offline without cloud credentials
9
+ * - CTS-CLI-2: granular subcommand
10
+ */
11
+ import { existsSync } from "node:fs";
12
+ import { resolve } from "node:path";
13
+ import { ExitCode } from "../../codebase-to-spec/exit-codes.js";
14
+ import { runStyleCheck } from "../../codebase-to-spec/style-check.js";
15
+ export async function styleCheckCommand(partialPath, options = {}) {
16
+ const absPath = resolve(partialPath);
17
+ if (!existsSync(absPath)) {
18
+ process.stderr.write(`File not found: ${partialPath}\n`);
19
+ process.exitCode = ExitCode.MissingInput;
20
+ return;
21
+ }
22
+ try {
23
+ const result = await runStyleCheck({
24
+ partialPath: absPath,
25
+ model: options.model,
26
+ });
27
+ if (result.exitCode !== 0) {
28
+ process.stderr.write(`style-check failed (exit ${result.exitCode})\n`);
29
+ process.exitCode = ExitCode.StageFailed;
30
+ return;
31
+ }
32
+ process.stdout.write(result.feedback);
33
+ if (!result.feedback.endsWith("\n")) {
34
+ process.stdout.write("\n");
35
+ }
36
+ }
37
+ catch (err) {
38
+ process.stderr.write(`style-check error: ${err instanceof Error ? err.message : String(err)}\n`);
39
+ process.exitCode = ExitCode.StageFailed;
40
+ }
41
+ }
42
+ //# sourceMappingURL=style-check.js.map
@@ -0,0 +1,18 @@
1
+ /**
2
+ * `dotrequirements codebase-to-spec validate <partial-path>` subcommand.
3
+ *
4
+ * Invoked by specifier workers via Bash to get a deterministic syntax check
5
+ * on their own partial drafts before they run the AI-driven style-check.
6
+ * Mirrors the validate-then-style-check ordering documented in CLAUDE.md.
7
+ *
8
+ * Exit code is non-zero on validation failure so the specifier can detect
9
+ * the failure programmatically if it wants to; the formatted feedback is
10
+ * always written to stdout so the agent can read it via Bash output.
11
+ *
12
+ * Requirements covered:
13
+ * - CTS-SPEC-3: Specifier runs a local schema validator on its draft,
14
+ * applying any reported errors as MUST FIX before style-check.
15
+ * - CTS-CLI-2: granular subcommand
16
+ */
17
+ export declare function validateCommand(partialPath: string): Promise<void>;
18
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1,38 @@
1
+ /**
2
+ * `dotrequirements codebase-to-spec validate <partial-path>` subcommand.
3
+ *
4
+ * Invoked by specifier workers via Bash to get a deterministic syntax check
5
+ * on their own partial drafts before they run the AI-driven style-check.
6
+ * Mirrors the validate-then-style-check ordering documented in CLAUDE.md.
7
+ *
8
+ * Exit code is non-zero on validation failure so the specifier can detect
9
+ * the failure programmatically if it wants to; the formatted feedback is
10
+ * always written to stdout so the agent can read it via Bash output.
11
+ *
12
+ * Requirements covered:
13
+ * - CTS-SPEC-3: Specifier runs a local schema validator on its draft,
14
+ * applying any reported errors as MUST FIX before style-check.
15
+ * - CTS-CLI-2: granular subcommand
16
+ */
17
+ import { existsSync } from "node:fs";
18
+ import { resolve } from "node:path";
19
+ import { ExitCode } from "../../codebase-to-spec/exit-codes.js";
20
+ import { formatValidateFeedback, runValidate, } from "../../codebase-to-spec/validate.js";
21
+ export async function validateCommand(partialPath) {
22
+ const absPath = resolve(partialPath);
23
+ if (!existsSync(absPath)) {
24
+ process.stderr.write(`File not found: ${partialPath}\n`);
25
+ process.exitCode = ExitCode.MissingInput;
26
+ return;
27
+ }
28
+ const result = runValidate({ partialPath: absPath });
29
+ const feedback = formatValidateFeedback(result);
30
+ process.stdout.write(feedback);
31
+ if (!feedback.endsWith("\n")) {
32
+ process.stdout.write("\n");
33
+ }
34
+ if (!result.ok) {
35
+ process.exitCode = ExitCode.StageFailed;
36
+ }
37
+ }
38
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1,2 @@
1
+ export declare function createRequirementDocumentCommand(filePath: string | undefined): Promise<void>;
2
+ //# sourceMappingURL=create-requirement-document.d.ts.map
@@ -0,0 +1,41 @@
1
+ import { getProjectContext } from "../requirements/cloud-ai.js";
2
+ import { loadAllRequirements } from "../requirements/index.js";
3
+ import { generateStyleGuide, readLocalStyleGuide, } from "../requirements/style-guide.js";
4
+ import { findProjectRoot, getProjectCredentials, } from "../utils/project-settings.js";
5
+ const CONVEX_URL = "https://data.dotrequirements.io";
6
+ export async function createRequirementDocumentCommand(filePath) {
7
+ const workspaceRoot = process.cwd();
8
+ // CLI-CREATE-DOC-1.1 / .2: discover existing patterns from the workspace.
9
+ // Best-effort — if the workspace has no requirements yet, we just have
10
+ // an empty pattern set.
11
+ let requirements = [];
12
+ try {
13
+ const result = await loadAllRequirements(workspaceRoot);
14
+ requirements = result.flattened;
15
+ }
16
+ catch {
17
+ // No requirements found — generateStyleGuide handles empty input
18
+ }
19
+ // CLI-CREATE-DOC-1.4 / .5: optional cloud-side custom style guidance.
20
+ // Silently skipped if the project isn't linked or the cloud is unavailable.
21
+ let customStyleGuidance = null;
22
+ const projectRoot = findProjectRoot(workspaceRoot);
23
+ if (projectRoot) {
24
+ try {
25
+ const { projectId, projectSecret } = getProjectCredentials(workspaceRoot);
26
+ const contextData = await getProjectContext(projectId, projectSecret, CONVEX_URL);
27
+ customStyleGuidance = contextData?.requirementsStyleContext ?? null;
28
+ }
29
+ catch {
30
+ // Not linked or cloud unavailable — fall through with defaults
31
+ }
32
+ }
33
+ const localStyleGuide = readLocalStyleGuide(workspaceRoot);
34
+ console.log(generateStyleGuide({
35
+ requirements,
36
+ customStyleGuidance,
37
+ filePath,
38
+ localStyleGuide,
39
+ }));
40
+ }
41
+ //# sourceMappingURL=create-requirement-document.js.map
@@ -1,8 +1,8 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
- import { finalize } from '../harness/finalize.js';
4
- import { findRequirementsDir, isCacheStale } from '../harness/cache.js';
5
- import { findProjectRoot } from '../utils/project-settings.js';
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+ import { findRequirementsDir, isCacheStale } from "../harness/cache.js";
4
+ import { finalize } from "../harness/finalize.js";
5
+ import { findProjectRoot } from "../utils/project-settings.js";
6
6
  export async function finalizeCommand(options) {
7
7
  // Warn if cache is stale before finalizing
8
8
  if (!options.quiet) {
@@ -10,11 +10,11 @@ export async function finalizeCommand(options) {
10
10
  if (projectRoot) {
11
11
  const requirementsDir = findRequirementsDir(projectRoot);
12
12
  if (requirementsDir) {
13
- const lookupPath = path.join(requirementsDir, '.cache', 'lookup.json');
13
+ const lookupPath = path.join(requirementsDir, ".cache", "lookup.json");
14
14
  try {
15
15
  const cacheStat = fs.statSync(lookupPath);
16
16
  if (isCacheStale(requirementsDir, cacheStat.mtimeMs)) {
17
- console.error('Warning: Cache may be stale — requirements have changed since last prepare. Run "dotrequirements prepare" to rebuild.\n');
17
+ console.error('Warning: Cache may be stale — requirements have changed since last prepare. Run "dotrequirements harness prepare" to rebuild.\n');
18
18
  }
19
19
  }
20
20
  catch {
@@ -0,0 +1,2 @@
1
+ export declare function getCommand(id: string): Promise<void>;
2
+ //# sourceMappingURL=get.d.ts.map
@@ -0,0 +1,55 @@
1
+ import { glob } from "glob";
2
+ import { formatRequirementTree, getRequirementTree, loadAllRequirements, } from "../requirements/index.js";
3
+ import { findFilesWithRequirement, findTestCodeForRequirement, } from "../requirements/testCodeExtractor.js";
4
+ export async function getCommand(id) {
5
+ const workspaceRoot = process.cwd();
6
+ const { flattened } = await loadAllRequirements(workspaceRoot);
7
+ const tree = getRequirementTree(flattened, id);
8
+ // CLI-FIND-GET-1.2: missing ID → error + non-zero exit
9
+ if (tree.length === 0) {
10
+ throw new Error(`Requirement "${id}" not found`);
11
+ }
12
+ const root = tree[0];
13
+ // CLI-FIND-GET-1.0 / 1.1: print the tree (root or subtree)
14
+ console.log(`${id}`);
15
+ console.log(` Document: ${root.documentTitle}`);
16
+ console.log(` Source: ${root.sourceFile}`);
17
+ console.log();
18
+ console.log(formatRequirementTree(tree));
19
+ console.log();
20
+ // CLI-FIND-GET-1.3 / 1.4: print test references + code snippets
21
+ const testFiles = await glob("**/*.{test,spec}.{js,jsx,ts,tsx}", {
22
+ cwd: workspaceRoot,
23
+ absolute: true,
24
+ ignore: ["**/node_modules/**", "**/dist/**", "**/build/**"],
25
+ });
26
+ const matchingFiles = findFilesWithRequirement(testFiles, id);
27
+ const testCodeSections = [];
28
+ for (const file of matchingFiles) {
29
+ const testRefs = findTestCodeForRequirement(file, id);
30
+ // Deduplicate nested blocks — keep only outermost
31
+ const deduplicated = testRefs.filter((ref, i) => {
32
+ const isNested = testRefs.some((other, j) => {
33
+ if (i === j)
34
+ return false;
35
+ return (other.startLine <= ref.startLine &&
36
+ other.endLine >= ref.endLine &&
37
+ (other.startLine < ref.startLine || other.endLine > ref.endLine));
38
+ });
39
+ return !isNested;
40
+ });
41
+ testCodeSections.push(...deduplicated);
42
+ }
43
+ // CLI-FIND-GET-1.5: explicit "no tests" message
44
+ if (testCodeSections.length === 0) {
45
+ console.log("Test Coverage: No tests found referencing this requirement.");
46
+ return;
47
+ }
48
+ console.log(`Test Coverage (${testCodeSections.length} reference(s)):\n`);
49
+ for (const ref of testCodeSections) {
50
+ console.log(`${ref.requirementId} — ${ref.file}:${ref.startLine}-${ref.endLine}`);
51
+ console.log(ref.code);
52
+ console.log();
53
+ }
54
+ }
55
+ //# sourceMappingURL=get.js.map