@kaddo/cli 3.129.0 → 3.129.2
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 +149 -134
- package/dist/index.js +149 -134
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -10454,101 +10454,97 @@ 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
|
-
"intent",
|
|
10462
|
-
"goal",
|
|
10463
|
-
"objetivo",
|
|
10464
|
-
"summary",
|
|
10465
|
-
"resumen",
|
|
10466
|
-
"overview",
|
|
10467
|
-
"context",
|
|
10468
|
-
"contexto",
|
|
10469
|
-
"scope",
|
|
10470
|
-
"alcance",
|
|
10471
|
-
"out of scope",
|
|
10472
|
-
"fuera de alcance",
|
|
10473
|
-
"acceptance criteria",
|
|
10474
|
-
"criterios de aceptacion",
|
|
10475
|
-
"criterios de aceptaci\xF3n",
|
|
10476
|
-
"validation",
|
|
10477
|
-
"validation scenarios",
|
|
10478
|
-
"validacion",
|
|
10479
|
-
"validaci\xF3n",
|
|
10480
|
-
"escenarios de validacion",
|
|
10481
|
-
"escenarios de validaci\xF3n",
|
|
10482
|
-
"notes",
|
|
10483
|
-
"notas",
|
|
10484
|
-
"references",
|
|
10485
|
-
"referencias",
|
|
10486
|
-
"examples",
|
|
10487
|
-
"ejemplos",
|
|
10488
|
-
"learning",
|
|
10489
|
-
"learnings",
|
|
10490
|
-
"aprendizaje",
|
|
10491
|
-
"aprendizajes",
|
|
10492
|
-
// Work Item template sections
|
|
10493
|
-
"problem",
|
|
10494
|
-
"problema",
|
|
10495
|
-
"expected result",
|
|
10496
|
-
"resultado esperado",
|
|
10497
|
-
"refinement",
|
|
10498
|
-
"refinamiento",
|
|
10499
|
-
"implementation guidance",
|
|
10500
|
-
"guia de implementacion",
|
|
10501
|
-
"gu\xEDa de implementaci\xF3n",
|
|
10502
|
-
"definition of done",
|
|
10503
|
-
"definicion de hecho",
|
|
10504
|
-
"definici\xF3n de hecho",
|
|
10505
|
-
"commit gate",
|
|
10506
|
-
"future evolution",
|
|
10507
|
-
"evolucion futura",
|
|
10508
|
-
"evoluci\xF3n futura",
|
|
10509
|
-
"guiding principle",
|
|
10510
|
-
"principio rector",
|
|
10511
|
-
"open questions",
|
|
10512
|
-
"preguntas abiertas",
|
|
10513
|
-
"dependencies",
|
|
10514
|
-
"dependencias",
|
|
10515
|
-
"conceptual model",
|
|
10516
|
-
"goal"
|
|
10517
|
-
]);
|
|
10518
|
-
var RULE_KEYWORDS = [
|
|
10519
|
-
"siempre",
|
|
10520
|
-
"nunca",
|
|
10521
|
-
"debe",
|
|
10522
|
-
"deben",
|
|
10523
|
-
"requiere",
|
|
10524
|
-
"requieren",
|
|
10525
|
-
"invariante",
|
|
10526
|
-
"restriccion",
|
|
10527
|
-
"restricci\xF3n",
|
|
10528
|
-
"regla",
|
|
10529
|
-
"obligatorio",
|
|
10530
|
-
"must",
|
|
10531
|
-
"always",
|
|
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, " ");
|
|
10457
|
+
var SHINGLE_SIZE = 6;
|
|
10458
|
+
var MIN_SHARED_RUN = 6;
|
|
10459
|
+
function stripNoise(text2) {
|
|
10460
|
+
return text2.replace(/```[\s\S]*?```/g, " ").replace(/`[^`]*`/g, " ").replace(/https?:\/\/\S+|www\.\S+/gi, " ");
|
|
10541
10461
|
}
|
|
10542
|
-
function
|
|
10543
|
-
const
|
|
10544
|
-
|
|
10545
|
-
|
|
10546
|
-
|
|
10547
|
-
|
|
10548
|
-
|
|
10549
|
-
|
|
10462
|
+
function contentBlocks(body) {
|
|
10463
|
+
const blocks = [];
|
|
10464
|
+
let cur = [];
|
|
10465
|
+
let inFence = false;
|
|
10466
|
+
const flush = () => {
|
|
10467
|
+
if (cur.length) blocks.push(cur);
|
|
10468
|
+
cur = [];
|
|
10469
|
+
};
|
|
10470
|
+
for (const raw of body.split(/\r?\n/)) {
|
|
10471
|
+
const t = raw.trim();
|
|
10472
|
+
if (/^```/.test(t)) {
|
|
10473
|
+
inFence = !inFence;
|
|
10474
|
+
flush();
|
|
10475
|
+
continue;
|
|
10476
|
+
}
|
|
10477
|
+
if (inFence) continue;
|
|
10478
|
+
if (t === "" || /^#{1,6}\s/.test(t) || /^>/.test(t)) {
|
|
10479
|
+
flush();
|
|
10480
|
+
continue;
|
|
10481
|
+
}
|
|
10482
|
+
const isListItem = /^([-*+]\s+|\d+\.\s+)/.test(t);
|
|
10483
|
+
if (isListItem) flush();
|
|
10484
|
+
const text2 = stripNoise(t.replace(/^([-*+]\s+|\d+\.\s+)/, ""));
|
|
10485
|
+
const matched = text2.toLowerCase().match(/[a-záéíóúñü0-9]+/gi);
|
|
10486
|
+
if (matched) cur.push(...matched);
|
|
10550
10487
|
}
|
|
10551
|
-
|
|
10488
|
+
flush();
|
|
10489
|
+
return blocks;
|
|
10490
|
+
}
|
|
10491
|
+
function buildShingles(body) {
|
|
10492
|
+
const blocks = contentBlocks(body);
|
|
10493
|
+
const set = /* @__PURE__ */ new Set();
|
|
10494
|
+
for (const block of blocks) {
|
|
10495
|
+
for (let i = 0; i + SHINGLE_SIZE <= block.length; i++) {
|
|
10496
|
+
set.add(block.slice(i, i + SHINGLE_SIZE).join(" "));
|
|
10497
|
+
}
|
|
10498
|
+
}
|
|
10499
|
+
return { blocks, set };
|
|
10500
|
+
}
|
|
10501
|
+
function longestSharedRun(a, b) {
|
|
10502
|
+
let best = 0;
|
|
10503
|
+
let bestSnippet = "";
|
|
10504
|
+
for (const block of a.blocks) {
|
|
10505
|
+
let run = 0;
|
|
10506
|
+
let runStart = 0;
|
|
10507
|
+
for (let i = 0; i + SHINGLE_SIZE <= block.length; i++) {
|
|
10508
|
+
const key = block.slice(i, i + SHINGLE_SIZE).join(" ");
|
|
10509
|
+
if (b.set.has(key)) {
|
|
10510
|
+
if (run === 0) runStart = i;
|
|
10511
|
+
run += 1;
|
|
10512
|
+
if (run > best) {
|
|
10513
|
+
best = run;
|
|
10514
|
+
bestSnippet = block.slice(runStart, runStart + SHINGLE_SIZE + run - 1).join(" ");
|
|
10515
|
+
}
|
|
10516
|
+
} else {
|
|
10517
|
+
run = 0;
|
|
10518
|
+
}
|
|
10519
|
+
}
|
|
10520
|
+
}
|
|
10521
|
+
return { length: best, snippet: bestSnippet };
|
|
10522
|
+
}
|
|
10523
|
+
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;
|
|
10524
|
+
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;
|
|
10525
|
+
var TEST_RE = /(\btest\w*|\bpruebas?\b|coverage|cobertura|verde[s]?|green\b|assert\w*)/i;
|
|
10526
|
+
var BENCH_RE = /(benchmark\w*|ns\/op|µs\b|throughput|latenc\w*|ops\/s|\d+\s*%|faster|slower|baseline)/i;
|
|
10527
|
+
var EXPERIMENT_RE = /(experiment\w*|experiment[oa]\w*|prototyp\w*|prototip\w*|spike\b|probamos|probé|intentamos)/i;
|
|
10528
|
+
function splitSentences(text2) {
|
|
10529
|
+
return text2.replace(/\s+/g, " ").split(/(?<=[.!?;])\s+/).map((s) => s.trim()).filter(Boolean);
|
|
10530
|
+
}
|
|
10531
|
+
function classifyLearningSentence(sentence) {
|
|
10532
|
+
const s = sentence.trim();
|
|
10533
|
+
if (!s) return "none";
|
|
10534
|
+
const normative = NORMATIVE_RE.test(s);
|
|
10535
|
+
const pastResult = PAST_RESULT_RE.test(s);
|
|
10536
|
+
if (normative && !pastResult) return "durable-rule";
|
|
10537
|
+
if (BENCH_RE.test(s)) return "benchmark-evidence";
|
|
10538
|
+
if (pastResult) return "historical-result";
|
|
10539
|
+
if (TEST_RE.test(s)) return "test-observation";
|
|
10540
|
+
if (EXPERIMENT_RE.test(s)) return "experimental-result";
|
|
10541
|
+
return "none";
|
|
10542
|
+
}
|
|
10543
|
+
function firstRuleFragment(learning) {
|
|
10544
|
+
for (const sentence of splitSentences(learning)) {
|
|
10545
|
+
if (classifyLearningSentence(sentence) === "durable-rule") return sentence;
|
|
10546
|
+
}
|
|
10547
|
+
return null;
|
|
10552
10548
|
}
|
|
10553
10549
|
function sectionBody(body, titles) {
|
|
10554
10550
|
const lines = body.split(/\r?\n/);
|
|
@@ -10632,32 +10628,33 @@ function buildConsolidationPlan(dir, opts = {}) {
|
|
|
10632
10628
|
requires_semantic_review: false
|
|
10633
10629
|
});
|
|
10634
10630
|
}
|
|
10635
|
-
const
|
|
10636
|
-
|
|
10637
|
-
);
|
|
10638
|
-
const
|
|
10639
|
-
|
|
10640
|
-
|
|
10641
|
-
|
|
10631
|
+
const comparable = scoped.filter(isComparableKnowledge);
|
|
10632
|
+
const shingleIndex = /* @__PURE__ */ new Map();
|
|
10633
|
+
const shinglesByRel = /* @__PURE__ */ new Map();
|
|
10634
|
+
for (const la of comparable) {
|
|
10635
|
+
const shingles = buildShingles(la.body);
|
|
10636
|
+
shinglesByRel.set(la.rel, shingles);
|
|
10637
|
+
for (const key of shingles.set) {
|
|
10638
|
+
const arr = shingleIndex.get(key) ?? [];
|
|
10642
10639
|
arr.push(la);
|
|
10643
|
-
|
|
10640
|
+
shingleIndex.set(key, arr);
|
|
10644
10641
|
}
|
|
10645
10642
|
}
|
|
10646
|
-
const
|
|
10647
|
-
for (const
|
|
10643
|
+
const candidatePairs = /* @__PURE__ */ new Map();
|
|
10644
|
+
for (const arts of shingleIndex.values()) {
|
|
10648
10645
|
if (arts.length < 2) continue;
|
|
10649
10646
|
for (let i = 0; i < arts.length; i++) {
|
|
10650
10647
|
for (let j = i + 1; j < arts.length; j++) {
|
|
10651
10648
|
if (arts[i].rel === arts[j].rel) continue;
|
|
10652
10649
|
const key = [arts[i].rel, arts[j].rel].sort().join("||");
|
|
10653
|
-
|
|
10654
|
-
entry.shared.add(heading);
|
|
10655
|
-
pairHeadings.set(key, entry);
|
|
10650
|
+
if (!candidatePairs.has(key)) candidatePairs.set(key, { a: arts[i], b: arts[j] });
|
|
10656
10651
|
}
|
|
10657
10652
|
}
|
|
10658
10653
|
}
|
|
10659
|
-
for (const { a, b
|
|
10660
|
-
|
|
10654
|
+
for (const { a, b } of candidatePairs.values()) {
|
|
10655
|
+
const run = longestSharedRun(shinglesByRel.get(a.rel), shinglesByRel.get(b.rel));
|
|
10656
|
+
if (run.length < MIN_SHARED_RUN) continue;
|
|
10657
|
+
const passageWords = SHINGLE_SIZE + run.length - 1;
|
|
10661
10658
|
opportunities.push({
|
|
10662
10659
|
id: stableOpportunityId("knowledge_redundancy", [label(a), label(b)]),
|
|
10663
10660
|
category: "knowledge_redundancy",
|
|
@@ -10666,18 +10663,22 @@ function buildConsolidationPlan(dir, opts = {}) {
|
|
|
10666
10663
|
title: `Possible overlapping content between ${label(a)} and ${label(b)}`,
|
|
10667
10664
|
source_artifacts: [label(a), label(b)],
|
|
10668
10665
|
target_artifacts: [label(a), label(b)],
|
|
10669
|
-
evidence: [
|
|
10670
|
-
|
|
10666
|
+
evidence: [
|
|
10667
|
+
`A ${passageWords}-word passage appears verbatim in both artifacts: "${redactSecrets2(run.snippet)}".`
|
|
10668
|
+
],
|
|
10669
|
+
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
10670
|
possible_impact: "If genuinely duplicated, the same fact can drift out of sync across files.",
|
|
10672
|
-
suggested_action: "Semantic review: compare the
|
|
10671
|
+
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
10672
|
requires_semantic_review: true
|
|
10674
10673
|
});
|
|
10675
10674
|
}
|
|
10676
10675
|
for (const la of scoped) {
|
|
10677
10676
|
if (!isCompletedWorkItem(la)) continue;
|
|
10678
|
-
const
|
|
10679
|
-
if (!
|
|
10680
|
-
|
|
10677
|
+
const learningRaw = sectionBody(la.body, ["Learning", "Aprendizaje", "Aprendizajes", "Learnings"]);
|
|
10678
|
+
if (!learningRaw) continue;
|
|
10679
|
+
const learning = stripNoise(learningRaw);
|
|
10680
|
+
const ruleFragment = firstRuleFragment(learning);
|
|
10681
|
+
if (!ruleFragment) continue;
|
|
10681
10682
|
opportunities.push({
|
|
10682
10683
|
id: stableOpportunityId("unincorporated_learning", [label(la)]),
|
|
10683
10684
|
category: "unincorporated_learning",
|
|
@@ -10685,16 +10686,18 @@ function buildConsolidationPlan(dir, opts = {}) {
|
|
|
10685
10686
|
confidence: "requires-review",
|
|
10686
10687
|
title: `${label(la)} captured a learning that may belong in current knowledge`,
|
|
10687
10688
|
source_artifacts: [label(la)],
|
|
10688
|
-
target_artifacts: [
|
|
10689
|
-
|
|
10690
|
-
|
|
10689
|
+
target_artifacts: [],
|
|
10690
|
+
// unresolved — determined in semantic review (never invent a destination)
|
|
10691
|
+
evidence: [`Completed Work Item records a rule-like learning (heuristic classification): "${redactSecrets2(ruleFragment)}"`],
|
|
10692
|
+
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
10693
|
possible_impact: "A relevant constraint stays buried in delivery history instead of informing current work.",
|
|
10692
|
-
suggested_action: "Semantic review:
|
|
10694
|
+
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
10695
|
requires_semantic_review: true
|
|
10694
10696
|
});
|
|
10695
10697
|
}
|
|
10696
10698
|
const weakByFolder = /* @__PURE__ */ new Map();
|
|
10697
10699
|
for (const la of scoped) {
|
|
10700
|
+
if (!isConsolidatableKnowledge(la)) continue;
|
|
10698
10701
|
const quality = safeQuality(dir, la.rel);
|
|
10699
10702
|
if (quality === "placeholder" || quality === "weak") {
|
|
10700
10703
|
opportunities.push({
|
|
@@ -10705,11 +10708,11 @@ function buildConsolidationPlan(dir, opts = {}) {
|
|
|
10705
10708
|
title: `${label(la)} is ${quality} and may need consolidation or expansion`,
|
|
10706
10709
|
source_artifacts: [label(la)],
|
|
10707
10710
|
target_artifacts: [label(la)],
|
|
10708
|
-
evidence: [`Artifact quality analysis classifies this artifact as "${quality}".`],
|
|
10709
|
-
rationale: "
|
|
10711
|
+
evidence: [`Artifact quality analysis classifies this canonical knowledge artifact as "${quality}".`],
|
|
10712
|
+
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
10713
|
possible_impact: "Readers must open more files to assemble a complete picture.",
|
|
10711
|
-
suggested_action: "
|
|
10712
|
-
requires_semantic_review:
|
|
10714
|
+
suggested_action: "Semantic review: decide whether to expand, merge into a stronger artifact, or cross-reference it.",
|
|
10715
|
+
requires_semantic_review: true
|
|
10713
10716
|
});
|
|
10714
10717
|
const folder = la.rel.split("/").slice(0, -1).join("/");
|
|
10715
10718
|
const arr = weakByFolder.get(folder) ?? [];
|
|
@@ -10724,11 +10727,11 @@ function buildConsolidationPlan(dir, opts = {}) {
|
|
|
10724
10727
|
category: "knowledge_fragmentation",
|
|
10725
10728
|
classification: "suggested",
|
|
10726
10729
|
confidence: "requires-review",
|
|
10727
|
-
title: `${folder}/ holds ${arts.length} low-signal artifacts \u2014 possible fragmentation`,
|
|
10730
|
+
title: `${folder}/ holds ${arts.length} low-signal canonical artifacts \u2014 possible fragmentation`,
|
|
10728
10731
|
source_artifacts: arts.map((a) => label(a)),
|
|
10729
10732
|
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.",
|
|
10733
|
+
evidence: [`${arts.length} placeholder/weak canonical knowledge artifacts in the same folder: ${arts.map((a) => a.rel.split("/").pop()).join(", ")}.`],
|
|
10734
|
+
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
10735
|
possible_impact: "Related knowledge is spread across too many files to follow.",
|
|
10733
10736
|
suggested_action: "Semantic review: evaluate whether cross-references or a consolidation would add clarity. Do not merge by file count alone.",
|
|
10734
10737
|
requires_semantic_review: true
|
|
@@ -10833,7 +10836,9 @@ function renderConsolidationMarkdown(plan) {
|
|
|
10833
10836
|
lines.push(`- Classification: **${o.classification}**${o.requires_semantic_review ? " (requires semantic review)" : ""}`);
|
|
10834
10837
|
lines.push(`- Confidence: ${o.confidence}`);
|
|
10835
10838
|
lines.push(`- Source: ${o.source_artifacts.join(", ") || "\u2014"}`);
|
|
10836
|
-
lines.push(
|
|
10839
|
+
lines.push(
|
|
10840
|
+
`- Suggested target: ${o.target_artifacts.length > 0 ? o.target_artifacts.join(", ") : "(unresolved \u2014 to be determined in semantic review)"}`
|
|
10841
|
+
);
|
|
10837
10842
|
lines.push(`- Evidence:`);
|
|
10838
10843
|
for (const e of o.evidence) lines.push(` - ${e}`);
|
|
10839
10844
|
lines.push(`- Rationale: ${o.rationale}`);
|
|
@@ -10858,15 +10863,25 @@ function isCompletedWorkItem(la) {
|
|
|
10858
10863
|
const p = toPosix6(la.artifact.filePath);
|
|
10859
10864
|
return p.includes("/delivery/work-items/completed/") || isWorkItem(la) && la.artifact.status === "completed";
|
|
10860
10865
|
}
|
|
10861
|
-
function
|
|
10862
|
-
const
|
|
10863
|
-
return
|
|
10866
|
+
function isScaffolding(la) {
|
|
10867
|
+
const p = toPosix6(la.artifact.filePath);
|
|
10868
|
+
return p.includes(`/${KNOWLEDGE5}/agents/`) || p.includes(`/${KNOWLEDGE5}/skills/`) || p.includes(`/${KNOWLEDGE5}/external/`) || la.artifact.type === "knowledge-capsule";
|
|
10869
|
+
}
|
|
10870
|
+
var NON_KNOWLEDGE_DOC_TYPES = /* @__PURE__ */ new Set([
|
|
10871
|
+
"roadmap",
|
|
10872
|
+
"initiative",
|
|
10873
|
+
"deprecation",
|
|
10874
|
+
"knowledge-capsule",
|
|
10875
|
+
"inventory",
|
|
10876
|
+
"project-resource"
|
|
10877
|
+
]);
|
|
10878
|
+
function isComparableKnowledge(la) {
|
|
10879
|
+
return !isWorkItem(la) && la.artifact.type !== "roadmap" && !isScaffolding(la);
|
|
10864
10880
|
}
|
|
10865
|
-
function
|
|
10866
|
-
|
|
10867
|
-
|
|
10868
|
-
|
|
10869
|
-
return redactSecrets2(s.trim());
|
|
10881
|
+
function isConsolidatableKnowledge(la) {
|
|
10882
|
+
if (isWorkItem(la) || isScaffolding(la)) return false;
|
|
10883
|
+
if (NON_KNOWLEDGE_DOC_TYPES.has(la.artifact.type)) return false;
|
|
10884
|
+
return la.layer === "Business" || la.layer === "Product" || la.layer === "Tech";
|
|
10870
10885
|
}
|
|
10871
10886
|
var SECRET_TOKEN_PATTERNS = [
|
|
10872
10887
|
/\bgh[pours]_[A-Za-z0-9]{16,}\b/g,
|
package/dist/index.js
CHANGED
|
@@ -25961,101 +25961,97 @@ 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
|
-
"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, " ");
|
|
25964
|
+
var SHINGLE_SIZE = 6;
|
|
25965
|
+
var MIN_SHARED_RUN = 6;
|
|
25966
|
+
function stripNoise(text2) {
|
|
25967
|
+
return text2.replace(/```[\s\S]*?```/g, " ").replace(/`[^`]*`/g, " ").replace(/https?:\/\/\S+|www\.\S+/gi, " ");
|
|
26048
25968
|
}
|
|
26049
|
-
function
|
|
26050
|
-
const
|
|
26051
|
-
|
|
26052
|
-
|
|
26053
|
-
|
|
26054
|
-
|
|
26055
|
-
|
|
26056
|
-
|
|
25969
|
+
function contentBlocks(body) {
|
|
25970
|
+
const blocks = [];
|
|
25971
|
+
let cur = [];
|
|
25972
|
+
let inFence = false;
|
|
25973
|
+
const flush2 = () => {
|
|
25974
|
+
if (cur.length) blocks.push(cur);
|
|
25975
|
+
cur = [];
|
|
25976
|
+
};
|
|
25977
|
+
for (const raw of body.split(/\r?\n/)) {
|
|
25978
|
+
const t = raw.trim();
|
|
25979
|
+
if (/^```/.test(t)) {
|
|
25980
|
+
inFence = !inFence;
|
|
25981
|
+
flush2();
|
|
25982
|
+
continue;
|
|
25983
|
+
}
|
|
25984
|
+
if (inFence) continue;
|
|
25985
|
+
if (t === "" || /^#{1,6}\s/.test(t) || /^>/.test(t)) {
|
|
25986
|
+
flush2();
|
|
25987
|
+
continue;
|
|
25988
|
+
}
|
|
25989
|
+
const isListItem = /^([-*+]\s+|\d+\.\s+)/.test(t);
|
|
25990
|
+
if (isListItem) flush2();
|
|
25991
|
+
const text2 = stripNoise(t.replace(/^([-*+]\s+|\d+\.\s+)/, ""));
|
|
25992
|
+
const matched = text2.toLowerCase().match(/[a-záéíóúñü0-9]+/gi);
|
|
25993
|
+
if (matched) cur.push(...matched);
|
|
26057
25994
|
}
|
|
26058
|
-
|
|
25995
|
+
flush2();
|
|
25996
|
+
return blocks;
|
|
25997
|
+
}
|
|
25998
|
+
function buildShingles(body) {
|
|
25999
|
+
const blocks = contentBlocks(body);
|
|
26000
|
+
const set = /* @__PURE__ */ new Set();
|
|
26001
|
+
for (const block of blocks) {
|
|
26002
|
+
for (let i = 0; i + SHINGLE_SIZE <= block.length; i++) {
|
|
26003
|
+
set.add(block.slice(i, i + SHINGLE_SIZE).join(" "));
|
|
26004
|
+
}
|
|
26005
|
+
}
|
|
26006
|
+
return { blocks, set };
|
|
26007
|
+
}
|
|
26008
|
+
function longestSharedRun(a, b) {
|
|
26009
|
+
let best = 0;
|
|
26010
|
+
let bestSnippet = "";
|
|
26011
|
+
for (const block of a.blocks) {
|
|
26012
|
+
let run = 0;
|
|
26013
|
+
let runStart = 0;
|
|
26014
|
+
for (let i = 0; i + SHINGLE_SIZE <= block.length; i++) {
|
|
26015
|
+
const key = block.slice(i, i + SHINGLE_SIZE).join(" ");
|
|
26016
|
+
if (b.set.has(key)) {
|
|
26017
|
+
if (run === 0) runStart = i;
|
|
26018
|
+
run += 1;
|
|
26019
|
+
if (run > best) {
|
|
26020
|
+
best = run;
|
|
26021
|
+
bestSnippet = block.slice(runStart, runStart + SHINGLE_SIZE + run - 1).join(" ");
|
|
26022
|
+
}
|
|
26023
|
+
} else {
|
|
26024
|
+
run = 0;
|
|
26025
|
+
}
|
|
26026
|
+
}
|
|
26027
|
+
}
|
|
26028
|
+
return { length: best, snippet: bestSnippet };
|
|
26029
|
+
}
|
|
26030
|
+
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;
|
|
26031
|
+
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;
|
|
26032
|
+
var TEST_RE = /(\btest\w*|\bpruebas?\b|coverage|cobertura|verde[s]?|green\b|assert\w*)/i;
|
|
26033
|
+
var BENCH_RE = /(benchmark\w*|ns\/op|µs\b|throughput|latenc\w*|ops\/s|\d+\s*%|faster|slower|baseline)/i;
|
|
26034
|
+
var EXPERIMENT_RE = /(experiment\w*|experiment[oa]\w*|prototyp\w*|prototip\w*|spike\b|probamos|probé|intentamos)/i;
|
|
26035
|
+
function splitSentences(text2) {
|
|
26036
|
+
return text2.replace(/\s+/g, " ").split(/(?<=[.!?;])\s+/).map((s) => s.trim()).filter(Boolean);
|
|
26037
|
+
}
|
|
26038
|
+
function classifyLearningSentence(sentence) {
|
|
26039
|
+
const s = sentence.trim();
|
|
26040
|
+
if (!s) return "none";
|
|
26041
|
+
const normative = NORMATIVE_RE.test(s);
|
|
26042
|
+
const pastResult = PAST_RESULT_RE.test(s);
|
|
26043
|
+
if (normative && !pastResult) return "durable-rule";
|
|
26044
|
+
if (BENCH_RE.test(s)) return "benchmark-evidence";
|
|
26045
|
+
if (pastResult) return "historical-result";
|
|
26046
|
+
if (TEST_RE.test(s)) return "test-observation";
|
|
26047
|
+
if (EXPERIMENT_RE.test(s)) return "experimental-result";
|
|
26048
|
+
return "none";
|
|
26049
|
+
}
|
|
26050
|
+
function firstRuleFragment(learning) {
|
|
26051
|
+
for (const sentence of splitSentences(learning)) {
|
|
26052
|
+
if (classifyLearningSentence(sentence) === "durable-rule") return sentence;
|
|
26053
|
+
}
|
|
26054
|
+
return null;
|
|
26059
26055
|
}
|
|
26060
26056
|
function sectionBody(body, titles) {
|
|
26061
26057
|
const lines = body.split(/\r?\n/);
|
|
@@ -26139,32 +26135,33 @@ function buildConsolidationPlan(dir, opts = {}) {
|
|
|
26139
26135
|
requires_semantic_review: false
|
|
26140
26136
|
});
|
|
26141
26137
|
}
|
|
26142
|
-
const
|
|
26143
|
-
|
|
26144
|
-
);
|
|
26145
|
-
const
|
|
26146
|
-
|
|
26147
|
-
|
|
26148
|
-
|
|
26138
|
+
const comparable = scoped.filter(isComparableKnowledge);
|
|
26139
|
+
const shingleIndex = /* @__PURE__ */ new Map();
|
|
26140
|
+
const shinglesByRel = /* @__PURE__ */ new Map();
|
|
26141
|
+
for (const la of comparable) {
|
|
26142
|
+
const shingles = buildShingles(la.body);
|
|
26143
|
+
shinglesByRel.set(la.rel, shingles);
|
|
26144
|
+
for (const key of shingles.set) {
|
|
26145
|
+
const arr = shingleIndex.get(key) ?? [];
|
|
26149
26146
|
arr.push(la);
|
|
26150
|
-
|
|
26147
|
+
shingleIndex.set(key, arr);
|
|
26151
26148
|
}
|
|
26152
26149
|
}
|
|
26153
|
-
const
|
|
26154
|
-
for (const
|
|
26150
|
+
const candidatePairs = /* @__PURE__ */ new Map();
|
|
26151
|
+
for (const arts of shingleIndex.values()) {
|
|
26155
26152
|
if (arts.length < 2) continue;
|
|
26156
26153
|
for (let i = 0; i < arts.length; i++) {
|
|
26157
26154
|
for (let j = i + 1; j < arts.length; j++) {
|
|
26158
26155
|
if (arts[i].rel === arts[j].rel) continue;
|
|
26159
26156
|
const key = [arts[i].rel, arts[j].rel].sort().join("||");
|
|
26160
|
-
|
|
26161
|
-
entry.shared.add(heading);
|
|
26162
|
-
pairHeadings.set(key, entry);
|
|
26157
|
+
if (!candidatePairs.has(key)) candidatePairs.set(key, { a: arts[i], b: arts[j] });
|
|
26163
26158
|
}
|
|
26164
26159
|
}
|
|
26165
26160
|
}
|
|
26166
|
-
for (const { a, b
|
|
26167
|
-
|
|
26161
|
+
for (const { a, b } of candidatePairs.values()) {
|
|
26162
|
+
const run = longestSharedRun(shinglesByRel.get(a.rel), shinglesByRel.get(b.rel));
|
|
26163
|
+
if (run.length < MIN_SHARED_RUN) continue;
|
|
26164
|
+
const passageWords = SHINGLE_SIZE + run.length - 1;
|
|
26168
26165
|
opportunities.push({
|
|
26169
26166
|
id: stableOpportunityId("knowledge_redundancy", [label(a), label(b)]),
|
|
26170
26167
|
category: "knowledge_redundancy",
|
|
@@ -26173,18 +26170,22 @@ function buildConsolidationPlan(dir, opts = {}) {
|
|
|
26173
26170
|
title: `Possible overlapping content between ${label(a)} and ${label(b)}`,
|
|
26174
26171
|
source_artifacts: [label(a), label(b)],
|
|
26175
26172
|
target_artifacts: [label(a), label(b)],
|
|
26176
|
-
evidence: [
|
|
26177
|
-
|
|
26173
|
+
evidence: [
|
|
26174
|
+
`A ${passageWords}-word passage appears verbatim in both artifacts: "${redactSecrets2(run.snippet)}".`
|
|
26175
|
+
],
|
|
26176
|
+
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
26177
|
possible_impact: "If genuinely duplicated, the same fact can drift out of sync across files.",
|
|
26179
|
-
suggested_action: "Semantic review: compare the
|
|
26178
|
+
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
26179
|
requires_semantic_review: true
|
|
26181
26180
|
});
|
|
26182
26181
|
}
|
|
26183
26182
|
for (const la of scoped) {
|
|
26184
26183
|
if (!isCompletedWorkItem(la)) continue;
|
|
26185
|
-
const
|
|
26186
|
-
if (!
|
|
26187
|
-
|
|
26184
|
+
const learningRaw = sectionBody(la.body, ["Learning", "Aprendizaje", "Aprendizajes", "Learnings"]);
|
|
26185
|
+
if (!learningRaw) continue;
|
|
26186
|
+
const learning = stripNoise(learningRaw);
|
|
26187
|
+
const ruleFragment = firstRuleFragment(learning);
|
|
26188
|
+
if (!ruleFragment) continue;
|
|
26188
26189
|
opportunities.push({
|
|
26189
26190
|
id: stableOpportunityId("unincorporated_learning", [label(la)]),
|
|
26190
26191
|
category: "unincorporated_learning",
|
|
@@ -26192,16 +26193,18 @@ function buildConsolidationPlan(dir, opts = {}) {
|
|
|
26192
26193
|
confidence: "requires-review",
|
|
26193
26194
|
title: `${label(la)} captured a learning that may belong in current knowledge`,
|
|
26194
26195
|
source_artifacts: [label(la)],
|
|
26195
|
-
target_artifacts: [
|
|
26196
|
-
|
|
26197
|
-
|
|
26196
|
+
target_artifacts: [],
|
|
26197
|
+
// unresolved — determined in semantic review (never invent a destination)
|
|
26198
|
+
evidence: [`Completed Work Item records a rule-like learning (heuristic classification): "${redactSecrets2(ruleFragment)}"`],
|
|
26199
|
+
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
26200
|
possible_impact: "A relevant constraint stays buried in delivery history instead of informing current work.",
|
|
26199
|
-
suggested_action: "Semantic review:
|
|
26201
|
+
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
26202
|
requires_semantic_review: true
|
|
26201
26203
|
});
|
|
26202
26204
|
}
|
|
26203
26205
|
const weakByFolder = /* @__PURE__ */ new Map();
|
|
26204
26206
|
for (const la of scoped) {
|
|
26207
|
+
if (!isConsolidatableKnowledge(la)) continue;
|
|
26205
26208
|
const quality = safeQuality(dir, la.rel);
|
|
26206
26209
|
if (quality === "placeholder" || quality === "weak") {
|
|
26207
26210
|
opportunities.push({
|
|
@@ -26212,11 +26215,11 @@ function buildConsolidationPlan(dir, opts = {}) {
|
|
|
26212
26215
|
title: `${label(la)} is ${quality} and may need consolidation or expansion`,
|
|
26213
26216
|
source_artifacts: [label(la)],
|
|
26214
26217
|
target_artifacts: [label(la)],
|
|
26215
|
-
evidence: [`Artifact quality analysis classifies this artifact as "${quality}".`],
|
|
26216
|
-
rationale: "
|
|
26218
|
+
evidence: [`Artifact quality analysis classifies this canonical knowledge artifact as "${quality}".`],
|
|
26219
|
+
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
26220
|
possible_impact: "Readers must open more files to assemble a complete picture.",
|
|
26218
|
-
suggested_action: "
|
|
26219
|
-
requires_semantic_review:
|
|
26221
|
+
suggested_action: "Semantic review: decide whether to expand, merge into a stronger artifact, or cross-reference it.",
|
|
26222
|
+
requires_semantic_review: true
|
|
26220
26223
|
});
|
|
26221
26224
|
const folder = la.rel.split("/").slice(0, -1).join("/");
|
|
26222
26225
|
const arr = weakByFolder.get(folder) ?? [];
|
|
@@ -26231,11 +26234,11 @@ function buildConsolidationPlan(dir, opts = {}) {
|
|
|
26231
26234
|
category: "knowledge_fragmentation",
|
|
26232
26235
|
classification: "suggested",
|
|
26233
26236
|
confidence: "requires-review",
|
|
26234
|
-
title: `${folder}/ holds ${arts.length} low-signal artifacts \u2014 possible fragmentation`,
|
|
26237
|
+
title: `${folder}/ holds ${arts.length} low-signal canonical artifacts \u2014 possible fragmentation`,
|
|
26235
26238
|
source_artifacts: arts.map((a) => label(a)),
|
|
26236
26239
|
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.",
|
|
26240
|
+
evidence: [`${arts.length} placeholder/weak canonical knowledge artifacts in the same folder: ${arts.map((a) => a.rel.split("/").pop()).join(", ")}.`],
|
|
26241
|
+
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
26242
|
possible_impact: "Related knowledge is spread across too many files to follow.",
|
|
26240
26243
|
suggested_action: "Semantic review: evaluate whether cross-references or a consolidation would add clarity. Do not merge by file count alone.",
|
|
26241
26244
|
requires_semantic_review: true
|
|
@@ -26327,7 +26330,9 @@ function renderConsolidationMarkdown(plan) {
|
|
|
26327
26330
|
lines.push(`- Classification: **${o.classification}**${o.requires_semantic_review ? " (requires semantic review)" : ""}`);
|
|
26328
26331
|
lines.push(`- Confidence: ${o.confidence}`);
|
|
26329
26332
|
lines.push(`- Source: ${o.source_artifacts.join(", ") || "\u2014"}`);
|
|
26330
|
-
lines.push(
|
|
26333
|
+
lines.push(
|
|
26334
|
+
`- Suggested target: ${o.target_artifacts.length > 0 ? o.target_artifacts.join(", ") : "(unresolved \u2014 to be determined in semantic review)"}`
|
|
26335
|
+
);
|
|
26331
26336
|
lines.push(`- Evidence:`);
|
|
26332
26337
|
for (const e of o.evidence) lines.push(` - ${e}`);
|
|
26333
26338
|
lines.push(`- Rationale: ${o.rationale}`);
|
|
@@ -26352,15 +26357,25 @@ function isCompletedWorkItem(la) {
|
|
|
26352
26357
|
const p = toPosix7(la.artifact.filePath);
|
|
26353
26358
|
return p.includes("/delivery/work-items/completed/") || isWorkItem(la) && la.artifact.status === "completed";
|
|
26354
26359
|
}
|
|
26355
|
-
function
|
|
26356
|
-
const
|
|
26357
|
-
return
|
|
26360
|
+
function isScaffolding(la) {
|
|
26361
|
+
const p = toPosix7(la.artifact.filePath);
|
|
26362
|
+
return p.includes(`/${KNOWLEDGE6}/agents/`) || p.includes(`/${KNOWLEDGE6}/skills/`) || p.includes(`/${KNOWLEDGE6}/external/`) || la.artifact.type === "knowledge-capsule";
|
|
26363
|
+
}
|
|
26364
|
+
var NON_KNOWLEDGE_DOC_TYPES = /* @__PURE__ */ new Set([
|
|
26365
|
+
"roadmap",
|
|
26366
|
+
"initiative",
|
|
26367
|
+
"deprecation",
|
|
26368
|
+
"knowledge-capsule",
|
|
26369
|
+
"inventory",
|
|
26370
|
+
"project-resource"
|
|
26371
|
+
]);
|
|
26372
|
+
function isComparableKnowledge(la) {
|
|
26373
|
+
return !isWorkItem(la) && la.artifact.type !== "roadmap" && !isScaffolding(la);
|
|
26358
26374
|
}
|
|
26359
|
-
function
|
|
26360
|
-
|
|
26361
|
-
|
|
26362
|
-
|
|
26363
|
-
return redactSecrets2(s.trim());
|
|
26375
|
+
function isConsolidatableKnowledge(la) {
|
|
26376
|
+
if (isWorkItem(la) || isScaffolding(la)) return false;
|
|
26377
|
+
if (NON_KNOWLEDGE_DOC_TYPES.has(la.artifact.type)) return false;
|
|
26378
|
+
return la.layer === "Business" || la.layer === "Product" || la.layer === "Tech";
|
|
26364
26379
|
}
|
|
26365
26380
|
var SECRET_TOKEN_PATTERNS = [
|
|
26366
26381
|
/\bgh[pours]_[A-Za-z0-9]{16,}\b/g,
|