@kaddo/cli 3.133.0 → 3.134.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 (34) hide show
  1. package/dist/admin-dist/assets/{architectureDiagram-3BPJPVTR-DR1_1O3v.js → architectureDiagram-3BPJPVTR-CYNwLGE7.js} +1 -1
  2. package/dist/admin-dist/assets/{chunk-727SXJPM-COmzRt04.js → chunk-727SXJPM-Cet603Hl.js} +1 -1
  3. package/dist/admin-dist/assets/{chunk-AQP2D5EJ-CXMsTGWW.js → chunk-AQP2D5EJ-8XEHPg3a.js} +1 -1
  4. package/dist/admin-dist/assets/{classDiagram-v2-Q7XG4LA2-D2dQFgos.js → classDiagram-4FO5ZUOK-Bhwb9850.js} +1 -1
  5. package/dist/admin-dist/assets/{classDiagram-4FO5ZUOK-D2dQFgos.js → classDiagram-v2-Q7XG4LA2-Bhwb9850.js} +1 -1
  6. package/dist/admin-dist/assets/{dagre-BM42HDAG-BMRsOxw1.js → dagre-BM42HDAG-DqQXdP8F.js} +1 -1
  7. package/dist/admin-dist/assets/{diagram-2AECGRRQ-CRXNCxDY.js → diagram-2AECGRRQ-B1bysbNR.js} +1 -1
  8. package/dist/admin-dist/assets/{diagram-5GNKFQAL-C9bO8FnC.js → diagram-5GNKFQAL-DRifvijh.js} +1 -1
  9. package/dist/admin-dist/assets/{diagram-LMA3HP47-ye8rGB9h.js → diagram-LMA3HP47-DajL2Tv-.js} +1 -1
  10. package/dist/admin-dist/assets/{diagram-OG6HWLK6-BL0joNkk.js → diagram-OG6HWLK6-WCJo9oL4.js} +1 -1
  11. package/dist/admin-dist/assets/{erDiagram-TEJ5UH35-lqVTGIq-.js → erDiagram-TEJ5UH35-DwgqKm6b.js} +1 -1
  12. package/dist/admin-dist/assets/{flowDiagram-I6XJVG4X-DA2CLejf.js → flowDiagram-I6XJVG4X-M0kG8sQQ.js} +1 -1
  13. package/dist/admin-dist/assets/{ganttDiagram-6RSMTGT7-Dkr4jLLp.js → ganttDiagram-6RSMTGT7-DtyZt9Ti.js} +1 -1
  14. package/dist/admin-dist/assets/{index-CZPZGMX7.js → index-CZVvIq5M.js} +10 -10
  15. package/dist/admin-dist/assets/{infoDiagram-5YYISTIA-PZDUmGz-.js → infoDiagram-5YYISTIA-Vwdw_1gf.js} +1 -1
  16. package/dist/admin-dist/assets/{ishikawaDiagram-YF4QCWOH-BByxhIgY.js → ishikawaDiagram-YF4QCWOH-CIi6B5fy.js} +1 -1
  17. package/dist/admin-dist/assets/{kanban-definition-UN3LZRKU-BSTqfNBc.js → kanban-definition-UN3LZRKU-5HNFMSQ7.js} +1 -1
  18. package/dist/admin-dist/assets/{linear-DJE08IfY.js → linear-D3H69r3G.js} +1 -1
  19. package/dist/admin-dist/assets/{mindmap-definition-RKZ34NQL-CmiCyDY8.js → mindmap-definition-RKZ34NQL-BI0w0H_c.js} +1 -1
  20. package/dist/admin-dist/assets/{pieDiagram-4H26LBE5-BlMxq332.js → pieDiagram-4H26LBE5-5oMGjRSP.js} +1 -1
  21. package/dist/admin-dist/assets/{quadrantDiagram-W4KKPZXB-Cy0zZxaY.js → quadrantDiagram-W4KKPZXB-Cf4_7xD4.js} +1 -1
  22. package/dist/admin-dist/assets/{requirementDiagram-4Y6WPE33-CAfQqVXA.js → requirementDiagram-4Y6WPE33-tKyHvrMo.js} +1 -1
  23. package/dist/admin-dist/assets/{sequenceDiagram-3UESZ5HK-CZYFDyTc.js → sequenceDiagram-3UESZ5HK-XJChOzcT.js} +1 -1
  24. package/dist/admin-dist/assets/{stateDiagram-AJRCARHV-BTWDzbes.js → stateDiagram-AJRCARHV-CG6QHhPz.js} +1 -1
  25. package/dist/admin-dist/assets/{stateDiagram-v2-BHNVJYJU-BcExDjN4.js → stateDiagram-v2-BHNVJYJU-COU53r4o.js} +1 -1
  26. package/dist/admin-dist/assets/{timeline-definition-PNZ67QCA-Db_z8PtC.js → timeline-definition-PNZ67QCA-CszwARJN.js} +1 -1
  27. package/dist/admin-dist/assets/{vennDiagram-CIIHVFJN-Dkj99o7j.js → vennDiagram-CIIHVFJN-kMR7sGYN.js} +1 -1
  28. package/dist/admin-dist/assets/{wardleyDiagram-YWT4CUSO-DG8V20tb.js → wardleyDiagram-YWT4CUSO-Cu44stm7.js} +1 -1
  29. package/dist/admin-dist/assets/{xychartDiagram-2RQKCTM6-B6EVudFe.js → xychartDiagram-2RQKCTM6-DeU0-PgC.js} +1 -1
  30. package/dist/admin-dist/index.html +1 -1
  31. package/dist/admin-server/index.js +112 -5
  32. package/dist/core.js +272 -82
  33. package/dist/index.js +501 -137
  34. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -144,10 +144,10 @@ Status: pending
144
144
  `;
145
145
  }
146
146
  function ensurePocArtifact(dir, projectName) {
147
- const path16 = join(dir, POC_ARTIFACT_PATH);
148
- if (exists(path16)) return false;
147
+ const path18 = join(dir, POC_ARTIFACT_PATH);
148
+ if (exists(path18)) return false;
149
149
  ensureDir(join(dir, "knowledge", "delivery"));
150
- writeFile(path16, pocTemplate(projectName));
150
+ writeFile(path18, pocTemplate(projectName));
151
151
  return true;
152
152
  }
153
153
  var PLACEHOLDER = /^[_<].*[_>]$|^(describe|list|document|what|how)\b/i;
@@ -162,13 +162,13 @@ function meaningful(text2) {
162
162
  });
163
163
  }
164
164
  function readPocSummary(dir) {
165
- const path16 = join(dir, POC_ARTIFACT_PATH);
166
- if (!exists(path16)) {
165
+ const path18 = join(dir, POC_ARTIFACT_PATH);
166
+ if (!exists(path18)) {
167
167
  return { exists: false, hypothesisDefined: false, successCriteriaCount: 0, constraintsDefined: false, nonGoalsDefined: false, conclusion: "pending" };
168
168
  }
169
169
  let markdown = "";
170
170
  try {
171
- markdown = readFile(path16);
171
+ markdown = readFile(path18);
172
172
  } catch {
173
173
  return { exists: false, hypothesisDefined: false, successCriteriaCount: 0, constraintsDefined: false, nonGoalsDefined: false, conclusion: "pending" };
174
174
  }
@@ -688,8 +688,8 @@ function loadConfig(dir) {
688
688
  const parsed = configSchema.safeParse(raw ?? {});
689
689
  if (!parsed.success) {
690
690
  const issues = parsed.error.issues.map((i) => {
691
- const path16 = i.path.join(".");
692
- return path16 ? ` - ${path16}: ${i.message}` : ` - ${i.message}`;
691
+ const path18 = i.path.join(".");
692
+ return path18 ? ` - ${path18}: ${i.message}` : ` - ${i.message}`;
693
693
  }).join("\n");
694
694
  throw new ConfigError(`Invalid .kaddo/config.yml:
