@shahmarasy/prodo 0.1.4 → 0.1.5

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 (173) hide show
  1. package/README.md +201 -97
  2. package/bin/prodo.cjs +6 -6
  3. package/dist/agents/agent-registry.d.ts +13 -0
  4. package/dist/agents/agent-registry.js +79 -0
  5. package/dist/agents/anthropic/index.d.ts +9 -0
  6. package/dist/agents/anthropic/index.js +55 -0
  7. package/dist/agents/base.d.ts +25 -0
  8. package/dist/agents/base.js +71 -0
  9. package/dist/agents/google/index.d.ts +9 -0
  10. package/dist/agents/google/index.js +53 -0
  11. package/dist/agents/mock/index.d.ts +11 -0
  12. package/dist/agents/mock/index.js +26 -0
  13. package/dist/agents/openai/index.d.ts +9 -0
  14. package/dist/agents/openai/index.js +57 -0
  15. package/dist/agents/system-prompts.d.ts +3 -0
  16. package/dist/agents/system-prompts.js +32 -0
  17. package/dist/cli/agent-command-installer.d.ts +4 -0
  18. package/dist/cli/agent-command-installer.js +148 -0
  19. package/dist/cli/agent-ids.d.ts +15 -0
  20. package/dist/cli/agent-ids.js +49 -0
  21. package/dist/cli/doctor.d.ts +1 -0
  22. package/dist/cli/doctor.js +144 -0
  23. package/dist/cli/fix-tui.d.ts +4 -0
  24. package/dist/cli/fix-tui.js +79 -0
  25. package/dist/cli/index.d.ts +9 -0
  26. package/dist/cli/index.js +465 -0
  27. package/dist/cli/init-tui.d.ts +23 -0
  28. package/dist/cli/init-tui.js +176 -0
  29. package/dist/cli/init.d.ts +11 -0
  30. package/dist/cli/init.js +334 -0
  31. package/dist/cli/normalize-interactive.d.ts +8 -0
  32. package/dist/cli/normalize-interactive.js +167 -0
  33. package/dist/cli/preset-loader.d.ts +4 -0
  34. package/dist/cli/preset-loader.js +210 -0
  35. package/dist/core/artifact-registry.d.ts +11 -0
  36. package/dist/core/artifact-registry.js +49 -0
  37. package/dist/core/artifacts.d.ts +10 -0
  38. package/dist/core/artifacts.js +892 -0
  39. package/dist/core/clean.d.ts +10 -0
  40. package/dist/core/clean.js +74 -0
  41. package/dist/core/consistency.d.ts +8 -0
  42. package/dist/core/consistency.js +328 -0
  43. package/dist/core/constants.d.ts +7 -0
  44. package/dist/core/constants.js +64 -0
  45. package/dist/core/errors.d.ts +3 -0
  46. package/dist/core/errors.js +10 -0
  47. package/dist/core/fix.d.ts +31 -0
  48. package/dist/core/fix.js +188 -0
  49. package/dist/core/hook-executor.d.ts +1 -0
  50. package/dist/core/hook-executor.js +175 -0
  51. package/dist/core/markdown.d.ts +16 -0
  52. package/dist/core/markdown.js +81 -0
  53. package/dist/core/normalize.d.ts +8 -0
  54. package/dist/core/normalize.js +125 -0
  55. package/dist/core/normalized-brief.d.ts +48 -0
  56. package/dist/core/normalized-brief.js +182 -0
  57. package/dist/core/output-index.d.ts +13 -0
  58. package/dist/core/output-index.js +55 -0
  59. package/dist/core/paths.d.ts +17 -0
  60. package/dist/core/paths.js +80 -0
  61. package/dist/core/project-config.d.ts +14 -0
  62. package/dist/core/project-config.js +69 -0
  63. package/dist/core/registry.d.ts +13 -0
  64. package/dist/core/registry.js +115 -0
  65. package/dist/core/settings.d.ts +7 -0
  66. package/dist/core/settings.js +35 -0
  67. package/dist/core/template-engine.d.ts +3 -0
  68. package/dist/core/template-engine.js +43 -0
  69. package/dist/core/template-resolver.d.ts +15 -0
  70. package/dist/core/template-resolver.js +46 -0
  71. package/dist/core/templates.d.ts +33 -0
  72. package/dist/core/templates.js +440 -0
  73. package/dist/core/terminology.d.ts +21 -0
  74. package/dist/core/terminology.js +143 -0
  75. package/dist/core/tracing.d.ts +21 -0
  76. package/dist/core/tracing.js +74 -0
  77. package/dist/core/types.d.ts +35 -0
  78. package/dist/core/types.js +5 -0
  79. package/dist/core/utils.d.ts +7 -0
  80. package/dist/core/utils.js +66 -0
  81. package/dist/core/validate.d.ts +10 -0
  82. package/dist/core/validate.js +226 -0
  83. package/dist/core/validator.d.ts +5 -0
  84. package/dist/core/validator.js +76 -0
  85. package/dist/core/version.d.ts +1 -0
  86. package/dist/core/version.js +30 -0
  87. package/dist/core/workflow-commands.d.ts +7 -0
  88. package/dist/core/workflow-commands.js +29 -0
  89. package/dist/i18n/en.json +45 -0
  90. package/dist/i18n/index.d.ts +5 -0
  91. package/dist/i18n/index.js +63 -0
  92. package/dist/i18n/tr.json +45 -0
  93. package/dist/providers/index.d.ts +2 -1
  94. package/dist/providers/index.js +20 -6
  95. package/dist/providers/mock-provider.d.ts +1 -1
  96. package/dist/providers/mock-provider.js +7 -6
  97. package/dist/providers/openai-provider.d.ts +1 -1
  98. package/dist/providers/openai-provider.js +1 -1
  99. package/dist/skills/engine.d.ts +10 -0
  100. package/dist/skills/engine.js +75 -0
  101. package/dist/skills/fix-skill.d.ts +2 -0
  102. package/dist/skills/fix-skill.js +38 -0
  103. package/dist/skills/generate-artifact-skill.d.ts +2 -0
  104. package/dist/skills/generate-artifact-skill.js +32 -0
  105. package/dist/skills/generate-pipeline-skill.d.ts +2 -0
  106. package/dist/skills/generate-pipeline-skill.js +45 -0
  107. package/dist/skills/normalize-skill.d.ts +2 -0
  108. package/dist/skills/normalize-skill.js +29 -0
  109. package/dist/skills/types.d.ts +28 -0
  110. package/dist/skills/types.js +2 -0
  111. package/dist/skills/validate-skill.d.ts +2 -0
  112. package/dist/skills/validate-skill.js +29 -0
  113. package/package.json +74 -45
  114. package/src/agents/agent-registry.ts +93 -0
  115. package/src/agents/anthropic/index.ts +86 -0
  116. package/src/agents/anthropic/manifest.json +7 -0
  117. package/src/agents/base.ts +77 -0
  118. package/src/agents/google/index.ts +79 -0
  119. package/src/agents/google/manifest.json +7 -0
  120. package/src/agents/mock/index.ts +32 -0
  121. package/src/agents/mock/manifest.json +7 -0
  122. package/src/agents/openai/index.ts +83 -0
  123. package/src/agents/openai/manifest.json +7 -0
  124. package/src/agents/system-prompts.ts +35 -0
  125. package/src/{agent-command-installer.ts → cli/agent-command-installer.ts} +164 -164
  126. package/src/{agents.ts → cli/agent-ids.ts} +58 -58
  127. package/src/{doctor.ts → cli/doctor.ts} +157 -137
  128. package/src/cli/fix-tui.ts +111 -0
  129. package/src/{cli.ts → cli/index.ts} +459 -410
  130. package/src/{init-tui.ts → cli/init-tui.ts} +208 -208
  131. package/src/{init.ts → cli/init.ts} +398 -398
  132. package/src/cli/normalize-interactive.ts +241 -0
  133. package/src/{preset-loader.ts → cli/preset-loader.ts} +237 -237
  134. package/src/{artifact-registry.ts → core/artifact-registry.ts} +69 -69
  135. package/src/{artifacts.ts → core/artifacts.ts} +1081 -1072
  136. package/src/core/clean.ts +88 -0
  137. package/src/{consistency.ts → core/consistency.ts} +374 -303
  138. package/src/{constants.ts → core/constants.ts} +72 -72
  139. package/src/{errors.ts → core/errors.ts} +7 -7
  140. package/src/core/fix.ts +253 -0
  141. package/src/{hook-executor.ts → core/hook-executor.ts} +196 -196
  142. package/src/{markdown.ts → core/markdown.ts} +93 -73
  143. package/src/{normalize.ts → core/normalize.ts} +145 -137
  144. package/src/{normalized-brief.ts → core/normalized-brief.ts} +227 -206
  145. package/src/{output-index.ts → core/output-index.ts} +59 -59
  146. package/src/{paths.ts → core/paths.ts} +75 -71
  147. package/src/{project-config.ts → core/project-config.ts} +78 -78
  148. package/src/{registry.ts → core/registry.ts} +119 -119
  149. package/src/{settings.ts → core/settings.ts} +35 -35
  150. package/src/core/template-engine.ts +45 -0
  151. package/src/{template-resolver.ts → core/template-resolver.ts} +54 -54
  152. package/src/{templates.ts → core/templates.ts} +452 -452
  153. package/src/core/terminology.ts +177 -0
  154. package/src/core/tracing.ts +110 -0
  155. package/src/{types.ts → core/types.ts} +46 -46
  156. package/src/{utils.ts → core/utils.ts} +64 -64
  157. package/src/{validate.ts → core/validate.ts} +252 -246
  158. package/src/{validator.ts → core/validator.ts} +92 -92
  159. package/src/{version.ts → core/version.ts} +24 -24
  160. package/src/{workflow-commands.ts → core/workflow-commands.ts} +32 -32
  161. package/src/i18n/en.json +45 -0
  162. package/src/i18n/index.ts +58 -0
  163. package/src/i18n/tr.json +45 -0
  164. package/src/providers/index.ts +29 -12
  165. package/src/providers/mock-provider.ts +200 -199
  166. package/src/providers/openai-provider.ts +88 -88
  167. package/src/skills/engine.ts +94 -0
  168. package/src/skills/fix-skill.ts +38 -0
  169. package/src/skills/generate-artifact-skill.ts +32 -0
  170. package/src/skills/generate-pipeline-skill.ts +49 -0
  171. package/src/skills/normalize-skill.ts +29 -0
  172. package/src/skills/types.ts +36 -0
  173. package/src/skills/validate-skill.ts +29 -0
