@kaddo/cli 3.105.0 → 3.107.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 (3) hide show
  1. package/dist/core.js +155 -0
  2. package/dist/index.js +773 -10
  3. package/package.json +1 -1
package/dist/core.js CHANGED
@@ -12058,6 +12058,30 @@ function computeInitiativeProgress(dir, ini) {
12058
12058
  }
12059
12059
  };
12060
12060
  }
12061
+ function getInitiativeContext(dir, ini) {
12062
+ return {
12063
+ initiative: {
12064
+ id: ini.id,
12065
+ title: ini.title,
12066
+ status: ini.status,
12067
+ horizon: ini.horizon,
12068
+ priority: ini.priority,
12069
+ knowledgeLevel: ini.knowledgeLevel,
12070
+ domains: ini.domains,
12071
+ relatedCapabilities: ini.relatedCapabilities,
12072
+ source: ini.source,
12073
+ sourceId: ini.sourceId
12074
+ },
12075
+ progress: computeInitiativeProgress(dir, ini),
12076
+ candidates: {
12077
+ total: ini.candidates.length,
12078
+ materialized: ini.candidates.filter((c) => c.materializedAs),
12079
+ pending: ini.candidates.filter((c) => !c.materializedAs)
12080
+ },
12081
+ workItems: associatedWorkItems(dir, ini.id),
12082
+ externalLinks: ini.externalLinks
12083
+ };
12084
+ }
12061
12085
 
12062
12086
  // src/core/initiative-write.ts
12063
12087
  import matter11 from "gray-matter";
@@ -12223,6 +12247,26 @@ function addCandidate(dir, id, candidate) {
12223
12247
  if (!updated) throw new InitiativeWriteError("Failed to parse the Initiative after adding a candidate.");
12224
12248
  return updated;
12225
12249
  }
12250
+ function updateInitiative(dir, id, patch) {
12251
+ const ini = getInitiative(dir, id);
12252
+ if (!ini) throw new InitiativeWriteError(`Initiative ${id} not found.`);
12253
+ const raw = readFile(ini.filePath);
12254
+ const { data, content } = matter11(raw, {});
12255
+ if (patch.title !== void 0) {
12256
+ if (!patch.title.trim()) throw new InitiativeWriteError("Initiative title cannot be empty.");
12257
+ data.title = patch.title.trim();
12258
+ }
12259
+ if (patch.horizon !== void 0) data.horizon = patch.horizon;
12260
+ if (patch.priority !== void 0) data.priority = patch.priority;
12261
+ if (patch.knowledgeLevel !== void 0) data.knowledge_level = patch.knowledgeLevel;
12262
+ if (patch.domains !== void 0) data.domains = patch.domains;
12263
+ if (patch.relatedCapabilities !== void 0) data.related_capabilities = patch.relatedCapabilities;
12264
+ const newContent = matter11.stringify(content, data);
12265
+ writeFile(ini.filePath, newContent);
12266
+ const updated = parseInitiative(dir, ini.filePath, newContent);
12267
+ if (!updated) throw new InitiativeWriteError("Failed to parse the Initiative after update.");
12268
+ return updated;
12269
+ }
12226
12270
  function nextWorkItemId2(dir) {
12227
12271
  const wiDir = join(dir, WORK_ITEMS_DIR2);
12228
12272
  let max = 0;
@@ -12350,6 +12394,112 @@ function materializeRoadmapInitiative(dir, rmId) {
12350
12394
  candidates
12351
12395
  });
12352
12396
  }