695
695
  ${issues}`);
@@ -7146,6 +7146,7 @@ async function runCreateFromRoadmap(dir, cliType) {
7146
7146
 
7147
7147
  // src/services/git.ts
7148
7148
  import { execa } from "execa";
7149
+ import path3 from "path";
7149
7150
  async function getModifiedFiles(mode = "head") {
7150
7151
  try {
7151
7152
  let args;
@@ -7206,6 +7207,41 @@ async function getUntrackedFiles() {
7206
7207
  return [];
7207
7208
  }
7208
7209
  }
7210
+ async function observeGit(dir, maxCommits = 100, repositoryId) {
7211
+ const limit = Math.max(1, Math.min(maxCommits, 250));
7212
+ const inspectedAt = (/* @__PURE__ */ new Date()).toISOString();
7213
+ try {
7214
+ const root = await getGitRoot(dir);
7215
+ if (!root) return { availability: "unavailable", repository: null, commits: [], branches: [], inspectedAt, limit };
7216
+ const [log2, refs] = await Promise.all([
7217
+ execa("git", ["log", `--max-count=${limit}`, "--format=%H%x1f%an%x1f%aI%x1f%s", "--name-only"], { cwd: root, timeout: 5e3 }),
7218
+ execa("git", ["for-each-ref", "--format=%(refname:short)", "refs/heads"], { cwd: root, timeout: 5e3 })
7219
+ ]);
7220
+ const commits = [];
7221
+ let current = null;
7222
+ for (const line of log2.stdout.split(/\r?\n/)) {
7223
+ const parts = line.split("");
7224
+ if (parts.length === 4) {
7225
+ if (current) commits.push(current);
7226
+ current = { sha: parts[0], author: parts[1], date: parts[2], subject: parts[3], files: [] };
7227
+ } else if (current && line.trim()) current.files.push(line.trim());
7228
+ }
7229
+ if (current) commits.push(current);
7230
+ return {
7231
+ // The display identity is supplied by the caller when a project observes
7232
+ // several repositories. A basename alone is ambiguous in a multirepo
7233
+ // workspace (for example, two independent `api` folders).
7234
+ availability: "available",
7235
+ repository: repositoryId ?? path3.basename(root),
7236
+ commits,
7237
+ branches: refs.stdout.split(/\r?\n/).map((name) => name.trim()).filter(Boolean).slice(0, 100).map((name) => ({ name })),
7238
+ inspectedAt,
7239
+ limit
7240
+ };
7241
+ } catch {
7242
+ return { availability: "partial", repository: null, commits: [], branches: [], inspectedAt, limit };
7243
+ }
7244
+ }
7209
7245
 
7210
7246
  // src/services/artifact-reader.ts
7211
7247
  import matter from "gray-matter";
@@ -7402,14 +7438,14 @@ function discoverWorkItems(dir) {
7402
7438
 
7403
7439
  // src/core/diff-analysis.ts
7404
7440
  import { minimatch } from "minimatch";
7405
- import path3 from "path";
7441
+ import path4 from "path";
7406
7442
  function toPosix2(p) {
7407
7443
  return p.replace(/\\/g, "/");
7408
7444
  }
7409
7445
  function normalizeTouchedPathForProject(touchedPath, gitRoot, projectRoot) {
7410
7446
  const t = toPosix2(touchedPath).replace(/^\.\//, "").replace(/^\/+/, "");
7411
7447
  if (!gitRoot) return t;
7412
- const prefix = toPosix2(path3.relative(gitRoot, projectRoot)).replace(/^\.\//, "").replace(/\/+$/, "");
7448
+ const prefix = toPosix2(path4.relative(gitRoot, projectRoot)).replace(/^\.\//, "").replace(/\/+$/, "");
7413
7449
  if (prefix === "" || prefix === ".") return t;
7414
7450
  if (prefix.startsWith("..")) return t;
7415
7451
  if (t === prefix) return null;
@@ -7475,10 +7511,10 @@ function analyzeGuard(touchedFiles, artifacts, silentWithoutOwnership) {
7475
7511
  import { parse as parseYaml5, stringify as stringifyYaml4 } from "yaml";
7476
7512
  var IGNORE_FILE = ".kaddo/ignores.yml";
7477
7513
  function loadIgnores(dir) {
7478
- const path16 = join(dir, IGNORE_FILE);
7479
- if (!exists(path16)) return [];
7514
+ const path18 = join(dir, IGNORE_FILE);
7515
+ if (!exists(path18)) return [];
7480
7516
  try {
7481
- const raw = readFile(path16);
7517
+ const raw = readFile(path18);
7482
7518
  const parsed = parseYaml5(raw);
7483
7519
  return Array.isArray(parsed) ? parsed : [];
7484
7520
  } catch {
@@ -7486,7 +7522,7 @@ function loadIgnores(dir) {
7486
7522
  }
7487
7523
  }
7488
7524
  function saveIgnore(dir, entry) {
7489
- const path16 = join(dir, IGNORE_FILE);
7525
+ const path18 = join(dir, IGNORE_FILE);
7490
7526
  const existing = loadIgnores(dir);
7491
7527
  const idx = existing.findIndex((e) => e.artifact_id === entry.artifact_id);
7492
7528
  if (idx >= 0) {
@@ -7494,17 +7530,17 @@ function saveIgnore(dir, entry) {
7494
7530
  } else {
7495
7531
  existing.push(entry);
7496
7532
  }
7497
- writeFile(path16, stringifyYaml4(existing));
7533
+ writeFile(path18, stringifyYaml4(existing));
7498
7534
  }
7499
7535
  function isIgnored(ignores, artifactId) {
7500
7536
  return ignores.find((e) => e.artifact_id === artifactId);
7501
7537
  }
7502
7538
  function removeIgnore(dir, artifactId) {
7503
- const path16 = join(dir, IGNORE_FILE);
7539
+ const path18 = join(dir, IGNORE_FILE);
7504
7540
  const existing = loadIgnores(dir);
7505
7541
  const filtered = existing.filter((e) => e.artifact_id !== artifactId);
7506
7542
  if (filtered.length === existing.length) return false;
7507
- writeFile(path16, stringifyYaml4(filtered));
7543
+ writeFile(path18, stringifyYaml4(filtered));
7508
7544
  return true;
7509
7545
  }
7510
7546
 
@@ -7526,11 +7562,11 @@ function moduleArtifactCoverage(dir, id) {
7526
7562
  };
7527
7563
  }
7528
7564
  function loadMappedModules(dir) {
7529
- const path16 = join(dir, DESCRIPTOR_PATH);
7530
- if (!exists(path16)) return [];
7565
+ const path18 = join(dir, DESCRIPTOR_PATH);
7566
+ if (!exists(path18)) return [];
7531
7567
  let parsed;
7532
7568
  try {
7533
- parsed = parseYaml6(readFile(path16));
7569
+ parsed = parseYaml6(readFile(path18));
7534
7570
  } catch {
7535
7571
  return [];
7536
7572
  }
@@ -7985,7 +8021,7 @@ function analyzeScopeCoverage(artifact, registeredModuleIds, frontendModuleIds)
7985
8021
  }
7986
8022
 
7987
8023
  // src/commands/guard.ts
7988
- import path4 from "path";
8024
+ import path5 from "path";
7989
8025
  import { parse as parseYaml8 } from "yaml";
7990
8026
 
7991
8027
  // src/plugins/prisma.ts
@@ -8274,7 +8310,7 @@ function buildGuardHistory(dir) {
8274
8310
  const d = hotspotDir(t.code_path);
8275
8311
  hotspotMap.set(d, (hotspotMap.get(d) ?? 0) + 1);
8276
8312
  }
8277
- const hotspots = [...hotspotMap.entries()].map(([path16, warnings]) => ({ path: path16, warnings })).sort((a, b) => b.warnings - a.warnings);
8313
+ const hotspots = [...hotspotMap.entries()].map(([path18, warnings]) => ({ path: path18, warnings })).sort((a, b) => b.warnings - a.warnings);
8278
8314
  return {
8279
8315
  available: true,
8280
8316
  total_runs: sorted.length,
@@ -8396,7 +8432,7 @@ function printHeader(touchedFiles) {
8396
8432
  function artifactLabel(artifact, dir) {
8397
8433
  if (artifact.id) return artifact.id;
8398
8434
  if (artifact.title) return artifact.title;
8399
- const rel = path4.relative(dir, artifact.filePath).split(path4.sep).join("/");
8435
+ const rel = path5.relative(dir, artifact.filePath).split(path5.sep).join("/");
8400
8436
  return rel || artifact.filePath;
8401
8437
  }
8402
8438
  function printWorkspaceHeader(scan2) {
@@ -10532,7 +10568,7 @@ function getTemplate(id) {
10532
10568
  }
10533
10569
 
10534
10570
  // src/commands/modules-discover.ts
10535
- import path5 from "path";
10571
+ import path6 from "path";
10536
10572
  import { parse as parseYaml9, stringify as stringifyYaml5 } from "yaml";
10537
10573
  var CONFIG_PATH3 = ".kaddo/config.yml";
10538
10574
  var MODULES_YML = ".kaddo/modules.yml";
@@ -10609,9 +10645,9 @@ function discoverModules(dir) {
10609
10645
  const seenIds = /* @__PURE__ */ new Set();
10610
10646
  const seenPaths = /* @__PURE__ */ new Set();
10611
10647
  const results = [];
10612
- const coreAbsPath = path5.resolve(dir);
10648
+ const coreAbsPath = path6.resolve(dir);
10613
10649
  for (const root of roots) {
10614
- const rootAbs = path5.resolve(dir, root);
10650
+ const rootAbs = path6.resolve(dir, root);
10615
10651
  if (!exists(rootAbs) || !isDir(rootAbs)) continue;
10616
10652
  let entries;
10617
10653
  try {
@@ -10621,10 +10657,10 @@ function discoverModules(dir) {
10621
10657
  }
10622
10658
  for (const entry of entries) {
10623
10659
  if (IGNORED_DIRS.has(entry)) continue;
10624
- const candidateAbs = path5.resolve(rootAbs, entry);
10660
+ const candidateAbs = path6.resolve(rootAbs, entry);
10625
10661
  if (!isDir(candidateAbs)) continue;
10626
10662
  if (candidateAbs === coreAbsPath) continue;
10627
- const relPath = path5.relative(dir, candidateAbs).replace(/\\/g, "/");
10663
+ const relPath = path6.relative(dir, candidateAbs).replace(/\\/g, "/");
10628
10664
  const repoConfig = readRepoConfig(candidateAbs);
10629
10665
  if (!repoConfig) {
10630
10666
  results.push({
@@ -10707,7 +10743,7 @@ function discoverModules(dir) {
10707
10743
  }
10708
10744
  }
10709
10745
  for (const m of existing.modules) {
10710
- const absPath = path5.resolve(dir, m.path);
10746
+ const absPath = path6.resolve(dir, m.path);
10711
10747
  if (!exists(absPath) && !results.some((r) => r.path === m.path)) {
10712
10748
  results.push({
10713
10749
  id: m.id,
@@ -10739,7 +10775,7 @@ function applyDiscovery(dir, discovered) {
10739
10775
  path: d.path,
10740
10776
  parent_system: d.parentSystem,
10741
10777
  status: d.status,
10742
- context: buildModuleContextPaths(path5.resolve(dir, d.path))
10778
+ context: buildModuleContextPaths(path6.resolve(dir, d.path))
10743
10779
  };
10744
10780
  if (existingIdx >= 0) {
10745
10781
  yml.modules[existingIdx] = entry;
@@ -10801,7 +10837,7 @@ function runModulesValidate(dir = cwd()) {
10801
10837
  }
10802
10838
  console.log("");
10803
10839
  for (const m of yml.modules) {
10804
- const absPath = path5.resolve(dir, m.path);
10840
+ const absPath = path6.resolve(dir, m.path);
10805
10841
  if (!exists(absPath)) {
10806
10842
  console.log(`${m.id.padEnd(16)} missing`);
10807
10843
  continue;
@@ -10912,10 +10948,10 @@ function slugify2(name) {
10912
10948
  return name.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
10913
10949
  }
10914
10950
  function readModulesDescriptor(dir) {
10915
- const path16 = join(dir, DESCRIPTOR_PATH2);
10916
- if (!exists(path16)) return { version: 1, modules: [] };
10951
+ const path18 = join(dir, DESCRIPTOR_PATH2);
10952
+ if (!exists(path18)) return { version: 1, modules: [] };
10917
10953
  try {
10918
- const parsed = parseYaml10(readFile(path16));
10954
+ const parsed = parseYaml10(readFile(path18));
10919
10955
  return { version: parsed.version ?? 1, modules: parsed.modules ?? [] };
10920
10956
  } catch {
10921
10957
  return { version: 1, modules: [] };
@@ -11295,7 +11331,7 @@ function sectionParagraph(md, title) {
11295
11331
  }
11296
11332
  return "";
11297
11333
  }
11298
- function parseCapsule(id, path16, md) {
11334
+ function parseCapsule(id, path18, md) {
11299
11335
  const { data } = matter3(md);
11300
11336
  const updatedAt = data.updated_at ? String(data.updated_at) : void 0;
11301
11337
  let ageDays = null;
@@ -11305,7 +11341,7 @@ function parseCapsule(id, path16, md) {
11305
11341
  }
11306
11342
  return {
11307
11343
  id,
11308
- path: path16,
11344
+ path: path18,
11309
11345
  system: data.system ? String(data.system) : id,
11310
11346
  owner: data.owner ? String(data.owner) : void 0,
11311
11347
  updatedAt,
@@ -12287,9 +12323,9 @@ function buildGraph(dir, config, opts = {}, now = /* @__PURE__ */ new Date()) {
12287
12323
  ];
12288
12324
  const presentLayers = [];
12289
12325
  for (const layer2 of layerDocs) {
12290
- const path16 = layer2.files.map((f) => `${KNOWLEDGE3}/${f}`).find((rel) => exists(join(dir, rel)));
12291
- if (path16) {
12292
- addNode({ id: layer2.id, type: layer2.type, label: layer2.label, path: path16 });
12326
+ const path18 = layer2.files.map((f) => `${KNOWLEDGE3}/${f}`).find((rel) => exists(join(dir, rel)));
12327
+ if (path18) {
12328
+ addNode({ id: layer2.id, type: layer2.type, label: layer2.label, path: path18 });
12293
12329
  presentLayers.push(layer2.id);
12294
12330
  }
12295
12331
  }
@@ -13857,11 +13893,11 @@ function redactSecrets(value) {
13857
13893
  return line.replace(/([:=]\s*)\S+.*/, "$1[redacted]");
13858
13894
  }).join("\n");
13859
13895
  }
13860
- function source(dir, path16, kind) {
13861
- const absolute = join(dir, path16);
13896
+ function source(dir, path18, kind) {
13897
+ const absolute = join(dir, path18);
13862
13898
  if (!exists(absolute)) return null;
13863
13899
  const raw = readFile(absolute);
13864
- return { path: posix(path16), kind, digest: sha(raw), content: redactSecrets(raw) };
13900
+ return { path: posix(path18), kind, digest: sha(raw), content: redactSecrets(raw) };
13865
13901
  }
13866
13902
  function reportFiles(dir) {
13867
13903
  const delivery = join(dir, "knowledge", "delivery");
@@ -13901,9 +13937,9 @@ function buildPocReportContext(dir) {
13901
13937
  };
13902
13938
  }
13903
13939
  const sources = [];
13904
- const add = (path16, kind) => {
13905
- if (sources.some((item2) => item2.path === posix(path16))) return;
13906
- const item = source(dir, path16, kind);
13940
+ const add = (path18, kind) => {
13941
+ if (sources.some((item2) => item2.path === posix(path18))) return;
13942
+ const item = source(dir, path18, kind);
13907
13943
  if (item) sources.push(item);
13908
13944
  };
13909
13945
  add(POC_ARTIFACT_PATH, "poc");
@@ -13931,7 +13967,7 @@ function buildPocReportContext(dir) {
13931
13967
  const sourceFingerprint = sha(sources.map((item) => `${item.path}\0${item.digest}`).join("\n"));
13932
13968
  const status = !latestReport ? "missing" : latestReport.sourceFingerprint === sourceFingerprint ? "current" : "stale";
13933
13969
  const currentManifest = Object.fromEntries(sources.map((item) => [item.path, item.digest]));
13934
- const changesSinceLatest = status === "stale" ? [.../* @__PURE__ */ new Set([...Object.keys(currentManifest), ...Object.keys(latestReport?.sourceManifest ?? {})])].filter((path16) => currentManifest[path16] !== latestReport?.sourceManifest[path16]).sort() : [];
13970
+ const changesSinceLatest = status === "stale" ? [.../* @__PURE__ */ new Set([...Object.keys(currentManifest), ...Object.keys(latestReport?.sourceManifest ?? {})])].filter((path18) => currentManifest[path18] !== latestReport?.sourceManifest[path18]).sort() : [];
13935
13971
  const sourceList = sources.map((item) => `- ${item.path} (${item.kind})`).join("\n") || "- No sources selected.";
13936
13972
  return {
13937
13973
  eligible: true,
@@ -14082,10 +14118,10 @@ function resolveNextStep(dir, now = /* @__PURE__ */ new Date()) {
14082
14118
  const q = (rel) => analyzeKnowledgeArtifact(dir, rel);
14083
14119
  const resolveAgent = (agent) => {
14084
14120
  const file = agent.endsWith(".md") ? agent : `${agent}.md`;
14085
- const path16 = agentInstallPath(file);
14086
- const installed = isFile(join(dir, path16));
14121
+ const path18 = agentInstallPath(file);
14122
+ const installed = isFile(join(dir, path18));
14087
14123
  const group = agentGroupOf(file);
14088
- return { agentPath: path16, agentInstalled: installed, installCommand: installed ? void 0 : `kaddo add agents --group ${group}` };
14124
+ return { agentPath: path18, agentInstalled: installed, installCommand: installed ? void 0 : `kaddo add agents --group ${group}` };
14089
14125
  };
14090
14126
  const moduleRepo = isModule(config);
14091
14127
  const coreRepo = isCore(config);
@@ -17638,7 +17674,7 @@ function runUnderstand() {
17638
17674
  }
17639
17675
 
17640
17676
  // src/core/classifier.ts
17641
- import path6 from "path";
17677
+ import path7 from "path";
17642
17678
  var MIGRATION_PATTERNS = [
17643
17679
  /supabase\/migrations\//,
17644
17680
  /prisma\/migrations\//,
@@ -17677,7 +17713,7 @@ var DEP_PATTERNS = [
17677
17713
  /^pom\.xml$/
17678
17714
  ];
17679
17715
  function normalizePath2(p) {
17680
- return p.split(path6.sep).join("/");
17716
+ return p.split(path7.sep).join("/");
17681
17717
  }
17682
17718
  function matchesAny2(file, patterns) {
17683
17719
  const normalized = normalizePath2(file);
@@ -17920,7 +17956,7 @@ function runStatus() {
17920
17956
 
17921
17957
  // src/commands/learn.ts
17922
17958
  import fs3 from "fs";
17923
- import path7 from "path";
17959
+ import path8 from "path";
17924
17960
  import matter13 from "gray-matter";
17925
17961
  var ARCH_DIR9 = "knowledge";
17926
17962
  var WORK_ITEMS_DIR2 = "knowledge/delivery/work-items";
@@ -17928,11 +17964,11 @@ function completedPathFor(filePath) {
17928
17964
  const posix2 = filePath.replace(/\\/g, "/");
17929
17965
  const m = posix2.match(/\/work-items\/(draft|ready|in-progress|blocked)\//);
17930
17966
  if (!m) return filePath;
17931
- const completedDir = path7.dirname(filePath).replace(
17967
+ const completedDir = path8.dirname(filePath).replace(
17932
17968
  new RegExp(`[/\\\\]${m[1]}$`),
17933
- path7.sep + "completed"
17969
+ path8.sep + "completed"
17934
17970
  );
17935
- return path7.join(completedDir, path7.basename(filePath));
17971
+ return path8.join(completedDir, path8.basename(filePath));
17936
17972
  }
17937
17973
  function updateWorkItemFile(filePath, learning) {
17938
17974
  const raw = readFile(filePath);
@@ -17964,7 +18000,7 @@ ${learning.trim()}
17964
18000
  const newRaw = matter13.stringify(updatedContent, data);
17965
18001
  const newPath = completedPathFor(filePath);
17966
18002
  if (newPath !== filePath) {
17967
- ensureDir(path7.dirname(newPath));
18003
+ ensureDir(path8.dirname(newPath));
17968
18004
  writeFile(newPath, newRaw);
17969
18005
  fs3.unlinkSync(filePath);
17970
18006
  } else {
@@ -18058,7 +18094,7 @@ async function runLearn(artifactId, opts = {}) {
18058
18094
  }
18059
18095
  const finalPath = updateWorkItemFile(filePath, enrichedLearning);
18060
18096
  log.success(`${targetId} marked as completed`);
18061
- log.success(`Learning recorded in ${finalPath.replace(dir + path7.sep, "").replace(/\\/g, "/")}`);
18097
+ log.success(`Learning recorded in ${finalPath.replace(dir + path8.sep, "").replace(/\\/g, "/")}`);
18062
18098
  if (hasExceptions) {
18063
18099
  log.warn("Learning captured from a Work Item completed with validation exceptions.");
18064
18100
  }
@@ -19364,7 +19400,7 @@ function runGraphExport(opts = {}) {
19364
19400
  // src/core/system-topology.ts
19365
19401
  import { parse as parseYaml17, stringify as stringifyYaml9 } from "yaml";
19366
19402
  import fs4 from "fs";
19367
- import path8 from "path";
19403
+ import path9 from "path";
19368
19404
  import crypto from "crypto";
19369
19405
  var TOPOLOGY_FILE = "knowledge/tech/system-topology.yml";
19370
19406
  var SYSTEM_ENTITY_KINDS = /* @__PURE__ */ new Set([
@@ -19530,7 +19566,7 @@ function serializeTopology(entities, relationships) {
19530
19566
  return stringifyYaml9(doc);
19531
19567
  }
19532
19568
  function atomicWrite(filePath, content) {
19533
- fs4.mkdirSync(path8.dirname(filePath), { recursive: true });
19569
+ fs4.mkdirSync(path9.dirname(filePath), { recursive: true });
19534
19570
  const tmp = `${filePath}.${process.pid}.${Date.now()}.tmp`;
19535
19571
  fs4.writeFileSync(tmp, content, "utf-8");
19536
19572
  try {
@@ -19644,7 +19680,7 @@ async function runTopologyApply(file, opts = {}) {
19644
19680
 
19645
19681
  // src/core/resource-write.ts
19646
19682
  import fs5 from "fs";
19647
- import path9 from "path";
19683
+ import path10 from "path";
19648
19684
  import matter15 from "gray-matter";
19649
19685
  var RESOURCES_DIR = "knowledge/tech/resources";
19650
19686
  var ResourceWriteError = class extends Error {
@@ -19783,7 +19819,7 @@ ${(input.purpose ?? "").trim() || "TODO: describe what this resource is for."}`;
19783
19819
  const relPath = `${RESOURCES_DIR}/${slug4(title) || slug4(id)}.md`;
