@kaddo/cli 3.134.0 → 3.135.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 (35) hide show
  1. package/dist/admin-dist/assets/{architectureDiagram-3BPJPVTR-CYNwLGE7.js → architectureDiagram-3BPJPVTR-DkdJ073y.js} +1 -1
  2. package/dist/admin-dist/assets/{chunk-727SXJPM-Cet603Hl.js → chunk-727SXJPM-DRof4aGT.js} +1 -1
  3. package/dist/admin-dist/assets/{chunk-AQP2D5EJ-8XEHPg3a.js → chunk-AQP2D5EJ-BOVZoYng.js} +1 -1
  4. package/dist/admin-dist/assets/{classDiagram-v2-Q7XG4LA2-Bhwb9850.js → classDiagram-4FO5ZUOK-cL_umCGu.js} +1 -1
  5. package/dist/admin-dist/assets/{classDiagram-4FO5ZUOK-Bhwb9850.js → classDiagram-v2-Q7XG4LA2-cL_umCGu.js} +1 -1
  6. package/dist/admin-dist/assets/{dagre-BM42HDAG-DqQXdP8F.js → dagre-BM42HDAG-Cvga2Wk-.js} +1 -1
  7. package/dist/admin-dist/assets/{diagram-2AECGRRQ-B1bysbNR.js → diagram-2AECGRRQ-C4H51In7.js} +1 -1
  8. package/dist/admin-dist/assets/{diagram-5GNKFQAL-DRifvijh.js → diagram-5GNKFQAL-BW2-XCqV.js} +1 -1
  9. package/dist/admin-dist/assets/{diagram-LMA3HP47-DajL2Tv-.js → diagram-LMA3HP47-CQnSrSZs.js} +1 -1
  10. package/dist/admin-dist/assets/{diagram-OG6HWLK6-WCJo9oL4.js → diagram-OG6HWLK6-BA6tBaOl.js} +1 -1
  11. package/dist/admin-dist/assets/{erDiagram-TEJ5UH35-DwgqKm6b.js → erDiagram-TEJ5UH35-DQK3b1Yu.js} +1 -1
  12. package/dist/admin-dist/assets/{flowDiagram-I6XJVG4X-M0kG8sQQ.js → flowDiagram-I6XJVG4X-BvtbwW59.js} +1 -1
  13. package/dist/admin-dist/assets/{ganttDiagram-6RSMTGT7-DtyZt9Ti.js → ganttDiagram-6RSMTGT7-Vb0T68-1.js} +1 -1
  14. package/dist/admin-dist/assets/index-F0fBD3Ys.js +96 -0
  15. package/dist/admin-dist/assets/{infoDiagram-5YYISTIA-Vwdw_1gf.js → infoDiagram-5YYISTIA-8oD9uPZj.js} +1 -1
  16. package/dist/admin-dist/assets/{ishikawaDiagram-YF4QCWOH-CIi6B5fy.js → ishikawaDiagram-YF4QCWOH-C32f84vy.js} +1 -1
  17. package/dist/admin-dist/assets/{kanban-definition-UN3LZRKU-5HNFMSQ7.js → kanban-definition-UN3LZRKU-cJc_snn8.js} +1 -1
  18. package/dist/admin-dist/assets/{linear-D3H69r3G.js → linear-XcP0Xi-K.js} +1 -1
  19. package/dist/admin-dist/assets/{mindmap-definition-RKZ34NQL-BI0w0H_c.js → mindmap-definition-RKZ34NQL-jhlLOmXd.js} +1 -1
  20. package/dist/admin-dist/assets/{pieDiagram-4H26LBE5-5oMGjRSP.js → pieDiagram-4H26LBE5-cEiC5w8m.js} +1 -1
  21. package/dist/admin-dist/assets/{quadrantDiagram-W4KKPZXB-Cf4_7xD4.js → quadrantDiagram-W4KKPZXB-xjpfY5PD.js} +1 -1
  22. package/dist/admin-dist/assets/{requirementDiagram-4Y6WPE33-tKyHvrMo.js → requirementDiagram-4Y6WPE33-C5KtzYhy.js} +1 -1
  23. package/dist/admin-dist/assets/{sequenceDiagram-3UESZ5HK-XJChOzcT.js → sequenceDiagram-3UESZ5HK-ByGOoS_6.js} +1 -1
  24. package/dist/admin-dist/assets/{stateDiagram-AJRCARHV-CG6QHhPz.js → stateDiagram-AJRCARHV-d9g3cuV4.js} +1 -1
  25. package/dist/admin-dist/assets/{stateDiagram-v2-BHNVJYJU-COU53r4o.js → stateDiagram-v2-BHNVJYJU-DJ9FtIdZ.js} +1 -1
  26. package/dist/admin-dist/assets/{timeline-definition-PNZ67QCA-CszwARJN.js → timeline-definition-PNZ67QCA-BB4Lz6CJ.js} +1 -1
  27. package/dist/admin-dist/assets/{vennDiagram-CIIHVFJN-kMR7sGYN.js → vennDiagram-CIIHVFJN-yj1GFfPu.js} +1 -1
  28. package/dist/admin-dist/assets/{wardleyDiagram-YWT4CUSO-Cu44stm7.js → wardleyDiagram-YWT4CUSO-5nw4MWMx.js} +1 -1
  29. package/dist/admin-dist/assets/{xychartDiagram-2RQKCTM6-DeU0-PgC.js → xychartDiagram-2RQKCTM6-C0iogx2l.js} +1 -1
  30. package/dist/admin-dist/index.html +1 -1
  31. package/dist/admin-server/index.js +157 -1
  32. package/dist/core.js +550 -96
  33. package/dist/index.js +742 -114
  34. package/package.json +1 -1
  35. package/dist/admin-dist/assets/index-CZVvIq5M.js +0 -96
