intentdna 1.7.4 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/LICENSE +201 -0
  4. package/README.md +143 -194
  5. package/dist/assets/candidates.d.ts +124 -0
  6. package/dist/assets/candidates.js +1249 -0
  7. package/dist/assets/catalog.d.ts +101 -0
  8. package/dist/assets/catalog.js +311 -0
  9. package/dist/assets/evidence.d.ts +93 -0
  10. package/dist/assets/evidence.js +391 -0
  11. package/dist/assets/index.d.ts +4 -0
  12. package/dist/assets/index.js +4 -0
  13. package/dist/assets/metadata.d.ts +19 -0
  14. package/dist/assets/metadata.js +227 -0
  15. package/dist/cli/commands/assets.d.ts +65 -0
  16. package/dist/cli/commands/assets.js +2871 -0
  17. package/dist/cli/commands/auth.d.ts +322 -0
  18. package/dist/cli/commands/auth.js +1592 -0
  19. package/dist/cli/commands/cloud-auth-guidance.d.ts +2 -0
  20. package/dist/cli/commands/cloud-auth-guidance.js +4 -0
  21. package/dist/cli/commands/cloud.d.ts +1359 -0
  22. package/dist/cli/commands/cloud.js +8364 -0
  23. package/dist/cli/commands/evolve.js +18 -2
  24. package/dist/cli/commands/generate.js +25 -2
  25. package/dist/cli/commands/guard.d.ts +1 -1
  26. package/dist/cli/commands/guard.js +1 -1
  27. package/dist/cli/commands/guide.d.ts +15 -0
  28. package/dist/cli/commands/guide.js +1747 -0
  29. package/dist/cli/commands/init.d.ts +12 -0
  30. package/dist/cli/commands/init.js +95 -60
  31. package/dist/cli/commands/org.d.ts +16 -0
  32. package/dist/cli/commands/org.js +2393 -0
  33. package/dist/cli/commands/release.d.ts +59 -0
  34. package/dist/cli/commands/release.js +716 -0
  35. package/dist/cli/commands/report.d.ts +82 -0
  36. package/dist/cli/commands/report.js +1516 -0
  37. package/dist/cli/commands/run.d.ts +6 -1
  38. package/dist/cli/commands/run.js +95 -26
  39. package/dist/cli/commands/sync.d.ts +8 -1
  40. package/dist/cli/commands/sync.js +436 -141
  41. package/dist/cli/commands/templates.d.ts +64 -0
  42. package/dist/cli/commands/templates.js +2151 -1
  43. package/dist/cli/commands/workflow.d.ts +26 -0
  44. package/dist/cli/commands/workflow.js +3053 -0
  45. package/dist/cli/index.js +719 -42
  46. package/dist/compiler/cascade.js +4 -9
  47. package/dist/compiler/compile.js +1 -0
  48. package/dist/governance/evidence-capture-attribution.d.ts +12 -0
  49. package/dist/governance/evidence-capture-attribution.js +46 -0
  50. package/dist/governance/index.d.ts +2 -0
  51. package/dist/governance/index.js +1 -0
  52. package/dist/hooks/cli.d.ts +6 -0
  53. package/dist/hooks/cli.js +168 -12
  54. package/dist/hooks/enforce.d.ts +1 -0
  55. package/dist/hooks/protocol.d.ts +1 -1
  56. package/dist/hooks/protocol.js +1 -1
  57. package/dist/hooks/state.d.ts +41 -0
  58. package/dist/hooks/state.js +126 -2
  59. package/dist/index.d.ts +3 -0
  60. package/dist/index.js +3 -0
  61. package/dist/mcp/tools-state.js +2 -0
  62. package/dist/organization/index.d.ts +121 -0
  63. package/dist/organization/index.js +413 -0
  64. package/dist/runtime/claude-sync-target.d.ts +49 -0
  65. package/dist/runtime/claude-sync-target.js +280 -0
  66. package/dist/runtime/codex-adapter.d.ts +254 -0
  67. package/dist/runtime/codex-adapter.js +1204 -0
  68. package/dist/runtime/codex-sync-target.d.ts +33 -0
  69. package/dist/runtime/codex-sync-target.js +241 -0
  70. package/dist/runtime/index.d.ts +8 -0
  71. package/dist/runtime/index.js +4 -0
  72. package/dist/runtime/output-artifact-registry.d.ts +1 -1
  73. package/dist/runtime/output-artifact-registry.js +2 -0
  74. package/dist/runtime/settings-adapter.d.ts +1 -1
  75. package/dist/runtime/settings-adapter.js +1 -1
  76. package/dist/runtime/skill-adapter.d.ts +5 -1
  77. package/dist/runtime/skill-adapter.js +120 -34
  78. package/dist/runtime/sync-artifact-registry.d.ts +99 -0
  79. package/dist/runtime/sync-artifact-registry.js +194 -0
  80. package/dist/runtime/sync-target-plan.d.ts +45 -0
  81. package/dist/runtime/sync-target-plan.js +19 -0
  82. package/dist/schema/controller-registry.d.ts +8 -1
  83. package/dist/schema/controller-registry.js +8 -0
  84. package/dist/schema/types.d.ts +35 -23
  85. package/dist/schema/types.js +10 -1
  86. package/dist/schema/validate.js +22 -22
  87. package/dist/schema/validators/controllers.js +38 -20
  88. package/dist/schema/workflow-authoring-contract.d.ts +29 -0
  89. package/dist/schema/workflow-authoring-contract.js +109 -0
  90. package/dist/schema/yaml-parser.js +18 -0
  91. package/dist/templates/api-backend.dna.yaml +19 -0
  92. package/dist/templates/brainstorming-first.dna.yaml +19 -0
  93. package/dist/templates/code-cleanup.dna.yaml +19 -0
  94. package/dist/templates/code-review-pipeline.dna.yaml +18 -0
  95. package/dist/templates/documentation-writer.dna.yaml +19 -0
  96. package/dist/templates/flutter-behavior-lock.dna.yaml +19 -0
  97. package/dist/templates/flutter-refactoring-rescue.dna.yaml +19 -0
  98. package/dist/templates/flutter-rewrite-diagnosis-review.dna.yaml +210 -0
  99. package/dist/templates/flutter-rewrite-fix-review-loop.dna.yaml +260 -0
  100. package/dist/templates/flutter-rewrite-new.dna.yaml +506 -0
  101. package/dist/templates/flutter-rewrite.dna.yaml +20 -0
  102. package/dist/templates/frontend-quality.dna.yaml +19 -0
  103. package/dist/templates/full-pipeline.dna.yaml +20 -0
  104. package/dist/templates/marketplace.d.ts +92 -0
  105. package/dist/templates/marketplace.js +502 -0
  106. package/dist/templates/metadata.d.ts +25 -0
  107. package/dist/templates/metadata.js +136 -3
  108. package/dist/templates/mobile-dev.dna.yaml +19 -0
  109. package/dist/templates/multi-agent-handoff-coordination.dna.yaml +156 -0
  110. package/dist/templates/multi-perspective-review.dna.yaml +19 -0
  111. package/dist/templates/persistent-executor.dna.yaml +19 -0
  112. package/dist/templates/qa-loop.dna.yaml +18 -0
  113. package/dist/templates/release-evidence-gate.dna.yaml +131 -0
  114. package/dist/templates/requirements-gate.dna.yaml +19 -0
  115. package/dist/templates/research-orchestration.dna.yaml +19 -0
  116. package/dist/templates/root-cause-analysis.dna.yaml +19 -0
  117. package/dist/templates/safe-refactoring.dna.yaml +321 -0
  118. package/dist/templates/secure-dev.dna.yaml +19 -0
  119. package/dist/templates/subagent-parallel.dna.yaml +19 -0
  120. package/dist/templates/systematic-debugging.dna.yaml +19 -0
  121. package/dist/templates/tdd-strict.dna.yaml +19 -0
  122. package/dist/templates/ui-visual-regression-qa.dna.yaml +133 -0
  123. package/dist/templates/workflow-author.dna.yaml +302 -0
  124. package/dist/templates/workflow-blocked-scope-triage.dna.yaml +242 -0
  125. package/dist/templates/workflow-completion-audit.dna.yaml +254 -0
  126. package/dist/templates/workflow-cross-boundary-resource-approval.dna.yaml +249 -0
  127. package/dist/templates/workflow-evidence-review.dna.yaml +198 -0
  128. package/dist/templates/workflow-module-inventory.dna.yaml +257 -0
  129. package/dist/templates/workflow-runtime-smoke-review.dna.yaml +252 -0
  130. package/dist/templates/workflow-verification-command-routing.dna.yaml +278 -0
  131. package/dist/workflow/authoring-packet.d.ts +67 -0
  132. package/dist/workflow/authoring-packet.js +218 -0
  133. package/dist/workflow/draft.d.ts +159 -0
  134. package/dist/workflow/draft.js +800 -0
  135. package/dist/workflow/index.d.ts +3 -0
  136. package/dist/workflow/index.js +3 -0
  137. package/dist/workflow/suggestion-review.d.ts +65 -0
  138. package/dist/workflow/suggestion-review.js +245 -0
  139. package/package.json +1 -1
  140. package/spec/README.md +15 -48
  141. package/spec/codex-adapter-contract.md +176 -0
  142. package/spec/sync-target-plan.md +158 -0
  143. package/spec/workflow-capability-ir.md +153 -0
  144. package/spec/agent-dispatch-fix.md +0 -116
  145. package/spec/control-plane-convergence-handoff-2026-04-24.md +0 -432
  146. package/spec/flutter-rewrite-template-optimization.md +0 -301
  147. package/spec/foundation-hardening.md +0 -178
  148. package/spec/hooks-infra-harness-hardening.md +0 -741
  149. package/spec/multi-config.md +0 -172
  150. package/spec/parallel-isolation.md +0 -268
  151. package/spec/template-version-namespace-fix.md +0 -653
  152. package/spec/workflow-pipeline.md +0 -101
