@kaddo/cli 3.129.0 → 3.129.1
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.
- package/dist/core.js +133 -133
- package/dist/index.js +133 -133
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -10454,101 +10454,83 @@ function relFromDir(dir, filePath) {
|
|
|
10454
10454
|
function sha256(content) {
|
|
10455
10455
|
return createHash2("sha256").update(content, "utf-8").digest("hex");
|
|
10456
10456
|
}
|
|
10457
|
-
var
|
|
10458
|
-
|
|
10459
|
-
|
|
10460
|
-
|
|
10461
|
-
|
|
10462
|
-
|
|
10463
|
-
|
|
10464
|
-
|
|
10465
|
-
|
|
10466
|
-
|
|
10467
|
-
|
|
10468
|
-
|
|
10469
|
-
|
|
10470
|
-
|
|
10471
|
-
|
|
10472
|
-
|
|
10473
|
-
|
|
10474
|
-
|
|
10475
|
-
|
|
10476
|
-
|
|
10477
|
-
|
|
10478
|
-
|
|
10479
|
-
|
|
10480
|
-
|
|
10481
|
-
|
|
10482
|
-
|
|
10483
|
-
|
|
10484
|
-
|
|
10485
|
-
|
|
10486
|
-
|
|
10487
|
-
|
|
10488
|
-
|
|
10489
|
-
|
|
10490
|
-
|
|
10491
|
-
|
|
10492
|
-
|
|
10493
|
-
|
|
10494
|
-
|
|
10495
|
-
|
|
10496
|
-
|
|
10497
|
-
|
|
10498
|
-
|
|
10499
|
-
|
|
10500
|
-
|
|
10501
|
-
|
|
10502
|
-
|
|
10503
|
-
|
|
10504
|
-
|
|
10505
|
-
"
|
|
10506
|
-
"
|
|
10507
|
-
|
|
10508
|
-
|
|
10509
|
-
|
|
10510
|
-
|
|
10511
|
-
|
|
10512
|
-
|
|
10513
|
-
|
|
10514
|
-
|
|
10515
|
-
"
|
|
10516
|
-
|
|
10517
|
-
|
|
10518
|
-
|
|
10519
|
-
"
|
|
10520
|
-
|
|
10521
|
-
|
|
10522
|
-
"
|
|
10523
|
-
"
|
|
10524
|
-
"
|
|
10525
|
-
"
|
|
10526
|
-
"
|
|
10527
|
-
"
|
|
10528
|
-
|
|
10529
|
-
|
|
10530
|
-
|
|
10531
|
-
|
|
10532
|
-
"never",
|
|
10533
|
-
"require",
|
|
10534
|
-
"requires",
|
|
10535
|
-
"constraint",
|
|
10536
|
-
"invariant",
|
|
10537
|
-
"rule"
|
|
10538
|
-
];
|
|
10539
|
-
function normalizeHeading(h) {
|
|
10540
|
-
return h.trim().toLowerCase().replace(/\s+/g, " ");
|
|
10541
|
-
}
|
|
10542
|
-
function distinctiveHeadings(body) {
|
|
10543
|
-
const out = [];
|
|
10544
|
-
for (const line of body.split(/\r?\n/)) {
|
|
10545
|
-
const m = line.match(/^#{2,3}\s+(.+?)\s*$/);
|
|
10546
|
-
if (!m) continue;
|
|
10547
|
-
const norm = normalizeHeading(m[1]);
|
|
10548
|
-
if (!norm || GENERIC_HEADINGS.has(norm)) continue;
|
|
10549
|
-
out.push(norm);
|
|
10457
|
+
var SHINGLE_SIZE = 6;
|
|
10458
|
+
var MIN_SHARED_RUN = 6;
|
|
10459
|
+
function contentWords(body) {
|
|
10460
|
+
const words = [];
|
|
10461
|
+
let inFence = false;
|
|
10462
|
+
for (const raw of body.split(/\r?\n/)) {
|
|
10463
|
+
const t = raw.trim();
|
|
10464
|
+
if (/^```/.test(t)) {
|
|
10465
|
+
inFence = !inFence;
|
|
10466
|
+
continue;
|
|
10467
|
+
}
|
|
10468
|
+
if (inFence) continue;
|
|
10469
|
+
if (/^#{1,6}\s/.test(t)) continue;
|
|
10470
|
+
if (/^>/.test(t)) continue;
|
|
10471
|
+
const text2 = t.replace(/^([-*+]\s+|\d+\.\s+)/, "");
|
|
10472
|
+
const matched = text2.toLowerCase().match(/[a-záéíóúñü0-9]+/gi);
|
|
10473
|
+
if (matched) words.push(...matched);
|
|
10474
|
+
}
|
|
10475
|
+
return words;
|
|
10476
|
+
}
|
|
10477
|
+
function buildShingles(body) {
|
|
10478
|
+
const words = contentWords(body);
|
|
10479
|
+
const keys = [];
|
|
10480
|
+
const set = /* @__PURE__ */ new Set();
|
|
10481
|
+
for (let i = 0; i + SHINGLE_SIZE <= words.length; i++) {
|
|
10482
|
+
const key = words.slice(i, i + SHINGLE_SIZE).join(" ");
|
|
10483
|
+
keys.push(key);
|
|
10484
|
+
set.add(key);
|
|
10485
|
+
}
|
|
10486
|
+
return { words, keys, set };
|
|
10487
|
+
}
|
|
10488
|
+
function longestSharedRun(a, b) {
|
|
10489
|
+
let best = 0;
|
|
10490
|
+
let bestStart = -1;
|
|
10491
|
+
let run = 0;
|
|
10492
|
+
let runStart = 0;
|
|
10493
|
+
for (let i = 0; i < a.keys.length; i++) {
|
|
10494
|
+
if (b.set.has(a.keys[i])) {
|
|
10495
|
+
if (run === 0) runStart = i;
|
|
10496
|
+
run += 1;
|
|
10497
|
+
if (run > best) {
|
|
10498
|
+
best = run;
|
|
10499
|
+
bestStart = runStart;
|
|
10500
|
+
}
|
|
10501
|
+
} else {
|
|
10502
|
+
run = 0;
|
|
10503
|
+
}
|
|
10504
|
+
}
|
|
10505
|
+
if (best === 0) return { length: 0, snippet: "" };
|
|
10506
|
+
const snippet = a.words.slice(bestStart, bestStart + SHINGLE_SIZE + best - 1).join(" ");
|
|
10507
|
+
return { length: best, snippet };
|
|
10508
|
+
}
|
|
10509
|
+
var NORMATIVE_RE = /(^|[^a-záéíóúñü])(must|should|shall|debe[ns]?|deber[ií]a[ns]?|se\s+debe|hay\s+que|requiere[ns]?|require[sd]?|no\s+debe|invariant[e]?|invariants|restricci[oó]n|constraint|regla|obligatori[oa])([^a-záéíóúñü]|$)/i;
|
|
10510
|
+
var PAST_RESULT_RE = /(compil[aoeéó]\w*|compiled|benchmark\w*|passed|succeed\w*|succeeded|ran\s+successfully|ejecut\w*|resultad\w*|crates?\b|ns\/op|µs\b|throughput|latenc\w*|baseline|measured|medid\w*|\d+\s*%|\bx\d|faster|slower)/i;
|
|
10511
|
+
var TEST_RE = /(\btest\w*|\bpruebas?\b|coverage|cobertura|verde[s]?|green\b|assert\w*)/i;
|
|
10512
|
+
var BENCH_RE = /(benchmark\w*|ns\/op|µs\b|throughput|latenc\w*|ops\/s|\d+\s*%|faster|slower|baseline)/i;
|
|
10513
|
+
var EXPERIMENT_RE = /(experiment\w*|experiment[oa]\w*|prototyp\w*|prototip\w*|spike\b|probamos|probé|intentamos)/i;
|
|
10514
|
+
function splitSentences(text2) {
|
|
10515
|
+
return text2.replace(/\s+/g, " ").split(/(?<=[.!?;])\s+/).map((s) => s.trim()).filter(Boolean);
|
|
10516
|
+
}
|
|
10517
|
+
function classifyLearningSentence(sentence) {
|
|
10518
|
+
const s = sentence.trim();
|
|
10519
|
+
if (!s) return "none";
|
|
10520
|
+
const normative = NORMATIVE_RE.test(s);
|
|
10521
|
+
const pastResult = PAST_RESULT_RE.test(s);
|
|
10522
|
+
if (normative && !pastResult) return "durable-rule";
|
|
10523
|
+
if (BENCH_RE.test(s)) return "benchmark-evidence";
|
|
10524
|
+
if (pastResult) return "historical-result";
|
|
10525
|
+
if (TEST_RE.test(s)) return "test-observation";
|
|
10526
|
+
if (EXPERIMENT_RE.test(s)) return "experimental-result";
|
|
10527
|
+
return "none";
|
|
10528
|
+
}
|
|
10529
|
+
function firstRuleFragment(learning) {
|
|
10530
|
+
for (const sentence of splitSentences(learning)) {
|
|
10531
|
+
if (classifyLearningSentence(sentence) === "durable-rule") return sentence;
|
|
10550
10532
|
}
|
|
10551
|
-
return
|
|
10533
|
+
return null;
|
|
10552
10534
|
}
|
|
10553
10535
|
function sectionBody(body, titles) {
|
|
10554
10536
|
const lines = body.split(/\r?\n/);
|
|
@@ -10632,32 +10614,33 @@ function buildConsolidationPlan(dir, opts = {}) {
|
|
|
10632
10614
|
requires_semantic_review: false
|
|
10633
10615
|
});
|
|
10634
10616
|
}
|
|
10635
|
-
const
|
|
10636
|
-
|
|
10637
|
-
);
|
|
10638
|
-
const
|
|
10639
|
-
|
|
10640
|
-
|
|
10641
|
-
|
|
10617
|
+
const comparable = scoped.filter(isComparableKnowledge);
|
|
10618
|
+
const shingleIndex = /* @__PURE__ */ new Map();
|
|
10619
|
+
const shinglesByRel = /* @__PURE__ */ new Map();
|
|
10620
|
+
for (const la of comparable) {
|
|
10621
|
+
const shingles = buildShingles(la.body);
|
|
10622
|
+
shinglesByRel.set(la.rel, shingles);
|
|
10623
|
+
for (const key of shingles.set) {
|
|
10624
|
+
const arr = shingleIndex.get(key) ?? [];
|
|
10642
10625
|
arr.push(la);
|
|
10643
|
-
|
|
10626
|
+
shingleIndex.set(key, arr);
|
|
10644
10627
|
}
|
|
10645
10628
|
}
|
|
10646
|
-
const
|
|
10647
|
-
for (const
|
|
10629
|
+
const candidatePairs = /* @__PURE__ */ new Map();
|
|
10630
|
+
for (const arts of shingleIndex.values()) {
|
|
10648
10631
|
if (arts.length < 2) continue;
|
|
10649
10632
|
for (let i = 0; i < arts.length; i++) {
|
|
10650
10633
|
for (let j = i + 1; j < arts.length; j++) {
|
|
10651
10634
|
if (arts[i].rel === arts[j].rel) continue;
|
|
10652
10635
|
const key = [arts[i].rel, arts[j].rel].sort().join("||");
|
|
10653
|
-
|
|
10654
|
-
entry.shared.add(heading);
|
|
10655
|
-
pairHeadings.set(key, entry);
|
|
10636
|
+
if (!candidatePairs.has(key)) candidatePairs.set(key, { a: arts[i], b: arts[j] });
|
|
10656
10637
|
}
|
|
10657
10638
|
}
|
|
10658
10639
|
}
|
|
10659
|
-
for (const { a, b
|
|
10660
|
-
|
|
10640
|
+
for (const { a, b } of candidatePairs.values()) {
|
|
10641
|
+
const run = longestSharedRun(shinglesByRel.get(a.rel), shinglesByRel.get(b.rel));
|
|
10642
|
+
if (run.length < MIN_SHARED_RUN) continue;
|
|
10643
|
+
const passageWords = SHINGLE_SIZE + run.length - 1;
|
|
10661
10644
|
opportunities.push({
|
|
10662
10645
|
id: stableOpportunityId("knowledge_redundancy", [label(a), label(b)]),
|
|
10663
10646
|
category: "knowledge_redundancy",
|
|
@@ -10666,10 +10649,12 @@ function buildConsolidationPlan(dir, opts = {}) {
|
|
|
10666
10649
|
title: `Possible overlapping content between ${label(a)} and ${label(b)}`,
|
|
10667
10650
|
source_artifacts: [label(a), label(b)],
|
|
10668
10651
|
target_artifacts: [label(a), label(b)],
|
|
10669
|
-
evidence: [
|
|
10670
|
-
|
|
10652
|
+
evidence: [
|
|
10653
|
+
`A ${passageWords}-word passage appears verbatim in both artifacts: "${redactSecrets2(run.snippet)}".`
|
|
10654
|
+
],
|
|
10655
|
+
rationale: "A verbatim shared passage is a hint of potential duplication, NOT proof. Two documents can legitimately restate context from different layers/responsibilities; shared template structure alone was NOT used.",
|
|
10671
10656
|
possible_impact: "If genuinely duplicated, the same fact can drift out of sync across files.",
|
|
10672
|
-
suggested_action: "Semantic review: compare the
|
|
10657
|
+
suggested_action: "Semantic review: compare the overlapping passage; if one restates the other, keep a single reference location and link the rest. Preserve layer separation.",
|
|
10673
10658
|
requires_semantic_review: true
|
|
10674
10659
|
});
|
|
10675
10660
|
}
|
|
@@ -10677,7 +10662,8 @@ function buildConsolidationPlan(dir, opts = {}) {
|
|
|
10677
10662
|
if (!isCompletedWorkItem(la)) continue;
|
|
10678
10663
|
const learning = sectionBody(la.body, ["Learning", "Aprendizaje", "Aprendizajes", "Learnings"]);
|
|
10679
10664
|
if (!learning) continue;
|
|
10680
|
-
|
|
10665
|
+
const ruleFragment = firstRuleFragment(learning);
|
|
10666
|
+
if (!ruleFragment) continue;
|
|
10681
10667
|
opportunities.push({
|
|
10682
10668
|
id: stableOpportunityId("unincorporated_learning", [label(la)]),
|
|
10683
10669
|
category: "unincorporated_learning",
|
|
@@ -10685,16 +10671,18 @@ function buildConsolidationPlan(dir, opts = {}) {
|
|
|
10685
10671
|
confidence: "requires-review",
|
|
10686
10672
|
title: `${label(la)} captured a learning that may belong in current knowledge`,
|
|
10687
10673
|
source_artifacts: [label(la)],
|
|
10688
|
-
target_artifacts: [
|
|
10689
|
-
|
|
10690
|
-
|
|
10674
|
+
target_artifacts: [],
|
|
10675
|
+
// unresolved — determined in semantic review (never invent a destination)
|
|
10676
|
+
evidence: [`Completed Work Item records a rule-like learning (heuristic classification): "${redactSecrets2(ruleFragment)}"`],
|
|
10677
|
+
rationale: "A sentence phrased as a durable rule MAY represent live technical knowledge not yet reflected in current knowledge. The rule/result distinction is a heuristic, not a verified conclusion \u2014 this is a candidate, not a confirmed gap.",
|
|
10691
10678
|
possible_impact: "A relevant constraint stays buried in delivery history instead of informing current work.",
|
|
10692
|
-
suggested_action: "Semantic review:
|
|
10679
|
+
suggested_action: "Semantic review: confirm whether this is a live rule and determine the right destination artifact; if so, incorporate it WITH a reference back to the Work Item. Do not delete or summarize the Work Item.",
|
|
10693
10680
|
requires_semantic_review: true
|
|
10694
10681
|
});
|
|
10695
10682
|
}
|
|
10696
10683
|
const weakByFolder = /* @__PURE__ */ new Map();
|
|
10697
10684
|
for (const la of scoped) {
|
|
10685
|
+
if (!isConsolidatableKnowledge(la)) continue;
|
|
10698
10686
|
const quality = safeQuality(dir, la.rel);
|
|
10699
10687
|
if (quality === "placeholder" || quality === "weak") {
|
|
10700
10688
|
opportunities.push({
|
|
@@ -10705,11 +10693,11 @@ function buildConsolidationPlan(dir, opts = {}) {
|
|
|
10705
10693
|
title: `${label(la)} is ${quality} and may need consolidation or expansion`,
|
|
10706
10694
|
source_artifacts: [label(la)],
|
|
10707
10695
|
target_artifacts: [label(la)],
|
|
10708
|
-
evidence: [`Artifact quality analysis classifies this artifact as "${quality}".`],
|
|
10709
|
-
rationale: "
|
|
10696
|
+
evidence: [`Artifact quality analysis classifies this canonical knowledge artifact as "${quality}".`],
|
|
10697
|
+
rationale: "Observed: the quality heuristic rates this artifact low-signal. Whether it should be expanded, merged or cross-referenced is a judgement that needs semantic review \u2014 the quality signal alone does not decide it.",
|
|
10710
10698
|
possible_impact: "Readers must open more files to assemble a complete picture.",
|
|
10711
|
-
suggested_action: "
|
|
10712
|
-
requires_semantic_review:
|
|
10699
|
+
suggested_action: "Semantic review: decide whether to expand, merge into a stronger artifact, or cross-reference it.",
|
|
10700
|
+
requires_semantic_review: true
|
|
10713
10701
|
});
|
|
10714
10702
|
const folder = la.rel.split("/").slice(0, -1).join("/");
|
|
10715
10703
|
const arr = weakByFolder.get(folder) ?? [];
|
|
@@ -10724,11 +10712,11 @@ function buildConsolidationPlan(dir, opts = {}) {
|
|
|
10724
10712
|
category: "knowledge_fragmentation",
|
|
10725
10713
|
classification: "suggested",
|
|
10726
10714
|
confidence: "requires-review",
|
|
10727
|
-
title: `${folder}/ holds ${arts.length} low-signal artifacts \u2014 possible fragmentation`,
|
|
10715
|
+
title: `${folder}/ holds ${arts.length} low-signal canonical artifacts \u2014 possible fragmentation`,
|
|
10728
10716
|
source_artifacts: arts.map((a) => label(a)),
|
|
10729
10717
|
target_artifacts: [folder],
|
|
10730
|
-
evidence: [`${arts.length} placeholder/weak artifacts in the same folder: ${arts.map((a) => a.rel.split("/").pop()).join(", ")}.`],
|
|
10731
|
-
rationale: "Several thin artifacts in one folder MAY be easier to consume if consolidated or cross-linked. Consolidation must preserve each distinct responsibility.",
|
|
10718
|
+
evidence: [`${arts.length} placeholder/weak canonical knowledge artifacts in the same folder: ${arts.map((a) => a.rel.split("/").pop()).join(", ")}.`],
|
|
10719
|
+
rationale: "Several thin canonical artifacts in one folder MAY be easier to consume if consolidated or cross-linked. Consolidation must preserve each distinct responsibility; Work Items and generated/lifecycle artifacts are not considered here.",
|
|
10732
10720
|
possible_impact: "Related knowledge is spread across too many files to follow.",
|
|
10733
10721
|
suggested_action: "Semantic review: evaluate whether cross-references or a consolidation would add clarity. Do not merge by file count alone.",
|
|
10734
10722
|
requires_semantic_review: true
|
|
@@ -10833,7 +10821,9 @@ function renderConsolidationMarkdown(plan) {
|
|
|
10833
10821
|
lines.push(`- Classification: **${o.classification}**${o.requires_semantic_review ? " (requires semantic review)" : ""}`);
|
|
10834
10822
|
lines.push(`- Confidence: ${o.confidence}`);
|
|
10835
10823
|
lines.push(`- Source: ${o.source_artifacts.join(", ") || "\u2014"}`);
|
|
10836
|
-
lines.push(
|
|
10824
|
+
lines.push(
|
|
10825
|
+
`- Suggested target: ${o.target_artifacts.length > 0 ? o.target_artifacts.join(", ") : "(unresolved \u2014 to be determined in semantic review)"}`
|
|
10826
|
+
);
|
|
10837
10827
|
lines.push(`- Evidence:`);
|
|
10838
10828
|
for (const e of o.evidence) lines.push(` - ${e}`);
|
|
10839
10829
|
lines.push(`- Rationale: ${o.rationale}`);
|
|
@@ -10858,15 +10848,25 @@ function isCompletedWorkItem(la) {
|
|
|
10858
10848
|
const p = toPosix6(la.artifact.filePath);
|
|
10859
10849
|
return p.includes("/delivery/work-items/completed/") || isWorkItem(la) && la.artifact.status === "completed";
|
|
10860
10850
|
}
|
|
10861
|
-
function
|
|
10862
|
-
const
|
|
10863
|
-
return
|
|
10851
|
+
function isScaffolding(la) {
|
|
10852
|
+
const p = toPosix6(la.artifact.filePath);
|
|
10853
|
+
return p.includes(`/${KNOWLEDGE5}/agents/`) || p.includes(`/${KNOWLEDGE5}/skills/`) || p.includes(`/${KNOWLEDGE5}/external/`) || la.artifact.type === "knowledge-capsule";
|
|
10854
|
+
}
|
|
10855
|
+
var NON_KNOWLEDGE_DOC_TYPES = /* @__PURE__ */ new Set([
|
|
10856
|
+
"roadmap",
|
|
10857
|
+
"initiative",
|
|
10858
|
+
"deprecation",
|
|
10859
|
+
"knowledge-capsule",
|
|
10860
|
+
"inventory",
|
|
10861
|
+
"project-resource"
|
|
10862
|
+
]);
|
|
10863
|
+
function isComparableKnowledge(la) {
|
|
10864
|
+
return !isWorkItem(la) && la.artifact.type !== "roadmap" && !isScaffolding(la);
|
|
10864
10865
|
}
|
|
10865
|
-
function
|
|
10866
|
-
|
|
10867
|
-
|
|
10868
|
-
|
|
10869
|
-
return redactSecrets2(s.trim());
|
|
10866
|
+
function isConsolidatableKnowledge(la) {
|
|
10867
|
+
if (isWorkItem(la) || isScaffolding(la)) return false;
|
|
10868
|
+
if (NON_KNOWLEDGE_DOC_TYPES.has(la.artifact.type)) return false;
|
|
10869
|
+
return la.layer === "Business" || la.layer === "Product" || la.layer === "Tech";
|
|
10870
10870
|
}
|
|
10871
10871
|
var SECRET_TOKEN_PATTERNS = [
|
|
10872
10872
|
/\bgh[pours]_[A-Za-z0-9]{16,}\b/g,
|
package/dist/index.js
CHANGED
|
@@ -25961,101 +25961,83 @@ function relFromDir(dir, filePath) {
|
|
|
25961
25961
|
function sha256(content) {
|
|
25962
25962
|
return createHash2("sha256").update(content, "utf-8").digest("hex");
|
|
25963
25963
|
}
|
|
25964
|
-
var
|
|
25965
|
-
|
|
25966
|
-
|
|
25967
|
-
|
|
25968
|
-
|
|
25969
|
-
|
|
25970
|
-
|
|
25971
|
-
|
|
25972
|
-
|
|
25973
|
-
|
|
25974
|
-
|
|
25975
|
-
|
|
25976
|
-
|
|
25977
|
-
|
|
25978
|
-
|
|
25979
|
-
|
|
25980
|
-
|
|
25981
|
-
|
|
25982
|
-
|
|
25983
|
-
|
|
25984
|
-
|
|
25985
|
-
|
|
25986
|
-
|
|
25987
|
-
|
|
25988
|
-
|
|
25989
|
-
|
|
25990
|
-
|
|
25991
|
-
|
|
25992
|
-
|
|
25993
|
-
|
|
25994
|
-
|
|
25995
|
-
|
|
25996
|
-
|
|
25997
|
-
|
|
25998
|
-
|
|
25999
|
-
|
|
26000
|
-
|
|
26001
|
-
|
|
26002
|
-
|
|
26003
|
-
|
|
26004
|
-
|
|
26005
|
-
|
|
26006
|
-
|
|
26007
|
-
|
|
26008
|
-
|
|
26009
|
-
|
|
26010
|
-
|
|
26011
|
-
|
|
26012
|
-
"
|
|
26013
|
-
"
|
|
26014
|
-
|
|
26015
|
-
|
|
26016
|
-
|
|
26017
|
-
|
|
26018
|
-
|
|
26019
|
-
|
|
26020
|
-
|
|
26021
|
-
|
|
26022
|
-
"
|
|
26023
|
-
|
|
26024
|
-
|
|
26025
|
-
|
|
26026
|
-
"
|
|
26027
|
-
|
|
26028
|
-
|
|
26029
|
-
"
|
|
26030
|
-
"
|
|
26031
|
-
"
|
|
26032
|
-
"
|
|
26033
|
-
"
|
|
26034
|
-
"
|
|
26035
|
-
|
|
26036
|
-
|
|
26037
|
-
|
|
26038
|
-
|
|
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);
|
|
25964
|
+
var SHINGLE_SIZE = 6;
|
|
25965
|
+
var MIN_SHARED_RUN = 6;
|
|
25966
|
+
function contentWords(body) {
|
|
25967
|
+
const words = [];
|
|
25968
|
+
let inFence = false;
|
|
25969
|
+
for (const raw of body.split(/\r?\n/)) {
|
|
25970
|
+
const t = raw.trim();
|
|
25971
|
+
if (/^```/.test(t)) {
|
|
25972
|
+
inFence = !inFence;
|
|
25973
|
+
continue;
|
|
25974
|
+
}
|
|
25975
|
+
if (inFence) continue;
|
|
25976
|
+
if (/^#{1,6}\s/.test(t)) continue;
|
|
25977
|
+
if (/^>/.test(t)) continue;
|
|
25978
|
+
const text2 = t.replace(/^([-*+]\s+|\d+\.\s+)/, "");
|
|
25979
|
+
const matched = text2.toLowerCase().match(/[a-záéíóúñü0-9]+/gi);
|
|
25980
|
+
if (matched) words.push(...matched);
|
|
25981
|
+
}
|
|
25982
|
+
return words;
|
|
25983
|
+
}
|
|
25984
|
+
function buildShingles(body) {
|
|
25985
|
+
const words = contentWords(body);
|
|
25986
|
+
const keys = [];
|
|
25987
|
+
const set = /* @__PURE__ */ new Set();
|
|
25988
|
+
for (let i = 0; i + SHINGLE_SIZE <= words.length; i++) {
|
|
25989
|
+
const key = words.slice(i, i + SHINGLE_SIZE).join(" ");
|
|
25990
|
+
keys.push(key);
|
|
25991
|
+
set.add(key);
|
|
25992
|
+
}
|
|
25993
|
+
return { words, keys, set };
|
|
25994
|
+
}
|
|
25995
|
+
function longestSharedRun(a, b) {
|
|
25996
|
+
let best = 0;
|
|
25997
|
+
let bestStart = -1;
|
|
25998
|
+
let run = 0;
|
|
25999
|
+
let runStart = 0;
|
|
26000
|
+
for (let i = 0; i < a.keys.length; i++) {
|
|
26001
|
+
if (b.set.has(a.keys[i])) {
|
|
26002
|
+
if (run === 0) runStart = i;
|
|
26003
|
+
run += 1;
|
|
26004
|
+
if (run > best) {
|
|
26005
|
+
best = run;
|
|
26006
|
+
bestStart = runStart;
|
|
26007
|
+
}
|
|
26008
|
+
} else {
|
|
26009
|
+
run = 0;
|
|
26010
|
+
}
|
|
26011
|
+
}
|
|
26012
|
+
if (best === 0) return { length: 0, snippet: "" };
|
|
26013
|
+
const snippet = a.words.slice(bestStart, bestStart + SHINGLE_SIZE + best - 1).join(" ");
|
|
26014
|
+
return { length: best, snippet };
|
|
26015
|
+
}
|
|
26016
|
+
var NORMATIVE_RE = /(^|[^a-záéíóúñü])(must|should|shall|debe[ns]?|deber[ií]a[ns]?|se\s+debe|hay\s+que|requiere[ns]?|require[sd]?|no\s+debe|invariant[e]?|invariants|restricci[oó]n|constraint|regla|obligatori[oa])([^a-záéíóúñü]|$)/i;
|
|
26017
|
+
var PAST_RESULT_RE = /(compil[aoeéó]\w*|compiled|benchmark\w*|passed|succeed\w*|succeeded|ran\s+successfully|ejecut\w*|resultad\w*|crates?\b|ns\/op|µs\b|throughput|latenc\w*|baseline|measured|medid\w*|\d+\s*%|\bx\d|faster|slower)/i;
|
|
26018
|
+
var TEST_RE = /(\btest\w*|\bpruebas?\b|coverage|cobertura|verde[s]?|green\b|assert\w*)/i;
|
|
26019
|
+
var BENCH_RE = /(benchmark\w*|ns\/op|µs\b|throughput|latenc\w*|ops\/s|\d+\s*%|faster|slower|baseline)/i;
|
|
26020
|
+
var EXPERIMENT_RE = /(experiment\w*|experiment[oa]\w*|prototyp\w*|prototip\w*|spike\b|probamos|probé|intentamos)/i;
|
|
26021
|
+
function splitSentences(text2) {
|
|
26022
|
+
return text2.replace(/\s+/g, " ").split(/(?<=[.!?;])\s+/).map((s) => s.trim()).filter(Boolean);
|
|
26023
|
+
}
|
|
26024
|
+
function classifyLearningSentence(sentence) {
|
|
26025
|
+
const s = sentence.trim();
|
|
26026
|
+
if (!s) return "none";
|
|
26027
|
+
const normative = NORMATIVE_RE.test(s);
|
|
26028
|
+
const pastResult = PAST_RESULT_RE.test(s);
|
|
26029
|
+
if (normative && !pastResult) return "durable-rule";
|
|
26030
|
+
if (BENCH_RE.test(s)) return "benchmark-evidence";
|
|
26031
|
+
if (pastResult) return "historical-result";
|
|
26032
|
+
if (TEST_RE.test(s)) return "test-observation";
|
|
26033
|
+
if (EXPERIMENT_RE.test(s)) return "experimental-result";
|
|
26034
|
+
return "none";
|
|
26035
|
+
}
|
|
26036
|
+
function firstRuleFragment(learning) {
|
|
26037
|
+
for (const sentence of splitSentences(learning)) {
|
|
26038
|
+
if (classifyLearningSentence(sentence) === "durable-rule") return sentence;
|
|
26057
26039
|
}
|
|
26058
|
-
return
|
|
26040
|
+
return null;
|
|
26059
26041
|
}
|
|
26060
26042
|
function sectionBody(body, titles) {
|
|
26061
26043
|
const lines = body.split(/\r?\n/);
|
|
@@ -26139,32 +26121,33 @@ function buildConsolidationPlan(dir, opts = {}) {
|
|
|
26139
26121
|
requires_semantic_review: false
|
|
26140
26122
|
});
|
|
26141
26123
|
}
|
|
26142
|
-
const
|
|
26143
|
-
|
|
26144
|
-
);
|
|
26145
|
-
const
|
|
26146
|
-
|
|
26147
|
-
|
|
26148
|
-
|
|
26124
|
+
const comparable = scoped.filter(isComparableKnowledge);
|
|
26125
|
+
const shingleIndex = /* @__PURE__ */ new Map();
|
|
26126
|
+
const shinglesByRel = /* @__PURE__ */ new Map();
|
|
26127
|
+
for (const la of comparable) {
|
|
26128
|
+
const shingles = buildShingles(la.body);
|
|
26129
|
+
shinglesByRel.set(la.rel, shingles);
|
|
26130
|
+
for (const key of shingles.set) {
|
|
26131
|
+
const arr = shingleIndex.get(key) ?? [];
|
|
26149
26132
|
arr.push(la);
|
|
26150
|
-
|
|
26133
|
+
shingleIndex.set(key, arr);
|
|
26151
26134
|
}
|
|
26152
26135
|
}
|
|
26153
|
-
const
|
|
26154
|
-
for (const
|
|
26136
|
+
const candidatePairs = /* @__PURE__ */ new Map();
|
|
26137
|
+
for (const arts of shingleIndex.values()) {
|
|
26155
26138
|
if (arts.length < 2) continue;
|
|
26156
26139
|
for (let i = 0; i < arts.length; i++) {
|
|
26157
26140
|
for (let j = i + 1; j < arts.length; j++) {
|
|
26158
26141
|
if (arts[i].rel === arts[j].rel) continue;
|
|
26159
26142
|
const key = [arts[i].rel, arts[j].rel].sort().join("||");
|
|
26160
|
-
|
|
26161
|
-
entry.shared.add(heading);
|
|
26162
|
-
pairHeadings.set(key, entry);
|
|
26143
|
+
if (!candidatePairs.has(key)) candidatePairs.set(key, { a: arts[i], b: arts[j] });
|
|
26163
26144
|
}
|
|
26164
26145
|
}
|
|
26165
26146
|
}
|
|
26166
|
-
for (const { a, b
|
|
26167
|
-
|
|
26147
|
+
for (const { a, b } of candidatePairs.values()) {
|
|
26148
|
+
const run = longestSharedRun(shinglesByRel.get(a.rel), shinglesByRel.get(b.rel));
|
|
26149
|
+
if (run.length < MIN_SHARED_RUN) continue;
|
|
26150
|
+
const passageWords = SHINGLE_SIZE + run.length - 1;
|
|
26168
26151
|
opportunities.push({
|
|
26169
26152
|
id: stableOpportunityId("knowledge_redundancy", [label(a), label(b)]),
|
|
26170
26153
|
category: "knowledge_redundancy",
|
|
@@ -26173,10 +26156,12 @@ function buildConsolidationPlan(dir, opts = {}) {
|
|
|
26173
26156
|
title: `Possible overlapping content between ${label(a)} and ${label(b)}`,
|
|
26174
26157
|
source_artifacts: [label(a), label(b)],
|
|
26175
26158
|
target_artifacts: [label(a), label(b)],
|
|
26176
|
-
evidence: [
|
|
26177
|
-
|
|
26159
|
+
evidence: [
|
|
26160
|
+
`A ${passageWords}-word passage appears verbatim in both artifacts: "${redactSecrets2(run.snippet)}".`
|
|
26161
|
+
],
|
|
26162
|
+
rationale: "A verbatim shared passage is a hint of potential duplication, NOT proof. Two documents can legitimately restate context from different layers/responsibilities; shared template structure alone was NOT used.",
|
|
26178
26163
|
possible_impact: "If genuinely duplicated, the same fact can drift out of sync across files.",
|
|
26179
|
-
suggested_action: "Semantic review: compare the
|
|
26164
|
+
suggested_action: "Semantic review: compare the overlapping passage; if one restates the other, keep a single reference location and link the rest. Preserve layer separation.",
|
|
26180
26165
|
requires_semantic_review: true
|
|
26181
26166
|
});
|
|
26182
26167
|
}
|
|
@@ -26184,7 +26169,8 @@ function buildConsolidationPlan(dir, opts = {}) {
|
|
|
26184
26169
|
if (!isCompletedWorkItem(la)) continue;
|
|
26185
26170
|
const learning = sectionBody(la.body, ["Learning", "Aprendizaje", "Aprendizajes", "Learnings"]);
|
|
26186
26171
|
if (!learning) continue;
|
|
26187
|
-
|
|
26172
|
+
const ruleFragment = firstRuleFragment(learning);
|
|
26173
|
+
if (!ruleFragment) continue;
|
|
26188
26174
|
opportunities.push({
|
|
26189
26175
|
id: stableOpportunityId("unincorporated_learning", [label(la)]),
|
|
26190
26176
|
category: "unincorporated_learning",
|
|
@@ -26192,16 +26178,18 @@ function buildConsolidationPlan(dir, opts = {}) {
|
|
|
26192
26178
|
confidence: "requires-review",
|
|
26193
26179
|
title: `${label(la)} captured a learning that may belong in current knowledge`,
|
|
26194
26180
|
source_artifacts: [label(la)],
|
|
26195
|
-
target_artifacts: [
|
|
26196
|
-
|
|
26197
|
-
|
|
26181
|
+
target_artifacts: [],
|
|
26182
|
+
// unresolved — determined in semantic review (never invent a destination)
|
|
26183
|
+
evidence: [`Completed Work Item records a rule-like learning (heuristic classification): "${redactSecrets2(ruleFragment)}"`],
|
|
26184
|
+
rationale: "A sentence phrased as a durable rule MAY represent live technical knowledge not yet reflected in current knowledge. The rule/result distinction is a heuristic, not a verified conclusion \u2014 this is a candidate, not a confirmed gap.",
|
|
26198
26185
|
possible_impact: "A relevant constraint stays buried in delivery history instead of informing current work.",
|
|
26199
|
-
suggested_action: "Semantic review:
|
|
26186
|
+
suggested_action: "Semantic review: confirm whether this is a live rule and determine the right destination artifact; if so, incorporate it WITH a reference back to the Work Item. Do not delete or summarize the Work Item.",
|
|
26200
26187
|
requires_semantic_review: true
|
|
26201
26188
|
});
|
|
26202
26189
|
}
|
|
26203
26190
|
const weakByFolder = /* @__PURE__ */ new Map();
|
|
26204
26191
|
for (const la of scoped) {
|
|
26192
|
+
if (!isConsolidatableKnowledge(la)) continue;
|
|
26205
26193
|
const quality = safeQuality(dir, la.rel);
|
|
26206
26194
|
if (quality === "placeholder" || quality === "weak") {
|
|
26207
26195
|
opportunities.push({
|
|
@@ -26212,11 +26200,11 @@ function buildConsolidationPlan(dir, opts = {}) {
|
|
|
26212
26200
|
title: `${label(la)} is ${quality} and may need consolidation or expansion`,
|
|
26213
26201
|
source_artifacts: [label(la)],
|
|
26214
26202
|
target_artifacts: [label(la)],
|
|
26215
|
-
evidence: [`Artifact quality analysis classifies this artifact as "${quality}".`],
|
|
26216
|
-
rationale: "
|
|
26203
|
+
evidence: [`Artifact quality analysis classifies this canonical knowledge artifact as "${quality}".`],
|
|
26204
|
+
rationale: "Observed: the quality heuristic rates this artifact low-signal. Whether it should be expanded, merged or cross-referenced is a judgement that needs semantic review \u2014 the quality signal alone does not decide it.",
|
|
26217
26205
|
possible_impact: "Readers must open more files to assemble a complete picture.",
|
|
26218
|
-
suggested_action: "
|
|
26219
|
-
requires_semantic_review:
|
|
26206
|
+
suggested_action: "Semantic review: decide whether to expand, merge into a stronger artifact, or cross-reference it.",
|
|
26207
|
+
requires_semantic_review: true
|
|
26220
26208
|
});
|
|
26221
26209
|
const folder = la.rel.split("/").slice(0, -1).join("/");
|
|
26222
26210
|
const arr = weakByFolder.get(folder) ?? [];
|
|
@@ -26231,11 +26219,11 @@ function buildConsolidationPlan(dir, opts = {}) {
|
|
|
26231
26219
|
category: "knowledge_fragmentation",
|
|
26232
26220
|
classification: "suggested",
|
|
26233
26221
|
confidence: "requires-review",
|
|
26234
|
-
title: `${folder}/ holds ${arts.length} low-signal artifacts \u2014 possible fragmentation`,
|
|
26222
|
+
title: `${folder}/ holds ${arts.length} low-signal canonical artifacts \u2014 possible fragmentation`,
|
|
26235
26223
|
source_artifacts: arts.map((a) => label(a)),
|
|
26236
26224
|
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.",
|
|
26225
|
+
evidence: [`${arts.length} placeholder/weak canonical knowledge artifacts in the same folder: ${arts.map((a) => a.rel.split("/").pop()).join(", ")}.`],
|
|
26226
|
+
rationale: "Several thin canonical artifacts in one folder MAY be easier to consume if consolidated or cross-linked. Consolidation must preserve each distinct responsibility; Work Items and generated/lifecycle artifacts are not considered here.",
|
|
26239
26227
|
possible_impact: "Related knowledge is spread across too many files to follow.",
|
|
26240
26228
|
suggested_action: "Semantic review: evaluate whether cross-references or a consolidation would add clarity. Do not merge by file count alone.",
|
|
26241
26229
|
requires_semantic_review: true
|
|
@@ -26327,7 +26315,9 @@ function renderConsolidationMarkdown(plan) {
|
|
|
26327
26315
|
lines.push(`- Classification: **${o.classification}**${o.requires_semantic_review ? " (requires semantic review)" : ""}`);
|
|
26328
26316
|
lines.push(`- Confidence: ${o.confidence}`);
|
|
26329
26317
|
lines.push(`- Source: ${o.source_artifacts.join(", ") || "\u2014"}`);
|
|
26330
|
-
lines.push(
|
|
26318
|
+
lines.push(
|
|
26319
|
+
`- Suggested target: ${o.target_artifacts.length > 0 ? o.target_artifacts.join(", ") : "(unresolved \u2014 to be determined in semantic review)"}`
|
|
26320
|
+
);
|
|
26331
26321
|
lines.push(`- Evidence:`);
|
|
26332
26322
|
for (const e of o.evidence) lines.push(` - ${e}`);
|
|
26333
26323
|
lines.push(`- Rationale: ${o.rationale}`);
|
|
@@ -26352,15 +26342,25 @@ function isCompletedWorkItem(la) {
|
|
|
26352
26342
|
const p = toPosix7(la.artifact.filePath);
|
|
26353
26343
|
return p.includes("/delivery/work-items/completed/") || isWorkItem(la) && la.artifact.status === "completed";
|
|
26354
26344
|
}
|
|
26355
|
-
function
|
|
26356
|
-
const
|
|
26357
|
-
return
|
|
26345
|
+
function isScaffolding(la) {
|
|
26346
|
+
const p = toPosix7(la.artifact.filePath);
|
|
26347
|
+
return p.includes(`/${KNOWLEDGE6}/agents/`) || p.includes(`/${KNOWLEDGE6}/skills/`) || p.includes(`/${KNOWLEDGE6}/external/`) || la.artifact.type === "knowledge-capsule";
|
|
26348
|
+
}
|
|
26349
|
+
var NON_KNOWLEDGE_DOC_TYPES = /* @__PURE__ */ new Set([
|
|
26350
|
+
"roadmap",
|
|
26351
|
+
"initiative",
|
|
26352
|
+
"deprecation",
|
|
26353
|
+
"knowledge-capsule",
|
|
26354
|
+
"inventory",
|
|
26355
|
+
"project-resource"
|
|
26356
|
+
]);
|
|
26357
|
+
function isComparableKnowledge(la) {
|
|
26358
|
+
return !isWorkItem(la) && la.artifact.type !== "roadmap" && !isScaffolding(la);
|
|
26358
26359
|
}
|
|
26359
|
-
function
|
|
26360
|
-
|
|
26361
|
-
|
|
26362
|
-
|
|
26363
|
-
return redactSecrets2(s.trim());
|
|
26360
|
+
function isConsolidatableKnowledge(la) {
|
|
26361
|
+
if (isWorkItem(la) || isScaffolding(la)) return false;
|
|
26362
|
+
if (NON_KNOWLEDGE_DOC_TYPES.has(la.artifact.type)) return false;
|
|
26363
|
+
return la.layer === "Business" || la.layer === "Product" || la.layer === "Tech";
|
|
26364
26364
|
}
|
|
26365
26365
|
var SECRET_TOKEN_PATTERNS = [
|
|
26366
26366
|
/\bgh[pours]_[A-Za-z0-9]{16,}\b/g,
|