sdd-cli 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/hello.js +63 -15
- package/dist/commands/req-finish.d.ts +11 -1
- package/dist/commands/req-finish.js +16 -13
- package/dist/commands/req-plan.d.ts +11 -1
- package/dist/commands/req-plan.js +42 -36
- package/dist/commands/req-start.d.ts +11 -1
- package/dist/commands/req-start.js +21 -14
- package/dist/commands/test-plan.d.ts +11 -1
- package/dist/commands/test-plan.js +20 -13
- package/package.json +1 -1
package/dist/commands/hello.js
CHANGED
|
@@ -8,7 +8,11 @@ const prompt_packs_1 = require("../router/prompt-packs");
|
|
|
8
8
|
const prompt_map_1 = require("../router/prompt-map");
|
|
9
9
|
const req_create_1 = require("./req-create");
|
|
10
10
|
const flags_1 = require("../context/flags");
|
|
11
|
+
const req_plan_1 = require("./req-plan");
|
|
12
|
+
const req_start_1 = require("./req-start");
|
|
13
|
+
const req_finish_1 = require("./req-finish");
|
|
11
14
|
const route_1 = require("./route");
|
|
15
|
+
const test_plan_1 = require("./test-plan");
|
|
12
16
|
function buildAutopilotDraft(input, flow, domain) {
|
|
13
17
|
const cleanInput = input.trim();
|
|
14
18
|
const objective = cleanInput.length > 0 ? cleanInput : "Deliver a clear first requirement draft.";
|
|
@@ -131,7 +135,7 @@ async function runHello(input, runQuestions) {
|
|
|
131
135
|
else {
|
|
132
136
|
console.log("Next: run `sdd-cli route <your input>` to view details.");
|
|
133
137
|
}
|
|
134
|
-
const shouldRunQuestions = runQuestions
|
|
138
|
+
const shouldRunQuestions = runQuestions === true;
|
|
135
139
|
console.log("Step 2/3: Requirement setup.");
|
|
136
140
|
if (shouldRunQuestions) {
|
|
137
141
|
const packs = (0, prompt_packs_1.loadPromptPacks)();
|
|
@@ -166,21 +170,65 @@ async function runHello(input, runQuestions) {
|
|
|
166
170
|
}
|
|
167
171
|
}
|
|
168
172
|
else {
|
|
169
|
-
const
|
|
170
|
-
if (
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
if (created) {
|
|
174
|
-
console.log(`Step 3/3: Draft created (${created.reqId}).`);
|
|
175
|
-
console.log("Next suggested commands:");
|
|
176
|
-
console.log("- sdd-cli req refine");
|
|
177
|
-
console.log("- sdd-cli req plan");
|
|
178
|
-
}
|
|
173
|
+
const activeProject = (0, flags_1.getFlags)().project || (await (0, prompt_1.askProjectName)());
|
|
174
|
+
if (!activeProject) {
|
|
175
|
+
console.log("Project name is required to run autopilot.");
|
|
176
|
+
return;
|
|
179
177
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
178
|
+
(0, flags_1.setFlags)({ project: activeProject });
|
|
179
|
+
const draft = buildAutopilotDraft(text, intent.flow, intent.domain);
|
|
180
|
+
draft.project_name = activeProject;
|
|
181
|
+
console.log("Step 3/7: Creating requirement draft automatically...");
|
|
182
|
+
const created = await (0, req_create_1.runReqCreate)(draft, { autofill: true });
|
|
183
|
+
if (!created) {
|
|
184
|
+
console.log("Autopilot stopped at requirement creation.");
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
console.log(`Step 4/7: Planning requirement ${created.reqId}...`);
|
|
188
|
+
const planned = await (0, req_plan_1.runReqPlan)({
|
|
189
|
+
projectName: activeProject,
|
|
190
|
+
reqId: created.reqId,
|
|
191
|
+
autofill: true,
|
|
192
|
+
seedText: text
|
|
193
|
+
});
|
|
194
|
+
if (!planned) {
|
|
195
|
+
console.log("Autopilot stopped at planning.");
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
console.log(`Step 5/7: Starting implementation plan for ${created.reqId}...`);
|
|
199
|
+
const started = await (0, req_start_1.runReqStart)({
|
|
200
|
+
projectName: activeProject,
|
|
201
|
+
reqId: created.reqId,
|
|
202
|
+
autofill: true,
|
|
203
|
+
seedText: text
|
|
204
|
+
});
|
|
205
|
+
if (!started) {
|
|
206
|
+
console.log("Autopilot stopped at start phase.");
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
console.log(`Step 6/7: Updating test plan for ${created.reqId}...`);
|
|
210
|
+
const tested = await (0, test_plan_1.runTestPlan)({
|
|
211
|
+
projectName: activeProject,
|
|
212
|
+
reqId: created.reqId,
|
|
213
|
+
autofill: true,
|
|
214
|
+
seedText: text
|
|
215
|
+
});
|
|
216
|
+
if (!tested) {
|
|
217
|
+
console.log("Autopilot stopped at test planning.");
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
console.log(`Step 7/7: Finalizing requirement ${created.reqId}...`);
|
|
221
|
+
const finished = await (0, req_finish_1.runReqFinish)({
|
|
222
|
+
projectName: activeProject,
|
|
223
|
+
reqId: created.reqId,
|
|
224
|
+
autofill: true,
|
|
225
|
+
seedText: text
|
|
226
|
+
});
|
|
227
|
+
if (!finished) {
|
|
228
|
+
console.log("Autopilot stopped at finish phase.");
|
|
229
|
+
return;
|
|
184
230
|
}
|
|
231
|
+
console.log(`Autopilot completed successfully for ${created.reqId}.`);
|
|
232
|
+
console.log(`Artifacts finalized at: ${finished.doneDir}`);
|
|
185
233
|
}
|
|
186
234
|
}
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
export declare function runReqFinish(): Promise<
|
|
1
|
+
export declare function runReqFinish(options?: ReqFinishOptions): Promise<ReqFinishResult | null>;
|
|
2
|
+
export type ReqFinishOptions = {
|
|
3
|
+
projectName?: string;
|
|
4
|
+
reqId?: string;
|
|
5
|
+
autofill?: boolean;
|
|
6
|
+
seedText?: string;
|
|
7
|
+
};
|
|
8
|
+
export type ReqFinishResult = {
|
|
9
|
+
reqId: string;
|
|
10
|
+
doneDir: string;
|
|
11
|
+
};
|
|
@@ -22,12 +22,13 @@ function findRequirementDir(projectRoot, reqId) {
|
|
|
22
22
|
return inProgress;
|
|
23
23
|
return null;
|
|
24
24
|
}
|
|
25
|
-
async function runReqFinish() {
|
|
26
|
-
const
|
|
27
|
-
const
|
|
25
|
+
async function runReqFinish(options) {
|
|
26
|
+
const auto = Boolean(options?.autofill);
|
|
27
|
+
const projectName = options?.projectName ?? (await (0, prompt_1.askProjectName)());
|
|
28
|
+
const reqId = options?.reqId ?? (await (0, prompt_1.ask)("Requirement ID (REQ-...): "));
|
|
28
29
|
if (!projectName || !reqId) {
|
|
29
30
|
console.log("Project name and requirement ID are required.");
|
|
30
|
-
return;
|
|
31
|
+
return null;
|
|
31
32
|
}
|
|
32
33
|
const workspace = (0, index_1.getWorkspaceInfo)();
|
|
33
34
|
let project;
|
|
@@ -36,12 +37,12 @@ async function runReqFinish() {
|
|
|
36
37
|
}
|
|
37
38
|
catch (error) {
|
|
38
39
|
console.log(error.message);
|
|
39
|
-
return;
|
|
40
|
+
return null;
|
|
40
41
|
}
|
|
41
42
|
const requirementDir = findRequirementDir(project.root, reqId);
|
|
42
43
|
if (!requirementDir) {
|
|
43
44
|
console.log("Requirement not found.");
|
|
44
|
-
return;
|
|
45
|
+
return null;
|
|
45
46
|
}
|
|
46
47
|
const jsonFiles = fs_1.default.readdirSync(requirementDir).filter((file) => file.endsWith(".json"));
|
|
47
48
|
const schemaMap = {
|
|
@@ -61,13 +62,14 @@ async function runReqFinish() {
|
|
|
61
62
|
if (!result.valid) {
|
|
62
63
|
console.log(`Validation failed for ${file}:`);
|
|
63
64
|
result.errors.forEach((error) => console.log(`- ${error}`));
|
|
64
|
-
return;
|
|
65
|
+
return null;
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
|
-
const
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
const
|
|
68
|
+
const seed = (options?.seedText ?? "").trim() || "initial scope";
|
|
69
|
+
const overview = auto ? `Project delivery for ${seed}` : await (0, prompt_1.ask)("Project overview (for README): ");
|
|
70
|
+
const howToRun = auto ? "Run CLI commands through sdd-cli flow." : await (0, prompt_1.ask)("How to run (for README): ");
|
|
71
|
+
const archSummary = auto ? "CLI + templates + schema validation architecture." : await (0, prompt_1.ask)("Architecture summary (for README): ");
|
|
72
|
+
const testingNotes = auto ? "Validated with unit and integration CLI tests." : await (0, prompt_1.ask)("Testing notes (for README): ");
|
|
71
73
|
const readmeTemplate = (0, render_1.loadTemplate)("project-readme");
|
|
72
74
|
const readmeRendered = (0, render_1.renderTemplate)(readmeTemplate, {
|
|
73
75
|
project_name: project.name,
|
|
@@ -97,7 +99,7 @@ async function runReqFinish() {
|
|
|
97
99
|
if (!readmeValidation.valid) {
|
|
98
100
|
console.log("Project README validation failed:");
|
|
99
101
|
readmeValidation.errors.forEach((error) => console.log(`- ${error}`));
|
|
100
|
-
return;
|
|
102
|
+
return null;
|
|
101
103
|
}
|
|
102
104
|
const sourceDir = requirementDir;
|
|
103
105
|
const sourceStatus = path_1.default.basename(path_1.default.dirname(sourceDir));
|
|
@@ -147,7 +149,8 @@ async function runReqFinish() {
|
|
|
147
149
|
(0, index_1.updateProjectStatus)(workspace, project.name, sourceStatus);
|
|
148
150
|
}
|
|
149
151
|
console.log(`Failed to finish requirement: ${error.message}`);
|
|
150
|
-
return;
|
|
152
|
+
return null;
|
|
151
153
|
}
|
|
152
154
|
console.log(`Moved requirement to ${doneDir}`);
|
|
155
|
+
return { reqId, doneDir };
|
|
153
156
|
}
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type ReqPlanOptions = {
|
|
2
|
+
projectName?: string;
|
|
3
|
+
reqId?: string;
|
|
4
|
+
autofill?: boolean;
|
|
5
|
+
seedText?: string;
|
|
6
|
+
};
|
|
7
|
+
export type ReqPlanResult = {
|
|
8
|
+
reqId: string;
|
|
9
|
+
targetDir: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function runReqPlan(options?: ReqPlanOptions): Promise<ReqPlanResult | null>;
|
|
@@ -22,12 +22,17 @@ function findRequirementDir(projectRoot, reqId) {
|
|
|
22
22
|
return wip;
|
|
23
23
|
return null;
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
25
|
+
function defaultSeed(seedText) {
|
|
26
|
+
const text = (seedText ?? "").trim();
|
|
27
|
+
return text.length > 0 ? text : "first delivery";
|
|
28
|
+
}
|
|
29
|
+
async function runReqPlan(options) {
|
|
30
|
+
const auto = Boolean(options?.autofill);
|
|
31
|
+
const projectName = options?.projectName ?? (await (0, prompt_1.askProjectName)());
|
|
32
|
+
const reqId = options?.reqId ?? (await (0, prompt_1.ask)("Requirement ID (REQ-...): "));
|
|
28
33
|
if (!projectName || !reqId) {
|
|
29
34
|
console.log("Project name and requirement ID are required.");
|
|
30
|
-
return;
|
|
35
|
+
return null;
|
|
31
36
|
}
|
|
32
37
|
const workspace = (0, index_1.getWorkspaceInfo)();
|
|
33
38
|
let project;
|
|
@@ -36,17 +41,17 @@ async function runReqPlan() {
|
|
|
36
41
|
}
|
|
37
42
|
catch (error) {
|
|
38
43
|
console.log(error.message);
|
|
39
|
-
return;
|
|
44
|
+
return null;
|
|
40
45
|
}
|
|
41
46
|
let requirementDir = findRequirementDir(project.root, reqId);
|
|
42
47
|
if (!requirementDir) {
|
|
43
48
|
console.log("Requirement not found in backlog or wip.");
|
|
44
|
-
return;
|
|
49
|
+
return null;
|
|
45
50
|
}
|
|
46
51
|
const requirementJsonPath = path_1.default.join(requirementDir, "requirement.json");
|
|
47
52
|
if (!fs_1.default.existsSync(requirementJsonPath)) {
|
|
48
53
|
console.log("Missing requirement.json. Run `req create` first.");
|
|
49
|
-
return;
|
|
54
|
+
return null;
|
|
50
55
|
}
|
|
51
56
|
const requirementJson = JSON.parse(fs_1.default.readFileSync(requirementJsonPath, "utf-8"));
|
|
52
57
|
let gates = (0, gates_1.checkRequirementGates)(requirementJson);
|
|
@@ -54,13 +59,13 @@ async function runReqPlan() {
|
|
|
54
59
|
console.log("Requirement gates failed. Please update the requirement first:");
|
|
55
60
|
gates.missing.forEach((field) => console.log(`- ${field}`));
|
|
56
61
|
console.log("Run `sdd-cli req refine` to complete missing fields.");
|
|
57
|
-
return;
|
|
62
|
+
return null;
|
|
58
63
|
}
|
|
59
64
|
const requirementValidation = (0, validate_1.validateJson)("requirement.schema.json", requirementJson);
|
|
60
65
|
if (!requirementValidation.valid) {
|
|
61
66
|
console.log("Requirement validation failed:");
|
|
62
67
|
requirementValidation.errors.forEach((error) => console.log(`- ${error}`));
|
|
63
|
-
return;
|
|
68
|
+
return null;
|
|
64
69
|
}
|
|
65
70
|
const wipDir = path_1.default.join(project.root, "requirements", "wip", reqId);
|
|
66
71
|
if (requirementDir.includes(path_1.default.join("requirements", "backlog"))) {
|
|
@@ -75,32 +80,33 @@ async function runReqPlan() {
|
|
|
75
80
|
}
|
|
76
81
|
requirementJson.updatedAt = new Date().toISOString();
|
|
77
82
|
fs_1.default.writeFileSync(path_1.default.join(targetDir, "requirement.json"), JSON.stringify(requirementJson, null, 2), "utf-8");
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
const
|
|
81
|
-
const
|
|
82
|
-
const
|
|
83
|
-
const
|
|
84
|
-
const
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
const
|
|
88
|
-
const
|
|
89
|
-
const
|
|
90
|
-
const
|
|
91
|
-
const
|
|
92
|
-
const
|
|
93
|
-
const
|
|
94
|
-
const
|
|
95
|
-
const
|
|
96
|
-
const
|
|
97
|
-
const
|
|
98
|
-
const
|
|
99
|
-
const
|
|
100
|
-
const
|
|
101
|
-
const
|
|
83
|
+
const seed = defaultSeed(options?.seedText ?? requirementJson.objective);
|
|
84
|
+
const overview = auto ? `Functional overview for ${seed}` : await (0, prompt_1.ask)("Functional overview: ");
|
|
85
|
+
const actors = auto ? "user, system" : await (0, prompt_1.ask)("Actors - comma separated: ");
|
|
86
|
+
const useCases = auto ? `capture need for ${seed}, deliver first iteration` : await (0, prompt_1.ask)("Use cases - comma separated: ");
|
|
87
|
+
const flows = auto ? "discover, plan, implement, validate" : await (0, prompt_1.ask)("Flows - comma separated: ");
|
|
88
|
+
const rules = auto ? "maintain traceability, validate artifacts" : await (0, prompt_1.ask)("Business rules - comma separated: ");
|
|
89
|
+
const errors = auto ? "invalid input, missing artifact" : await (0, prompt_1.ask)("Errors - comma separated: ");
|
|
90
|
+
const acceptance = auto ? "artifacts generated, schemas valid" : await (0, prompt_1.ask)("Acceptance criteria - comma separated: ");
|
|
91
|
+
const stack = auto ? "node, typescript" : await (0, prompt_1.ask)("Tech stack - comma separated: ");
|
|
92
|
+
const interfaces = auto ? "cli commands, markdown artifacts" : await (0, prompt_1.ask)("Interfaces - comma separated: ");
|
|
93
|
+
const dataModel = auto ? "requirement json, spec json" : await (0, prompt_1.ask)("Data model - comma separated: ");
|
|
94
|
+
const security = auto ? "safe defaults, input validation" : await (0, prompt_1.ask)("Security - comma separated: ");
|
|
95
|
+
const techErrors = auto ? "clear cli errors, retry guidance" : await (0, prompt_1.ask)("Error handling - comma separated: ");
|
|
96
|
+
const performance = auto ? "fast local generation" : await (0, prompt_1.ask)("Performance - comma separated: ");
|
|
97
|
+
const observability = auto ? "progress logs, changelog entries" : await (0, prompt_1.ask)("Observability - comma separated: ");
|
|
98
|
+
const context = auto ? "CLI orchestrator with schema validation" : await (0, prompt_1.ask)("Architecture context: ");
|
|
99
|
+
const containers = auto ? "cli runtime, workspace files" : await (0, prompt_1.ask)("Containers - comma separated: ");
|
|
100
|
+
const components = auto ? "router, generators, validators" : await (0, prompt_1.ask)("Components - comma separated: ");
|
|
101
|
+
const deployment = auto ? "local workstation" : await (0, prompt_1.ask)("Deployment - comma separated: ");
|
|
102
|
+
const diagrams = auto ? "context.mmd, container.mmd" : await (0, prompt_1.ask)("Diagrams - comma separated: ");
|
|
103
|
+
const criticalPaths = auto ? "hello to requirement, requirement to plan" : await (0, prompt_1.ask)("Test critical paths - comma separated: ");
|
|
104
|
+
const edgeCases = auto ? "missing fields, invalid schema" : await (0, prompt_1.ask)("Test edge cases - comma separated: ");
|
|
105
|
+
const acceptanceTests = auto ? "generate and validate complete bundle" : await (0, prompt_1.ask)("Acceptance tests - comma separated: ");
|
|
106
|
+
const regressions = auto ? "flags behavior, template loading" : await (0, prompt_1.ask)("Regression tests - comma separated: ");
|
|
107
|
+
const coverageTarget = auto ? "80%" : await (0, prompt_1.ask)("Coverage target: ");
|
|
102
108
|
const flags = (0, flags_1.getFlags)();
|
|
103
|
-
const improveNote = flags.improve ? await (0, prompt_1.ask)("Improve focus (optional): ") : "";
|
|
109
|
+
const improveNote = flags.improve && !auto ? await (0, prompt_1.ask)("Improve focus (optional): ") : "";
|
|
104
110
|
const functionalJson = {
|
|
105
111
|
overview: overview || "N/A",
|
|
106
112
|
actors: (0, list_1.parseList)(actors),
|
|
@@ -143,9 +149,8 @@ async function runReqPlan() {
|
|
|
143
149
|
if (failures.length > 0) {
|
|
144
150
|
console.log("Spec validation failed:");
|
|
145
151
|
failures.forEach((error) => console.log(`- ${error}`));
|
|
146
|
-
return;
|
|
152
|
+
return null;
|
|
147
153
|
}
|
|
148
|
-
console.log("Spec validation passed.");
|
|
149
154
|
const functionalTemplate = (0, render_1.loadTemplate)("functional-spec");
|
|
150
155
|
const technicalTemplate = (0, render_1.loadTemplate)("technical-spec");
|
|
151
156
|
const architectureTemplate = (0, render_1.loadTemplate)("architecture");
|
|
@@ -219,4 +224,5 @@ async function runReqPlan() {
|
|
|
219
224
|
const changeEntry = `\n- ${new Date().toISOString()} planned requirement ${reqId}\n`;
|
|
220
225
|
fs_1.default.appendFileSync(changelog, changeEntry, "utf-8");
|
|
221
226
|
console.log(`Generated specs in ${targetDir}`);
|
|
227
|
+
return { reqId, targetDir };
|
|
222
228
|
}
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type ReqStartOptions = {
|
|
2
|
+
projectName?: string;
|
|
3
|
+
reqId?: string;
|
|
4
|
+
autofill?: boolean;
|
|
5
|
+
seedText?: string;
|
|
6
|
+
};
|
|
7
|
+
export type ReqStartResult = {
|
|
8
|
+
reqId: string;
|
|
9
|
+
targetDir: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function runReqStart(options?: ReqStartOptions): Promise<ReqStartResult | null>;
|
|
@@ -24,12 +24,17 @@ function findRequirementDir(projectRoot, reqId) {
|
|
|
24
24
|
return inProgress;
|
|
25
25
|
return null;
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
27
|
+
function defaultSeed(seedText) {
|
|
28
|
+
const text = (seedText ?? "").trim();
|
|
29
|
+
return text.length > 0 ? text : "initial delivery";
|
|
30
|
+
}
|
|
31
|
+
async function runReqStart(options) {
|
|
32
|
+
const auto = Boolean(options?.autofill);
|
|
33
|
+
const projectName = options?.projectName ?? (await (0, prompt_1.askProjectName)());
|
|
34
|
+
const reqId = options?.reqId ?? (await (0, prompt_1.ask)("Requirement ID (REQ-...): "));
|
|
30
35
|
if (!projectName || !reqId) {
|
|
31
36
|
console.log("Project name and requirement ID are required.");
|
|
32
|
-
return;
|
|
37
|
+
return null;
|
|
33
38
|
}
|
|
34
39
|
const workspace = (0, index_1.getWorkspaceInfo)();
|
|
35
40
|
let project;
|
|
@@ -38,12 +43,12 @@ async function runReqStart() {
|
|
|
38
43
|
}
|
|
39
44
|
catch (error) {
|
|
40
45
|
console.log(error.message);
|
|
41
|
-
return;
|
|
46
|
+
return null;
|
|
42
47
|
}
|
|
43
48
|
let requirementDir = findRequirementDir(project.root, reqId);
|
|
44
49
|
if (!requirementDir) {
|
|
45
50
|
console.log("Requirement not found.");
|
|
46
|
-
return;
|
|
51
|
+
return null;
|
|
47
52
|
}
|
|
48
53
|
const requirementPath = requirementDir;
|
|
49
54
|
const requiredSpecs = [
|
|
@@ -56,7 +61,7 @@ async function runReqStart() {
|
|
|
56
61
|
if (missing.length > 0) {
|
|
57
62
|
console.log("Cannot start. Missing specs:");
|
|
58
63
|
missing.forEach((spec) => console.log(`- ${spec.file}`));
|
|
59
|
-
return;
|
|
64
|
+
return null;
|
|
60
65
|
}
|
|
61
66
|
for (const spec of requiredSpecs) {
|
|
62
67
|
const data = JSON.parse(fs_1.default.readFileSync(path_1.default.join(requirementPath, spec.file), "utf-8"));
|
|
@@ -64,7 +69,7 @@ async function runReqStart() {
|
|
|
64
69
|
if (!result.valid) {
|
|
65
70
|
console.log(`Spec validation failed for ${spec.file}:`);
|
|
66
71
|
result.errors.forEach((error) => console.log(`- ${error}`));
|
|
67
|
-
return;
|
|
72
|
+
return null;
|
|
68
73
|
}
|
|
69
74
|
}
|
|
70
75
|
const inProgressDir = path_1.default.join(project.root, "requirements", "in-progress", reqId);
|
|
@@ -82,12 +87,13 @@ async function runReqStart() {
|
|
|
82
87
|
requirementJson.updatedAt = new Date().toISOString();
|
|
83
88
|
fs_1.default.writeFileSync(requirementJsonPath, JSON.stringify(requirementJson, null, 2), "utf-8");
|
|
84
89
|
}
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
const
|
|
88
|
-
const
|
|
90
|
+
const seed = defaultSeed(options?.seedText);
|
|
91
|
+
const milestones = auto ? `milestone for ${seed}` : await (0, prompt_1.ask)("Milestones - comma separated: ");
|
|
92
|
+
const tasks = auto ? "implement core flow, validate outputs" : await (0, prompt_1.ask)("Tasks - comma separated: ");
|
|
93
|
+
const dependencies = auto ? "node runtime, templates, schemas" : await (0, prompt_1.ask)("Dependencies - comma separated: ");
|
|
94
|
+
const risks = auto ? "scope drift, missing validation" : await (0, prompt_1.ask)("Risks - comma separated: ");
|
|
89
95
|
const flags = (0, flags_1.getFlags)();
|
|
90
|
-
const improveNote = flags.improve ? await (0, prompt_1.ask)("Improve focus (optional): ") : "";
|
|
96
|
+
const improveNote = flags.improve && !auto ? await (0, prompt_1.ask)("Improve focus (optional): ") : "";
|
|
91
97
|
const implementationTemplate = (0, render_1.loadTemplate)("implementation-plan");
|
|
92
98
|
const rendered = (0, render_1.renderTemplate)(implementationTemplate, {
|
|
93
99
|
title: project.name,
|
|
@@ -110,7 +116,7 @@ async function runReqStart() {
|
|
|
110
116
|
if (!validation.valid) {
|
|
111
117
|
console.log("Quality validation failed:");
|
|
112
118
|
validation.errors.forEach((error) => console.log(`- ${error}`));
|
|
113
|
-
return;
|
|
119
|
+
return null;
|
|
114
120
|
}
|
|
115
121
|
fs_1.default.writeFileSync(path_1.default.join(targetDir, "implementation-plan.md"), rendered, "utf-8");
|
|
116
122
|
fs_1.default.writeFileSync(path_1.default.join(targetDir, "quality.json"), JSON.stringify(qualityJson, null, 2), "utf-8");
|
|
@@ -145,4 +151,5 @@ async function runReqStart() {
|
|
|
145
151
|
fs_1.default.appendFileSync(changelog, changeEntry, "utf-8");
|
|
146
152
|
console.log(`Implementation plan generated in ${targetDir}`);
|
|
147
153
|
console.log(`Status updated to in-progress for ${project.name}`);
|
|
154
|
+
return { reqId, targetDir };
|
|
148
155
|
}
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type TestPlanOptions = {
|
|
2
|
+
projectName?: string;
|
|
3
|
+
reqId?: string;
|
|
4
|
+
autofill?: boolean;
|
|
5
|
+
seedText?: string;
|
|
6
|
+
};
|
|
7
|
+
export type TestPlanResult = {
|
|
8
|
+
reqId: string;
|
|
9
|
+
requirementDir: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function runTestPlan(options?: TestPlanOptions): Promise<TestPlanResult | null>;
|
|
@@ -23,12 +23,17 @@ function findRequirementDir(projectRoot, reqId) {
|
|
|
23
23
|
}
|
|
24
24
|
return null;
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
26
|
+
function defaultSeed(seedText) {
|
|
27
|
+
const text = (seedText ?? "").trim();
|
|
28
|
+
return text.length > 0 ? text : "initial scope";
|
|
29
|
+
}
|
|
30
|
+
async function runTestPlan(options) {
|
|
31
|
+
const auto = Boolean(options?.autofill);
|
|
32
|
+
const projectName = options?.projectName ?? (await (0, prompt_1.askProjectName)());
|
|
33
|
+
const reqId = options?.reqId ?? (await (0, prompt_1.ask)("Requirement ID (REQ-...): "));
|
|
29
34
|
if (!projectName || !reqId) {
|
|
30
35
|
console.log("Project name and requirement ID are required.");
|
|
31
|
-
return;
|
|
36
|
+
return null;
|
|
32
37
|
}
|
|
33
38
|
const workspace = (0, index_1.getWorkspaceInfo)();
|
|
34
39
|
let project;
|
|
@@ -37,20 +42,21 @@ async function runTestPlan() {
|
|
|
37
42
|
}
|
|
38
43
|
catch (error) {
|
|
39
44
|
console.log(error.message);
|
|
40
|
-
return;
|
|
45
|
+
return null;
|
|
41
46
|
}
|
|
42
47
|
const requirementDir = findRequirementDir(project.root, reqId);
|
|
43
48
|
if (!requirementDir) {
|
|
44
49
|
console.log("Requirement not found.");
|
|
45
|
-
return;
|
|
50
|
+
return null;
|
|
46
51
|
}
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
+
const seed = defaultSeed(options?.seedText);
|
|
53
|
+
const criticalPaths = auto ? `core path for ${seed}` : await (0, prompt_1.ask)("Test critical paths - comma separated: ");
|
|
54
|
+
const edgeCases = auto ? "invalid data, missing inputs" : await (0, prompt_1.ask)("Test edge cases - comma separated: ");
|
|
55
|
+
const acceptanceTests = auto ? "happy path end-to-end generation" : await (0, prompt_1.ask)("Acceptance tests - comma separated: ");
|
|
56
|
+
const regressions = auto ? "existing command behavior remains valid" : await (0, prompt_1.ask)("Regression tests - comma separated: ");
|
|
57
|
+
const coverageTarget = auto ? "80%" : await (0, prompt_1.ask)("Coverage target: ");
|
|
52
58
|
const flags = (0, flags_1.getFlags)();
|
|
53
|
-
const improveNote = flags.improve ? await (0, prompt_1.ask)("Improve focus (optional): ") : "";
|
|
59
|
+
const improveNote = flags.improve && !auto ? await (0, prompt_1.ask)("Improve focus (optional): ") : "";
|
|
54
60
|
const testPlanJson = {
|
|
55
61
|
criticalPaths: (0, list_1.parseList)(criticalPaths),
|
|
56
62
|
edgeCases: (0, list_1.parseList)(edgeCases),
|
|
@@ -62,7 +68,7 @@ async function runTestPlan() {
|
|
|
62
68
|
if (!validation.valid) {
|
|
63
69
|
console.log("Test plan validation failed:");
|
|
64
70
|
validation.errors.forEach((error) => console.log(`- ${error}`));
|
|
65
|
-
return;
|
|
71
|
+
return null;
|
|
66
72
|
}
|
|
67
73
|
const template = (0, render_1.loadTemplate)("test-plan");
|
|
68
74
|
const rendered = (0, render_1.renderTemplate)(template, {
|
|
@@ -86,4 +92,5 @@ async function runTestPlan() {
|
|
|
86
92
|
fs_1.default.appendFileSync(progressLog, improveEntry, "utf-8");
|
|
87
93
|
}
|
|
88
94
|
console.log(`Test plan updated in ${requirementDir}`);
|
|
95
|
+
return { reqId, requirementDir };
|
|
89
96
|
}
|