@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.
- package/README.md +169 -22
- package/dist/cli.js +121 -60
- package/dist/codebase-to-spec/budget.d.ts +53 -0
- package/dist/codebase-to-spec/budget.js +80 -0
- package/dist/codebase-to-spec/cache.d.ts +49 -0
- package/dist/codebase-to-spec/cache.js +54 -0
- package/dist/codebase-to-spec/claude.d.ts +69 -0
- package/dist/codebase-to-spec/claude.js +126 -0
- package/dist/codebase-to-spec/compose.d.ts +49 -0
- package/dist/codebase-to-spec/compose.js +124 -0
- package/dist/codebase-to-spec/edit-loop.d.ts +54 -0
- package/dist/codebase-to-spec/edit-loop.js +195 -0
- package/dist/codebase-to-spec/editor.d.ts +54 -0
- package/dist/codebase-to-spec/editor.js +74 -0
- package/dist/codebase-to-spec/exit-codes.d.ts +40 -0
- package/dist/codebase-to-spec/exit-codes.js +58 -0
- package/dist/codebase-to-spec/fan-out.d.ts +63 -0
- package/dist/codebase-to-spec/fan-out.js +215 -0
- package/dist/codebase-to-spec/interactive.d.ts +30 -0
- package/dist/codebase-to-spec/interactive.js +48 -0
- package/dist/codebase-to-spec/outline-review-loop.d.ts +51 -0
- package/dist/codebase-to-spec/outline-review-loop.js +187 -0
- package/dist/codebase-to-spec/pack.d.ts +51 -0
- package/dist/codebase-to-spec/pack.js +127 -0
- package/dist/codebase-to-spec/planner.d.ts +41 -0
- package/dist/codebase-to-spec/planner.js +76 -0
- package/dist/codebase-to-spec/present.d.ts +94 -0
- package/dist/codebase-to-spec/present.js +288 -0
- package/dist/codebase-to-spec/progress.d.ts +33 -0
- package/dist/codebase-to-spec/progress.js +28 -0
- package/dist/codebase-to-spec/prompts/editor.d.ts +13 -0
- package/dist/codebase-to-spec/prompts/editor.js +57 -0
- package/dist/codebase-to-spec/prompts/outline-reviewer.d.ts +12 -0
- package/dist/codebase-to-spec/prompts/outline-reviewer.js +87 -0
- package/dist/codebase-to-spec/prompts/planner-initial.d.ts +11 -0
- package/dist/codebase-to-spec/prompts/planner-initial.js +125 -0
- package/dist/codebase-to-spec/prompts/planner-revise.d.ts +14 -0
- package/dist/codebase-to-spec/prompts/planner-revise.js +60 -0
- package/dist/codebase-to-spec/prompts/spec-reviewer.d.ts +16 -0
- package/dist/codebase-to-spec/prompts/spec-reviewer.js +96 -0
- package/dist/codebase-to-spec/prompts/specifier.d.ts +12 -0
- package/dist/codebase-to-spec/prompts/specifier.js +100 -0
- package/dist/codebase-to-spec/prompts/style-check.d.ts +12 -0
- package/dist/codebase-to-spec/prompts/style-check.js +78 -0
- package/dist/codebase-to-spec/schemas.d.ts +257 -0
- package/dist/codebase-to-spec/schemas.js +183 -0
- package/dist/codebase-to-spec/skill-install.d.ts +57 -0
- package/dist/codebase-to-spec/skill-install.js +79 -0
- package/dist/codebase-to-spec/slice.d.ts +49 -0
- package/dist/codebase-to-spec/slice.js +111 -0
- package/dist/codebase-to-spec/specifier.d.ts +60 -0
- package/dist/codebase-to-spec/specifier.js +79 -0
- package/dist/codebase-to-spec/style-check.d.ts +29 -0
- package/dist/codebase-to-spec/style-check.js +33 -0
- package/dist/codebase-to-spec/summary.d.ts +51 -0
- package/dist/codebase-to-spec/summary.js +183 -0
- package/dist/codebase-to-spec/validate.d.ts +46 -0
- package/dist/codebase-to-spec/validate.js +130 -0
- package/dist/commands/acceptance-test.d.ts +6 -0
- package/dist/commands/{browsertest.js → acceptance-test.js} +36 -29
- package/dist/commands/ai-setup.d.ts +5 -0
- package/dist/commands/ai-setup.js +441 -0
- package/dist/commands/codebase-to-spec/compose.d.ts +14 -0
- package/dist/commands/codebase-to-spec/compose.js +57 -0
- package/dist/commands/codebase-to-spec/edit-loop.d.ts +16 -0
- package/dist/commands/codebase-to-spec/edit-loop.js +83 -0
- package/dist/commands/codebase-to-spec/fan-out.d.ts +19 -0
- package/dist/commands/codebase-to-spec/fan-out.js +77 -0
- package/dist/commands/codebase-to-spec/index.d.ts +9 -0
- package/dist/commands/codebase-to-spec/index.js +135 -0
- package/dist/commands/codebase-to-spec/pack.d.ts +22 -0
- package/dist/commands/codebase-to-spec/pack.js +76 -0
- package/dist/commands/codebase-to-spec/plan-loop.d.ts +26 -0
- package/dist/commands/codebase-to-spec/plan-loop.js +105 -0
- package/dist/commands/codebase-to-spec/present.d.ts +21 -0
- package/dist/commands/codebase-to-spec/present.js +92 -0
- package/dist/commands/codebase-to-spec/run.d.ts +20 -0
- package/dist/commands/codebase-to-spec/run.js +85 -0
- package/dist/commands/codebase-to-spec/skill-install.d.ts +20 -0
- package/dist/commands/codebase-to-spec/skill-install.js +51 -0
- package/dist/commands/codebase-to-spec/specify-area.d.ts +18 -0
- package/dist/commands/codebase-to-spec/specify-area.js +82 -0
- package/dist/commands/codebase-to-spec/style-check.d.ts +15 -0
- package/dist/commands/codebase-to-spec/style-check.js +42 -0
- package/dist/commands/codebase-to-spec/validate.d.ts +18 -0
- package/dist/commands/codebase-to-spec/validate.js +38 -0
- package/dist/commands/create-requirement-document.d.ts +2 -0
- package/dist/commands/create-requirement-document.js +41 -0
- package/dist/commands/finalize.js +7 -7
- package/dist/commands/get.d.ts +2 -0
- package/dist/commands/get.js +55 -0
- package/dist/commands/init.js +132 -117
- package/dist/commands/link.js +27 -27
- package/dist/commands/list.d.ts +6 -0
- package/dist/commands/list.js +43 -0
- package/dist/commands/mcp.js +1 -1
- package/dist/commands/prepare.js +4 -4
- package/dist/commands/pull.js +116 -121
- package/dist/commands/push.js +106 -112
- package/dist/commands/report.d.ts +6 -2
- package/dist/commands/report.js +177 -122
- package/dist/commands/requirements-for.d.ts +2 -0
- package/dist/commands/requirements-for.js +29 -0
- package/dist/commands/review-test.d.ts +2 -0
- package/dist/commands/review-test.js +75 -0
- package/dist/commands/search.d.ts +6 -0
- package/dist/commands/search.js +39 -0
- package/dist/commands/style-check.d.ts +7 -0
- package/dist/commands/style-check.js +75 -0
- package/dist/commands/tests-for.d.ts +2 -0
- package/dist/commands/tests-for.js +80 -0
- package/dist/commands/validate.d.ts +6 -0
- package/dist/commands/validate.js +72 -0
- package/dist/config.js +1 -1
- package/dist/convex.d.ts +34 -22
- package/dist/convex.js +38 -22
- package/dist/harness/cache.d.ts +1 -5
- package/dist/harness/cache.js +49 -59
- package/dist/harness/convexReporting.d.ts +1 -1
- package/dist/harness/convexReporting.js +9 -7
- package/dist/harness/coverageCache.js +3 -3
- package/dist/harness/finalize.js +59 -46
- package/dist/harness/index.d.ts +6 -7
- package/dist/harness/index.js +9 -10
- package/dist/harness/prepare.js +6 -5
- package/dist/harness/requirementsLoader.d.ts +2 -2
- package/dist/harness/requirementsLoader.js +13 -35
- package/dist/harness/tracking.js +18 -18
- package/dist/harness/types.d.ts +1 -1
- package/dist/mcp/convexClient.d.ts +0 -39
- package/dist/mcp/convexClient.js +2 -107
- package/dist/mcp/handlers/authoring.d.ts +1 -1
- package/dist/mcp/handlers/authoring.js +30 -234
- package/dist/mcp/handlers/debug.d.ts +2 -3
- package/dist/mcp/handlers/debug.js +10 -10
- package/dist/mcp/handlers/get.d.ts +1 -1
- package/dist/mcp/handlers/get.js +11 -10
- package/dist/mcp/handlers/index.d.ts +20 -20
- package/dist/mcp/handlers/index.js +10 -10
- package/dist/mcp/handlers/list.d.ts +4 -33
- package/dist/mcp/handlers/list.js +16 -38
- package/dist/mcp/handlers/push.d.ts +1 -1
- package/dist/mcp/handlers/push.js +28 -18
- package/dist/mcp/handlers/report.d.ts +16 -0
- package/dist/mcp/handlers/report.js +134 -0
- package/dist/mcp/handlers/review.d.ts +1 -1
- package/dist/mcp/handlers/review.js +40 -59
- package/dist/mcp/handlers/search.d.ts +1 -1
- package/dist/mcp/handlers/search.js +7 -9
- package/dist/mcp/handlers/test-mapping.d.ts +1 -1
- package/dist/mcp/handlers/test-mapping.js +14 -14
- package/dist/mcp/handlers/types.d.ts +3 -3
- package/dist/mcp/handlers/types.js +2 -2
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +147 -167
- package/dist/push/core.d.ts +2 -2
- package/dist/push/core.js +20 -20
- package/dist/push/index.d.ts +1 -1
- package/dist/push/index.js +2 -2
- package/dist/requirements/cloud-ai.d.ts +57 -0
- package/dist/requirements/cloud-ai.js +104 -0
- package/dist/requirements/cloud-coverage.d.ts +41 -0
- package/dist/requirements/cloud-coverage.js +60 -0
- package/dist/requirements/coverage.d.ts +45 -0
- package/dist/requirements/coverage.js +114 -0
- package/dist/{mcp → requirements}/grep.d.ts +10 -1
- package/dist/{mcp → requirements}/grep.js +89 -44
- package/dist/{mcp/requirements.d.ts → requirements/index.d.ts} +19 -3
- package/dist/{mcp/requirements.js → requirements/index.js} +54 -35
- package/dist/requirements/style-guide.d.ts +67 -0
- package/dist/requirements/style-guide.js +299 -0
- package/dist/{mcp → requirements}/testCodeExtractor.js +24 -26
- package/dist/schema/browser.d.ts +8 -8
- package/dist/schema/browser.js +13 -15
- package/dist/schema/builder.d.ts +1 -1
- package/dist/schema/builder.js +13 -44
- package/dist/schema/conversions.d.ts +2 -2
- package/dist/schema/conversions.js +11 -11
- package/dist/schema/index.d.ts +9 -9
- package/dist/schema/index.js +15 -15
- package/dist/schema/parser-core.d.ts +1 -1
- package/dist/schema/parser-core.js +23 -22
- package/dist/schema/parser.d.ts +3 -3
- package/dist/schema/parser.js +27 -31
- package/dist/schema/resolver.d.ts +1 -1
- package/dist/schema/resolver.js +9 -9
- package/dist/schema/scenario.d.ts +1 -1
- package/dist/schema/scenario.js +1 -1
- package/dist/schema/schemas.d.ts +3 -3
- package/dist/schema/schemas.js +41 -28
- package/dist/schema/test-schema.js +27 -27
- package/dist/templates/context-file-section.md +3 -2
- package/dist/templates/example-requirements.js +1 -1
- package/dist/templates/example-requirements.ts +3 -1
- package/dist/templates/requirements-readme.js +1 -1
- package/dist/templates/requirements-readme.ts +1 -1
- package/dist/templates/skills/codebase-to-spec/SKILL.md +118 -0
- package/dist/utils/brand.js +3 -3
- package/dist/utils/browser-launch.js +4 -4
- package/dist/utils/context-file.d.ts +1 -1
- package/dist/utils/context-file.js +26 -26
- package/dist/utils/env.js +7 -7
- package/dist/utils/gitignore.js +7 -7
- package/dist/utils/oauth-callback-server.d.ts +1 -1
- package/dist/utils/oauth-callback-server.js +27 -25
- package/dist/utils/oauth-flow.js +32 -29
- package/dist/utils/project-discovery.d.ts +3 -3
- package/dist/utils/project-discovery.js +18 -17
- package/dist/utils/project-name.js +8 -8
- package/dist/utils/project-selector.d.ts +1 -1
- package/dist/utils/project-selector.js +24 -21
- package/dist/utils/project-settings.d.ts +1 -1
- package/dist/utils/project-settings.js +24 -22
- package/dist/utils/templates.js +6 -6
- package/package.json +3 -2
- package/dist/commands/browsertest.d.ts +0 -6
- package/dist/commands/login.d.ts +0 -12
- package/dist/commands/login.js +0 -117
- package/dist/commands/logout.d.ts +0 -5
- package/dist/commands/logout.js +0 -17
- package/dist/commands/mcp-setup.d.ts +0 -5
- package/dist/commands/mcp-setup.js +0 -431
- package/dist/commands/test.d.ts +0 -6
- package/dist/commands/test.js +0 -78
- package/dist/mcp/handlers/coverage.d.ts +0 -44
- package/dist/mcp/handlers/coverage.js +0 -105
- package/dist/mcp/types.d.ts +0 -27
- package/dist/mcp/types.js +0 -2
- package/dist/utils/local-project.d.ts +0 -31
- package/dist/utils/local-project.js +0 -33
- package/dist/utils/token-refresh.d.ts +0 -24
- package/dist/utils/token-refresh.js +0 -69
- package/dist/utils/token-storage.d.ts +0 -31
- package/dist/utils/token-storage.js +0 -57
- /package/dist/{mcp → requirements}/testCodeExtractor.d.ts +0 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pipeline summary generation.
|
|
3
|
+
*
|
|
4
|
+
* Reads cached artifacts to assemble a structured summary of what the
|
|
5
|
+
* pipeline produced. Surfaced both as JSON (parseable by wrappers like the
|
|
6
|
+
* skill) and as a short human-readable block.
|
|
7
|
+
*
|
|
8
|
+
* Requirements covered:
|
|
9
|
+
* - CTS-PRESENT-4: Final pipeline summary is surfaced
|
|
10
|
+
* - CTS-OBSERVE-2 (partial): structured failure information available
|
|
11
|
+
*/
|
|
12
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
13
|
+
import { sanitizeAreaName } from "./fan-out.js";
|
|
14
|
+
import { parseOutlineReview, parseSpecReview, } from "./schemas.js";
|
|
15
|
+
/**
|
|
16
|
+
* Count top-level requirements in a file by counting fenced
|
|
17
|
+
* \`\`\`dotrequirements blocks. Each block represents one root requirement
|
|
18
|
+
* (CTS-OBSERVE-2 counts each requirement ID once, excluding child criteria).
|
|
19
|
+
*/
|
|
20
|
+
function countRequirementsInFile(path) {
|
|
21
|
+
if (!existsSync(path))
|
|
22
|
+
return 0;
|
|
23
|
+
const content = readFileSync(path, "utf-8");
|
|
24
|
+
const matches = content.match(/```dotrequirements\b/g);
|
|
25
|
+
return matches ? matches.length : 0;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Look at outline-review-N.json files in the cache and return how many turns
|
|
29
|
+
* ran and what the final verdict was. Returns {turnsUsed: 0, finalVerdict: null}
|
|
30
|
+
* if no review artifacts exist.
|
|
31
|
+
*/
|
|
32
|
+
function summarizeOutlineReview(paths) {
|
|
33
|
+
let n = 0;
|
|
34
|
+
let lastReviewPath = null;
|
|
35
|
+
while (true) {
|
|
36
|
+
const path = paths.outlineReviewTurn(n + 1);
|
|
37
|
+
if (!existsSync(path))
|
|
38
|
+
break;
|
|
39
|
+
n++;
|
|
40
|
+
lastReviewPath = path;
|
|
41
|
+
}
|
|
42
|
+
if (!lastReviewPath)
|
|
43
|
+
return { turnsUsed: 0, finalVerdict: null, residualNotes: [] };
|
|
44
|
+
try {
|
|
45
|
+
const review = parseOutlineReview(readFileSync(lastReviewPath, "utf-8"));
|
|
46
|
+
const notes = [];
|
|
47
|
+
// Surface unresolved findings as residual notes if verdict isn't 'approved'.
|
|
48
|
+
if (review.verdict !== "approved") {
|
|
49
|
+
for (const cat of [
|
|
50
|
+
["coverage_gap", review.coverage_gaps],
|
|
51
|
+
["framing_error", review.framing_errors],
|
|
52
|
+
["granularity", review.granularity_issues],
|
|
53
|
+
["file_assignment", review.file_assignment_issues],
|
|
54
|
+
]) {
|
|
55
|
+
for (const note of cat[1]) {
|
|
56
|
+
notes.push(`outline.${cat[0]}: ${note}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return { turnsUsed: n, finalVerdict: review.verdict, residualNotes: notes };
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
return { turnsUsed: n, finalVerdict: null, residualNotes: [] };
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function summarizeSpecReview(paths) {
|
|
67
|
+
let n = 0;
|
|
68
|
+
let lastReviewPath = null;
|
|
69
|
+
while (true) {
|
|
70
|
+
const path = paths.specReviewTurn(n + 1);
|
|
71
|
+
if (!existsSync(path))
|
|
72
|
+
break;
|
|
73
|
+
n++;
|
|
74
|
+
lastReviewPath = path;
|
|
75
|
+
}
|
|
76
|
+
if (!lastReviewPath)
|
|
77
|
+
return { turnsUsed: 0, finalVerdict: null, residualNotes: [] };
|
|
78
|
+
try {
|
|
79
|
+
const review = parseSpecReview(readFileSync(lastReviewPath, "utf-8"));
|
|
80
|
+
const notes = [];
|
|
81
|
+
if (review.verdict !== "approved") {
|
|
82
|
+
for (const cat of [
|
|
83
|
+
["coverage_gap", review.coverage_gaps],
|
|
84
|
+
["framing_error", review.framing_errors],
|
|
85
|
+
["cross_area", review.cross_area_issues],
|
|
86
|
+
["internal_mechanics", review.internal_mechanics_drift],
|
|
87
|
+
]) {
|
|
88
|
+
for (const note of cat[1]) {
|
|
89
|
+
notes.push(`spec.${cat[0]}: ${note}`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return { turnsUsed: n, finalVerdict: review.verdict, residualNotes: notes };
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return { turnsUsed: n, finalVerdict: null, residualNotes: [] };
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function summarizeSpecifiers(outline, paths) {
|
|
100
|
+
let completed = 0;
|
|
101
|
+
const missingAreas = [];
|
|
102
|
+
for (const area of outline.areas) {
|
|
103
|
+
const partialPath = paths.partial(sanitizeAreaName(area.name));
|
|
104
|
+
if (!existsSync(partialPath)) {
|
|
105
|
+
missingAreas.push(area.name);
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const content = readFileSync(partialPath, "utf-8").trim();
|
|
109
|
+
if (!content ||
|
|
110
|
+
content.startsWith("_(missing partial") ||
|
|
111
|
+
content.startsWith("_(no files")) {
|
|
112
|
+
missingAreas.push(area.name);
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
completed++;
|
|
116
|
+
}
|
|
117
|
+
return { completed, missing: missingAreas.length, missingAreas };
|
|
118
|
+
}
|
|
119
|
+
export function buildPipelineSummary(input) {
|
|
120
|
+
const { outline, paths, outputPaths } = input;
|
|
121
|
+
const outlineReview = summarizeOutlineReview(paths);
|
|
122
|
+
const specReview = summarizeSpecReview(paths);
|
|
123
|
+
const specifiers = summarizeSpecifiers(outline, paths);
|
|
124
|
+
// Count top-level requirements across all written .requirements/ files.
|
|
125
|
+
let totalRequirements = 0;
|
|
126
|
+
for (const path of outputPaths) {
|
|
127
|
+
totalRequirements += countRequirementsInFile(path);
|
|
128
|
+
}
|
|
129
|
+
// Fall back to counting the final cached spec if nothing was written (e.g.
|
|
130
|
+
// dry-run / interrupted) — that way the summary still reflects what the
|
|
131
|
+
// pipeline produced.
|
|
132
|
+
if (totalRequirements === 0 && existsSync(paths.specFinal)) {
|
|
133
|
+
totalRequirements = countRequirementsInFile(paths.specFinal);
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
totalAreas: outline.areas.length,
|
|
137
|
+
totalRequirements,
|
|
138
|
+
outline: outlineReview,
|
|
139
|
+
specifiers,
|
|
140
|
+
specReview,
|
|
141
|
+
outputs: { paths: outputPaths },
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Render a short human-readable block for the summary. Designed to fit on a
|
|
146
|
+
* small number of lines (CTS-PRESENT-4.2). Wrappers that want richer
|
|
147
|
+
* presentation can read the JSON form instead.
|
|
148
|
+
*/
|
|
149
|
+
export function renderSummaryText(summary) {
|
|
150
|
+
const lines = [];
|
|
151
|
+
lines.push(`Pipeline summary:`);
|
|
152
|
+
lines.push(` Areas: ${summary.totalAreas}`);
|
|
153
|
+
lines.push(` Top-level reqs: ${summary.totalRequirements}`);
|
|
154
|
+
lines.push(` Outline review: ${summary.outline.turnsUsed} turn(s), verdict: ${summary.outline.finalVerdict ?? "n/a"}`);
|
|
155
|
+
lines.push(` Specifiers: ${summary.specifiers.completed} completed, ${summary.specifiers.missing} missing`);
|
|
156
|
+
lines.push(` Spec review: ${summary.specReview.turnsUsed} turn(s), verdict: ${summary.specReview.finalVerdict ?? "n/a"}`);
|
|
157
|
+
lines.push(` Output files:`);
|
|
158
|
+
for (const path of summary.outputs.paths) {
|
|
159
|
+
lines.push(` - ${path}`);
|
|
160
|
+
}
|
|
161
|
+
if (summary.outline.residualNotes.length ||
|
|
162
|
+
summary.specReview.residualNotes.length) {
|
|
163
|
+
lines.push(``);
|
|
164
|
+
lines.push(` Residual notes (worth reviewing manually):`);
|
|
165
|
+
for (const note of [
|
|
166
|
+
...summary.outline.residualNotes,
|
|
167
|
+
...summary.specReview.residualNotes,
|
|
168
|
+
]) {
|
|
169
|
+
lines.push(` - ${note}`);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (summary.specifiers.missingAreas.length) {
|
|
173
|
+
lines.push(``);
|
|
174
|
+
lines.push(` Missing specifier output for:`);
|
|
175
|
+
for (const area of summary.specifiers.missingAreas) {
|
|
176
|
+
lines.push(` - ${area}`);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return lines.join("\n");
|
|
180
|
+
}
|
|
181
|
+
/** Suppress unused-var warning. */
|
|
182
|
+
void statSync;
|
|
183
|
+
//# sourceMappingURL=summary.js.map
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
export interface ValidateOptions {
|
|
22
|
+
/** Path to the partial-spec file to validate. */
|
|
23
|
+
partialPath: string;
|
|
24
|
+
}
|
|
25
|
+
export interface ValidateResult {
|
|
26
|
+
/** True if the partial parsed cleanly. */
|
|
27
|
+
ok: boolean;
|
|
28
|
+
/** Human-readable error message when `ok === false`. */
|
|
29
|
+
error?: string;
|
|
30
|
+
/** Number of requirement blocks found (when `ok === true`). */
|
|
31
|
+
requirementCount?: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Validate a partial-spec file. Reads the file, synthesizes a frontmatter
|
|
35
|
+
* envelope, and delegates to the canonical parser. Errors are surfaced as
|
|
36
|
+
* a single human-readable string so the calling agent can act on them as
|
|
37
|
+
* MUST FIX items.
|
|
38
|
+
*/
|
|
39
|
+
export declare function runValidate(options: ValidateOptions): ValidateResult;
|
|
40
|
+
/**
|
|
41
|
+
* Format a ValidateResult as the Markdown feedback block the specifier
|
|
42
|
+
* agent reads on stdout. Mirrors the severity-categorized shape produced
|
|
43
|
+
* by `runStyleCheck`, so the prompt can describe them uniformly.
|
|
44
|
+
*/
|
|
45
|
+
export declare function formatValidateFeedback(result: ValidateResult): string;
|
|
46
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -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
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { execFile } from
|
|
2
|
-
import { promisify } from
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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
5
|
const execFileAsync = promisify(execFile);
|
|
6
6
|
function extractResults(parsed) {
|
|
7
7
|
if (Array.isArray(parsed))
|
|
8
8
|
return parsed;
|
|
9
|
-
if (parsed && typeof parsed ===
|
|
9
|
+
if (parsed && typeof parsed === "object") {
|
|
10
10
|
const obj = parsed;
|
|
11
11
|
// { results: [...] } format
|
|
12
12
|
if (Array.isArray(obj.results))
|
|
13
13
|
return obj.results;
|
|
14
14
|
// { structured_output: { results: [...] } } format
|
|
15
|
-
if (obj.structured_output && typeof obj.structured_output ===
|
|
15
|
+
if (obj.structured_output && typeof obj.structured_output === "object") {
|
|
16
16
|
const so = obj.structured_output;
|
|
17
17
|
if (Array.isArray(so.results))
|
|
18
18
|
return so.results;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
throw new Error(
|
|
21
|
+
throw new Error("Unexpected browser-automation output format");
|
|
22
22
|
}
|
|
23
|
-
export async function
|
|
23
|
+
export async function acceptanceTestCommand(requirementKey, url, options) {
|
|
24
24
|
// 1. Find project and load settings
|
|
25
25
|
const projectInfo = getProjectInfo();
|
|
26
26
|
if (!projectInfo) {
|
|
27
|
-
console.error(
|
|
27
|
+
console.error("Error: No dotrequirements project found.");
|
|
28
28
|
console.log('Run "dotrequirements init" to create one.');
|
|
29
29
|
process.exit(1);
|
|
30
30
|
}
|
|
@@ -40,7 +40,7 @@ export async function browserTestCommand(requirementKey, url, options) {
|
|
|
40
40
|
// 2. Determine URL
|
|
41
41
|
const targetURL = url || settings?.defaultURL;
|
|
42
42
|
if (!targetURL) {
|
|
43
|
-
console.error(
|
|
43
|
+
console.error("Error: No URL provided and no defaultURL in project-settings.json.");
|
|
44
44
|
console.log('Either provide a URL argument or add "defaultURL" to .requirements/project-settings.json');
|
|
45
45
|
process.exit(1);
|
|
46
46
|
}
|
|
@@ -49,23 +49,23 @@ export async function browserTestCommand(requirementKey, url, options) {
|
|
|
49
49
|
const modelApiKey = settings?.browserTest?.modelApiKey;
|
|
50
50
|
const geminiApiKey = settings?.browserTest?.geminiApiKey;
|
|
51
51
|
if (!modelName && !modelApiKey && !geminiApiKey) {
|
|
52
|
-
console.error(
|
|
53
|
-
console.log(
|
|
52
|
+
console.error("Error: no browser-test model configured in project-settings.json.");
|
|
53
|
+
console.log("Add a block like:\n" +
|
|
54
54
|
' "browserTest": {\n' +
|
|
55
55
|
' "modelName": "gateway/anthropic/claude-haiku-4-5",\n' +
|
|
56
56
|
' "modelApiKey": "..."\n' +
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
" }\n" +
|
|
58
|
+
"to .requirements/project-settings.json. See the docs for supported models.");
|
|
59
59
|
process.exit(1);
|
|
60
60
|
}
|
|
61
61
|
if ((modelName && !modelApiKey) || (modelApiKey && !modelName)) {
|
|
62
|
-
console.error(
|
|
62
|
+
console.error("Error: browserTest.modelName and browserTest.modelApiKey must be set together.");
|
|
63
63
|
process.exit(1);
|
|
64
64
|
}
|
|
65
65
|
// 4. Load requirements
|
|
66
66
|
const { flattened } = await loadAllRequirements(projectInfo.rootPath);
|
|
67
67
|
if (flattened.length === 0) {
|
|
68
|
-
console.error(
|
|
68
|
+
console.error("Error: No requirements found in .requirements/");
|
|
69
69
|
process.exit(1);
|
|
70
70
|
}
|
|
71
71
|
// 5. Find the requirement tree
|
|
@@ -86,7 +86,8 @@ export async function browserTestCommand(requirementKey, url, options) {
|
|
|
86
86
|
env.GEMINI_API_KEY = geminiApiKey;
|
|
87
87
|
}
|
|
88
88
|
if (settings?.browserTest?.vercelBypassSecret) {
|
|
89
|
-
env.VERCEL_AUTOMATION_BYPASS_SECRET =
|
|
89
|
+
env.VERCEL_AUTOMATION_BYPASS_SECRET =
|
|
90
|
+
settings.browserTest.vercelBypassSecret;
|
|
90
91
|
}
|
|
91
92
|
if (settings?.browserTest?.browserbaseApiKey) {
|
|
92
93
|
env.BROWSERBASE_API_KEY = settings.browserTest.browserbaseApiKey;
|
|
@@ -99,8 +100,14 @@ export async function browserTestCommand(requirementKey, url, options) {
|
|
|
99
100
|
console.log(`Testing ${requirementKey} against ${targetURL}...\n`);
|
|
100
101
|
}
|
|
101
102
|
try {
|
|
102
|
-
const modelFlags = modelName ? [
|
|
103
|
-
const { stdout } = await execFileAsync(
|
|
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 });
|
|
104
111
|
// 9. Parse results
|
|
105
112
|
let results;
|
|
106
113
|
try {
|
|
@@ -108,7 +115,7 @@ export async function browserTestCommand(requirementKey, url, options) {
|
|
|
108
115
|
results = extractResults(parsed);
|
|
109
116
|
}
|
|
110
117
|
catch (parseErr) {
|
|
111
|
-
console.error(
|
|
118
|
+
console.error("Error: Could not parse browser-automation output");
|
|
112
119
|
console.error(parseErr.message);
|
|
113
120
|
console.error(stdout);
|
|
114
121
|
process.exit(1);
|
|
@@ -121,7 +128,7 @@ export async function browserTestCommand(requirementKey, url, options) {
|
|
|
121
128
|
displayResults(requirementTree, results);
|
|
122
129
|
}
|
|
123
130
|
// 11. Exit with appropriate code
|
|
124
|
-
const failedCount = results.filter((r) => r.status !==
|
|
131
|
+
const failedCount = results.filter((r) => r.status !== "passed").length;
|
|
125
132
|
if (failedCount > 0) {
|
|
126
133
|
process.exit(1);
|
|
127
134
|
}
|
|
@@ -143,7 +150,7 @@ export async function browserTestCommand(requirementKey, url, options) {
|
|
|
143
150
|
}
|
|
144
151
|
catch {
|
|
145
152
|
// Not JSON, show raw output
|
|
146
|
-
console.error(
|
|
153
|
+
console.error("browser-automation error:");
|
|
147
154
|
if (error.stdout)
|
|
148
155
|
console.error(error.stdout);
|
|
149
156
|
if (error.stderr)
|
|
@@ -170,14 +177,14 @@ function displayResults(requirements, results) {
|
|
|
170
177
|
failedCount++;
|
|
171
178
|
continue;
|
|
172
179
|
}
|
|
173
|
-
const indent =
|
|
174
|
-
const label = req.label ? ` (${req.label})` :
|
|
175
|
-
const icon = result.status ===
|
|
180
|
+
const indent = " ".repeat(req.path.length);
|
|
181
|
+
const label = req.label ? ` (${req.label})` : "";
|
|
182
|
+
const icon = result.status === "passed" ? "\u2713" : "\u2717";
|
|
176
183
|
console.log(`${indent}${icon} ${req.id}${label}: ${req.content}`);
|
|
177
|
-
if (result.status !==
|
|
184
|
+
if (result.status !== "passed" && result.notes) {
|
|
178
185
|
console.log(`${indent} \u2192 ${result.notes}`);
|
|
179
186
|
}
|
|
180
|
-
if (result.status ===
|
|
187
|
+
if (result.status === "passed") {
|
|
181
188
|
passedCount++;
|
|
182
189
|
}
|
|
183
190
|
else {
|
|
@@ -197,9 +204,9 @@ function outputJson(requirements, results) {
|
|
|
197
204
|
id: req.id,
|
|
198
205
|
label: req.label || null,
|
|
199
206
|
content: req.content,
|
|
200
|
-
status: results[i]?.status ||
|
|
207
|
+
status: results[i]?.status || "blocked",
|
|
201
208
|
notes: results[i]?.notes || null,
|
|
202
209
|
}));
|
|
203
210
|
console.log(JSON.stringify(combined, null, 2));
|
|
204
211
|
}
|
|
205
|
-
//# sourceMappingURL=
|
|
212
|
+
//# sourceMappingURL=acceptance-test.js.map
|