19784
19820
  const filePath = join(dir, relPath);
19785
19821
  if (exists(filePath)) throw new ResourceWriteError("DUPLICATE", `Resource file already exists: ${relPath}`);
19786
- ensureDir(path9.dirname(filePath));
19822
+ ensureDir(path10.dirname(filePath));
19787
19823
  atomicWrite2(filePath, serialize(data, body));
19788
19824
  return { id, path: relPath, findings };
19789
19825
  }
@@ -20269,7 +20305,7 @@ var CANDIDATE_DISCOVERY_GUIDANCE = [
20269
20305
 
20270
20306
  // src/core/deprecation-write.ts
20271
20307
  import fs6 from "fs";
20272
- import path10 from "path";
20308
+ import path11 from "path";
20273
20309
  import matter16 from "gray-matter";
20274
20310
  var DeprecationWriteError = class extends Error {
20275
20311
  constructor(code, message) {
@@ -20385,7 +20421,7 @@ ${(input.purpose ?? "").trim() || "TODO: describe what this plan retires and why
20385
20421
  const relPath = `${DEPRECATION_PLANS_DIR}/${id}-${slug5(title) || "plan"}.md`;
20386
20422
  const filePath = join(dir, relPath);
20387
20423
  if (exists(filePath)) throw new DeprecationWriteError("DUPLICATE", `Plan file already exists: ${relPath}`);
20388
- ensureDir(path10.dirname(filePath));
20424
+ ensureDir(path11.dirname(filePath));
20389
20425
  atomicWrite3(filePath, serialize2(data, body));
20390
20426
  return { id, path: relPath, findings: [] };
20391
20427
  }
@@ -20404,7 +20440,7 @@ function addTarget(dir, planId, input) {
20404
20440
  }
20405
20441
  data.targets = [...targets, raw];
20406
20442
  atomicWrite3(filePath, serialize2(data, body));
20407
- return { planId, targetId, path: `${DEPRECATION_PLANS_DIR}/${path10.basename(filePath)}`, findings };
20443
+ return { planId, targetId, path: `${DEPRECATION_PLANS_DIR}/${path11.basename(filePath)}`, findings };
20408
20444
  }
20409
20445
  function updateTarget(dir, planId, targetId, patch) {
20410
20446
  const { filePath, data, body } = loadPlanRaw(dir, planId);
@@ -20420,7 +20456,7 @@ function updateTarget(dir, planId, targetId, patch) {
20420
20456
  next[idx] = merged;
20421
20457
  data.targets = next;
20422
20458
  atomicWrite3(filePath, serialize2(data, body));
20423
- return { planId, targetId: String(targets[idx].id), path: `${DEPRECATION_PLANS_DIR}/${path10.basename(filePath)}`, findings };
20459
+ return { planId, targetId: String(targets[idx].id), path: `${DEPRECATION_PLANS_DIR}/${path11.basename(filePath)}`, findings };
20424
20460
  }
20425
20461
  function removeTarget(dir, planId, targetId, opts = {}) {
20426
20462
  const { filePath, data, body } = loadPlanRaw(dir, planId);
@@ -20433,7 +20469,7 @@ function removeTarget(dir, planId, targetId, opts = {}) {
20433
20469
  }
20434
20470
  data.targets = targets.filter((t) => String(t.id ?? "").toUpperCase() !== targetId.toUpperCase());
20435
20471
  atomicWrite3(filePath, serialize2(data, body));
20436
- return { removed: true, path: `${DEPRECATION_PLANS_DIR}/${path10.basename(filePath)}` };
20472
+ return { removed: true, path: `${DEPRECATION_PLANS_DIR}/${path11.basename(filePath)}` };
20437
20473
  }
20438
20474
 
20439
20475
  // src/core/deprecation-runbook.ts
@@ -20516,7 +20552,7 @@ function buildProductionRunbookContext(dir, planId, targetId) {
20516
20552
  blockers.push(`Dependency ${dependency.id} is not retired (current: ${dependency.lifecycle}).`);
20517
20553
  }
20518
20554
  }
20519
- const path16 = runbookPath(dir, target);
20555
+ const path18 = runbookPath(dir, target);
20520
20556
  return {
20521
20557
  eligible: blockers.length === 0,
20522
20558
  plan: { id: plan.id, title: plan.title, purpose: plan.purpose },
@@ -20524,7 +20560,7 @@ function buildProductionRunbookContext(dir, planId, targetId) {
20524
20560
  resource: target.resource ? getResource(dir, target.resource) : null,
20525
20561
  dependencies,
20526
20562
  blockers,
20527
- nextPath: path16,
20563
+ nextPath: path18,
20528
20564
  nextStep: blockers.length > 0 ? "Resolve the listed safeguards; no production proposal can be persisted yet." : "Review the generated proposal, obtain human approval, execute manually, then record evidence and validate the observation window."
20529
20565
  };
20530
20566
  }
@@ -20617,8 +20653,8 @@ function renderRunbook(context) {
20617
20653
  function createProductionRunbook(dir, planId, targetId) {
20618
20654
  const context = buildProductionRunbookContext(dir, planId, targetId);
20619
20655
  if (!context.eligible) throw new ProductionRunbookError(context.blockers.join(" "));
20620
- const path16 = context.nextPath;
20621
- const id = path16.split("/").pop()?.match(/^(RB-\d+)-/)?.[1] ?? "";
20656
+ const path18 = context.nextPath;
20657
+ const id = path18.split("/").pop()?.match(/^(RB-\d+)-/)?.[1] ?? "";
20622
20658
  const content = matter17.stringify(renderRunbook(context), {
20623
20659
  id,
20624
20660
  type: PRODUCTION_RUNBOOK_ARTIFACT_TYPE,
@@ -20628,13 +20664,13 @@ function createProductionRunbook(dir, planId, targetId) {
20628
20664
  resource: context.target.resource,
20629
20665
  approval: { required: true, status: "pending", approved_by: null, approved_at: null }
20630
20666
  });
20631
- const absolute = join(dir, path16);
20632
- if (exists(absolute)) throw new ProductionRunbookError(`Runbook already exists: ${path16}`);
20667
+ const absolute = join(dir, path18);
20668
+ if (exists(absolute)) throw new ProductionRunbookError(`Runbook already exists: ${path18}`);
20633
20669
  writeFile(absolute, content);
20634
20670
  return {
20635
20671
  id,
20636
20672
  title: `Production runbook \u2014 ${context.target.title ?? context.target.id}`,
20637
- path: path16,
20673
+ path: path18,
20638
20674
  planId: context.plan.id,
20639
20675
  targetId: context.target.id,
20640
20676
  approval: { required: true, status: "pending", approvedBy: null, approvedAt: null },
@@ -20645,14 +20681,14 @@ function getProductionRunbook(dir, id) {
20645
20681
  const root = join(dir, PRODUCTION_RUNBOOKS_DIR);
20646
20682
  for (const name of readDir(root)) {
20647
20683
  if (!name.toLowerCase().startsWith(`${id.toLowerCase()}-`) || !name.endsWith(".md")) continue;
20648
- const path16 = `${PRODUCTION_RUNBOOKS_DIR}/${name}`;
20649
- const parsed = matter17(readFile(join(dir, path16)));
20684
+ const path18 = `${PRODUCTION_RUNBOOKS_DIR}/${name}`;
20685
+ const parsed = matter17(readFile(join(dir, path18)));
20650
20686
  const data = parsed.data;
20651
20687
  if (data.type !== PRODUCTION_RUNBOOK_ARTIFACT_TYPE) continue;
20652
20688
  return {
20653
20689
  id: stringValue(data.id) ?? id,
20654
20690
  title: stringValue(data.title) ?? id,
20655
- path: path16,
20691
+ path: path18,
20656
20692
  planId: stringValue(data.deprecation_plan) ?? "",
20657
20693
  targetId: stringValue(data.deprecation_target) ?? "",
20658
20694
  approval: parseApproval(data.approval),
@@ -20991,7 +21027,7 @@ ${runbook.id} \u2014 ${payload.valid ? "valid" : "invalid"}`);
20991
21027
 
20992
21028
  // src/core/okf/export.ts
20993
21029
  import fs7 from "fs";
20994
- import path11 from "path";
21030
+ import path12 from "path";
20995
21031
 
20996
21032
  // src/core/okf/mapping.ts
20997
21033
  import matter18 from "gray-matter";
@@ -22387,16 +22423,16 @@ function frontmatter(data) {
22387
22423
  return lines.join("\n");
22388
22424
  }
22389
22425
  function relLink(fromPath, toPath) {
22390
- const rel = path11.posix.relative(path11.posix.dirname(fromPath), toPath);
22426
+ const rel = path12.posix.relative(path12.posix.dirname(fromPath), toPath);
22391
22427
  return rel.startsWith(".") ? rel : `./${rel}`;
22392
22428
  }
22393
22429
  function rewriteBodyLinks(body, sourcePath, srcToBundle, selfBundlePath) {
22394
- const srcDir = path11.posix.dirname(sourcePath);
22430
+ const srcDir = path12.posix.dirname(sourcePath);
22395
22431
  return body.replace(/\]\(([^)]+)\)/g, (whole, href) => {
22396
22432
  const raw = href.trim();
22397
22433
  const bare = raw.split("#")[0].split(" ")[0];
22398
22434
  if (!bare || /^(https?:|mailto:|#)/.test(bare)) return whole;
22399
- const candidate = bare.startsWith("/") ? bare.replace(/^\/+/, "") : path11.posix.normalize(path11.posix.join(srcDir, bare));
22435
+ const candidate = bare.startsWith("/") ? bare.replace(/^\/+/, "") : path12.posix.normalize(path12.posix.join(srcDir, bare));
22400
22436
  const target = srcToBundle.get(candidate);
22401
22437
  if (!target) return whole;
22402
22438
  const anchor = raw.includes("#") ? "#" + raw.split("#").slice(1).join("#") : "";
@@ -22473,22 +22509,22 @@ function sensitiveLabels(content) {
22473
22509
  return [...new Set(SENSITIVE_PATTERNS.filter((p) => p.re.test(content)).map((p) => p.label))];
22474
22510
  }
22475
22511
  function assertSafeDestination(dir, outputDir) {
22476
- const root = path11.resolve(dir);
22477
- const out = path11.resolve(outputDir);
22512
+ const root = path12.resolve(dir);
22513
+ const out = path12.resolve(outputDir);
22478
22514
  const within = (child, parent) => {
22479
- const rel = path11.relative(parent, child);
22480
- return rel === "" || !rel.startsWith("..") && !path11.isAbsolute(rel);
22515
+ const rel = path12.relative(parent, child);
22516
+ return rel === "" || !rel.startsWith("..") && !path12.isAbsolute(rel);
22481
22517
  };
22482
22518
  if (out === root) throw new OkfExportError("UNSAFE_DESTINATION", "Refusing to export onto the project root.");
22483
22519
  if (within(root, out)) throw new OkfExportError("UNSAFE_DESTINATION", "Refusing to export onto a parent of the project.");
22484
22520
  for (const protectedDir of ["knowledge", "packages", "apps", "src", "node_modules", ".git"]) {
22485
- const p = path11.join(root, protectedDir);
22521
+ const p = path12.join(root, protectedDir);
22486
22522
  if (out === p || within(out, p)) throw new OkfExportError("UNSAFE_DESTINATION", `Refusing to export into a protected directory: ${protectedDir}/`);
22487
22523
  }
22488
22524
  if (fs7.existsSync(out)) {
22489
22525
  try {
22490
22526
  const entries = fs7.readdirSync(out);
22491
- const looksOkf = entries.includes("index.md") && /okf_version/.test(fs7.readFileSync(path11.join(out, "index.md"), "utf-8"));
22527
+ const looksOkf = entries.includes("index.md") && /okf_version/.test(fs7.readFileSync(path12.join(out, "index.md"), "utf-8"));
22492
22528
  if (entries.length > 0 && !looksOkf) {
22493
22529
  throw new OkfExportError("UNSAFE_DESTINATION", `Destination is not empty and is not an OKF bundle: ${outputDir}. Use an empty or dedicated directory.`);
22494
22530
  }
@@ -22513,7 +22549,7 @@ function detectCollisions(concepts) {
22513
22549
  }
22514
22550
  function exportOkf(dir, opts = {}) {
22515
22551
  const outRel = opts.output ?? OKF_DEFAULT_OUTPUT;
22516
- const outputDir = path11.isAbsolute(outRel) ? outRel : path11.join(dir, outRel);
22552
+ const outputDir = path12.isAbsolute(outRel) ? outRel : path12.join(dir, outRel);
22517
22553
  assertSafeDestination(dir, outputDir);
22518
22554
  const extraWarnings = [];
22519
22555
  const artifacts = discoverKnowledge(dir);
@@ -22569,7 +22605,7 @@ ${c.body ?? ""}`;
22569
22605
  const dirs = /* @__PURE__ */ new Map();
22570
22606
  const childDirs = /* @__PURE__ */ new Map();
22571
22607
  for (const c of concepts) {
22572
- const d = path11.posix.dirname(c.path);
22608
+ const d = path12.posix.dirname(c.path);
22573
22609
  (dirs.get(d) ?? dirs.set(d, []).get(d)).push(c);
22574
22610
  const segs = d === "." ? [] : d.split("/");
22575
22611
  for (let i = 0; i < segs.length; i++) {
@@ -22595,8 +22631,8 @@ ${c.body ?? ""}`;
22595
22631
  try {
22596
22632
  fs7.rmSync(staging, { recursive: true, force: true });
22597
22633
  for (const [rel, content] of files) {
22598
- const full = path11.join(staging, rel);
22599
- fs7.mkdirSync(path11.dirname(full), { recursive: true });
22634
+ const full = path12.join(staging, rel);
22635
+ fs7.mkdirSync(path12.dirname(full), { recursive: true });
22600
22636
  fs7.writeFileSync(full, content, "utf-8");
22601
22637
  }
22602
22638
  const backup = `${outputDir}.old-${process.pid}-${Date.now()}`;
@@ -22625,13 +22661,13 @@ ${c.body ?? ""}`;
22625
22661
 
22626
22662
  // src/core/okf/validate.ts
22627
22663
  import fs8 from "fs";
22628
- import path12 from "path";
22664
+ import path13 from "path";
22629
22665
  import matter20 from "gray-matter";
22630
22666
  function walk(root) {
22631
22667
  const out = [];
22632
22668
  const rec = (d) => {
22633
22669
  for (const entry of fs8.readdirSync(d)) {
22634
- const full = path12.join(d, entry);
22670
+ const full = path13.join(d, entry);
22635
22671
  const st = fs8.statSync(full);
22636
22672
  if (st.isDirectory()) rec(full);
22637
22673
  else if (entry.endsWith(".md")) out.push(full);
@@ -22653,24 +22689,24 @@ function internalLinks(body) {
22653
22689
  }
22654
22690
  function validateOkf(dir, opts = {}) {
22655
22691
  const loc = opts.location ?? OKF_DEFAULT_OUTPUT;
22656
- const bundleDir = path12.isAbsolute(loc) ? loc : path12.join(dir, loc);
22692
+ const bundleDir = path13.isAbsolute(loc) ? loc : path13.join(dir, loc);
22657
22693
  const findings = [];
22658
22694
  if (!fs8.existsSync(bundleDir)) {
22659
22695
  findings.push({ level: "conformance", message: `OKF bundle directory not found: ${loc}. Run \`kaddo okf export\` first.` });
22660
22696
  return { dir: bundleDir, conformant: false, conceptCount: 0, findings, counts: { conformance: 1, warning: 0, info: 0 } };
22661
22697
  }
22662
22698
  const files = walk(bundleDir);
22663
- const rel = (f) => path12.relative(bundleDir, f).split(path12.sep).join("/");
22699
+ const rel = (f) => path13.relative(bundleDir, f).split(path13.sep).join("/");
22664
22700
  const present = new Set(files.map(rel));
22665
22701
  const idToFile = /* @__PURE__ */ new Map();
22666
22702
  let conceptCount = 0;
22667
- const rootIndex = path12.join(bundleDir, "index.md");
22703
+ const rootIndex = path13.join(bundleDir, "index.md");
22668
22704
  if (!fs8.existsSync(rootIndex)) {
22669
22705
  findings.push({ level: "warning", message: "No root index.md \u2014 the bundle has no top-level navigation entry." });
22670
22706
  }
22671
22707
  for (const file of files) {
22672
22708
  const r = rel(file);
22673
- const isIndex = path12.basename(file) === "index.md";
22709
+ const isIndex = path13.basename(file) === "index.md";
22674
22710
  let data = {};
22675
22711
  try {
22676
22712
  data = matter20(fs8.readFileSync(file, "utf-8")).data ?? {};
@@ -22701,7 +22737,7 @@ function validateOkf(dir, opts = {}) {
22701
22737
  }
22702
22738
  })();
22703
22739
  for (const href of internalLinks(body)) {
22704
- const resolved = path12.posix.normalize(path12.posix.join(path12.posix.dirname(r), href));
22740
+ const resolved = path13.posix.normalize(path13.posix.join(path13.posix.dirname(r), href));
22705
22741
  if (!present.has(resolved)) findings.push({ level: "info", file: r, message: `Internal link not resolvable yet: ${href}` });
22706
22742
  }
22707
22743
  }
@@ -22771,7 +22807,7 @@ import { parse as parseYaml19, stringify as stringifyYaml10 } from "yaml";
22771
22807
 
22772
22808
  // src/core/work-item-write.ts
22773
22809
  import fs9 from "fs";
22774
- import path13 from "path";
22810
+ import path14 from "path";
22775
22811
  import crypto2 from "crypto";
22776
22812
  import matter21 from "gray-matter";
22777
22813
  var WORK_ITEMS_DIR3 = "knowledge/delivery/work-items";
@@ -22783,6 +22819,7 @@ var WorkItemWriteError = class extends Error {
22783
22819
  }
22784
22820
  code;
22785
22821
  };
22822
+ var EDITABLE_STATES = ["draft"];
22786
22823
  function revisionOf(raw) {
22787
22824
  return crypto2.createHash("sha256").update(raw, "utf-8").digest("hex");
22788
22825
  }
@@ -22808,7 +22845,7 @@ function nextWorkItemId2(dir) {
22808
22845
  return `WI-${String(max + 1).padStart(3, "0")}`;
22809
22846
  }
22810
22847
  function atomicWrite4(filePath, content) {
22811
- fs9.mkdirSync(path13.dirname(filePath), { recursive: true });
22848
+ fs9.mkdirSync(path14.dirname(filePath), { recursive: true });
22812
22849
  const tmp = `${filePath}.${process.pid}.${Date.now()}.tmp`;
22813
22850
  fs9.writeFileSync(tmp, content, "utf-8");
22814
22851
  try {
@@ -22821,6 +22858,16 @@ function atomicWrite4(filePath, content) {
22821
22858
  throw err;
22822
22859
  }
22823
22860
  }
22861
+ function findArtifact(dir, id) {
22862
+ const match = discoverWorkItems(dir).find((a) => (a.id || a.title) === id);
22863
+ if (!match) throw new WorkItemWriteError("WORK_ITEM_NOT_FOUND", `Work Item "${id}" was not found.`);
22864
+ return { filePath: match.filePath, relPath: match.relPath };
22865
+ }
22866
+ function validModuleIds(dir) {
22867
+ const ids = /* @__PURE__ */ new Set(["core"]);
22868
+ for (const m of loadMappedModules(dir)) ids.add(m.id);
22869
+ return ids;
22870
+ }
22824
22871
  var SECTION_ORDER = [
22825
22872
  "Actor",
22826
22873
  "Outcome",
@@ -22832,6 +22879,35 @@ var SECTION_ORDER = [
22832
22879
  "Acceptance criteria"
22833
22880
  ];
22834
22881
  var KNOWN_HEADINGS = new Set(SECTION_ORDER.map((s) => s.toLowerCase()));
22882
+ function parseBody(content) {
22883
+ const lines = content.split(/\r?\n/);
22884
+ const preamble = [];
22885
+ const sections = [];
22886
+ let current = null;
22887
+ let buffer = [];
22888
+ let seenHeading = false;
22889
+ const flush2 = () => {
22890
+ if (current) {
22891
+ current.body = buffer.join("\n").trim();
22892
+ sections.push(current);
22893
+ }
22894
+ buffer = [];
22895
+ };
22896
+ for (const line of lines) {
22897
+ const m = line.match(/^##\s+(.*?)\s*$/);
22898
+ if (m) {
22899
+ seenHeading = true;
22900
+ flush2();
22901
+ current = { heading: m[1].trim(), normalized: m[1].trim().toLowerCase(), body: "" };
22902
+ } else if (!seenHeading) {
22903
+ preamble.push(line);
22904
+ } else {
22905
+ buffer.push(line);
22906
+ }
22907
+ }
22908
+ flush2();
22909
+ return { preamble, sections };
22910
+ }
22835
22911
  function renderList(items) {
22836
22912
  return items.map((i) => `- ${i.trim()}`).filter((l) => l.trim() !== "-").join("\n");
22837
22913
  }
@@ -22881,6 +22957,77 @@ function serialize3(data, body) {
22881
22957
  ${body.trim()}
22882
22958
  `, data);
22883
22959
  }
22960
+ function toInput(data, content) {
22961
+ const { sections } = parseBody(content);
22962
+ const sec = (name) => {
22963
+ const s = sections.find((x) => x.normalized === name);
22964
+ return s && s.body.trim() ? s.body.trim() : void 0;
22965
+ };
22966
+ const bullets = (name) => {
22967
+ const body = sec(name);
22968
+ if (!body) return [];
22969
+ return body.split(/\r?\n/).map((l) => l.replace(/^\s*[-*+]\s+(\[[ xX]\]\s*)?/, "").trim()).filter(Boolean);
22970
+ };
22971
+ const criteria = (() => {
22972
+ const body = sec("acceptance criteria");
22973
+ if (!body) return [];
22974
+ const out = [];
22975
+ for (const line of body.split(/\r?\n/)) {
22976
+ const m = line.match(/^\s*[-*+]\s+(.*)$/);
22977
+ if (!m) continue;
22978
+ let text2 = m[1].trim();
22979
+ let checked = null;
22980
+ const cb = text2.match(/^\[([ xX])\]\s*(.*)$/);
22981
+ if (cb) {
22982
+ checked = cb[1].toLowerCase() === "x";
22983
+ text2 = cb[2].trim();
22984
+ }
22985
+ if (text2) out.push({ text: text2, checked });
22986
+ }
22987
+ return out;
22988
+ })();
22989
+ const sc = data.scope_confidence;
22990
+ const mc = data.module_coverage;
22991
+ const ia = data.impact_analysis?.surfaces;
22992
+ return {
22993
+ title: String(data.title ?? ""),
22994
+ type: String(data.type ?? "feature"),
22995
+ summary: data.summary ? String(data.summary) : void 0,
22996
+ actor: sec("actor"),
22997
+ outcome: sec("outcome"),
22998
+ currentBehavior: sec("current behavior"),
22999
+ targetBehavior: sec("target behavior"),
23000
+ entryPoints: sec("entry points"),
23001
+ endToEndFlow: sec("end-to-end flow"),
23002
+ scopeConfidence: sc && sc.level ? { level: String(sc.level), reasons: Array.isArray(sc.reasons) ? sc.reasons.map(String) : [] } : null,
23003
+ scopeUnknowns: bullets("scope unknowns"),
23004
+ affectedModules: Array.isArray(data.affected_modules) ? data.affected_modules.map(String) : [],
23005
+ moduleCoverage: mc ? Object.entries(mc).map(([id, v]) => ({ id, status: String(v.status ?? ""), ...v.reason ? { reason: String(v.reason) } : {} })) : [],
23006
+ impactAnalysis: ia ? Object.entries(ia).map(([surface, v]) => ({ surface, status: String(v.status ?? ""), ...v.reason ? { reason: String(v.reason) } : {}, ...v.question ? { question: String(v.question) } : {} })) : [],
23007
+ acceptanceCriteria: criteria,
23008
+ decisions: Array.isArray(data.decisions) ? data.decisions.map(String) : [],
23009
+ relatedKnowledge: Array.isArray(data.related_knowledge) ? data.related_knowledge.map(String) : [],
23010
+ owners: Array.isArray(data.owners) ? data.owners.map(String) : [],
23011
+ contributors: Array.isArray(data.contributors) ? data.contributors.map(String) : []
23012
+ };
23013
+ }
23014
+ function getWorkItemForEdit(dir, id) {
23015
+ const { filePath, relPath } = findArtifact(dir, id);
23016
+ const raw = readFile(filePath);
23017
+ const { data, content } = matter21(raw);
23018
+ const status = lifecycleStateOf({ status: String(data.status ?? ""), filePath });
23019
+ const input = toInput(data, content);
23020
+ const editable = EDITABLE_STATES.includes(status);
23021
+ return {
23022
+ ...input,
23023
+ id,
23024
+ status,
23025
+ revision: revisionOf(raw),
23026
+ path: relPath,
23027
+ editable,
23028
+ ...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.` }
23029
+ };
23030
+ }
22884
23031
  var CAPTURE_SECTIONS = [
22885
23032
  { field: "problem", heading: "Problem" },
22886
23033
  { field: "expected_result", heading: "Expected result" },
@@ -22949,6 +23096,85 @@ function createWorkItem(dir, opts) {
22949
23096
  atomicWrite4(filePath, raw);
22950
23097
  return { id, path: relPath, revision: revisionOf(raw) };
22951
23098
  }
23099
+ function validateWorkItem(dir, id) {
23100
+ const { filePath } = findArtifact(dir, id);
23101
+ const raw = readFile(filePath);
23102
+ const { data, content } = matter21(raw);
23103
+ const input = toInput(data, content);
23104
+ const findings = [];
23105
+ const modules = validModuleIds(dir);
23106
+ for (const c of input.moduleCoverage) {
23107
+ if (c.status === "affected" && !input.affectedModules.includes(c.id)) {
23108
+ findings.push({ level: "blocking", message: `${c.id} is marked affected in module coverage but is missing from affected_modules.` });
23109
+ }
23110
+ }
23111
+ for (const m of input.affectedModules) {
23112
+ if (!modules.has(m)) findings.push({ level: "blocking", message: `Module "${m}" is not registered in this project.` });
23113
+ }
23114
+ if (!input.targetBehavior?.trim()) findings.push({ level: "warning", message: "Target behavior is not defined." });
23115
+ if (input.acceptanceCriteria.length === 0) findings.push({ level: "warning", message: "No acceptance criteria have been defined." });
23116
+ if (input.scopeConfidence?.level === "low") findings.push({ level: "warning", message: "Scope confidence is Low." });
23117
+ if (!input.scopeConfidence) findings.push({ level: "warning", message: "Scope confidence has not been assessed." });
23118
+ for (const c of input.moduleCoverage) {
23119
+ if (c.status === "reviewed-not-affected") findings.push({ level: "fyi", message: `${c.id} was reviewed and is not affected.` });
23120
+ }
23121
+ for (const s of input.impactAnalysis) {
23122
+ if (s.status === "unknown") findings.push({ level: "fyi", message: `Impact on ${s.surface} is unknown.` });
23123
+ }
23124
+ const topology = loadSystemTopology(dir);
23125
+ const entityById = new Map(topology.entities.map((e) => [e.id, e]));
23126
+ const fm2 = data;
23127
+ 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) : [];
23129
+ for (const eid of affectedEntities) {
23130
+ const e = entityById.get(eid);
23131
+ if (!e) {
23132
+ findings.push({ level: "blocking", message: `Affected system entity "${eid}" does not exist in the semantic topology.` });
23133
+ continue;
23134
+ }
23135
+ if (e.moduleId && !input.affectedModules.includes(e.moduleId)) {
23136
+ findings.push({ level: "warning", message: `System entity "${e.label}" belongs to module "${e.moduleId}", which is not in affected_modules.` });
23137
+ }
23138
+ }
23139
+ if (Array.isArray(fm2.reviewed_system_entities)) {
23140
+ for (const r of fm2.reviewed_system_entities) {
23141
+ const rid = r && typeof r === "object" ? String(r.id ?? "") : "";
23142
+ if (rid && !entityById.has(rid)) findings.push({ level: "warning", message: `Reviewed system entity "${rid}" does not exist in the semantic topology.` });
23143
+ }
23144
+ }
23145
+ const canMarkReady = !findings.some((f) => f.level === "blocking");
23146
+ return { findings, canMarkReady };
23147
+ }
23148
+ var ALLOWED = { draft: ["ready"], ready: ["draft", "in-progress"] };
23149
+ function transitionWorkItem(dir, id, to, expectedRevision) {
23150
+ const { filePath } = findArtifact(dir, id);
23151
+ const raw = readFile(filePath);
23152
+ if (revisionOf(raw) !== expectedRevision) {
23153
+ throw new WorkItemWriteError("WORK_ITEM_CONFLICT", "This Work Item changed outside Kaddo Admin. Reload the latest version before continuing.");
23154
+ }
23155
+ const { data, content } = matter21(raw);
23156
+ const from = lifecycleStateOf({ status: String(data.status ?? ""), filePath });
23157
+ if (!(ALLOWED[from] ?? []).includes(to)) {
23158
+ throw new WorkItemWriteError("INVALID_TRANSITION", `Cannot transition a ${from} Work Item to ${to}.`);
23159
+ }
23160
+ if (to === "ready") {
23161
+ const { canMarkReady } = validateWorkItem(dir, id);
23162
+ if (!canMarkReady) throw new WorkItemWriteError("INVALID_TRANSITION", "This Work Item has blocking issues and cannot be marked Ready.");
23163
+ }
23164
+ const nextData = { ...data, status: to };
23165
+ const nextRaw = serialize3(nextData, content);
23166
+ const filename = path14.basename(filePath);
23167
+ const targetRel = `${WORK_ITEMS_DIR3}/${to}/${filename}`;
23168
+ const targetPath = join(dir, targetRel);
23169
+ atomicWrite4(targetPath, nextRaw);
23170
+ if (path14.resolve(targetPath) !== path14.resolve(filePath)) {
23171
+ try {
23172
+ fs9.rmSync(filePath, { force: true });
23173
+ } catch {
23174
+ }
23175
+ }
23176
+ return { revision: revisionOf(nextRaw), status: to, path: targetRel };
23177
+ }
22952
23178
 
22953
23179
  // ../integrations/src/errors.ts
22954
23180
  var RETRYABLE = /* @__PURE__ */ new Set([
@@ -23634,8 +23860,8 @@ async function handleJiraResponse(res) {
23634
23860
  }
23635
23861
  return await res.json();
23636
23862
  }
23637
- async function jiraFetch(baseUrl, path16, auth, timeoutMs, params) {
23638
- const url = new URL(path16, baseUrl + "/");
23863
+ async function jiraFetch(baseUrl, path18, auth, timeoutMs, params) {
23864
+ const url = new URL(path18, baseUrl + "/");
23639
23865
  if (params) for (const [k, v] of Object.entries(params)) url.searchParams.set(k, v);
23640
23866
  const controller = new AbortController();
23641
23867
  const timer = setTimeout(() => controller.abort(), timeoutMs);
@@ -23653,8 +23879,8 @@ async function jiraFetch(baseUrl, path16, auth, timeoutMs, params) {
23653
23879
  clearTimeout(timer);
23654
23880
  }
23655
23881
  }
23656
- async function jiraPost(baseUrl, path16, auth, timeoutMs, body) {
23657
- const url = new URL(path16, baseUrl + "/");
23882
+ async function jiraPost(baseUrl, path18, auth, timeoutMs, body) {
23883
+ const url = new URL(path18, baseUrl + "/");
23658
23884
  const controller = new AbortController();
23659
23885
  const timer = setTimeout(() => controller.abort(), timeoutMs);
23660
23886
  try {
@@ -24609,7 +24835,7 @@ function runAssetsUpdate(kind, opts = {}) {
24609
24835
 
24610
24836
  // src/commands/ready.ts
24611
24837
  import fs11 from "fs";
24612
- import path14 from "path";
24838
+ import path15 from "path";
24613
24839
  import matter23 from "gray-matter";
24614
24840
  function validateReadiness(content, frontmatter2) {
24615
24841
  const warnings = [];
@@ -24672,10 +24898,10 @@ function transitionToReady(filePath) {
24672
24898
  const posix2 = filePath.replace(/\\/g, "/");
24673
24899
  let newPath = filePath;
24674
24900
  if (posix2.includes("/work-items/draft/")) {
24675
- const readyDir = path14.dirname(filePath).replace(/[/\\]draft$/, path14.sep + "ready");
24901
+ const readyDir = path15.dirname(filePath).replace(/[/\\]draft$/, path15.sep + "ready");
24676
24902
  ensureDir(readyDir);
24677
- const fileName = path14.basename(filePath);
24678
- newPath = path14.join(readyDir, fileName);
24903
+ const fileName = path15.basename(filePath);
24904
+ newPath = path15.join(readyDir, fileName);
24679
24905
  }
24680
24906
  return { newPath, newContent };
24681
24907
  }
@@ -24746,8 +24972,8 @@ async function runReady(id, opts = {}) {
24746
24972
  fs11.unlinkSync(wi.filePath);
24747
24973
  log.success(`Updated status: ready`);
24748
24974
  log.success(`Moved file:`);
24749
- log.info(` ${path14.relative(dir, wi.filePath)}`);
24750
- log.info(` \u2192 ${path14.relative(dir, newPath)}`);
24975
+ log.info(` ${path15.relative(dir, wi.filePath)}`);
24976
+ log.info(` \u2192 ${path15.relative(dir, newPath)}`);
24751
24977
  } else {
24752
24978
  writeFile(wi.filePath, newContent);
24753
24979
  log.success(`Updated status: ready`);
@@ -24757,8 +24983,36 @@ async function runReady(id, opts = {}) {
24757
24983
  outro(`Work Item ${wi.id} is ready.`);
24758
24984
  }
24759
24985
 
24986
+ // src/commands/start.ts
24987
+ async function runStart(id, opts = {}) {
24988
+ intro(`kaddo start ${id}`);
24989
+ let edit;
24990
+ try {
24991
+ edit = getWorkItemForEdit(process.cwd(), id);
24992
+ } catch (error) {
24993
+ log.error(error.message);
24994
+ return;
24995
+ }
24996
+ if (edit.status !== "ready") {
24997
+ log.error(`Work Item ${id} is "${edit.status}". Only ready Work Items can be started.`);
24998
+ return;
24999
+ }
25000
+ if (!opts.yes && !await confirm({ message: "Start implementation and move this Work Item to in-progress?" })) {
25001
+ cancel("Cancelled.");
25002
+ return;
25003
+ }
25004
+ try {
25005
+ const result = transitionWorkItem(process.cwd(), id, "in-progress", edit.revision);
25006
+ log.success(`Updated status: ${result.status}`);
25007
+ log.success(`Moved file: ${result.path}`);
25008
+ outro(`Work Item ${id} is in progress.`);
25009
+ } catch (error) {
25010
+ log.error(error instanceof WorkItemWriteError ? error.message : error.message);
25011
+ }
25012
+ }
25013
+
24760
25014
  // src/commands/admin.ts
24761
- import path15 from "path";
25015
+ import path16 from "path";
24762
25016
  import { fileURLToPath as fileURLToPath2 } from "url";
24763
25017
  import net from "net";
24764
25018
  function isPortAvailable(port, host) {
@@ -24773,17 +25027,17 @@ function isPortAvailable(port, host) {
24773
25027
  });
24774
25028
  }
24775
25029
  function resolveStaticDir() {
24776
- const __dirname = path15.dirname(fileURLToPath2(import.meta.url));
25030
+ const __dirname = path16.dirname(fileURLToPath2(import.meta.url));
24777
25031
  const candidates = [
24778
25032
  // Monorepo development: prefer the freshly built admin over the copy bundled into the CLI dist.
24779
25033
  // The CLI build copies admin/dist into dist/admin-dist, but that copy can be stale when the admin
24780
25034
  // was rebuilt after the CLI (build order is not guaranteed in `pnpm -r build`). Serving the admin
24781
25035
  // package's own dist first ensures `kaddo admin` always shows the current frontend in dev. This
24782
25036
  // path does not exist in a published npm install (admin is private), so it falls back below.
24783
- path15.resolve(__dirname, "..", "..", "admin", "dist"),
24784
- path15.resolve(__dirname, "..", "node_modules", "@kaddo", "admin", "dist"),
25037
+ path16.resolve(__dirname, "..", "..", "admin", "dist"),
25038
+ path16.resolve(__dirname, "..", "node_modules", "@kaddo", "admin", "dist"),
24785
25039
  // Bundled inside CLI dist (npm install)
24786
- path15.resolve(__dirname, "admin-dist")
25040
+ path16.resolve(__dirname, "admin-dist")
24787
25041
  ];
24788
25042
  for (const c of candidates) {
24789
25043
  if (exists(join(c, "index.html"))) return c;
@@ -24825,8 +25079,8 @@ async function runAdmin(opts = {}) {
24825
25079
  }
24826
25080
  let adminServer;
24827
25081
  try {
24828
- const __dirname = path15.dirname(fileURLToPath2(import.meta.url));
24829
- const bundled = path15.resolve(__dirname, "admin-server", "index.js");
25082
+ const __dirname = path16.dirname(fileURLToPath2(import.meta.url));
25083
+ const bundled = path16.resolve(__dirname, "admin-server", "index.js");
24830
25084
  if (exists(bundled)) {
24831
25085
  const { pathToFileURL } = await import("url");
24832
25086
  adminServer = await import(pathToFileURL(bundled).href);
@@ -24918,7 +25172,9 @@ function toListItem(a) {
24918
25172
  releaseStatus: a.releaseStatus || null,
24919
25173
  affectedModules: a.affectedModules,
24920
25174
  scopeConfidenceLevel: a.scopeConfidence?.level ?? null,
24921
- initiative: a.initiative || null
25175
+ initiative: a.initiative || null,
25176
+ owners: Array.isArray(a.rawFrontmatter.owners) ? a.rawFrontmatter.owners.map(String).filter(Boolean) : [],
25177
+ contributors: Array.isArray(a.rawFrontmatter.contributors) ? a.rawFrontmatter.contributors.map(String).filter(Boolean) : []
24922
25178
  };
24923
25179
  }
24924
25180
  function getWorkItem(dir, workItemId) {
@@ -24967,8 +25223,8 @@ function parseGraphReason(v) {
24967
25223
  if (!v || typeof v !== "object") return null;
24968
25224
  const o = v;
24969
25225
  const relationship = typeof o.relationship === "string" && o.relationship.trim() ? o.relationship.trim() : null;
24970
- const path16 = Array.isArray(o.path) ? o.path.map(String).filter(Boolean) : [];
24971
- return relationship || path16.length ? { relationship, path: path16 } : null;
25226
+ const path18 = Array.isArray(o.path) ? o.path.map(String).filter(Boolean) : [];
25227
+ return relationship || path18.length ? { relationship, path: path18 } : null;
24972
25228
  }
24973
25229
  function parseExplain(o) {
24974
25230
  const refs = Array.isArray(o.evidence) ? o.evidence : Array.isArray(o.evidence_refs) ? o.evidence_refs : [];
@@ -25895,7 +26151,12 @@ function collectImplementationEvidence(dir, workItemId, input) {
25895
26151
  } : {}
25896
26152
  };
25897
26153
  }
25898
- return { repositories };
26154
+ return {
26155
+ repositories,
26156
+ ...input.acVerifications.length > 0 ? {
26157
+ ac_verifications: input.acVerifications.map((verification) => ({ ...verification }))
26158
+ } : {}
26159
+ };
25899
26160
  }
25900
26161
  function verifyWorkItem(dir, workItemId, input) {
25901
26162
  const evidence = collectImplementationEvidence(dir, workItemId, input);
@@ -25955,6 +26216,9 @@ function evaluateCompletion(verification) {
25955
26216
  warnings.push(`Completion exception "${ex.id}" is still proposed (not yet accepted).`);
25956
26217
  }
25957
26218
  }
26219
+ if (verification.acSummary.total === 0) {
26220
+ blockers.push("No acceptance criteria were detected; completion evidence is insufficient.");
26221
+ }
25958
26222
  if (verification.acSummary.failed > 0) {
25959
26223
  const failedACs = verification.acVerifications.filter((ac) => ac.status === "failed");
25960
26224
  for (const ac of failedACs) {
@@ -25966,10 +26230,16 @@ function evaluateCompletion(verification) {
25966
26230
  blockers.push(f.message);
25967
26231
  }
25968
26232
  if (verification.acSummary.manualReview > 0) {
25969
- warnings.push(`${verification.acSummary.manualReview} AC(s) require manual review.`);
26233
+ blockers.push(`${verification.acSummary.manualReview} AC(s) require manual review.`);
25970
26234
  }
25971
26235
  if (verification.acSummary.notVerified > 0) {
25972
- warnings.push(`${verification.acSummary.notVerified} AC(s) not yet verified.`);
26236
+ blockers.push(`${verification.acSummary.notVerified} AC(s) not yet verified.`);
26237
+ }
26238
+ if (verification.implementationStatus !== "completed") {
26239
+ blockers.push(`Implementation status is "${verification.implementationStatus}", not "completed".`);
26240
+ }
26241
+ if (!["passed", "accepted-with-exceptions"].includes(verification.validationStatus)) {
26242
+ blockers.push(`Validation status is "${verification.validationStatus}", not passed.`);
25973
26243
  }
25974
26244
  const warningFindings = verification.findings.filter((f) => f.severity === "warning");
25975
26245
  for (const f of warningFindings) {
@@ -25986,8 +26256,8 @@ function evaluateCompletion(verification) {
25986
26256
  }
25987
26257
  let readiness;
25988
26258
  if (blockers.length > 0) {
25989
- const hasOnlyACFailures = blockers.every((b) => b.startsWith("AC failed:"));
25990
- if (hasOnlyACFailures) {
26259
+ const needsEvidence = blockers.every((b) => b.startsWith("AC failed:") || b.includes("acceptance criteria") || b.includes("AC(s)") || b.startsWith("Implementation status") || b.startsWith("Validation status"));
26260
+ if (needsEvidence) {
25991
26261
  readiness = "NEEDS_WORK";
25992
26262
  reasons.push("Acceptance criteria have failures that must be addressed.");
25993
26263
  } else {
@@ -26069,12 +26339,34 @@ function deriveImplementationStatus(repos) {
26069
26339
  }
26070
26340
 
26071
26341
  // src/commands/verify.ts
26342
+ function normalizeAC(text2) {
26343
+ return text2.trim().toLowerCase().replace(/\s+/g, " ");
26344
+ }
26345
+ function storedACVerifications(value) {
26346
+ if (!Array.isArray(value)) return /* @__PURE__ */ new Map();
26347
+ return new Map(value.filter((entry) => Boolean(entry) && typeof entry === "object").filter((entry) => typeof entry.criterion === "string").map((entry) => [normalizeAC(entry.criterion), entry]));
26348
+ }
26349
+ function buildACVerifications(acs, persisted) {
26350
+ const persistedACs = storedACVerifications(persisted);
26351
+ return acs.map((ac) => {
26352
+ const stored = persistedACs.get(normalizeAC(ac.criterion));
26353
+ const validStatus = stored?.status === "passed" || stored?.status === "failed" || stored?.status === "not-verified" || stored?.status === "manual-review-required" ? stored.status : "not-verified";
26354
+ const hasEvidence = typeof stored?.evidence === "string" && stored.evidence.trim().length > 0 && typeof stored?.reference === "string" && stored.reference.trim().length > 0;
26355
+ return {
26356
+ criterion: ac.criterion,
26357
+ status: validStatus === "passed" && !hasEvidence ? "not-verified" : validStatus,
26358
+ ...typeof stored?.evidence === "string" ? { evidence: stored.evidence } : {},
26359
+ ...typeof stored?.reference === "string" ? { reference: stored.reference } : {},
26360
+ ...stored?.method === "automated" || stored?.method === "manual" ? { method: stored.method } : {}
26361
+ };
26362
+ });
26363
+ }
26072
26364
  function extractACsFromBody(body) {
26073
26365
  const lines = body.split(/\r?\n/);
26074
26366
  let inAC = false;
26075
26367
  const acs = [];
26076
26368
  for (const line of lines) {
26077
- if (/^#{1,6}\s+(acceptance\s+criteria|criterios\s+de\s+aceptaci[oó]n)/i.test(line)) {
26369
+ if (/^#{1,6}\s+(?:\d+(?:\.\d+)*\.?\s+)?(acceptance\s+criteria|criterios\s+de\s+aceptaci[oó]n)\s*$/i.test(line)) {
26078
26370
  inAC = true;
26079
26371
  continue;
26080
26372
  }
@@ -26143,11 +26435,7 @@ async function runVerify(workItemId, opts = {}) {
26143
26435
  })) : void 0
26144
26436
  };
26145
26437
  }) : [{ repoId: "core", changedPaths, validations: [] }];
26146
- const acVerifications = acs.map((ac) => ({
26147
- criterion: ac.criterion,
26148
- status: ac.checked ? "passed" : "not-verified",
26149
- ...ac.checked ? { evidence: "Explicitly checked in the Work Item acceptance criteria." } : {}
26150
- }));
26438
+ const acVerifications = buildACVerifications(acs, existingEvidence?.ac_verifications);
26151
26439
  const input = {
26152
26440
  repos,
26153
26441
  acVerifications
@@ -26322,15 +26610,15 @@ function longestSharedRun(a, b) {
26322
26610
  let bestSnippet = "";
26323
26611
  for (const block of a.blocks) {
26324
26612
  let run = 0;
26325
- let runStart = 0;
26613
+ let runStart2 = 0;
26326
26614
  for (let i = 0; i + SHINGLE_SIZE <= block.length; i++) {
26327
26615
  const key = block.slice(i, i + SHINGLE_SIZE).join(" ");
26328
26616
  if (b.set.has(key)) {
26329
- if (run === 0) runStart = i;
26617
+ if (run === 0) runStart2 = i;
26330
26618
  run += 1;
26331
26619
  if (run > best) {
26332
26620
  best = run;
26333
- bestSnippet = block.slice(runStart, runStart + SHINGLE_SIZE + run - 1).join(" ");
26621
+ bestSnippet = block.slice(runStart2, runStart2 + SHINGLE_SIZE + run - 1).join(" ");
26334
26622
  }
26335
26623
  } else {
26336
26624
  run = 0;
@@ -27387,9 +27675,9 @@ function markRegistered(dir, identity) {
27387
27675
  ensureDir(join(dir, TELEMETRY_DIR));
27388
27676
  writeFile(identityPath(dir), JSON.stringify(identity, null, 2));
27389
27677
  }
27390
- function signPayload(identity, method, path16, timestamp, nonce, bodySha256) {
27678
+ function signPayload(identity, method, path18, timestamp, nonce, bodySha256) {
27391
27679
  const canonical = `${method}
27392
- ${path16}
27680
+ ${path18}
27393
27681
  ${identity.installationId}
27394
27682
  ${timestamp}
27395
27683
  ${nonce}
@@ -27614,6 +27902,75 @@ function runTelemetryDisable() {
27614
27902
  outro("Run `kaddo telemetry enable` to re-enable.");
27615
27903
  }
27616
27904
 
27905
+ // src/core/collaboration.ts
27906
+ import path17 from "path";
27907
+ function matchesWorkItemReference(value, id) {
27908
+ return new RegExp(`(^|[^A-Za-z0-9_-])${id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?=$|[^A-Za-z0-9_-])`, "i").test(value);
27909
+ }
27910
+ async function observationsForProject(dir) {
27911
+ const corePath = path17.resolve(dir);
27912
+ const mapped = loadMappedModules(dir).filter((module) => Boolean(module.repoPath)).map((module) => ({ path: path17.resolve(corePath, module.repoPath), repositoryId: `module:${module.id}` }));
27913
+ const candidates = [{ path: corePath, repositoryId: "core" }, ...mapped];
27914
+ const resolved = await Promise.all(candidates.map(async (candidate) => ({ ...candidate, root: await getGitRoot(candidate.path) })));
27915
+ const repositories = /* @__PURE__ */ new Map();
27916
+ for (const item of resolved) if (item.root && !repositories.has(item.root)) repositories.set(item.root, { root: item.root, repositoryId: item.repositoryId });
27917
+ const observations = await Promise.all([...repositories.values()].map((repo) => observeGit(repo.root, 100, repo.repositoryId)));
27918
+ return observations;
27919
+ }
27920
+ async function collaborationForWorkItems(dir, ids) {
27921
+ const observations = await observationsForProject(dir);
27922
+ return ids.map((id) => {
27923
+ const wi = getWorkItem(dir, id);
27924
+ const linkedCommits = [];
27925
+ const relatedBranches = [];
27926
+ for (const observation of observations) {
27927
+ const repository = observation.repository ?? "local";
27928
+ for (const commit of observation.commits) {
27929
+ if (!matchesWorkItemReference(commit.subject, wi.id)) continue;
27930
+ linkedCommits.push({ repository, sha: commit.sha, author: commit.author, date: commit.date, subject: commit.subject, paths: commit.files.slice(0, 50), attribution: "explicit-reference", evidence: `Exact reference ${wi.id} in commit subject.` });
27931
+ }
27932
+ for (const branch of observation.branches) {
27933
+ if (!matchesWorkItemReference(branch.name, wi.id)) continue;
27934
+ relatedBranches.push({ repository, name: branch.name, attribution: "branch-associated", evidence: `Exact reference ${wi.id} in local branch name.` });
27935
+ }
27936
+ }
27937
+ const inspectedCommits = observations.reduce((total, observation) => total + observation.commits.length, 0);
27938
+ const available = observations.filter((observation) => observation.availability === "available").length;
27939
+ const availability = available === observations.length ? "available" : available > 0 ? "partial" : observations.some((observation) => observation.availability === "partial") ? "partial" : "unavailable";
27940
+ return {
27941
+ workItemId: wi.id,
27942
+ responsibility: { owners: wi.owners, contributors: wi.contributors },
27943
+ git: {
27944
+ availability,
27945
+ repositories: observations.flatMap((observation) => observation.repository ? [observation.repository] : []),
27946
+ observedAuthors: [...new Set(linkedCommits.map((commit) => commit.author))],
27947
+ linkedCommits,
27948
+ relatedBranches,
27949
+ unattributedActivityCount: Math.max(0, inspectedCommits - linkedCommits.length),
27950
+ inspectedAt: observations.map((observation) => observation.inspectedAt).sort().at(-1) ?? null,
27951
+ coverage: { maxCommits: observations[0]?.limit ?? 100, inspectedCommits, note: "Only the core repository and explicitly mapped module repositories were inspected with read-only Git metadata. File overlap never creates attribution." }
27952
+ }
27953
+ };
27954
+ });
27955
+ }
27956
+ async function getWorkItemCollaboration(dir, id) {
27957
+ return (await collaborationForWorkItems(dir, [id]))[0];
27958
+ }
27959
+
27960
+ // src/commands/collaboration.ts
27961
+ async function runCollaborationShow(dir, id) {
27962
+ try {
27963
+ console.log(JSON.stringify(await getWorkItemCollaboration(dir, id), null, 2));
27964
+ } catch (err) {
27965
+ if (err instanceof WorkItemNotFoundError) {
27966
+ console.error(err.message);
27967
+ process.exitCode = 1;
27968
+ return;
27969
+ }
27970
+ throw err;
27971
+ }
27972
+ }
27973
+
27617
27974
  // src/core/initiative-analysis.ts
27618
27975
  var SUCCESS_HEADING_RE = /^#{1,6}\s*(success criteria|criterios de[ét]xito|criterios de éxito)\s*$/i;
27619
27976
  var HEADING_RE2 = /^#{1,6}\s+/;
@@ -27961,6 +28318,9 @@ program.command("create [type]").description("Create a work item (feature, bugfi
27961
28318
  program.command("ready <id>").description("Mark a draft Work Item as ready for implementation after human review").option("--yes", "Skip confirmation prompt").action(async (id, opts) => {
27962
28319
  await runReady(id, opts);
27963
28320
  });
28321
+ program.command("start <id>").description("Start a ready Work Item and move it to in-progress").option("--yes", "Skip confirmation prompt").action(async (id, opts) => {
28322
+ await runStart(id, opts);
28323
+ });
27964
28324
  var pocCmd = program.command("poc").description("Proof of Concept lifecycle helpers");
27965
28325
  pocCmd.command("report").description("Prepare a deterministic final POC report handoff (no LLM call, no write)").option("--json", "Output the report context as JSON").action((opts) => {
27966
28326
  runPocReport(opts);
@@ -27969,8 +28329,8 @@ var capsuleCmd = program.command("capsule").description("Export this project as
27969
28329
  capsuleCmd.command("export").description("Write a Knowledge Capsule about this project to .kaddo/exports/").option("--scope <scope>", 'Export scope: "system" includes all mapped modules').option("--module <id>", "Export a capsule for a specific mapped module").action((opts) => {
27970
28330
  runCapsuleExport(opts);
27971
28331
  });
27972
- capsuleCmd.command("add <path>").description("Register an external Knowledge Capsule as project context (.kaddo/external.yml)").action((path16) => {
27973
- runCapsuleAdd(path16);
28332
+ capsuleCmd.command("add <path>").description("Register an external Knowledge Capsule as project context (.kaddo/external.yml)").action((path18) => {
28333
+ runCapsuleAdd(path18);
27974
28334
  });
27975
28335
  var graphCmd = program.command("graph").description("Export the lightweight, file-based knowledge graph of the project");
27976
28336
  graphCmd.command("export").description("Write the knowledge graph to .kaddo/graph.json and .kaddo/graph.mmd").option("--scope <scope>", "Graph scope: active (default) or all").option("--format <format>", "Output format: json, mermaid (default: both)").action((opts) => {
@@ -28203,6 +28563,10 @@ initiativeCmd.command("analyze <id>").description("Analyze an initiative: succes
28203
28563
  initiativeCmd.command("complete <id>").description("Review completion readiness and mark an initiative completed (human-confirmed)").option("--yes", "Skip the confirmation prompt").action(async (id, opts) => {
28204
28564
  await runInitiativeComplete(id, opts);
28205
28565
  });
28566
+ var collaborationCmd = program.command("collaboration").description("Read declared responsibility and bounded, read-only local Git evidence");
28567
+ collaborationCmd.command("show <id>").description("Show collaboration evidence for one Work Item").action(async (id) => {
28568
+ await runCollaborationShow(cwd(), id);
28569
+ });
28206
28570
  var telemetryCmd = program.command("telemetry").description("Manage anonymous usage telemetry");
28207
28571
  telemetryCmd.command("status").description("Show telemetry status (enabled, registered, pending events)").action(() => {
28208
28572
  runTelemetryStatus();