@kaddo/cli 3.127.0 → 3.129.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-CMM88Fvp.js → architectureDiagram-3BPJPVTR-DmExPmRV.js} +1 -1
  2. package/dist/admin-dist/assets/{chunk-727SXJPM-Bs62kBjZ.js → chunk-727SXJPM-TzlKi4JG.js} +1 -1
  3. package/dist/admin-dist/assets/{chunk-AQP2D5EJ-DRvPiKZx.js → chunk-AQP2D5EJ-uLib6NNt.js} +1 -1
  4. package/dist/admin-dist/assets/{classDiagram-v2-Q7XG4LA2-reL3VD_F.js → classDiagram-4FO5ZUOK-p84ByjtF.js} +1 -1
  5. package/dist/admin-dist/assets/{classDiagram-4FO5ZUOK-reL3VD_F.js → classDiagram-v2-Q7XG4LA2-p84ByjtF.js} +1 -1
  6. package/dist/admin-dist/assets/{dagre-BM42HDAG-BiSamapq.js → dagre-BM42HDAG-DfHID2Qj.js} +1 -1
  7. package/dist/admin-dist/assets/{diagram-2AECGRRQ-B4Icn510.js → diagram-2AECGRRQ-DDK0Mbu2.js} +1 -1
  8. package/dist/admin-dist/assets/{diagram-5GNKFQAL-CRhc2zde.js → diagram-5GNKFQAL-G7QIVN3E.js} +1 -1
  9. package/dist/admin-dist/assets/{diagram-LMA3HP47-CMeLXuDa.js → diagram-LMA3HP47-C1R6_2ZM.js} +1 -1
  10. package/dist/admin-dist/assets/{diagram-OG6HWLK6-CgyZ3SmF.js → diagram-OG6HWLK6-C2BKviiy.js} +1 -1
  11. package/dist/admin-dist/assets/{erDiagram-TEJ5UH35-DO8yBpvF.js → erDiagram-TEJ5UH35-BON2r_Ng.js} +1 -1
  12. package/dist/admin-dist/assets/{flowDiagram-I6XJVG4X-BMmW0ZfD.js → flowDiagram-I6XJVG4X-BupCBn3Y.js} +1 -1
  13. package/dist/admin-dist/assets/{ganttDiagram-6RSMTGT7-DfLBlZnZ.js → ganttDiagram-6RSMTGT7-D38vIu5c.js} +1 -1
  14. package/dist/admin-dist/assets/{index-Dot4bbKF.js → index-C0OcFqnH.js} +4 -4
  15. package/dist/admin-dist/assets/{infoDiagram-5YYISTIA-D4-F59aW.js → infoDiagram-5YYISTIA-Dg0XWL5A.js} +1 -1
  16. package/dist/admin-dist/assets/{ishikawaDiagram-YF4QCWOH-C4V7mlnH.js → ishikawaDiagram-YF4QCWOH-BmqtQz0f.js} +1 -1
  17. package/dist/admin-dist/assets/{kanban-definition-UN3LZRKU-TvjpEN_z.js → kanban-definition-UN3LZRKU-Q4XSbP4K.js} +1 -1
  18. package/dist/admin-dist/assets/{linear-Ceo1WLSG.js → linear-B8RusEEd.js} +1 -1
  19. package/dist/admin-dist/assets/{mindmap-definition-RKZ34NQL-Dp8dKxKQ.js → mindmap-definition-RKZ34NQL-CTC4EsvK.js} +1 -1
  20. package/dist/admin-dist/assets/{pieDiagram-4H26LBE5-DJcqowoN.js → pieDiagram-4H26LBE5-kbXjsg4R.js} +1 -1
  21. package/dist/admin-dist/assets/{quadrantDiagram-W4KKPZXB-1zF7s5vy.js → quadrantDiagram-W4KKPZXB-mSk4KLyQ.js} +1 -1
  22. package/dist/admin-dist/assets/{requirementDiagram-4Y6WPE33-Cfur45jl.js → requirementDiagram-4Y6WPE33-CibbOF7W.js} +1 -1
  23. package/dist/admin-dist/assets/{sequenceDiagram-3UESZ5HK-aantaPdN.js → sequenceDiagram-3UESZ5HK-q-174vfI.js} +1 -1
  24. package/dist/admin-dist/assets/{stateDiagram-AJRCARHV-ClWINPoO.js → stateDiagram-AJRCARHV-C7Puq4hY.js} +1 -1
  25. package/dist/admin-dist/assets/{stateDiagram-v2-BHNVJYJU-CAAGRYC1.js → stateDiagram-v2-BHNVJYJU-0x5B8-RG.js} +1 -1
  26. package/dist/admin-dist/assets/{timeline-definition-PNZ67QCA-BIYt-JNC.js → timeline-definition-PNZ67QCA-BTU1Sz9c.js} +1 -1
  27. package/dist/admin-dist/assets/{vennDiagram-CIIHVFJN-CCeVIZsB.js → vennDiagram-CIIHVFJN-CioUtDz7.js} +1 -1
  28. package/dist/admin-dist/assets/{wardleyDiagram-YWT4CUSO-B6hFn7xR.js → wardleyDiagram-YWT4CUSO-Bptd1Iun.js} +1 -1
  29. package/dist/admin-dist/assets/{xychartDiagram-2RQKCTM6-C4T-rH7k.js → xychartDiagram-2RQKCTM6-BP8nOU9q.js} +1 -1
  30. package/dist/admin-dist/index.html +1 -1
  31. package/dist/admin-server/index.js +6 -0
  32. package/dist/core.js +815 -52
  33. package/dist/index.js +854 -68
  34. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -818,8 +818,8 @@ function emptySignals() {
818
818
  environment: []
819
819
  };
820
820
  }