@@ -0,0 +1,502 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import { parseYAML } from "../schema/yaml-parser.js";
3
+ import { getWorkflowAssetMetadata } from "../assets/metadata.js";
4
+ import { listTemplateCatalog } from "./catalog.js";
5
+ function isRecord(value) {
6
+ return typeof value === "object" && value !== null && !Array.isArray(value);
7
+ }
8
+ function recordSize(value) {
9
+ return isRecord(value) ? Object.keys(value).length : 0;
10
+ }
11
+ function hasWorkflow(data) {
12
+ return recordSize(data.workflows) > 0 || isRecord(data.workflow);
13
+ }
14
+ function hasControllers(data) {
15
+ return recordSize(data.controllers) > 0;
16
+ }
17
+ function hasRoles(data) {
18
+ return recordSize(data.roles) > 0;
19
+ }
20
+ function templateLabel(template) {
21
+ return template.displayName ?? template.name
22
+ .split("-")
23
+ .map((part) => part.length <= 3 ? part.toUpperCase() : `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`)
24
+ .join(" ");
25
+ }
26
+ function productPurpose(template, data) {
27
+ const text = `${template.name} ${template.displayName ?? ""} ${template.keywords.join(" ")}`.toLowerCase();
28
+ const label = templateLabel(template);
29
+ if (text.includes("flutter") && (text.includes("rewrite") || text.includes("migration"))) {
30
+ return "Govern high-risk Flutter rewrites with behavior truth, diagnosis review, bounded fixes, and verification evidence.";
31
+ }
32
+ if (text.includes("review")) {
33
+ return "Turn code, workflow, or evidence review into a repeatable route with explicit findings and follow-up gates.";
34
+ }
35
+ if (text.includes("release") || text.includes("deploy")) {
36
+ return "Gate public release work with deploy planning, verification commands, and reviewable release evidence.";
37
+ }
38
+ if (text.includes("debug") || text.includes("root-cause") || text.includes("incident")) {
39
+ return "Structure incident or debugging work around hypotheses, evidence, root cause, and regression checks.";
40
+ }
41
+ if (text.includes("cleanup") || text.includes("refactor")) {
42
+ return "Clean up or refactor code while preserving behavior, limiting scope, and recording verification.";
43
+ }
44
+ if (text.includes("tdd") || text.includes("test") || text.includes("qa")) {
45
+ return "Make test or QA work repeatable by defining evidence, verification commands, and acceptance gates.";
46
+ }
47
+ if (text.includes("security") || text.includes("secure") || text.includes("enterprise")) {
48
+ return "Apply security or enterprise guardrails to local AI work without moving runtime authority online.";
49
+ }
50
+ if (text.includes("research") || text.includes("brainstorm")) {
51
+ return "Coordinate research or ideation into evidence-backed options before implementation.";
52
+ }
53
+ if (text.includes("documentation") || text.includes("doc")) {
54
+ return "Produce maintainable documentation, handoff material, or project knowledge with reviewable outputs.";
55
+ }
56
+ if (hasWorkflow(data) || hasRoles(data)) {
57
+ return `Package ${label} as a governed workflow asset with roles, steps, boundaries, and local sync outputs.`;
58
+ }
59
+ return `Package ${label} as local DNA constraints and guidance for repeatable AI-assisted work.`;
60
+ }
61
+ function hasAnyTerm(text, terms) {
62
+ return terms.some((term) => new RegExp(`(^|[^a-z0-9])${term.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}([^a-z0-9]|$)`).test(text));
63
+ }
64
+ function productFit(template, data) {
65
+ const yamlName = typeof data.name === "string" ? data.name : "";
66
+ const text = `${template.name} ${template.displayName ?? ""} ${yamlName} ${template.keywords.join(" ")}`.toLowerCase();
67
+ const fit = new Set();
68
+ if (hasAnyTerm(text, ["api", "backend"]))
69
+ fit.add("Backend/API teams that need consistent implementation and review boundaries");
70
+ if (hasAnyTerm(text, ["frontend", "ui", "visual"]))
71
+ fit.add("Frontend teams shipping user-facing changes with visual and accessibility checks");
72
+ if (hasAnyTerm(text, ["mobile", "ios", "android"]))
73
+ fit.add("Mobile teams coordinating app changes across platform-specific constraints");
74
+ if (hasAnyTerm(text, ["documentation", "doc", "docs", "readme", "wiki"]))
75
+ fit.add("Teams turning implementation knowledge into maintainable docs and handoff material");
76
+ if (hasAnyTerm(text, ["requirements"]))
77
+ fit.add("Teams that need requirements clarified before implementation begins");
78
+ if (hasAnyTerm(text, ["research", "brainstorm", "ideation"]))
79
+ fit.add("Teams exploring options before committing to an implementation path");
80
+ if (hasAnyTerm(text, ["performance", "profiling", "benchmark", "latency"]))
81
+ fit.add("Teams investigating latency, throughput, or resource-use regressions");
82
+ if (hasAnyTerm(text, ["debug", "debugging", "troubleshoot", "root-cause", "root cause", "bug fix"]))
83
+ fit.add("Teams debugging failures through reproduction, hypotheses, evidence, and regression checks");
84
+ if (hasAnyTerm(text, ["cleanup", "clean up"]))
85
+ fit.add("Teams cleaning code by smell type while preserving current behavior and tests");
86
+ if (hasAnyTerm(text, ["incident", "hotfix", "outage", "postmortem"]))
87
+ fit.add("Production support teams handling incidents, hotfixes, and follow-up evidence");
88
+ if (hasAnyTerm(text, ["monorepo", "workspace", "packages"]))
89
+ fit.add("Monorepo teams coordinating package boundaries, ownership, and workspace-wide changes");
90
+ if (hasAnyTerm(text, ["branch", "pr", "pull", "request"]))
91
+ fit.add("Teams preparing branch closure, pull requests, or review-ready handoffs");
92
+ if (hasAnyTerm(text, ["persistent", "yolo"]))
93
+ fit.add("Operators who need faster autonomous execution while preserving explicit guardrails");
94
+ if (text.includes("flutter"))
95
+ fit.add("Flutter or mobile migration teams");
96
+ if (text.includes("rewrite") || text.includes("migration") || text.includes("refactor"))
97
+ fit.add("High-risk behavior-preserving code changes");
98
+ if (text.includes("review"))
99
+ fit.add("Teams that need independent review before adoption or rollout");
100
+ if (text.includes("release") || text.includes("deploy"))
101
+ fit.add("Public web or release workflows that require deployment evidence");
102
+ if (text.includes("security") || text.includes("secure") || text.includes("enterprise"))
103
+ fit.add("Security-sensitive repositories with strict tool and secret boundaries");
104
+ if (text.includes("qa") || text.includes("test") || text.includes("verification"))
105
+ fit.add("Workflows where pass/fail evidence must be explicit");
106
+ if (text.includes("multi-agent") || text.includes("subagent") || text.includes("handoff"))
107
+ fit.add("Multi-agent work that needs owned handoff artifacts");
108
+ if (hasControllers(data))
109
+ fit.add("Long-running workflows with stop conditions and progress evidence");
110
+ if (fit.size === 0)
111
+ fit.add("Teams turning a repeated AI work method into a reusable local workflow asset");
112
+ return [...fit].slice(0, 4);
113
+ }
114
+ function productInputs(data) {
115
+ const variables = isRecord(data.variables) ? data.variables : {};
116
+ const inputs = Object.entries(variables).flatMap(([key, value]) => {
117
+ if (!isRecord(value))
118
+ return [`${key}: project-specific value`];
119
+ const description = typeof value.description === "string" ? value.description : "project-specific value";
120
+ const defaultValue = typeof value.default === "string" ? ` (default: ${value.default})` : "";
121
+ return [`${key}: ${description}${defaultValue}`];
122
+ });
123
+ if (inputs.length > 0)
124
+ return inputs.slice(0, 6);
125
+ return ["Project context and the selected local workflow goal"];
126
+ }
127
+ function collectProducedArtifacts(value, outputs) {
128
+ if (Array.isArray(value)) {
129
+ for (const item of value)
130
+ collectProducedArtifacts(item, outputs);
131
+ return;
132
+ }
133
+ if (!isRecord(value))
134
+ return;
135
+ if (typeof value.path === "string")
136
+ outputs.add(value.path);
137
+ for (const child of Object.values(value))
138
+ collectProducedArtifacts(child, outputs);
139
+ }
140
+ function productOutputs(data) {
141
+ const outputs = new Set();
142
+ if (hasWorkflow(data))
143
+ outputs.add("Workflow steps and handoff contracts for local harness execution");
144
+ if (hasRoles(data))
145
+ outputs.add("Role instructions and tool/scope boundaries");
146
+ if (hasControllers(data))
147
+ outputs.add("Controller stop conditions and progress evidence");
148
+ outputs.add("Compiled IR and local sync artifacts");
149
+ collectProducedArtifacts(data.workflows, outputs);
150
+ return [...outputs].slice(0, 8);
151
+ }
152
+ function evidencePosture(examples) {
153
+ if (examples.some((example) => example.kind === "dogfood"))
154
+ return "dogfood";
155
+ return examples.length > 0 ? "example" : "explicit_gap";
156
+ }
157
+ function templateEvidenceGap(templateName, examples) {
158
+ if (examples.length > 0) {
159
+ return {
160
+ status: "covered_by_examples",
161
+ summary: "This workflow asset has attached evidence examples for marketplace selection and local review.",
162
+ nextCommands: [
163
+ `dna assets inspect ${templateName} --evidence`,
164
+ `dna assets adoption ${templateName}`,
165
+ ],
166
+ acceptanceCriteria: [
167
+ "Evidence examples are inspectable from the local CLI.",
168
+ "Adoption review can explain whether the asset is ready for local bind, rollout, and sync.",
169
+ ],
170
+ notEvidence: [
171
+ "Attached examples do not prove this asset is installed in the user's project.",
172
+ "Attached examples do not grant runtime authority or org-private visibility.",
173
+ ],
174
+ };
175
+ }
176
+ return {
177
+ status: "needs_local_evidence",
178
+ summary: "No public example or dogfood evidence is attached yet; run the asset locally before using it as adoption proof.",
179
+ nextCommands: [
180
+ `dna templates show ${templateName}`,
181
+ `dna init --template ${templateName}`,
182
+ "dna sync --dry-run",
183
+ "dna sync",
184
+ "dna report package --json",
185
+ "dna report sign --package .dna/reports/latest-report-package.json --output .dna/reports/ingest/local-envelope.json --json",
186
+ "dna report verify .dna/reports/ingest/local-envelope.json --json",
187
+ ],
188
+ acceptanceCriteria: [
189
+ "A local report package exists for a real run of this asset.",
190
+ "The signed local envelope verifies with runtime_authority=false.",
191
+ "The evidence can be attached to a later template review or adoption packet without exposing secrets.",
192
+ ],
193
+ notEvidence: [
194
+ "Catalog metadata alone is not adoption evidence.",
195
+ "Browser-local selection is not trusted evidence.",
196
+ "A dry-run install plan is not workflow execution.",
197
+ "Online projection is not runtime approval or org-private publication.",
198
+ ],
199
+ };
200
+ }
201
+ function assetMaturity(visibility, posture, data) {
202
+ if (visibility === "internal_ready")
203
+ return "internal_ready";
204
+ if (posture === "dogfood")
205
+ return "dogfood";
206
+ if (hasWorkflow(data) || hasControllers(data) || hasRoles(data))
207
+ return "reviewed";
208
+ return "draft";
209
+ }
210
+ function lifecycleGuide(visibility, maturity, templateName) {
211
+ if (visibility === "personal") {
212
+ return {
213
+ state: "personal",
214
+ meaning: "Project-local workflow asset or draft visible from the local template catalog.",
215
+ availableNow: [
216
+ "Inspect with dna templates show/manage.",
217
+ "Adapt through a reviewable draft instead of mutating the original asset.",
218
+ "Install and sync locally after explicit review.",
219
+ ],
220
+ nextStep: `Run dna assets adoption ${templateName}, then bind it locally only if the review passes.`,
221
+ notAllowedToImply: [
222
+ "organization approval",
223
+ "durable cloud storage",
224
+ "team-wide visibility",
225
+ "runtime execution",
226
+ "runtime authority",
227
+ ],
228
+ };
229
+ }
230
+ if (visibility === "internal_ready") {
231
+ return {
232
+ state: "internal_ready",
233
+ meaning: "Adoption candidate that is structured enough for local organization review.",
234
+ availableNow: [
235
+ "Review evidence and maturity locally.",
236
+ "Bind to a local organization/project profile after manager review.",
237
+ "Prepare a SaaS org-private publication handoff only after auth, RLS, scoped token, storage, and audit gates pass.",
238
+ ],
239
+ nextStep: `Run dna org bind --asset ${templateName} --status active --sync-target codex, then dna org rollout.`,
240
+ notAllowedToImply: [
241
+ "org_private SaaS catalog visibility",
242
+ "authenticated organization membership",
243
+ "publish/unpublish audit",
244
+ "runtime authority",
245
+ ],
246
+ };
247
+ }
248
+ return {
249
+ state: "public",
250
+ meaning: maturity === "dogfood"
251
+ ? "Built-in public workflow asset with dogfood or example evidence for selection and local install."
252
+ : "Built-in public workflow asset available for browsing, comparison, and local install.",
253
+ availableNow: [
254
+ "Browse and compare in the marketplace catalog.",
255
+ "Initialize with dna init.",
256
+ "Preview sync before writing harness artifacts.",
257
+ "Run the workflow only in the local harness after sync.",
258
+ ],
259
+ nextStep: `Run dna templates show ${templateName}, then dna init --template ${templateName}.`,
260
+ notAllowedToImply: [
261
+ "automatic fit for every project",
262
+ "installed state",
263
+ "approval",
264
+ "workflow execution",
265
+ "runtime authority",
266
+ ],
267
+ };
268
+ }
269
+ function templateEvidenceExamples(templateName, data) {
270
+ const metadata = getWorkflowAssetMetadata(templateName);
271
+ const examples = [];
272
+ for (const link of metadata?.evidence ?? []) {
273
+ examples.push({
274
+ label: link.label,
275
+ path: link.path,
276
+ kind: link.kind,
277
+ description: link.description,
278
+ });
279
+ }
280
+ if (Array.isArray(data.evidence)) {
281
+ for (const entry of data.evidence) {
282
+ if (!isRecord(entry))
283
+ continue;
284
+ if (typeof entry.label !== "string" || typeof entry.path !== "string")
285
+ continue;
286
+ if (entry.kind !== "doc" && entry.kind !== "dogfood" && entry.kind !== "reference")
287
+ continue;
288
+ examples.push({
289
+ label: entry.label,
290
+ path: entry.path,
291
+ kind: entry.kind,
292
+ description: typeof entry.description === "string" ? entry.description : undefined,
293
+ });
294
+ }
295
+ }
296
+ const seen = new Set();
297
+ return examples.filter((example) => {
298
+ const key = `${example.kind}:${example.path}`;
299
+ if (seen.has(key))
300
+ return false;
301
+ seen.add(key);
302
+ return true;
303
+ }).slice(0, 4);
304
+ }
305
+ function supportedHarnesses(data) {
306
+ const harnesses = ["claude_code"];
307
+ if (hasWorkflow(data) || hasControllers(data) || hasRoles(data))
308
+ harnesses.push("codex_cli");
309
+ return harnesses;
310
+ }
311
+ function syncSurfaces(data) {
312
+ const surfaces = ["markdown_injection", "compiled_ir", "claude_mcp"];
313
+ if (hasRoles(data))
314
+ surfaces.push("claude_agents");
315
+ if (hasWorkflow(data) || hasControllers(data)) {
316
+ surfaces.push("claude_skills", "workflow_scripts", "codex_adapter");
317
+ }
318
+ if (recordSize(data.genes) > 0 || hasWorkflow(data) || hasControllers(data))
319
+ surfaces.push("claude_settings_hooks");
320
+ return [...new Set(surfaces)];
321
+ }
322
+ function templateSyncCommands(data) {
323
+ const commands = ["dna sync --dry-run", "dna sync"];
324
+ if (supportedHarnesses(data).includes("codex_cli")) {
325
+ commands.push("dna sync --codex --dry-run", "dna sync --codex");
326
+ }
327
+ return [...new Set(commands)];
328
+ }
329
+ function templateReviewRoute(templateName) {
330
+ return {
331
+ inspectCommand: `dna assets inspect ${templateName} --evidence`,
332
+ adoptionCommand: `dna assets adoption ${templateName}`,
333
+ orgBindCommand: `dna org bind --asset ${templateName} --status active --sync-target codex`,
334
+ orgReviewCommand: "dna org review",
335
+ rolloutCommand: "dna org rollout",
336
+ boundary: "Review, adoption, org binding, and rollout are local dna routes; marketplace metadata does not create org_private visibility or runtime authority.",
337
+ };
338
+ }
339
+ function templateAssetRelations(templateName) {
340
+ if (templateName === "flutter-rewrite") {
341
+ return [
342
+ {
343
+ relatedTemplate: "flutter-rewrite-fix-review-loop",
344
+ relation: "reusable_loop",
345
+ purpose: "The fix loop is the reusable inner diagnosis-backed fix/review/verify loop inside the full Flutter rewrite workflow.",
346
+ preserves: [
347
+ "flutter-rewrite remains the complete rewrite workflow asset.",
348
+ "The fix loop remains a separate reusable asset for bounded fix rounds.",
349
+ "Using the loop does not remove scanner, test writer, analyzer, diagnosis review, or PASS gates from flutter-rewrite.",
350
+ ],
351
+ nextCommands: [
352
+ "dna templates show flutter-rewrite-fix-review-loop",
353
+ "dna assets inspect flutter-rewrite --evidence",
354
+ ],
355
+ notAllowedToImply: [
356
+ "source template deletion",
357
+ "source template replacement",
358
+ "automatic adoption",
359
+ "workflow execution",
360
+ "runtime authority",
361
+ ],
362
+ },
363
+ {
364
+ relatedTemplate: "flutter-rewrite-active-followup",
365
+ relation: "followup_draft",
366
+ purpose: "The active follow-up is a reviewable unfinished-work draft for dogfood evidence, not a replacement for the original workflow.",
367
+ preserves: [
368
+ "flutter-rewrite remains the original workflow asset.",
369
+ "flutter-rewrite-fix-review-loop remains the reusable fix loop asset.",
370
+ "The follow-up draft requires diff, adoption, organization bind, and rollout review before local use.",
371
+ ],
372
+ nextCommands: [
373
+ "dna assets diff flutter-rewrite flutter-rewrite-active-followup",
374
+ "dna assets adoption flutter-rewrite-active-followup",
375
+ "dna org bind --asset flutter-rewrite-active-followup --status active --sync-target codex",
376
+ ],
377
+ notAllowedToImply: [
378
+ "source template deletion",
379
+ "source template replacement",
380
+ "automatic adoption",
381
+ "org_private visibility",
382
+ "workflow execution",
383
+ "runtime authority",
384
+ ],
385
+ },
386
+ ];
387
+ }
388
+ if (templateName === "flutter-rewrite-fix-review-loop") {
389
+ return [
390
+ {
391
+ relatedTemplate: "flutter-rewrite",
392
+ relation: "main_workflow",
393
+ purpose: "This asset extracts the bounded fix/review/verify loop from the full Flutter rewrite workflow so teams can reuse the loop without starting the whole rewrite route.",
394
+ preserves: [
395
+ "flutter-rewrite remains the full behavior-preserving rewrite workflow.",
396
+ "This loop does not replace behavior documentation, diagnosis approval, or final PASS criteria.",
397
+ ],
398
+ nextCommands: [
399
+ "dna templates show flutter-rewrite",
400
+ "dna assets inspect flutter-rewrite-fix-review-loop --evidence",
401
+ ],
402
+ notAllowedToImply: [
403
+ "full rewrite workflow deletion",
404
+ "automatic PASS",
405
+ "workflow execution",
406
+ "runtime authority",
407
+ ],
408
+ },
409
+ ];
410
+ }
411
+ if (templateName === "flutter-rewrite-active-followup") {
412
+ return [
413
+ {
414
+ relatedTemplate: "flutter-rewrite",
415
+ relation: "followup_draft",
416
+ purpose: "This draft records unfinished dogfood follow-up work for review before a manager accepts, binds, or rolls it out locally.",
417
+ preserves: [
418
+ "flutter-rewrite remains the original workflow asset.",
419
+ "The reusable fix loop remains separate and available.",
420
+ "This draft is not installed until local review and adoption gates pass.",
421
+ ],
422
+ nextCommands: [
423
+ "dna assets diff flutter-rewrite flutter-rewrite-active-followup",
424
+ "dna assets adoption flutter-rewrite-active-followup",
425
+ "dna org rollout",
426
+ ],
427
+ notAllowedToImply: [
428
+ "source template deletion",
429
+ "source template replacement",
430
+ "automatic adoption",
431
+ "org_private visibility",
432
+ "workflow execution",
433
+ "runtime authority",
434
+ ],
435
+ },
436
+ ];
437
+ }
438
+ return [];
439
+ }
440
+ export async function getTemplateMarketplaceMetadata(template, options) {
441
+ const content = options?.content ?? await readFile(template.path, "utf-8");
442
+ const parsed = parseYAML(content);
443
+ const data = isRecord(parsed) ? parsed : {};
444
+ const visibility = template.source === "project" ? "personal" : "public";
445
+ const examples = templateEvidenceExamples(template.name, data);
446
+ const posture = evidencePosture(examples);
447
+ const maturity = assetMaturity(visibility, posture, data);
448
+ const syncCommands = templateSyncCommands(data);
449
+ return {
450
+ visibility,
451
+ purpose: productPurpose(template, data),
452
+ fit: productFit(template, data),
453
+ inputs: productInputs(data),
454
+ outputs: productOutputs(data),
455
+ assetRelations: templateAssetRelations(template.name),
456
+ evidencePosture: posture,
457
+ evidenceGap: templateEvidenceGap(template.name, examples),
458
+ maturity,
459
+ lifecycleGuide: lifecycleGuide(visibility, maturity, template.name),
460
+ supportedHarnesses: supportedHarnesses(data),
461
+ requiredDnaVersion: ">=1.7.5",
462
+ syncSurfaces: syncSurfaces(data),
463
+ evidenceExamples: examples,
464
+ install: {
465
+ command: `dna init --template ${template.name}`,
466
+ syncCommands,
467
+ },
468
+ review: templateReviewRoute(template.name),
469
+ };
470
+ }
471
+ export async function buildTemplateMarketplaceCatalog(options) {
472
+ const templates = await listTemplateCatalog({ projectDir: options?.projectDir });
473
+ const items = await Promise.all(templates.map(async (template) => ({
474
+ name: template.name,
475
+ displayName: template.displayName,
476
+ namespace: template.namespace,
477
+ version: template.version,
478
+ source: template.source,
479
+ contentHash: template.contentHash,
480
+ keywords: template.keywords,
481
+ marketplace: await getTemplateMarketplaceMetadata(template),
482
+ })));
483
+ return {
484
+ schema_version: "intentdna.template_marketplace_catalog.v1",
485
+ generated_at: options?.generatedAt ?? new Date().toISOString(),
486
+ totals: {
487
+ templates: items.length,
488
+ public: items.filter((item) => item.marketplace.visibility === "public").length,
489
+ personal: items.filter((item) => item.marketplace.visibility === "personal").length,
490
+ internal_ready: items.filter((item) => item.marketplace.visibility === "internal_ready").length,
491
+ claude_code: items.filter((item) => item.marketplace.supportedHarnesses.includes("claude_code")).length,
492
+ codex_cli: items.filter((item) => item.marketplace.supportedHarnesses.includes("codex_cli")).length,
493
+ },
494
+ items,
495
+ boundaries: [
496
+ "Template marketplace catalog is asset distribution metadata, not workflow runtime.",
497
+ "Templates install into local projects through dna init and dna sync; Claude Code/Codex execute the workflow after sync.",
498
+ "Public, personal, and internal_ready are asset lifecycle states; org_private requires SaaS auth, RLS, storage, permissions, and audit.",
499
+ "External workflow references may inform drafts, but this catalog contains IntentDNA templates only.",
500
+ ],
501
+ };
502
+ }
@@ -1,6 +1,31 @@
1
1
  export interface TemplateMatchMetadata {
2
2
  name: string;
3
3
  keywords: readonly string[];
4
+ intent_signals?: readonly TemplateIntentSignal[];
4
5
  }
