@deksden-com/dd-flow-cli 0.7.0 → 0.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 (69) hide show
  1. package/CHANGELOG.md +666 -0
  2. package/README.md +7 -2
  3. package/dist/build-info.json +5 -5
  4. package/dist/cli/help.js +88 -10
  5. package/dist/cli/run-cli.js +523 -28
  6. package/dist/domain/stage-catalog.js +22 -0
  7. package/dist/domain/validation.js +1 -1
  8. package/dist/schemas/code-review-decision.schema.json +26 -0
  9. package/dist/schemas/code-review-result.schema.json +14 -0
  10. package/dist/schemas/code-verification.schema.json +14 -0
  11. package/dist/schemas/code-work-batch.schema.json +24 -0
  12. package/dist/schemas/code-work-result.schema.json +16 -0
  13. package/dist/schemas/compatibility.schema.json +32 -0
  14. package/dist/schemas/flow-contract.schema.json +9 -5
  15. package/dist/schemas/flow-run.schema.json +16 -123
  16. package/dist/schemas/plan-aspect-map.schema.json +22 -0
  17. package/dist/schemas/plan-review-decision.schema.json +14 -0
  18. package/dist/schemas/plan-review-result.schema.json +42 -0
  19. package/dist/schemas/protocol-plan.schema.json +15 -182
  20. package/dist/schemas/stage-finish-input.schema.json +16 -2
  21. package/dist/schemas/stage-report.schema.json +8 -7
  22. package/dist/schemas/stage-start-response.schema.json +4 -2
  23. package/dist/schemas/status-report.schema.json +76 -0
  24. package/dist/schemas/vnext-protocol-plan.schema.json +37 -0
  25. package/dist/schemas/vnext-protocolize-result.schema.json +29 -0
  26. package/dist/schemas/vnext-specify.schema.json +45 -0
  27. package/dist/services/branch-context.js +1 -1
  28. package/dist/services/cleanup.js +8 -8
  29. package/dist/services/cli-operation-classifier.js +10 -2
  30. package/dist/services/code-checks.js +244 -0
  31. package/dist/services/config.js +7 -1
  32. package/dist/services/dashboard.js +12 -12
  33. package/dist/services/engines.js +1 -1
  34. package/dist/services/eval-snapshots.js +404 -0
  35. package/dist/services/hooks.js +774 -18
  36. package/dist/services/ids.js +16 -6
  37. package/dist/services/lanes.js +1 -1
  38. package/dist/services/merge-queue.js +5 -5
  39. package/dist/services/merge-worker.js +2 -2
  40. package/dist/services/migrations.js +2 -2
  41. package/dist/services/plan-runtime.js +1 -1
  42. package/dist/services/projects.js +4 -4
  43. package/dist/services/prompts.js +17 -11
  44. package/dist/services/protocols.js +8 -8
  45. package/dist/services/run-projection.js +49 -13
  46. package/dist/services/runs.js +504 -51
  47. package/dist/services/schema-validation.js +21 -3
  48. package/dist/services/sessions.js +51 -12
  49. package/dist/services/stage-blocker.js +57 -0
  50. package/dist/services/stage-context.js +90 -0
  51. package/dist/services/stage-lifecycle.js +198 -75
  52. package/dist/services/stage-pause.js +175 -0
  53. package/dist/services/stage-report-renderer.js +65 -0
  54. package/dist/services/usage.js +526 -18
  55. package/dist/services/vnext-code-review.js +305 -0
  56. package/dist/services/vnext-code.js +686 -0
  57. package/dist/services/vnext-contracts.js +1 -0
  58. package/dist/services/vnext-execution-profile.js +27 -0
  59. package/dist/services/vnext-fanout.js +79 -0
  60. package/dist/services/vnext-plan-review.js +499 -0
  61. package/dist/services/vnext-plan.js +552 -0
  62. package/dist/services/vnext-protocolize.js +542 -0
  63. package/dist/services/vnext-specify.js +595 -0
  64. package/dist/services/vnext-workspace-policy.js +87 -0
  65. package/dist/services/work-registry.js +522 -0
  66. package/dist/services/worktrees.js +58 -37
  67. package/dist/storage/database.js +263 -34
  68. package/dist/storage/paths.js +47 -1
  69. package/package.json +12 -12