@@ -1,453 +1,453 @@
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
- - preserve original language and Unicode characters exactly from brief
351
- - never transliterate Turkish letters (ç, ğ, ı, İ, ö, ş, ü) into ASCII
352
- - if critical field is missing, return empty and low confidence (<0.7)
353
- - assign deterministic IDs: goals => G1..Gn, features => F1..Fn, constraints => C1..Cn
354
- - input files are read-only; never modify, summarize, or rewrite \`brief.md\` in-place
355
- - write normalized output as a new JSON object only`;
356
-
357
- export function commandTemplate(command: WorkflowCommand): string {
358
- const normalizeJsonGuard =
359
- command.cliSubcommand === "normalize"
360
- ? `
361
- - Normalize output format check:
362
- - \`.prodo/briefs/normalized-brief.json\` must be strict JSON object (no markdown fences).
363
- - If invalid, rewrite file as pure JSON object only.`
364
- : "";
365
- return `---
366
- description: ${command.description}
367
- handoffs:
368
- - label: Continue Workflow
369
- agent: prodo-next
370
- prompt: Continue with the next Prodo command in sequence.
371
- send: true
372
- ---
373
-
374
- ## User Input
375
-
376
- \`\`\`text
377
- $ARGUMENTS
378
- \`\`\`
379
-
380
- Execution policy:
381
- - Execute-first, diagnose-second.
382
- - Perform only minimal prerequisite checks before execution.
383
- - Do not run shell commands or CLI commands from inside the agent.
384
- - Never run \`prodo-${command.cliSubcommand}\`, \`prodo ${command.cliSubcommand}\`, or \`prodo ...\` in shell.
385
- - Do not inspect hooks or internals unless command execution fails.
386
- - Input files are read-only; never modify or rewrite \`brief.md\`.
387
- - Never print full artifact content in chat.
388
- - Write/update files first, then reply with short status + written file path(s).
389
-
390
- ## Execution
391
-
392
- 1. Minimal prerequisites only:
393
- - Confirm project is initialized (\`.prodo/\` exists).
394
- - Confirm required input files for \`${command.cliSubcommand}\` exist.
395
- - Confirm output location is writable.
396
-
397
- 2. Execute immediately:
398
- - Execute the \`${command.cliSubcommand}\` process directly using workspace files and Prodo rules.
399
- - Keep narration short and action-oriented.
400
-
401
- 3. Verify result:
402
- - Confirm expected output file(s) were created/updated under \`product-docs/\` (or \`.prodo/briefs\` for normalize).
403
- - Confirm command success state (exit code or validation status).
404
- - Confirm \`brief.md\` hash/content did not change.
405
- - Do NOT create manual fallback files under \`.prodo/artifact\` or any ad-hoc folder.
406
- ${normalizeJsonGuard}
407
-
408
- 4. Diagnose only on failure:
409
- - Inspect \`.prodo/hooks.yml\` only after execution failure.
410
- - Explain root cause and next fix steps briefly.
411
-
412
- ## Handoff
413
-
414
- Suggest the next slash command explicitly (for example: \`/prodo-prd\`, \`/prodo-workflow\`).`;
415
- }
416
-
417
- export const HOOKS_TEMPLATE = `# Hook item fields:
418
- # - command: string (required)
419
- # - optional: boolean (default false)
420
- # - enabled: boolean (default true)
421
- # - condition: shell command; run hook only if condition exits 0
422
- # - timeout_ms: per-attempt timeout in milliseconds (default 30000)
423
- # - retry: extra retry count after first attempt (default 0)
424
- # - retry_delay_ms: delay between retries (default 500)
425
- #
426
- # Example:
427
- # hooks:
428
- # before_prd:
429
- # - command: "node -e \\"console.log('lint ok')\\""
430
- # optional: false
431
- # enabled: true
432
- # condition: "node -e \\"process.exit(0)\\""
433
- # timeout_ms: 15000
434
- # retry: 1
435
- # retry_delay_ms: 300
436
-
437
- hooks:
438
- before_normalize: []
439
- after_normalize: []
440
- before_prd: []
441
- after_prd: []
442
- before_workflow: []
443
- after_workflow: []
444
- before_wireframe: []
445
- after_wireframe: []
446
- before_stories: []
447
- after_stories: []
448
- before_techspec: []
449
- after_techspec: []
450
- before_validate: []
451
- after_validate: []
452
- `;
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
+ - preserve original language and Unicode characters exactly from brief
351
+ - never transliterate Turkish letters (ç, ğ, ı, İ, ö, ş, ü) into ASCII
352
+ - if critical field is missing, return empty and low confidence (<0.7)
353
+ - assign deterministic IDs: goals => G1..Gn, features => F1..Fn, constraints => C1..Cn
354
+ - input files are read-only; never modify, summarize, or rewrite \`brief.md\` in-place
355
+ - write normalized output as a new JSON object only`;
356
+
357
+ export function commandTemplate(command: WorkflowCommand): string {
358
+ const normalizeJsonGuard =
359
+ command.cliSubcommand === "normalize"
360
+ ? `
361
+ - Normalize output format check:
362
+ - \`.prodo/briefs/normalized-brief.json\` must be strict JSON object (no markdown fences).
363
+ - If invalid, rewrite file as pure JSON object only.`
364
+ : "";
365
+ return `---
366
+ description: ${command.description}
367
+ handoffs:
368
+ - label: Continue Workflow
369
+ agent: prodo-next
370
+ prompt: Continue with the next Prodo command in sequence.
371
+ send: true
372
+ ---
373
+
374
+ ## User Input
375
+
376
+ \`\`\`text
377
+ $ARGUMENTS
378
+ \`\`\`
379
+
380
+ Execution policy:
381
+ - Execute-first, diagnose-second.
382
+ - Perform only minimal prerequisite checks before execution.
383
+ - Do not run shell commands or CLI commands from inside the agent.
384
+ - Never run \`prodo-${command.cliSubcommand}\`, \`prodo ${command.cliSubcommand}\`, or \`prodo ...\` in shell.
385
+ - Do not inspect hooks or internals unless command execution fails.
386
+ - Input files are read-only; never modify or rewrite \`brief.md\`.
387
+ - Never print full artifact content in chat.
388
+ - Write/update files first, then reply with short status + written file path(s).
389
+
390
+ ## Execution
391
+
392
+ 1. Minimal prerequisites only:
393
+ - Confirm project is initialized (\`.prodo/\` exists).
394
+ - Confirm required input files for \`${command.cliSubcommand}\` exist.
395
+ - Confirm output location is writable.
396
+
397
+ 2. Execute immediately:
398
+ - Execute the \`${command.cliSubcommand}\` process directly using workspace files and Prodo rules.
399
+ - Keep narration short and action-oriented.
400
+
401
+ 3. Verify result:
402
+ - Confirm expected output file(s) were created/updated under \`product-docs/\` (or \`.prodo/briefs\` for normalize).
403
+ - Confirm command success state (exit code or validation status).
404
+ - Confirm \`brief.md\` hash/content did not change.
405
+ - Do NOT create manual fallback files under \`.prodo/artifact\` or any ad-hoc folder.
406
+ ${normalizeJsonGuard}
407
+
408
+ 4. Diagnose only on failure:
409
+ - Inspect \`.prodo/hooks.yml\` only after execution failure.
410
+ - Explain root cause and next fix steps briefly.
411
+
412
+ ## Handoff
413
+
414
+ Suggest the next slash command explicitly (for example: \`/prodo-prd\`, \`/prodo-workflow\`).`;
415
+ }
416
+
417
+ export const HOOKS_TEMPLATE = `# Hook item fields:
418
+ # - command: string (required)
419
+ # - optional: boolean (default false)
420
+ # - enabled: boolean (default true)
421
+ # - condition: shell command; run hook only if condition exits 0
422
+ # - timeout_ms: per-attempt timeout in milliseconds (default 30000)
423
+ # - retry: extra retry count after first attempt (default 0)
424
+ # - retry_delay_ms: delay between retries (default 500)
425
+ #
426
+ # Example:
427
+ # hooks:
428
+ # before_prd:
429
+ # - command: "node -e \\"console.log('lint ok')\\""
430
+ # optional: false
431
+ # enabled: true
432
+ # condition: "node -e \\"process.exit(0)\\""
433
+ # timeout_ms: 15000
434
+ # retry: 1
435
+ # retry_delay_ms: 300
436
+
437
+ hooks:
438
+ before_normalize: []
439
+ after_normalize: []
440
+ before_prd: []
441
+ after_prd: []
442
+ before_workflow: []
443
+ after_workflow: []
444
+ before_wireframe: []
445
+ after_wireframe: []
446
+ before_stories: []
447
+ after_stories: []
448
+ before_techspec: []
449
+ after_techspec: []
450
+ before_validate: []
451
+ after_validate: []
452
+ `;
453
453