@shahmarasy/prodo 0.1.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.
- package/LICENSE +21 -0
- package/README.md +157 -0
- package/bin/prodo.cjs +6 -0
- package/dist/agent-command-installer.d.ts +4 -0
- package/dist/agent-command-installer.js +158 -0
- package/dist/agents.d.ts +15 -0
- package/dist/agents.js +47 -0
- package/dist/artifact-registry.d.ts +11 -0
- package/dist/artifact-registry.js +49 -0
- package/dist/artifacts.d.ts +9 -0
- package/dist/artifacts.js +514 -0
- package/dist/cli.d.ts +9 -0
- package/dist/cli.js +305 -0
- package/dist/consistency.d.ts +8 -0
- package/dist/consistency.js +268 -0
- package/dist/constants.d.ts +7 -0
- package/dist/constants.js +64 -0
- package/dist/doctor.d.ts +1 -0
- package/dist/doctor.js +123 -0
- package/dist/errors.d.ts +3 -0
- package/dist/errors.js +10 -0
- package/dist/hook-executor.d.ts +1 -0
- package/dist/hook-executor.js +175 -0
- package/dist/init-tui.d.ts +21 -0
- package/dist/init-tui.js +161 -0
- package/dist/init.d.ts +10 -0
- package/dist/init.js +307 -0
- package/dist/markdown.d.ts +11 -0
- package/dist/markdown.js +66 -0
- package/dist/normalize.d.ts +7 -0
- package/dist/normalize.js +73 -0
- package/dist/normalized-brief.d.ts +39 -0
- package/dist/normalized-brief.js +170 -0
- package/dist/output-index.d.ts +13 -0
- package/dist/output-index.js +55 -0
- package/dist/paths.d.ts +16 -0
- package/dist/paths.js +76 -0
- package/dist/preset-loader.d.ts +4 -0
- package/dist/preset-loader.js +210 -0
- package/dist/project-config.d.ts +14 -0
- package/dist/project-config.js +69 -0
- package/dist/providers/index.d.ts +2 -0
- package/dist/providers/index.js +12 -0
- package/dist/providers/mock-provider.d.ts +7 -0
- package/dist/providers/mock-provider.js +168 -0
- package/dist/providers/openai-provider.d.ts +11 -0
- package/dist/providers/openai-provider.js +69 -0
- package/dist/registry.d.ts +13 -0
- package/dist/registry.js +115 -0
- package/dist/settings.d.ts +6 -0
- package/dist/settings.js +34 -0
- package/dist/template-resolver.d.ts +11 -0
- package/dist/template-resolver.js +28 -0
- package/dist/templates.d.ts +33 -0
- package/dist/templates.js +428 -0
- package/dist/types.d.ts +35 -0
- package/dist/types.js +5 -0
- package/dist/utils.d.ts +6 -0
- package/dist/utils.js +53 -0
- package/dist/validate.d.ts +9 -0
- package/dist/validate.js +226 -0
- package/dist/validator.d.ts +5 -0
- package/dist/validator.js +80 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +30 -0
- package/dist/workflow-commands.d.ts +7 -0
- package/dist/workflow-commands.js +28 -0
- package/package.json +45 -0
- package/presets/fintech/preset.json +1 -0
- package/presets/fintech/prompts/prd.md +3 -0
- package/presets/marketplace/preset.json +1 -0
- package/presets/marketplace/prompts/prd.md +3 -0
- package/presets/saas/preset.json +1 -0
- package/presets/saas/prompts/prd.md +3 -0
- package/src/agent-command-installer.ts +174 -0
- package/src/agents.ts +56 -0
- package/src/artifact-registry.ts +69 -0
- package/src/artifacts.ts +606 -0
- package/src/cli.ts +322 -0
- package/src/consistency.ts +303 -0
- package/src/constants.ts +72 -0
- package/src/doctor.ts +137 -0
- package/src/errors.ts +7 -0
- package/src/hook-executor.ts +196 -0
- package/src/init-tui.ts +193 -0
- package/src/init.ts +375 -0
- package/src/markdown.ts +73 -0
- package/src/normalize.ts +89 -0
- package/src/normalized-brief.ts +206 -0
- package/src/output-index.ts +59 -0
- package/src/paths.ts +72 -0
- package/src/preset-loader.ts +237 -0
- package/src/project-config.ts +78 -0
- package/src/providers/index.ts +12 -0
- package/src/providers/mock-provider.ts +188 -0
- package/src/providers/openai-provider.ts +87 -0
- package/src/registry.ts +119 -0
- package/src/settings.ts +34 -0
- package/src/template-resolver.ts +33 -0
- package/src/templates.ts +440 -0
- package/src/types.ts +46 -0
- package/src/utils.ts +50 -0
- package/src/validate.ts +246 -0
- package/src/validator.ts +96 -0
- package/src/version.ts +24 -0
- package/src/workflow-commands.ts +31 -0
- package/templates/artifacts/prd.md +219 -0
- package/templates/artifacts/stories.md +49 -0
- package/templates/artifacts/techspec.md +42 -0
- package/templates/artifacts/wireframe.html +260 -0
- package/templates/artifacts/wireframe.md +22 -0
- package/templates/artifacts/workflow.md +22 -0
- package/templates/artifacts/workflow.mmd +6 -0
- package/templates/commands/prodo-normalize.md +24 -0
- package/templates/commands/prodo-prd.md +24 -0
- package/templates/commands/prodo-stories.md +24 -0
- package/templates/commands/prodo-techspec.md +24 -0
- package/templates/commands/prodo-validate.md +24 -0
- package/templates/commands/prodo-wireframe.md +24 -0
- package/templates/commands/prodo-workflow.md +24 -0
package/src/templates.ts
ADDED
|
@@ -0,0 +1,440 @@
|
|
|
1
|
+
import { defaultRequiredHeadings } from "./constants";
|
|
2
|
+
import type { ArtifactType } from "./types";
|
|
3
|
+
import type { WorkflowCommand } from "./workflow-commands";
|
|
4
|
+
|
|
5
|
+
const BASE_SCHEMA = {
|
|
6
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
7
|
+
type: "object",
|
|
8
|
+
required: ["frontmatter", "body"],
|
|
9
|
+
properties: {
|
|
10
|
+
frontmatter: {
|
|
11
|
+
type: "object",
|
|
12
|
+
required: ["artifact_type", "version", "source_brief", "generated_at", "status"],
|
|
13
|
+
properties: {
|
|
14
|
+
artifact_type: { type: "string" },
|
|
15
|
+
version: { type: "string", minLength: 1 },
|
|
16
|
+
source_brief: { type: "string", minLength: 1 },
|
|
17
|
+
generated_at: { type: "string", format: "date-time" },
|
|
18
|
+
status: { type: "string", enum: ["draft", "reviewed", "approved"] },
|
|
19
|
+
title: { type: "string" },
|
|
20
|
+
upstream_artifacts: {
|
|
21
|
+
type: "array",
|
|
22
|
+
items: { type: "string" }
|
|
23
|
+
},
|
|
24
|
+
contract_coverage: {
|
|
25
|
+
type: "object",
|
|
26
|
+
required: ["goals", "core_features", "constraints"],
|
|
27
|
+
properties: {
|
|
28
|
+
goals: { type: "array", items: { type: "string", pattern: "^G[0-9]+$" } },
|
|
29
|
+
core_features: { type: "array", items: { type: "string", pattern: "^F[0-9]+$" } },
|
|
30
|
+
constraints: { type: "array", items: { type: "string", pattern: "^C[0-9]+$" } }
|
|
31
|
+
},
|
|
32
|
+
additionalProperties: false
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
additionalProperties: true
|
|
36
|
+
},
|
|
37
|
+
body: {
|
|
38
|
+
type: "string",
|
|
39
|
+
minLength: 40
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
additionalProperties: false
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export function schemaTemplate(artifactType: ArtifactType): Record<string, unknown> {
|
|
46
|
+
return {
|
|
47
|
+
...BASE_SCHEMA,
|
|
48
|
+
properties: {
|
|
49
|
+
...(BASE_SCHEMA.properties as Record<string, unknown>),
|
|
50
|
+
frontmatter: {
|
|
51
|
+
...((BASE_SCHEMA.properties as Record<string, unknown>).frontmatter as Record<string, unknown>),
|
|
52
|
+
properties: {
|
|
53
|
+
...((((BASE_SCHEMA.properties as Record<string, unknown>).frontmatter as Record<string, unknown>)
|
|
54
|
+
.properties as Record<string, unknown>)),
|
|
55
|
+
artifact_type: { const: artifactType }
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
x_required_headings: defaultRequiredHeadings(artifactType)
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function promptTemplate(artifactType: ArtifactType, lang = "en"): string {
|
|
64
|
+
const tr = lang.toLowerCase().startsWith("tr");
|
|
65
|
+
if (artifactType === "workflow") {
|
|
66
|
+
return `You are Prodo's artifact generator for WORKFLOW.
|
|
67
|
+
|
|
68
|
+
Goal:
|
|
69
|
+
- Produce paired workflow outputs for the same flow.
|
|
70
|
+
|
|
71
|
+
Output contract (STRICT):
|
|
72
|
+
- Return Markdown explanation first (no frontmatter), following required headings exactly.
|
|
73
|
+
- Include actionable flow details and contract tags like [F1].
|
|
74
|
+
- Then append a mandatory Mermaid block for the same flow:
|
|
75
|
+
\`\`\`mermaid
|
|
76
|
+
flowchart TD
|
|
77
|
+
A --> B
|
|
78
|
+
\`\`\`
|
|
79
|
+
- Do not return prose-only markdown without Mermaid.
|
|
80
|
+
|
|
81
|
+
Input immutability:
|
|
82
|
+
- Input files are read-only.
|
|
83
|
+
- Do not modify, rewrite, summarize, or optimize \`brief.md\`.
|
|
84
|
+
|
|
85
|
+
Language contract:
|
|
86
|
+
- Output text in requested language from inputContext.outputLanguage.
|
|
87
|
+
- If outputLanguage is "tr", every sentence and heading MUST be Turkish.
|
|
88
|
+
- Never mix Turkish and English in the same artifact.
|
|
89
|
+
|
|
90
|
+
Quality bar:
|
|
91
|
+
- Main flow must be implementation-ready.
|
|
92
|
+
- Edge cases and postconditions must be explicit.`;
|
|
93
|
+
}
|
|
94
|
+
if (artifactType === "wireframe") {
|
|
95
|
+
return `You are Prodo's artifact generator for WIREFRAME.
|
|
96
|
+
|
|
97
|
+
Goal:
|
|
98
|
+
- Produce a human-readable wireframe explanation in Markdown.
|
|
99
|
+
|
|
100
|
+
Output contract (STRICT):
|
|
101
|
+
- Return Markdown body only (no frontmatter).
|
|
102
|
+
- Include all required headings exactly as provided.
|
|
103
|
+
- Describe one concrete screen at a time with actionable details.
|
|
104
|
+
- HTML wireframe is generated by Prodo as a companion .html file; do not output raw HTML as primary markdown body.
|
|
105
|
+
|
|
106
|
+
Input immutability:
|
|
107
|
+
- Input files are read-only.
|
|
108
|
+
- Do not modify, rewrite, summarize, or optimize \`brief.md\`.
|
|
109
|
+
|
|
110
|
+
Language contract:
|
|
111
|
+
- Output text in requested language from inputContext.outputLanguage.
|
|
112
|
+
- If outputLanguage is "tr", every sentence and heading MUST be Turkish.
|
|
113
|
+
- Never mix Turkish and English in the same artifact.
|
|
114
|
+
|
|
115
|
+
Quality bar:
|
|
116
|
+
- Keep sections concise but specific.
|
|
117
|
+
- Ensure actions/states/messages are testable and implementation-relevant.`;
|
|
118
|
+
}
|
|
119
|
+
return `You are Prodo's artifact generator for ${artifactType.toUpperCase()}.
|
|
120
|
+
|
|
121
|
+
Goal:
|
|
122
|
+
- Produce a decision-ready product artifact from normalized brief and upstream artifacts.
|
|
123
|
+
|
|
124
|
+
Output contract:
|
|
125
|
+
- Return only Markdown body (NO YAML frontmatter).
|
|
126
|
+
- Keep all required section headings exactly as provided.
|
|
127
|
+
- When referencing brief contracts, use explicit tags like [G1], [F2], [C1].
|
|
128
|
+
- Use concrete statements, avoid placeholders like "TBD" unless unavoidable.
|
|
129
|
+
- Reference upstream constraints and tradeoffs explicitly.
|
|
130
|
+
|
|
131
|
+
Input immutability:
|
|
132
|
+
- Input files are read-only.
|
|
133
|
+
- Do not modify, rewrite, summarize, or optimize \`brief.md\`.
|
|
134
|
+
|
|
135
|
+
Language contract:
|
|
136
|
+
- Output text in requested language from inputContext.outputLanguage.
|
|
137
|
+
- If outputLanguage is "tr", every sentence and heading MUST be Turkish.
|
|
138
|
+
- Never mix Turkish and English in the same artifact.
|
|
139
|
+
- Do not translate or change required headings unless outputLanguage is "tr" and Turkish headings are provided.
|
|
140
|
+
|
|
141
|
+
Quality bar:
|
|
142
|
+
- Every section must contain actionable content.
|
|
143
|
+
- Include assumptions and risks where relevant.
|
|
144
|
+
- Keep content concise but implementation-ready.
|
|
145
|
+
|
|
146
|
+
Required headings:
|
|
147
|
+
${defaultRequiredHeadings(artifactType).map((heading) => `- ${heading}`).join("\n")}
|
|
148
|
+
|
|
149
|
+
When data is missing:
|
|
150
|
+
${tr ? "- varsayim yaparken Turkce yaz\n- varsayimi ilgili bolumde acikca belirt" : "- infer a sensible default\n- state the assumption clearly in the relevant section"}`;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export function artifactTemplateTemplate(artifactType: ArtifactType, lang = "en"): string {
|
|
154
|
+
const tr = lang.toLowerCase().startsWith("tr");
|
|
155
|
+
const base = [`# ${artifactType.toUpperCase()} Template`, ""];
|
|
156
|
+
|
|
157
|
+
if (artifactType === "prd") {
|
|
158
|
+
return [
|
|
159
|
+
...base,
|
|
160
|
+
"## Problem",
|
|
161
|
+
"- User pain and why now",
|
|
162
|
+
"- Existing workaround and gap",
|
|
163
|
+
"",
|
|
164
|
+
"## Goals",
|
|
165
|
+
"- Business goals (measurable)",
|
|
166
|
+
"- User outcomes",
|
|
167
|
+
"",
|
|
168
|
+
"## Scope",
|
|
169
|
+
"- In scope",
|
|
170
|
+
"- Out of scope",
|
|
171
|
+
"",
|
|
172
|
+
"## Requirements",
|
|
173
|
+
"- Functional requirements",
|
|
174
|
+
"- Non-functional requirements",
|
|
175
|
+
"- Compliance/security requirements",
|
|
176
|
+
"",
|
|
177
|
+
"## Risks",
|
|
178
|
+
"- Top risks and mitigations",
|
|
179
|
+
"",
|
|
180
|
+
"## Assumptions",
|
|
181
|
+
"- Key assumptions"
|
|
182
|
+
].join("\n");
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (artifactType === "workflow") {
|
|
186
|
+
return [
|
|
187
|
+
"flowchart TD",
|
|
188
|
+
` A[${tr ? "Baslangic" : "Start"}] --> B[[F1] ${tr ? "Kullanici islemi" : "User action"}]`,
|
|
189
|
+
` B --> C[${tr ? "Sistem islemi" : "System process"}]`,
|
|
190
|
+
` C --> D[${tr ? "Basari" : "Success"}]`,
|
|
191
|
+
` C --> E[${tr ? "Hata" : "Error"}]`
|
|
192
|
+
].join("\n");
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (artifactType === "wireframe") {
|
|
196
|
+
return `<!doctype html>
|
|
197
|
+
<html lang="${tr ? "tr" : "en"}">
|
|
198
|
+
<head>
|
|
199
|
+
<meta charset="utf-8" />
|
|
200
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
201
|
+
<title>${tr ? "Wireframe Ekrani" : "Wireframe Screen"}</title>
|
|
202
|
+
</head>
|
|
203
|
+
<body>
|
|
204
|
+
<header>
|
|
205
|
+
<h1>${tr ? "Ekran Basligi" : "Screen Title"}</h1>
|
|
206
|
+
<nav>
|
|
207
|
+
<button type="button">${tr ? "Geri" : "Back"}</button>
|
|
208
|
+
<button type="button">${tr ? "Devam" : "Next"}</button>
|
|
209
|
+
</nav>
|
|
210
|
+
</header>
|
|
211
|
+
<main>
|
|
212
|
+
<section>
|
|
213
|
+
<h2>${tr ? "Birincil Icerik" : "Primary Content"}</h2>
|
|
214
|
+
<ul>
|
|
215
|
+
<li>${tr ? "Durum ozeti" : "Status summary"}</li>
|
|
216
|
+
<li>${tr ? "Aksiyon alani" : "Action area"}</li>
|
|
217
|
+
</ul>
|
|
218
|
+
</section>
|
|
219
|
+
<section>
|
|
220
|
+
<h2>${tr ? "Form" : "Form"}</h2>
|
|
221
|
+
<form>
|
|
222
|
+
<label>${tr ? "Alan" : "Field"} <input type="text" /></label>
|
|
223
|
+
<button type="submit">${tr ? "Kaydet" : "Save"}</button>
|
|
224
|
+
</form>
|
|
225
|
+
</section>
|
|
226
|
+
</main>
|
|
227
|
+
</body>
|
|
228
|
+
</html>`;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (artifactType === "stories") {
|
|
232
|
+
return [
|
|
233
|
+
...base,
|
|
234
|
+
"## User Stories",
|
|
235
|
+
"- As a <user>, I want <goal>, so that <benefit>",
|
|
236
|
+
"",
|
|
237
|
+
"## Acceptance Criteria",
|
|
238
|
+
"- Given / When / Then criteria",
|
|
239
|
+
"- Negative and edge scenarios",
|
|
240
|
+
"",
|
|
241
|
+
"## Traceability",
|
|
242
|
+
"- Map each story to PRD requirement"
|
|
243
|
+
].join("\n");
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (artifactType === "techspec") {
|
|
247
|
+
return [
|
|
248
|
+
...base,
|
|
249
|
+
"## Architecture",
|
|
250
|
+
"- High-level components and boundaries",
|
|
251
|
+
"",
|
|
252
|
+
"## Data Model",
|
|
253
|
+
"- Entities, fields, relations",
|
|
254
|
+
"",
|
|
255
|
+
"## APIs",
|
|
256
|
+
"- Endpoints/interfaces and contracts",
|
|
257
|
+
"",
|
|
258
|
+
"## Risks",
|
|
259
|
+
"- Technical risks and mitigation",
|
|
260
|
+
"",
|
|
261
|
+
"## Observability",
|
|
262
|
+
"- Logs, metrics, alerts"
|
|
263
|
+
].join("\n");
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const fallbackTemplate = [
|
|
267
|
+
...base,
|
|
268
|
+
tr ? "## Ozet" : "## Summary",
|
|
269
|
+
tr ? "- Ana amac ve beklenen cikti" : "- Core intent and outcomes",
|
|
270
|
+
"",
|
|
271
|
+
tr ? "## Detaylar" : "## Details",
|
|
272
|
+
tr ? "- Kararlar, varsayimlar ve riskler" : "- Key decisions, assumptions, and risks",
|
|
273
|
+
"",
|
|
274
|
+
tr ? "## Izlenebilirlik" : "## Traceability",
|
|
275
|
+
tr ? "- Kararlari kontrat etiketleri ile eslestir" : "- Link decisions to contract tags"
|
|
276
|
+
].join("\n");
|
|
277
|
+
|
|
278
|
+
return fallbackTemplate;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export const START_BRIEF_TEMPLATE = `# Product Brief
|
|
282
|
+
|
|
283
|
+
## Product Name
|
|
284
|
+
Example Product
|
|
285
|
+
|
|
286
|
+
## Problem
|
|
287
|
+
Describe the user problem.
|
|
288
|
+
|
|
289
|
+
## Audience
|
|
290
|
+
Who this product is for.
|
|
291
|
+
|
|
292
|
+
## Core Features
|
|
293
|
+
- Feature A
|
|
294
|
+
- Feature B
|
|
295
|
+
|
|
296
|
+
## Goals
|
|
297
|
+
- Goal 1
|
|
298
|
+
- Goal 2
|
|
299
|
+
|
|
300
|
+
## Constraints
|
|
301
|
+
- Budget or timeline constraints
|
|
302
|
+
- Compliance or technical constraints
|
|
303
|
+
`;
|
|
304
|
+
|
|
305
|
+
export const NORMALIZED_BRIEF_TEMPLATE = {
|
|
306
|
+
schema_version: "1.0",
|
|
307
|
+
product_name: "Example Product",
|
|
308
|
+
problem: "Describe the user problem clearly.",
|
|
309
|
+
audience: ["Primary users"],
|
|
310
|
+
goals: ["Goal 1", "Goal 2"],
|
|
311
|
+
core_features: ["Feature A", "Feature B"],
|
|
312
|
+
constraints: ["Constraint 1"],
|
|
313
|
+
assumptions: ["Assumption 1"],
|
|
314
|
+
contracts: {
|
|
315
|
+
goals: [
|
|
316
|
+
{ id: "G1", text: "Goal 1" },
|
|
317
|
+
{ id: "G2", text: "Goal 2" }
|
|
318
|
+
],
|
|
319
|
+
core_features: [
|
|
320
|
+
{ id: "F1", text: "Feature A" },
|
|
321
|
+
{ id: "F2", text: "Feature B" }
|
|
322
|
+
],
|
|
323
|
+
constraints: [{ id: "C1", text: "Constraint 1" }]
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
export const NORMALIZE_PROMPT_TEMPLATE = `Normalize start-brief content into JSON.
|
|
328
|
+
|
|
329
|
+
Return JSON object with keys:
|
|
330
|
+
- schema_version (string)
|
|
331
|
+
- product_name (string)
|
|
332
|
+
- problem (string)
|
|
333
|
+
- audience (string[])
|
|
334
|
+
- goals (string[])
|
|
335
|
+
- core_features (string[])
|
|
336
|
+
- constraints (string[])
|
|
337
|
+
- assumptions (string[])
|
|
338
|
+
- contracts.goals[] ({id,text})
|
|
339
|
+
- contracts.core_features[] ({id,text})
|
|
340
|
+
- contracts.constraints[] ({id,text})
|
|
341
|
+
- confidence.product_name (0..1)
|
|
342
|
+
- confidence.problem (0..1)
|
|
343
|
+
- confidence.audience (0..1)
|
|
344
|
+
- confidence.goals (0..1)
|
|
345
|
+
- confidence.core_features (0..1)
|
|
346
|
+
|
|
347
|
+
Rules:
|
|
348
|
+
- do NOT invent missing critical content
|
|
349
|
+
- keep wording concise and concrete
|
|
350
|
+
- if critical field is missing, return empty and low confidence (<0.7)
|
|
351
|
+
- assign deterministic IDs: goals => G1..Gn, features => F1..Fn, constraints => C1..Cn
|
|
352
|
+
- input files are read-only; never modify, summarize, or rewrite \`brief.md\` in-place
|
|
353
|
+
- write normalized output as a new JSON object only`;
|
|
354
|
+
|
|
355
|
+
export function commandTemplate(command: WorkflowCommand): string {
|
|
356
|
+
return `---
|
|
357
|
+
description: ${command.description}
|
|
358
|
+
handoffs:
|
|
359
|
+
- label: Continue Workflow
|
|
360
|
+
agent: prodo-next
|
|
361
|
+
prompt: Continue with the next Prodo command in sequence.
|
|
362
|
+
send: true
|
|
363
|
+
run:
|
|
364
|
+
action: ${command.cliSubcommand}
|
|
365
|
+
mode: internal-runtime
|
|
366
|
+
---
|
|
367
|
+
|
|
368
|
+
## User Input
|
|
369
|
+
|
|
370
|
+
\`\`\`text
|
|
371
|
+
$ARGUMENTS
|
|
372
|
+
\`\`\`
|
|
373
|
+
|
|
374
|
+
Execution policy:
|
|
375
|
+
- Execute-first, diagnose-second.
|
|
376
|
+
- Perform only minimal prerequisite checks before execution.
|
|
377
|
+
- Do not inspect hooks or internals unless command execution fails.
|
|
378
|
+
- Input files are read-only; never modify or rewrite \`brief.md\`.
|
|
379
|
+
|
|
380
|
+
## Execution
|
|
381
|
+
|
|
382
|
+
1. Minimal prerequisites only:
|
|
383
|
+
- Confirm project is initialized (\`.prodo/\` exists).
|
|
384
|
+
- Confirm required input files for \`${command.cliSubcommand}\` exist.
|
|
385
|
+
- Confirm output location is writable.
|
|
386
|
+
|
|
387
|
+
2. Execute immediately:
|
|
388
|
+
- Execute the \`${command.cliSubcommand}\` process through Prodo internal runtime.
|
|
389
|
+
- Keep narration short and action-oriented.
|
|
390
|
+
|
|
391
|
+
3. Verify result:
|
|
392
|
+
- Confirm expected output file(s) were created/updated.
|
|
393
|
+
- Confirm command success state (exit code or validation status).
|
|
394
|
+
|
|
395
|
+
4. Diagnose only on failure:
|
|
396
|
+
- Inspect \`.prodo/hooks.yml\` only after execution failure.
|
|
397
|
+
- Explain root cause and next fix steps briefly.
|
|
398
|
+
|
|
399
|
+
## Handoff
|
|
400
|
+
|
|
401
|
+
Suggest the next slash command explicitly (for example: \`/prodo-prd\`, \`/prodo-workflow\`).`;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
export const HOOKS_TEMPLATE = `# Hook item fields:
|
|
405
|
+
# - command: string (required)
|
|
406
|
+
# - optional: boolean (default false)
|
|
407
|
+
# - enabled: boolean (default true)
|
|
408
|
+
# - condition: shell command; run hook only if condition exits 0
|
|
409
|
+
# - timeout_ms: per-attempt timeout in milliseconds (default 30000)
|
|
410
|
+
# - retry: extra retry count after first attempt (default 0)
|
|
411
|
+
# - retry_delay_ms: delay between retries (default 500)
|
|
412
|
+
#
|
|
413
|
+
# Example:
|
|
414
|
+
# hooks:
|
|
415
|
+
# before_prd:
|
|
416
|
+
# - command: "node -e \\"console.log('lint ok')\\""
|
|
417
|
+
# optional: false
|
|
418
|
+
# enabled: true
|
|
419
|
+
# condition: "node -e \\"process.exit(0)\\""
|
|
420
|
+
# timeout_ms: 15000
|
|
421
|
+
# retry: 1
|
|
422
|
+
# retry_delay_ms: 300
|
|
423
|
+
|
|
424
|
+
hooks:
|
|
425
|
+
before_normalize: []
|
|
426
|
+
after_normalize: []
|
|
427
|
+
before_prd: []
|
|
428
|
+
after_prd: []
|
|
429
|
+
before_workflow: []
|
|
430
|
+
after_workflow: []
|
|
431
|
+
before_wireframe: []
|
|
432
|
+
after_wireframe: []
|
|
433
|
+
before_stories: []
|
|
434
|
+
after_stories: []
|
|
435
|
+
before_techspec: []
|
|
436
|
+
after_techspec: []
|
|
437
|
+
before_validate: []
|
|
438
|
+
after_validate: []
|
|
439
|
+
`;
|
|
440
|
+
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export const CORE_ARTIFACT_TYPES = ["prd", "workflow", "wireframe", "stories", "techspec"] as const;
|
|
2
|
+
export const ARTIFACT_TYPES = CORE_ARTIFACT_TYPES;
|
|
3
|
+
|
|
4
|
+
export type CoreArtifactType = (typeof CORE_ARTIFACT_TYPES)[number];
|
|
5
|
+
export type ArtifactType = CoreArtifactType | string;
|
|
6
|
+
|
|
7
|
+
export type ArtifactDoc = {
|
|
8
|
+
frontmatter: Record<string, unknown>;
|
|
9
|
+
body: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type ContractCoverage = {
|
|
13
|
+
goals: string[];
|
|
14
|
+
core_features: string[];
|
|
15
|
+
constraints: string[];
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type ValidationIssue = {
|
|
19
|
+
level: "error" | "warning";
|
|
20
|
+
code: string;
|
|
21
|
+
check?: "schema" | "tag_coverage" | "semantic_consistency" | "contract_relevance";
|
|
22
|
+
artifactType?: ArtifactType;
|
|
23
|
+
file?: string;
|
|
24
|
+
field?: string;
|
|
25
|
+
message: string;
|
|
26
|
+
suggestion?: string;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type GenerateResult = {
|
|
30
|
+
body: string;
|
|
31
|
+
frontmatter?: Record<string, unknown>;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type ProviderSchemaHint = {
|
|
35
|
+
artifactType: ArtifactType | "normalize" | "semantic_consistency" | "contract_relevance";
|
|
36
|
+
requiredHeadings: string[];
|
|
37
|
+
requiredContracts: Array<keyof ContractCoverage>;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type LLMProvider = {
|
|
41
|
+
generate: (
|
|
42
|
+
prompt: string,
|
|
43
|
+
inputContext: Record<string, unknown>,
|
|
44
|
+
schemaHint: ProviderSchemaHint
|
|
45
|
+
) => Promise<GenerateResult>;
|
|
46
|
+
};
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
export async function ensureDir(dirPath: string): Promise<void> {
|
|
5
|
+
await fs.mkdir(dirPath, { recursive: true });
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export async function fileExists(filePath: string): Promise<boolean> {
|
|
9
|
+
try {
|
|
10
|
+
await fs.access(filePath);
|
|
11
|
+
return true;
|
|
12
|
+
} catch {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export async function readJsonFile<T>(filePath: string): Promise<T> {
|
|
18
|
+
const raw = await fs.readFile(filePath, "utf8");
|
|
19
|
+
return JSON.parse(raw) as T;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function timestampSlug(date = new Date()): string {
|
|
23
|
+
return date.toISOString().replace(/[:.]/g, "-");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export async function listFilesSortedByMtime(dirPath: string): Promise<string[]> {
|
|
27
|
+
const exists = await fileExists(dirPath);
|
|
28
|
+
if (!exists) return [];
|
|
29
|
+
|
|
30
|
+
const entries = await fs.readdir(dirPath);
|
|
31
|
+
const withStats = await Promise.all(
|
|
32
|
+
entries.map(async (name) => {
|
|
33
|
+
const fullPath = path.join(dirPath, name);
|
|
34
|
+
const stat = await fs.stat(fullPath);
|
|
35
|
+
return { fullPath, mtimeMs: stat.mtimeMs, isFile: stat.isFile() };
|
|
36
|
+
})
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
return withStats
|
|
40
|
+
.filter((entry) => entry.isFile)
|
|
41
|
+
.sort((a, b) => b.mtimeMs - a.mtimeMs)
|
|
42
|
+
.map((entry) => entry.fullPath);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function isPathInside(parentDir: string, candidatePath: string): boolean {
|
|
46
|
+
const parent = path.resolve(parentDir);
|
|
47
|
+
const child = path.resolve(candidatePath);
|
|
48
|
+
const relative = path.relative(parent, child);
|
|
49
|
+
return relative === "" || (!relative.startsWith("..") && !path.isAbsolute(relative));
|
|
50
|
+
}
|