package/dist/index.js CHANGED
@@ -5948,7 +5948,7 @@ function selectAgentFiles(opts) {
5948
5948
  // src/modules/agents.ts
5949
5949
  function withAgentFrontMatter(fileName, content) {
5950
5950
  const name = fileName.replace(/\.md$/, "");
5951
- const fm2 = [
5951
+ const fm3 = [
5952
5952
  "---",
5953
5953
  "type: agent",
5954
5954
  `name: ${name}`,
@@ -5957,7 +5957,7 @@ function withAgentFrontMatter(fileName, content) {
5957
5957
  "---",
5958
5958
  ""
5959
5959
  ].join("\n");
5960
- return fm2 + content.replace(/^\s+/, "");
5960
+ return fm3 + content.replace(/^\s+/, "");
5961
5961
  }
5962
5962
  var agentReadme = {
5963
5963
  path: "knowledge/agents/README.md",
@@ -6678,7 +6678,7 @@ function formatList(items) {
6678
6678
  return items.map((i) => `- ${i.trim()}`).join("\n");
6679
6679
  }
6680
6680
  function buildFrontMatter(id, type, level, title, answers) {
6681
- const today3 = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
6681
+ const today4 = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
6682
6682
  const lines = [
6683
6683
  "---",
6684
6684
  `type: ${type}`,
@@ -6691,7 +6691,7 @@ function buildFrontMatter(id, type, level, title, answers) {
6691
6691
  `initiative:`,
6692
6692
  `domains: []`,
6693
6693
  `code: []`,
6694
- `created_at: ${today3}`,
6694
+ `created_at: ${today4}`,
6695
6695
  `source:`,
6696
6696
  ` type: manual`,
6697
6697
  ` inferred: false`,
@@ -6766,7 +6766,7 @@ _What did we learn from this change? Update after completion._
6766
6766
  return sections.join("\n");
6767
6767
  }
6768
6768
  function buildModuleFrontMatter(id, modType, title, answers) {
6769
- const today3 = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
6769
+ const today4 = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
6770
6770
  const extra = modType.extraFrontMatter ?? {};
6771
6771
  const extraLines = Object.entries(extra).map(
6772
6772
  ([k, v]) => `${k}: ${JSON.stringify(v)}`
@@ -6782,7 +6782,7 @@ function buildModuleFrontMatter(id, modType, title, answers) {
6782
6782
  `initiative:`,
6783
6783
  `domains: []`,
6784
6784
  `code: []`,
6785
- `created_at: ${today3}`,
6785
+ `created_at: ${today4}`,
6786
6786
  `source: manual`,
6787
6787
  `summary: "${title}"`,
6788
6788
  ...extraLines,
@@ -6930,7 +6930,7 @@ function resolveCandidateLevel(candidate, type) {
6930
6930
  return getLevelForType(type);
6931
6931
  }
6932
6932
  function buildRoadmapFrontMatter(id, type, level, title, candidate, answers) {
6933
- const today3 = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
6933
+ const today4 = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
6934
6934
  const summary = (answers.problem?.split(".")[0] ?? candidate.expectedValue ?? title).trim();
6935
6935
  const initiative = candidate.initiative?.title ?? candidate.initiative?.id ?? "";
6936
6936
  const q = (s) => s.replace(/"/g, "'");
@@ -6953,7 +6953,7 @@ function buildRoadmapFrontMatter(id, type, level, title, candidate, answers) {
6953
6953
  ...yamlList2("domains", domains),
6954
6954
  ...domains.length === 0 ? ["domains: []"] : [],
6955
6955
  `code: []`,
6956
- `created_at: ${today3}`,
6956
+ `created_at: ${today4}`,
6957
6957
  `source: roadmap`,
6958
6958
  `source_id: ${candidate.id}`,
6959
6959
  `source_initiative: ${candidate.initiative?.id ?? "unknown"}`,
@@ -7763,8 +7763,8 @@ function analyzeMetadataHealth(dir) {
7763
7763
  if (isFile(p) && entry.endsWith(".md")) {
7764
7764
  try {
7765
7765
  const raw = readFile(p);
7766
- const fm2 = matter2(raw).data;
7767
- if (fm2.status === "done") {
7766
+ const fm3 = matter2(raw).data;
7767
+ if (fm3.status === "done") {
7768
7768
  const rel = p.replace(dir + "/", "").replace(dir + "\\", "").replace(/\\/g, "/");
7769
7769
  findings.push({
7770
7770
  file: rel,
@@ -11255,7 +11255,7 @@ ${items.map((i) => `- ${i}`).join("\n")}
11255
11255
  `;
11256
11256
  }
11257
11257
  function renderCapsuleMarkdown(c) {
11258
- const fm2 = [
11258
+ const fm3 = [
11259
11259
  "---",
11260
11260
  "type: knowledge-capsule",
11261
11261
  `system: ${c.system}`,
@@ -11267,7 +11267,7 @@ function renderCapsuleMarkdown(c) {
11267
11267
  "---"
11268
11268
  ].join("\n");
11269
11269
  const parts = [
11270
- fm2,
11270
+ fm3,
11271
11271
  "",
11272
11272
  `# ${c.system} \u2014 Knowledge Capsule`,
11273
11273
  "",
@@ -11574,6 +11574,18 @@ var DELIVERY_PLANS_DIR = "knowledge/delivery/plans";
11574
11574
  var EPICS_DIR = "knowledge/delivery/epics";
11575
11575
  var PLAN_STATES = ["draft", "in-progress", "completed", "cancelled"];
11576
11576
  var EPIC_STATES = ["planned", "in-progress", "completed", "cancelled"];
11577
+ var PLAN_TRANSITIONS = {
11578
+ draft: ["in-progress", "cancelled"],
11579
+ "in-progress": ["completed", "cancelled"],
11580
+ completed: [],
11581
+ cancelled: []
11582
+ };
11583
+ var EPIC_TRANSITIONS = {
11584
+ planned: ["in-progress", "cancelled"],
11585
+ "in-progress": ["completed", "cancelled"],
11586
+ completed: [],
11587
+ cancelled: []
11588
+ };
11577
11589
  function toPosix5(p) {
11578
11590
  return p.replace(/\\/g, "/");
11579
11591
  }
@@ -11854,6 +11866,9 @@ function validatePlanningGraph(dir) {
11854
11866
  findings.push({ level: "warning", kind: "pending_dependency", subject: e.id, message: `Epic ${e.id} is blocked by unfinished dependency ${d}.` });
11855
11867
  return findings;
11856
11868
  }
11869
+ function revisionOf(content) {
11870
+ return createHash("sha256").update(content, "utf8").digest("hex").slice(0, 16);
11871
+ }
11857
11872
 
11858
11873
  // src/core/resources.ts
11859
11874
  import matter6 from "gray-matter";
@@ -11973,40 +11988,40 @@ function purposeFromBody(body) {
11973
11988
  }
11974
11989
  function toDetail(filePath, relPath, raw) {
11975
11990
  const parsed = matter6(raw);
11976
- const fm2 = parsed.data ?? {};
11991
+ const fm3 = parsed.data ?? {};
11977
11992
  const body = parsed.content.trim();
11978
- const id = str(fm2.id) ?? "";
11993
+ const id = str(fm3.id) ?? "";
11979
11994
  return {
11980
11995
  id,
11981
- title: str(fm2.title) ?? id,
11982
- resourceType: str(fm2.resource_type),
11983
- provider: str(fm2.provider),
11984
- environments: strArray(fm2.environments),
11985
- scope: parseScope(fm2.scope),
11986
- modules: strArray(fm2.modules),
11996
+ title: str(fm3.title) ?? id,
11997
+ resourceType: str(fm3.resource_type),
11998
+ provider: str(fm3.provider),
11999
+ environments: strArray(fm3.environments),
12000
+ scope: parseScope(fm3.scope),
12001
+ modules: strArray(fm3.modules),
11987
12002
  path: relPath,
11988
- purpose: str(fm2.purpose) ?? purposeFromBody(body),
11989
- interfaces: parseInterfaces(fm2.access_interfaces),
11990
- boundaries: parseBoundaries(fm2.access_boundaries),
12003
+ purpose: str(fm3.purpose) ?? purposeFromBody(body),
12004
+ interfaces: parseInterfaces(fm3.access_interfaces),
12005
+ boundaries: parseBoundaries(fm3.access_boundaries),
11991
12006
  ...(() => {
11992
- const a = parseAuth(fm2.authentication);
12007
+ const a = parseAuth(fm3.authentication);
11993
12008
  return { authRefs: a.refs, authMode: a.mode };
11994
12009
  })(),
11995
- connectionProfiles: parseConnectionProfiles(fm2.connection_profiles),
12010
+ connectionProfiles: parseConnectionProfiles(fm3.connection_profiles),
11996
12011
  markdownBody: body
11997
12012
  };
11998
12013
  }
11999
12014
  function getResources(dir) {
12000
12015
  return discoverKnowledge(dir).filter((a) => a.type === RESOURCE_ARTIFACT_TYPE).map((a) => {
12001
- const fm2 = a.rawFrontmatter;
12016
+ const fm3 = a.rawFrontmatter;
12002
12017
  return {
12003
- id: a.id || str(fm2.id) || a.title,
12004
- title: a.title || str(fm2.title) || a.id,
12005
- resourceType: str(fm2.resource_type),
12006
- provider: str(fm2.provider),
12007
- environments: strArray(fm2.environments),
12008
- scope: parseScope(fm2.scope),
12009
- modules: strArray(fm2.modules),
12018
+ id: a.id || str(fm3.id) || a.title,
12019
+ title: a.title || str(fm3.title) || a.id,
12020
+ resourceType: str(fm3.resource_type),
12021
+ provider: str(fm3.provider),
12022
+ environments: strArray(fm3.environments),
12023
+ scope: parseScope(fm3.scope),
12024
+ modules: strArray(fm3.modules),
12010
12025
  path: a.relPath
12011
12026
  };
12012
12027
  }).sort((x, y) => x.id.localeCompare(y.id));
@@ -12019,8 +12034,8 @@ function getResource(dir, id) {
12019
12034
  const raw = readFile(match.filePath);
12020
12035
  return toDetail(match.filePath, match.relPath, raw);
12021
12036
  }
12022
- function parseWorkItemResources(fm2) {
12023
- const v = fm2.resources;
12037
+ function parseWorkItemResources(fm3) {
12038
+ const v = fm3.resources;
12024
12039
  if (!Array.isArray(v)) return [];
12025
12040
  const out = [];
12026
12041
  for (const raw of v) {
@@ -12072,8 +12087,8 @@ var EVIDENCE_SIGNALS = [
12072
12087
  function str2(v) {
12073
12088
  return typeof v === "string" && v.trim() ? v.trim() : null;
12074
12089
  }
12075
- function parseWorkItemDeprecationTargets(fm2) {
12076
- const v = fm2.deprecation_targets;
12090
+ function parseWorkItemDeprecationTargets(fm3) {
12091
+ const v = fm3.deprecation_targets;
12077
12092
  if (!Array.isArray(v)) return [];
12078
12093
  const out = [];
12079
12094
  for (const raw of v) {
@@ -12207,13 +12222,13 @@ function purposeFromBody2(body) {
12207
12222
  }
12208
12223
  function getDeprecationPlans(dir) {
12209
12224
  return discoverKnowledge(dir).filter((a) => a.type === DEPRECATION_ARTIFACT_TYPE).map((a) => {
12210
- const fm2 = a.rawFrontmatter;
12211
- const targets = parseTargets(fm2.targets);
12225
+ const fm3 = a.rawFrontmatter;
12226
+ const targets = parseTargets(fm3.targets);
12212
12227
  return {
12213
- id: a.id || str2(fm2.id) || a.title,
12214
- title: a.title || str2(fm2.title) || a.id,
12228
+ id: a.id || str2(fm3.id) || a.title,
12229
+ title: a.title || str2(fm3.title) || a.id,
12215
12230
  path: a.relPath,
12216
- status: str2(fm2.status),
12231
+ status: str2(fm3.status),
12217
12232
  targetCount: targets.length,
12218
12233
  lifecycleCounts: lifecycleCountsOf(targets)
12219
12234
  };
@@ -12226,17 +12241,17 @@ function getDeprecationPlan(dir, id) {
12226
12241
  if (!match) return null;
12227
12242
  const raw = readFile(match.filePath);
12228
12243
  const parsed = matter7(raw);
12229
- const fm2 = parsed.data ?? {};
12244
+ const fm3 = parsed.data ?? {};
12230
12245
  const body = parsed.content.trim();
12231
- const targets = parseTargets(fm2.targets);
12246
+ const targets = parseTargets(fm3.targets);
12232
12247
  return {
12233
- id: str2(fm2.id) ?? match.id,
12234
- title: str2(fm2.title) ?? match.title,
12248
+ id: str2(fm3.id) ?? match.id,
12249
+ title: str2(fm3.title) ?? match.title,
12235
12250
  path: match.relPath,
12236
- status: str2(fm2.status),
12251
+ status: str2(fm3.status),
12237
12252
  targetCount: targets.length,
12238
12253
  lifecycleCounts: lifecycleCountsOf(targets),
12239
- purpose: str2(fm2.purpose) ?? purposeFromBody2(body),
12254
+ purpose: str2(fm3.purpose) ?? purposeFromBody2(body),
12240
12255
  targets,
12241
12256
  markdownBody: body
12242
12257
  };
@@ -12762,9 +12777,9 @@ var QUALITY_NOTE = {
12762
12777
  sparse: "The graph has many nodes but few meaningful edges.",
12763
12778
  empty: "The graph has almost no relationships."
12764
12779
  };
12765
- function yamlBlock(fm2) {
12780
+ function yamlBlock(fm3) {
12766
12781
  const lines = ["```yaml"];
12767
- for (const [k, vals] of Object.entries(fm2)) {
12782
+ for (const [k, vals] of Object.entries(fm3)) {
12768
12783
  lines.push(`${k}:`);
12769
12784
  for (const v of vals) lines.push(` - ${v}`);
12770
12785
  }
@@ -15678,8 +15693,8 @@ function buildProjectExplanation(dir) {
15678
15693
  };
15679
15694
  }),
15680
15695
  implementationEvidence: workItemArtifacts.filter((a) => a.affectedModules.length > 0).map((a) => {
15681
- const fm2 = a.rawFrontmatter;
15682
- const evidence = fm2.implementation_evidence;
15696
+ const fm3 = a.rawFrontmatter;
15697
+ const evidence = fm3.implementation_evidence;
15683
15698
  const repos = evidence?.repositories ?? {};
15684
15699
  const repoEvidence = {};
15685
15700
  for (const [repoId, data] of Object.entries(repos)) {
@@ -15697,8 +15712,8 @@ function buildProjectExplanation(dir) {
15697
15712
  validationStatus: a.validationStatus || historicalDefault,
15698
15713
  releaseStatus: a.releaseStatus || "not-assessed",
15699
15714
  affectedModules: a.affectedModules,
15700
- releaseGates: Array.isArray(fm2.release_gates) ? fm2.release_gates : [],
15701
- completionExceptions: Array.isArray(fm2.completion_exceptions) ? fm2.completion_exceptions : [],
15715
+ releaseGates: Array.isArray(fm3.release_gates) ? fm3.release_gates : [],
15716
+ completionExceptions: Array.isArray(fm3.completion_exceptions) ? fm3.completion_exceptions : [],
15702
15717
  repoEvidence
15703
15718
  };
15704
15719
  })
@@ -16143,9 +16158,9 @@ function readConfig(dir) {
16143
16158
  }
16144
16159
  function filterBySince(artifacts, since) {
16145
16160
  return artifacts.filter((a) => {
16146
- const fm2 = a;
16147
- if (!fm2.created_at) return true;
16148
- return fm2.created_at >= since;
16161
+ const fm3 = a;
16162
+ if (!fm3.created_at) return true;
16163
+ return fm3.created_at >= since;
16149
16164
  });
16150
16165
  }
16151
16166
  function filterByScope(artifacts, scope) {
@@ -19197,8 +19212,8 @@ var DIR_TARGETS = ["knowledge/tech/decisions", "knowledge/tech/discovery", "know
19197
19212
  function withLanguageDirective(content, language) {
19198
19213
  if (language !== "es") return content;
19199
19214
  const note = "> Idioma del proyecto: **espa\xF1ol**. Escribe este conocimiento en espa\xF1ol. Mant\xE9n en ingl\xE9s el c\xF3digo, los nombres de archivo, los comandos y las claves de configuraci\xF3n.\n";
19200
- const fm2 = content.match(/^---\n[\s\S]*?\n---\n/);
19201
- if (fm2) return content.slice(0, fm2[0].length) + "\n" + note + content.slice(fm2[0].length);
19215
+ const fm3 = content.match(/^---\n[\s\S]*?\n---\n/);
19216
+ if (fm3) return content.slice(0, fm3[0].length) + "\n" + note + content.slice(fm3[0].length);
19202
19217
  return `${note}
19203
19218
  ${content}`;
19204
19219
  }
@@ -21097,9 +21112,9 @@ function conceptBundlePath(a, id) {
21097
21112
  return `misc/${file}`;
21098
21113
  }
21099
21114
  }
21100
- function workItemRelations(fm2) {
21115
+ function workItemRelations(fm3) {
21101
21116
  const out = [];
21102
- const resources = fm2.resources;
21117
+ const resources = fm3.resources;
21103
21118
  if (Array.isArray(resources)) {
21104
21119
  for (const r of resources) {
21105
21120
  if (r && typeof r === "object") {
@@ -21108,16 +21123,16 @@ function workItemRelations(fm2) {
21108
21123
  }
21109
21124
  }
21110
21125
  }
21111
- const dep = fm2.deprecation_targets;
21126
+ const dep = fm3.deprecation_targets;
21112
21127
  if (Array.isArray(dep)) {
21113
21128
  for (const d of dep) {
21114
21129
  const s = typeof d === "string" ? d : d && typeof d === "object" ? str3(d.plan) : null;
21115
21130
  if (s) out.push({ id: s.includes("/") ? s.split("/")[0] : s, role: "deprecates-via" });
21116
21131
  }
21117
21132
  }
21118
- const parent = str3(fm2.parent);
21133
+ const parent = str3(fm3.parent);
21119
21134
  if (parent) out.push({ id: parent, role: "child-of" });
21120
- for (const dId of strArray3(fm2.decisions)) out.push({ id: dId, role: "decided-by" });
21135
+ for (const dId of strArray3(fm3.decisions)) out.push({ id: dId, role: "decided-by" });
21121
21136
  return out;
21122
21137
  }
21123
21138
  function slugify5(s) {
@@ -22820,7 +22835,7 @@ var WorkItemWriteError = class extends Error {
22820
22835
  code;
22821
22836
  };
22822
22837
  var EDITABLE_STATES = ["draft"];
22823
- function revisionOf(raw) {
22838
+ function revisionOf2(raw) {
22824
22839
  return crypto2.createHash("sha256").update(raw, "utf-8").digest("hex");
22825
22840
  }
22826
22841
  function slugify6(s) {
@@ -23022,7 +23037,7 @@ function getWorkItemForEdit(dir, id) {
23022
23037
  ...input,
23023
23038
  id,
23024
23039
  status,
23025
- revision: revisionOf(raw),
23040
+ revision: revisionOf2(raw),
23026
23041
  path: relPath,
23027
23042
  editable,
23028
23043
  ...editable ? {} : { editableReason: status === "ready" ? "This Work Item is Ready. Reopen it as Draft to edit its scope." : `This Work Item is ${status} and cannot be edited from the structured editor.` }
@@ -23057,7 +23072,7 @@ function createWorkItem(dir, opts) {
23057
23072
  if (!type) throw new WorkItemWriteError("INVALID_INPUT", `Unknown Work Item type "${opts.type}".`);
23058
23073
  const id = nextWorkItemId2(dir);
23059
23074
  const title = intent.split(/\r?\n/)[0].trim().slice(0, 120);
23060
- const today3 = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
23075
+ const today4 = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
23061
23076
  const summary = opts.summary?.trim() || intent;
23062
23077
  const source2 = opts.source ? { ...opts.source, inferred: false } : { type: "manual", inferred: false };
23063
23078
  const data = {
@@ -23066,7 +23081,7 @@ function createWorkItem(dir, opts) {
23066
23081
  title,
23067
23082
  status: "draft",
23068
23083
  work_type: type,
23069
- created_at: today3,
23084
+ created_at: today4,
23070
23085
  source: source2,
23071
23086
  generated_by: "kaddo-admin",
23072
23087
  affected_modules: [],
@@ -23094,7 +23109,7 @@ function createWorkItem(dir, opts) {
23094
23109
  if (exists(filePath)) throw new WorkItemWriteError("INVALID_INPUT", `Work Item file already exists: ${relPath}`);
23095
23110
  const raw = serialize3(data, body);
23096
23111
  atomicWrite4(filePath, raw);
23097
- return { id, path: relPath, revision: revisionOf(raw) };
23112
+ return { id, path: relPath, revision: revisionOf2(raw) };
23098
23113
  }
23099
23114
  function validateWorkItem(dir, id) {
23100
23115
  const { filePath } = findArtifact(dir, id);
@@ -23123,9 +23138,9 @@ function validateWorkItem(dir, id) {
23123
23138
  }
23124
23139
  const topology = loadSystemTopology(dir);
23125
23140
  const entityById = new Map(topology.entities.map((e) => [e.id, e]));
23126
- const fm2 = data;
23141
+ const fm3 = data;
23127
23142
  const idOf = (raw2) => typeof raw2 === "string" ? raw2 : raw2 && typeof raw2 === "object" ? String(raw2.id ?? "") : "";
23128
- const affectedEntities = Array.isArray(fm2.affected_system_entities) ? fm2.affected_system_entities.map(idOf).filter(Boolean) : [];
23143
+ const affectedEntities = Array.isArray(fm3.affected_system_entities) ? fm3.affected_system_entities.map(idOf).filter(Boolean) : [];
23129
23144
  for (const eid of affectedEntities) {
23130
23145
  const e = entityById.get(eid);
23131
23146
  if (!e) {
@@ -23136,8 +23151,8 @@ function validateWorkItem(dir, id) {
23136
23151
  findings.push({ level: "warning", message: `System entity "${e.label}" belongs to module "${e.moduleId}", which is not in affected_modules.` });
23137
23152
  }
23138
23153
  }
23139
- if (Array.isArray(fm2.reviewed_system_entities)) {
23140
- for (const r of fm2.reviewed_system_entities) {
23154
+ if (Array.isArray(fm3.reviewed_system_entities)) {
23155
+ for (const r of fm3.reviewed_system_entities) {
23141
23156
  const rid = r && typeof r === "object" ? String(r.id ?? "") : "";
23142
23157
  if (rid && !entityById.has(rid)) findings.push({ level: "warning", message: `Reviewed system entity "${rid}" does not exist in the semantic topology.` });
23143
23158
  }
@@ -23149,7 +23164,7 @@ var ALLOWED = { draft: ["ready"], ready: ["draft", "in-progress"] };
23149
23164
  function transitionWorkItem(dir, id, to, expectedRevision) {
23150
23165
  const { filePath } = findArtifact(dir, id);
23151
23166
  const raw = readFile(filePath);
23152
- if (revisionOf(raw) !== expectedRevision) {
23167
+ if (revisionOf2(raw) !== expectedRevision) {
23153
23168
  throw new WorkItemWriteError("WORK_ITEM_CONFLICT", "This Work Item changed outside Kaddo Admin. Reload the latest version before continuing.");
23154
23169
  }
23155
23170
  const { data, content } = matter21(raw);
@@ -23173,7 +23188,7 @@ function transitionWorkItem(dir, id, to, expectedRevision) {
23173
23188
  } catch {
23174
23189
  }
23175
23190
  }
23176
- return { revision: revisionOf(nextRaw), status: to, path: targetRel };
23191
+ return { revision: revisionOf2(nextRaw), status: to, path: targetRel };
23177
23192
  }
23178
23193
 
23179
23194
  // ../integrations/src/errors.ts
@@ -24891,9 +24906,9 @@ function isResolvedSection(text2) {
24891
24906
  function transitionToReady(filePath) {
24892
24907
  const raw = readFile(filePath);
24893
24908
  const { data, content } = matter23(raw);
24894
- const today3 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
24909
+ const today4 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
24895
24910
  data.status = "ready";
24896
- data.ready_at = today3;
24911
+ data.ready_at = today4;
24897
24912
  const newContent = matter23.stringify(content, data);
24898
24913
  const posix2 = filePath.replace(/\\/g, "/");
24899
24914
  let newPath = filePath;
@@ -25184,7 +25199,7 @@ function getWorkItem(dir, workItemId) {
25184
25199
  const base = toListItem(match);
25185
25200
  const body = readBody2(match.filePath);
25186
25201
  const sections = splitSections(body);
25187
- const fm2 = match.rawFrontmatter;
25202
+ const fm3 = match.rawFrontmatter;
25188
25203
  const knowledge = discoverKnowledge(dir).filter((a) => !a.isWorkItem);
25189
25204
  const knowledgeById = new Map(knowledge.filter((k) => k.id).map((k) => [k.id, k]));
25190
25205
  const detail = {
@@ -25201,21 +25216,21 @@ function getWorkItem(dir, workItemId) {
25201
25216
  moduleCoverage: normalizeCoverage(match.moduleCoverage),
25202
25217
  impactAnalysis: normalizeImpact(match.impactAnalysis),
25203
25218
  acceptanceCriteria: parseAcceptanceCriteria(sections),
25204
- implementationEvidence: parseEvidence(fm2),
25205
- releaseGates: parseReleaseGates(fm2),
25206
- completionExceptions: parseExceptions(fm2),
25219
+ implementationEvidence: parseEvidence(fm3),
25220
+ releaseGates: parseReleaseGates(fm3),
25221
+ completionExceptions: parseExceptions(fm3),
25207
25222
  decisions: parseDecisions(match.decisions, knowledgeById),
25208
- relatedKnowledge: parseRelatedKnowledge(fm2, knowledgeById),
25209
- source: parseWorkItemSource(fm2),
25210
- originalSnapshot: parseOriginalSnapshot(fm2),
25223
+ relatedKnowledge: parseRelatedKnowledge(fm3, knowledgeById),
25224
+ source: parseWorkItemSource(fm3),
25225
+ originalSnapshot: parseOriginalSnapshot(fm3),
25211
25226
  path: match.relPath,
25212
25227
  // Faithful source of truth: the artifact body already read above, not reconstructed (WI-025).
25213
25228
  markdownBody: body.trim(),
25214
25229
  // External systems this WI relates to (WI-030), separate from affectedModules (code).
25215
- resources: parseWorkItemResources(fm2),
25230
+ resources: parseWorkItemResources(fm3),
25216
25231
  // Deprecation Targets this WI retires (WI-050), referenced not copied.
25217
- deprecationTargets: parseWorkItemDeprecationTargets(fm2),
25218
- ...parseSystemImpact(dir, fm2)
25232
+ deprecationTargets: parseWorkItemDeprecationTargets(fm3),
25233
+ ...parseSystemImpact(dir, fm3)
25219
25234
  };
25220
25235
  return { ...detail, refinement: computeRefinementStatus(detail) };
25221
25236
  }
@@ -25238,14 +25253,14 @@ function parseExplain(o) {
25238
25253
  function emptyExplain() {
25239
25254
  return { reason: null, graphReason: null, evidenceRefs: [], evidenceSummary: null };
25240
25255
  }
25241
- function parseSystemImpact(dir, fm2) {
25256
+ function parseSystemImpact(dir, fm3) {
25242
25257
  const topology = loadSystemTopology(dir);
25243
25258
  const byId = new Map(topology.entities.map((e) => [e.id, e]));
25244
25259
  const resolve = (id) => {
25245
25260
  const e = byId.get(id);
25246
25261
  return { id, nodeId: `sys:${id}`, label: e?.label ?? id, kind: e?.kind ?? "unknown", moduleId: e?.moduleId ?? null };
25247
25262
  };
25248
- const affected = Array.isArray(fm2.affected_system_entities) ? fm2.affected_system_entities.map((raw) => {
25263
+ const affected = Array.isArray(fm3.affected_system_entities) ? fm3.affected_system_entities.map((raw) => {
25249
25264
  if (typeof raw === "string") return raw ? { ...resolve(raw), ...emptyExplain() } : null;
25250
25265
  if (raw && typeof raw === "object") {
25251
25266
  const o = raw;
@@ -25254,13 +25269,13 @@ function parseSystemImpact(dir, fm2) {
25254
25269
  }
25255
25270
  return null;
25256
25271
  }).filter((e) => e != null) : [];
25257
- const reviewed = Array.isArray(fm2.reviewed_system_entities) ? fm2.reviewed_system_entities.filter((r) => Boolean(r) && typeof r === "object").map((r) => ({ ...resolve(String(r.id ?? "")), ...parseExplain(r), status: String(r.status ?? "unknown") })).filter((r) => r.id) : [];
25258
- const graphRevision = typeof fm2.graph_revision === "string" && fm2.graph_revision.trim() ? fm2.graph_revision.trim() : null;
25272
+ const reviewed = Array.isArray(fm3.reviewed_system_entities) ? fm3.reviewed_system_entities.filter((r) => Boolean(r) && typeof r === "object").map((r) => ({ ...resolve(String(r.id ?? "")), ...parseExplain(r), status: String(r.status ?? "unknown") })).filter((r) => r.id) : [];
25273
+ const graphRevision = typeof fm3.graph_revision === "string" && fm3.graph_revision.trim() ? fm3.graph_revision.trim() : null;
25259
25274
  const graphCoverage = topology.entities.length === 0 ? "unavailable" : topology.relationships.length > 0 ? "available" : "partial";
25260
25275
  return { affectedSystemEntities: affected, reviewedSystemEntities: reviewed, graphRevision, graphCoverage };
25261
25276
  }
25262
- function parseOriginalSnapshot(fm2) {
25263
- const raw = fm2.original_snapshot;
25277
+ function parseOriginalSnapshot(fm3) {
25278
+ const raw = fm3.original_snapshot;
25264
25279
  if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
25265
25280
  const o = raw;
25266
25281
  const title = typeof o.title === "string" ? o.title : void 0;
@@ -25367,8 +25382,8 @@ function optStr4(v) {
25367
25382
  if (typeof v === "string" && v.trim()) return v.trim();
25368
25383
  return void 0;
25369
25384
  }
25370
- function parseEvidence(fm2) {
25371
- const evidence = fm2.implementation_evidence;
25385
+ function parseEvidence(fm3) {
25386
+ const evidence = fm3.implementation_evidence;
25372
25387
  const repos = evidence?.repositories;
25373
25388
  if (!repos || typeof repos !== "object" || Array.isArray(repos)) return [];
25374
25389
  const out = [];
@@ -25397,18 +25412,18 @@ function parseEvidence(fm2) {
25397
25412
  }
25398
25413
  return out;
25399
25414
  }
25400
- function parseReleaseGates(fm2) {
25401
- if (!Array.isArray(fm2.release_gates)) return [];
25402
- return fm2.release_gates.filter((g) => g && typeof g === "object").map((g) => ({
25415
+ function parseReleaseGates(fm3) {
25416
+ if (!Array.isArray(fm3.release_gates)) return [];
25417
+ return fm3.release_gates.filter((g) => g && typeof g === "object").map((g) => ({
25403
25418
  id: String(g.id ?? ""),
25404
25419
  status: String(g.status ?? "pending"),
25405
25420
  ...optStr4(g.reason) ? { reason: optStr4(g.reason) } : {},
25406
25421
  ...optStr4(g.required_for) ? { requiredFor: optStr4(g.required_for) } : {}
25407
25422
  }));
25408
25423
  }
25409
- function parseExceptions(fm2) {
25410
- if (!Array.isArray(fm2.completion_exceptions)) return [];
25411
- return fm2.completion_exceptions.filter((e) => e && typeof e === "object").map((e) => ({
25424
+ function parseExceptions(fm3) {
25425
+ if (!Array.isArray(fm3.completion_exceptions)) return [];
25426
+ return fm3.completion_exceptions.filter((e) => e && typeof e === "object").map((e) => ({
25412
25427
  id: String(e.id ?? ""),
25413
25428
  status: String(e.status ?? "proposed"),
25414
25429
  ...optStr4(e.reason) ? { reason: optStr4(e.reason) } : {},
@@ -25426,10 +25441,10 @@ function parseDecisions(decisions, knowledgeById) {
25426
25441
  };
25427
25442
  });
25428
25443
  }
25429
- function parseRelatedKnowledge(fm2, knowledgeById) {
25444
+ function parseRelatedKnowledge(fm3, knowledgeById) {
25430
25445
  const refs = /* @__PURE__ */ new Set();
25431
25446
  for (const field of ["related_knowledge", "knowledge", "related"]) {
25432
- const v = fm2[field];
25447
+ const v = fm3[field];
25433
25448
  if (Array.isArray(v)) {
25434
25449
  for (const r of v) if (typeof r === "string" && r.trim()) refs.add(r.trim());
25435
25450
  }
@@ -26163,11 +26178,11 @@ function verifyWorkItem(dir, workItemId, input) {
26163
26178
  const artifacts = discoverWorkItems(dir);
26164
26179
  const match = artifacts.find((a) => (a.id || a.title) === workItemId);
26165
26180
  const lifecycle = lifecycleStateOf({ status: match.status, filePath: match.filePath });
26166
- const fm2 = match.rawFrontmatter;
26181
+ const fm3 = match.rawFrontmatter;
26167
26182
  const acVerifications = mapACVerifications(input.acVerifications);
26168
26183
  const acSummary = computeACSummary(acVerifications);
26169
- const releaseGates = Array.isArray(fm2.release_gates) ? fm2.release_gates : [];
26170
- const completionExceptions = Array.isArray(fm2.completion_exceptions) ? fm2.completion_exceptions : [];
26184
+ const releaseGates = Array.isArray(fm3.release_gates) ? fm3.release_gates : [];
26185
+ const completionExceptions = Array.isArray(fm3.completion_exceptions) ? fm3.completion_exceptions : [];
26171
26186
  const plannedVsActual = computePlannedVsActual(match.affectedModules, input.repos);
26172
26187
  const registeredModuleIds = loadMappedModules(dir).map((m) => m.id);
26173
26188
  const modifiedRepoIds = input.repos.map((r) => r.repoId);
@@ -26178,7 +26193,7 @@ function verifyWorkItem(dir, workItemId, input) {
26178
26193
  validationStatus: match.validationStatus || "not-started",
26179
26194
  releaseStatus: match.releaseStatus || "not-assessed",
26180
26195
  affectedModules: match.affectedModules,
26181
- rawFrontmatter: fm2,
26196
+ rawFrontmatter: fm3,
26182
26197
  registeredModuleIds,
26183
26198
  modifiedRepoIds
26184
26199
  });
@@ -26363,15 +26378,22 @@ function buildACVerifications(acs, persisted) {
26363
26378
  }
26364
26379
  function extractACsFromBody(body) {
26365
26380
  const lines = body.split(/\r?\n/);
26366
- let inAC = false;
26381
+ let acLevel = 0;
26367
26382
  const acs = [];
26368
26383
  for (const line of lines) {
26369
- if (/^#{1,6}\s+(?:\d+(?:\.\d+)*\.?\s+)?(acceptance\s+criteria|criterios\s+de\s+aceptaci[oó]n)\s*$/i.test(line)) {
26370
- inAC = true;
26384
+ const heading = line.match(/^(#{1,6})\s+(.*)$/);
26385
+ if (heading) {
26386
+ const level = heading[1].length;
26387
+ if (acLevel === 0) {
26388
+ if (/^(?:\d+(?:\.\d+)*\.?\s+)?(acceptance\s+criteria|criterios\s+de\s+aceptaci[oó]n)\s*$/i.test(heading[2].trim())) {
26389
+ acLevel = level;
26390
+ }
26391
+ continue;
26392
+ }
26393
+ if (level <= acLevel) break;
26371
26394
  continue;
26372
26395
  }
26373
- if (inAC && /^#{1,6}\s+/.test(line)) break;
26374
- if (inAC) {
26396
+ if (acLevel > 0) {
26375
26397
  const m = line.match(/^\s*[-*+]\s+(?:\[([ xX])\]\s*)?(.+)$/);
26376
26398
  if (m) {
26377
26399
  const text2 = m[2].trim();
@@ -26412,9 +26434,9 @@ async function runVerify(workItemId, opts = {}) {
26412
26434
  const changedPaths = await getModifiedFiles("head");
26413
26435
  const raw = readFile(match.filePath);
26414
26436
  const parsed = matter26(raw);
26415
- const fm2 = parsed.data;
26437
+ const fm3 = parsed.data;
26416
26438
  const acs = extractACsFromBody(parsed.content);
26417
- const existingEvidence = fm2.implementation_evidence;
26439
+ const existingEvidence = fm3.implementation_evidence;
26418
26440
  const existingRepos = existingEvidence?.repositories ?? {};
26419
26441
  const repos = Object.keys(existingRepos).length > 0 ? Object.entries(existingRepos).map(([repoId, data]) => {
26420
26442
  const d = data;
@@ -27372,6 +27394,246 @@ function materializeCandidate(dir, id, candidateId) {
27372
27394
  return { workItemId: wiId, fileName, initiative: updated };
27373
27395
  }
27374
27396
 
27397
+ // src/core/delivery-verification.ts
27398
+ function normalizeCriterion(text2) {
27399
+ return text2.trim().toLowerCase().replace(/\s+/g, " ");
27400
+ }
27401
+ var STATUSES = ["passed", "failed", "not-verified", "manual-review-required"];
27402
+ function optStr5(v) {
27403
+ if (typeof v === "string" && v.trim()) return v.trim();
27404
+ if (typeof v === "number") return String(v);
27405
+ return void 0;
27406
+ }
27407
+ function parseEvidenceList(raw) {
27408
+ if (!Array.isArray(raw)) return [];
27409
+ const out = [];
27410
+ for (const entry of raw) {
27411
+ if (!entry || typeof entry !== "object" || Array.isArray(entry)) continue;
27412
+ const o = entry;
27413
+ const criterion = optStr5(o.criterion);
27414
+ if (!criterion) continue;
27415
+ const statusRaw = optStr5(o.status);
27416
+ const status = STATUSES.includes(statusRaw ?? "") ? statusRaw : "not-verified";
27417
+ const method = optStr5(o.method);
27418
+ out.push({
27419
+ criterion,
27420
+ status,
27421
+ ...optStr5(o.evidence) ? { evidence: optStr5(o.evidence) } : {},
27422
+ ...optStr5(o.reference) ? { reference: optStr5(o.reference) } : {},
27423
+ ...method === "automated" || method === "manual" ? { method } : {},
27424
+ ...optStr5(o.verified_at) ? { verified_at: optStr5(o.verified_at) } : {},
27425
+ ...optStr5(o.verified_by) ? { verified_by: optStr5(o.verified_by) } : {}
27426
+ });
27427
+ }
27428
+ return out;
27429
+ }
27430
+ function parseExceptions2(raw) {
27431
+ if (!Array.isArray(raw)) return [];
27432
+ const out = [];
27433
+ for (const entry of raw) {
27434
+ if (!entry || typeof entry !== "object" || Array.isArray(entry)) continue;
27435
+ const o = entry;
27436
+ const id = optStr5(o.id);
27437
+ if (!id) continue;
27438
+ const st = optStr5(o.status);
27439
+ const status = st === "accepted" || st === "rejected" ? st : "proposed";
27440
+ out.push({
27441
+ id,
27442
+ status,
27443
+ ...optStr5(o.criterion) ? { criterion: optStr5(o.criterion) } : {},
27444
+ ...optStr5(o.reason) ? { reason: optStr5(o.reason) } : {}
27445
+ });
27446
+ }
27447
+ return out;
27448
+ }
27449
+ function buildOutcomeVerification(declared, evidence, exceptions = []) {
27450
+ const byCriterion = /* @__PURE__ */ new Map();
27451
+ for (const e of evidence) byCriterion.set(normalizeCriterion(e.criterion), e);
27452
+ const declaredKeys = new Set(declared.map(normalizeCriterion));
27453
+ const counts = /* @__PURE__ */ new Map();
27454
+ for (const c of declared) counts.set(normalizeCriterion(c), (counts.get(normalizeCriterion(c)) ?? 0) + 1);
27455
+ const ambiguousKeys = new Set([...counts.entries()].filter(([, n]) => n > 1).map(([k]) => k));
27456
+ const waived = new Set(
27457
+ exceptions.filter((x) => x.status === "accepted" && x.reason?.trim() && x.criterion && declaredKeys.has(normalizeCriterion(x.criterion)) && !ambiguousKeys.has(normalizeCriterion(x.criterion))).map((x) => normalizeCriterion(x.criterion))
27458
+ );
27459
+ const criteria = declared.map((criterion) => {
27460
+ const key = normalizeCriterion(criterion);
27461
+ const ambiguous = ambiguousKeys.has(key);
27462
+ const e = ambiguous ? void 0 : byCriterion.get(key);
27463
+ return {
27464
+ criterion,
27465
+ status: e?.status ?? "not-verified",
27466
+ ...e?.evidence ? { evidence: e.evidence } : {},
27467
+ ...e?.reference ? { reference: e.reference } : {},
27468
+ ...e?.method ? { method: e.method } : {},
27469
+ ...e?.verified_at ? { verifiedAt: e.verified_at } : {},
27470
+ ...e?.verified_by ? { verifiedBy: e.verified_by } : {},
27471
+ ...!ambiguous && waived.has(key) ? { waived: true } : {},
27472
+ ...ambiguous ? { ambiguous: true } : {}
27473
+ };
27474
+ });
27475
+ const stale = evidence.filter((e) => !declaredKeys.has(normalizeCriterion(e.criterion)));
27476
+ return {
27477
+ total: criteria.length,
27478
+ // An ambiguous criterion is never counted as passed/waived; it counts as unverified until disambiguated.
27479
+ passed: criteria.filter((c) => !c.ambiguous && (c.status === "passed" || c.waived)).length,
27480
+ failed: criteria.filter((c) => !c.ambiguous && c.status === "failed" && !c.waived).length,
27481
+ notVerified: criteria.filter((c) => c.ambiguous || c.status === "not-verified" && !c.waived).length,
27482
+ manualReview: criteria.filter((c) => !c.ambiguous && c.status === "manual-review-required" && !c.waived).length,
27483
+ ambiguous: criteria.filter((c) => c.ambiguous).length,
27484
+ criteria,
27485
+ stale
27486
+ };
27487
+ }
27488
+ function fm2(entity, key) {
27489
+ return entity.rawFrontmatter?.[key];
27490
+ }
27491
+ function epicOutcomeVerification(epic) {
27492
+ return buildOutcomeVerification(
27493
+ epic.successCriteria,
27494
+ parseEvidenceList(fm2(epic, "outcome_verifications")),
27495
+ parseExceptions2(fm2(epic, "completion_exceptions"))
27496
+ );
27497
+ }
27498
+ function planOutcomeVerification(plan) {
27499
+ return buildOutcomeVerification(
27500
+ plan.successCriteria,
27501
+ parseEvidenceList(fm2(plan, "outcome_verifications")),
27502
+ parseExceptions2(fm2(plan, "completion_exceptions"))
27503
+ );
27504
+ }
27505
+ function planMilestoneVerifications(plan) {
27506
+ const rawMs = Array.isArray(fm2(plan, "milestones")) ? fm2(plan, "milestones") : [];
27507
+ return plan.milestones.map((m) => {
27508
+ const rawEntry = rawMs.find((r) => r && typeof r === "object" && optStr5(r.id)?.toLowerCase() === m.id.toLowerCase());
27509
+ const evidence = parseEvidenceList(rawEntry?.exit_verifications);
27510
+ return { id: m.id, title: m.title, outcome: buildOutcomeVerification(m.exitCriteria, evidence) };
27511
+ });
27512
+ }
27513
+ function decide(blockers, softBlocks, hasAcceptedExceptions) {
27514
+ if (blockers.length > 0) return "BLOCKED";
27515
+ if (softBlocks.length > 0) return "NEEDS_WORK";
27516
+ return hasAcceptedExceptions ? "READY_WITH_EXCEPTIONS" : "READY_TO_COMPLETE";
27517
+ }
27518
+ function evaluateEpicCompletion(dir, epic) {
27519
+ const prog = computeEpicProgress(dir, epic);
27520
+ const exceptions = parseExceptions2(fm2(epic, "completion_exceptions"));
27521
+ const outcome = epicOutcomeVerification(epic);
27522
+ const blockers = [];
27523
+ const softBlocks = [];
27524
+ const reasons = [];
27525
+ const warnings = [];
27526
+ for (const d of prog.readiness.blockingDependencies) blockers.push(`Blocked by unfinished dependency ${d}.`);
27527
+ for (const f of integrityBlockers(dir, epic.id)) blockers.push(f);
27528
+ evaluateOutcomeInto(epic.outcome, true, outcome, blockers, softBlocks, reasons, warnings);
27529
+ if (prog.delivery.total > 0 && prog.delivery.completed < prog.delivery.total) {
27530
+ softBlocks.push("committed-work-incomplete");
27531
+ reasons.push(`Committed work is incomplete (${prog.delivery.completed}/${prog.delivery.total} Work Items completed).`);
27532
+ }
27533
+ const readiness = decide(blockers, softBlocks, exceptions.some((x) => x.status === "accepted"));
27534
+ pushReadinessReason(readiness, reasons);
27535
+ return {
27536
+ id: epic.id,
27537
+ kind: "epic",
27538
+ status: epic.status,
27539
+ readiness,
27540
+ reasons,
27541
+ blockers,
27542
+ warnings,
27543
+ outcome,
27544
+ delivery: { total: prog.delivery.total, completed: prog.delivery.completed, blocked: prog.delivery.blocked },
27545
+ blockingDependencies: prog.readiness.blockingDependencies,
27546
+ exceptions
27547
+ };
27548
+ }
27549
+ function evaluatePlanCompletion(dir, plan) {
27550
+ const prog = computePlanProgress(dir, plan);
27551
+ const exceptions = parseExceptions2(fm2(plan, "completion_exceptions"));
27552
+ const outcome = planOutcomeVerification(plan);
27553
+ const milestones = planMilestoneVerifications(plan);
27554
+ const epics = epicsInPlan(dir, plan.id).map((e) => ({ id: e.id, status: e.status }));
27555
+ const blockers = [];
27556
+ const softBlocks = [];
27557
+ const reasons = [];
27558
+ const warnings = [];
27559
+ for (const d of prog.readiness.blockingDependencies) blockers.push(`Blocked by unfinished dependency ${d}.`);
27560
+ for (const f of integrityBlockers(dir, plan.id)) blockers.push(f);
27561
+ evaluateOutcomeInto(plan.objective, false, outcome, blockers, softBlocks, reasons, warnings);
27562
+ if (!plan.objective) warnings.push("No objective is declared for this Plan (optional, but recommended for completion review).");
27563
+ if (prog.delivery.total > 0 && prog.delivery.completed < prog.delivery.total) {
27564
+ softBlocks.push("committed-work-incomplete");
27565
+ reasons.push(`Committed work is incomplete (${prog.delivery.completed}/${prog.delivery.total} Work Items completed).`);
27566
+ }
27567
+ if (epics.length === 0 && prog.delivery.total === 0) {
27568
+ softBlocks.push("no-committed-work");
27569
+ reasons.push("No Epics and no committed Work Items \u2014 the Plan has no verifiable deliverables yet.");
27570
+ }
27571
+ const openEpics = epics.filter((e) => e.status !== "completed" && e.status !== "cancelled");
27572
+ if (openEpics.length > 0) {
27573
+ softBlocks.push("epics-open");
27574
+ reasons.push(`${openEpics.length} Epic(s) not yet completed: ${openEpics.map((e) => e.id).join(", ")}.`);
27575
+ }
27576
+ for (const m of milestones) {
27577
+ if (m.outcome.failed > 0) {
27578
+ blockers.push(`Milestone ${m.id} has a failed exit criterion.`);
27579
+ }
27580
+ const pending = m.outcome.notVerified + m.outcome.manualReview;
27581
+ if (pending > 0) {
27582
+ softBlocks.push(`milestone-${m.id}-pending`);
27583
+ reasons.push(`Milestone ${m.id}: ${pending} exit criterion(s) not verified.`);
27584
+ }
27585
+ if (m.outcome.stale.length > 0) warnings.push(`Milestone ${m.id} has stale exit-criteria evidence.`);
27586
+ }
27587
+ const readiness = decide(blockers, softBlocks, exceptions.some((x) => x.status === "accepted"));
27588
+ pushReadinessReason(readiness, reasons);
27589
+ return {
27590
+ id: plan.id,
27591
+ kind: "plan",
27592
+ status: plan.status,
27593
+ readiness,
27594
+ reasons,
27595
+ blockers,
27596
+ warnings,
27597
+ outcome,
27598
+ delivery: { total: prog.delivery.total, completed: prog.delivery.completed, blocked: prog.delivery.blocked },
27599
+ blockingDependencies: prog.readiness.blockingDependencies,
27600
+ milestones,
27601
+ epics,
27602
+ exceptions
27603
+ };
27604
+ }
27605
+ function integrityBlockers(dir, subjectId) {
27606
+ return validatePlanningGraph(dir).filter((f) => f.level === "error" && f.subject.toLowerCase() === subjectId.toLowerCase()).map((f) => f.message);
27607
+ }
27608
+ function evaluateOutcomeInto(declaredOutcome, requireDeclaredOutcome, outcome, blockers, softBlocks, reasons, warnings) {
27609
+ if (requireDeclaredOutcome && !declaredOutcome) {
27610
+ softBlocks.push("no-outcome");
27611
+ reasons.push("No expected outcome is declared.");
27612
+ }
27613
+ if (outcome.total === 0) {
27614
+ softBlocks.push("no-success-criteria");
27615
+ reasons.push("No success criteria to verify \u2014 completion cannot be judged by outcome.");
27616
+ }
27617
+ if (outcome.ambiguous > 0) {
27618
+ softBlocks.push("criteria-ambiguous");
27619
+ reasons.push(`${outcome.ambiguous} success criterion(s) collide in text \u2014 rename to disambiguate before verifying.`);
27620
+ }
27621
+ if (outcome.failed > 0) {
27622
+ softBlocks.push("criteria-failed");
27623
+ reasons.push(`${outcome.failed} success criterion(s) failed verification.`);
27624
+ }
27625
+ const pending = outcome.notVerified + outcome.manualReview - outcome.ambiguous;
27626
+ if (pending > 0) {
27627
+ softBlocks.push("criteria-unverified");
27628
+ reasons.push(`${pending} success criterion(s) not verified (no or insufficient evidence).`);
27629
+ }
27630
+ if (outcome.stale.length > 0) warnings.push(`${outcome.stale.length} evidence record(s) no longer match a declared criterion (stale).`);
27631
+ }
27632
+ function pushReadinessReason(readiness, reasons) {
27633
+ if (readiness === "READY_TO_COMPLETE") reasons.unshift("All success criteria are verified and committed work is complete. Human approval is still required to close.");
27634
+ else if (readiness === "READY_WITH_EXCEPTIONS") reasons.unshift("Remaining gaps are covered by accepted exceptions. Human approval is still required to close.");
27635
+ }
27636
+
27375
27637
  // src/core/delivery-planning-write.ts
27376
27638
  var DeliveryPlanningWriteError = class extends Error {
27377
27639
  constructor(message) {
@@ -27379,6 +27641,23 @@ var DeliveryPlanningWriteError = class extends Error {
27379
27641
  this.name = "DeliveryPlanningWriteError";
27380
27642
  }
27381
27643
  };
27644
+ var PlanningConflictError = class extends Error {
27645
+ constructor(id, expectedRevision, actualRevision) {
27646
+ super(`"${id}" was modified since it was loaded (expected revision ${expectedRevision}, found ${actualRevision}). Reload and try again.`);
27647
+ this.id = id;
27648
+ this.expectedRevision = expectedRevision;
27649
+ this.actualRevision = actualRevision;
27650
+ this.name = "PlanningConflictError";
27651
+ }
27652
+ id;
27653
+ expectedRevision;
27654
+ actualRevision;
27655
+ };
27656
+ function assertFreshRevision(id, currentContent, opts) {
27657
+ if (!opts?.expectedRevision) return;
27658
+ const actual = revisionOf(currentContent);
27659
+ if (actual !== opts.expectedRevision) throw new PlanningConflictError(id, opts.expectedRevision, actual);
27660
+ }
27382
27661
  function slugify8(s) {
27383
27662
  return s.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "item";
27384
27663
  }
@@ -27439,6 +27718,163 @@ function associateInitiativeWithEpic(dir, initiativeId, epicId) {
27439
27718
  if (!getEpic(dir, epicId)) throw new DeliveryPlanningWriteError(`Epic ${epicId} does not exist.`);
27440
27719
  return updateInitiative(dir, ini.id, { epic: epicId });
27441
27720
  }
27721
+ function today3() {
27722
+ return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
27723
+ }
27724
+ var PlanningNotReadyError = class extends DeliveryPlanningWriteError {
27725
+ constructor(evaluation) {
27726
+ super(`${evaluation.kind === "plan" ? "Plan" : "Epic"} ${evaluation.id} is not ready to complete (${evaluation.readiness}).`);
27727
+ this.evaluation = evaluation;
27728
+ this.name = "PlanningNotReadyError";
27729
+ }
27730
+ evaluation;
27731
+ };
27732
+ function transitionDeliveryPlan(dir, id, to, opts) {
27733
+ const plan = getPlan(dir, id);
27734
+ if (!plan) throw new DeliveryPlanningWriteError(`Plan ${id} does not exist.`);
27735
+ if (!PLAN_STATES.includes(to)) throw new DeliveryPlanningWriteError(`Invalid plan status: ${to}.`);
27736
+ if (to === "completed") throw new DeliveryPlanningWriteError(`Completing Plan ${id} requires evidence-based review \u2014 use completeDeliveryPlan.`);
27737
+ const raw = readFile(plan.filePath);
27738
+ assertFreshRevision(plan.id, raw, opts);
27739
+ if (plan.status === to) return plan;
27740
+ if (!PLAN_TRANSITIONS[plan.status].includes(to)) throw new DeliveryPlanningWriteError(`Invalid transition ${plan.status} \u2192 ${to} for Plan ${id}.`);
27741
+ const { data, content } = matter29(raw, {});
27742
+ data.status = to;
27743
+ if (to === "completed") data.completed_at = today3();
27744
+ const newContent = matter29.stringify(content, data);
27745
+ writeFile(plan.filePath, newContent);
27746
+ const updated = parseDeliveryPlan(dir, plan.filePath, newContent);
27747
+ if (!updated) throw new DeliveryPlanningWriteError("Failed to parse the Plan after transition.");
27748
+ return updated;
27749
+ }
27750
+ function transitionEpic(dir, id, to, opts) {
27751
+ const epic = getEpic(dir, id);
27752
+ if (!epic) throw new DeliveryPlanningWriteError(`Epic ${id} does not exist.`);
27753
+ if (!EPIC_STATES.includes(to)) throw new DeliveryPlanningWriteError(`Invalid epic status: ${to}.`);
27754
+ if (to === "completed") throw new DeliveryPlanningWriteError(`Completing Epic ${id} requires evidence-based review \u2014 use completeEpic.`);
27755
+ const raw = readFile(epic.filePath);
27756
+ assertFreshRevision(epic.id, raw, opts);
27757
+ if (epic.status === to) return epic;
27758
+ if (!EPIC_TRANSITIONS[epic.status].includes(to)) throw new DeliveryPlanningWriteError(`Invalid transition ${epic.status} \u2192 ${to} for Epic ${id}.`);
27759
+ const { data, content } = matter29(raw, {});
27760
+ data.status = to;
27761
+ if (to === "completed") data.completed_at = today3();
27762
+ const newContent = matter29.stringify(content, data);
27763
+ writeFile(epic.filePath, newContent);
27764
+ const updated = parseEpic(dir, epic.filePath, newContent);
27765
+ if (!updated) throw new DeliveryPlanningWriteError("Failed to parse the Epic after transition.");
27766
+ return updated;
27767
+ }
27768
+ function assertCriterionDeclared(declared, criterion, kind) {
27769
+ const key = normalizeCriterion(criterion);
27770
+ const matches = declared.filter((c) => normalizeCriterion(c) === key).length;
27771
+ if (matches === 0) throw new DeliveryPlanningWriteError(`"${criterion}" is not a declared ${kind} criterion.`);
27772
+ if (matches > 1) throw new DeliveryPlanningWriteError(`"${criterion}" matches more than one declared ${kind} criterion \u2014 rename them to disambiguate before recording evidence.`);
27773
+ }
27774
+ function upsertEvidence(existing, input) {
27775
+ const list2 = Array.isArray(existing) ? existing.filter((e) => e && typeof e === "object" && !Array.isArray(e)) : [];
27776
+ const key = normalizeCriterion(input.criterion);
27777
+ const kept = list2.filter((e) => normalizeCriterion(String(e.criterion ?? "")) !== key);
27778
+ const obj = { criterion: input.criterion.trim(), status: input.status };
27779
+ if (input.evidence?.trim()) obj.evidence = input.evidence.trim();
27780
+ if (input.reference?.trim()) obj.reference = input.reference.trim();
27781
+ if (input.method) obj.method = input.method;
27782
+ obj.verified_at = today3();
27783
+ if (input.verifiedBy?.trim()) obj.verified_by = input.verifiedBy.trim();
27784
+ return [...kept, obj];
27785
+ }
27786
+ function recordEpicOutcomeVerification(dir, id, input, opts) {
27787
+ const epic = getEpic(dir, id);
27788
+ if (!epic) throw new DeliveryPlanningWriteError(`Epic ${id} does not exist.`);
27789
+ assertCriterionDeclared(epic.successCriteria, input.criterion, "success");
27790
+ const raw = readFile(epic.filePath);
27791
+ assertFreshRevision(epic.id, raw, opts);
27792
+ const { data, content } = matter29(raw, {});
27793
+ data.outcome_verifications = upsertEvidence(data.outcome_verifications, input);
27794
+ const newContent = matter29.stringify(content, data);
27795
+ writeFile(epic.filePath, newContent);
27796
+ const updated = parseEpic(dir, epic.filePath, newContent);
27797
+ if (!updated) throw new DeliveryPlanningWriteError("Failed to parse the Epic after recording evidence.");
27798
+ return updated;
27799
+ }
27800
+ function recordPlanOutcomeVerification(dir, id, input, opts) {
27801
+ const plan = getPlan(dir, id);
27802
+ if (!plan) throw new DeliveryPlanningWriteError(`Plan ${id} does not exist.`);
27803
+ assertCriterionDeclared(plan.successCriteria, input.criterion, "success");
27804
+ const raw = readFile(plan.filePath);
27805
+ assertFreshRevision(plan.id, raw, opts);
27806
+ const { data, content } = matter29(raw, {});
27807
+ data.outcome_verifications = upsertEvidence(data.outcome_verifications, input);
27808
+ const newContent = matter29.stringify(content, data);
27809
+ writeFile(plan.filePath, newContent);
27810
+ const updated = parseDeliveryPlan(dir, plan.filePath, newContent);
27811
+ if (!updated) throw new DeliveryPlanningWriteError("Failed to parse the Plan after recording evidence.");
27812
+ return updated;
27813
+ }
27814
+ function recordMilestoneExitVerification(dir, planId, milestoneId, input, opts) {
27815
+ const plan = getPlan(dir, planId);
27816
+ if (!plan) throw new DeliveryPlanningWriteError(`Plan ${planId} does not exist.`);
27817
+ const milestone = plan.milestones.find((m) => m.id.toLowerCase() === milestoneId.toLowerCase());
27818
+ if (!milestone) throw new DeliveryPlanningWriteError(`Milestone ${milestoneId} is not defined in ${planId}.`);
27819
+ assertCriterionDeclared(milestone.exitCriteria, input.criterion, "exit");
27820
+ const raw = readFile(plan.filePath);
27821
+ assertFreshRevision(plan.id, raw, opts);
27822
+ const { data, content } = matter29(raw, {});
27823
+ const rawMs = Array.isArray(data.milestones) ? data.milestones : [];
27824
+ const entry = rawMs.find((m) => m && typeof m === "object" && String(m.id ?? "").toLowerCase() === milestoneId.toLowerCase());
27825
+ if (!entry) throw new DeliveryPlanningWriteError(`Milestone ${milestoneId} entry not found in ${planId} frontmatter.`);
27826
+ entry.exit_verifications = upsertEvidence(entry.exit_verifications, input);
27827
+ data.milestones = rawMs;
27828
+ const newContent = matter29.stringify(content, data);
27829
+ writeFile(plan.filePath, newContent);
27830
+ const updated = parseDeliveryPlan(dir, plan.filePath, newContent);
27831
+ if (!updated) throw new DeliveryPlanningWriteError("Failed to parse the Plan after recording milestone evidence.");
27832
+ return updated;
27833
+ }
27834
+ function completionDecisionRecord(evaluation, input) {
27835
+ const rec = { readiness: evaluation.readiness, decided_at: today3(), reasons: evaluation.reasons };
27836
+ if (input.decidedBy?.trim()) rec.decided_by = input.decidedBy.trim();
27837
+ if (input.note?.trim()) rec.note = input.note.trim();
27838
+ const acceptedExceptions = evaluation.exceptions.filter((x) => x.status === "accepted");
27839
+ if (acceptedExceptions.length > 0) rec.exceptions = acceptedExceptions;
27840
+ return rec;
27841
+ }
27842
+ function completeEpic(dir, id, input = {}, opts) {
27843
+ const epic = getEpic(dir, id);
27844
+ if (!epic) throw new DeliveryPlanningWriteError(`Epic ${id} does not exist.`);
27845
+ const evaluation = evaluateEpicCompletion(dir, epic);
27846
+ if (evaluation.readiness !== "READY_TO_COMPLETE" && evaluation.readiness !== "READY_WITH_EXCEPTIONS") throw new PlanningNotReadyError(evaluation);
27847
+ if (!EPIC_TRANSITIONS[epic.status].includes("completed")) throw new DeliveryPlanningWriteError(`Epic ${id} cannot move from ${epic.status} to completed.`);
27848
+ const raw = readFile(epic.filePath);
27849
+ assertFreshRevision(epic.id, raw, opts);
27850
+ const { data, content } = matter29(raw, {});
27851
+ data.status = "completed";
27852
+ data.completed_at = today3();
27853
+ data.completion_decision = completionDecisionRecord(evaluation, input);
27854
+ const newContent = matter29.stringify(content, data);
27855
+ writeFile(epic.filePath, newContent);
27856
+ const updated = parseEpic(dir, epic.filePath, newContent);
27857
+ if (!updated) throw new DeliveryPlanningWriteError("Failed to parse the Epic after completion.");
27858
+ return updated;
27859
+ }
27860
+ function completeDeliveryPlan(dir, id, input = {}, opts) {
27861
+ const plan = getPlan(dir, id);
27862
+ if (!plan) throw new DeliveryPlanningWriteError(`Plan ${id} does not exist.`);
27863
+ const evaluation = evaluatePlanCompletion(dir, plan);
27864
+ if (evaluation.readiness !== "READY_TO_COMPLETE" && evaluation.readiness !== "READY_WITH_EXCEPTIONS") throw new PlanningNotReadyError(evaluation);
27865
+ if (!PLAN_TRANSITIONS[plan.status].includes("completed")) throw new DeliveryPlanningWriteError(`Plan ${id} cannot move from ${plan.status} to completed.`);
27866
+ const raw = readFile(plan.filePath);
27867
+ assertFreshRevision(plan.id, raw, opts);
27868
+ const { data, content } = matter29(raw, {});
27869
+ data.status = "completed";
27870
+ data.completed_at = today3();
27871
+ data.completion_decision = completionDecisionRecord(evaluation, input);
27872
+ const newContent = matter29.stringify(content, data);
27873
+ writeFile(plan.filePath, newContent);
27874
+ const updated = parseDeliveryPlan(dir, plan.filePath, newContent);
27875
+ if (!updated) throw new DeliveryPlanningWriteError("Failed to parse the Plan after completion.");
27876
+ return updated;
27877
+ }
27442
27878
 
27443
27879
  // src/commands/plan.ts
27444
27880
  function requireInit(dir) {
@@ -27631,6 +28067,186 @@ async function runEpicAssociate(epicId, initiativeId) {
27631
28067
  process.exit(1);
27632
28068
  }
27633
28069
  }
28070
+ var EVIDENCE_STATUSES = ["passed", "failed", "not-verified", "manual-review-required"];
28071
+ function printEvaluation(ev) {
28072
+ log.info(` Readiness: ${ev.readiness}`);
28073
+ const o = ev.outcome;
28074
+ log.info(` Outcome criteria: ${o.passed}/${o.total} passed${o.failed ? ` \xB7 ${o.failed} failed` : ""}${o.notVerified ? ` \xB7 ${o.notVerified} unverified` : ""}${o.ambiguous ? ` \xB7 ${o.ambiguous} ambiguous` : ""}`);
28075
+ for (const c of o.criteria) log.info(` [${c.status}${c.waived ? "/waived" : ""}${c.ambiguous ? "/ambiguous" : ""}] ${c.criterion}`);
28076
+ if (o.stale.length) log.warn(` Stale evidence (criterion changed): ${o.stale.map((s) => s.criterion).join("; ")}`);
28077
+ if (ev.milestones) for (const m of ev.milestones) log.info(` Milestone ${m.id}: ${m.outcome.passed}/${m.outcome.total} exit criteria verified`);
28078
+ if (ev.blockingDependencies.length) log.warn(` Blocking dependencies: ${ev.blockingDependencies.join(", ")}`);
28079
+ for (const b of ev.blockers) log.warn(` Blocker: ${b}`);
28080
+ for (const w of ev.warnings) log.warn(` Warning: ${w}`);
28081
+ for (const r of ev.reasons) log.info(` ${r}`);
28082
+ log.info(" Completion is never automatic \u2014 it always requires an explicit human decision.");
28083
+ }
28084
+ function evidenceInput(opts) {
28085
+ if (!opts.criterion?.trim()) {
28086
+ log.error("A --criterion is required.");
28087
+ process.exit(1);
28088
+ }
28089
+ const status = opts.status ?? "passed";
28090
+ if (!EVIDENCE_STATUSES.includes(status)) {
28091
+ log.error(`--status must be one of: ${EVIDENCE_STATUSES.join(", ")}.`);
28092
+ process.exit(1);
28093
+ }
28094
+ const method = opts.method === "automated" || opts.method === "manual" ? opts.method : void 0;
28095
+ return { criterion: opts.criterion.trim(), status, evidence: opts.evidence, reference: opts.reference, method, verifiedBy: opts.by };
28096
+ }
28097
+ function runPlanStart(id) {
28098
+ const dir = cwd();
28099
+ requireInit(dir);
28100
+ intro(`kaddo plan start ${id}`);
28101
+ try {
28102
+ const p = transitionDeliveryPlan(dir, id, "in-progress");
28103
+ log.success(`Plan ${p.id} is now ${p.status}.`);
28104
+ outro("Started.");
28105
+ } catch (err) {
28106
+ log.error(err instanceof DeliveryPlanningWriteError ? err.message : String(err));
28107
+ process.exit(1);
28108
+ }
28109
+ }
28110
+ function runPlanVerify(id, opts = {}) {
28111
+ const dir = cwd();
28112
+ requireInit(dir);
28113
+ const plan = getPlan(dir, id);
28114
+ if (!plan) {
28115
+ if (opts.json) console.log(JSON.stringify({ error: `Plan ${id} not found.` }));
28116
+ else log.error(`Plan ${id} not found.`);
28117
+ process.exit(1);
28118
+ }
28119
+ const ev = evaluatePlanCompletion(dir, plan);
28120
+ if (opts.json) {
28121
+ console.log(JSON.stringify(ev, null, 2));
28122
+ return;
28123
+ }
28124
+ intro(`kaddo plan verify ${id}`);
28125
+ printEvaluation(ev);
28126
+ outro(`Plan ${id} \u2014 ${ev.readiness}.`);
28127
+ }
28128
+ async function runPlanComplete(id, opts = {}) {
28129
+ const dir = cwd();
28130
+ requireInit(dir);
28131
+ intro(`kaddo plan complete ${id}`);
28132
+ const plan = getPlan(dir, id);
28133
+ if (!plan) {
28134
+ log.error(`Plan ${id} not found.`);
28135
+ process.exit(1);
28136
+ }
28137
+ const ev = evaluatePlanCompletion(dir, plan);
28138
+ printEvaluation(ev);
28139
+ if (ev.readiness !== "READY_TO_COMPLETE" && ev.readiness !== "READY_WITH_EXCEPTIONS") {
28140
+ log.error(`Plan ${id} is not ready to complete (${ev.readiness}).`);
28141
+ process.exit(1);
28142
+ }
28143
+ const ok = opts.yes === true || await confirm({ message: `Complete Plan ${id}? This records a human completion decision.` }) === true;
28144
+ if (!ok) {
28145
+ cancel("Cancelled.");
28146
+ return;
28147
+ }
28148
+ try {
28149
+ const done = completeDeliveryPlan(dir, id, { decidedBy: opts.by });
28150
+ log.success(`Plan ${done.id} completed (${ev.readiness}).`);
28151
+ outro("Completion decision recorded.");
28152
+ } catch (err) {
28153
+ log.error(err instanceof DeliveryPlanningWriteError ? err.message : String(err));
28154
+ process.exit(1);
28155
+ }
28156
+ }
28157
+ function runPlanEvidence(id, opts = {}) {
28158
+ const dir = cwd();
28159
+ requireInit(dir);
28160
+ intro(`kaddo plan evidence ${id}`);
28161
+ const input = evidenceInput(opts);
28162
+ try {
28163
+ if (opts.milestone) {
28164
+ recordMilestoneExitVerification(dir, id, opts.milestone, input);
28165
+ log.success(`Recorded evidence for milestone ${opts.milestone} criterion.`);
28166
+ } else {
28167
+ recordPlanOutcomeVerification(dir, id, input);
28168
+ log.success("Recorded Plan outcome evidence.");
28169
+ }
28170
+ outro(`[${input.status}] ${input.criterion}`);
28171
+ } catch (err) {
28172
+ log.error(err instanceof DeliveryPlanningWriteError ? err.message : String(err));
28173
+ process.exit(1);
28174
+ }
28175
+ }
28176
+ function runEpicStart(id) {
28177
+ const dir = cwd();
28178
+ requireInit(dir);
28179
+ intro(`kaddo epic start ${id}`);
28180
+ try {
28181
+ const e = transitionEpic(dir, id, "in-progress");
28182
+ log.success(`Epic ${e.id} is now ${e.status}.`);
28183
+ outro("Started.");
28184
+ } catch (err) {
28185
+ log.error(err instanceof DeliveryPlanningWriteError ? err.message : String(err));
28186
+ process.exit(1);
28187
+ }
28188
+ }
28189
+ function runEpicVerify(id, opts = {}) {
28190
+ const dir = cwd();
28191
+ requireInit(dir);
28192
+ const epic = getEpic(dir, id);
28193
+ if (!epic) {
28194
+ if (opts.json) console.log(JSON.stringify({ error: `Epic ${id} not found.` }));
28195
+ else log.error(`Epic ${id} not found.`);
28196
+ process.exit(1);
28197
+ }
28198
+ const ev = evaluateEpicCompletion(dir, epic);
28199
+ if (opts.json) {
28200
+ console.log(JSON.stringify(ev, null, 2));
28201
+ return;
28202
+ }
28203
+ intro(`kaddo epic verify ${id}`);
28204
+ printEvaluation(ev);
28205
+ outro(`Epic ${id} \u2014 ${ev.readiness}.`);
28206
+ }
28207
+ async function runEpicComplete(id, opts = {}) {
28208
+ const dir = cwd();
28209
+ requireInit(dir);
28210
+ intro(`kaddo epic complete ${id}`);
28211
+ const epic = getEpic(dir, id);
28212
+ if (!epic) {
28213
+ log.error(`Epic ${id} not found.`);
28214
+ process.exit(1);
28215
+ }
28216
+ const ev = evaluateEpicCompletion(dir, epic);
28217
+ printEvaluation(ev);
28218
+ if (ev.readiness !== "READY_TO_COMPLETE" && ev.readiness !== "READY_WITH_EXCEPTIONS") {
28219
+ log.error(`Epic ${id} is not ready to complete (${ev.readiness}).`);
28220
+ process.exit(1);
28221
+ }
28222
+ const ok = opts.yes === true || await confirm({ message: `Complete Epic ${id}? This records a human completion decision.` }) === true;
28223
+ if (!ok) {
28224
+ cancel("Cancelled.");
28225
+ return;
28226
+ }
28227
+ try {
28228
+ const done = completeEpic(dir, id, { decidedBy: opts.by });
28229
+ log.success(`Epic ${done.id} completed (${ev.readiness}).`);
28230
+ outro("Completion decision recorded.");
28231
+ } catch (err) {
28232
+ log.error(err instanceof PlanningNotReadyError || err instanceof DeliveryPlanningWriteError ? err.message : String(err));
28233
+ process.exit(1);
28234
+ }
28235
+ }
28236
+ function runEpicEvidence(id, opts = {}) {
28237
+ const dir = cwd();
28238
+ requireInit(dir);
28239
+ intro(`kaddo epic evidence ${id}`);
28240
+ const input = evidenceInput(opts);
28241
+ try {
28242
+ recordEpicOutcomeVerification(dir, id, input);
28243
+ log.success("Recorded Epic outcome evidence.");
28244
+ outro(`[${input.status}] ${input.criterion}`);
28245
+ } catch (err) {
28246
+ log.error(err instanceof DeliveryPlanningWriteError ? err.message : String(err));
28247
+ process.exit(1);
28248
+ }
28249
+ }
27634
28250
 
27635
28251
  // src/core/telemetry.ts
27636
28252
  import crypto6 from "crypto";
@@ -28347,6 +28963,12 @@ planCmd.command("progress <id>").description("Planning coverage, delivery progre
28347
28963
  planCmd.command("create").description("Create a new delivery plan (interactive)").action(() => {
28348
28964
  void runPlanCreate();
28349
28965
  });
28966
+ planCmd.command("start <id>").description("Transition a Delivery Plan to in-progress (WI-078)").action((id) => runPlanStart(id));
28967
+ planCmd.command("verify <id>").description("Evidence-based completion readiness of a Plan (read-only)").option("--json", "Machine-readable output").action((id, o) => runPlanVerify(id, o));
28968
+ planCmd.command("evidence <id>").description("Record outcome (or milestone exit) verification evidence").requiredOption("--criterion <text>", "The declared success / exit criterion").option("--status <status>", "passed | failed | not-verified | manual-review-required", "passed").option("--evidence <text>", "What the evidence shows").option("--reference <ref>", "File, test, ADR or report").option("--method <method>", "automated | manual").option("--milestone <id>", "Verify a milestone exit criterion instead of a Plan success criterion").option("--by <who>", "Who verified it").action((id, o) => runPlanEvidence(id, o));
28969
+ planCmd.command("complete <id>").description("Complete a Plan after an evidence-based review (human-gated)").option("-y, --yes", "Skip the confirmation prompt").option("--by <who>", "Who approved the completion").action((id, o) => {
28970
+ void runPlanComplete(id, o);
28971
+ });
28350
28972
  var epicCmd = program.command("epic").description("Delivery Epics \u2014 significant outcomes spanning Initiatives and Work Items (WI-074)");
28351
28973
  epicCmd.command("list").description("List epics with progress").action(() => runEpicList());
28352
28974
  epicCmd.command("show <id>").description("Show an epic, its plan/milestone and initiatives").action((id) => runEpicShow(id));
@@ -28357,6 +28979,12 @@ epicCmd.command("create").description("Create a new epic (interactive)").action(
28357
28979
  epicCmd.command("associate <epicId> <initiativeId>").description("Associate an existing Initiative with an Epic").action((e, i) => {
28358
28980
  void runEpicAssociate(e, i);
28359
28981
  });
28982
+ epicCmd.command("start <id>").description("Transition an Epic to in-progress (WI-078)").action((id) => runEpicStart(id));
28983
+ epicCmd.command("verify <id>").description("Evidence-based completion readiness of an Epic (read-only)").option("--json", "Machine-readable output").action((id, o) => runEpicVerify(id, o));
28984
+ epicCmd.command("evidence <id>").description("Record outcome verification evidence for a success criterion").requiredOption("--criterion <text>", "The declared success criterion").option("--status <status>", "passed | failed | not-verified | manual-review-required", "passed").option("--evidence <text>", "What the evidence shows").option("--reference <ref>", "File, test, ADR or report").option("--method <method>", "automated | manual").option("--by <who>", "Who verified it").action((id, o) => runEpicEvidence(id, o));
28985
+ epicCmd.command("complete <id>").description("Complete an Epic after an evidence-based review (human-gated)").option("-y, --yes", "Skip the confirmation prompt").option("--by <who>", "Who approved the completion").action((id, o) => {
28986
+ void runEpicComplete(id, o);
28987
+ });
28360
28988
  var topologyCmd = program.command("topology").description("Validate and apply a semantic system topology proposal (agent proposes, human confirms, Core applies)");
28361
28989
  topologyCmd.command("validate <file>").description("Validate a topology proposal file deterministically (no write)").action((file) => {
28362
28990
  runTopologyValidate(file);