@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.
- package/dist/admin-dist/assets/{architectureDiagram-3BPJPVTR-CMM88Fvp.js → architectureDiagram-3BPJPVTR-DmExPmRV.js} +1 -1
- package/dist/admin-dist/assets/{chunk-727SXJPM-Bs62kBjZ.js → chunk-727SXJPM-TzlKi4JG.js} +1 -1
- package/dist/admin-dist/assets/{chunk-AQP2D5EJ-DRvPiKZx.js → chunk-AQP2D5EJ-uLib6NNt.js} +1 -1
- package/dist/admin-dist/assets/{classDiagram-v2-Q7XG4LA2-reL3VD_F.js → classDiagram-4FO5ZUOK-p84ByjtF.js} +1 -1
- package/dist/admin-dist/assets/{classDiagram-4FO5ZUOK-reL3VD_F.js → classDiagram-v2-Q7XG4LA2-p84ByjtF.js} +1 -1
- package/dist/admin-dist/assets/{dagre-BM42HDAG-BiSamapq.js → dagre-BM42HDAG-DfHID2Qj.js} +1 -1
- package/dist/admin-dist/assets/{diagram-2AECGRRQ-B4Icn510.js → diagram-2AECGRRQ-DDK0Mbu2.js} +1 -1
- package/dist/admin-dist/assets/{diagram-5GNKFQAL-CRhc2zde.js → diagram-5GNKFQAL-G7QIVN3E.js} +1 -1
- package/dist/admin-dist/assets/{diagram-LMA3HP47-CMeLXuDa.js → diagram-LMA3HP47-C1R6_2ZM.js} +1 -1
- package/dist/admin-dist/assets/{diagram-OG6HWLK6-CgyZ3SmF.js → diagram-OG6HWLK6-C2BKviiy.js} +1 -1
- package/dist/admin-dist/assets/{erDiagram-TEJ5UH35-DO8yBpvF.js → erDiagram-TEJ5UH35-BON2r_Ng.js} +1 -1
- package/dist/admin-dist/assets/{flowDiagram-I6XJVG4X-BMmW0ZfD.js → flowDiagram-I6XJVG4X-BupCBn3Y.js} +1 -1
- package/dist/admin-dist/assets/{ganttDiagram-6RSMTGT7-DfLBlZnZ.js → ganttDiagram-6RSMTGT7-D38vIu5c.js} +1 -1
- package/dist/admin-dist/assets/{index-Dot4bbKF.js → index-C0OcFqnH.js} +4 -4
- package/dist/admin-dist/assets/{infoDiagram-5YYISTIA-D4-F59aW.js → infoDiagram-5YYISTIA-Dg0XWL5A.js} +1 -1
- package/dist/admin-dist/assets/{ishikawaDiagram-YF4QCWOH-C4V7mlnH.js → ishikawaDiagram-YF4QCWOH-BmqtQz0f.js} +1 -1
- package/dist/admin-dist/assets/{kanban-definition-UN3LZRKU-TvjpEN_z.js → kanban-definition-UN3LZRKU-Q4XSbP4K.js} +1 -1
- package/dist/admin-dist/assets/{linear-Ceo1WLSG.js → linear-B8RusEEd.js} +1 -1
- package/dist/admin-dist/assets/{mindmap-definition-RKZ34NQL-Dp8dKxKQ.js → mindmap-definition-RKZ34NQL-CTC4EsvK.js} +1 -1
- package/dist/admin-dist/assets/{pieDiagram-4H26LBE5-DJcqowoN.js → pieDiagram-4H26LBE5-kbXjsg4R.js} +1 -1
- package/dist/admin-dist/assets/{quadrantDiagram-W4KKPZXB-1zF7s5vy.js → quadrantDiagram-W4KKPZXB-mSk4KLyQ.js} +1 -1
- package/dist/admin-dist/assets/{requirementDiagram-4Y6WPE33-Cfur45jl.js → requirementDiagram-4Y6WPE33-CibbOF7W.js} +1 -1
- package/dist/admin-dist/assets/{sequenceDiagram-3UESZ5HK-aantaPdN.js → sequenceDiagram-3UESZ5HK-q-174vfI.js} +1 -1
- package/dist/admin-dist/assets/{stateDiagram-AJRCARHV-ClWINPoO.js → stateDiagram-AJRCARHV-C7Puq4hY.js} +1 -1
- package/dist/admin-dist/assets/{stateDiagram-v2-BHNVJYJU-CAAGRYC1.js → stateDiagram-v2-BHNVJYJU-0x5B8-RG.js} +1 -1
- package/dist/admin-dist/assets/{timeline-definition-PNZ67QCA-BIYt-JNC.js → timeline-definition-PNZ67QCA-BTU1Sz9c.js} +1 -1
- package/dist/admin-dist/assets/{vennDiagram-CIIHVFJN-CCeVIZsB.js → vennDiagram-CIIHVFJN-CioUtDz7.js} +1 -1
- package/dist/admin-dist/assets/{wardleyDiagram-YWT4CUSO-B6hFn7xR.js → wardleyDiagram-YWT4CUSO-Bptd1Iun.js} +1 -1
- package/dist/admin-dist/assets/{xychartDiagram-2RQKCTM6-C4T-rH7k.js → xychartDiagram-2RQKCTM6-BP8nOU9q.js} +1 -1
- package/dist/admin-dist/index.html +1 -1
- package/dist/admin-server/index.js +6 -0
- package/dist/core.js +815 -52
- package/dist/index.js +854 -68
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -166,6 +166,21 @@ function setProjectMode(dir, mode) {
|
|
|
166
166
|
if (!updated) throw new ConfigError("Could not reload .kaddo/config.yml after updating project.mode.");
|
|
167
167
|
return updated;
|
|
168
168
|
}
|
|
169
|
+
function requireConfig(dir) {
|
|
170
|
+
let config;
|
|
171
|
+
try {
|
|
172
|
+
config = loadConfig(dir);
|
|
173
|
+
} catch (err) {
|
|
174
|
+
const message = err instanceof ConfigError ? err.message : String(err);
|
|
175
|
+
console.error(message);
|
|
176
|
+
process.exit(1);
|
|
177
|
+
}
|
|
178
|
+
if (!config) {
|
|
179
|
+
console.error("No .kaddo/config.yml found. Run `kaddo init` first.");
|
|
180
|
+
process.exit(1);
|
|
181
|
+
}
|
|
182
|
+
return config;
|
|
183
|
+
}
|
|
169
184
|
function projectRole(config) {
|
|
170
185
|
return config.project.role ?? config.multirepo?.role;
|
|
171
186
|
}
|
|
@@ -1888,6 +1903,29 @@ var RESOURCE_TYPES = [
|
|
|
1888
1903
|
];
|
|
1889
1904
|
var INTERFACE_TYPES = ["cli", "mcp", "api", "sql", "sdk", "iac", "console", "other"];
|
|
1890
1905
|
var RESOURCE_ROLES = ["affected", "implementation", "validation", "delivery"];
|
|
1906
|
+
var REDACTED_COORDINATE = "\u2022\u2022\u2022\u2022 (hidden \u2014 store as an authentication reference)";
|
|
1907
|
+
var SECRET_KEY_RE = /(pass(word|phrase)?|secret|token|api[_-]?key|\bkey\b|credential|private|auth[_-]?token|access[_-]?key)/i;
|
|
1908
|
+
var SECRET_VALUE_PATTERNS = [
|
|
1909
|
+
/\b(AKIA|ASIA)[A-Z0-9]{8,}/,
|
|
1910
|
+
// AWS access key id
|
|
1911
|
+
/\b(ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{20,}/,
|
|
1912
|
+
// GitHub tokens
|
|
1913
|
+
/\bxox[baprs]-[A-Za-z0-9-]{10,}/,
|
|
1914
|
+
// Slack tokens
|
|
1915
|
+
/\bsk-[A-Za-z0-9]{16,}/,
|
|
1916
|
+
// OpenAI-style secret keys
|
|
1917
|
+
/\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\./,
|
|
1918
|
+
// JWT
|
|
1919
|
+
/\w+=[^;\s]{6,}/,
|
|
1920
|
+
// key=value credential fragments
|
|
1921
|
+
/^[A-Za-z0-9+/]{40,}={0,2}$/
|
|
1922
|
+
// long opaque base64 blob
|
|
1923
|
+
];
|
|
1924
|
+
function looksLikeSecretCoordinate(key, value) {
|
|
1925
|
+
if (SECRET_KEY_RE.test(key)) return true;
|
|
1926
|
+
const v = value.trim();
|
|
1927
|
+
return SECRET_VALUE_PATTERNS.some((re) => re.test(v));
|
|
1928
|
+
}
|
|
1891
1929
|
function str(v) {
|
|
1892
1930
|
return typeof v === "string" && v.trim() ? v.trim() : null;
|
|
1893
1931
|
}
|
|
@@ -1916,6 +1954,29 @@ function parseInterfaces(v) {
|
|
|
1916
1954
|
}
|
|
1917
1955
|
return out;
|
|
1918
1956
|
}
|
|
1957
|
+
function parseConnectionProfiles(v) {
|
|
1958
|
+
if (!Array.isArray(v)) return [];
|
|
1959
|
+
const out = [];
|
|
1960
|
+
for (const raw of v) {
|
|
1961
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) continue;
|
|
1962
|
+
const o = raw;
|
|
1963
|
+
const coords = [];
|
|
1964
|
+
const rawCoords = o.coordinates;
|
|
1965
|
+
if (rawCoords && typeof rawCoords === "object" && !Array.isArray(rawCoords)) {
|
|
1966
|
+
for (const [key, val] of Object.entries(rawCoords)) {
|
|
1967
|
+
const k = key.trim();
|
|
1968
|
+
const value = val == null ? "" : String(val).trim();
|
|
1969
|
+
if (!k || !value) continue;
|
|
1970
|
+
coords.push({ key: k, value: looksLikeSecretCoordinate(k, value) ? REDACTED_COORDINATE : value });
|
|
1971
|
+
}
|
|
1972
|
+
}
|
|
1973
|
+
const environment = str(o.environment);
|
|
1974
|
+
const iface = str(o.interface);
|
|
1975
|
+
if (!environment && !iface && coords.length === 0) continue;
|
|
1976
|
+
out.push({ environment, interface: iface, coordinates: coords });
|
|
1977
|
+
}
|
|
1978
|
+
return out;
|
|
1979
|
+
}
|
|
1919
1980
|
function parseBoundaries(v) {
|
|
1920
1981
|
if (!v || typeof v !== "object" || Array.isArray(v)) return {};
|
|
1921
1982
|
const out = {};
|
|
@@ -1964,6 +2025,7 @@ function toDetail(filePath, relPath, raw) {
|
|
|
1964
2025
|
const a = parseAuth(fm.authentication);
|
|
1965
2026
|
return { authRefs: a.refs, authMode: a.mode };
|
|
1966
2027
|
})(),
|
|
2028
|
+
connectionProfiles: parseConnectionProfiles(fm.connection_profiles),
|
|
1967
2029
|
markdownBody: body
|
|
1968
2030
|
};
|
|
1969
2031
|
}
|
|
@@ -3634,7 +3696,8 @@ var AGENT_GROUPS = {
|
|
|
3634
3696
|
"work-item-agent.md",
|
|
3635
3697
|
"implementation-agent.md",
|
|
3636
3698
|
"ownership-agent.md",
|
|
3637
|
-
"git-strategy-agent.md"
|
|
3699
|
+
"git-strategy-agent.md",
|
|
3700
|
+
"knowledge-consolidation-agent.md"
|
|
3638
3701
|
],
|
|
3639
3702
|
utilities: ["legacy-agent.md"]
|
|
3640
3703
|
};
|
|
@@ -4341,7 +4404,7 @@ var KNOWLEDGE_FILES = [
|
|
|
4341
4404
|
function buildReadinessReport(dir, now = /* @__PURE__ */ new Date()) {
|
|
4342
4405
|
const config = loadConfig(dir);
|
|
4343
4406
|
const rec = resolveNextStep(dir, now);
|
|
4344
|
-
const stub = (overall2,
|
|
4407
|
+
const stub = (overall2, label2, command) => ({
|
|
4345
4408
|
project_name: config?.project.name ?? "unknown",
|
|
4346
4409
|
project_type: config?.project.state ?? "unknown",
|
|
4347
4410
|
overall: overall2,
|
|
@@ -4364,7 +4427,7 @@ function buildReadinessReport(dir, now = /* @__PURE__ */ new Date()) {
|
|
|
4364
4427
|
resolved_questions: 0,
|
|
4365
4428
|
deferred_questions: 0
|
|
4366
4429
|
},
|
|
4367
|
-
recommended_next_step: { label, ...command ? { command } : {} },
|
|
4430
|
+
recommended_next_step: { label: label2, ...command ? { command } : {} },
|
|
4368
4431
|
nextStepRecommendation: rec
|
|
4369
4432
|
});
|
|
4370
4433
|
if (!config) return stub("not-initialized", rec.label, rec.command);
|
|
@@ -5239,6 +5302,69 @@ After a POC has a canonical conclusion and Core has prepared its deterministic r
|
|
|
5239
5302
|
15. Traceability and Sources
|
|
5240
5303
|
`
|
|
5241
5304
|
);
|
|
5305
|
+
var KNOWLEDGE_CONSOLIDATION = skill(
|
|
5306
|
+
"knowledge-consolidation",
|
|
5307
|
+
"Knowledge Consolidation Skill",
|
|
5308
|
+
"delivery",
|
|
5309
|
+
["knowledge-consolidation-agent", "work-item-agent", "architecture-agent"],
|
|
5310
|
+
`
|
|
5311
|
+
# Knowledge Consolidation Skill
|
|
5312
|
+
|
|
5313
|
+
## Purpose
|
|
5314
|
+
|
|
5315
|
+
Standardize the SEMANTIC review of a deterministic Consolidation Plan so canonical knowledge becomes
|
|
5316
|
+
more precise, connected, consistent and retrievable \u2014 without losing history, decisions or evidence.
|
|
5317
|
+
|
|
5318
|
+
## When to use
|
|
5319
|
+
|
|
5320
|
+
After \`kaddo knowledge consolidate\` (or the \`kaddo_generate_consolidation_plan\` tool) has produced
|
|
5321
|
+
\`.kaddo/consolidation-plan.{md,json}\`, and a human or agent wants to review the opportunities and
|
|
5322
|
+
prepare refinements. Never as an autonomous rewrite of \`knowledge/\`.
|
|
5323
|
+
|
|
5324
|
+
## Inputs
|
|
5325
|
+
|
|
5326
|
+
The Consolidation Plan (\`.kaddo/consolidation-plan.json\`), the referenced source artifacts, and the
|
|
5327
|
+
context pack. Each opportunity carries: category, classification, confidence, source/target, evidence,
|
|
5328
|
+
rationale, suggested action, and \`requires_semantic_review\`.
|
|
5329
|
+
|
|
5330
|
+
## Output
|
|
5331
|
+
|
|
5332
|
+
For each opportunity the agent chooses to act on: a reviewable proposal that states what would change,
|
|
5333
|
+
what content is added/moved/summarized, what must be preserved, and which claims still need
|
|
5334
|
+
confirmation \u2014 with a diff or equivalent. No canonical file is edited by this skill; application goes
|
|
5335
|
+
through the existing controlled-edit flows after human approval.
|
|
5336
|
+
|
|
5337
|
+
## Rules
|
|
5338
|
+
|
|
5339
|
+
- Distinguish \`observed\` (verifiable fact) from \`suggested\` (a candidate needing judgement). Never
|
|
5340
|
+
present a \`suggested\` candidate as a verified conclusion.
|
|
5341
|
+
- Classify every claim as Observed / Derived / Suggested / Unknown.
|
|
5342
|
+
- Do not merge Business/Product/Tech just because they share a topic \u2014 preserve layer responsibilities.
|
|
5343
|
+
- Do not move every historical learning into current knowledge; incorporate only live rules, WITH a
|
|
5344
|
+
reference back to the originating Work Item. Never summarize or delete the Work Item.
|
|
5345
|
+
- Do not invent relationships, decisions or business rules; a missing optional relationship is an
|
|
5346
|
+
opportunity, not an error.
|
|
5347
|
+
- For a potential inconsistency, present BOTH sources and say whether the conflict is verified or
|
|
5348
|
+
potential. Never pick a winner arbitrarily.
|
|
5349
|
+
- Preserve critical constraints, decisions and reasons, exceptions, known risks, technical contracts,
|
|
5350
|
+
implementation evidence, provenance and necessary history.
|
|
5351
|
+
- Never reveal secret values or resolve secret references; never connect to a Project Resource.
|
|
5352
|
+
- Do not commit, push or release automatically.
|
|
5353
|
+
|
|
5354
|
+
## Quality checklist
|
|
5355
|
+
|
|
5356
|
+
- Every proposal cites its source artifact(s) and evidence.
|
|
5357
|
+
- Facts are separated from interpretations.
|
|
5358
|
+
- Preserved information is named explicitly.
|
|
5359
|
+
- Claims needing confirmation are flagged.
|
|
5360
|
+
- No canonical artifact was modified by the analysis or the review.
|
|
5361
|
+
|
|
5362
|
+
## Example output
|
|
5363
|
+
|
|
5364
|
+
A short set of proposals, each with evidence, a before/after (or diff) and an explicit list of what
|
|
5365
|
+
must be preserved, ready for human approval.
|
|
5366
|
+
`
|
|
5367
|
+
);
|
|
5242
5368
|
var SKILLS = [
|
|
5243
5369
|
ADR_WRITING,
|
|
5244
5370
|
WORK_ITEM_REFINEMENT,
|
|
@@ -5250,10 +5376,11 @@ var SKILLS = [
|
|
|
5250
5376
|
MODULE_CONTEXT_REFINEMENT,
|
|
5251
5377
|
EVIDENCE_VERIFICATION,
|
|
5252
5378
|
LEGACY_RISK_ASSESSMENT,
|
|
5253
|
-
POC_REPORT_WRITING
|
|
5379
|
+
POC_REPORT_WRITING,
|
|
5380
|
+
KNOWLEDGE_CONSOLIDATION
|
|
5254
5381
|
];
|
|
5255
5382
|
var SKILL_GROUPS = {
|
|
5256
|
-
delivery: ["work-item-refinement", "implementation-planning", "learning-capture", "evidence-verification", "legacy-risk-assessment", "poc-report-writing"],
|
|
5383
|
+
delivery: ["work-item-refinement", "implementation-planning", "learning-capture", "evidence-verification", "legacy-risk-assessment", "poc-report-writing", "knowledge-consolidation"],
|
|
5257
5384
|
tech: ["adr-writing", "ownership-suggestion", "graph-metadata-review", "module-context-refinement"],
|
|
5258
5385
|
integration: ["capsule-writing"]
|
|
5259
5386
|
};
|
|
@@ -5449,6 +5576,24 @@ var RESPONSIBILITY_MATRIX = {
|
|
|
5449
5576
|
],
|
|
5450
5577
|
next: ["kaddo graph export"]
|
|
5451
5578
|
},
|
|
5579
|
+
"knowledge-consolidation-agent": {
|
|
5580
|
+
agent: "knowledge-consolidation-agent",
|
|
5581
|
+
responsibleFor: [
|
|
5582
|
+
"Semantic review of the deterministic Consolidation Plan",
|
|
5583
|
+
"Preparing reviewable knowledge refinements"
|
|
5584
|
+
],
|
|
5585
|
+
produces: ["proposed refinements (before/after) for human approval"],
|
|
5586
|
+
canSuggest: ["kaddo knowledge consolidate"],
|
|
5587
|
+
cannotSuggest: [
|
|
5588
|
+
"code",
|
|
5589
|
+
"git",
|
|
5590
|
+
"commits",
|
|
5591
|
+
"modifying canonical knowledge without confirmation",
|
|
5592
|
+
"inventing facts or relationships",
|
|
5593
|
+
"deleting history"
|
|
5594
|
+
],
|
|
5595
|
+
next: ["kaddo knowledge consolidate"]
|
|
5596
|
+
},
|
|
5452
5597
|
"ownership-agent": {
|
|
5453
5598
|
agent: "ownership-agent",
|
|
5454
5599
|
responsibleFor: ["Precise code: ownership for Work Items and artifacts"],
|
|
@@ -7609,6 +7754,78 @@ ADRs) and re-runs \`kaddo graph export\`.
|
|
|
7609
7754
|
- No files were modified; no Git was run.
|
|
7610
7755
|
- The human is asked to confirm and re-export the graph.
|
|
7611
7756
|
`;
|
|
7757
|
+
var KNOWLEDGE_CONSOLIDATION_AGENT = `# Knowledge Consolidation Agent
|
|
7758
|
+
|
|
7759
|
+
## Role
|
|
7760
|
+
|
|
7761
|
+
You are the Kaddo Knowledge Consolidation Agent. Your job is to perform the **semantic review** of
|
|
7762
|
+
the deterministic **Consolidation Plan** produced by \`kaddo knowledge consolidate\`, and to prepare
|
|
7763
|
+
**reviewable refinements** that make canonical knowledge more precise, connected, consistent and
|
|
7764
|
+
retrievable \u2014 without losing history, decisions or evidence.
|
|
7765
|
+
|
|
7766
|
+
You do not write code, you do not modify canonical files, and you never run Git. You propose; a human
|
|
7767
|
+
confirms, and application goes through Kaddo's existing controlled-edit flows.
|
|
7768
|
+
|
|
7769
|
+
## When to Use
|
|
7770
|
+
|
|
7771
|
+
Use this agent after \`kaddo knowledge consolidate\` (or the \`kaddo_generate_consolidation_plan\`
|
|
7772
|
+
tool) has produced \`.kaddo/consolidation-plan.md\` and \`.kaddo/consolidation-plan.json\`, and the
|
|
7773
|
+
plan contains opportunities flagged \`requires_semantic_review\`.
|
|
7774
|
+
|
|
7775
|
+
## Input Required
|
|
7776
|
+
|
|
7777
|
+
Provide \`.kaddo/context-pack.md\` and \`.kaddo/consolidation-plan.json\` as the primary inputs, plus
|
|
7778
|
+
the source artifacts each opportunity references under \`knowledge/\` (and completed Work Items under
|
|
7779
|
+
\`knowledge/delivery/work-items/completed/\` for learning opportunities).
|
|
7780
|
+
|
|
7781
|
+
## Expected Output
|
|
7782
|
+
|
|
7783
|
+
For each opportunity you choose to act on, a proposal that states what would change, what content is
|
|
7784
|
+
added / moved / summarized, what must be preserved, and which claims still need confirmation \u2014 with a
|
|
7785
|
+
diff or equivalent before/after.
|
|
7786
|
+
|
|
7787
|
+
## Instructions
|
|
7788
|
+
|
|
7789
|
+
1. Read the plan and work one opportunity at a time, highest-signal first.
|
|
7790
|
+
2. Separate what you **observe** in the files from what you **suggest** \u2014 never present a suggested
|
|
7791
|
+
candidate as a verified conclusion.
|
|
7792
|
+
3. For possible redundancy, compare the actual sections; propose a single reference location only if
|
|
7793
|
+
one genuinely restates the other. Preserve layer separation (Business / Product / Tech / Delivery).
|
|
7794
|
+
4. For an unincorporated learning, decide whether it is a live rule; if so, propose incorporating it
|
|
7795
|
+
into the right Tech artifact **with a reference back to the originating Work Item**. Never summarize
|
|
7796
|
+
or delete the Work Item.
|
|
7797
|
+
5. For a relationship opportunity, propose the relationship only when existing knowledge justifies it;
|
|
7798
|
+
a missing optional relationship is an opportunity, not an error.
|
|
7799
|
+
6. For a potential inconsistency, present **both** sources and say whether the conflict is verified or
|
|
7800
|
+
potential. Do not pick a winner arbitrarily.
|
|
7801
|
+
7. Classify every claim as Observed / Derived / Suggested / Unknown, and mark what needs confirmation.
|
|
7802
|
+
|
|
7803
|
+
## Constraints
|
|
7804
|
+
|
|
7805
|
+
- Do **not** modify canonical files \u2014 propose changes for a human to apply.
|
|
7806
|
+
- Do **not** invent facts, relationships, decisions or business rules.
|
|
7807
|
+
- Do **not** delete historical information, change Work Item states, or alter verification results.
|
|
7808
|
+
- Do **not** reveal secret values or resolve secret references; do **not** connect to a Project Resource.
|
|
7809
|
+
- Do **not** run Git, commit, push or release.
|
|
7810
|
+
|
|
7811
|
+
## Output Format
|
|
7812
|
+
|
|
7813
|
+
Per opportunity: the opportunity id, classification and confidence, the proposed before/after (or
|
|
7814
|
+
diff), the explicit list of what must be preserved, and the open questions that need confirmation.
|
|
7815
|
+
|
|
7816
|
+
## Where to Save the Result
|
|
7817
|
+
|
|
7818
|
+
Nothing is saved automatically. The human reviews the proposals and applies the approved ones through
|
|
7819
|
+
Kaddo's existing controlled-edit flows. Re-run \`kaddo knowledge consolidate\` afterwards to confirm.
|
|
7820
|
+
|
|
7821
|
+
## Quality Checklist
|
|
7822
|
+
|
|
7823
|
+
- Every proposal cites its source artifact(s) and evidence from the plan.
|
|
7824
|
+
- Facts are separated from interpretations; suggested candidates are never asserted as fact.
|
|
7825
|
+
- Preserved information (constraints, decisions, exceptions, risks, contracts, provenance) is named.
|
|
7826
|
+
- No canonical artifact was modified; no Git was run.
|
|
7827
|
+
- The human is asked to confirm before anything is applied.
|
|
7828
|
+
`;
|
|
7612
7829
|
var AGENT_PROMPTS = [
|
|
7613
7830
|
{ fileName: "capability-agent.md", content: CAPABILITY_AGENT },
|
|
7614
7831
|
{ fileName: "architecture-agent.md", content: ARCHITECTURE_AGENT },
|
|
@@ -7635,7 +7852,9 @@ var AGENT_PROMPTS = [
|
|
|
7635
7852
|
// Knowledge Capsule refinement (external context — VS-054)
|
|
7636
7853
|
{ fileName: "capsule-agent.md", content: CAPSULE_AGENT },
|
|
7637
7854
|
// Graph relationship quality (metadata hints → precise front matter — VS-056)
|
|
7638
|
-
{ fileName: "graph-agent.md", content: GRAPH_AGENT }
|
|
7855
|
+
{ fileName: "graph-agent.md", content: GRAPH_AGENT },
|
|
7856
|
+
// Knowledge Consolidation semantic review (deterministic plan → reviewable refinements — WI-070)
|
|
7857
|
+
{ fileName: "knowledge-consolidation-agent.md", content: KNOWLEDGE_CONSOLIDATION_AGENT }
|
|
7639
7858
|
// Every official prompt ends with its responsibility boundaries + Agent Trace footer.
|
|
7640
7859
|
].map((p) => ({ fileName: p.fileName, content: withResponsibilityTrace(p.fileName, p.content) }));
|
|
7641
7860
|
|
|
@@ -7842,9 +8061,9 @@ function installedAssetsSummary(dir) {
|
|
|
7842
8061
|
// src/core/roadmap-quality.ts
|
|
7843
8062
|
var ROADMAP_PATH = "knowledge/delivery/roadmap.md";
|
|
7844
8063
|
var INITIATIVE_RE2 = /^#{2,4}\s+(RM-[\w.-]+)\s*[:\-–]?\s*(.*)$/;
|
|
7845
|
-
function fieldPresent(lines,
|
|
8064
|
+
function fieldPresent(lines, label2) {
|
|
7846
8065
|
for (let i = 0; i < lines.length; i++) {
|
|
7847
|
-
const m = lines[i].match(new RegExp(`^\\s*[-*]?\\s*(?:\\*\\*)?\\s*(${
|
|
8066
|
+
const m = lines[i].match(new RegExp(`^\\s*[-*]?\\s*(?:\\*\\*)?\\s*(${label2.source})\\s*(?:\\*\\*)?\\s*:\\s*(.*)$`, "i"));
|
|
7848
8067
|
if (!m) continue;
|
|
7849
8068
|
const inline = m[2].trim();
|
|
7850
8069
|
if (inline) return true;
|
|
@@ -9670,9 +9889,9 @@ function renderImpactMarkdown(r, opts = {}) {
|
|
|
9670
9889
|
["validation section", gp.missing_validation]
|
|
9671
9890
|
];
|
|
9672
9891
|
L.push("## Historical Documentation Completeness", "");
|
|
9673
|
-
for (const [
|
|
9892
|
+
for (const [label2, items] of historical) {
|
|
9674
9893
|
const completed = items.filter((item) => item.status === "completed");
|
|
9675
|
-
if (completed.length > 0) L.push(`- Completed Work Items without detected ${
|
|
9894
|
+
if (completed.length > 0) L.push(`- Completed Work Items without detected ${label2}: ${completed.length}`);
|
|
9676
9895
|
}
|
|
9677
9896
|
if (!historical.some(([, items]) => items.some((item) => item.status === "completed"))) {
|
|
9678
9897
|
L.push("No historical documentation completeness gaps were detected.");
|
|
@@ -10212,10 +10431,517 @@ function serializeSavingsJson(r) {
|
|
|
10212
10431
|
return JSON.stringify(r, null, 2) + "\n";
|
|
10213
10432
|
}
|
|
10214
10433
|
|
|
10434
|
+
// src/core/knowledge-consolidation.ts
|
|
10435
|
+
import { createHash as createHash2 } from "crypto";
|
|
10436
|
+
import matter11 from "gray-matter";
|
|
10437
|
+
var KNOWLEDGE5 = "knowledge";
|
|
10438
|
+
var CONSOLIDATION_CATEGORIES = [
|
|
10439
|
+
"knowledge_redundancy",
|
|
10440
|
+
"unincorporated_learning",
|
|
10441
|
+
"knowledge_fragmentation",
|
|
10442
|
+
"relationship_opportunity",
|
|
10443
|
+
"potentially_outdated",
|
|
10444
|
+
"knowledge_organization"
|
|
10445
|
+
];
|
|
10446
|
+
function toPosix6(p) {
|
|
10447
|
+
return p.replace(/\\/g, "/");
|
|
10448
|
+
}
|
|
10449
|
+
function relFromDir(dir, filePath) {
|
|
10450
|
+
const d = toPosix6(dir).replace(/\/+$/, "");
|
|
10451
|
+
const f = toPosix6(filePath);
|
|
10452
|
+
return f.startsWith(d + "/") ? f.slice(d.length + 1) : f;
|
|
10453
|
+
}
|
|
10454
|
+
function sha256(content) {
|
|
10455
|
+
return createHash2("sha256").update(content, "utf-8").digest("hex");
|
|
10456
|
+
}
|
|
10457
|
+
var GENERIC_HEADINGS = /* @__PURE__ */ new Set([
|
|
10458
|
+
"purpose",
|
|
10459
|
+
"proposito",
|
|
10460
|
+
"prop\xF3sito",
|
|
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, " ");
|
|
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);
|
|
10550
|
+
}
|
|
10551
|
+
return [...new Set(out)];
|
|
10552
|
+
}
|
|
10553
|
+
function sectionBody(body, titles) {
|
|
10554
|
+
const lines = body.split(/\r?\n/);
|
|
10555
|
+
const re = new RegExp(`^#{1,3}\\s+(${titles.join("|")})\\s*$`, "i");
|
|
10556
|
+
const start = lines.findIndex((l) => re.test(l));
|
|
10557
|
+
if (start < 0) return null;
|
|
10558
|
+
const collected = [];
|
|
10559
|
+
for (let i = start + 1; i < lines.length; i++) {
|
|
10560
|
+
if (/^#{1,3}\s+/.test(lines[i])) break;
|
|
10561
|
+
collected.push(lines[i]);
|
|
10562
|
+
}
|
|
10563
|
+
const text2 = collected.join("\n").trim();
|
|
10564
|
+
return text2.length > 0 ? text2 : null;
|
|
10565
|
+
}
|
|
10566
|
+
function stableOpportunityId(category, sources) {
|
|
10567
|
+
const key = [category, ...[...sources].sort()].join("|");
|
|
10568
|
+
return `${category}:${sha256(key).slice(0, 12)}`;
|
|
10569
|
+
}
|
|
10570
|
+
function layerOf(a) {
|
|
10571
|
+
const byType = layerForType(a.type);
|
|
10572
|
+
if (byType) return byType;
|
|
10573
|
+
const p = toPosix6(a.filePath);
|
|
10574
|
+
if (p.includes(`/${KNOWLEDGE5}/business/`)) return "Business";
|
|
10575
|
+
if (p.includes(`/${KNOWLEDGE5}/product/`)) return "Product";
|
|
10576
|
+
if (p.includes(`/${KNOWLEDGE5}/tech/`)) return "Tech";
|
|
10577
|
+
if (p.includes(`/${KNOWLEDGE5}/delivery/`)) return "Delivery";
|
|
10578
|
+
return null;
|
|
10579
|
+
}
|
|
10580
|
+
function inScope(la, scope) {
|
|
10581
|
+
if (scope.kind === "all") return true;
|
|
10582
|
+
if (scope.kind === "layer") return la.layer === scope.layer;
|
|
10583
|
+
return la.artifact.affectedModules.includes(scope.module);
|
|
10584
|
+
}
|
|
10585
|
+
function label(la) {
|
|
10586
|
+
return la.artifact.id || la.rel;
|
|
10587
|
+
}
|
|
10588
|
+
function buildConsolidationPlan(dir, opts = {}) {
|
|
10589
|
+
requireConfig(dir);
|
|
10590
|
+
const scope = opts.scope ?? { kind: "all" };
|
|
10591
|
+
const now = opts.now ?? /* @__PURE__ */ new Date();
|
|
10592
|
+
const archDir = join(dir, KNOWLEDGE5);
|
|
10593
|
+
const rawArtifacts = exists(archDir) ? readArtifacts(archDir) : [];
|
|
10594
|
+
const loaded = rawArtifacts.map((a) => {
|
|
10595
|
+
let body = "";
|
|
10596
|
+
try {
|
|
10597
|
+
body = matter11(readFile(a.filePath)).content;
|
|
10598
|
+
} catch {
|
|
10599
|
+
body = "";
|
|
10600
|
+
}
|
|
10601
|
+
return { artifact: a, rel: relFromDir(dir, a.filePath), body, layer: layerOf(a) };
|
|
10602
|
+
});
|
|
10603
|
+
const scoped = loaded.filter((la) => inScope(la, scope));
|
|
10604
|
+
const scopedRels = new Set(scoped.map((la) => la.rel));
|
|
10605
|
+
const knownIds = new Set(loaded.map((la) => la.artifact.id).filter(Boolean));
|
|
10606
|
+
const opportunities = [];
|
|
10607
|
+
try {
|
|
10608
|
+
const config = requireConfig(dir);
|
|
10609
|
+
const graph = buildGraph(dir, config, { scope: "all" }, now);
|
|
10610
|
+
const hints = buildGraphHints(dir, graph, now);
|
|
10611
|
+
for (const hint of hints.hints) {
|
|
10612
|
+
if (!hintInScope(hint, scoped)) continue;
|
|
10613
|
+
opportunities.push(relationshipOpportunityFromHint(hint));
|
|
10614
|
+
}
|
|
10615
|
+
} catch {
|
|
10616
|
+
}
|
|
10617
|
+
for (const la of scoped) {
|
|
10618
|
+
const dangling = la.artifact.decisions.filter((d) => d && !knownIds.has(d) && !decisionFileExists(dir, d));
|
|
10619
|
+
if (dangling.length === 0) continue;
|
|
10620
|
+
opportunities.push({
|
|
10621
|
+
id: stableOpportunityId("potentially_outdated", [label(la), ...dangling]),
|
|
10622
|
+
category: "potentially_outdated",
|
|
10623
|
+
classification: "observed",
|
|
10624
|
+
confidence: "requires-review",
|
|
10625
|
+
title: `${label(la)} references decision(s) that no longer exist`,
|
|
10626
|
+
source_artifacts: [label(la)],
|
|
10627
|
+
target_artifacts: [label(la)],
|
|
10628
|
+
evidence: dangling.map((d) => `Declared decision \`${d}\` has no matching artifact in the project.`),
|
|
10629
|
+
rationale: "A reference to a missing decision is a verifiable inconsistency: either the decision artifact was removed/renamed or the reference is stale.",
|
|
10630
|
+
possible_impact: "Broken traceability between a Work Item/artifact and its decisions.",
|
|
10631
|
+
suggested_action: "Review and update or remove the dangling decision reference.",
|
|
10632
|
+
requires_semantic_review: false
|
|
10633
|
+
});
|
|
10634
|
+
}
|
|
10635
|
+
const canonical = scoped.filter(
|
|
10636
|
+
(la) => la.layer !== null && !isWorkItem(la) && la.artifact.type !== "roadmap"
|
|
10637
|
+
);
|
|
10638
|
+
const byHeading = /* @__PURE__ */ new Map();
|
|
10639
|
+
for (const la of canonical) {
|
|
10640
|
+
for (const h of distinctiveHeadings(la.body)) {
|
|
10641
|
+
const arr = byHeading.get(h) ?? [];
|
|
10642
|
+
arr.push(la);
|
|
10643
|
+
byHeading.set(h, arr);
|
|
10644
|
+
}
|
|
10645
|
+
}
|
|
10646
|
+
const pairHeadings = /* @__PURE__ */ new Map();
|
|
10647
|
+
for (const [heading, arts] of byHeading) {
|
|
10648
|
+
if (arts.length < 2) continue;
|
|
10649
|
+
for (let i = 0; i < arts.length; i++) {
|
|
10650
|
+
for (let j = i + 1; j < arts.length; j++) {
|
|
10651
|
+
if (arts[i].rel === arts[j].rel) continue;
|
|
10652
|
+
const key = [arts[i].rel, arts[j].rel].sort().join("||");
|
|
10653
|
+
const entry = pairHeadings.get(key) ?? { a: arts[i], b: arts[j], shared: /* @__PURE__ */ new Set() };
|
|
10654
|
+
entry.shared.add(heading);
|
|
10655
|
+
pairHeadings.set(key, entry);
|
|
10656
|
+
}
|
|
10657
|
+
}
|
|
10658
|
+
}
|
|
10659
|
+
for (const { a, b, shared } of pairHeadings.values()) {
|
|
10660
|
+
if (shared.size < 2) continue;
|
|
10661
|
+
opportunities.push({
|
|
10662
|
+
id: stableOpportunityId("knowledge_redundancy", [label(a), label(b)]),
|
|
10663
|
+
category: "knowledge_redundancy",
|
|
10664
|
+
classification: "suggested",
|
|
10665
|
+
confidence: "requires-review",
|
|
10666
|
+
title: `Possible overlapping content between ${label(a)} and ${label(b)}`,
|
|
10667
|
+
source_artifacts: [label(a), label(b)],
|
|
10668
|
+
target_artifacts: [label(a), label(b)],
|
|
10669
|
+
evidence: [`Both artifacts declare the sections: ${[...shared].sort().join(", ")}.`],
|
|
10670
|
+
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.",
|
|
10671
|
+
possible_impact: "If genuinely duplicated, the same fact can drift out of sync across files.",
|
|
10672
|
+
suggested_action: "Semantic review: compare the sections; if one restates the other, keep a single reference location and link the rest. Preserve layer separation.",
|
|
10673
|
+
requires_semantic_review: true
|
|
10674
|
+
});
|
|
10675
|
+
}
|
|
10676
|
+
for (const la of scoped) {
|
|
10677
|
+
if (!isCompletedWorkItem(la)) continue;
|
|
10678
|
+
const learning = sectionBody(la.body, ["Learning", "Aprendizaje", "Aprendizajes", "Learnings"]);
|
|
10679
|
+
if (!learning) continue;
|
|
10680
|
+
if (!looksLikeDurableRule(learning)) continue;
|
|
10681
|
+
opportunities.push({
|
|
10682
|
+
id: stableOpportunityId("unincorporated_learning", [label(la)]),
|
|
10683
|
+
category: "unincorporated_learning",
|
|
10684
|
+
classification: "suggested",
|
|
10685
|
+
confidence: "requires-review",
|
|
10686
|
+
title: `${label(la)} captured a learning that may belong in current knowledge`,
|
|
10687
|
+
source_artifacts: [label(la)],
|
|
10688
|
+
target_artifacts: ["knowledge/tech/codebase.md"],
|
|
10689
|
+
evidence: [`Completed Work Item records a rule-like learning: "${firstSentence(learning)}"`],
|
|
10690
|
+
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.",
|
|
10691
|
+
possible_impact: "A relevant constraint stays buried in delivery history instead of informing current work.",
|
|
10692
|
+
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.",
|
|
10693
|
+
requires_semantic_review: true
|
|
10694
|
+
});
|
|
10695
|
+
}
|
|
10696
|
+
const weakByFolder = /* @__PURE__ */ new Map();
|
|
10697
|
+
for (const la of scoped) {
|
|
10698
|
+
const quality = safeQuality(dir, la.rel);
|
|
10699
|
+
if (quality === "placeholder" || quality === "weak") {
|
|
10700
|
+
opportunities.push({
|
|
10701
|
+
id: stableOpportunityId("knowledge_organization", [la.rel]),
|
|
10702
|
+
category: "knowledge_organization",
|
|
10703
|
+
classification: "observed",
|
|
10704
|
+
confidence: "requires-review",
|
|
10705
|
+
title: `${label(la)} is ${quality} and may need consolidation or expansion`,
|
|
10706
|
+
source_artifacts: [label(la)],
|
|
10707
|
+
target_artifacts: [label(la)],
|
|
10708
|
+
evidence: [`Artifact quality analysis classifies this artifact as "${quality}".`],
|
|
10709
|
+
rationale: "Low-signal artifacts reduce retrieval quality. This is an observed quality signal, not a judgement that the content is wrong.",
|
|
10710
|
+
possible_impact: "Readers must open more files to assemble a complete picture.",
|
|
10711
|
+
suggested_action: "Review whether to expand, merge into a stronger artifact, or cross-reference it.",
|
|
10712
|
+
requires_semantic_review: false
|
|
10713
|
+
});
|
|
10714
|
+
const folder = la.rel.split("/").slice(0, -1).join("/");
|
|
10715
|
+
const arr = weakByFolder.get(folder) ?? [];
|
|
10716
|
+
arr.push(la);
|
|
10717
|
+
weakByFolder.set(folder, arr);
|
|
10718
|
+
}
|
|
10719
|
+
}
|
|
10720
|
+
for (const [folder, arts] of weakByFolder) {
|
|
10721
|
+
if (arts.length < 3) continue;
|
|
10722
|
+
opportunities.push({
|
|
10723
|
+
id: stableOpportunityId("knowledge_fragmentation", arts.map((a) => a.rel)),
|
|
10724
|
+
category: "knowledge_fragmentation",
|
|
10725
|
+
classification: "suggested",
|
|
10726
|
+
confidence: "requires-review",
|
|
10727
|
+
title: `${folder}/ holds ${arts.length} low-signal artifacts \u2014 possible fragmentation`,
|
|
10728
|
+
source_artifacts: arts.map((a) => label(a)),
|
|
10729
|
+
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.",
|
|
10732
|
+
possible_impact: "Related knowledge is spread across too many files to follow.",
|
|
10733
|
+
suggested_action: "Semantic review: evaluate whether cross-references or a consolidation would add clarity. Do not merge by file count alone.",
|
|
10734
|
+
requires_semantic_review: true
|
|
10735
|
+
});
|
|
10736
|
+
}
|
|
10737
|
+
opportunities.sort((x, y) => {
|
|
10738
|
+
const ci = CONSOLIDATION_CATEGORIES.indexOf(x.category) - CONSOLIDATION_CATEGORIES.indexOf(y.category);
|
|
10739
|
+
return ci !== 0 ? ci : x.id.localeCompare(y.id);
|
|
10740
|
+
});
|
|
10741
|
+
const seen = /* @__PURE__ */ new Set();
|
|
10742
|
+
const deduped = opportunities.filter((o) => seen.has(o.id) ? false : (seen.add(o.id), true));
|
|
10743
|
+
const layers = discoverLayers(dir);
|
|
10744
|
+
const layersEvaluated = scope.kind === "layer" ? [scope.layer] : layers.map((l) => l.layer);
|
|
10745
|
+
const workItemsEvaluated = scoped.filter(isWorkItem).length;
|
|
10746
|
+
const sourceFiles = [...scopedRels].sort().map((rel) => ({ path: rel, hash: sha256(readFileSafe(join(dir, rel))) }));
|
|
10747
|
+
const byCategory = Object.fromEntries(
|
|
10748
|
+
CONSOLIDATION_CATEGORIES.map((c) => [c, deduped.filter((o) => o.category === c).length])
|
|
10749
|
+
);
|
|
10750
|
+
return {
|
|
10751
|
+
generated_at: now.toISOString(),
|
|
10752
|
+
scope: describeScope(scope),
|
|
10753
|
+
project_context: reportingProjectContext(dir),
|
|
10754
|
+
coverage: {
|
|
10755
|
+
scope: describeScope(scope),
|
|
10756
|
+
layers_evaluated: layersEvaluated,
|
|
10757
|
+
artifacts_evaluated: scoped.length,
|
|
10758
|
+
work_items_evaluated: workItemsEvaluated,
|
|
10759
|
+
excluded_sources: scope.kind === "all" ? [] : [...loaded.map((l) => l.rel)].filter((r) => !scopedRels.has(r)).sort()
|
|
10760
|
+
},
|
|
10761
|
+
source_files: sourceFiles,
|
|
10762
|
+
opportunities: deduped,
|
|
10763
|
+
summary: {
|
|
10764
|
+
total: deduped.length,
|
|
10765
|
+
by_category: byCategory,
|
|
10766
|
+
requires_semantic_review: deduped.filter((o) => o.requires_semantic_review).length
|
|
10767
|
+
}
|
|
10768
|
+
};
|
|
10769
|
+
}
|
|
10770
|
+
function consolidationPlanStaleness(dir, plan) {
|
|
10771
|
+
const changed = [];
|
|
10772
|
+
const removed = [];
|
|
10773
|
+
for (const sf of plan.source_files) {
|
|
10774
|
+
const abs = join(dir, sf.path);
|
|
10775
|
+
if (!exists(abs)) {
|
|
10776
|
+
removed.push(sf.path);
|
|
10777
|
+
continue;
|
|
10778
|
+
}
|
|
10779
|
+
if (sha256(readFileSafe(abs)) !== sf.hash) changed.push(sf.path);
|
|
10780
|
+
}
|
|
10781
|
+
return { stale: changed.length > 0 || removed.length > 0, changed, removed };
|
|
10782
|
+
}
|
|
10783
|
+
var CATEGORY_LABELS = {
|
|
10784
|
+
knowledge_redundancy: "Possible redundancy",
|
|
10785
|
+
unincorporated_learning: "Learning integration opportunity",
|
|
10786
|
+
knowledge_fragmentation: "Possible fragmentation",
|
|
10787
|
+
relationship_opportunity: "Relationship review hint",
|
|
10788
|
+
potentially_outdated: "Potential inconsistency",
|
|
10789
|
+
knowledge_organization: "Organization opportunity"
|
|
10790
|
+
};
|
|
10791
|
+
function renderConsolidationMarkdown(plan) {
|
|
10792
|
+
const lines = [];
|
|
10793
|
+
lines.push("# Knowledge Consolidation Plan");
|
|
10794
|
+
lines.push("");
|
|
10795
|
+
lines.push("> Derived, review-only projection. No canonical knowledge was modified by this analysis.");
|
|
10796
|
+
lines.push("");
|
|
10797
|
+
lines.push(`- Generated at: ${plan.generated_at}`);
|
|
10798
|
+
lines.push(`- Scope: ${plan.scope}`);
|
|
10799
|
+
lines.push(`- Project: state=${plan.project_context.state}, mode=${plan.project_context.mode}, structure=${plan.project_context.repository_structure}`);
|
|
10800
|
+
lines.push("");
|
|
10801
|
+
lines.push("## Coverage");
|
|
10802
|
+
lines.push("");
|
|
10803
|
+
lines.push(`- Layers evaluated: ${plan.coverage.layers_evaluated.join(", ") || "\u2014"}`);
|
|
10804
|
+
lines.push(`- Artifacts evaluated: ${plan.coverage.artifacts_evaluated}`);
|
|
10805
|
+
lines.push(`- Work Items evaluated: ${plan.coverage.work_items_evaluated}`);
|
|
10806
|
+
if (plan.coverage.excluded_sources.length > 0) {
|
|
10807
|
+
lines.push(`- Excluded from this scope: ${plan.coverage.excluded_sources.length} artifact(s)`);
|
|
10808
|
+
}
|
|
10809
|
+
lines.push("");
|
|
10810
|
+
lines.push("## Findings");
|
|
10811
|
+
lines.push("");
|
|
10812
|
+
if (plan.summary.total === 0) {
|
|
10813
|
+
lines.push("No consolidation opportunities were detected by the available deterministic analyses within this scope.");
|
|
10814
|
+
lines.push("");
|
|
10815
|
+
lines.push("This is not a claim that the knowledge is perfect \u2014 only that no opportunity was found with the current signals.");
|
|
10816
|
+
lines.push("");
|
|
10817
|
+
return lines.join("\n") + "\n";
|
|
10818
|
+
}
|
|
10819
|
+
for (const cat of CONSOLIDATION_CATEGORIES) {
|
|
10820
|
+
const n = plan.summary.by_category[cat];
|
|
10821
|
+
if (n > 0) lines.push(`- ${n} \xD7 ${CATEGORY_LABELS[cat]}`);
|
|
10822
|
+
}
|
|
10823
|
+
lines.push("");
|
|
10824
|
+
lines.push(`${plan.summary.requires_semantic_review} finding(s) require semantic (agent/human) review before acting.`);
|
|
10825
|
+
lines.push("");
|
|
10826
|
+
lines.push("## Opportunities");
|
|
10827
|
+
lines.push("");
|
|
10828
|
+
for (const o of plan.opportunities) {
|
|
10829
|
+
lines.push(`### ${o.title}`);
|
|
10830
|
+
lines.push("");
|
|
10831
|
+
lines.push(`- Id: \`${o.id}\``);
|
|
10832
|
+
lines.push(`- Category: ${o.category}`);
|
|
10833
|
+
lines.push(`- Classification: **${o.classification}**${o.requires_semantic_review ? " (requires semantic review)" : ""}`);
|
|
10834
|
+
lines.push(`- Confidence: ${o.confidence}`);
|
|
10835
|
+
lines.push(`- Source: ${o.source_artifacts.join(", ") || "\u2014"}`);
|
|
10836
|
+
lines.push(`- Suggested target: ${o.target_artifacts.join(", ") || "\u2014"}`);
|
|
10837
|
+
lines.push(`- Evidence:`);
|
|
10838
|
+
for (const e of o.evidence) lines.push(` - ${e}`);
|
|
10839
|
+
lines.push(`- Rationale: ${o.rationale}`);
|
|
10840
|
+
lines.push(`- Possible impact: ${o.possible_impact}`);
|
|
10841
|
+
lines.push(`- Suggested action: ${o.suggested_action}`);
|
|
10842
|
+
lines.push("");
|
|
10843
|
+
}
|
|
10844
|
+
return lines.join("\n") + "\n";
|
|
10845
|
+
}
|
|
10846
|
+
function serializeConsolidationJson(plan) {
|
|
10847
|
+
return JSON.stringify(plan, null, 2) + "\n";
|
|
10848
|
+
}
|
|
10849
|
+
function describeScope(scope) {
|
|
10850
|
+
if (scope.kind === "all") return "all";
|
|
10851
|
+
if (scope.kind === "layer") return `layer:${scope.layer}`;
|
|
10852
|
+
return `module:${scope.module}`;
|
|
10853
|
+
}
|
|
10854
|
+
function isWorkItem(la) {
|
|
10855
|
+
return toPosix6(la.artifact.filePath).includes("/delivery/work-items/");
|
|
10856
|
+
}
|
|
10857
|
+
function isCompletedWorkItem(la) {
|
|
10858
|
+
const p = toPosix6(la.artifact.filePath);
|
|
10859
|
+
return p.includes("/delivery/work-items/completed/") || isWorkItem(la) && la.artifact.status === "completed";
|
|
10860
|
+
}
|
|
10861
|
+
function looksLikeDurableRule(text2) {
|
|
10862
|
+
const lower = text2.toLowerCase();
|
|
10863
|
+
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));
|
|
10864
|
+
}
|
|
10865
|
+
function firstSentence(text2) {
|
|
10866
|
+
const flat = text2.replace(/\s+/g, " ").trim();
|
|
10867
|
+
const m = flat.match(/^(.{0,200}?[.!?])(\s|$)/);
|
|
10868
|
+
const s = (m ? m[1] : flat).slice(0, 200);
|
|
10869
|
+
return redactSecrets2(s.trim());
|
|
10870
|
+
}
|
|
10871
|
+
var SECRET_TOKEN_PATTERNS = [
|
|
10872
|
+
/\bgh[pours]_[A-Za-z0-9]{16,}\b/g,
|
|
10873
|
+
// GitHub tokens
|
|
10874
|
+
/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g,
|
|
10875
|
+
// AWS access key ids
|
|
10876
|
+
/\bxox[baprs]-[A-Za-z0-9-]{10,}\b/g,
|
|
10877
|
+
// Slack tokens
|
|
10878
|
+
/\bsk-[A-Za-z0-9]{16,}\b/g,
|
|
10879
|
+
// OpenAI-style keys
|
|
10880
|
+
/\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g,
|
|
10881
|
+
// JWTs
|
|
10882
|
+
/\b[A-Za-z0-9+/]{40,}={0,2}\b/g
|
|
10883
|
+
// long base64 / opaque blobs
|
|
10884
|
+
];
|
|
10885
|
+
function redactSecrets2(text2) {
|
|
10886
|
+
let out = text2;
|
|
10887
|
+
for (const re of SECRET_TOKEN_PATTERNS) out = out.replace(re, "[redacted]");
|
|
10888
|
+
return out;
|
|
10889
|
+
}
|
|
10890
|
+
function safeQuality(dir, rel) {
|
|
10891
|
+
try {
|
|
10892
|
+
return analyzeKnowledgeArtifact(dir, rel);
|
|
10893
|
+
} catch {
|
|
10894
|
+
return "useful";
|
|
10895
|
+
}
|
|
10896
|
+
}
|
|
10897
|
+
function readFileSafe(abs) {
|
|
10898
|
+
try {
|
|
10899
|
+
return readFile(abs);
|
|
10900
|
+
} catch {
|
|
10901
|
+
return "";
|
|
10902
|
+
}
|
|
10903
|
+
}
|
|
10904
|
+
function decisionFileExists(dir, decisionId) {
|
|
10905
|
+
const decisionsDir = join(dir, KNOWLEDGE5, "tech", "decisions");
|
|
10906
|
+
if (!exists(decisionsDir)) return false;
|
|
10907
|
+
try {
|
|
10908
|
+
return readDir(decisionsDir).some((e) => {
|
|
10909
|
+
const full = join(decisionsDir, e);
|
|
10910
|
+
if (!isFile(full) || !e.endsWith(".md")) return false;
|
|
10911
|
+
return e.toLowerCase().includes(decisionId.toLowerCase());
|
|
10912
|
+
});
|
|
10913
|
+
} catch {
|
|
10914
|
+
return false;
|
|
10915
|
+
}
|
|
10916
|
+
}
|
|
10917
|
+
function hintInScope(hint, scoped) {
|
|
10918
|
+
if (scoped.length === 0) return false;
|
|
10919
|
+
return scoped.some(
|
|
10920
|
+
(la) => la.artifact.id === hint.artifact_id || hint.path && toPosix6(la.artifact.filePath).endsWith(toPosix6(hint.path))
|
|
10921
|
+
);
|
|
10922
|
+
}
|
|
10923
|
+
function relationshipOpportunityFromHint(hint) {
|
|
10924
|
+
const finding = graphHintFinding(hint);
|
|
10925
|
+
return {
|
|
10926
|
+
id: stableOpportunityId("relationship_opportunity", [hint.artifact_id, ...hint.missing]),
|
|
10927
|
+
category: "relationship_opportunity",
|
|
10928
|
+
classification: "observed",
|
|
10929
|
+
confidence: "requires-review",
|
|
10930
|
+
title: hint.message,
|
|
10931
|
+
source_artifacts: [hint.artifact_id],
|
|
10932
|
+
target_artifacts: [hint.artifact_id],
|
|
10933
|
+
evidence: [finding.evidence],
|
|
10934
|
+
rationale: "A missing OPTIONAL relationship is an opportunity to review, not an error or a verified inconsistency. Kaddo never invents the relationship.",
|
|
10935
|
+
possible_impact: "Weaker traceability in the knowledge graph.",
|
|
10936
|
+
suggested_action: finding.suggested_action,
|
|
10937
|
+
requires_semantic_review: false
|
|
10938
|
+
};
|
|
10939
|
+
}
|
|
10940
|
+
|
|
10215
10941
|
// src/core/resource-write.ts
|
|
10216
10942
|
import fs2 from "fs";
|
|
10217
10943
|
import path2 from "path";
|
|
10218
|
-
import
|
|
10944
|
+
import matter12 from "gray-matter";
|
|
10219
10945
|
var RESOURCES_DIR = "knowledge/tech/resources";
|
|
10220
10946
|
var ResourceWriteError = class extends Error {
|
|
10221
10947
|
constructor(code, message) {
|
|
@@ -10261,6 +10987,20 @@ function validateResource(dir, input) {
|
|
|
10261
10987
|
findings.push({ level: "warning", message: `Unknown access interface type "${i.type}".` });
|
|
10262
10988
|
}
|
|
10263
10989
|
}
|
|
10990
|
+
for (const p of input.connectionProfiles ?? []) {
|
|
10991
|
+
const where = p.environment ? ` in environment "${p.environment}"` : "";
|
|
10992
|
+
for (const c of p.coordinates ?? []) {
|
|
10993
|
+
const key = (c?.key ?? "").trim();
|
|
10994
|
+
const value = (c?.value ?? "").trim();
|
|
10995
|
+
if (!key || !value) continue;
|
|
10996
|
+
if (looksLikeSecretCoordinate(key, value)) {
|
|
10997
|
+
findings.push({
|
|
10998
|
+
level: "error",
|
|
10999
|
+
message: `Connection coordinate "${key}"${where} looks like a secret value. Store credentials as authentication references, not connection coordinates.`
|
|
11000
|
+
});
|
|
11001
|
+
}
|
|
11002
|
+
}
|
|
11003
|
+
}
|
|
10264
11004
|
const mapped = loadMappedModules(dir).map((m) => m.id);
|
|
10265
11005
|
if (mapped.length > 0) {
|
|
10266
11006
|
const refs = /* @__PURE__ */ new Set();
|
|
@@ -10287,6 +11027,22 @@ function buildFrontmatter(id, input, base = {}) {
|
|
|
10287
11027
|
if (input.modules != null) data.modules = input.modules;
|
|
10288
11028
|
if (input.accessInterfaces != null) data.access_interfaces = input.accessInterfaces;
|
|
10289
11029
|
if (input.accessBoundaries != null) data.access_boundaries = input.accessBoundaries;
|
|
11030
|
+
if (input.connectionProfiles != null) {
|
|
11031
|
+
data.connection_profiles = input.connectionProfiles.map((p) => {
|
|
11032
|
+
const coordinates = {};
|
|
11033
|
+
for (const c of p.coordinates ?? []) {
|
|
11034
|
+
const key = (c?.key ?? "").trim();
|
|
11035
|
+
const value = (c?.value ?? "").trim();
|
|
11036
|
+
if (!key || !value || looksLikeSecretCoordinate(key, value)) continue;
|
|
11037
|
+
coordinates[key] = value;
|
|
11038
|
+
}
|
|
11039
|
+
const entry = {};
|
|
11040
|
+
if (p.environment?.trim()) entry.environment = p.environment.trim();
|
|
11041
|
+
if (p.interface?.trim()) entry.interface = p.interface.trim();
|
|
11042
|
+
if (Object.keys(coordinates).length) entry.coordinates = coordinates;
|
|
11043
|
+
return entry;
|
|
11044
|
+
}).filter((e) => Object.keys(e).length > 0);
|
|
11045
|
+
}
|
|
10290
11046
|
if (input.authentication != null) {
|
|
10291
11047
|
const mode = input.authentication.mode;
|
|
10292
11048
|
const refs = sanitizeRefs(input.authentication.refs);
|
|
@@ -10295,7 +11051,7 @@ function buildFrontmatter(id, input, base = {}) {
|
|
|
10295
11051
|
return data;
|
|
10296
11052
|
}
|
|
10297
11053
|
function serialize(data, body) {
|
|
10298
|
-
return
|
|
11054
|
+
return matter12.stringify(`
|
|
10299
11055
|
${body.trim()}
|
|
10300
11056
|
`, data);
|
|
10301
11057
|
}
|
|
@@ -10335,7 +11091,7 @@ function updateResource(dir, id, input) {
|
|
|
10335
11091
|
throw new ResourceWriteError("VALIDATION_FAILED", findings.filter((f) => f.level === "error").map((f) => f.message).join("; "));
|
|
10336
11092
|
}
|
|
10337
11093
|
const raw = readFile(match.filePath);
|
|
10338
|
-
const parsed =
|
|
11094
|
+
const parsed = matter12(raw);
|
|
10339
11095
|
const base = parsed.data ?? {};
|
|
10340
11096
|
const data = buildFrontmatter(match.id || id, input, base);
|
|
10341
11097
|
let body = parsed.content.trim();
|
|
@@ -10606,7 +11362,7 @@ function analyzeCrossRepoEvidence(input) {
|
|
|
10606
11362
|
}
|
|
10607
11363
|
|
|
10608
11364
|
// src/core/work-items.ts
|
|
10609
|
-
import
|
|
11365
|
+
import matter13 from "gray-matter";
|
|
10610
11366
|
|
|
10611
11367
|
// src/core/system-topology.ts
|
|
10612
11368
|
import { parse as parseYaml9, stringify as stringifyYaml5 } from "yaml";
|
|
@@ -11044,7 +11800,7 @@ function parseOriginalSnapshot(fm) {
|
|
|
11044
11800
|
function readBody(filePath) {
|
|
11045
11801
|
try {
|
|
11046
11802
|
const raw = readFile(filePath);
|
|
11047
|
-
return
|
|
11803
|
+
return matter13(raw).content;
|
|
11048
11804
|
} catch {
|
|
11049
11805
|
return "";
|
|
11050
11806
|
}
|
|
@@ -11211,7 +11967,7 @@ function parseRelatedKnowledge(fm, knowledgeById) {
|
|
|
11211
11967
|
import fs4 from "fs";
|
|
11212
11968
|
import path4 from "path";
|
|
11213
11969
|
import crypto2 from "crypto";
|
|
11214
|
-
import
|
|
11970
|
+
import matter14 from "gray-matter";
|
|
11215
11971
|
|
|
11216
11972
|
// src/core/knowledge-levels.ts
|
|
11217
11973
|
var WORK_ITEM_TYPES2 = ["feature", "bugfix", "hotfix", "spike", "chore"];
|
|
@@ -11618,7 +12374,7 @@ function applyFrontmatter(data, input) {
|
|
|
11618
12374
|
return next;
|
|
11619
12375
|
}
|
|
11620
12376
|
function serialize2(data, body) {
|
|
11621
|
-
return
|
|
12377
|
+
return matter14.stringify(`
|
|
11622
12378
|
${body.trim()}
|
|
11623
12379
|
`, data);
|
|
11624
12380
|
}
|
|
@@ -11677,7 +12433,7 @@ function toInput(data, content) {
|
|
|
11677
12433
|
function getWorkItemForEdit(dir, id) {
|
|
11678
12434
|
const { filePath, relPath } = findArtifact(dir, id);
|
|
11679
12435
|
const raw = readFile(filePath);
|
|
11680
|
-
const { data, content } =
|
|
12436
|
+
const { data, content } = matter14(raw);
|
|
11681
12437
|
const status = lifecycleStateOf({ status: String(data.status ?? ""), filePath });
|
|
11682
12438
|
const input = toInput(data, content);
|
|
11683
12439
|
const editable = EDITABLE_STATES.includes(status);
|
|
@@ -11770,7 +12526,7 @@ function updateWorkItem(dir, id, input, expectedRevision) {
|
|
|
11770
12526
|
if (revisionOf(raw) !== expectedRevision) {
|
|
11771
12527
|
throw new WorkItemWriteError("WORK_ITEM_CONFLICT", "This Work Item changed outside Kaddo Admin. Reload the latest version before saving.");
|
|
11772
12528
|
}
|
|
11773
|
-
const { data, content } =
|
|
12529
|
+
const { data, content } = matter14(raw);
|
|
11774
12530
|
const status = lifecycleStateOf({ status: String(data.status ?? ""), filePath });
|
|
11775
12531
|
if (!EDITABLE_STATES.includes(status)) {
|
|
11776
12532
|
throw new WorkItemWriteError("WORK_ITEM_NOT_EDITABLE", `A ${status} Work Item cannot be edited. Reopen it as Draft first.`);
|
|
@@ -11784,7 +12540,7 @@ function updateWorkItem(dir, id, input, expectedRevision) {
|
|
|
11784
12540
|
function validateWorkItem(dir, id) {
|
|
11785
12541
|
const { filePath } = findArtifact(dir, id);
|
|
11786
12542
|
const raw = readFile(filePath);
|
|
11787
|
-
const { data, content } =
|
|
12543
|
+
const { data, content } = matter14(raw);
|
|
11788
12544
|
const input = toInput(data, content);
|
|
11789
12545
|
const findings = [];
|
|
11790
12546
|
const modules = validModuleIds(dir);
|
|
@@ -11837,7 +12593,7 @@ function transitionWorkItem(dir, id, to, expectedRevision) {
|
|
|
11837
12593
|
if (revisionOf(raw) !== expectedRevision) {
|
|
11838
12594
|
throw new WorkItemWriteError("WORK_ITEM_CONFLICT", "This Work Item changed outside Kaddo Admin. Reload the latest version before continuing.");
|
|
11839
12595
|
}
|
|
11840
|
-
const { data, content } =
|
|
12596
|
+
const { data, content } = matter14(raw);
|
|
11841
12597
|
const from = lifecycleStateOf({ status: String(data.status ?? ""), filePath });
|
|
11842
12598
|
if (!(ALLOWED[from] ?? []).includes(to)) {
|
|
11843
12599
|
throw new WorkItemWriteError("INVALID_TRANSITION", `Cannot transition a ${from} Work Item to ${to}.`);
|
|
@@ -13013,7 +13769,7 @@ function deriveImplementationStatus(repos) {
|
|
|
13013
13769
|
// src/core/work-item-import.ts
|
|
13014
13770
|
import crypto3 from "crypto";
|
|
13015
13771
|
import fs5 from "fs";
|
|
13016
|
-
import
|
|
13772
|
+
import matter15 from "gray-matter";
|
|
13017
13773
|
var MAX_INPUT_BYTES = 102400;
|
|
13018
13774
|
var LIFECYCLE_FIELDS = /* @__PURE__ */ new Set([
|
|
13019
13775
|
"id",
|
|
@@ -13035,7 +13791,7 @@ function detectFormat(raw) {
|
|
|
13035
13791
|
if (!trimmed) throw new ImportError("EMPTY_INPUT", "Import content is empty.");
|
|
13036
13792
|
if (trimmed.startsWith("---")) {
|
|
13037
13793
|
try {
|
|
13038
|
-
const { data } =
|
|
13794
|
+
const { data } = matter15(trimmed);
|
|
13039
13795
|
if (data && typeof data === "object" && Object.keys(data).length > 0) {
|
|
13040
13796
|
const d = data;
|
|
13041
13797
|
if (d.type === "work-item" || d.id && typeof d.id === "string" && /^WI-\d+/.test(d.id)) {
|
|
@@ -13057,7 +13813,7 @@ function parseContent(raw) {
|
|
|
13057
13813
|
let bodyText = trimmed;
|
|
13058
13814
|
if (format === "kaddo-frontmatter" || format === "markdown-frontmatter") {
|
|
13059
13815
|
try {
|
|
13060
|
-
const parsed =
|
|
13816
|
+
const parsed = matter15(trimmed);
|
|
13061
13817
|
frontmatterFields = parsed.data ?? {};
|
|
13062
13818
|
bodyText = parsed.content.trim();
|
|
13063
13819
|
} catch {
|
|
@@ -13154,7 +13910,7 @@ function findDuplicateByHash(dir, hash) {
|
|
|
13154
13910
|
const raw = readFile(item.filePath);
|
|
13155
13911
|
if (!raw) continue;
|
|
13156
13912
|
try {
|
|
13157
|
-
const { data } =
|
|
13913
|
+
const { data } = matter15(raw);
|
|
13158
13914
|
const source2 = data?.source;
|
|
13159
13915
|
if (source2 && typeof source2 === "object" && !Array.isArray(source2)) {
|
|
13160
13916
|
const s = source2;
|
|
@@ -13263,7 +14019,7 @@ var ImportError = class extends Error {
|
|
|
13263
14019
|
};
|
|
13264
14020
|
|
|
13265
14021
|
// src/services/integrations.ts
|
|
13266
|
-
import
|
|
14022
|
+
import matter16 from "gray-matter";
|
|
13267
14023
|
import { parse as parseYaml10, stringify as stringifyYaml6 } from "yaml";
|
|
13268
14024
|
|
|
13269
14025
|
// ../integrations/src/errors.ts
|
|
@@ -14605,7 +15361,7 @@ function findLinkedWorkItem(dir, integrationId, externalId) {
|
|
|
14605
15361
|
for (const art of discoverWorkItems(dir)) {
|
|
14606
15362
|
let data;
|
|
14607
15363
|
try {
|
|
14608
|
-
data =
|
|
15364
|
+
data = matter16(readFile(art.filePath)).data;
|
|
14609
15365
|
} catch {
|
|
14610
15366
|
continue;
|
|
14611
15367
|
}
|
|
@@ -14621,7 +15377,7 @@ function buildImportIndex(dir) {
|
|
|
14621
15377
|
for (const art of discoverWorkItems(dir)) {
|
|
14622
15378
|
let data;
|
|
14623
15379
|
try {
|
|
14624
|
-
data =
|
|
15380
|
+
data = matter16(readFile(art.filePath)).data;
|
|
14625
15381
|
} catch {
|
|
14626
15382
|
continue;
|
|
14627
15383
|
}
|
|
@@ -14797,7 +15553,7 @@ function getStatus(dir) {
|
|
|
14797
15553
|
}
|
|
14798
15554
|
|
|
14799
15555
|
// src/core/initiative-write.ts
|
|
14800
|
-
import
|
|
15556
|
+
import matter17 from "gray-matter";
|
|
14801
15557
|
var WORK_ITEMS_DIR2 = "knowledge/delivery/work-items";
|
|
14802
15558
|
var DRAFT_DIR = `${WORK_ITEMS_DIR2}/draft`;
|
|
14803
15559
|
var ROADMAP_PATH2 = "knowledge/delivery/roadmap.md";
|
|
@@ -14910,7 +15666,7 @@ function buildInitiativeContent(id, input) {
|
|
|
14910
15666
|
if (input.priority) data.priority = input.priority;
|
|
14911
15667
|
if (input.source) data.source = input.source;
|
|
14912
15668
|
if (input.sourceId) data.source_id = input.sourceId;
|
|
14913
|
-
return
|
|
15669
|
+
return matter17.stringify("\n" + (input.body ?? defaultBody(input.title.trim())), data);
|
|
14914
15670
|
}
|
|
14915
15671
|
function createInitiative(dir, input) {
|
|
14916
15672
|
if (!input.title?.trim()) throw new InitiativeWriteError("Initiative title is required.");
|
|
@@ -14934,10 +15690,10 @@ function transitionInitiative(dir, id, to) {
|
|
|
14934
15690
|
throw new InitiativeWriteError(`Invalid transition ${ini.status} \u2192 ${to}.`);
|
|
14935
15691
|
}
|
|
14936
15692
|
const raw = readFile(ini.filePath);
|
|
14937
|
-
const { data, content } =
|
|
15693
|
+
const { data, content } = matter17(raw, {});
|
|
14938
15694
|
data.status = to;
|
|
14939
15695
|
if (to === "completed") data.completed_at = today();
|
|
14940
|
-
const newContent =
|
|
15696
|
+
const newContent = matter17.stringify(content, data);
|
|
14941
15697
|
writeFile(ini.filePath, newContent);
|
|
14942
15698
|
const updated = parseInitiative(dir, ini.filePath, newContent);
|
|
14943
15699
|
if (!updated) throw new InitiativeWriteError("Failed to parse the Initiative after transition.");
|
|
@@ -14947,7 +15703,7 @@ function addCandidate(dir, id, candidate) {
|
|
|
14947
15703
|
const ini = getInitiative(dir, id);
|
|
14948
15704
|
if (!ini) throw new InitiativeWriteError(`Initiative ${id} not found.`);
|
|
14949
15705
|
const raw = readFile(ini.filePath);
|
|
14950
|
-
const { data, content } =
|
|
15706
|
+
const { data, content } = matter17(raw, {});
|
|
14951
15707
|
const existing = Array.isArray(data.candidates) ? data.candidates : [];
|
|
14952
15708
|
const fallbackId = `WI-CANDIDATE-${String(existing.length + 1).padStart(3, "0")}`;
|
|
14953
15709
|
const normalized = normalizeCandidate(candidate, fallbackId);
|
|
@@ -14955,7 +15711,7 @@ function addCandidate(dir, id, candidate) {
|
|
|
14955
15711
|
throw new InitiativeWriteError(`Candidate ${normalized.id} already exists in ${id}.`);
|
|
14956
15712
|
}
|
|
14957
15713
|
data.candidates = [...existing, candidateToData(normalized)];
|
|
14958
|
-
const newContent =
|
|
15714
|
+
const newContent = matter17.stringify(content, data);
|
|
14959
15715
|
writeFile(ini.filePath, newContent);
|
|
14960
15716
|
const updated = parseInitiative(dir, ini.filePath, newContent);
|
|
14961
15717
|
if (!updated) throw new InitiativeWriteError("Failed to parse the Initiative after adding a candidate.");
|
|
@@ -14965,7 +15721,7 @@ function updateInitiative(dir, id, patch) {
|
|
|
14965
15721
|
const ini = getInitiative(dir, id);
|
|
14966
15722
|
if (!ini) throw new InitiativeWriteError(`Initiative ${id} not found.`);
|
|
14967
15723
|
const raw = readFile(ini.filePath);
|
|
14968
|
-
const { data, content } =
|
|
15724
|
+
const { data, content } = matter17(raw, {});
|
|
14969
15725
|
if (patch.title !== void 0) {
|
|
14970
15726
|
if (!patch.title.trim()) throw new InitiativeWriteError("Initiative title cannot be empty.");
|
|
14971
15727
|
data.title = patch.title.trim();
|
|
@@ -14975,7 +15731,7 @@ function updateInitiative(dir, id, patch) {
|
|
|
14975
15731
|
if (patch.knowledgeLevel !== void 0) data.knowledge_level = patch.knowledgeLevel;
|
|
14976
15732
|
if (patch.domains !== void 0) data.domains = patch.domains;
|
|
14977
15733
|
if (patch.relatedCapabilities !== void 0) data.related_capabilities = patch.relatedCapabilities;
|
|
14978
|
-
const newContent =
|
|
15734
|
+
const newContent = matter17.stringify(content, data);
|
|
14979
15735
|
writeFile(ini.filePath, newContent);
|
|
14980
15736
|
const updated = parseInitiative(dir, ini.filePath, newContent);
|
|
14981
15737
|
if (!updated) throw new InitiativeWriteError("Failed to parse the Initiative after update.");
|
|
@@ -14993,10 +15749,10 @@ function addExternalLink(dir, id, link) {
|
|
|
14993
15749
|
throw new InitiativeWriteError(`External link ${link.integration}:${link.externalId} already exists on ${id}.`);
|
|
14994
15750
|
}
|
|
14995
15751
|
const raw = readFile(ini.filePath);
|
|
14996
|
-
const { data, content } =
|
|
15752
|
+
const { data, content } = matter17(raw, {});
|
|
14997
15753
|
const existing = Array.isArray(data.external_links) ? data.external_links : [];
|
|
14998
15754
|
data.external_links = [...existing, externalLinkToData(link)];
|
|
14999
|
-
const newContent =
|
|
15755
|
+
const newContent = matter17.stringify(content, data);
|
|
15000
15756
|
writeFile(ini.filePath, newContent);
|
|
15001
15757
|
const updated = parseInitiative(dir, ini.filePath, newContent);
|
|
15002
15758
|
if (!updated) throw new InitiativeWriteError("Failed to parse the Initiative after adding an external link.");
|
|
@@ -15065,7 +15821,7 @@ function buildWorkItemContent(wiId, iniId, candidate) {
|
|
|
15065
15821
|
"_What did we learn? Update after completion._",
|
|
15066
15822
|
""
|
|
15067
15823
|
].join("\n");
|
|
15068
|
-
return
|
|
15824
|
+
return matter17.stringify("\n" + body, data);
|
|
15069
15825
|
}
|
|
15070
15826
|
function materializeCandidate(dir, id, candidateId) {
|
|
15071
15827
|
const ini = getInitiative(dir, id);
|
|
@@ -15082,13 +15838,13 @@ function materializeCandidate(dir, id, candidateId) {
|
|
|
15082
15838
|
ensureDir(join(dir, DRAFT_DIR));
|
|
15083
15839
|
writeFile(join(dir, DRAFT_DIR, fileName), buildWorkItemContent(wiId, ini.id, candidate));
|
|
15084
15840
|
const raw = readFile(ini.filePath);
|
|
15085
|
-
const { data, content } =
|
|
15841
|
+
const { data, content } = matter17(raw, {});
|
|
15086
15842
|
const cands = Array.isArray(data.candidates) ? data.candidates : [];
|
|
15087
15843
|
for (const c of cands) {
|
|
15088
15844
|
if (c && typeof c === "object" && String(c.id) === candidateId) c.materialized_as = wiId;
|
|
15089
15845
|
}
|
|
15090
15846
|
data.candidates = cands;
|
|
15091
|
-
const newContent =
|
|
15847
|
+
const newContent = matter17.stringify(content, data);
|
|
15092
15848
|
writeFile(ini.filePath, newContent);
|
|
15093
15849
|
const updated = parseInitiative(dir, ini.filePath, newContent);
|
|
15094
15850
|
if (!updated) throw new InitiativeWriteError("Failed to parse the Initiative after materialization.");
|
|
@@ -15239,7 +15995,7 @@ function evaluateInitiativeCompletion(dir, ini) {
|
|
|
15239
15995
|
// src/core/deprecation-write.ts
|
|
15240
15996
|
import fs6 from "fs";
|
|
15241
15997
|
import path5 from "path";
|
|
15242
|
-
import
|
|
15998
|
+
import matter18 from "gray-matter";
|
|
15243
15999
|
var DeprecationWriteError = class extends Error {
|
|
15244
16000
|
constructor(code, message) {
|
|
15245
16001
|
super(message);
|
|
@@ -15257,7 +16013,7 @@ function atomicWrite4(filePath, content) {
|
|
|
15257
16013
|
fs6.renameSync(tmp, filePath);
|
|
15258
16014
|
}
|
|
15259
16015
|
function serialize3(data, body) {
|
|
15260
|
-
return
|
|
16016
|
+
return matter18.stringify(`
|
|
15261
16017
|
${body.trim()}
|
|
15262
16018
|
`, data);
|
|
15263
16019
|
}
|
|
@@ -15323,7 +16079,7 @@ function validateTargetInput(dir, raw) {
|
|
|
15323
16079
|
function loadPlanRaw(dir, planId) {
|
|
15324
16080
|
const match = allPlanArtifacts(dir).find((a) => a.id === planId || a.title === planId);
|
|
15325
16081
|
if (!match) throw new DeprecationWriteError("NOT_FOUND", `Deprecation Plan "${planId}" not found.`);
|
|
15326
|
-
const parsed =
|
|
16082
|
+
const parsed = matter18(readFile(match.filePath));
|
|
15327
16083
|
const data = { ...parsed.data ?? {} };
|
|
15328
16084
|
return { filePath: match.filePath, data, body: parsed.content.trim() };
|
|
15329
16085
|
}
|
|
@@ -15406,7 +16162,7 @@ function removeTarget(dir, planId, targetId, opts = {}) {
|
|
|
15406
16162
|
}
|
|
15407
16163
|
|
|
15408
16164
|
// src/core/deprecation-runbook.ts
|
|
15409
|
-
import
|
|
16165
|
+
import matter19 from "gray-matter";
|
|
15410
16166
|
var PRODUCTION_RUNBOOK_ARTIFACT_TYPE = "production-runbook";
|
|
15411
16167
|
var PRODUCTION_RUNBOOKS_DIR = "knowledge/delivery/runbooks";
|
|
15412
16168
|
var RUNBOOK_SECTIONS = [
|
|
@@ -15588,7 +16344,7 @@ function createProductionRunbook(dir, planId, targetId) {
|
|
|
15588
16344
|
if (!context.eligible) throw new ProductionRunbookError(context.blockers.join(" "));
|
|
15589
16345
|
const path8 = context.nextPath;
|
|
15590
16346
|
const id = path8.split("/").pop()?.match(/^(RB-\d+)-/)?.[1] ?? "";
|
|
15591
|
-
const content =
|
|
16347
|
+
const content = matter19.stringify(renderRunbook(context), {
|
|
15592
16348
|
id,
|
|
15593
16349
|
type: PRODUCTION_RUNBOOK_ARTIFACT_TYPE,
|
|
15594
16350
|
title: `Production runbook \u2014 ${context.target.title ?? context.target.id}`,
|
|
@@ -15615,7 +16371,7 @@ function getProductionRunbook(dir, id) {
|
|
|
15615
16371
|
for (const name of readDir(root)) {
|
|
15616
16372
|
if (!name.toLowerCase().startsWith(`${id.toLowerCase()}-`) || !name.endsWith(".md")) continue;
|
|
15617
16373
|
const path8 = `${PRODUCTION_RUNBOOKS_DIR}/${name}`;
|
|
15618
|
-
const parsed =
|
|
16374
|
+
const parsed = matter19(readFile(join(dir, path8)));
|
|
15619
16375
|
const data = parsed.data;
|
|
15620
16376
|
if (data.type !== PRODUCTION_RUNBOOK_ARTIFACT_TYPE) continue;
|
|
15621
16377
|
return {
|
|
@@ -15649,7 +16405,7 @@ import fs7 from "fs";
|
|
|
15649
16405
|
import path6 from "path";
|
|
15650
16406
|
|
|
15651
16407
|
// src/core/okf/mapping.ts
|
|
15652
|
-
import
|
|
16408
|
+
import matter20 from "gray-matter";
|
|
15653
16409
|
var OKF_TYPE_TABLE = {
|
|
15654
16410
|
"business-knowledge": "Business Knowledge",
|
|
15655
16411
|
"product-knowledge": "Product Knowledge",
|
|
@@ -15750,7 +16506,7 @@ function conceptId(a) {
|
|
|
15750
16506
|
}
|
|
15751
16507
|
function readBody2(a) {
|
|
15752
16508
|
try {
|
|
15753
|
-
const body =
|
|
16509
|
+
const body = matter20(readFile(a.filePath)).content.trim();
|
|
15754
16510
|
return body || null;
|
|
15755
16511
|
} catch {
|
|
15756
16512
|
return null;
|
|
@@ -16128,7 +16884,7 @@ ${c.body ?? ""}`;
|
|
|
16128
16884
|
// src/core/okf/validate.ts
|
|
16129
16885
|
import fs8 from "fs";
|
|
16130
16886
|
import path7 from "path";
|
|
16131
|
-
import
|
|
16887
|
+
import matter21 from "gray-matter";
|
|
16132
16888
|
function walk(root) {
|
|
16133
16889
|
const out = [];
|
|
16134
16890
|
const rec = (d) => {
|
|
@@ -16175,7 +16931,7 @@ function validateOkf(dir, opts = {}) {
|
|
|
16175
16931
|
const isIndex = path7.basename(file) === "index.md";
|
|
16176
16932
|
let data = {};
|
|
16177
16933
|
try {
|
|
16178
|
-
data =
|
|
16934
|
+
data = matter21(fs8.readFileSync(file, "utf-8")).data ?? {};
|
|
16179
16935
|
} catch {
|
|
16180
16936
|
findings.push({ level: "conformance", file: r, message: "Invalid YAML frontmatter." });
|
|
16181
16937
|
continue;
|
|
@@ -16197,7 +16953,7 @@ function validateOkf(dir, opts = {}) {
|
|
|
16197
16953
|
}
|
|
16198
16954
|
const body = (() => {
|
|
16199
16955
|
try {
|
|
16200
|
-
return
|
|
16956
|
+
return matter21(fs8.readFileSync(file, "utf-8")).content;
|
|
16201
16957
|
} catch {
|
|
16202
16958
|
return "";
|
|
16203
16959
|
}
|
|
@@ -16216,6 +16972,7 @@ function validateOkf(dir, opts = {}) {
|
|
|
16216
16972
|
}
|
|
16217
16973
|
export {
|
|
16218
16974
|
CANDIDATE_DISCOVERY_GUIDANCE,
|
|
16975
|
+
CONSOLIDATION_CATEGORIES,
|
|
16219
16976
|
CURRENT_CONSENT_VERSION,
|
|
16220
16977
|
DEPRECATION_ARTIFACT_TYPE,
|
|
16221
16978
|
DEPRECATION_PLANS_DIR,
|
|
@@ -16246,6 +17003,7 @@ export {
|
|
|
16246
17003
|
PRODUCTION_RUNBOOKS_DIR,
|
|
16247
17004
|
PRODUCTION_RUNBOOK_ARTIFACT_TYPE,
|
|
16248
17005
|
ProductionRunbookError,
|
|
17006
|
+
REDACTED_COORDINATE,
|
|
16249
17007
|
RESOURCE_ARTIFACT_TYPE,
|
|
16250
17008
|
RESOURCE_ROLES,
|
|
16251
17009
|
RESOURCE_TYPES,
|
|
@@ -16269,6 +17027,7 @@ export {
|
|
|
16269
17027
|
applyTopologyProposal,
|
|
16270
17028
|
associatedWorkItems,
|
|
16271
17029
|
buildConcept,
|
|
17030
|
+
buildConsolidationPlan,
|
|
16272
17031
|
buildDriftReport,
|
|
16273
17032
|
buildImpactReport,
|
|
16274
17033
|
buildImplementationHandoff,
|
|
@@ -16287,6 +17046,7 @@ export {
|
|
|
16287
17046
|
computeRefinementStatus,
|
|
16288
17047
|
conceptBundlePath,
|
|
16289
17048
|
consentNotice,
|
|
17049
|
+
consolidationPlanStaleness,
|
|
16290
17050
|
createInitiative,
|
|
16291
17051
|
createIntegration,
|
|
16292
17052
|
createPlan,
|
|
@@ -16366,6 +17126,7 @@ export {
|
|
|
16366
17126
|
loadConfig,
|
|
16367
17127
|
loadMappedModules,
|
|
16368
17128
|
loadSystemTopology,
|
|
17129
|
+
looksLikeSecretCoordinate,
|
|
16369
17130
|
materializeCandidate,
|
|
16370
17131
|
materializeRoadmapInitiative,
|
|
16371
17132
|
nextInitiativeId,
|
|
@@ -16394,10 +17155,12 @@ export {
|
|
|
16394
17155
|
redactSecrets,
|
|
16395
17156
|
removeIntegrationSecret,
|
|
16396
17157
|
removeTarget,
|
|
17158
|
+
renderConsolidationMarkdown,
|
|
16397
17159
|
renderDriftMarkdown,
|
|
16398
17160
|
renderImpactMarkdown,
|
|
16399
17161
|
renderSavingsMarkdown,
|
|
16400
17162
|
searchSystemNodes,
|
|
17163
|
+
serializeConsolidationJson,
|
|
16401
17164
|
serializeDriftJson,
|
|
16402
17165
|
serializeImpactJson,
|
|
16403
17166
|
serializeSavingsJson,
|