6
+ export interface TemplateIntentSignal {
7
+ keywords: readonly string[];
8
+ signal: string;
9
+ weight: number;
10
+ }
11
+ export declare const WORKFLOW_ASSET_IDS: {
12
+ readonly default: "flutter-rewrite";
13
+ readonly behaviorLock: "flutter-behavior-lock";
14
+ readonly refactoringRescue: "flutter-refactoring-rescue";
15
+ readonly rewriteDiagnosisReview: "flutter-rewrite-diagnosis-review";
16
+ readonly rewriteFixReviewLoop: "flutter-rewrite-fix-review-loop";
17
+ readonly rewriteActiveFollowup: "flutter-rewrite-active-followup";
18
+ readonly author: "workflow-author";
19
+ readonly blockedScopeTriage: "workflow-blocked-scope-triage";
20
+ readonly crossBoundaryResourceApproval: "workflow-cross-boundary-resource-approval";
21
+ readonly verificationCommandRouting: "workflow-verification-command-routing";
22
+ };
23
+ export declare const WORKFLOW_SUGGESTION_IDS: {
24
+ readonly activeFollowup: "template-active-followup";
25
+ readonly blockedTriage: "template-blocked-triage";
26
+ readonly c5CapturedRunFacts: "c5-captured-run-facts";
27
+ readonly crossBoundaryResourceApproval: "template-cross-boundary-resource-approval";
28
+ readonly modelVerifier: "template-model-verifier";
29
+ };
5
30
  export declare const TEMPLATE_MATCH_METADATA: readonly TemplateMatchMetadata[];
6
31
  export declare function getTemplateMatchMetadata(name: string): TemplateMatchMetadata | undefined;