@@ -0,0 +1,65 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { writeJsonAtomic } from "../storage/paths.js";
4
+ /** Deterministic JSON -> Markdown/HTML projection shared by every stage. */
5
+ export function writeStageReport(root, report) {
6
+ const json = path.join(root, "stage-report.json");
7
+ const markdown = path.join(root, "stage-report.md");
8
+ const html = path.join(root, "stage-report.html");
9
+ const semantic = object(report.semantic);
10
+ const sourceArtifacts = object(report.artifacts);
11
+ const normalized = {
12
+ ...report,
13
+ schema_id: "dd-flow/stage-report@2",
14
+ summary: string(report.summary) || string(semantic.result) || "Stage completed.",
15
+ semantic: {
16
+ ...semantic,
17
+ result: string(semantic.result),
18
+ acceptance: array(semantic.acceptance),
19
+ changed_files: array(semantic.changed_files ?? semantic.run_changed_files),
20
+ checks: array(semantic.checks),
21
+ evidence: array(semantic.evidence),
22
+ next_action: string(semantic.next_action)
23
+ },
24
+ artifacts: {
25
+ json: string(sourceArtifacts.json) || "stage-report.json",
26
+ markdown: string(sourceArtifacts.markdown) || "stage-report.md",
27
+ html: string(sourceArtifacts.html) || "stage-report.html"
28
+ }
29
+ };
30
+ writeJsonAtomic(json, normalized);
31
+ const text = renderStageReportMarkdown(normalized);
32
+ fs.writeFileSync(markdown, text);
33
+ fs.writeFileSync(html, renderStageReportHtml(normalized, text));
34
+ return { json, markdown, html };
35
+ }
36
+ export function renderStageReportMarkdown(report) {
37
+ const semantic = object(report.semantic);
38
+ const summary = string(semantic.result) || string(report.summary) || "Stage completed.";
39
+ const acceptance = strings(semantic.acceptance);
40
+ const checks = strings(semantic.checks);
41
+ const evidence = strings(semantic.evidence);
42
+ const next = string(semantic.next_action);
43
+ const sections = [
44
+ `# ${string(report.stage).toUpperCase() || "Stage"} report`,
45
+ "",
46
+ summary,
47
+ "",
48
+ `**Verdict:** ${string(report.verdict) || "unknown"}`,
49
+ ...(acceptance.length ? ["", "## Acceptance", "", ...acceptance.map((item) => `- ${item}`)] : []),
50
+ ...(checks.length ? ["", "## Checks", "", ...checks.map((item) => `- ${item}`)] : []),
51
+ ...(evidence.length ? ["", "## Evidence", "", ...evidence.map((item) => `- ${item}`)] : []),
52
+ ...(next ? ["", `**Next action:** ${next}`] : []),
53
+ ""
54
+ ];
55
+ return sections.join("\n");
56
+ }
57
+ function renderStageReportHtml(report, markdown) {
58
+ const title = `${string(report.stage).toUpperCase() || "Stage"} report`;
59
+ return `<!doctype html><html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${escape(title)}</title><style>body{font:16px/1.55 system-ui,sans-serif;max-width:880px;margin:3rem auto;padding:0 1.25rem;color:#202124}pre{white-space:pre-wrap;font:inherit}</style><main><pre>${escape(markdown)}</pre></main></html>\n`;
60
+ }
61
+ function object(value) { return value && typeof value === "object" && !Array.isArray(value) ? value : {}; }
62
+ function string(value) { return typeof value === "string" ? value : ""; }
63
+ function strings(value) { return Array.isArray(value) ? value.filter((item) => typeof item === "string") : []; }
64
+ function array(value) { return Array.isArray(value) ? value : []; }
65
+ function escape(value) { return value.replace(/[&<>"']/g, (character) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[character]); }