@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,130 @@
1
+ /**
2
+ * Local schema validation for a partial-spec file.
3
+ *
4
+ * Mirrors the existing `dotrequirements validate` path (and the
5
+ * `mcp__dotrequirements__validate_requirements` MCP tool), but works on
6
+ * partial files — which lack YAML frontmatter — by synthesizing a minimal
7
+ * wrapper before running the canonical parser.
8
+ *
9
+ * This is a deterministic syntax check: it catches things like missing
10
+ * `→`/`->` arrows, malformed position paths, indentation/position mismatches,
11
+ * and duplicate IDs — things the AI-driven style-check is not guaranteed
12
+ * to notice.
13
+ *
14
+ * Convention from CLAUDE.md: validate before style-check. Validate is the
15
+ * cheap, deterministic gate; style-check is the AI clarity pass.
16
+ *
17
+ * Requirements covered:
18
+ * - CTS-SPEC-3: Specifier worker runs a local schema validator on its draft,
19
+ * then a local style-check, applying feedback from each.
20
+ */
21
+ import { readFileSync } from "node:fs";
22
+ import { parseRequirementsFile } from "../schema/parser.js";
23
+ import { ValidationError } from "../schema/schemas.js";
24
+ /**
25
+ * Wrap a partial in a synthetic frontmatter envelope so the canonical
26
+ * Markdown-with-frontmatter parser can validate it.
27
+ */
28
+ function wrapPartial(partialBody) {
29
+ return [
30
+ "---",
31
+ "document:",
32
+ ' title: "Codebase-to-spec partial"',
33
+ "---",
34
+ "",
35
+ partialBody,
36
+ ].join("\n");
37
+ }
38
+ /**
39
+ * Validate a partial-spec file. Reads the file, synthesizes a frontmatter
40
+ * envelope, and delegates to the canonical parser. Errors are surfaced as
41
+ * a single human-readable string so the calling agent can act on them as
42
+ * MUST FIX items.
43
+ */
44
+ export function runValidate(options) {
45
+ let content;
46
+ try {
47
+ content = readFileSync(options.partialPath, "utf-8");
48
+ }
49
+ catch (err) {
50
+ return {
51
+ ok: false,
52
+ error: `Could not read ${options.partialPath}: ${err instanceof Error ? err.message : String(err)}`,
53
+ };
54
+ }
55
+ // Sanity check: the partial should contain at least one fenced
56
+ // dotrequirements block. A partial with no blocks is also a syntax error
57
+ // worth surfacing as MUST FIX.
58
+ if (!/```dotrequirements\s/.test(content)) {
59
+ return {
60
+ ok: false,
61
+ error: "No `dotrequirements` fenced code blocks found in partial. Every requirement must live inside a ```dotrequirements ... ``` block.",
62
+ };
63
+ }
64
+ try {
65
+ const parsed = parseRequirementsFile(wrapPartial(content));
66
+ return {
67
+ ok: true,
68
+ requirementCount: parsed.requirements.length,
69
+ };
70
+ }
71
+ catch (err) {
72
+ return {
73
+ ok: false,
74
+ error: describeValidationError(err),
75
+ };
76
+ }
77
+ }
78
+ /**
79
+ * The canonical parser wraps low-level failures (e.g. "Each criterion line
80
+ * must contain the delimiter `->` or `→`") inside a high-level ValidationError
81
+ * (e.g. "Failed to parse requirement FOO-001"). We want both — the high-level
82
+ * context tells the agent which block to fix, the low-level reason tells it
83
+ * what to fix.
84
+ */
85
+ function describeValidationError(err) {
86
+ if (err instanceof ValidationError) {
87
+ const parts = [err.message];
88
+ let cursor = err.cause;
89
+ while (cursor instanceof Error) {
90
+ // Don't repeat the same message twice if the wrapper just rethrew.
91
+ if (cursor.message && cursor.message !== parts[parts.length - 1]) {
92
+ parts.push(cursor.message);
93
+ }
94
+ cursor = cursor.cause;
95
+ }
96
+ return parts.join(" — ");
97
+ }
98
+ if (err instanceof Error) {
99
+ return err.message;
100
+ }
101
+ return String(err);
102
+ }
103
+ /**
104
+ * Format a ValidateResult as the Markdown feedback block the specifier
105
+ * agent reads on stdout. Mirrors the severity-categorized shape produced
106
+ * by `runStyleCheck`, so the prompt can describe them uniformly.
107
+ */
108
+ export function formatValidateFeedback(result) {
109
+ if (result.ok) {
110
+ return [
111
+ "# Schema validation: PASS",
112
+ "",
113
+ `${result.requirementCount ?? 0} requirement block(s) parsed cleanly.`,
114
+ "",
115
+ "No syntax issues. Proceed to the style-check step.",
116
+ "",
117
+ ].join("\n");
118
+ }
119
+ return [
120
+ "# Schema validation: FAIL",
121
+ "",
122
+ "## MUST FIX",
123
+ "",
124
+ `- ${result.error}`,
125
+ "",
126
+ "Fix the syntax issue above with the Edit tool, then re-run validate.",
127
+ "",
128
+ ].join("\n");
129
+ }
130
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1,6 @@
1
+ interface AcceptanceTestOptions {
2
+ json?: boolean;
3
+ }
4
+ export declare function acceptanceTestCommand(requirementKey: string, url: string | undefined, options: AcceptanceTestOptions): Promise<void>;
5
+ export {};
6
+ //# sourceMappingURL=acceptance-test.d.ts.map
@@ -0,0 +1,212 @@
1
+ import { execFile } from "node:child_process";
2
+ import { promisify } from "node:util";
3
+ import { formatRequirement, getRequirementTree, loadAllRequirements, } from "../requirements/index.js";
4
+ import { getProjectInfo, readProjectSettings, } from "../utils/project-settings.js";
5
+ const execFileAsync = promisify(execFile);
6
+ function extractResults(parsed) {
7
+ if (Array.isArray(parsed))
8
+ return parsed;
9
+ if (parsed && typeof parsed === "object") {
10
+ const obj = parsed;
11
+ // { results: [...] } format
12
+ if (Array.isArray(obj.results))
13
+ return obj.results;
14
+ // { structured_output: { results: [...] } } format
15
+ if (obj.structured_output && typeof obj.structured_output === "object") {
16
+ const so = obj.structured_output;
17
+ if (Array.isArray(so.results))
18
+ return so.results;
19
+ }
20
+ }
21
+ throw new Error("Unexpected browser-automation output format");
22
+ }
23
+ export async function acceptanceTestCommand(requirementKey, url, options) {
24
+ // 1. Find project and load settings
25
+ const projectInfo = getProjectInfo();
26
+ if (!projectInfo) {
27
+ console.error("Error: No dotrequirements project found.");
28
+ console.log('Run "dotrequirements init" to create one.');
29
+ process.exit(1);
30
+ }
31
+ let settings;
32
+ try {
33
+ settings = readProjectSettings(projectInfo.rootPath);
34
+ }
35
+ catch (err) {
36
+ // Settings file exists but is invalid
37
+ console.error(`Error: ${err.message}`);
38
+ process.exit(1);
39
+ }
40
+ // 2. Determine URL
41
+ const targetURL = url || settings?.defaultURL;
42
+ if (!targetURL) {
43
+ console.error("Error: No URL provided and no defaultURL in project-settings.json.");
44
+ console.log('Either provide a URL argument or add "defaultURL" to .requirements/project-settings.json');
45
+ process.exit(1);
46
+ }
47
+ // 3. Resolve model config
48
+ const modelName = settings?.browserTest?.modelName;
49
+ const modelApiKey = settings?.browserTest?.modelApiKey;
50
+ const geminiApiKey = settings?.browserTest?.geminiApiKey;
51
+ if (!modelName && !modelApiKey && !geminiApiKey) {
52
+ console.error("Error: no browser-test model configured in project-settings.json.");
53
+ console.log("Add a block like:\n" +
54
+ ' "browserTest": {\n' +
55
+ ' "modelName": "gateway/anthropic/claude-haiku-4-5",\n' +
56
+ ' "modelApiKey": "..."\n' +
57
+ " }\n" +
58
+ "to .requirements/project-settings.json. See the docs for supported models.");
59
+ process.exit(1);
60
+ }
61
+ if ((modelName && !modelApiKey) || (modelApiKey && !modelName)) {
62
+ console.error("Error: browserTest.modelName and browserTest.modelApiKey must be set together.");
63
+ process.exit(1);
64
+ }
65
+ // 4. Load requirements
66
+ const { flattened } = await loadAllRequirements(projectInfo.rootPath);
67
+ if (flattened.length === 0) {
68
+ console.error("Error: No requirements found in .requirements/");
69
+ process.exit(1);
70
+ }
71
+ // 5. Find the requirement tree
72
+ const requirementTree = getRequirementTree(flattened, requirementKey);
73
+ if (requirementTree.length === 0) {
74
+ console.error(`Error: Requirement "${requirementKey}" not found.`);
75
+ process.exit(1);
76
+ }
77
+ // 6. Format each requirement as an assertion
78
+ const assertions = requirementTree.map((req) => formatRequirement(req));
79
+ // 7. Build environment with injected secrets
80
+ const env = { ...process.env };
81
+ // env var keeps the key out of process listings (not a CLI flag)
82
+ if (modelApiKey) {
83
+ env.MODEL_API_KEY = modelApiKey;
84
+ }
85
+ else if (geminiApiKey) {
86
+ env.GEMINI_API_KEY = geminiApiKey;
87
+ }
88
+ if (settings?.browserTest?.vercelBypassSecret) {
89
+ env.VERCEL_AUTOMATION_BYPASS_SECRET =
90
+ settings.browserTest.vercelBypassSecret;
91
+ }
92
+ if (settings?.browserTest?.browserbaseApiKey) {
93
+ env.BROWSERBASE_API_KEY = settings.browserTest.browserbaseApiKey;
94
+ }
95
+ if (settings?.browserTest?.browserbaseProjectId) {
96
+ env.BROWSERBASE_PROJECT_ID = settings.browserTest.browserbaseProjectId;
97
+ }
98
+ // 8. Run browser-automation
99
+ if (!options.json) {
100
+ console.log(`Testing ${requirementKey} against ${targetURL}...\n`);
101
+ }
102
+ try {
103
+ const modelFlags = modelName ? ["--modelName", modelName] : [];
104
+ const { stdout } = await execFileAsync("npx", [
105
+ "@popoverai/browser-automation",
106
+ "test",
107
+ ...modelFlags,
108
+ targetURL,
109
+ ...assertions,
110
+ ], { env, maxBuffer: 10 * 1024 * 1024 });
111
+ // 9. Parse results
112
+ let results;
113
+ try {
114
+ const parsed = JSON.parse(stdout.trim());
115
+ results = extractResults(parsed);
116
+ }
117
+ catch (parseErr) {
118
+ console.error("Error: Could not parse browser-automation output");
119
+ console.error(parseErr.message);
120
+ console.error(stdout);
121
+ process.exit(1);
122
+ }
123
+ // 10. Display results
124
+ if (options.json) {
125
+ outputJson(requirementTree, results);
126
+ }
127
+ else {
128
+ displayResults(requirementTree, results);
129
+ }
130
+ // 11. Exit with appropriate code
131
+ const failedCount = results.filter((r) => r.status !== "passed").length;
132
+ if (failedCount > 0) {
133
+ process.exit(1);
134
+ }
135
+ }
136
+ catch (err) {
137
+ const error = err;
138
+ // browser-automation returns exit code 1 on failure, but still outputs JSON
139
+ if (error.stdout) {
140
+ try {
141
+ const parsed = JSON.parse(error.stdout.trim());
142
+ const results = extractResults(parsed);
143
+ if (options.json) {
144
+ outputJson(requirementTree, results);
145
+ }
146
+ else {
147
+ displayResults(requirementTree, results);
148
+ }
149
+ process.exit(1);
150
+ }
151
+ catch {
152
+ // Not JSON, show raw output
153
+ console.error("browser-automation error:");
154
+ if (error.stdout)
155
+ console.error(error.stdout);
156
+ if (error.stderr)
157
+ console.error(error.stderr);
158
+ process.exit(1);
159
+ }
160
+ }
161
+ else {
162
+ console.error(`Error running browser-automation: ${error.message}`);
163
+ if (error.stderr)
164
+ console.error(error.stderr);
165
+ process.exit(1);
166
+ }
167
+ }
168
+ }
169
+ function displayResults(requirements, results) {
170
+ let passedCount = 0;
171
+ let failedCount = 0;
172
+ for (let i = 0; i < requirements.length; i++) {
173
+ const req = requirements[i];
174
+ const result = results[i];
175
+ if (!result) {
176
+ console.log(` ? ${req.id}: No result`);
177
+ failedCount++;
178
+ continue;
179
+ }
180
+ const indent = " ".repeat(req.path.length);
181
+ const label = req.label ? ` (${req.label})` : "";
182
+ const icon = result.status === "passed" ? "\u2713" : "\u2717";
183
+ console.log(`${indent}${icon} ${req.id}${label}: ${req.content}`);
184
+ if (result.status !== "passed" && result.notes) {
185
+ console.log(`${indent} \u2192 ${result.notes}`);
186
+ }
187
+ if (result.status === "passed") {
188
+ passedCount++;
189
+ }
190
+ else {
191
+ failedCount++;
192
+ }
193
+ }
194
+ console.log();
195
+ if (failedCount === 0) {
196
+ console.log(`${passedCount}/${requirements.length} passed`);
197
+ }
198
+ else {
199
+ console.log(`${passedCount}/${requirements.length} passed, ${failedCount} failed`);
200
+ }
201
+ }
202
+ function outputJson(requirements, results) {
203
+ const combined = requirements.map((req, i) => ({
204
+ id: req.id,
205
+ label: req.label || null,
206
+ content: req.content,
207
+ status: results[i]?.status || "blocked",
208
+ notes: results[i]?.notes || null,
209
+ }));
210
+ console.log(JSON.stringify(combined, null, 2));
211
+ }
212
+ //# sourceMappingURL=acceptance-test.js.map
@@ -0,0 +1,5 @@
1
+ /**
2
+ * AI setup command - configures the MCP server for AI assistants
3
+ */
4
+ export declare function aiSetupCommand(): Promise<void>;
5
+ //# sourceMappingURL=ai-setup.d.ts.map