@kaddo/cli 3.106.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 +109 -0
  2. package/dist/index.js +180 -0
  3. package/package.json +1 -1
package/dist/core.js CHANGED
@@ -12394,6 +12394,112 @@ function materializeRoadmapInitiative(dir, rmId) {
12394
12394
  candidates
12395
12395
  });
12396
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
+ }
12397
12503
  export {
12398
12504
  CURRENT_CONSENT_VERSION,
12399
12505
  INITIATIVES_DIR,
@@ -12412,6 +12518,7 @@ export {
12412
12518
  WorkItemWriteError,
12413
12519
  addCandidate,
12414
12520
  analyzeCrossRepoEvidence,
12521
+ analyzeInitiative,
12415
12522
  analyzeScopeCoverage,
12416
12523
  applyTopologyProposal,
12417
12524
  associatedWorkItems,
@@ -12441,6 +12548,7 @@ export {
12441
12548
  discoverWorkItems,
12442
12549
  enableIntegration,
12443
12550
  evaluateCompletion,
12551
+ evaluateInitiativeCompletion,
12444
12552
  exists,
12445
12553
  filterSecretPaths,
12446
12554
  findDuplicateByHash,
@@ -12489,6 +12597,7 @@ export {
12489
12597
  nextInitiativeId,
12490
12598
  parseContent,
12491
12599
  parseInitiative,
12600
+ parseSuccessCriteria,
12492
12601
  persistConsent,
12493
12602
  previewImport,
12494
12603
  readFile,
package/dist/index.js CHANGED
@@ -22704,6 +22704,112 @@ function materializeCandidate(dir, id, candidateId) {
22704
22704
  return { workItemId: wiId, fileName, initiative: updated };
22705
22705
  }
22706
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
+
22707
22813
  // src/commands/initiative.ts
22708
22814
  function requireInit(dir) {
22709
22815
  if (!loadConfig(dir)) {
@@ -22837,6 +22943,74 @@ async function runInitiativeUpdate(id, opts) {
22837
22943
  process.exit(1);
22838
22944
  }
22839
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
+ }
22840
23014
  function runInitiativeMaterialize(id, candidateId) {
22841
23015
  const dir = cwd();
22842
23016
  requireInit(dir);
@@ -23052,6 +23226,12 @@ initiativeCmd.command("update <id>").description("Update an initiative status (v
23052
23226
  initiativeCmd.command("materialize <id> <candidateId>").description("Materialize an initiative candidate into a draft Work Item").action((id, candidateId) => {
23053
23227
  runInitiativeMaterialize(id, candidateId);
23054
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
+ });
23055
23235
  var telemetryCmd = program.command("telemetry").description("Manage anonymous usage telemetry");
23056
23236
  telemetryCmd.command("status").description("Show telemetry status (enabled, registered, pending events)").action(() => {
23057
23237
  runTelemetryStatus();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaddo/cli",
3
- "version": "3.106.0",
3
+ "version": "3.107.0",
4
4
  "description": "Knowledge Driven Development toolkit",
5
5
  "license": "MIT",
6
6
  "repository": {