12397
+
12398
+ // src/core/initiative-analysis.ts
12399
+ var SUCCESS_HEADING_RE = /^#{1,6}\s*(success criteria|criterios de[ét]xito|criterios de éxito)\s*$/i;
12400
+ var HEADING_RE2 = /^#{1,6}\s+/;
12401
+ var CHECK_ITEM_RE = /^\s*[-*]\s+\[([ xX])\]\s+(.*)$/;
12402
+ var BULLET_RE2 = /^\s*[-*]\s+(.*)$/;
12403
+ var PLACEHOLDER_RE = /^_.*_$/;
12404
+ function parseSuccessCriteria(body) {
12405
+ const lines = body.split(/\r?\n/);
12406
+ const out = [];
12407
+ let capture = false;
12408
+ for (const line of lines) {
12409
+ if (capture && HEADING_RE2.test(line)) break;
12410
+ if (!capture) {
12411
+ if (SUCCESS_HEADING_RE.test(line.trim())) capture = true;
12412
+ continue;
12413
+ }
12414
+ const check = line.match(CHECK_ITEM_RE);
12415
+ if (check) {
12416
+ const text2 = check[2].trim();
12417
+ if (text2 && !PLACEHOLDER_RE.test(text2)) {
12418
+ out.push({ text: text2, checked: check[1].toLowerCase() === "x" });
12419
+ }
12420
+ continue;
12421
+ }
12422
+ const bullet = line.match(BULLET_RE2);
12423
+ if (bullet) {
12424
+ const text2 = bullet[1].trim();
12425
+ if (text2 && !PLACEHOLDER_RE.test(text2)) out.push({ text: text2, checked: null });
12426
+ }
12427
+ }
12428
+ return out;
12429
+ }
12430
+ function analyzeInitiative(dir, ini) {
12431
+ const progress = computeInitiativeProgress(dir, ini);
12432
+ const successCriteria = parseSuccessCriteria(ini.body);
12433
+ const pendingCandidates = ini.candidates.filter((c) => !c.materializedAs);
12434
+ const associated = associatedWorkItems(dir, ini.id);
12435
+ const findings = [];
12436
+ if (successCriteria.length === 0) {
12437
+ findings.push({
12438
+ code: "no-success-criteria",
12439
+ severity: "warning",
12440
+ message: "The Initiative has no explicit Success Criteria; completion cannot be judged by outcome, only by delivery."
12441
+ });
12442
+ } else {
12443
+ const uncovered = successCriteria.filter((c) => c.checked === false);
12444
+ if (uncovered.length > 0) {
12445
+ findings.push({
12446
+ code: "uncovered-success-criteria",
12447
+ severity: "blocking",
12448
+ message: `${uncovered.length} success criterion/criteria remain uncovered.`,
12449
+ items: uncovered.map((c) => c.text)
12450
+ });
12451
+ }
12452
+ }
12453
+ if (pendingCandidates.length > 0) {
12454
+ findings.push({
12455
+ code: "pending-candidates",
12456
+ severity: "blocking",
12457
+ message: `${pendingCandidates.length} committed candidate(s) not yet materialized into Work Items.`,
12458
+ items: pendingCandidates.map((c) => `${c.id}: ${c.title}`)
12459
+ });
12460
+ }
12461
+ const notCompleted = associated.filter((w) => w.status !== "completed" && w.status !== "archived");
12462
+ if (associated.length === 0) {
12463
+ findings.push({
12464
+ code: "no-delivery",
12465
+ severity: "info",
12466
+ message: "No Work Items are associated with this Initiative yet."
12467
+ });
12468
+ } else if (notCompleted.length > 0) {
12469
+ findings.push({
12470
+ code: "incomplete-delivery",
12471
+ severity: "blocking",
12472
+ message: `${notCompleted.length} associated Work Item(s) are not completed.`,
12473
+ items: notCompleted.map((w) => `${w.id} (${w.status})`)
12474
+ });
12475
+ }
12476
+ return {
12477
+ initiative: ini.id,
12478
+ status: ini.status,
12479
+ progress,
12480
+ successCriteria,
12481
+ pendingCandidates,
12482
+ findings,
12483
+ suggestedCandidates: pendingCandidates
12484
+ };
12485
+ }
12486
+ function evaluateInitiativeCompletion(dir, ini) {
12487
+ const analysis = analyzeInitiative(dir, ini);
12488
+ const reasons = [];
12489
+ for (const f of analysis.findings) {
12490
+ if (f.severity === "blocking") reasons.push(f.message);
12491
+ }
12492
+ if (analysis.progress.delivery.total === 0 && analysis.pendingCandidates.length === 0) {
12493
+ reasons.push("Nothing has been delivered or committed under this Initiative.");
12494
+ }
12495
+ const ready = reasons.length === 0;
12496
+ return {
12497
+ initiative: ini.id,
12498
+ ready,
12499
+ readiness: ready ? "ready" : "not-ready",
12500
+ reasons
12501
+ };
12502
+ }
12353
12503
  export {
12354
12504
  CURRENT_CONSENT_VERSION,
12355
12505
  INITIATIVES_DIR,
@@ -12368,6 +12518,7 @@ export {
12368
12518
  WorkItemWriteError,
12369
12519
  addCandidate,
12370
12520
  analyzeCrossRepoEvidence,
12521
+ analyzeInitiative,
12371
12522
  analyzeScopeCoverage,
12372
12523
  applyTopologyProposal,
12373
12524
  associatedWorkItems,
@@ -12397,6 +12548,7 @@ export {
12397
12548
  discoverWorkItems,
12398
12549
  enableIntegration,
12399
12550
  evaluateCompletion,
12551
+ evaluateInitiativeCompletion,
12400
12552
  exists,
12401
12553
  filterSecretPaths,
12402
12554
  findDuplicateByHash,
@@ -12408,6 +12560,7 @@ export {
12408
12560
  getExternalWorkItem,
12409
12561
  getImpactCandidates,
12410
12562
  getInitiative,
12563
+ getInitiativeContext,
12411
12564
  getIntegration,
12412
12565
  getIntegrationFilters,
12413
12566
  getIntegrationSecretStatus,
@@ -12444,6 +12597,7 @@ export {
12444
12597
  nextInitiativeId,
12445
12598
  parseContent,
12446
12599
  parseInitiative,
12600
+ parseSuccessCriteria,
12447
12601
  persistConsent,
12448
12602
  previewImport,
12449
12603
  readFile,
@@ -12453,6 +12607,7 @@ export {
12453
12607
  topologyRevision,
12454
12608
  transitionInitiative,
12455
12609
  transitionWorkItem,
12610
+ updateInitiative,
12456
12611
  updateIntegration,
12457
12612
  updateIntegrationFilters,
12458
12613
  updateWorkItem,
package/dist/index.js CHANGED
@@ -6247,7 +6247,7 @@ function formatList(items) {
6247
6247
  return items.map((i) => `- ${i.trim()}`).join("\n");
6248
6248
  }
6249
6249
  function buildFrontMatter(id, type, level, title, answers) {
6250
- const today2 = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
6250
+ const today3 = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
6251
6251
  const lines = [
6252
6252
  "---",
6253
6253
  `type: ${type}`,
@@ -6260,7 +6260,7 @@ function buildFrontMatter(id, type, level, title, answers) {
6260
6260
  `initiative:`,
6261
6261
  `domains: []`,
6262
6262
  `code: []`,
6263
- `created_at: ${today2}`,
6263
+ `created_at: ${today3}`,
6264
6264
  `source:`,
6265
6265
  ` type: manual`,
6266
6266
  ` inferred: false`,
@@ -6335,7 +6335,7 @@ _What did we learn from this change? Update after completion._
6335
6335
  return sections.join("\n");
6336
6336
  }
6337
6337
  function buildModuleFrontMatter(id, modType, title, answers) {
6338
- const today2 = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
6338
+ const today3 = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
6339
6339
  const extra = modType.extraFrontMatter ?? {};
6340
6340
  const extraLines = Object.entries(extra).map(
6341
6341
  ([k, v]) => `${k}: ${JSON.stringify(v)}`
@@ -6351,7 +6351,7 @@ function buildModuleFrontMatter(id, modType, title, answers) {
6351
6351
  `initiative:`,
6352
6352
  `domains: []`,
6353
6353
  `code: []`,
6354
- `created_at: ${today2}`,
6354
+ `created_at: ${today3}`,
6355
6355
  `source: manual`,
6356
6356
  `summary: "${title}"`,
6357
6357
  ...extraLines,
@@ -6499,7 +6499,7 @@ function resolveCandidateLevel(candidate, type) {
6499
6499
  return getLevelForType(type);
6500
6500
  }
6501
6501
  function buildRoadmapFrontMatter(id, type, level, title, candidate, answers) {
6502
- const today2 = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
6502
+ const today3 = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
6503
6503
  const summary = (answers.problem?.split(".")[0] ?? candidate.expectedValue ?? title).trim();
6504
6504
  const initiative = candidate.initiative?.title ?? candidate.initiative?.id ?? "";
6505
6505
  const q = (s) => s.replace(/"/g, "'");
@@ -6522,7 +6522,7 @@ function buildRoadmapFrontMatter(id, type, level, title, candidate, answers) {
6522
6522
  ...yamlList2("domains", domains),
6523
6523
  ...domains.length === 0 ? ["domains: []"] : [],
6524
6524
  `code: []`,
6525
- `created_at: ${today2}`,
6525
+ `created_at: ${today3}`,
6526
6526
  `source: roadmap`,
6527
6527
  `source_id: ${candidate.id}`,
6528
6528
  `source_initiative: ${candidate.initiative?.id ?? "unknown"}`,
@@ -17924,7 +17924,7 @@ function createWorkItem(dir, opts) {
17924
17924
  if (!type) throw new WorkItemWriteError("INVALID_INPUT", `Unknown Work Item type "${opts.type}".`);
17925
17925
  const id = nextWorkItemId2(dir);
17926
17926
  const title = intent.split(/\r?\n/)[0].trim().slice(0, 120);
17927
- const today2 = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
17927
+ const today3 = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
17928
17928
  const source = opts.source ? { ...opts.source, inferred: false } : { type: "manual", inferred: false };
17929
17929
  const data = {
17930
17930
  type,
@@ -17932,7 +17932,7 @@ function createWorkItem(dir, opts) {
17932
17932
  title,
17933
17933
  status: "draft",
17934
17934
  work_type: type,
17935
- created_at: today2,
17935
+ created_at: today3,
17936
17936
  source,
17937
17937
  generated_by: "kaddo-admin",
17938
17938
  affected_modules: [],
@@ -20481,9 +20481,9 @@ function isResolvedSection(text2) {
20481
20481
  function transitionToReady(filePath) {
20482
20482
  const raw = readFile(filePath);
20483
20483
  const { data, content } = matter13(raw);
20484
- const today2 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
20484
+ const today3 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
20485
20485
  data.status = "ready";
20486
- data.ready_at = today2;
20486
+ data.ready_at = today3;
20487
20487
  const newContent = matter13.stringify(content, data);
20488
20488
  const posix = filePath.replace(/\\/g, "/");
20489
20489
  let newPath = filePath;
@@ -22292,6 +22292,741 @@ function runTelemetryDisable() {
22292
22292
  outro("Run `kaddo telemetry enable` to re-enable.");
22293
22293
  }
22294
22294
 
22295
+ // src/core/initiative.ts
22296
+ import matter17 from "gray-matter";
22297
+ var INITIATIVES_DIR = "knowledge/delivery/initiatives";
22298
+ var INITIATIVE_STATES = [
22299
+ "candidate",
22300
+ "planned",
22301
+ "in-progress",
22302
+ "completed",
22303
+ "deferred",
22304
+ "cancelled"
22305
+ ];
22306
+ var INITIATIVE_TRANSITIONS = {
22307
+ candidate: ["planned", "cancelled"],
22308
+ planned: ["in-progress", "deferred", "cancelled"],
22309
+ "in-progress": ["completed", "deferred", "cancelled"],
22310
+ deferred: ["planned", "cancelled"],
22311
+ completed: [],
22312
+ cancelled: []
22313
+ };
22314
+ var STATUS_SET = new Set(INITIATIVE_STATES);
22315
+ function isValidInitiativeStatus(s) {
22316
+ return STATUS_SET.has(s);
22317
+ }
22318
+ function isValidInitiativeTransition(from, to) {
22319
+ return INITIATIVE_TRANSITIONS[from].includes(to);
22320
+ }
22321
+ function toPosix6(p) {
22322
+ return p.replace(/\\/g, "/");
22323
+ }
22324
+ function optStr3(v) {
22325
+ if (typeof v === "string" && v.trim()) return v.trim();
22326
+ if (typeof v === "number") return String(v);
22327
+ return void 0;
22328
+ }
22329
+ function strList2(v) {
22330
+ if (!Array.isArray(v)) return [];
22331
+ return v.map((x) => typeof x === "string" ? x.trim() : String(x)).filter(Boolean);
22332
+ }
22333
+ function parseCandidates(data) {
22334
+ const raw = data.candidates;
22335
+ if (!Array.isArray(raw)) return [];
22336
+ const out = [];
22337
+ for (const entry of raw) {
22338
+ if (!entry || typeof entry !== "object" || Array.isArray(entry)) continue;
22339
+ const o = entry;
22340
+ const id = optStr3(o.id);
22341
+ const title = optStr3(o.title);
22342
+ if (!id || !title) continue;
22343
+ out.push({
22344
+ id,
22345
+ title,
22346
+ type: optStr3(o.type),
22347
+ suggestedKnowledgeLevel: optStr3(o.suggested_knowledge_level ?? o.knowledge_level),
22348
+ expectedValue: optStr3(o.expected_value),
22349
+ notes: optStr3(o.notes),
22350
+ sourceSignals: strList2(o.source_signals),
22351
+ dependencies: strList2(o.dependencies),
22352
+ materializedAs: optStr3(o.materialized_as) ?? null
22353
+ });
22354
+ }
22355
+ return out;
22356
+ }
22357
+ function parseExternalLinks(data) {
22358
+ const raw = data.external_links;
22359
+ if (!Array.isArray(raw)) return [];
22360
+ const out = [];
22361
+ for (const entry of raw) {
22362
+ if (!entry || typeof entry !== "object" || Array.isArray(entry)) continue;
22363
+ const o = entry;
22364
+ const integration = optStr3(o.integration);
22365
+ const externalId = optStr3(o.external_id);
22366
+ if (!integration || !externalId) continue;
22367
+ out.push({
22368
+ integration,
22369
+ externalId,
22370
+ externalType: optStr3(o.external_type),
22371
+ url: optStr3(o.url)
22372
+ });
22373
+ }
22374
+ return out;
22375
+ }
22376
+ function parseInitiative(dir, filePath, raw) {
22377
+ let parsed;
22378
+ try {
22379
+ parsed = matter17(raw, {});
22380
+ } catch {
22381
+ return null;
22382
+ }
22383
+ const data = parsed.data;
22384
+ if (optStr3(data.type) !== "initiative") return null;
22385
+ const id = optStr3(data.id);
22386
+ if (!id) return null;
22387
+ const statusRaw = optStr3(data.status) ?? "planned";
22388
+ const status = isValidInitiativeStatus(statusRaw) ? statusRaw : "planned";
22389
+ return {
22390
+ id,
22391
+ title: optStr3(data.title) ?? id,
22392
+ status,
22393
+ horizon: optStr3(data.horizon) ?? null,
22394
+ priority: optStr3(data.priority) ?? null,
22395
+ knowledgeLevel: optStr3(data.knowledge_level) ?? null,
22396
+ domains: strList2(data.domains),
22397
+ relatedCapabilities: strList2(data.related_capabilities),
22398
+ source: optStr3(data.source) ?? null,
22399
+ sourceId: optStr3(data.source_id) ?? null,
22400
+ createdAt: optStr3(data.created_at) ?? null,
22401
+ externalLinks: parseExternalLinks(data),
22402
+ candidates: parseCandidates(data),
22403
+ filePath,
22404
+ relPath: toPosix6(filePath).startsWith(toPosix6(dir) + "/") ? toPosix6(filePath).slice(toPosix6(dir).length + 1) : toPosix6(filePath),
22405
+ body: parsed.content.trim(),
22406
+ rawFrontmatter: data
22407
+ };
22408
+ }
22409
+ function discoverInitiatives(dir) {
22410
+ const iniDir = join(dir, INITIATIVES_DIR);
22411
+ if (!exists(iniDir)) return [];
22412
+ const out = [];
22413
+ for (const entry of readDir(iniDir)) {
22414
+ if (!entry.endsWith(".md")) continue;
22415
+ const full = join(iniDir, entry);
22416
+ if (!isFile(full)) continue;
22417
+ const ini = parseInitiative(dir, full, readFile(full));
22418
+ if (ini) out.push(ini);
22419
+ }
22420
+ return out.sort((a, b) => a.id.localeCompare(b.id));
22421
+ }
22422
+ function getInitiative(dir, id) {
22423
+ const want = id.trim().toLowerCase();
22424
+ return discoverInitiatives(dir).find((i) => i.id.toLowerCase() === want) ?? null;
22425
+ }
22426
+ function nextInitiativeId(dir) {
22427
+ const iniDir = join(dir, INITIATIVES_DIR);
22428
+ let max = 0;
22429
+ if (exists(iniDir)) {
22430
+ for (const entry of readDir(iniDir)) {
22431
+ const m = entry.match(/INI-(\d+)/);
22432
+ if (m) max = Math.max(max, parseInt(m[1], 10));
22433
+ }
22434
+ }
22435
+ return `INI-${String(max + 1).padStart(3, "0")}`;
22436
+ }
22437
+ function workItemBelongsToInitiative(workItemInitiative, iniId) {
22438
+ const v = (workItemInitiative ?? "").trim().toLowerCase();
22439
+ return v !== "" && v === iniId.trim().toLowerCase();
22440
+ }
22441
+ function associatedWorkItems(dir, iniId) {
22442
+ return discoverWorkItems(dir).filter((wi) => workItemBelongsToInitiative(wi.initiative, iniId)).map((wi) => ({
22443
+ id: wi.id,
22444
+ title: wi.title,
22445
+ status: wi.lifecycle ?? "ready"
22446
+ })).sort((a, b) => a.id.localeCompare(b.id));
22447
+ }
22448
+ function computeInitiativeProgress(dir, ini) {
22449
+ const totalCandidates = ini.candidates.length;
22450
+ const materialized = ini.candidates.filter((c) => c.materializedAs).length;
22451
+ const byState = emptyLifecycleCounts();
22452
+ const associated = associatedWorkItems(dir, ini.id);
22453
+ for (const wi of associated) byState[wi.status]++;
22454
+ return {
22455
+ initiative: ini.id,
22456
+ status: ini.status,
22457
+ planning: {
22458
+ totalCandidates,
22459
+ materialized,
22460
+ remaining: Math.max(0, totalCandidates - materialized)
22461
+ },
22462
+ delivery: {
22463
+ total: associated.length,
22464
+ byState
22465
+ }
22466
+ };
22467
+ }
22468
+
22469
+ // src/core/initiative-write.ts
22470
+ import matter18 from "gray-matter";
22471
+ var WORK_ITEMS_DIR4 = "knowledge/delivery/work-items";
22472
+ var DRAFT_DIR2 = `${WORK_ITEMS_DIR4}/draft`;
22473
+ var InitiativeWriteError = class extends Error {
22474
+ constructor(message) {
22475
+ super(message);
22476
+ this.name = "InitiativeWriteError";
22477
+ }
22478
+ };
22479
+ function slugify6(s) {
22480
+ return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 50);
22481
+ }
22482
+ function today2() {
22483
+ return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
22484
+ }
22485
+ function candidateToData(c) {
22486
+ const out = { id: c.id, title: c.title };
22487
+ if (c.type) out.type = c.type;
22488
+ if (c.suggestedKnowledgeLevel) out.suggested_knowledge_level = c.suggestedKnowledgeLevel;
22489
+ if (c.expectedValue) out.expected_value = c.expectedValue;
22490
+ if (c.notes) out.notes = c.notes;
22491
+ if (c.sourceSignals.length) out.source_signals = c.sourceSignals;
22492
+ if (c.dependencies.length) out.dependencies = c.dependencies;
22493
+ if (c.materializedAs) out.materialized_as = c.materializedAs;
22494
+ return out;
22495
+ }
22496
+ function externalLinkToData(l) {
22497
+ const out = { integration: l.integration, external_id: l.externalId };
22498
+ if (l.externalType) out.external_type = l.externalType;
22499
+ if (l.url) out.url = l.url;
22500
+ return out;
22501
+ }
22502
+ function normalizeCandidate(input, fallbackId) {
22503
+ return {
22504
+ id: input.id?.trim() || fallbackId,
22505
+ title: input.title.trim(),
22506
+ type: input.type?.trim() || void 0,
22507
+ suggestedKnowledgeLevel: input.suggestedKnowledgeLevel?.trim() || void 0,
22508
+ expectedValue: input.expectedValue?.trim() || void 0,
22509
+ notes: input.notes?.trim() || void 0,
22510
+ sourceSignals: input.sourceSignals ?? [],
22511
+ dependencies: input.dependencies ?? [],
22512
+ materializedAs: input.materializedAs ?? null
22513
+ };
22514
+ }
22515
+ function defaultBody(title) {
22516
+ return [
22517
+ `# ${title}`,
22518
+ "",
22519
+ "## Goal",
22520
+ "",
22521
+ "_What outcome does this Initiative pursue?_",
22522
+ "",
22523
+ "## Expected Value",
22524
+ "",
22525
+ "_Why it matters._",
22526
+ "",
22527
+ "## Scope",
22528
+ "",
22529
+ "_What this Initiative covers._",
22530
+ "",
22531
+ "## Out of Scope",
22532
+ "",
22533
+ "_What it explicitly does not cover._",
22534
+ "",
22535
+ "## Success Criteria",
22536
+ "",
22537
+ '_Observable outcomes that define completion (not just "all Work Items done")._',
22538
+ "",
22539
+ "## Dependencies",
22540
+ "",
22541
+ "_Other Initiatives, modules, or external work this depends on._",
22542
+ "",
22543
+ "## Work Item Candidates",
22544
+ "",
22545
+ "_Candidates live in frontmatter `candidates`; summarize them here as they evolve._",
22546
+ "",
22547
+ "## Open Questions",
22548
+ "",
22549
+ "_Unresolved questions for this Initiative._",
22550
+ "",
22551
+ "## Learning",
22552
+ "",
22553
+ "_Captured on completion: what was delivered, what stayed out of scope, outcome reached._",
22554
+ ""
22555
+ ].join("\n");
22556
+ }
22557
+ function buildInitiativeContent(id, input) {
22558
+ const status = input.status ?? "planned";
22559
+ if (!isValidInitiativeStatus(status)) {
22560
+ throw new InitiativeWriteError(`Invalid initiative status: ${status}.`);
22561
+ }
22562
+ const candidates = (input.candidates ?? []).map(
22563
+ (c, i) => normalizeCandidate(c, `WI-CANDIDATE-${String(i + 1).padStart(3, "0")}`)
22564
+ );
22565
+ const data = {
22566
+ type: "initiative",
22567
+ id,
22568
+ title: input.title.trim(),
22569
+ status,
22570
+ knowledge_level: input.knowledgeLevel ?? "K2",
22571
+ domains: input.domains ?? [],
22572
+ related_capabilities: input.relatedCapabilities ?? [],
22573
+ created_at: today2(),
22574
+ external_links: (input.externalLinks ?? []).map(externalLinkToData),
22575
+ candidates: candidates.map(candidateToData)
22576
+ };
22577
+ if (input.horizon) data.horizon = input.horizon;
22578
+ if (input.priority) data.priority = input.priority;
22579
+ if (input.source) data.source = input.source;
22580
+ if (input.sourceId) data.source_id = input.sourceId;
22581
+ return matter18.stringify("\n" + (input.body ?? defaultBody(input.title.trim())), data);
22582
+ }
22583
+ function createInitiative(dir, input) {
22584
+ if (!input.title?.trim()) throw new InitiativeWriteError("Initiative title is required.");
22585
+ const id = nextInitiativeId(dir);
22586
+ const fileName = `${id}-${slugify6(input.title)}.md`;
22587
+ const iniDir = join(dir, INITIATIVES_DIR);
22588
+ ensureDir(iniDir);
22589
+ const filePath = join(iniDir, fileName);
22590
+ const content = buildInitiativeContent(id, input);
22591
+ writeFile(filePath, content);
22592
+ const ini = parseInitiative(dir, filePath, content);
22593
+ if (!ini) throw new InitiativeWriteError("Failed to parse the Initiative just written.");
22594
+ return ini;
22595
+ }
22596
+ function transitionInitiative(dir, id, to) {
22597
+ const ini = getInitiative(dir, id);
22598
+ if (!ini) throw new InitiativeWriteError(`Initiative ${id} not found.`);
22599
+ if (!isValidInitiativeStatus(to)) throw new InitiativeWriteError(`Invalid status: ${to}.`);
22600
+ if (ini.status === to) return ini;
22601
+ if (!isValidInitiativeTransition(ini.status, to)) {
22602
+ throw new InitiativeWriteError(`Invalid transition ${ini.status} \u2192 ${to}.`);
22603
+ }
22604
+ const raw = readFile(ini.filePath);
22605
+ const { data, content } = matter18(raw, {});
22606
+ data.status = to;
22607
+ if (to === "completed") data.completed_at = today2();
22608
+ const newContent = matter18.stringify(content, data);
22609
+ writeFile(ini.filePath, newContent);
22610
+ const updated = parseInitiative(dir, ini.filePath, newContent);
22611
+ if (!updated) throw new InitiativeWriteError("Failed to parse the Initiative after transition.");
22612
+ return updated;
22613
+ }
22614
+ function nextWorkItemId3(dir) {
22615
+ const wiDir = join(dir, WORK_ITEMS_DIR4);
22616
+ let max = 0;
22617
+ const walk = (d) => {
22618
+ if (!exists(d)) return;
22619
+ for (const entry of readDir(d)) {
22620
+ const full = join(d, entry);
22621
+ if (isFile(full)) {
22622
+ const m = entry.match(/WI-(\d+)/);
22623
+ if (m) max = Math.max(max, parseInt(m[1], 10));
22624
+ } else if (!entry.startsWith(".")) {
22625
+ walk(full);
22626
+ }
22627
+ }
22628
+ };
22629
+ walk(wiDir);
22630
+ return `WI-${String(max + 1).padStart(3, "0")}`;
22631
+ }
22632
+ function buildWorkItemContent(wiId, iniId, candidate) {
22633
+ const data = {
22634
+ type: candidate.type ?? "feature",
22635
+ id: wiId,
22636
+ title: candidate.title,
22637
+ knowledge_level: candidate.suggestedKnowledgeLevel ?? "K2",
22638
+ status: "draft",
22639
+ phase: "now",
22640
+ initiative: iniId,
22641
+ domains: [],
22642
+ code: [],
22643
+ created_at: today2(),
22644
+ source: "initiative",
22645
+ source_id: candidate.id,
22646
+ source_initiative: iniId,
22647
+ affected_modules: []
22648
+ };
22649
+ if (candidate.sourceSignals.length) data.source_signals = candidate.sourceSignals;
22650
+ if (candidate.dependencies.length) data.dependencies = candidate.dependencies;
22651
+ const body = [
22652
+ `# ${candidate.title}`,
22653
+ "",
22654
+ `> Materialized from Initiative ${iniId}, candidate ${candidate.id}.`,
22655
+ "",
22656
+ "## Problem",
22657
+ "",
22658
+ candidate.expectedValue ? `_Expected value:_ ${candidate.expectedValue}` : "_Describe the problem._",
22659
+ "",
22660
+ "## Acceptance Criteria",
22661
+ "",
22662
+ "- [ ] _Define at least one testable criterion._",
22663
+ "",
22664
+ "## Out of scope",
22665
+ "",
22666
+ "_Not included in this Work Item._",
22667
+ "",
22668
+ "## Validation",
22669
+ "",
22670
+ "_How will this be validated?_",
22671
+ "",
22672
+ "## Learning",
22673
+ "",
22674
+ "_What did we learn? Update after completion._",
22675
+ ""
22676
+ ].join("\n");
22677
+ return matter18.stringify("\n" + body, data);
22678
+ }
22679
+ function materializeCandidate(dir, id, candidateId) {
22680
+ const ini = getInitiative(dir, id);
22681
+ if (!ini) throw new InitiativeWriteError(`Initiative ${id} not found.`);
22682
+ const candidate = ini.candidates.find((c) => c.id === candidateId);
22683
+ if (!candidate) throw new InitiativeWriteError(`Candidate ${candidateId} not found in ${id}.`);
22684
+ if (candidate.materializedAs) {
22685
+ throw new InitiativeWriteError(
22686
+ `Candidate ${candidateId} is already materialized as ${candidate.materializedAs}.`
22687
+ );
22688
+ }
22689
+ const wiId = nextWorkItemId3(dir);
22690
+ const fileName = `${wiId}-${slugify6(candidate.title)}.md`;
22691
+ ensureDir(join(dir, DRAFT_DIR2));
22692
+ writeFile(join(dir, DRAFT_DIR2, fileName), buildWorkItemContent(wiId, ini.id, candidate));
22693
+ const raw = readFile(ini.filePath);
22694
+ const { data, content } = matter18(raw, {});
22695
+ const cands = Array.isArray(data.candidates) ? data.candidates : [];
22696
+ for (const c of cands) {
22697
+ if (c && typeof c === "object" && String(c.id) === candidateId) c.materialized_as = wiId;
22698
+ }
22699
+ data.candidates = cands;
22700
+ const newContent = matter18.stringify(content, data);
22701
+ writeFile(ini.filePath, newContent);
22702
+ const updated = parseInitiative(dir, ini.filePath, newContent);
22703
+ if (!updated) throw new InitiativeWriteError("Failed to parse the Initiative after materialization.");
22704
+ return { workItemId: wiId, fileName, initiative: updated };
22705
+ }
22706
+
22707
+ // src/core/initiative-analysis.ts
22708
+ var SUCCESS_HEADING_RE = /^#{1,6}\s*(success criteria|criterios de[ét]xito|criterios de éxito)\s*$/i;
22709
+ var HEADING_RE2 = /^#{1,6}\s+/;
22710
+ var CHECK_ITEM_RE = /^\s*[-*]\s+\[([ xX])\]\s+(.*)$/;
22711
+ var BULLET_RE2 = /^\s*[-*]\s+(.*)$/;
22712
+ var PLACEHOLDER_RE = /^_.*_$/;
22713
+ function parseSuccessCriteria(body) {
22714
+ const lines = body.split(/\r?\n/);
22715
+ const out = [];
22716
+ let capture = false;
22717
+ for (const line of lines) {
22718
+ if (capture && HEADING_RE2.test(line)) break;
22719
+ if (!capture) {
22720
+ if (SUCCESS_HEADING_RE.test(line.trim())) capture = true;
22721
+ continue;
22722
+ }
22723
+ const check = line.match(CHECK_ITEM_RE);
22724
+ if (check) {
22725
+ const text2 = check[2].trim();
22726
+ if (text2 && !PLACEHOLDER_RE.test(text2)) {
22727
+ out.push({ text: text2, checked: check[1].toLowerCase() === "x" });
22728
+ }
22729
+ continue;
22730
+ }
22731
+ const bullet = line.match(BULLET_RE2);
22732
+ if (bullet) {
22733
+ const text2 = bullet[1].trim();
22734
+ if (text2 && !PLACEHOLDER_RE.test(text2)) out.push({ text: text2, checked: null });
22735
+ }
22736
+ }
22737
+ return out;
22738
+ }
22739
+ function analyzeInitiative(dir, ini) {
22740
+ const progress = computeInitiativeProgress(dir, ini);
22741
+ const successCriteria = parseSuccessCriteria(ini.body);
22742
+ const pendingCandidates = ini.candidates.filter((c) => !c.materializedAs);
22743
+ const associated = associatedWorkItems(dir, ini.id);
22744
+ const findings = [];
22745
+ if (successCriteria.length === 0) {
22746
+ findings.push({
22747
+ code: "no-success-criteria",
22748
+ severity: "warning",
22749
+ message: "The Initiative has no explicit Success Criteria; completion cannot be judged by outcome, only by delivery."
22750
+ });
22751
+ } else {
22752
+ const uncovered = successCriteria.filter((c) => c.checked === false);
22753
+ if (uncovered.length > 0) {
22754
+ findings.push({
22755
+ code: "uncovered-success-criteria",
22756
+ severity: "blocking",
22757
+ message: `${uncovered.length} success criterion/criteria remain uncovered.`,
22758
+ items: uncovered.map((c) => c.text)
22759
+ });
22760
+ }
22761
+ }
22762
+ if (pendingCandidates.length > 0) {
22763
+ findings.push({
22764
+ code: "pending-candidates",
22765
+ severity: "blocking",
22766
+ message: `${pendingCandidates.length} committed candidate(s) not yet materialized into Work Items.`,
22767
+ items: pendingCandidates.map((c) => `${c.id}: ${c.title}`)
22768
+ });
22769
+ }
22770
+ const notCompleted = associated.filter((w) => w.status !== "completed" && w.status !== "archived");
22771
+ if (associated.length === 0) {
22772
+ findings.push({
22773
+ code: "no-delivery",
22774
+ severity: "info",
22775
+ message: "No Work Items are associated with this Initiative yet."
22776
+ });
22777
+ } else if (notCompleted.length > 0) {
22778
+ findings.push({
22779
+ code: "incomplete-delivery",
22780
+ severity: "blocking",
22781
+ message: `${notCompleted.length} associated Work Item(s) are not completed.`,
22782
+ items: notCompleted.map((w) => `${w.id} (${w.status})`)
22783
+ });
22784
+ }
22785
+ return {
22786
+ initiative: ini.id,
22787
+ status: ini.status,
22788
+ progress,
22789
+ successCriteria,
22790
+ pendingCandidates,
22791
+ findings,
22792
+ suggestedCandidates: pendingCandidates
22793
+ };
22794
+ }
22795
+ function evaluateInitiativeCompletion(dir, ini) {
22796
+ const analysis = analyzeInitiative(dir, ini);
22797
+ const reasons = [];
22798
+ for (const f of analysis.findings) {
22799
+ if (f.severity === "blocking") reasons.push(f.message);
22800
+ }
22801
+ if (analysis.progress.delivery.total === 0 && analysis.pendingCandidates.length === 0) {
22802
+ reasons.push("Nothing has been delivered or committed under this Initiative.");
22803
+ }
22804
+ const ready = reasons.length === 0;
22805
+ return {
22806
+ initiative: ini.id,
22807
+ ready,
22808
+ readiness: ready ? "ready" : "not-ready",
22809
+ reasons
22810
+ };
22811
+ }
22812
+
22813
+ // src/commands/initiative.ts
22814
+ function requireInit(dir) {
22815
+ if (!loadConfig(dir)) {
22816
+ log.error("Kaddo is not initialized. Run `kaddo init` first.");
22817
+ process.exit(1);
22818
+ }
22819
+ }
22820
+ function runInitiativeList() {
22821
+ const dir = cwd();
22822
+ requireInit(dir);
22823
+ intro("kaddo initiative list");
22824
+ const all = discoverInitiatives(dir);
22825
+ if (all.length === 0) {
22826
+ log.info("No initiatives yet. Create one with `kaddo initiative create`.");
22827
+ outro("Nothing to show.");
22828
+ return;
22829
+ }
22830
+ for (const ini of all) {
22831
+ const p = computeInitiativeProgress(dir, ini);
22832
+ log.info(
22833
+ `${ini.id} \u2014 ${ini.title} [${ini.status}] planning ${p.planning.materialized}/${p.planning.totalCandidates} \xB7 delivery ${p.delivery.byState.completed}/${p.delivery.total} completed`
22834
+ );
22835
+ }
22836
+ outro(`${all.length} initiative(s).`);
22837
+ }
22838
+ function runInitiativeShow(id) {
22839
+ const dir = cwd();
22840
+ requireInit(dir);
22841
+ intro(`kaddo initiative show ${id}`);
22842
+ const ini = getInitiative(dir, id);
22843
+ if (!ini) {
22844
+ log.error(`Initiative ${id} not found.`);
22845
+ process.exit(1);
22846
+ }
22847
+ log.info(` ${ini.id} \u2014 ${ini.title}`);
22848
+ log.info(` Status: ${ini.status}`);
22849
+ if (ini.horizon) log.info(` Horizon: ${ini.horizon}`);
22850
+ if (ini.priority) log.info(` Priority: ${ini.priority}`);
22851
+ if (ini.domains.length) log.info(` Domains: ${ini.domains.join(", ")}`);
22852
+ if (ini.relatedCapabilities.length) log.info(` Capabilities: ${ini.relatedCapabilities.join(", ")}`);
22853
+ if (ini.source) log.info(` Source: ${ini.source}${ini.sourceId ? ` (${ini.sourceId})` : ""}`);
22854
+ log.info(` Candidates: ${ini.candidates.length}`);
22855
+ for (const c of ini.candidates) {
22856
+ log.info(` - ${c.id}: ${c.title}${c.materializedAs ? ` \u2192 ${c.materializedAs}` : " (pending)"}`);
22857
+ }
22858
+ outro(`Initiative ${ini.id}.`);
22859
+ }
22860
+ function runInitiativeProgress(id) {
22861
+ const dir = cwd();
22862
+ requireInit(dir);
22863
+ intro(`kaddo initiative progress ${id}`);
22864
+ const ini = getInitiative(dir, id);
22865
+ if (!ini) {
22866
+ log.error(`Initiative ${id} not found.`);
22867
+ process.exit(1);
22868
+ }
22869
+ const p = computeInitiativeProgress(dir, ini);
22870
+ log.info(` Status: ${p.status}`);
22871
+ log.info("");
22872
+ log.info(` Planning: ${p.planning.materialized}/${p.planning.totalCandidates} candidates materialized (${p.planning.remaining} remaining)`);
22873
+ log.info("");
22874
+ log.info(` Delivery: ${p.delivery.total} associated Work Items`);
22875
+ for (const [state, n] of Object.entries(p.delivery.byState)) {
22876
+ if (n > 0) log.info(` ${state}: ${n}`);
22877
+ }
22878
+ outro(`Progress for ${ini.id}.`);
22879
+ }
22880
+ function runInitiativeCandidates(id) {
22881
+ const dir = cwd();
22882
+ requireInit(dir);
22883
+ intro(`kaddo initiative candidates ${id}`);
22884
+ const ini = getInitiative(dir, id);
22885
+ if (!ini) {
22886
+ log.error(`Initiative ${id} not found.`);
22887
+ process.exit(1);
22888
+ }
22889
+ if (ini.candidates.length === 0) {
22890
+ log.info("No candidates on this initiative.");
22891
+ outro("Nothing to show.");
22892
+ return;
22893
+ }
22894
+ for (const c of ini.candidates) {
22895
+ log.info(` ${c.id}: ${c.title}${c.materializedAs ? ` \u2192 ${c.materializedAs}` : " (pending)"}`);
22896
+ if (c.expectedValue) log.info(` value: ${c.expectedValue}`);
22897
+ }
22898
+ outro(`${ini.candidates.length} candidate(s).`);
22899
+ }
22900
+ async function runInitiativeCreate(opts) {
22901
+ const dir = cwd();
22902
+ requireInit(dir);
22903
+ intro("kaddo initiative create");
22904
+ const title = opts.title?.trim() || (await text({
22905
+ message: "Initiative title",
22906
+ validate: (v) => v.trim().length === 0 ? "Title is required." : void 0
22907
+ })).trim();
22908
+ try {
22909
+ const ini = createInitiative(dir, { title });
22910
+ log.success(`Created ${ini.id} \u2014 ${ini.title}`);
22911
+ log.info(` knowledge/delivery/initiatives/`);
22912
+ outro(`Initiative ${ini.id} created.`);
22913
+ } catch (err) {
22914
+ log.error(err instanceof InitiativeWriteError ? err.message : String(err));
22915
+ process.exit(1);
22916
+ }
22917
+ }
22918
+ async function runInitiativeUpdate(id, opts) {
22919
+ const dir = cwd();
22920
+ requireInit(dir);
22921
+ intro(`kaddo initiative update ${id}`);
22922
+ const ini = getInitiative(dir, id);
22923
+ if (!ini) {
22924
+ log.error(`Initiative ${id} not found.`);
22925
+ process.exit(1);
22926
+ }
22927
+ const to = opts.status ?? await select({
22928
+ message: "New status",
22929
+ options: [
22930
+ { value: "planned", label: "planned" },
22931
+ { value: "in-progress", label: "in-progress" },
22932
+ { value: "completed", label: "completed" },
22933
+ { value: "deferred", label: "deferred" },
22934
+ { value: "cancelled", label: "cancelled" }
22935
+ ]
22936
+ });
22937
+ try {
22938
+ const updated = transitionInitiative(dir, id, to);
22939
+ log.success(`Status: ${updated.status}`);
22940
+ outro(`Initiative ${updated.id} updated.`);
22941
+ } catch (err) {
22942
+ log.error(err instanceof InitiativeWriteError ? err.message : String(err));
22943
+ process.exit(1);
22944
+ }
22945
+ }
22946
+ function runInitiativeAnalyze(id) {
22947
+ const dir = cwd();
22948
+ requireInit(dir);
22949
+ intro(`kaddo initiative analyze ${id}`);
22950
+ const ini = getInitiative(dir, id);
22951
+ if (!ini) {
22952
+ log.error(`Initiative ${id} not found.`);
22953
+ process.exit(1);
22954
+ }
22955
+ const analysis = analyzeInitiative(dir, ini);
22956
+ log.info(` Status: ${analysis.status}`);
22957
+ log.info(` Success criteria: ${analysis.successCriteria.length}`);
22958
+ log.info(` Planning: ${analysis.progress.planning.materialized}/${analysis.progress.planning.totalCandidates} materialized`);
22959
+ log.info(` Delivery: ${analysis.progress.delivery.byState.completed}/${analysis.progress.delivery.total} completed`);
22960
+ if (analysis.findings.length === 0) {
22961
+ log.success("No gaps detected.");
22962
+ } else {
22963
+ log.info("");
22964
+ for (const f of analysis.findings) {
22965
+ const line = ` [${f.severity}] ${f.message}`;
22966
+ if (f.severity === "blocking") log.warn(line);
22967
+ else log.info(line);
22968
+ for (const item of f.items ?? []) log.info(` - ${item}`);
22969
+ }
22970
+ }
22971
+ if (analysis.suggestedCandidates.length > 0) {
22972
+ log.info("");
22973
+ log.info(" Suggested (pending) candidates to materialize:");
22974
+ for (const c of analysis.suggestedCandidates) log.info(` - ${c.id}: ${c.title}`);
22975
+ }
22976
+ outro(`Analysis for ${ini.id}.`);
22977
+ }
22978
+ async function runInitiativeComplete(id, opts = {}) {
22979
+ const dir = cwd();
22980
+ requireInit(dir);
22981
+ intro(`kaddo initiative complete ${id}`);
22982
+ const ini = getInitiative(dir, id);
22983
+ if (!ini) {
22984
+ log.error(`Initiative ${id} not found.`);
22985
+ process.exit(1);
22986
+ }
22987
+ const readiness = evaluateInitiativeCompletion(dir, ini);
22988
+ if (readiness.ready) {
22989
+ log.success("Completion readiness: ready.");
22990
+ } else {
22991
+ log.warn("Completion readiness: NOT ready.");
22992
+ for (const r of readiness.reasons) log.warn(` - ${r}`);
22993
+ }
22994
+ if (!opts.yes) {
22995
+ log.info("");
22996
+ const proceed = await confirm({
22997
+ message: readiness.ready ? "Mark this Initiative as completed?" : "This Initiative is not ready. Complete it anyway?",
22998
+ initialValue: false
22999
+ });
23000
+ if (!proceed) {
23001
+ cancel("Cancelled. Initiative not completed.");
23002
+ return;
23003
+ }
23004
+ }
23005
+ try {
23006
+ const done = transitionInitiative(dir, id, "completed");
23007
+ log.success(`Status: ${done.status}`);
23008
+ outro(`Initiative ${done.id} completed.`);
23009
+ } catch (err) {
23010
+ log.error(err instanceof InitiativeWriteError ? err.message : String(err));
23011
+ process.exit(1);
23012
+ }
23013
+ }
23014
+ function runInitiativeMaterialize(id, candidateId) {
23015
+ const dir = cwd();
23016
+ requireInit(dir);
23017
+ intro(`kaddo initiative materialize ${id} ${candidateId}`);
23018
+ try {
23019
+ const result = materializeCandidate(dir, id, candidateId);
23020
+ log.success(`Materialized ${candidateId} \u2192 ${result.workItemId}`);
23021
+ log.info(` knowledge/delivery/work-items/draft/${result.fileName}`);
23022
+ log.info(` Associated to ${id} via \`initiative: ${id}\`.`);
23023
+ outro(`Work Item ${result.workItemId} created from candidate.`);
23024
+ } catch (err) {
23025
+ log.error(err instanceof InitiativeWriteError ? err.message : String(err));
23026
+ process.exit(1);
23027
+ }
23028
+ }
23029
+
22295
23030
  // src/index.ts
22296
23031
  var require2 = createRequire(import.meta.url);
22297
23032
  var { version } = require2("../package.json");
@@ -22469,6 +23204,34 @@ program.command("add [module]").description("Install an optional Kaddo module (a
22469
23204
  program.command("admin").description("Start Kaddo Admin \u2014 a local web interface for the project knowledge").option("--port <port>", "Server port (default: 4173)", parseInt).option("--host <host>", "Server host (default: 127.0.0.1)").option("--no-open", "Do not open the browser automatically").action(async (opts) => {
22470
23205
  await runAdmin({ port: opts.port, host: opts.host, noOpen: opts.open === false });
22471
23206
  });
23207
+ var initiativeCmd = program.command("initiative").description("Manage initiatives \u2014 the optional outcome layer over Work Items");
23208
+ initiativeCmd.command("list").description("List initiatives with planning and delivery progress").action(() => {
23209
+ runInitiativeList();
23210
+ });
23211
+ initiativeCmd.command("show <id>").description("Show an initiative, its metadata and candidates").action((id) => {
23212
+ runInitiativeShow(id);
23213
+ });
23214
+ initiativeCmd.command("progress <id>").description("Show planning coverage and delivery progress for an initiative").action((id) => {
23215
+ runInitiativeProgress(id);
23216
+ });
23217
+ initiativeCmd.command("candidates <id>").description("List the Work Item candidates of an initiative").action((id) => {
23218
+ runInitiativeCandidates(id);
23219
+ });
23220
+ initiativeCmd.command("create").description("Create a new initiative").option("--title <title>", "Initiative title (prompts if omitted)").action(async (opts) => {
23221
+ await runInitiativeCreate(opts);
23222
+ });
23223
+ initiativeCmd.command("update <id>").description("Update an initiative status (valid lifecycle transitions only)").option("--status <status>", "New status: planned, in-progress, completed, deferred, cancelled").action(async (id, opts) => {
23224
+ await runInitiativeUpdate(id, opts);
23225
+ });
23226
+ initiativeCmd.command("materialize <id> <candidateId>").description("Materialize an initiative candidate into a draft Work Item").action((id, candidateId) => {
23227
+ runInitiativeMaterialize(id, candidateId);
23228
+ });
23229
+ initiativeCmd.command("analyze <id>").description("Analyze an initiative: success-criteria coverage, gaps, and suggested candidates").action((id) => {
23230
+ runInitiativeAnalyze(id);
23231
+ });
23232
+ 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) => {
23233
+ await runInitiativeComplete(id, opts);
23234
+ });
22472
23235
  var telemetryCmd = program.command("telemetry").description("Manage anonymous usage telemetry");
22473
23236
  telemetryCmd.command("status").description("Show telemetry status (enabled, registered, pending events)").action(() => {
22474
23237
  runTelemetryStatus();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaddo/cli",
3
- "version": "3.105.0",
3
+ "version": "3.107.0",
4
4
  "description": "Knowledge Driven Development toolkit",
5
5
  "license": "MIT",
6
6
  "repository": {