821
- function sig(type, label, confidence, evidence, extra) {
822
- return { type, label, confidence, evidence, ...extra };
821
+ function sig(type, label2, confidence, evidence, extra) {
822
+ return { type, label: label2, confidence, evidence, ...extra };
823
823
  }
824
824
  function readDeps(dir) {
825
825
  const pkgPath = join(dir, "package.json");
@@ -898,10 +898,10 @@ function detectAuth(dir, deps, codeDirs, signals) {
898
898
  ["@aws-amplify/auth", "AWS Amplify Auth"]
899
899
  ];
900
900
  const seen = /* @__PURE__ */ new Set();
901
- for (const [dep, label] of authDeps) {
902
- if (dep in deps && !seen.has(label)) {
903
- seen.add(label);
904
- signals.auth.push(sig("auth", label, "high", ["package.json"]));
901
+ for (const [dep, label2] of authDeps) {
902
+ if (dep in deps && !seen.has(label2)) {
903
+ seen.add(label2);
904
+ signals.auth.push(sig("auth", label2, "high", ["package.json"]));
905
905
  }
906
906
  }
907
907
  const authPaths = findPathsContaining(dir, codeDirs, ["auth", "login", "register", "signin", "signup", "session"], 3);
@@ -922,10 +922,10 @@ function detectPayments(dir, deps, codeDirs, signals) {
922
922
  ["square", "Square"]
923
923
  ];
924
924
  const seen = /* @__PURE__ */ new Set();
925
- for (const [dep, label] of payDeps) {
926
- if (dep in deps && !seen.has(label)) {
927
- seen.add(label);
928
- signals.payments.push(sig("payments", label, "high", ["package.json"]));
925
+ for (const [dep, label2] of payDeps) {
926
+ if (dep in deps && !seen.has(label2)) {
927
+ seen.add(label2);
928
+ signals.payments.push(sig("payments", label2, "high", ["package.json"]));
929
929
  }
930
930
  }
931
931
  const payPaths = findPathsContaining(dir, codeDirs, ["payment", "checkout", "billing", "invoice", "subscription", "pricing"], 3);
@@ -953,10 +953,10 @@ function detectStorage(dir, deps, codeDirs, signals) {
953
953
  ["@azure/storage-blob", "Azure Blob Storage"]
954
954
  ];
955
955
  const seen = /* @__PURE__ */ new Set();
956
- for (const [dep, label] of storageDeps) {
957
- if (dep in deps && !seen.has(label)) {
958
- seen.add(label);
959
- signals.storage.push(sig("storage", label, "high", ["package.json"]));
956
+ for (const [dep, label2] of storageDeps) {
957
+ if (dep in deps && !seen.has(label2)) {
958
+ seen.add(label2);
959
+ signals.storage.push(sig("storage", label2, "high", ["package.json"]));
960
960
  }
961
961
  }
962
962
  const storagePaths = findPathsContaining(dir, codeDirs, ["upload", "storage", "bucket"], 3);
@@ -975,9 +975,9 @@ function detectBackgroundJobs(dir, deps, codeDirs, signals) {
975
975
  ["node-cron", "Node-cron"],
976
976
  ["cron", "Cron"]
977
977
  ];
978
- for (const [dep, label] of jobDeps) {
978
+ for (const [dep, label2] of jobDeps) {
979
979
  if (dep in deps) {
980
- signals.background_jobs.push(sig("background_jobs", label, "high", ["package.json"]));
980
+ signals.background_jobs.push(sig("background_jobs", label2, "high", ["package.json"]));
981
981
  }
982
982
  }
983
983
  if (isDir(join(dir, "supabase", "functions"))) {
@@ -1013,9 +1013,9 @@ function detectEmail(dir, deps, signals) {
1013
1013
  ["mailgun-js", "Mailgun"],
1014
1014
  ["@mailchimp/mailchimp_transactional", "Mailchimp Transactional"]
1015
1015
  ];
1016
- for (const [dep, label] of emailDeps) {
1016
+ for (const [dep, label2] of emailDeps) {
1017
1017
  if (dep in deps) {
1018
- signals.email.push(sig("email", label, "high", ["package.json"]));
1018
+ signals.email.push(sig("email", label2, "high", ["package.json"]));
1019
1019
  }
1020
1020
  }
1021
1021
  }
@@ -1038,10 +1038,10 @@ function detectDatabase(dir, deps, signals) {
1038
1038
  ["@libsql/client", "Turso (LibSQL)"]
1039
1039
  ];
1040
1040
  const seen = /* @__PURE__ */ new Set();
1041
- for (const [dep, label] of dbDeps) {
1042
- if (dep in deps && !seen.has(label)) {
1043
- seen.add(label);
1044
- signals.database.push(sig("database", label, "high", ["package.json"]));
1041
+ for (const [dep, label2] of dbDeps) {
1042
+ if (dep in deps && !seen.has(label2)) {
1043
+ seen.add(label2);
1044
+ signals.database.push(sig("database", label2, "high", ["package.json"]));
1045
1045
  }
1046
1046
  }
1047
1047
  }
@@ -1088,9 +1088,9 @@ function detectTests(dir, testDirs, deps, signals) {
1088
1088
  ["mocha", "Mocha"],
1089
1089
  ["ava", "AVA"]
1090
1090
  ];
1091
- for (const [dep, label] of testFrameworks) {
1091
+ for (const [dep, label2] of testFrameworks) {
1092
1092
  if (dep in deps) {
1093
- signals.tests.push(sig("tests", label, "high", ["package.json"]));
1093
+ signals.tests.push(sig("tests", label2, "high", ["package.json"]));
1094
1094
  }
1095
1095
  }
1096
1096
  if (testDirs.length > 0) {
@@ -1110,9 +1110,9 @@ function detectSecurity(dir, deps, codeDirs, envVarNames, signals) {
1110
1110
  ["express-rate-limit", "Rate limiting"],
1111
1111
  ["@upstash/ratelimit", "Upstash Rate Limiting"]
1112
1112
  ];
1113
- for (const [dep, label] of secDeps) {
1113
+ for (const [dep, label2] of secDeps) {
1114
1114
  if (dep in deps) {
1115
- signals.security.push(sig("security", label, "high", ["package.json"]));
1115
+ signals.security.push(sig("security", label2, "high", ["package.json"]));
1116
1116
  }
1117
1117
  }
1118
1118
  const middlewarePaths = findPathsContaining(dir, codeDirs, ["middleware"], 2);
@@ -1138,8 +1138,8 @@ function detectSecurity(dir, deps, codeDirs, envVarNames, signals) {
1138
1138
  }
1139
1139
  function detectInfrastructure(dir, infraFiles, signals) {
1140
1140
  for (const f of infraFiles) {
1141
- const label = inferInfraLabel(f);
1142
- signals.infrastructure.push(sig("infrastructure", label, "high", [f]));
1141
+ const label2 = inferInfraLabel(f);
1142
+ signals.infrastructure.push(sig("infrastructure", label2, "high", [f]));
1143
1143
  }
1144
1144
  }
1145
1145
  function inferInfraLabel(f) {
@@ -1186,10 +1186,10 @@ function detectExternalIntegrations(deps, signals) {
1186
1186
  ["ioredis", "Redis"]
1187
1187
  ];
1188
1188
  const seen = /* @__PURE__ */ new Set();
1189
- for (const [dep, label] of integrations) {
1190
- if (dep in deps && !seen.has(label)) {
1191
- seen.add(label);
1192
- signals.external_integrations.push(sig("external_integrations", label, "high", ["package.json"]));
1189
+ for (const [dep, label2] of integrations) {
1190
+ if (dep in deps && !seen.has(label2)) {
1191
+ seen.add(label2);
1192
+ signals.external_integrations.push(sig("external_integrations", label2, "high", ["package.json"]));
1193
1193
  }
1194
1194
  }
1195
1195
  }
@@ -1267,13 +1267,13 @@ function renderSignalsCompact(signals) {
1267
1267
  ["external_integrations", "External integrations"],
1268
1268
  ["environment", "Environment"]
1269
1269
  ];
1270
- for (const [key, label] of CATEGORIES) {
1270
+ for (const [key, label2] of CATEGORIES) {
1271
1271
  const arr = signals[key];
1272
1272
  if (arr.length === 0) continue;
1273
1273
  if (arr.length === 1) {
1274
- lines.push(`- ${label}: ${arr[0].label}`);
1274
+ lines.push(`- ${label2}: ${arr[0].label}`);
1275
1275
  } else {
1276
- lines.push(`- ${label}: ${arr.length}`);
1276
+ lines.push(`- ${label2}: ${arr.length}`);
1277
1277
  }
1278
1278
  }
1279
1279
  return lines.length > 0 ? lines.join("\n") + "\n" : "No signals detected.\n";
@@ -1296,10 +1296,10 @@ function renderSignalsInventory(signals) {
1296
1296
  ["external_integrations", "External Integrations"],
1297
1297
  ["environment", "Environment"]
1298
1298
  ];
1299
- for (const [key, label] of CATEGORIES) {
1299
+ for (const [key, label2] of CATEGORIES) {
1300
1300
  const arr = signals[key];
1301
1301
  if (arr.length === 0) continue;
1302
- parts.push(`### ${label}
1302
+ parts.push(`### ${label2}
1303
1303
  `);
1304
1304
  for (const s of arr) {
1305
1305
  parts.push(`- ${s.label} \u2014 confidence: ${s.confidence}`);
@@ -1332,14 +1332,14 @@ function renderSignalsConsole(signals) {
1332
1332
  ["external_integrations", "Integrations"],
1333
1333
  ["environment", "Environment"]
1334
1334
  ];
1335
- for (const [key, label] of CATEGORIES) {
1335
+ for (const [key, label2] of CATEGORIES) {
1336
1336
  const arr = signals[key];
1337
1337
  if (arr.length === 0) continue;
1338
1338
  if (arr.length === 1) {
1339
1339
  const warning = arr[0].label.toLowerCase().includes("no test") ? " \u26A0" : "";
1340
- lines.push(` ${label}: ${arr[0].label}${warning}`);
1340
+ lines.push(` ${label2}: ${arr[0].label}${warning}`);
1341
1341
  } else {
1342
- lines.push(` ${label}: ${arr.map((s) => s.label).join(", ")}`);
1342
+ lines.push(` ${label2}: ${arr.map((s) => s.label).join(", ")}`);
1343
1343
  }
1344
1344
  }
1345
1345
  return lines;
@@ -3276,6 +3276,69 @@ After a POC has a canonical conclusion and Core has prepared its deterministic r
3276
3276
  15. Traceability and Sources
3277
3277
  `
3278
3278
  );
3279
+ var KNOWLEDGE_CONSOLIDATION = skill(
3280
+ "knowledge-consolidation",
3281
+ "Knowledge Consolidation Skill",
3282
+ "delivery",
3283
+ ["knowledge-consolidation-agent", "work-item-agent", "architecture-agent"],
3284
+ `
3285
+ # Knowledge Consolidation Skill
3286
+
3287
+ ## Purpose
3288
+
3289
+ Standardize the SEMANTIC review of a deterministic Consolidation Plan so canonical knowledge becomes
3290
+ more precise, connected, consistent and retrievable \u2014 without losing history, decisions or evidence.
3291
+
3292
+ ## When to use
3293
+
3294
+ After \`kaddo knowledge consolidate\` (or the \`kaddo_generate_consolidation_plan\` tool) has produced
3295
+ \`.kaddo/consolidation-plan.{md,json}\`, and a human or agent wants to review the opportunities and
3296
+ prepare refinements. Never as an autonomous rewrite of \`knowledge/\`.
3297
+
3298
+ ## Inputs
3299
+
3300
+ The Consolidation Plan (\`.kaddo/consolidation-plan.json\`), the referenced source artifacts, and the
3301
+ context pack. Each opportunity carries: category, classification, confidence, source/target, evidence,
3302
+ rationale, suggested action, and \`requires_semantic_review\`.
3303
+
3304
+ ## Output
3305
+
3306
+ For each opportunity the agent chooses to act on: a reviewable proposal that states what would change,
3307
+ what content is added/moved/summarized, what must be preserved, and which claims still need
3308
+ confirmation \u2014 with a diff or equivalent. No canonical file is edited by this skill; application goes
3309
+ through the existing controlled-edit flows after human approval.
3310
+
3311
+ ## Rules
3312
+
3313
+ - Distinguish \`observed\` (verifiable fact) from \`suggested\` (a candidate needing judgement). Never
3314
+ present a \`suggested\` candidate as a verified conclusion.
3315
+ - Classify every claim as Observed / Derived / Suggested / Unknown.
3316
+ - Do not merge Business/Product/Tech just because they share a topic \u2014 preserve layer responsibilities.
3317
+ - Do not move every historical learning into current knowledge; incorporate only live rules, WITH a
3318
+ reference back to the originating Work Item. Never summarize or delete the Work Item.
3319
+ - Do not invent relationships, decisions or business rules; a missing optional relationship is an
3320
+ opportunity, not an error.
3321
+ - For a potential inconsistency, present BOTH sources and say whether the conflict is verified or
3322
+ potential. Never pick a winner arbitrarily.
3323
+ - Preserve critical constraints, decisions and reasons, exceptions, known risks, technical contracts,
3324
+ implementation evidence, provenance and necessary history.
3325
+ - Never reveal secret values or resolve secret references; never connect to a Project Resource.
3326
+ - Do not commit, push or release automatically.
3327
+
3328
+ ## Quality checklist
3329
+
3330
+ - Every proposal cites its source artifact(s) and evidence.
3331
+ - Facts are separated from interpretations.
3332
+ - Preserved information is named explicitly.
3333
+ - Claims needing confirmation are flagged.
3334
+ - No canonical artifact was modified by the analysis or the review.
3335
+
3336
+ ## Example output
3337
+
3338
+ A short set of proposals, each with evidence, a before/after (or diff) and an explicit list of what
3339
+ must be preserved, ready for human approval.
3340
+ `
3341
+ );
3279
3342
  var SKILLS = [
3280
3343
  ADR_WRITING,
3281
3344
  WORK_ITEM_REFINEMENT,
@@ -3287,10 +3350,11 @@ var SKILLS = [
3287
3350
  MODULE_CONTEXT_REFINEMENT,
3288
3351
  EVIDENCE_VERIFICATION,
3289
3352
  LEGACY_RISK_ASSESSMENT,
3290
- POC_REPORT_WRITING
3353
+ POC_REPORT_WRITING,
3354
+ KNOWLEDGE_CONSOLIDATION
3291
3355
  ];
3292
3356
  var SKILL_GROUPS = {
3293
- delivery: ["work-item-refinement", "implementation-planning", "learning-capture", "evidence-verification", "legacy-risk-assessment", "poc-report-writing"],
3357
+ delivery: ["work-item-refinement", "implementation-planning", "learning-capture", "evidence-verification", "legacy-risk-assessment", "poc-report-writing", "knowledge-consolidation"],
3294
3358
  tech: ["adr-writing", "ownership-suggestion", "graph-metadata-review", "module-context-refinement"],
3295
3359
  integration: ["capsule-writing"]
3296
3360
  };
@@ -3502,6 +3566,24 @@ var RESPONSIBILITY_MATRIX = {
3502
3566
  ],
3503
3567
  next: ["kaddo graph export"]
3504
3568
  },
3569
+ "knowledge-consolidation-agent": {
3570
+ agent: "knowledge-consolidation-agent",
3571
+ responsibleFor: [
3572
+ "Semantic review of the deterministic Consolidation Plan",
3573
+ "Preparing reviewable knowledge refinements"
3574
+ ],
3575
+ produces: ["proposed refinements (before/after) for human approval"],
3576
+ canSuggest: ["kaddo knowledge consolidate"],
3577
+ cannotSuggest: [
3578
+ "code",
3579
+ "git",
3580
+ "commits",
3581
+ "modifying canonical knowledge without confirmation",
3582
+ "inventing facts or relationships",
3583
+ "deleting history"
3584
+ ],
3585
+ next: ["kaddo knowledge consolidate"]
3586
+ },
3505
3587
  "ownership-agent": {
3506
3588
  agent: "ownership-agent",
3507
3589
  responsibleFor: ["Precise code: ownership for Work Items and artifacts"],
@@ -5662,6 +5744,78 @@ ADRs) and re-runs \`kaddo graph export\`.
5662
5744
  - No files were modified; no Git was run.
5663
5745
  - The human is asked to confirm and re-export the graph.
5664
5746
  `;
5747
+ var KNOWLEDGE_CONSOLIDATION_AGENT = `# Knowledge Consolidation Agent
5748
+
5749
+ ## Role
5750
+
5751
+ You are the Kaddo Knowledge Consolidation Agent. Your job is to perform the **semantic review** of
5752
+ the deterministic **Consolidation Plan** produced by \`kaddo knowledge consolidate\`, and to prepare
5753
+ **reviewable refinements** that make canonical knowledge more precise, connected, consistent and
5754
+ retrievable \u2014 without losing history, decisions or evidence.
5755
+
5756
+ You do not write code, you do not modify canonical files, and you never run Git. You propose; a human
5757
+ confirms, and application goes through Kaddo's existing controlled-edit flows.
5758
+
5759
+ ## When to Use
5760
+
5761
+ Use this agent after \`kaddo knowledge consolidate\` (or the \`kaddo_generate_consolidation_plan\`
5762
+ tool) has produced \`.kaddo/consolidation-plan.md\` and \`.kaddo/consolidation-plan.json\`, and the
5763
+ plan contains opportunities flagged \`requires_semantic_review\`.
5764
+
5765
+ ## Input Required
5766
+
5767
+ Provide \`.kaddo/context-pack.md\` and \`.kaddo/consolidation-plan.json\` as the primary inputs, plus
5768
+ the source artifacts each opportunity references under \`knowledge/\` (and completed Work Items under
5769
+ \`knowledge/delivery/work-items/completed/\` for learning opportunities).
5770
+
5771
+ ## Expected Output
5772
+
5773
+ For each opportunity you choose to act on, a proposal that states what would change, what content is
5774
+ added / moved / summarized, what must be preserved, and which claims still need confirmation \u2014 with a
5775
+ diff or equivalent before/after.
5776
+
5777
+ ## Instructions
5778
+
5779
+ 1. Read the plan and work one opportunity at a time, highest-signal first.
5780
+ 2. Separate what you **observe** in the files from what you **suggest** \u2014 never present a suggested
5781
+ candidate as a verified conclusion.
5782
+ 3. For possible redundancy, compare the actual sections; propose a single reference location only if
5783
+ one genuinely restates the other. Preserve layer separation (Business / Product / Tech / Delivery).
5784
+ 4. For an unincorporated learning, decide whether it is a live rule; if so, propose incorporating it
5785
+ into the right Tech artifact **with a reference back to the originating Work Item**. Never summarize
5786
+ or delete the Work Item.
5787
+ 5. For a relationship opportunity, propose the relationship only when existing knowledge justifies it;
5788
+ a missing optional relationship is an opportunity, not an error.
5789
+ 6. For a potential inconsistency, present **both** sources and say whether the conflict is verified or
5790
+ potential. Do not pick a winner arbitrarily.
5791
+ 7. Classify every claim as Observed / Derived / Suggested / Unknown, and mark what needs confirmation.
5792
+
5793
+ ## Constraints
5794
+
5795
+ - Do **not** modify canonical files \u2014 propose changes for a human to apply.
5796
+ - Do **not** invent facts, relationships, decisions or business rules.
5797
+ - Do **not** delete historical information, change Work Item states, or alter verification results.
5798
+ - Do **not** reveal secret values or resolve secret references; do **not** connect to a Project Resource.
5799
+ - Do **not** run Git, commit, push or release.
5800
+
5801
+ ## Output Format
5802
+
5803
+ Per opportunity: the opportunity id, classification and confidence, the proposed before/after (or
5804
+ diff), the explicit list of what must be preserved, and the open questions that need confirmation.
5805
+
5806
+ ## Where to Save the Result
5807
+
5808
+ Nothing is saved automatically. The human reviews the proposals and applies the approved ones through
5809
+ Kaddo's existing controlled-edit flows. Re-run \`kaddo knowledge consolidate\` afterwards to confirm.
5810
+
5811
+ ## Quality Checklist
5812
+
5813
+ - Every proposal cites its source artifact(s) and evidence from the plan.
5814
+ - Facts are separated from interpretations; suggested candidates are never asserted as fact.
5815
+ - Preserved information (constraints, decisions, exceptions, risks, contracts, provenance) is named.
5816
+ - No canonical artifact was modified; no Git was run.
5817
+ - The human is asked to confirm before anything is applied.
5818
+ `;
5665
5819
  var AGENT_PROMPTS = [
5666
5820
  { fileName: "capability-agent.md", content: CAPABILITY_AGENT },
5667
5821
  { fileName: "architecture-agent.md", content: ARCHITECTURE_AGENT },
@@ -5688,7 +5842,9 @@ var AGENT_PROMPTS = [
5688
5842
  // Knowledge Capsule refinement (external context — VS-054)
5689
5843
  { fileName: "capsule-agent.md", content: CAPSULE_AGENT },
5690
5844
  // Graph relationship quality (metadata hints → precise front matter — VS-056)
5691
- { fileName: "graph-agent.md", content: GRAPH_AGENT }
5845
+ { fileName: "graph-agent.md", content: GRAPH_AGENT },
5846
+ // Knowledge Consolidation semantic review (deterministic plan → reviewable refinements — WI-070)
5847
+ { fileName: "knowledge-consolidation-agent.md", content: KNOWLEDGE_CONSOLIDATION_AGENT }
5692
5848
  // Every official prompt ends with its responsibility boundaries + Agent Trace footer.
5693
5849
  ].map((p) => ({ fileName: p.fileName, content: withResponsibilityTrace(p.fileName, p.content) }));
5694
5850
 
@@ -5714,7 +5870,8 @@ var AGENT_GROUPS = {
5714
5870
  "work-item-agent.md",
5715
5871
  "implementation-agent.md",
5716
5872
  "ownership-agent.md",
5717
- "git-strategy-agent.md"
5873
+ "git-strategy-agent.md",
5874
+ "knowledge-consolidation-agent.md"
5718
5875
  ],
5719
5876
  utilities: ["legacy-agent.md"]
5720
5877
  };
@@ -8322,15 +8479,15 @@ function printCIJson(dir, touchedFiles, activeMatches, ignoredCount, pluginSigna
8322
8479
  plugin_signals: pluginSignals,
8323
8480
  domain_owners: affectedOwners,
8324
8481
  findings: activeMatches.map((m) => {
8325
- const label = artifactLabel(m.artifact, dir);
8482
+ const label2 = artifactLabel(m.artifact, dir);
8326
8483
  return {
8327
- artifact_id: label,
8484
+ artifact_id: label2,
8328
8485
  artifact_type: m.artifact.type,
8329
8486
  knowledge_level: m.artifact.knowledgeLevel,
8330
8487
  matched_files: m.matchedFiles,
8331
8488
  ownership: m.artifact.codeGlobs,
8332
8489
  evidence: m.evidence.signals,
8333
- message: `${label} was not modified in this diff`
8490
+ message: `${label2} was not modified in this diff`
8334
8491
  };
8335
8492
  })
8336
8493
  };
@@ -11386,6 +11543,29 @@ var RESOURCE_TYPES = [
11386
11543
  "other"
11387
11544
  ];
11388
11545
  var INTERFACE_TYPES = ["cli", "mcp", "api", "sql", "sdk", "iac", "console", "other"];
11546
+ var REDACTED_COORDINATE = "\u2022\u2022\u2022\u2022 (hidden \u2014 store as an authentication reference)";
11547
+ var SECRET_KEY_RE = /(pass(word|phrase)?|secret|token|api[_-]?key|\bkey\b|credential|private|auth[_-]?token|access[_-]?key)/i;
11548
+ var SECRET_VALUE_PATTERNS = [
11549
+ /\b(AKIA|ASIA)[A-Z0-9]{8,}/,
11550
+ // AWS access key id
11551
+ /\b(ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{20,}/,
11552
+ // GitHub tokens
11553
+ /\bxox[baprs]-[A-Za-z0-9-]{10,}/,
11554
+ // Slack tokens
11555
+ /\bsk-[A-Za-z0-9]{16,}/,
11556
+ // OpenAI-style secret keys
11557
+ /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\./,
11558
+ // JWT
11559
+ /\w+=[^;\s]{6,}/,
11560
+ // key=value credential fragments
11561
+ /^[A-Za-z0-9+/]{40,}={0,2}$/
11562
+ // long opaque base64 blob
11563
+ ];
11564
+ function looksLikeSecretCoordinate(key, value) {
11565
+ if (SECRET_KEY_RE.test(key)) return true;
11566
+ const v = value.trim();
11567
+ return SECRET_VALUE_PATTERNS.some((re) => re.test(v));
11568
+ }
11389
11569
  function str(v) {
11390
11570
  return typeof v === "string" && v.trim() ? v.trim() : null;
11391
11571
  }
@@ -11414,6 +11594,29 @@ function parseInterfaces(v) {
11414
11594
  }
11415
11595
  return out;
11416
11596
  }
11597
+ function parseConnectionProfiles(v) {
11598
+ if (!Array.isArray(v)) return [];
11599
+ const out = [];
11600
+ for (const raw of v) {
11601
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) continue;
11602
+ const o = raw;
11603
+ const coords = [];
11604
+ const rawCoords = o.coordinates;
11605
+ if (rawCoords && typeof rawCoords === "object" && !Array.isArray(rawCoords)) {
11606
+ for (const [key, val] of Object.entries(rawCoords)) {
11607
+ const k = key.trim();
11608
+ const value = val == null ? "" : String(val).trim();
11609
+ if (!k || !value) continue;
11610
+ coords.push({ key: k, value: looksLikeSecretCoordinate(k, value) ? REDACTED_COORDINATE : value });
11611
+ }
11612
+ }
11613
+ const environment = str(o.environment);
11614
+ const iface = str(o.interface);
11615
+ if (!environment && !iface && coords.length === 0) continue;
11616
+ out.push({ environment, interface: iface, coordinates: coords });
11617
+ }
11618
+ return out;
11619
+ }
11417
11620
  function parseBoundaries(v) {
11418
11621
  if (!v || typeof v !== "object" || Array.isArray(v)) return {};
11419
11622
  const out = {};
@@ -11462,6 +11665,7 @@ function toDetail(filePath, relPath, raw) {
11462
11665
  const a = parseAuth(fm2.authentication);
11463
11666
  return { authRefs: a.refs, authMode: a.mode };
11464
11667
  })(),
11668
+ connectionProfiles: parseConnectionProfiles(fm2.connection_profiles),
11465
11669
  markdownBody: body
11466
11670
  };
11467
11671
  }
@@ -13864,7 +14068,7 @@ var KNOWLEDGE_FILES2 = [
13864
14068
  function buildReadinessReport(dir, now = /* @__PURE__ */ new Date()) {
13865
14069
  const config = loadConfig(dir);
13866
14070
  const rec = resolveNextStep(dir, now);
13867
- const stub = (overall2, label, command) => ({
14071
+ const stub = (overall2, label2, command) => ({
13868
14072
  project_name: config?.project.name ?? "unknown",
13869
14073
  project_type: config?.project.state ?? "unknown",
13870
14074
  overall: overall2,
@@ -13887,7 +14091,7 @@ function buildReadinessReport(dir, now = /* @__PURE__ */ new Date()) {
13887
14091
  resolved_questions: 0,
13888
14092
  deferred_questions: 0
13889
14093
  },
13890
- recommended_next_step: { label, ...command ? { command } : {} },
14094
+ recommended_next_step: { label: label2, ...command ? { command } : {} },
13891
14095
  nextStepRecommendation: rec
13892
14096
  });
13893
14097
  if (!config) return stub("not-initialized", rec.label, rec.command);
@@ -14067,9 +14271,9 @@ function installedAssetsSummary(dir) {
14067
14271
  // src/core/roadmap-quality.ts
14068
14272
  var ROADMAP_PATH2 = "knowledge/delivery/roadmap.md";
14069
14273
  var INITIATIVE_RE2 = /^#{2,4}\s+(RM-[\w.-]+)\s*[:\-–]?\s*(.*)$/;
14070
- function fieldPresent(lines, label) {
14274
+ function fieldPresent(lines, label2) {
14071
14275
  for (let i = 0; i < lines.length; i++) {
14072
- const m = lines[i].match(new RegExp(`^\\s*[-*]?\\s*(?:\\*\\*)?\\s*(${label.source})\\s*(?:\\*\\*)?\\s*:\\s*(.*)$`, "i"));
14276
+ const m = lines[i].match(new RegExp(`^\\s*[-*]?\\s*(?:\\*\\*)?\\s*(${label2.source})\\s*(?:\\*\\*)?\\s*:\\s*(.*)$`, "i"));
14073
14277
  if (!m) continue;
14074
14278
  const inline = m[2].trim();
14075
14279
  if (inline) return true;
@@ -16257,11 +16461,11 @@ function renderContextPack(pack) {
16257
16461
  if (mixEntries.length > 0) {
16258
16462
  parts.push("## Delivery Mix\n");
16259
16463
  parts.push("Active Work Items by type:\n");
16260
- const label = (t) => {
16464
+ const label2 = (t) => {
16261
16465
  const c = t.charAt(0).toUpperCase() + t.slice(1);
16262
16466
  return c.endsWith("s") ? c : `${c}s`;
16263
16467
  };
16264
- parts.push(mixEntries.map(([t, n]) => `- ${label(t)}: ${n}`).join("\n") + "\n");
16468
+ parts.push(mixEntries.map(([t, n]) => `- ${label2(t)}: ${n}`).join("\n") + "\n");
16265
16469
  }
16266
16470
  parts.push("## Artifacts and Ownership\n");
16267
16471
  if (knowledge.artifacts.length > 0) {
@@ -17619,18 +17823,18 @@ function readProjectState(dir) {
17619
17823
  }
17620
17824
  }
17621
17825
  function selectAgentModuleFiles(files, opts, state) {
17622
- const { files: names, label } = selectAgentFiles({ all: opts.all, group: opts.group, state });
17826
+ const { files: names, label: label2 } = selectAgentFiles({ all: opts.all, group: opts.group, state });
17623
17827
  const wanted = new Set(names);
17624
17828
  const selected = files.filter(
17625
17829
  (f) => f.path.endsWith("README.md") || names.some((n) => f.path.endsWith(n)) || wanted.has(f.path)
17626
17830
  );
17627
- return { files: selected, label };
17831
+ return { files: selected, label: label2 };
17628
17832
  }
17629
17833
  function selectSkillModuleFiles(files, opts) {
17630
- const { ids, label } = selectSkills({ all: opts.all, group: opts.group });
17834
+ const { ids, label: label2 } = selectSkills({ all: opts.all, group: opts.group });
17631
17835
  const wanted = new Set(ids.map((id) => skillInstallPath(id)));
17632
17836
  const selected = files.filter((f) => f.path.endsWith("README.md") || wanted.has(f.path));
17633
- return { files: selected, label };
17837
+ return { files: selected, label: label2 };
17634
17838
  }
17635
17839
  function markModuleInstalled(dir, configKey, moduleName) {
17636
17840
  const configPath = join(dir, CONFIG_PATH7);
@@ -19175,6 +19379,20 @@ function validateResource(dir, input) {
19175
19379
  findings.push({ level: "warning", message: `Unknown access interface type "${i.type}".` });
19176
19380
  }
19177
19381
  }
19382
+ for (const p of input.connectionProfiles ?? []) {
19383
+ const where = p.environment ? ` in environment "${p.environment}"` : "";
19384
+ for (const c of p.coordinates ?? []) {
19385
+ const key = (c?.key ?? "").trim();
19386
+ const value = (c?.value ?? "").trim();
19387
+ if (!key || !value) continue;
19388
+ if (looksLikeSecretCoordinate(key, value)) {
19389
+ findings.push({
19390
+ level: "error",
19391
+ message: `Connection coordinate "${key}"${where} looks like a secret value. Store credentials as authentication references, not connection coordinates.`
19392
+ });
19393
+ }
19394
+ }
19395
+ }
19178
19396
  const mapped = loadMappedModules(dir).map((m) => m.id);
19179
19397
  if (mapped.length > 0) {
19180
19398
  const refs = /* @__PURE__ */ new Set();
@@ -19201,6 +19419,22 @@ function buildFrontmatter(id, input, base = {}) {
19201
19419
  if (input.modules != null) data.modules = input.modules;
19202
19420
  if (input.accessInterfaces != null) data.access_interfaces = input.accessInterfaces;
19203
19421
  if (input.accessBoundaries != null) data.access_boundaries = input.accessBoundaries;
19422
+ if (input.connectionProfiles != null) {
19423
+ data.connection_profiles = input.connectionProfiles.map((p) => {
19424
+ const coordinates = {};
19425
+ for (const c of p.coordinates ?? []) {
19426
+ const key = (c?.key ?? "").trim();
19427
+ const value = (c?.value ?? "").trim();
19428
+ if (!key || !value || looksLikeSecretCoordinate(key, value)) continue;
19429
+ coordinates[key] = value;
19430
+ }
19431
+ const entry = {};
19432
+ if (p.environment?.trim()) entry.environment = p.environment.trim();
19433
+ if (p.interface?.trim()) entry.interface = p.interface.trim();
19434
+ if (Object.keys(coordinates).length) entry.coordinates = coordinates;
19435
+ return entry;
19436
+ }).filter((e) => Object.keys(e).length > 0);
19437
+ }
19204
19438
  if (input.authentication != null) {
19205
19439
  const mode = input.authentication.mode;
19206
19440
  const refs = sanitizeRefs(input.authentication.refs);
@@ -19343,8 +19577,8 @@ function runResourcesGet(id, dir = cwd(), opts = {}) {
19343
19577
  console.log(" Access interfaces:");
19344
19578
  for (const i of r.interfaces) {
19345
19579
  const tool = i.tool ?? i.provider ?? "";
19346
- const label = tool ? `${i.type} (${tool})` : i.type;
19347
- console.log(` - ${label}`);
19580
+ const label2 = tool ? `${i.type} (${tool})` : i.type;
19581
+ console.log(` - ${label2}`);
19348
19582
  if (i.purpose) console.log(` purpose: ${i.purpose}`);
19349
19583
  if (i.operations.length > 0) console.log(` operations: ${i.operations.join(", ")}`);
19350
19584
  if (i.environments.length > 0) console.log(` environments: ${i.environments.join(", ")}`);
@@ -21161,9 +21395,9 @@ function renderImpactMarkdown(r, opts = {}) {
21161
21395
  ["validation section", gp.missing_validation]
21162
21396
  ];
21163
21397
  L.push("## Historical Documentation Completeness", "");
21164
- for (const [label, items] of historical) {
21398
+ for (const [label2, items] of historical) {
21165
21399
  const completed = items.filter((item) => item.status === "completed");
21166
- if (completed.length > 0) L.push(`- Completed Work Items without detected ${label}: ${completed.length}`);
21400
+ if (completed.length > 0) L.push(`- Completed Work Items without detected ${label2}: ${completed.length}`);
21167
21401
  }
21168
21402
  if (!historical.some(([, items]) => items.some((item) => item.status === "completed"))) {
21169
21403
  L.push("No historical documentation completeness gaps were detected.");
@@ -25704,6 +25938,554 @@ async function runVerify(workItemId, opts = {}) {
25704
25938
  if (!opts.json) outro("Verification complete.");
25705
25939
  }
25706
25940
 
25941
+ // src/core/knowledge-consolidation.ts
25942
+ import { createHash as createHash2 } from "crypto";
25943
+ import matter26 from "gray-matter";
25944
+ var KNOWLEDGE6 = "knowledge";
25945
+ var CONSOLIDATION_CATEGORIES = [
25946
+ "knowledge_redundancy",
25947
+ "unincorporated_learning",
25948
+ "knowledge_fragmentation",
25949
+ "relationship_opportunity",
25950
+ "potentially_outdated",
25951
+ "knowledge_organization"
25952
+ ];
25953
+ function toPosix7(p) {
25954
+ return p.replace(/\\/g, "/");
25955
+ }
25956
+ function relFromDir(dir, filePath) {
25957
+ const d = toPosix7(dir).replace(/\/+$/, "");
25958
+ const f = toPosix7(filePath);
25959
+ return f.startsWith(d + "/") ? f.slice(d.length + 1) : f;
25960
+ }
25961
+ function sha256(content) {
25962
+ return createHash2("sha256").update(content, "utf-8").digest("hex");
25963
+ }
25964
+ var GENERIC_HEADINGS = /* @__PURE__ */ new Set([
25965
+ "purpose",
25966
+ "proposito",
25967
+ "prop\xF3sito",
25968
+ "intent",
25969
+ "goal",
25970
+ "objetivo",
25971
+ "summary",
25972
+ "resumen",
25973
+ "overview",
25974
+ "context",
25975
+ "contexto",
25976
+ "scope",
25977
+ "alcance",
25978
+ "out of scope",
25979
+ "fuera de alcance",
25980
+ "acceptance criteria",
25981
+ "criterios de aceptacion",
25982
+ "criterios de aceptaci\xF3n",
25983
+ "validation",
25984
+ "validation scenarios",
25985
+ "validacion",
25986
+ "validaci\xF3n",
25987
+ "escenarios de validacion",
25988
+ "escenarios de validaci\xF3n",
25989
+ "notes",
25990
+ "notas",
25991
+ "references",
25992
+ "referencias",
25993
+ "examples",
25994
+ "ejemplos",
25995
+ "learning",
25996
+ "learnings",
25997
+ "aprendizaje",
25998
+ "aprendizajes",
25999
+ // Work Item template sections
26000
+ "problem",
26001
+ "problema",
26002
+ "expected result",
26003
+ "resultado esperado",
26004
+ "refinement",
26005
+ "refinamiento",
26006
+ "implementation guidance",
26007
+ "guia de implementacion",
26008
+ "gu\xEDa de implementaci\xF3n",
26009
+ "definition of done",
26010
+ "definicion de hecho",
26011
+ "definici\xF3n de hecho",
26012
+ "commit gate",
26013
+ "future evolution",
26014
+ "evolucion futura",
26015
+ "evoluci\xF3n futura",
26016
+ "guiding principle",
26017
+ "principio rector",
26018
+ "open questions",
26019
+ "preguntas abiertas",
26020
+ "dependencies",
26021
+ "dependencias",
26022
+ "conceptual model",
26023
+ "goal"
26024
+ ]);
26025
+ var RULE_KEYWORDS = [
26026
+ "siempre",
26027
+ "nunca",
26028
+ "debe",
26029
+ "deben",
26030
+ "requiere",
26031
+ "requieren",
26032
+ "invariante",
26033
+ "restriccion",
26034
+ "restricci\xF3n",
26035
+ "regla",
26036
+ "obligatorio",
26037
+ "must",
26038
+ "always",
26039
+ "never",
26040
+ "require",
26041
+ "requires",
26042
+ "constraint",
26043
+ "invariant",
26044
+ "rule"
26045
+ ];
26046
+ function normalizeHeading(h) {
26047
+ return h.trim().toLowerCase().replace(/\s+/g, " ");
26048
+ }
26049
+ function distinctiveHeadings(body) {
26050
+ const out = [];
26051
+ for (const line of body.split(/\r?\n/)) {
26052
+ const m = line.match(/^#{2,3}\s+(.+?)\s*$/);
26053
+ if (!m) continue;
26054
+ const norm = normalizeHeading(m[1]);
26055
+ if (!norm || GENERIC_HEADINGS.has(norm)) continue;
26056
+ out.push(norm);
26057
+ }
26058
+ return [...new Set(out)];
26059
+ }
26060
+ function sectionBody(body, titles) {
26061
+ const lines = body.split(/\r?\n/);
26062
+ const re = new RegExp(`^#{1,3}\\s+(${titles.join("|")})\\s*$`, "i");
26063
+ const start = lines.findIndex((l) => re.test(l));
26064
+ if (start < 0) return null;
26065
+ const collected = [];
26066
+ for (let i = start + 1; i < lines.length; i++) {
26067
+ if (/^#{1,3}\s+/.test(lines[i])) break;
26068
+ collected.push(lines[i]);
26069
+ }
26070
+ const text2 = collected.join("\n").trim();
26071
+ return text2.length > 0 ? text2 : null;
26072
+ }
26073
+ function stableOpportunityId(category, sources) {
26074
+ const key = [category, ...[...sources].sort()].join("|");
26075
+ return `${category}:${sha256(key).slice(0, 12)}`;
26076
+ }
26077
+ function layerOf(a) {
26078
+ const byType = layerForType(a.type);
26079
+ if (byType) return byType;
26080
+ const p = toPosix7(a.filePath);
26081
+ if (p.includes(`/${KNOWLEDGE6}/business/`)) return "Business";
26082
+ if (p.includes(`/${KNOWLEDGE6}/product/`)) return "Product";
26083
+ if (p.includes(`/${KNOWLEDGE6}/tech/`)) return "Tech";
26084
+ if (p.includes(`/${KNOWLEDGE6}/delivery/`)) return "Delivery";
26085
+ return null;
26086
+ }
26087
+ function inScope(la, scope) {
26088
+ if (scope.kind === "all") return true;
26089
+ if (scope.kind === "layer") return la.layer === scope.layer;
26090
+ return la.artifact.affectedModules.includes(scope.module);
26091
+ }
26092
+ function label(la) {
26093
+ return la.artifact.id || la.rel;
26094
+ }
26095
+ function buildConsolidationPlan(dir, opts = {}) {
26096
+ requireConfig(dir);
26097
+ const scope = opts.scope ?? { kind: "all" };
26098
+ const now = opts.now ?? /* @__PURE__ */ new Date();
26099
+ const archDir = join(dir, KNOWLEDGE6);
26100
+ const rawArtifacts = exists(archDir) ? readArtifacts(archDir) : [];
26101
+ const loaded = rawArtifacts.map((a) => {
26102
+ let body = "";
26103
+ try {
26104
+ body = matter26(readFile(a.filePath)).content;
26105
+ } catch {
26106
+ body = "";
26107
+ }
26108
+ return { artifact: a, rel: relFromDir(dir, a.filePath), body, layer: layerOf(a) };
26109
+ });
26110
+ const scoped = loaded.filter((la) => inScope(la, scope));
26111
+ const scopedRels = new Set(scoped.map((la) => la.rel));
26112
+ const knownIds = new Set(loaded.map((la) => la.artifact.id).filter(Boolean));
26113
+ const opportunities = [];
26114
+ try {
26115
+ const config = requireConfig(dir);
26116
+ const graph = buildGraph(dir, config, { scope: "all" }, now);
26117
+ const hints = buildGraphHints(dir, graph, now);
26118
+ for (const hint of hints.hints) {
26119
+ if (!hintInScope(hint, scoped)) continue;
26120
+ opportunities.push(relationshipOpportunityFromHint(hint));
26121
+ }
26122
+ } catch {
26123
+ }
26124
+ for (const la of scoped) {
26125
+ const dangling = la.artifact.decisions.filter((d) => d && !knownIds.has(d) && !decisionFileExists(dir, d));
26126
+ if (dangling.length === 0) continue;
26127
+ opportunities.push({
26128
+ id: stableOpportunityId("potentially_outdated", [label(la), ...dangling]),
26129
+ category: "potentially_outdated",
26130
+ classification: "observed",
26131
+ confidence: "requires-review",
26132
+ title: `${label(la)} references decision(s) that no longer exist`,
26133
+ source_artifacts: [label(la)],
26134
+ target_artifacts: [label(la)],
26135
+ evidence: dangling.map((d) => `Declared decision \`${d}\` has no matching artifact in the project.`),
26136
+ rationale: "A reference to a missing decision is a verifiable inconsistency: either the decision artifact was removed/renamed or the reference is stale.",
26137
+ possible_impact: "Broken traceability between a Work Item/artifact and its decisions.",
26138
+ suggested_action: "Review and update or remove the dangling decision reference.",
26139
+ requires_semantic_review: false
26140
+ });
26141
+ }
26142
+ const canonical = scoped.filter(
26143
+ (la) => la.layer !== null && !isWorkItem(la) && la.artifact.type !== "roadmap"
26144
+ );
26145
+ const byHeading = /* @__PURE__ */ new Map();
26146
+ for (const la of canonical) {
26147
+ for (const h of distinctiveHeadings(la.body)) {
26148
+ const arr = byHeading.get(h) ?? [];
26149
+ arr.push(la);
26150
+ byHeading.set(h, arr);
26151
+ }
26152
+ }
26153
+ const pairHeadings = /* @__PURE__ */ new Map();
26154
+ for (const [heading, arts] of byHeading) {
26155
+ if (arts.length < 2) continue;
26156
+ for (let i = 0; i < arts.length; i++) {
26157
+ for (let j = i + 1; j < arts.length; j++) {
26158
+ if (arts[i].rel === arts[j].rel) continue;
26159
+ const key = [arts[i].rel, arts[j].rel].sort().join("||");
26160
+ const entry = pairHeadings.get(key) ?? { a: arts[i], b: arts[j], shared: /* @__PURE__ */ new Set() };
26161
+ entry.shared.add(heading);
26162
+ pairHeadings.set(key, entry);
26163
+ }
26164
+ }
26165
+ }
26166
+ for (const { a, b, shared } of pairHeadings.values()) {
26167
+ if (shared.size < 2) continue;
26168
+ opportunities.push({
26169
+ id: stableOpportunityId("knowledge_redundancy", [label(a), label(b)]),
26170
+ category: "knowledge_redundancy",
26171
+ classification: "suggested",
26172
+ confidence: "requires-review",
26173
+ title: `Possible overlapping content between ${label(a)} and ${label(b)}`,
26174
+ source_artifacts: [label(a), label(b)],
26175
+ target_artifacts: [label(a), label(b)],
26176
+ evidence: [`Both artifacts declare the sections: ${[...shared].sort().join(", ")}.`],
26177
+ rationale: "Shared section titles are a hint of potential overlap, NOT proof of duplication. Two documents can legitimately address the same topic from different layers/responsibilities.",
26178
+ possible_impact: "If genuinely duplicated, the same fact can drift out of sync across files.",
26179
+ suggested_action: "Semantic review: compare the sections; if one restates the other, keep a single reference location and link the rest. Preserve layer separation.",
26180
+ requires_semantic_review: true
26181
+ });
26182
+ }
26183
+ for (const la of scoped) {
26184
+ if (!isCompletedWorkItem(la)) continue;
26185
+ const learning = sectionBody(la.body, ["Learning", "Aprendizaje", "Aprendizajes", "Learnings"]);
26186
+ if (!learning) continue;
26187
+ if (!looksLikeDurableRule(learning)) continue;
26188
+ opportunities.push({
26189
+ id: stableOpportunityId("unincorporated_learning", [label(la)]),
26190
+ category: "unincorporated_learning",
26191
+ classification: "suggested",
26192
+ confidence: "requires-review",
26193
+ title: `${label(la)} captured a learning that may belong in current knowledge`,
26194
+ source_artifacts: [label(la)],
26195
+ target_artifacts: ["knowledge/tech/codebase.md"],
26196
+ evidence: [`Completed Work Item records a rule-like learning: "${firstSentence(learning)}"`],
26197
+ rationale: "A learning phrased as a durable rule MAY represent live technical knowledge not yet reflected in Tech Knowledge. This is a candidate, not a confirmed gap.",
26198
+ possible_impact: "A relevant constraint stays buried in delivery history instead of informing current work.",
26199
+ suggested_action: "Semantic review: decide whether this learning is a live rule; if so, incorporate it into the right Tech artifact WITH a reference back to the Work Item. Do not delete or summarize the Work Item.",
26200
+ requires_semantic_review: true
26201
+ });
26202
+ }
26203
+ const weakByFolder = /* @__PURE__ */ new Map();
26204
+ for (const la of scoped) {
26205
+ const quality = safeQuality(dir, la.rel);
26206
+ if (quality === "placeholder" || quality === "weak") {
26207
+ opportunities.push({
26208
+ id: stableOpportunityId("knowledge_organization", [la.rel]),
26209
+ category: "knowledge_organization",
26210
+ classification: "observed",
26211
+ confidence: "requires-review",
26212
+ title: `${label(la)} is ${quality} and may need consolidation or expansion`,
26213
+ source_artifacts: [label(la)],
26214
+ target_artifacts: [label(la)],
26215
+ evidence: [`Artifact quality analysis classifies this artifact as "${quality}".`],
26216
+ rationale: "Low-signal artifacts reduce retrieval quality. This is an observed quality signal, not a judgement that the content is wrong.",
26217
+ possible_impact: "Readers must open more files to assemble a complete picture.",
26218
+ suggested_action: "Review whether to expand, merge into a stronger artifact, or cross-reference it.",
26219
+ requires_semantic_review: false
26220
+ });
26221
+ const folder = la.rel.split("/").slice(0, -1).join("/");
26222
+ const arr = weakByFolder.get(folder) ?? [];
26223
+ arr.push(la);
26224
+ weakByFolder.set(folder, arr);
26225
+ }
26226
+ }
26227
+ for (const [folder, arts] of weakByFolder) {
26228
+ if (arts.length < 3) continue;
26229
+ opportunities.push({
26230
+ id: stableOpportunityId("knowledge_fragmentation", arts.map((a) => a.rel)),
26231
+ category: "knowledge_fragmentation",
26232
+ classification: "suggested",
26233
+ confidence: "requires-review",
26234
+ title: `${folder}/ holds ${arts.length} low-signal artifacts \u2014 possible fragmentation`,
26235
+ source_artifacts: arts.map((a) => label(a)),
26236
+ target_artifacts: [folder],
26237
+ evidence: [`${arts.length} placeholder/weak artifacts in the same folder: ${arts.map((a) => a.rel.split("/").pop()).join(", ")}.`],
26238
+ rationale: "Several thin artifacts in one folder MAY be easier to consume if consolidated or cross-linked. Consolidation must preserve each distinct responsibility.",
26239
+ possible_impact: "Related knowledge is spread across too many files to follow.",
26240
+ suggested_action: "Semantic review: evaluate whether cross-references or a consolidation would add clarity. Do not merge by file count alone.",
26241
+ requires_semantic_review: true
26242
+ });
26243
+ }
26244
+ opportunities.sort((x, y) => {
26245
+ const ci = CONSOLIDATION_CATEGORIES.indexOf(x.category) - CONSOLIDATION_CATEGORIES.indexOf(y.category);
26246
+ return ci !== 0 ? ci : x.id.localeCompare(y.id);
26247
+ });
26248
+ const seen = /* @__PURE__ */ new Set();
26249
+ const deduped = opportunities.filter((o) => seen.has(o.id) ? false : (seen.add(o.id), true));
26250
+ const layers = discoverLayers(dir);
26251
+ const layersEvaluated = scope.kind === "layer" ? [scope.layer] : layers.map((l) => l.layer);
26252
+ const workItemsEvaluated = scoped.filter(isWorkItem).length;
26253
+ const sourceFiles = [...scopedRels].sort().map((rel) => ({ path: rel, hash: sha256(readFileSafe(join(dir, rel))) }));
26254
+ const byCategory = Object.fromEntries(
26255
+ CONSOLIDATION_CATEGORIES.map((c) => [c, deduped.filter((o) => o.category === c).length])
26256
+ );
26257
+ return {
26258
+ generated_at: now.toISOString(),
26259
+ scope: describeScope(scope),
26260
+ project_context: reportingProjectContext(dir),
26261
+ coverage: {
26262
+ scope: describeScope(scope),
26263
+ layers_evaluated: layersEvaluated,
26264
+ artifacts_evaluated: scoped.length,
26265
+ work_items_evaluated: workItemsEvaluated,
26266
+ excluded_sources: scope.kind === "all" ? [] : [...loaded.map((l) => l.rel)].filter((r) => !scopedRels.has(r)).sort()
26267
+ },
26268
+ source_files: sourceFiles,
26269
+ opportunities: deduped,
26270
+ summary: {
26271
+ total: deduped.length,
26272
+ by_category: byCategory,
26273
+ requires_semantic_review: deduped.filter((o) => o.requires_semantic_review).length
26274
+ }
26275
+ };
26276
+ }
26277
+ var CATEGORY_LABELS = {
26278
+ knowledge_redundancy: "Possible redundancy",
26279
+ unincorporated_learning: "Learning integration opportunity",
26280
+ knowledge_fragmentation: "Possible fragmentation",
26281
+ relationship_opportunity: "Relationship review hint",
26282
+ potentially_outdated: "Potential inconsistency",
26283
+ knowledge_organization: "Organization opportunity"
26284
+ };
26285
+ function renderConsolidationMarkdown(plan) {
26286
+ const lines = [];
26287
+ lines.push("# Knowledge Consolidation Plan");
26288
+ lines.push("");
26289
+ lines.push("> Derived, review-only projection. No canonical knowledge was modified by this analysis.");
26290
+ lines.push("");
26291
+ lines.push(`- Generated at: ${plan.generated_at}`);
26292
+ lines.push(`- Scope: ${plan.scope}`);
26293
+ lines.push(`- Project: state=${plan.project_context.state}, mode=${plan.project_context.mode}, structure=${plan.project_context.repository_structure}`);
26294
+ lines.push("");
26295
+ lines.push("## Coverage");
26296
+ lines.push("");
26297
+ lines.push(`- Layers evaluated: ${plan.coverage.layers_evaluated.join(", ") || "\u2014"}`);
26298
+ lines.push(`- Artifacts evaluated: ${plan.coverage.artifacts_evaluated}`);
26299
+ lines.push(`- Work Items evaluated: ${plan.coverage.work_items_evaluated}`);
26300
+ if (plan.coverage.excluded_sources.length > 0) {
26301
+ lines.push(`- Excluded from this scope: ${plan.coverage.excluded_sources.length} artifact(s)`);
26302
+ }
26303
+ lines.push("");
26304
+ lines.push("## Findings");
26305
+ lines.push("");
26306
+ if (plan.summary.total === 0) {
26307
+ lines.push("No consolidation opportunities were detected by the available deterministic analyses within this scope.");
26308
+ lines.push("");
26309
+ lines.push("This is not a claim that the knowledge is perfect \u2014 only that no opportunity was found with the current signals.");
26310
+ lines.push("");
26311
+ return lines.join("\n") + "\n";
26312
+ }
26313
+ for (const cat of CONSOLIDATION_CATEGORIES) {
26314
+ const n = plan.summary.by_category[cat];
26315
+ if (n > 0) lines.push(`- ${n} \xD7 ${CATEGORY_LABELS[cat]}`);
26316
+ }
26317
+ lines.push("");
26318
+ lines.push(`${plan.summary.requires_semantic_review} finding(s) require semantic (agent/human) review before acting.`);
26319
+ lines.push("");
26320
+ lines.push("## Opportunities");
26321
+ lines.push("");
26322
+ for (const o of plan.opportunities) {
26323
+ lines.push(`### ${o.title}`);
26324
+ lines.push("");
26325
+ lines.push(`- Id: \`${o.id}\``);
26326
+ lines.push(`- Category: ${o.category}`);
26327
+ lines.push(`- Classification: **${o.classification}**${o.requires_semantic_review ? " (requires semantic review)" : ""}`);
26328
+ lines.push(`- Confidence: ${o.confidence}`);
26329
+ lines.push(`- Source: ${o.source_artifacts.join(", ") || "\u2014"}`);
26330
+ lines.push(`- Suggested target: ${o.target_artifacts.join(", ") || "\u2014"}`);
26331
+ lines.push(`- Evidence:`);
26332
+ for (const e of o.evidence) lines.push(` - ${e}`);
26333
+ lines.push(`- Rationale: ${o.rationale}`);
26334
+ lines.push(`- Possible impact: ${o.possible_impact}`);
26335
+ lines.push(`- Suggested action: ${o.suggested_action}`);
26336
+ lines.push("");
26337
+ }
26338
+ return lines.join("\n") + "\n";
26339
+ }
26340
+ function serializeConsolidationJson(plan) {
26341
+ return JSON.stringify(plan, null, 2) + "\n";
26342
+ }
26343
+ function describeScope(scope) {
26344
+ if (scope.kind === "all") return "all";
26345
+ if (scope.kind === "layer") return `layer:${scope.layer}`;
26346
+ return `module:${scope.module}`;
26347
+ }
26348
+ function isWorkItem(la) {
26349
+ return toPosix7(la.artifact.filePath).includes("/delivery/work-items/");
26350
+ }
26351
+ function isCompletedWorkItem(la) {
26352
+ const p = toPosix7(la.artifact.filePath);
26353
+ return p.includes("/delivery/work-items/completed/") || isWorkItem(la) && la.artifact.status === "completed";
26354
+ }
26355
+ function looksLikeDurableRule(text2) {
26356
+ const lower = text2.toLowerCase();
26357
+ return RULE_KEYWORDS.some((k) => new RegExp(`(^|[^a-z\xE1\xE9\xED\xF3\xFA\xF1])${k}([^a-z\xE1\xE9\xED\xF3\xFA\xF1]|$)`, "i").test(lower));
26358
+ }
26359
+ function firstSentence(text2) {
26360
+ const flat = text2.replace(/\s+/g, " ").trim();
26361
+ const m = flat.match(/^(.{0,200}?[.!?])(\s|$)/);
26362
+ const s = (m ? m[1] : flat).slice(0, 200);
26363
+ return redactSecrets2(s.trim());
26364
+ }
26365
+ var SECRET_TOKEN_PATTERNS = [
26366
+ /\bgh[pours]_[A-Za-z0-9]{16,}\b/g,
26367
+ // GitHub tokens
26368
+ /\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g,
26369
+ // AWS access key ids
26370
+ /\bxox[baprs]-[A-Za-z0-9-]{10,}\b/g,
26371
+ // Slack tokens
26372
+ /\bsk-[A-Za-z0-9]{16,}\b/g,
26373
+ // OpenAI-style keys
26374
+ /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g,
26375
+ // JWTs
26376
+ /\b[A-Za-z0-9+/]{40,}={0,2}\b/g
26377
+ // long base64 / opaque blobs
26378
+ ];
26379
+ function redactSecrets2(text2) {
26380
+ let out = text2;
26381
+ for (const re of SECRET_TOKEN_PATTERNS) out = out.replace(re, "[redacted]");
26382
+ return out;
26383
+ }
26384
+ function safeQuality(dir, rel) {
26385
+ try {
26386
+ return analyzeKnowledgeArtifact(dir, rel);
26387
+ } catch {
26388
+ return "useful";
26389
+ }
26390
+ }
26391
+ function readFileSafe(abs) {
26392
+ try {
26393
+ return readFile(abs);
26394
+ } catch {
26395
+ return "";
26396
+ }
26397
+ }
26398
+ function decisionFileExists(dir, decisionId) {
26399
+ const decisionsDir = join(dir, KNOWLEDGE6, "tech", "decisions");
26400
+ if (!exists(decisionsDir)) return false;
26401
+ try {
26402
+ return readDir(decisionsDir).some((e) => {
26403
+ const full = join(decisionsDir, e);
26404
+ if (!isFile(full) || !e.endsWith(".md")) return false;
26405
+ return e.toLowerCase().includes(decisionId.toLowerCase());
26406
+ });
26407
+ } catch {
26408
+ return false;
26409
+ }
26410
+ }
26411
+ function hintInScope(hint, scoped) {
26412
+ if (scoped.length === 0) return false;
26413
+ return scoped.some(
26414
+ (la) => la.artifact.id === hint.artifact_id || hint.path && toPosix7(la.artifact.filePath).endsWith(toPosix7(hint.path))
26415
+ );
26416
+ }
26417
+ function relationshipOpportunityFromHint(hint) {
26418
+ const finding = graphHintFinding(hint);
26419
+ return {
26420
+ id: stableOpportunityId("relationship_opportunity", [hint.artifact_id, ...hint.missing]),
26421
+ category: "relationship_opportunity",
26422
+ classification: "observed",
26423
+ confidence: "requires-review",
26424
+ title: hint.message,
26425
+ source_artifacts: [hint.artifact_id],
26426
+ target_artifacts: [hint.artifact_id],
26427
+ evidence: [finding.evidence],
26428
+ rationale: "A missing OPTIONAL relationship is an opportunity to review, not an error or a verified inconsistency. Kaddo never invents the relationship.",
26429
+ possible_impact: "Weaker traceability in the knowledge graph.",
26430
+ suggested_action: finding.suggested_action,
26431
+ requires_semantic_review: false
26432
+ };
26433
+ }
26434
+
26435
+ // src/commands/knowledge.ts
26436
+ var LAYER_BY_FLAG = {
26437
+ business: "Business",
26438
+ product: "Product",
26439
+ tech: "Tech",
26440
+ delivery: "Delivery"
26441
+ };
26442
+ function resolveScope(opts) {
26443
+ if (opts.module) return { kind: "module", module: opts.module };
26444
+ if (opts.layer) {
26445
+ const layer2 = LAYER_BY_FLAG[opts.layer.toLowerCase()];
26446
+ if (!layer2) {
26447
+ throw new Error(`Unknown --layer "${opts.layer}". Use one of: business, product, tech, delivery.`);
26448
+ }
26449
+ return { kind: "layer", layer: layer2 };
26450
+ }
26451
+ return { kind: "all" };
26452
+ }
26453
+ function runKnowledgeConsolidate(opts = {}) {
26454
+ const dir = cwd();
26455
+ requireConfig(dir);
26456
+ intro("kaddo knowledge consolidate");
26457
+ if (opts.scope && opts.scope !== "all" && !opts.layer && !opts.module) {
26458
+ log.warn(`Unrecognized --scope "${opts.scope}"; analyzing the whole project. Use --layer or --module for a narrower scope.`);
26459
+ }
26460
+ const scope = resolveScope(opts);
26461
+ const plan = buildConsolidationPlan(dir, { scope });
26462
+ ensureDir(join(dir, ".kaddo"));
26463
+ const mdRel = join(".kaddo", "consolidation-plan.md");
26464
+ const jsonRel = join(".kaddo", "consolidation-plan.json");
26465
+ writeFile(join(dir, mdRel), renderConsolidationMarkdown(plan));
26466
+ writeFile(join(dir, jsonRel), serializeConsolidationJson(plan));
26467
+ log.success(`Consolidation analysis complete (scope: ${plan.scope}).`);
26468
+ log.info(
26469
+ `Artifacts evaluated: ${plan.coverage.artifacts_evaluated} \xB7 Work Items: ${plan.coverage.work_items_evaluated} \xB7 Opportunities: ${plan.summary.total}`
26470
+ );
26471
+ if (plan.summary.total === 0) {
26472
+ log.info("No consolidation opportunities detected within this scope by the available analyses.");
26473
+ log.info("This is not a claim of perfection \u2014 only that no opportunity surfaced with the current signals.");
26474
+ } else {
26475
+ for (const cat of CONSOLIDATION_CATEGORIES) {
26476
+ const n = plan.summary.by_category[cat];
26477
+ if (n > 0) log.info(`- ${n} \xD7 ${cat}`);
26478
+ }
26479
+ log.warn(
26480
+ `${plan.summary.requires_semantic_review} finding(s) require semantic review (agent/human) before acting \u2014 nothing was changed automatically.`
26481
+ );
26482
+ }
26483
+ log.info(`- ${mdRel.replace(/\\/g, "/")}`);
26484
+ log.info(`- ${jsonRel.replace(/\\/g, "/")}`);
26485
+ printCommandFooter("knowledge consolidate");
26486
+ outro("Consolidation Plan ready for review.");
26487
+ }
26488
+
25707
26489
  // src/core/telemetry.ts
25708
26490
  import crypto6 from "crypto";
25709
26491
 
@@ -25975,7 +26757,7 @@ function runTelemetryDisable() {
25975
26757
  }
25976
26758
 
25977
26759
  // src/core/initiative-write.ts
25978
- import matter26 from "gray-matter";
26760
+ import matter27 from "gray-matter";
25979
26761
  var WORK_ITEMS_DIR4 = "knowledge/delivery/work-items";
25980
26762
  var DRAFT_DIR2 = `${WORK_ITEMS_DIR4}/draft`;
25981
26763
  var InitiativeWriteError = class extends Error {
@@ -26087,7 +26869,7 @@ function buildInitiativeContent(id, input) {
26087
26869
  if (input.priority) data.priority = input.priority;
26088
26870
  if (input.source) data.source = input.source;
26089
26871
  if (input.sourceId) data.source_id = input.sourceId;
26090
- return matter26.stringify("\n" + (input.body ?? defaultBody(input.title.trim())), data);
26872
+ return matter27.stringify("\n" + (input.body ?? defaultBody(input.title.trim())), data);
26091
26873
  }
26092
26874
  function createInitiative(dir, input) {
26093
26875
  if (!input.title?.trim()) throw new InitiativeWriteError("Initiative title is required.");
@@ -26111,10 +26893,10 @@ function transitionInitiative(dir, id, to) {
26111
26893
  throw new InitiativeWriteError(`Invalid transition ${ini.status} \u2192 ${to}.`);
26112
26894
  }
26113
26895
  const raw = readFile(ini.filePath);
26114
- const { data, content } = matter26(raw, {});
26896
+ const { data, content } = matter27(raw, {});
26115
26897
  data.status = to;
26116
26898
  if (to === "completed") data.completed_at = today2();
26117
- const newContent = matter26.stringify(content, data);
26899
+ const newContent = matter27.stringify(content, data);
26118
26900
  writeFile(ini.filePath, newContent);
26119
26901
  const updated = parseInitiative(dir, ini.filePath, newContent);
26120
26902
  if (!updated) throw new InitiativeWriteError("Failed to parse the Initiative after transition.");
@@ -26183,7 +26965,7 @@ function buildWorkItemContent(wiId, iniId, candidate) {
26183
26965
  "_What did we learn? Update after completion._",
26184
26966
  ""
26185
26967
  ].join("\n");
26186
- return matter26.stringify("\n" + body, data);
26968
+ return matter27.stringify("\n" + body, data);
26187
26969
  }
26188
26970
  function materializeCandidate(dir, id, candidateId) {
26189
26971
  const ini = getInitiative(dir, id);
@@ -26200,13 +26982,13 @@ function materializeCandidate(dir, id, candidateId) {
26200
26982
  ensureDir(join(dir, DRAFT_DIR2));
26201
26983
  writeFile(join(dir, DRAFT_DIR2, fileName), buildWorkItemContent(wiId, ini.id, candidate));
26202
26984
  const raw = readFile(ini.filePath);
26203
- const { data, content } = matter26(raw, {});
26985
+ const { data, content } = matter27(raw, {});
26204
26986
  const cands = Array.isArray(data.candidates) ? data.candidates : [];
26205
26987
  for (const c of cands) {
26206
26988
  if (c && typeof c === "object" && String(c.id) === candidateId) c.materialized_as = wiId;
26207
26989
  }
26208
26990
  data.candidates = cands;
26209
- const newContent = matter26.stringify(content, data);
26991
+ const newContent = matter27.stringify(content, data);
26210
26992
  writeFile(ini.filePath, newContent);
26211
26993
  const updated = parseInitiative(dir, ini.filePath, newContent);
26212
26994
  if (!updated) throw new InitiativeWriteError("Failed to parse the Initiative after materialization.");
@@ -26575,6 +27357,10 @@ var graphCmd = program.command("graph").description("Export the lightweight, fil
26575
27357
  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) => {
26576
27358
  runGraphExport(opts);
26577
27359
  });
27360
+ var knowledgeCmd = program.command("knowledge").description("Operate on the canonical knowledge base (consolidation analysis \u2014 read-only, no LLM)");
27361
+ knowledgeCmd.command("consolidate").description("Analyze canonical knowledge and write a reviewable Consolidation Plan to .kaddo/ (no changes to knowledge/)").option("--layer <layer>", "Limit the analysis to one layer: business, product, tech, delivery").option("--module <id>", "Limit the analysis to artifacts affecting one mapped module").option("--scope <scope>", "Analysis scope: all (default)").action((opts) => {
27362
+ runKnowledgeConsolidate(opts);
27363
+ });
26578
27364
  var topologyCmd = program.command("topology").description("Validate and apply a semantic system topology proposal (agent proposes, human confirms, Core applies)");
26579
27365
  topologyCmd.command("validate <file>").description("Validate a topology proposal file deterministically (no write)").action((file) => {
26580
27366
  runTopologyValidate(file);