@kaddo/cli 3.132.0 → 3.134.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-B0OuhO94.js → architectureDiagram-3BPJPVTR-CYNwLGE7.js} +1 -1
- package/dist/admin-dist/assets/{chunk-727SXJPM-CaqXII8F.js → chunk-727SXJPM-Cet603Hl.js} +1 -1
- package/dist/admin-dist/assets/{chunk-AQP2D5EJ-Bg4-fugM.js → chunk-AQP2D5EJ-8XEHPg3a.js} +1 -1
- package/dist/admin-dist/assets/{classDiagram-v2-Q7XG4LA2-CckXCSJd.js → classDiagram-4FO5ZUOK-Bhwb9850.js} +1 -1
- package/dist/admin-dist/assets/{classDiagram-4FO5ZUOK-CckXCSJd.js → classDiagram-v2-Q7XG4LA2-Bhwb9850.js} +1 -1
- package/dist/admin-dist/assets/{dagre-BM42HDAG-C0-ZkGqx.js → dagre-BM42HDAG-DqQXdP8F.js} +1 -1
- package/dist/admin-dist/assets/{diagram-2AECGRRQ-CXx8vdld.js → diagram-2AECGRRQ-B1bysbNR.js} +1 -1
- package/dist/admin-dist/assets/{diagram-5GNKFQAL-DsmIj164.js → diagram-5GNKFQAL-DRifvijh.js} +1 -1
- package/dist/admin-dist/assets/{diagram-LMA3HP47-BwY_Oswl.js → diagram-LMA3HP47-DajL2Tv-.js} +1 -1
- package/dist/admin-dist/assets/{diagram-OG6HWLK6-DZmoKiat.js → diagram-OG6HWLK6-WCJo9oL4.js} +1 -1
- package/dist/admin-dist/assets/{erDiagram-TEJ5UH35-DnkbNH-3.js → erDiagram-TEJ5UH35-DwgqKm6b.js} +1 -1
- package/dist/admin-dist/assets/{flowDiagram-I6XJVG4X-0M5AwmbD.js → flowDiagram-I6XJVG4X-M0kG8sQQ.js} +1 -1
- package/dist/admin-dist/assets/{ganttDiagram-6RSMTGT7-p0YbWB-q.js → ganttDiagram-6RSMTGT7-DtyZt9Ti.js} +1 -1
- package/dist/admin-dist/assets/index-CZVvIq5M.js +96 -0
- package/dist/admin-dist/assets/{infoDiagram-5YYISTIA-CizIjxWP.js → infoDiagram-5YYISTIA-Vwdw_1gf.js} +1 -1
- package/dist/admin-dist/assets/{ishikawaDiagram-YF4QCWOH-DZKlVu1h.js → ishikawaDiagram-YF4QCWOH-CIi6B5fy.js} +1 -1
- package/dist/admin-dist/assets/{kanban-definition-UN3LZRKU-G70NiHFN.js → kanban-definition-UN3LZRKU-5HNFMSQ7.js} +1 -1
- package/dist/admin-dist/assets/{linear-BBYNswBY.js → linear-D3H69r3G.js} +1 -1
- package/dist/admin-dist/assets/{mindmap-definition-RKZ34NQL-CSed8LsK.js → mindmap-definition-RKZ34NQL-BI0w0H_c.js} +1 -1
- package/dist/admin-dist/assets/{pieDiagram-4H26LBE5-BMiHTdzs.js → pieDiagram-4H26LBE5-5oMGjRSP.js} +1 -1
- package/dist/admin-dist/assets/{quadrantDiagram-W4KKPZXB-xAoJMAFV.js → quadrantDiagram-W4KKPZXB-Cf4_7xD4.js} +1 -1
- package/dist/admin-dist/assets/{requirementDiagram-4Y6WPE33-BqxSHuU_.js → requirementDiagram-4Y6WPE33-tKyHvrMo.js} +1 -1
- package/dist/admin-dist/assets/{sequenceDiagram-3UESZ5HK-CEQr2xzT.js → sequenceDiagram-3UESZ5HK-XJChOzcT.js} +1 -1
- package/dist/admin-dist/assets/{stateDiagram-AJRCARHV-DxYDejoz.js → stateDiagram-AJRCARHV-CG6QHhPz.js} +1 -1
- package/dist/admin-dist/assets/{stateDiagram-v2-BHNVJYJU-DXEhlcga.js → stateDiagram-v2-BHNVJYJU-COU53r4o.js} +1 -1
- package/dist/admin-dist/assets/{timeline-definition-PNZ67QCA-BAUnT8tD.js → timeline-definition-PNZ67QCA-CszwARJN.js} +1 -1
- package/dist/admin-dist/assets/{vennDiagram-CIIHVFJN-DAWIyWJZ.js → vennDiagram-CIIHVFJN-kMR7sGYN.js} +1 -1
- package/dist/admin-dist/assets/{wardleyDiagram-YWT4CUSO-B5sNcSKa.js → wardleyDiagram-YWT4CUSO-Cu44stm7.js} +1 -1
- package/dist/admin-dist/assets/{xychartDiagram-2RQKCTM6-0N6T1yeV.js → xychartDiagram-2RQKCTM6-DeU0-PgC.js} +1 -1
- package/dist/admin-dist/index.html +1 -1
- package/dist/admin-server/index.js +281 -6
- package/dist/core.js +469 -93
- package/dist/index.js +506 -141
- package/package.json +1 -1
- package/dist/admin-dist/assets/index-DE-FwnK7.js +0 -94
package/dist/core.js
CHANGED
|
@@ -141,8 +141,8 @@ function loadConfig(dir) {
|
|
|
141
141
|
const parsed = configSchema.safeParse(raw ?? {});
|
|
142
142
|
if (!parsed.success) {
|
|
143
143
|
const issues = parsed.error.issues.map((i) => {
|
|
144
|
-
const
|
|
145
|
-
return
|
|
144
|
+
const path10 = i.path.join(".");
|
|
145
|
+
return path10 ? ` - ${path10}: ${i.message}` : ` - ${i.message}`;
|
|
146
146
|
}).join("\n");
|
|
147
147
|
throw new ConfigError(`Invalid .kaddo/config.yml:
|
|
148
148
|
${issues}`);
|
|
@@ -409,11 +409,11 @@ function moduleArtifactCoverage(dir, id) {
|
|
|
409
409
|
};
|
|
410
410
|
}
|
|
411
411
|
function loadMappedModules(dir) {
|
|
412
|
-
const
|
|
413
|
-
if (!exists(
|
|
412
|
+
const path10 = join(dir, DESCRIPTOR_PATH);
|
|
413
|
+
if (!exists(path10)) return [];
|
|
414
414
|
let parsed;
|
|
415
415
|
try {
|
|
416
|
-
parsed = parseYaml3(readFile(
|
|
416
|
+
parsed = parseYaml3(readFile(path10));
|
|
417
417
|
} catch {
|
|
418
418
|
return [];
|
|
419
419
|
}
|
|
@@ -1644,7 +1644,7 @@ function sectionParagraph(md, title) {
|
|
|
1644
1644
|
}
|
|
1645
1645
|
return "";
|
|
1646
1646
|
}
|
|
1647
|
-
function parseCapsule(id,
|
|
1647
|
+
function parseCapsule(id, path10, md) {
|
|
1648
1648
|
const { data } = matter2(md);
|
|
1649
1649
|
const updatedAt = data.updated_at ? String(data.updated_at) : void 0;
|
|
1650
1650
|
let ageDays = null;
|
|
@@ -1654,7 +1654,7 @@ function parseCapsule(id, path8, md) {
|
|
|
1654
1654
|
}
|
|
1655
1655
|
return {
|
|
1656
1656
|
id,
|
|
1657
|
-
path:
|
|
1657
|
+
path: path10,
|
|
1658
1658
|
system: data.system ? String(data.system) : id,
|
|
1659
1659
|
owner: data.owner ? String(data.owner) : void 0,
|
|
1660
1660
|
updatedAt,
|
|
@@ -1891,6 +1891,7 @@ function suggestInitiativesForExternalItem(dir, integration, externalId) {
|
|
|
1891
1891
|
}
|
|
1892
1892
|
|
|
1893
1893
|
// src/core/delivery-planning.ts
|
|
1894
|
+
import { createHash } from "crypto";
|
|
1894
1895
|
import matter4 from "gray-matter";
|
|
1895
1896
|
var DELIVERY_PLANS_DIR = "knowledge/delivery/plans";
|
|
1896
1897
|
var EPICS_DIR = "knowledge/delivery/epics";
|
|
@@ -2176,6 +2177,35 @@ function validatePlanningGraph(dir) {
|
|
|
2176
2177
|
findings.push({ level: "warning", kind: "pending_dependency", subject: e.id, message: `Epic ${e.id} is blocked by unfinished dependency ${d}.` });
|
|
2177
2178
|
return findings;
|
|
2178
2179
|
}
|
|
2180
|
+
function revisionOf(content) {
|
|
2181
|
+
return createHash("sha256").update(content, "utf8").digest("hex").slice(0, 16);
|
|
2182
|
+
}
|
|
2183
|
+
function validateEpicDependencyChange(dir, epicId, deps) {
|
|
2184
|
+
const epics = discoverEpics(dir);
|
|
2185
|
+
const epicIds = new Set(epics.map((e) => e.id.toLowerCase()));
|
|
2186
|
+
const self = epicId.toLowerCase();
|
|
2187
|
+
const errors = [];
|
|
2188
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2189
|
+
for (const d of deps) {
|
|
2190
|
+
const key = d.toLowerCase();
|
|
2191
|
+
if (key === self) {
|
|
2192
|
+
errors.push(`Epic ${epicId} cannot depend on itself.`);
|
|
2193
|
+
continue;
|
|
2194
|
+
}
|
|
2195
|
+
if (!epicIds.has(key)) {
|
|
2196
|
+
errors.push(`Epic ${epicId} depends on missing Epic ${d}.`);
|
|
2197
|
+
continue;
|
|
2198
|
+
}
|
|
2199
|
+
if (seen.has(key)) errors.push(`Epic ${epicId} declares duplicate dependency ${d}.`);
|
|
2200
|
+
seen.add(key);
|
|
2201
|
+
}
|
|
2202
|
+
if (errors.length > 0) return errors;
|
|
2203
|
+
const edges = new Map(epics.map((e) => [e.id.toLowerCase(), e.dependsOn.map((d) => d.toLowerCase())]));
|
|
2204
|
+
edges.set(self, deps.map((d) => d.toLowerCase()));
|
|
2205
|
+
const cycle = findCycle([...epicIds, self], edges);
|
|
2206
|
+
if (cycle) errors.push(`Dependency cycle among Epics: ${cycle.join(" \u2192 ")}.`);
|
|
2207
|
+
return errors;
|
|
2208
|
+
}
|
|
2179
2209
|
|
|
2180
2210
|
// src/core/resources.ts
|
|
2181
2211
|
import matter5 from "gray-matter";
|
|
@@ -2696,9 +2726,9 @@ function buildGraph(dir, config, opts = {}, now = /* @__PURE__ */ new Date()) {
|
|
|
2696
2726
|
];
|
|
2697
2727
|
const presentLayers = [];
|
|
2698
2728
|
for (const layer of layerDocs) {
|
|
2699
|
-
const
|
|
2700
|
-
if (
|
|
2701
|
-
addNode({ id: layer.id, type: layer.type, label: layer.label, path:
|
|
2729
|
+
const path10 = layer.files.map((f) => `${KNOWLEDGE2}/${f}`).find((rel) => exists(join(dir, rel)));
|
|
2730
|
+
if (path10) {
|
|
2731
|
+
addNode({ id: layer.id, type: layer.type, label: layer.label, path: path10 });
|
|
2702
2732
|
presentLayers.push(layer.id);
|
|
2703
2733
|
}
|
|
2704
2734
|
}
|
|
@@ -4126,13 +4156,13 @@ function meaningful(text2) {
|
|
|
4126
4156
|
});
|
|
4127
4157
|
}
|
|
4128
4158
|
function readPocSummary(dir) {
|
|
4129
|
-
const
|
|
4130
|
-
if (!exists(
|
|
4159
|
+
const path10 = join(dir, POC_ARTIFACT_PATH);
|
|
4160
|
+
if (!exists(path10)) {
|
|
4131
4161
|
return { exists: false, hypothesisDefined: false, successCriteriaCount: 0, constraintsDefined: false, nonGoalsDefined: false, conclusion: "pending" };
|
|
4132
4162
|
}
|
|
4133
4163
|
let markdown = "";
|
|
4134
4164
|
try {
|
|
4135
|
-
markdown = readFile(
|
|
4165
|
+
markdown = readFile(path10);
|
|
4136
4166
|
} catch {
|
|
4137
4167
|
return { exists: false, hypothesisDefined: false, successCriteriaCount: 0, constraintsDefined: false, nonGoalsDefined: false, conclusion: "pending" };
|
|
4138
4168
|
}
|
|
@@ -4150,13 +4180,13 @@ function readPocSummary(dir) {
|
|
|
4150
4180
|
}
|
|
4151
4181
|
|
|
4152
4182
|
// src/core/poc-report.ts
|
|
4153
|
-
import { createHash } from "crypto";
|
|
4183
|
+
import { createHash as createHash2 } from "crypto";
|
|
4154
4184
|
import matter8 from "gray-matter";
|
|
4155
4185
|
var POC_REPORT_PREFIX = "poc-report-v";
|
|
4156
4186
|
var SECRET_LINE = /(^|\s)(?:[A-Z][A-Z0-9_]*(?:TOKEN|SECRET|PASSWORD|API_KEY|PRIVATE_KEY)|(?:token|secret|password|api[_-]?key))\s*[:=]\s*\S+/i;
|
|
4157
4187
|
var reportName = /^poc-report-v(\d{3,})\.md$/;
|
|
4158
4188
|
function sha(value) {
|
|
4159
|
-
return
|
|
4189
|
+
return createHash2("sha256").update(value).digest("hex");
|
|
4160
4190
|
}
|
|
4161
4191
|
function posix(value) {
|
|
4162
4192
|
return value.replace(/\\/g, "/");
|
|
@@ -4167,11 +4197,11 @@ function redactSecrets(value) {
|
|
|
4167
4197
|
return line.replace(/([:=]\s*)\S+.*/, "$1[redacted]");
|
|
4168
4198
|
}).join("\n");
|
|
4169
4199
|
}
|
|
4170
|
-
function source(dir,
|
|
4171
|
-
const absolute = join(dir,
|
|
4200
|
+
function source(dir, path10, kind) {
|
|
4201
|
+
const absolute = join(dir, path10);
|
|
4172
4202
|
if (!exists(absolute)) return null;
|
|
4173
4203
|
const raw = readFile(absolute);
|
|
4174
|
-
return { path: posix(
|
|
4204
|
+
return { path: posix(path10), kind, digest: sha(raw), content: redactSecrets(raw) };
|
|
4175
4205
|
}
|
|
4176
4206
|
function reportFiles(dir) {
|
|
4177
4207
|
const delivery = join(dir, "knowledge", "delivery");
|
|
@@ -4211,9 +4241,9 @@ function buildPocReportContext(dir) {
|
|
|
4211
4241
|
};
|
|
4212
4242
|
}
|
|
4213
4243
|
const sources = [];
|
|
4214
|
-
const add = (
|
|
4215
|
-
if (sources.some((item2) => item2.path === posix(
|
|
4216
|
-
const item = source(dir,
|
|
4244
|
+
const add = (path10, kind) => {
|
|
4245
|
+
if (sources.some((item2) => item2.path === posix(path10))) return;
|
|
4246
|
+
const item = source(dir, path10, kind);
|
|
4217
4247
|
if (item) sources.push(item);
|
|
4218
4248
|
};
|
|
4219
4249
|
add(POC_ARTIFACT_PATH, "poc");
|
|
@@ -4241,7 +4271,7 @@ function buildPocReportContext(dir) {
|
|
|
4241
4271
|
const sourceFingerprint = sha(sources.map((item) => `${item.path}\0${item.digest}`).join("\n"));
|
|
4242
4272
|
const status = !latestReport ? "missing" : latestReport.sourceFingerprint === sourceFingerprint ? "current" : "stale";
|
|
4243
4273
|
const currentManifest = Object.fromEntries(sources.map((item) => [item.path, item.digest]));
|
|
4244
|
-
const changesSinceLatest = status === "stale" ? [.../* @__PURE__ */ new Set([...Object.keys(currentManifest), ...Object.keys(latestReport?.sourceManifest ?? {})])].filter((
|
|
4274
|
+
const changesSinceLatest = status === "stale" ? [.../* @__PURE__ */ new Set([...Object.keys(currentManifest), ...Object.keys(latestReport?.sourceManifest ?? {})])].filter((path10) => currentManifest[path10] !== latestReport?.sourceManifest[path10]).sort() : [];
|
|
4245
4275
|
const sourceList = sources.map((item) => `- ${item.path} (${item.kind})`).join("\n") || "- No sources selected.";
|
|
4246
4276
|
return {
|
|
4247
4277
|
eligible: true,
|
|
@@ -4417,10 +4447,10 @@ function resolveNextStep(dir, now = /* @__PURE__ */ new Date()) {
|
|
|
4417
4447
|
const q = (rel) => analyzeKnowledgeArtifact(dir, rel);
|
|
4418
4448
|
const resolveAgent = (agent) => {
|
|
4419
4449
|
const file = agent.endsWith(".md") ? agent : `${agent}.md`;
|
|
4420
|
-
const
|
|
4421
|
-
const installed = isFile(join(dir,
|
|
4450
|
+
const path10 = agentInstallPath(file);
|
|
4451
|
+
const installed = isFile(join(dir, path10));
|
|
4422
4452
|
const group = agentGroupOf(file);
|
|
4423
|
-
return { agentPath:
|
|
4453
|
+
return { agentPath: path10, agentInstalled: installed, installCommand: installed ? void 0 : `kaddo add agents --group ${group}` };
|
|
4424
4454
|
};
|
|
4425
4455
|
const moduleRepo = isModule(config);
|
|
4426
4456
|
const coreRepo = isCore(config);
|
|
@@ -9597,7 +9627,7 @@ function buildGuardHistory(dir) {
|
|
|
9597
9627
|
const d = hotspotDir(t.code_path);
|
|
9598
9628
|
hotspotMap.set(d, (hotspotMap.get(d) ?? 0) + 1);
|
|
9599
9629
|
}
|
|
9600
|
-
const hotspots = [...hotspotMap.entries()].map(([
|
|
9630
|
+
const hotspots = [...hotspotMap.entries()].map(([path10, warnings]) => ({ path: path10, warnings })).sort((a, b) => b.warnings - a.warnings);
|
|
9601
9631
|
return {
|
|
9602
9632
|
available: true,
|
|
9603
9633
|
total_runs: sorted.length,
|
|
@@ -11095,6 +11125,31 @@ var DeliveryPlanningWriteError = class extends Error {
|
|
|
11095
11125
|
this.name = "DeliveryPlanningWriteError";
|
|
11096
11126
|
}
|
|
11097
11127
|
};
|
|
11128
|
+
var PlanningConflictError = class extends Error {
|
|
11129
|
+
constructor(id, expectedRevision, actualRevision) {
|
|
11130
|
+
super(`"${id}" was modified since it was loaded (expected revision ${expectedRevision}, found ${actualRevision}). Reload and try again.`);
|
|
11131
|
+
this.id = id;
|
|
11132
|
+
this.expectedRevision = expectedRevision;
|
|
11133
|
+
this.actualRevision = actualRevision;
|
|
11134
|
+
this.name = "PlanningConflictError";
|
|
11135
|
+
}
|
|
11136
|
+
id;
|
|
11137
|
+
expectedRevision;
|
|
11138
|
+
actualRevision;
|
|
11139
|
+
};
|
|
11140
|
+
function assertFreshRevision(id, currentContent, opts) {
|
|
11141
|
+
if (!opts?.expectedRevision) return;
|
|
11142
|
+
const actual = revisionOf(currentContent);
|
|
11143
|
+
if (actual !== opts.expectedRevision) throw new PlanningConflictError(id, opts.expectedRevision, actual);
|
|
11144
|
+
}
|
|
11145
|
+
function cleanList(v) {
|
|
11146
|
+
return v.map((x) => typeof x === "string" ? x.trim() : String(x)).filter(Boolean);
|
|
11147
|
+
}
|
|
11148
|
+
function setListOrDelete(data, key, list2) {
|
|
11149
|
+
const cleaned = cleanList(list2);
|
|
11150
|
+
if (cleaned.length > 0) data[key] = cleaned;
|
|
11151
|
+
else delete data[key];
|
|
11152
|
+
}
|
|
11098
11153
|
function slugify3(s) {
|
|
11099
11154
|
return s.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "item";
|
|
11100
11155
|
}
|
|
@@ -11155,9 +11210,134 @@ function associateInitiativeWithEpic(dir, initiativeId, epicId) {
|
|
|
11155
11210
|
if (!getEpic(dir, epicId)) throw new DeliveryPlanningWriteError(`Epic ${epicId} does not exist.`);
|
|
11156
11211
|
return updateInitiative(dir, ini.id, { epic: epicId });
|
|
11157
11212
|
}
|
|
11213
|
+
function disassociateInitiativeFromEpic(dir, initiativeId) {
|
|
11214
|
+
const ini = getInitiative(dir, initiativeId);
|
|
11215
|
+
if (!ini) throw new DeliveryPlanningWriteError(`Initiative ${initiativeId} not found.`);
|
|
11216
|
+
if (!ini.epic) return ini;
|
|
11217
|
+
return updateInitiative(dir, ini.id, { epic: null });
|
|
11218
|
+
}
|
|
11219
|
+
function normalizeMilestones(planId, input) {
|
|
11220
|
+
const seen = /* @__PURE__ */ new Set();
|
|
11221
|
+
const data = [];
|
|
11222
|
+
const model = [];
|
|
11223
|
+
for (const m of input) {
|
|
11224
|
+
const id = m.id?.trim();
|
|
11225
|
+
if (!id) throw new DeliveryPlanningWriteError("Each milestone needs an id.");
|
|
11226
|
+
const key = id.toLowerCase();
|
|
11227
|
+
if (seen.has(key)) throw new DeliveryPlanningWriteError(`Plan ${planId} declares milestone ${id} more than once.`);
|
|
11228
|
+
seen.add(key);
|
|
11229
|
+
const title = m.title?.trim() || id;
|
|
11230
|
+
const exit = cleanList(m.exitCriteria ?? []);
|
|
11231
|
+
const entry = { id, title };
|
|
11232
|
+
if (exit.length > 0) entry.exit_criteria = exit;
|
|
11233
|
+
data.push(entry);
|
|
11234
|
+
model.push({ id, title, exitCriteria: exit });
|
|
11235
|
+
}
|
|
11236
|
+
return { data, model };
|
|
11237
|
+
}
|
|
11238
|
+
function updateDeliveryPlan(dir, id, patch, opts) {
|
|
11239
|
+
const plan = getPlan(dir, id);
|
|
11240
|
+
if (!plan) throw new DeliveryPlanningWriteError(`Plan ${id} does not exist.`);
|
|
11241
|
+
const raw = readFile(plan.filePath);
|
|
11242
|
+
assertFreshRevision(plan.id, raw, opts);
|
|
11243
|
+
const { data, content } = matter13(raw, {});
|
|
11244
|
+
if (patch.title !== void 0) {
|
|
11245
|
+
if (!patch.title.trim()) throw new DeliveryPlanningWriteError("Plan title cannot be empty.");
|
|
11246
|
+
data.title = patch.title.trim();
|
|
11247
|
+
}
|
|
11248
|
+
if (patch.objective !== void 0) {
|
|
11249
|
+
if (patch.objective === null || patch.objective.trim() === "") delete data.objective;
|
|
11250
|
+
else data.objective = patch.objective.trim();
|
|
11251
|
+
}
|
|
11252
|
+
if (patch.successCriteria !== void 0) setListOrDelete(data, "success_criteria", patch.successCriteria);
|
|
11253
|
+
if (patch.risks !== void 0) setListOrDelete(data, "risks", patch.risks);
|
|
11254
|
+
if (patch.dependsOn !== void 0) setListOrDelete(data, "depends_on", patch.dependsOn);
|
|
11255
|
+
if (patch.references !== void 0) setListOrDelete(data, "references", patch.references);
|
|
11256
|
+
if (patch.milestones !== void 0) {
|
|
11257
|
+
const { data: msData, model } = normalizeMilestones(plan.id, patch.milestones);
|
|
11258
|
+
const newIds = new Set(model.map((m) => m.id.toLowerCase()));
|
|
11259
|
+
const referencedByEpic = /* @__PURE__ */ new Map();
|
|
11260
|
+
for (const e of epicsInPlan(dir, plan.id)) {
|
|
11261
|
+
if (!e.milestone) continue;
|
|
11262
|
+
const key = e.milestone.toLowerCase();
|
|
11263
|
+
if (!newIds.has(key)) {
|
|
11264
|
+
const list2 = referencedByEpic.get(e.milestone) ?? [];
|
|
11265
|
+
list2.push(e.id);
|
|
11266
|
+
referencedByEpic.set(e.milestone, list2);
|
|
11267
|
+
}
|
|
11268
|
+
}
|
|
11269
|
+
if (referencedByEpic.size > 0) {
|
|
11270
|
+
const detail = [...referencedByEpic.entries()].map(([ms, epics]) => `${ms} (used by ${epics.join(", ")})`).join("; ");
|
|
11271
|
+
throw new DeliveryPlanningWriteError(`Cannot remove or rename milestone(s) still referenced by an Epic: ${detail}. Reassign the Epic first.`);
|
|
11272
|
+
}
|
|
11273
|
+
data.milestones = msData;
|
|
11274
|
+
}
|
|
11275
|
+
const newContent = matter13.stringify(content, data);
|
|
11276
|
+
writeFile(plan.filePath, newContent);
|
|
11277
|
+
const updated = parseDeliveryPlan(dir, plan.filePath, newContent);
|
|
11278
|
+
if (!updated) throw new DeliveryPlanningWriteError("Failed to parse the Plan after update.");
|
|
11279
|
+
return updated;
|
|
11280
|
+
}
|
|
11281
|
+
function updateEpic(dir, id, patch, opts) {
|
|
11282
|
+
const epic = getEpic(dir, id);
|
|
11283
|
+
if (!epic) throw new DeliveryPlanningWriteError(`Epic ${id} does not exist.`);
|
|
11284
|
+
const raw = readFile(epic.filePath);
|
|
11285
|
+
assertFreshRevision(epic.id, raw, opts);
|
|
11286
|
+
const { data, content } = matter13(raw, {});
|
|
11287
|
+
const finalPlan = patch.plan !== void 0 ? patch.plan?.trim() || null : epic.plan;
|
|
11288
|
+
let finalMilestone = patch.milestone !== void 0 ? patch.milestone?.trim() || null : epic.milestone;
|
|
11289
|
+
if (!finalPlan) {
|
|
11290
|
+
if (patch.milestone !== void 0 && finalMilestone) {
|
|
11291
|
+
throw new DeliveryPlanningWriteError("A milestone can only be set together with its plan.");
|
|
11292
|
+
}
|
|
11293
|
+
finalMilestone = null;
|
|
11294
|
+
} else {
|
|
11295
|
+
if (patch.plan !== void 0 && !getPlan(dir, finalPlan)) {
|
|
11296
|
+
throw new DeliveryPlanningWriteError(`Plan ${finalPlan} does not exist.`);
|
|
11297
|
+
}
|
|
11298
|
+
if (finalMilestone) {
|
|
11299
|
+
const plan = getPlan(dir, finalPlan);
|
|
11300
|
+
if (!plan) throw new DeliveryPlanningWriteError(`Plan ${finalPlan} does not exist.`);
|
|
11301
|
+
if (!plan.milestones.some((m) => m.id.toLowerCase() === finalMilestone.toLowerCase())) {
|
|
11302
|
+
throw new DeliveryPlanningWriteError(`Milestone ${finalMilestone} is not defined in ${finalPlan}.`);
|
|
11303
|
+
}
|
|
11304
|
+
}
|
|
11305
|
+
}
|
|
11306
|
+
if (patch.dependsOn !== void 0) {
|
|
11307
|
+
const deps = cleanList(patch.dependsOn);
|
|
11308
|
+
const errs = validateEpicDependencyChange(dir, epic.id, deps);
|
|
11309
|
+
if (errs.length > 0) throw new DeliveryPlanningWriteError(errs.join(" "));
|
|
11310
|
+
}
|
|
11311
|
+
if (patch.title !== void 0) {
|
|
11312
|
+
if (!patch.title.trim()) throw new DeliveryPlanningWriteError("Epic title cannot be empty.");
|
|
11313
|
+
data.title = patch.title.trim();
|
|
11314
|
+
}
|
|
11315
|
+
if (patch.outcome !== void 0) {
|
|
11316
|
+
delete data.expected_outcome;
|
|
11317
|
+
if (patch.outcome === null || patch.outcome.trim() === "") delete data.outcome;
|
|
11318
|
+
else data.outcome = patch.outcome.trim();
|
|
11319
|
+
}
|
|
11320
|
+
if (patch.plan !== void 0) {
|
|
11321
|
+
if (finalPlan) data.plan = finalPlan;
|
|
11322
|
+
else delete data.plan;
|
|
11323
|
+
}
|
|
11324
|
+
if (patch.plan !== void 0 || patch.milestone !== void 0) {
|
|
11325
|
+
if (finalMilestone) data.milestone = finalMilestone;
|
|
11326
|
+
else delete data.milestone;
|
|
11327
|
+
}
|
|
11328
|
+
if (patch.successCriteria !== void 0) setListOrDelete(data, "success_criteria", patch.successCriteria);
|
|
11329
|
+
if (patch.dependsOn !== void 0) setListOrDelete(data, "depends_on", patch.dependsOn);
|
|
11330
|
+
if (patch.relatedCapabilities !== void 0) setListOrDelete(data, "related_capabilities", patch.relatedCapabilities);
|
|
11331
|
+
if (patch.decisions !== void 0) setListOrDelete(data, "decisions", patch.decisions);
|
|
11332
|
+
const newContent = matter13.stringify(content, data);
|
|
11333
|
+
writeFile(epic.filePath, newContent);
|
|
11334
|
+
const updated = parseEpic(dir, epic.filePath, newContent);
|
|
11335
|
+
if (!updated) throw new DeliveryPlanningWriteError("Failed to parse the Epic after update.");
|
|
11336
|
+
return updated;
|
|
11337
|
+
}
|
|
11158
11338
|
|
|
11159
11339
|
// src/core/knowledge-consolidation.ts
|
|
11160
|
-
import { createHash as
|
|
11340
|
+
import { createHash as createHash3 } from "crypto";
|
|
11161
11341
|
import matter14 from "gray-matter";
|
|
11162
11342
|
var KNOWLEDGE5 = "knowledge";
|
|
11163
11343
|
var CONSOLIDATION_CATEGORIES = [
|
|
@@ -11177,7 +11357,7 @@ function relFromDir(dir, filePath) {
|
|
|
11177
11357
|
return f.startsWith(d + "/") ? f.slice(d.length + 1) : f;
|
|
11178
11358
|
}
|
|
11179
11359
|
function sha256(content) {
|
|
11180
|
-
return
|
|
11360
|
+
return createHash3("sha256").update(content, "utf-8").digest("hex");
|
|
11181
11361
|
}
|
|
11182
11362
|
var SHINGLE_SIZE = 6;
|
|
11183
11363
|
var MIN_SHARED_RUN = 6;
|
|
@@ -12435,7 +12615,9 @@ function toListItem(a) {
|
|
|
12435
12615
|
releaseStatus: a.releaseStatus || null,
|
|
12436
12616
|
affectedModules: a.affectedModules,
|
|
12437
12617
|
scopeConfidenceLevel: a.scopeConfidence?.level ?? null,
|
|
12438
|
-
initiative: a.initiative || null
|
|
12618
|
+
initiative: a.initiative || null,
|
|
12619
|
+
owners: Array.isArray(a.rawFrontmatter.owners) ? a.rawFrontmatter.owners.map(String).filter(Boolean) : [],
|
|
12620
|
+
contributors: Array.isArray(a.rawFrontmatter.contributors) ? a.rawFrontmatter.contributors.map(String).filter(Boolean) : []
|
|
12439
12621
|
};
|
|
12440
12622
|
}
|
|
12441
12623
|
function getWorkItem(dir, workItemId) {
|
|
@@ -12484,8 +12666,8 @@ function parseGraphReason(v) {
|
|
|
12484
12666
|
if (!v || typeof v !== "object") return null;
|
|
12485
12667
|
const o = v;
|
|
12486
12668
|
const relationship = typeof o.relationship === "string" && o.relationship.trim() ? o.relationship.trim() : null;
|
|
12487
|
-
const
|
|
12488
|
-
return relationship ||
|
|
12669
|
+
const path10 = Array.isArray(o.path) ? o.path.map(String).filter(Boolean) : [];
|
|
12670
|
+
return relationship || path10.length ? { relationship, path: path10 } : null;
|
|
12489
12671
|
}
|
|
12490
12672
|
function parseExplain(o) {
|
|
12491
12673
|
const refs = Array.isArray(o.evidence) ? o.evidence : Array.isArray(o.evidence_refs) ? o.evidence_refs : [];
|
|
@@ -12908,7 +13090,7 @@ var WorkItemWriteError = class extends Error {
|
|
|
12908
13090
|
var VALID_COVERAGE = /* @__PURE__ */ new Set(["affected", "reviewed-not-affected", "unknown", "not-applicable"]);
|
|
12909
13091
|
var VALID_CONFIDENCE = /* @__PURE__ */ new Set(["high", "medium", "low"]);
|
|
12910
13092
|
var EDITABLE_STATES = ["draft"];
|
|
12911
|
-
function
|
|
13093
|
+
function revisionOf2(raw) {
|
|
12912
13094
|
return crypto2.createHash("sha256").update(raw, "utf-8").digest("hex");
|
|
12913
13095
|
}
|
|
12914
13096
|
function slugify4(s) {
|
|
@@ -13084,6 +13266,8 @@ function applyFrontmatter(data, input) {
|
|
|
13084
13266
|
next.type = input.type;
|
|
13085
13267
|
next.work_type = input.type;
|
|
13086
13268
|
if (input.summary != null) next.summary = input.summary;
|
|
13269
|
+
next.owners = [...new Set((input.owners ?? []).map((v) => v.trim()).filter(Boolean))];
|
|
13270
|
+
next.contributors = [...new Set((input.contributors ?? []).map((v) => v.trim()).filter(Boolean))];
|
|
13087
13271
|
next.affected_modules = [...input.affectedModules];
|
|
13088
13272
|
if (input.scopeConfidence && VALID_CONFIDENCE.has(input.scopeConfidence.level)) {
|
|
13089
13273
|
next.scope_confidence = { level: input.scopeConfidence.level, reasons: input.scopeConfidence.reasons.filter((r) => r.trim()) };
|
|
@@ -13167,7 +13351,9 @@ function toInput(data, content) {
|
|
|
13167
13351
|
impactAnalysis: ia ? Object.entries(ia).map(([surface, v]) => ({ surface, status: String(v.status ?? ""), ...v.reason ? { reason: String(v.reason) } : {}, ...v.question ? { question: String(v.question) } : {} })) : [],
|
|
13168
13352
|
acceptanceCriteria: criteria,
|
|
13169
13353
|
decisions: Array.isArray(data.decisions) ? data.decisions.map(String) : [],
|
|
13170
|
-
relatedKnowledge: Array.isArray(data.related_knowledge) ? data.related_knowledge.map(String) : []
|
|
13354
|
+
relatedKnowledge: Array.isArray(data.related_knowledge) ? data.related_knowledge.map(String) : [],
|
|
13355
|
+
owners: Array.isArray(data.owners) ? data.owners.map(String) : [],
|
|
13356
|
+
contributors: Array.isArray(data.contributors) ? data.contributors.map(String) : []
|
|
13171
13357
|
};
|
|
13172
13358
|
}
|
|
13173
13359
|
function getWorkItemForEdit(dir, id) {
|
|
@@ -13181,7 +13367,7 @@ function getWorkItemForEdit(dir, id) {
|
|
|
13181
13367
|
...input,
|
|
13182
13368
|
id,
|
|
13183
13369
|
status,
|
|
13184
|
-
revision:
|
|
13370
|
+
revision: revisionOf2(raw),
|
|
13185
13371
|
path: relPath,
|
|
13186
13372
|
editable,
|
|
13187
13373
|
...editable ? {} : { editableReason: status === "ready" ? "This Work Item is Ready. Reopen it as Draft to edit its scope." : `This Work Item is ${status} and cannot be edited from the structured editor.` }
|
|
@@ -13253,7 +13439,7 @@ function createWorkItem(dir, opts) {
|
|
|
13253
13439
|
if (exists(filePath)) throw new WorkItemWriteError("INVALID_INPUT", `Work Item file already exists: ${relPath}`);
|
|
13254
13440
|
const raw = serialize2(data, body);
|
|
13255
13441
|
atomicWrite3(filePath, raw);
|
|
13256
|
-
return { id, path: relPath, revision:
|
|
13442
|
+
return { id, path: relPath, revision: revisionOf2(raw) };
|
|
13257
13443
|
}
|
|
13258
13444
|
function validateInput(input) {
|
|
13259
13445
|
if (!input.title.trim()) throw new WorkItemWriteError("INVALID_INPUT", "Title is required.");
|
|
@@ -13263,7 +13449,7 @@ function updateWorkItem(dir, id, input, expectedRevision) {
|
|
|
13263
13449
|
validateInput(input);
|
|
13264
13450
|
const { filePath, relPath } = findArtifact(dir, id);
|
|
13265
13451
|
const raw = readFile(filePath);
|
|
13266
|
-
if (
|
|
13452
|
+
if (revisionOf2(raw) !== expectedRevision) {
|
|
13267
13453
|
throw new WorkItemWriteError("WORK_ITEM_CONFLICT", "This Work Item changed outside Kaddo Admin. Reload the latest version before saving.");
|
|
13268
13454
|
}
|
|
13269
13455
|
const { data, content } = matter17(raw);
|
|
@@ -13275,7 +13461,25 @@ function updateWorkItem(dir, id, input, expectedRevision) {
|
|
|
13275
13461
|
const nextBody = mergeBody(content, input);
|
|
13276
13462
|
const nextRaw = serialize2(nextData, nextBody);
|
|
13277
13463
|
atomicWrite3(filePath, nextRaw);
|
|
13278
|
-
return { revision:
|
|
13464
|
+
return { revision: revisionOf2(nextRaw), path: relPath };
|
|
13465
|
+
}
|
|
13466
|
+
function updateWorkItemAssignments(dir, id, assignments, expectedRevision) {
|
|
13467
|
+
const { filePath, relPath } = findArtifact(dir, id);
|
|
13468
|
+
const raw = readFile(filePath);
|
|
13469
|
+
if (revisionOf2(raw) !== expectedRevision) {
|
|
13470
|
+
throw new WorkItemWriteError("WORK_ITEM_CONFLICT", "This Work Item changed outside Kaddo Admin. Reload the latest version before saving assignments.");
|
|
13471
|
+
}
|
|
13472
|
+
const { data, content } = matter17(raw);
|
|
13473
|
+
const status = lifecycleStateOf({ status: String(data.status ?? ""), filePath });
|
|
13474
|
+
if (!["draft", "ready", "in-progress"].includes(status)) {
|
|
13475
|
+
throw new WorkItemWriteError("WORK_ITEM_NOT_EDITABLE", `Assignments cannot be changed for a ${status} Work Item.`);
|
|
13476
|
+
}
|
|
13477
|
+
const next = { ...data };
|
|
13478
|
+
next.owners = [...new Set((assignments.owners ?? []).map((value) => value.trim()).filter(Boolean))];
|
|
13479
|
+
next.contributors = [...new Set((assignments.contributors ?? []).map((value) => value.trim()).filter(Boolean))];
|
|
13480
|
+
const nextRaw = serialize2(next, content);
|
|
13481
|
+
atomicWrite3(filePath, nextRaw);
|
|
13482
|
+
return { revision: revisionOf2(nextRaw), path: relPath, status };
|
|
13279
13483
|
}
|
|
13280
13484
|
function validateWorkItem(dir, id) {
|
|
13281
13485
|
const { filePath } = findArtifact(dir, id);
|
|
@@ -13326,11 +13530,11 @@ function validateWorkItem(dir, id) {
|
|
|
13326
13530
|
const canMarkReady = !findings.some((f) => f.level === "blocking");
|
|
13327
13531
|
return { findings, canMarkReady };
|
|
13328
13532
|
}
|
|
13329
|
-
var ALLOWED = { draft: ["ready"], ready: ["draft"] };
|
|
13533
|
+
var ALLOWED = { draft: ["ready"], ready: ["draft", "in-progress"] };
|
|
13330
13534
|
function transitionWorkItem(dir, id, to, expectedRevision) {
|
|
13331
13535
|
const { filePath } = findArtifact(dir, id);
|
|
13332
13536
|
const raw = readFile(filePath);
|
|
13333
|
-
if (
|
|
13537
|
+
if (revisionOf2(raw) !== expectedRevision) {
|
|
13334
13538
|
throw new WorkItemWriteError("WORK_ITEM_CONFLICT", "This Work Item changed outside Kaddo Admin. Reload the latest version before continuing.");
|
|
13335
13539
|
}
|
|
13336
13540
|
const { data, content } = matter17(raw);
|
|
@@ -13354,7 +13558,7 @@ function transitionWorkItem(dir, id, to, expectedRevision) {
|
|
|
13354
13558
|
} catch {
|
|
13355
13559
|
}
|
|
13356
13560
|
}
|
|
13357
|
-
return { revision:
|
|
13561
|
+
return { revision: revisionOf2(nextRaw), status: to, path: targetRel };
|
|
13358
13562
|
}
|
|
13359
13563
|
|
|
13360
13564
|
// src/core/system-map.ts
|
|
@@ -13599,16 +13803,16 @@ function findSystemPaths(dir, source2, target, opts = {}) {
|
|
|
13599
13803
|
out.get(r.source).push(r.target);
|
|
13600
13804
|
}
|
|
13601
13805
|
const paths = [];
|
|
13602
|
-
const walk2 = (node,
|
|
13806
|
+
const walk2 = (node, path10) => {
|
|
13603
13807
|
if (paths.length >= 20) return;
|
|
13604
|
-
if (node === target &&
|
|
13605
|
-
paths.push([...
|
|
13808
|
+
if (node === target && path10.length > 1) {
|
|
13809
|
+
paths.push([...path10]);
|
|
13606
13810
|
return;
|
|
13607
13811
|
}
|
|
13608
|
-
if (
|
|
13812
|
+
if (path10.length > maxDepth) return;
|
|
13609
13813
|
for (const nxt of out.get(node) ?? []) {
|
|
13610
|
-
if (
|
|
13611
|
-
walk2(nxt, [...
|
|
13814
|
+
if (path10.includes(nxt)) continue;
|
|
13815
|
+
walk2(nxt, [...path10, nxt]);
|
|
13612
13816
|
}
|
|
13613
13817
|
};
|
|
13614
13818
|
walk2(source2, [source2]);
|
|
@@ -13633,14 +13837,14 @@ function getImpactCandidates(dir, seedIds, opts = {}) {
|
|
|
13633
13837
|
existing.reason.push(reason);
|
|
13634
13838
|
continue;
|
|
13635
13839
|
}
|
|
13636
|
-
const
|
|
13840
|
+
const path10 = findSystemPaths(dir, seed, n.id, { maxDepth: opts.maxDepth ?? DEFAULT_MAX_DEPTH })[0];
|
|
13637
13841
|
candidates.set(n.id, {
|
|
13638
13842
|
nodeId: n.id,
|
|
13639
13843
|
label: n.label,
|
|
13640
13844
|
kind: n.type,
|
|
13641
13845
|
...n.moduleId ? { moduleId: n.moduleId } : {},
|
|
13642
13846
|
reason: [reason],
|
|
13643
|
-
...
|
|
13847
|
+
...path10 ? { graphPath: path10.map((id) => byId.get(id)?.label ?? id) } : {},
|
|
13644
13848
|
...n.implementationRefs?.length ? { implementationRefs: n.implementationRefs } : {},
|
|
13645
13849
|
...n.knowledgeRefs?.length ? { knowledgeRefs: n.knowledgeRefs } : {},
|
|
13646
13850
|
status: "candidate",
|
|
@@ -14333,7 +14537,12 @@ function collectImplementationEvidence(dir, workItemId, input) {
|
|
|
14333
14537
|
} : {}
|
|
14334
14538
|
};
|
|
14335
14539
|
}
|
|
14336
|
-
return {
|
|
14540
|
+
return {
|
|
14541
|
+
repositories,
|
|
14542
|
+
...input.acVerifications.length > 0 ? {
|
|
14543
|
+
ac_verifications: input.acVerifications.map((verification) => ({ ...verification }))
|
|
14544
|
+
} : {}
|
|
14545
|
+
};
|
|
14337
14546
|
}
|
|
14338
14547
|
function verifyWorkItem(dir, workItemId, input) {
|
|
14339
14548
|
const evidence = collectImplementationEvidence(dir, workItemId, input);
|
|
@@ -14393,6 +14602,9 @@ function evaluateCompletion(verification) {
|
|
|
14393
14602
|
warnings.push(`Completion exception "${ex.id}" is still proposed (not yet accepted).`);
|
|
14394
14603
|
}
|
|
14395
14604
|
}
|
|
14605
|
+
if (verification.acSummary.total === 0) {
|
|
14606
|
+
blockers.push("No acceptance criteria were detected; completion evidence is insufficient.");
|
|
14607
|
+
}
|
|
14396
14608
|
if (verification.acSummary.failed > 0) {
|
|
14397
14609
|
const failedACs = verification.acVerifications.filter((ac) => ac.status === "failed");
|
|
14398
14610
|
for (const ac of failedACs) {
|
|
@@ -14404,10 +14616,16 @@ function evaluateCompletion(verification) {
|
|
|
14404
14616
|
blockers.push(f.message);
|
|
14405
14617
|
}
|
|
14406
14618
|
if (verification.acSummary.manualReview > 0) {
|
|
14407
|
-
|
|
14619
|
+
blockers.push(`${verification.acSummary.manualReview} AC(s) require manual review.`);
|
|
14408
14620
|
}
|
|
14409
14621
|
if (verification.acSummary.notVerified > 0) {
|
|
14410
|
-
|
|
14622
|
+
blockers.push(`${verification.acSummary.notVerified} AC(s) not yet verified.`);
|
|
14623
|
+
}
|
|
14624
|
+
if (verification.implementationStatus !== "completed") {
|
|
14625
|
+
blockers.push(`Implementation status is "${verification.implementationStatus}", not "completed".`);
|
|
14626
|
+
}
|
|
14627
|
+
if (!["passed", "accepted-with-exceptions"].includes(verification.validationStatus)) {
|
|
14628
|
+
blockers.push(`Validation status is "${verification.validationStatus}", not passed.`);
|
|
14411
14629
|
}
|
|
14412
14630
|
const warningFindings = verification.findings.filter((f) => f.severity === "warning");
|
|
14413
14631
|
for (const f of warningFindings) {
|
|
@@ -14424,8 +14642,8 @@ function evaluateCompletion(verification) {
|
|
|
14424
14642
|
}
|
|
14425
14643
|
let readiness;
|
|
14426
14644
|
if (blockers.length > 0) {
|
|
14427
|
-
const
|
|
14428
|
-
if (
|
|
14645
|
+
const needsEvidence = blockers.every((b) => b.startsWith("AC failed:") || b.includes("acceptance criteria") || b.includes("AC(s)") || b.startsWith("Implementation status") || b.startsWith("Validation status"));
|
|
14646
|
+
if (needsEvidence) {
|
|
14429
14647
|
readiness = "NEEDS_WORK";
|
|
14430
14648
|
reasons.push("Acceptance criteria have failures that must be addressed.");
|
|
14431
14649
|
} else {
|
|
@@ -14506,6 +14724,152 @@ function deriveImplementationStatus(repos) {
|
|
|
14506
14724
|
return "in-progress";
|
|
14507
14725
|
}
|
|
14508
14726
|
|
|
14727
|
+
// src/services/git.ts
|
|
14728
|
+
import { execa } from "execa";
|
|
14729
|
+
import path5 from "path";
|
|
14730
|
+
async function getGitRoot(dir) {
|
|
14731
|
+
try {
|
|
14732
|
+
const result = await execa("git", ["rev-parse", "--show-toplevel"], { cwd: dir });
|
|
14733
|
+
return result.stdout.trim() || null;
|
|
14734
|
+
} catch {
|
|
14735
|
+
return null;
|
|
14736
|
+
}
|
|
14737
|
+
}
|
|
14738
|
+
async function observeGit(dir, maxCommits = 100, repositoryId) {
|
|
14739
|
+
const limit = Math.max(1, Math.min(maxCommits, 250));
|
|
14740
|
+
const inspectedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
14741
|
+
try {
|
|
14742
|
+
const root = await getGitRoot(dir);
|
|
14743
|
+
if (!root) return { availability: "unavailable", repository: null, commits: [], branches: [], inspectedAt, limit };
|
|
14744
|
+
const [log2, refs] = await Promise.all([
|
|
14745
|
+
execa("git", ["log", `--max-count=${limit}`, "--format=%H%x1f%an%x1f%aI%x1f%s", "--name-only"], { cwd: root, timeout: 5e3 }),
|
|
14746
|
+
execa("git", ["for-each-ref", "--format=%(refname:short)", "refs/heads"], { cwd: root, timeout: 5e3 })
|
|
14747
|
+
]);
|
|
14748
|
+
const commits = [];
|
|
14749
|
+
let current = null;
|
|
14750
|
+
for (const line of log2.stdout.split(/\r?\n/)) {
|
|
14751
|
+
const parts = line.split("");
|
|
14752
|
+
if (parts.length === 4) {
|
|
14753
|
+
if (current) commits.push(current);
|
|
14754
|
+
current = { sha: parts[0], author: parts[1], date: parts[2], subject: parts[3], files: [] };
|
|
14755
|
+
} else if (current && line.trim()) current.files.push(line.trim());
|
|
14756
|
+
}
|
|
14757
|
+
if (current) commits.push(current);
|
|
14758
|
+
return {
|
|
14759
|
+
// The display identity is supplied by the caller when a project observes
|
|
14760
|
+
// several repositories. A basename alone is ambiguous in a multirepo
|
|
14761
|
+
// workspace (for example, two independent `api` folders).
|
|
14762
|
+
availability: "available",
|
|
14763
|
+
repository: repositoryId ?? path5.basename(root),
|
|
14764
|
+
commits,
|
|
14765
|
+
branches: refs.stdout.split(/\r?\n/).map((name) => name.trim()).filter(Boolean).slice(0, 100).map((name) => ({ name })),
|
|
14766
|
+
inspectedAt,
|
|
14767
|
+
limit
|
|
14768
|
+
};
|
|
14769
|
+
} catch {
|
|
14770
|
+
return { availability: "partial", repository: null, commits: [], branches: [], inspectedAt, limit };
|
|
14771
|
+
}
|
|
14772
|
+
}
|
|
14773
|
+
|
|
14774
|
+
// src/core/collaboration.ts
|
|
14775
|
+
import path6 from "path";
|
|
14776
|
+
function matchesWorkItemReference(value, id) {
|
|
14777
|
+
return new RegExp(`(^|[^A-Za-z0-9_-])${id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?=$|[^A-Za-z0-9_-])`, "i").test(value);
|
|
14778
|
+
}
|
|
14779
|
+
async function observationsForProject(dir) {
|
|
14780
|
+
const corePath = path6.resolve(dir);
|
|
14781
|
+
const mapped = loadMappedModules(dir).filter((module) => Boolean(module.repoPath)).map((module) => ({ path: path6.resolve(corePath, module.repoPath), repositoryId: `module:${module.id}` }));
|
|
14782
|
+
const candidates = [{ path: corePath, repositoryId: "core" }, ...mapped];
|
|
14783
|
+
const resolved = await Promise.all(candidates.map(async (candidate) => ({ ...candidate, root: await getGitRoot(candidate.path) })));
|
|
14784
|
+
const repositories = /* @__PURE__ */ new Map();
|
|
14785
|
+
for (const item of resolved) if (item.root && !repositories.has(item.root)) repositories.set(item.root, { root: item.root, repositoryId: item.repositoryId });
|
|
14786
|
+
const observations = await Promise.all([...repositories.values()].map((repo) => observeGit(repo.root, 100, repo.repositoryId)));
|
|
14787
|
+
return observations;
|
|
14788
|
+
}
|
|
14789
|
+
async function collaborationForWorkItems(dir, ids) {
|
|
14790
|
+
const observations = await observationsForProject(dir);
|
|
14791
|
+
return ids.map((id) => {
|
|
14792
|
+
const wi = getWorkItem(dir, id);
|
|
14793
|
+
const linkedCommits = [];
|
|
14794
|
+
const relatedBranches = [];
|
|
14795
|
+
for (const observation of observations) {
|
|
14796
|
+
const repository = observation.repository ?? "local";
|
|
14797
|
+
for (const commit of observation.commits) {
|
|
14798
|
+
if (!matchesWorkItemReference(commit.subject, wi.id)) continue;
|
|
14799
|
+
linkedCommits.push({ repository, sha: commit.sha, author: commit.author, date: commit.date, subject: commit.subject, paths: commit.files.slice(0, 50), attribution: "explicit-reference", evidence: `Exact reference ${wi.id} in commit subject.` });
|
|
14800
|
+
}
|
|
14801
|
+
for (const branch of observation.branches) {
|
|
14802
|
+
if (!matchesWorkItemReference(branch.name, wi.id)) continue;
|
|
14803
|
+
relatedBranches.push({ repository, name: branch.name, attribution: "branch-associated", evidence: `Exact reference ${wi.id} in local branch name.` });
|
|
14804
|
+
}
|
|
14805
|
+
}
|
|
14806
|
+
const inspectedCommits = observations.reduce((total, observation) => total + observation.commits.length, 0);
|
|
14807
|
+
const available = observations.filter((observation) => observation.availability === "available").length;
|
|
14808
|
+
const availability = available === observations.length ? "available" : available > 0 ? "partial" : observations.some((observation) => observation.availability === "partial") ? "partial" : "unavailable";
|
|
14809
|
+
return {
|
|
14810
|
+
workItemId: wi.id,
|
|
14811
|
+
responsibility: { owners: wi.owners, contributors: wi.contributors },
|
|
14812
|
+
git: {
|
|
14813
|
+
availability,
|
|
14814
|
+
repositories: observations.flatMap((observation) => observation.repository ? [observation.repository] : []),
|
|
14815
|
+
observedAuthors: [...new Set(linkedCommits.map((commit) => commit.author))],
|
|
14816
|
+
linkedCommits,
|
|
14817
|
+
relatedBranches,
|
|
14818
|
+
unattributedActivityCount: Math.max(0, inspectedCommits - linkedCommits.length),
|
|
14819
|
+
inspectedAt: observations.map((observation) => observation.inspectedAt).sort().at(-1) ?? null,
|
|
14820
|
+
coverage: { maxCommits: observations[0]?.limit ?? 100, inspectedCommits, note: "Only the core repository and explicitly mapped module repositories were inspected with read-only Git metadata. File overlap never creates attribution." }
|
|
14821
|
+
}
|
|
14822
|
+
};
|
|
14823
|
+
});
|
|
14824
|
+
}
|
|
14825
|
+
async function getWorkItemsCollaboration(dir, ids) {
|
|
14826
|
+
return collaborationForWorkItems(dir, [...new Set(ids)]);
|
|
14827
|
+
}
|
|
14828
|
+
async function getWorkItemCollaboration(dir, id) {
|
|
14829
|
+
return (await collaborationForWorkItems(dir, [id]))[0];
|
|
14830
|
+
}
|
|
14831
|
+
function aggregate(id, responsibility, items) {
|
|
14832
|
+
const commits = /* @__PURE__ */ new Map();
|
|
14833
|
+
for (const item of items) for (const commit of item.git.linkedCommits) {
|
|
14834
|
+
const key = `${commit.repository}:${commit.sha}`;
|
|
14835
|
+
const existing = commits.get(key);
|
|
14836
|
+
if (existing) existing.workItemIds = [.../* @__PURE__ */ new Set([...existing.workItemIds, item.workItemId])];
|
|
14837
|
+
else commits.set(key, { ...commit, workItemIds: [item.workItemId] });
|
|
14838
|
+
}
|
|
14839
|
+
const first2 = items[0];
|
|
14840
|
+
return {
|
|
14841
|
+
id,
|
|
14842
|
+
responsibility,
|
|
14843
|
+
workItems: items.map((item) => ({ id: item.workItemId, owners: item.responsibility.owners, contributors: item.responsibility.contributors, linkedCommitCount: item.git.linkedCommits.length })),
|
|
14844
|
+
observedAuthors: [...new Set([...commits.values()].map((commit) => commit.author))],
|
|
14845
|
+
linkedCommits: [...commits.values()],
|
|
14846
|
+
unassignedWorkItemIds: items.filter((item) => item.responsibility.owners.length === 0).map((item) => item.workItemId),
|
|
14847
|
+
git: first2?.git ?? { availability: "unavailable", repositories: [], observedAuthors: [], linkedCommits: [], relatedBranches: [], unattributedActivityCount: 0, inspectedAt: null, coverage: { maxCommits: 100, inspectedCommits: 0, note: "No associated Work Items." } }
|
|
14848
|
+
};
|
|
14849
|
+
}
|
|
14850
|
+
async function getInitiativeCollaboration(dir, id) {
|
|
14851
|
+
const initiative = getInitiative(dir, id);
|
|
14852
|
+
if (!initiative) throw new WorkItemNotFoundError(`Initiative ${id} was not found.`);
|
|
14853
|
+
const items = await collaborationForWorkItems(dir, associatedWorkItems(dir, id).map((item) => item.id));
|
|
14854
|
+
return aggregate(id, { owners: initiative.owners, contributors: initiative.contributors }, items);
|
|
14855
|
+
}
|
|
14856
|
+
async function getEpicCollaboration(dir, id) {
|
|
14857
|
+
const epic = getEpic(dir, id);
|
|
14858
|
+
if (!epic) throw new WorkItemNotFoundError(`Epic ${id} was not found.`);
|
|
14859
|
+
const items = await collaborationForWorkItems(dir, workItemsInEpic(dir, id).map((item) => item.id));
|
|
14860
|
+
const initiatives = initiativesInEpic(dir, id);
|
|
14861
|
+
return aggregate(id, { owners: [...new Set(initiatives.flatMap((item) => item.owners))], contributors: [...new Set(initiatives.flatMap((item) => item.contributors))] }, items);
|
|
14862
|
+
}
|
|
14863
|
+
async function getPlanCollaboration(dir, id) {
|
|
14864
|
+
const plan = getPlan(dir, id);
|
|
14865
|
+
if (!plan) throw new WorkItemNotFoundError(`Plan ${id} was not found.`);
|
|
14866
|
+
const epicIds = epicsInPlan(dir, id).map((epic) => epic.id);
|
|
14867
|
+
const workItemIds = [...new Set(epicIds.flatMap((epicId) => workItemsInEpic(dir, epicId).map((item) => item.id)))];
|
|
14868
|
+
const items = await collaborationForWorkItems(dir, workItemIds);
|
|
14869
|
+
const initiatives = epicIds.flatMap((epicId) => initiativesInEpic(dir, epicId));
|
|
14870
|
+
return aggregate(id, { owners: [...new Set(initiatives.flatMap((item) => item.owners))], contributors: [...new Set(initiatives.flatMap((item) => item.contributors))] }, items);
|
|
14871
|
+
}
|
|
14872
|
+
|
|
14509
14873
|
// src/core/work-item-import.ts
|
|
14510
14874
|
import crypto3 from "crypto";
|
|
14511
14875
|
import fs5 from "fs";
|
|
@@ -15528,8 +15892,8 @@ async function handleJiraResponse(res) {
|
|
|
15528
15892
|
}
|
|
15529
15893
|
return await res.json();
|
|
15530
15894
|
}
|
|
15531
|
-
async function jiraFetch(baseUrl,
|
|
15532
|
-
const url = new URL(
|
|
15895
|
+
async function jiraFetch(baseUrl, path10, auth, timeoutMs, params) {
|
|
15896
|
+
const url = new URL(path10, baseUrl + "/");
|
|
15533
15897
|
if (params) for (const [k, v] of Object.entries(params)) url.searchParams.set(k, v);
|
|
15534
15898
|
const controller = new AbortController();
|
|
15535
15899
|
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
@@ -15547,8 +15911,8 @@ async function jiraFetch(baseUrl, path8, auth, timeoutMs, params) {
|
|
|
15547
15911
|
clearTimeout(timer);
|
|
15548
15912
|
}
|
|
15549
15913
|
}
|
|
15550
|
-
async function jiraPost(baseUrl,
|
|
15551
|
-
const url = new URL(
|
|
15914
|
+
async function jiraPost(baseUrl, path10, auth, timeoutMs, body) {
|
|
15915
|
+
const url = new URL(path10, baseUrl + "/");
|
|
15552
15916
|
const controller = new AbortController();
|
|
15553
15917
|
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
15554
15918
|
try {
|
|
@@ -16400,7 +16764,7 @@ function evaluateInitiativeCompletion(dir, ini) {
|
|
|
16400
16764
|
|
|
16401
16765
|
// src/core/deprecation-write.ts
|
|
16402
16766
|
import fs6 from "fs";
|
|
16403
|
-
import
|
|
16767
|
+
import path7 from "path";
|
|
16404
16768
|
import matter20 from "gray-matter";
|
|
16405
16769
|
var DeprecationWriteError = class extends Error {
|
|
16406
16770
|
constructor(code, message) {
|
|
@@ -16516,7 +16880,7 @@ ${(input.purpose ?? "").trim() || "TODO: describe what this plan retires and why
|
|
|
16516
16880
|
const relPath = `${DEPRECATION_PLANS_DIR}/${id}-${slug4(title) || "plan"}.md`;
|
|
16517
16881
|
const filePath = join(dir, relPath);
|
|
16518
16882
|
if (exists(filePath)) throw new DeprecationWriteError("DUPLICATE", `Plan file already exists: ${relPath}`);
|
|
16519
|
-
ensureDir(
|
|
16883
|
+
ensureDir(path7.dirname(filePath));
|
|
16520
16884
|
atomicWrite4(filePath, serialize3(data, body));
|
|
16521
16885
|
return { id, path: relPath, findings: [] };
|
|
16522
16886
|
}
|
|
@@ -16535,7 +16899,7 @@ function addTarget(dir, planId, input) {
|
|
|
16535
16899
|
}
|
|
16536
16900
|
data.targets = [...targets, raw];
|
|
16537
16901
|
atomicWrite4(filePath, serialize3(data, body));
|
|
16538
|
-
return { planId, targetId, path: `${DEPRECATION_PLANS_DIR}/${
|
|
16902
|
+
return { planId, targetId, path: `${DEPRECATION_PLANS_DIR}/${path7.basename(filePath)}`, findings };
|
|
16539
16903
|
}
|
|
16540
16904
|
function updateTarget(dir, planId, targetId, patch) {
|
|
16541
16905
|
const { filePath, data, body } = loadPlanRaw(dir, planId);
|
|
@@ -16551,7 +16915,7 @@ function updateTarget(dir, planId, targetId, patch) {
|
|
|
16551
16915
|
next[idx] = merged;
|
|
16552
16916
|
data.targets = next;
|
|
16553
16917
|
atomicWrite4(filePath, serialize3(data, body));
|
|
16554
|
-
return { planId, targetId: String(targets[idx].id), path: `${DEPRECATION_PLANS_DIR}/${
|
|
16918
|
+
return { planId, targetId: String(targets[idx].id), path: `${DEPRECATION_PLANS_DIR}/${path7.basename(filePath)}`, findings };
|
|
16555
16919
|
}
|
|
16556
16920
|
function removeTarget(dir, planId, targetId, opts = {}) {
|
|
16557
16921
|
const { filePath, data, body } = loadPlanRaw(dir, planId);
|
|
@@ -16564,7 +16928,7 @@ function removeTarget(dir, planId, targetId, opts = {}) {
|
|
|
16564
16928
|
}
|
|
16565
16929
|
data.targets = targets.filter((t) => String(t.id ?? "").toUpperCase() !== targetId.toUpperCase());
|
|
16566
16930
|
atomicWrite4(filePath, serialize3(data, body));
|
|
16567
|
-
return { removed: true, path: `${DEPRECATION_PLANS_DIR}/${
|
|
16931
|
+
return { removed: true, path: `${DEPRECATION_PLANS_DIR}/${path7.basename(filePath)}` };
|
|
16568
16932
|
}
|
|
16569
16933
|
|
|
16570
16934
|
// src/core/deprecation-runbook.ts
|
|
@@ -16647,7 +17011,7 @@ function buildProductionRunbookContext(dir, planId, targetId) {
|
|
|
16647
17011
|
blockers.push(`Dependency ${dependency.id} is not retired (current: ${dependency.lifecycle}).`);
|
|
16648
17012
|
}
|
|
16649
17013
|
}
|
|
16650
|
-
const
|
|
17014
|
+
const path10 = runbookPath(dir, target);
|
|
16651
17015
|
return {
|
|
16652
17016
|
eligible: blockers.length === 0,
|
|
16653
17017
|
plan: { id: plan.id, title: plan.title, purpose: plan.purpose },
|
|
@@ -16655,7 +17019,7 @@ function buildProductionRunbookContext(dir, planId, targetId) {
|
|
|
16655
17019
|
resource: target.resource ? getResource(dir, target.resource) : null,
|
|
16656
17020
|
dependencies,
|
|
16657
17021
|
blockers,
|
|
16658
|
-
nextPath:
|
|
17022
|
+
nextPath: path10,
|
|
16659
17023
|
nextStep: blockers.length > 0 ? "Resolve the listed safeguards; no production proposal can be persisted yet." : "Review the generated proposal, obtain human approval, execute manually, then record evidence and validate the observation window."
|
|
16660
17024
|
};
|
|
16661
17025
|
}
|
|
@@ -16748,8 +17112,8 @@ function renderRunbook(context) {
|
|
|
16748
17112
|
function createProductionRunbook(dir, planId, targetId) {
|
|
16749
17113
|
const context = buildProductionRunbookContext(dir, planId, targetId);
|
|
16750
17114
|
if (!context.eligible) throw new ProductionRunbookError(context.blockers.join(" "));
|
|
16751
|
-
const
|
|
16752
|
-
const id =
|
|
17115
|
+
const path10 = context.nextPath;
|
|
17116
|
+
const id = path10.split("/").pop()?.match(/^(RB-\d+)-/)?.[1] ?? "";
|
|
16753
17117
|
const content = matter21.stringify(renderRunbook(context), {
|
|
16754
17118
|
id,
|
|
16755
17119
|
type: PRODUCTION_RUNBOOK_ARTIFACT_TYPE,
|
|
@@ -16759,13 +17123,13 @@ function createProductionRunbook(dir, planId, targetId) {
|
|
|
16759
17123
|
resource: context.target.resource,
|
|
16760
17124
|
approval: { required: true, status: "pending", approved_by: null, approved_at: null }
|
|
16761
17125
|
});
|
|
16762
|
-
const absolute = join(dir,
|
|
16763
|
-
if (exists(absolute)) throw new ProductionRunbookError(`Runbook already exists: ${
|
|
17126
|
+
const absolute = join(dir, path10);
|
|
17127
|
+
if (exists(absolute)) throw new ProductionRunbookError(`Runbook already exists: ${path10}`);
|
|
16764
17128
|
writeFile(absolute, content);
|
|
16765
17129
|
return {
|
|
16766
17130
|
id,
|
|
16767
17131
|
title: `Production runbook \u2014 ${context.target.title ?? context.target.id}`,
|
|
16768
|
-
path:
|
|
17132
|
+
path: path10,
|
|
16769
17133
|
planId: context.plan.id,
|
|
16770
17134
|
targetId: context.target.id,
|
|
16771
17135
|
approval: { required: true, status: "pending", approvedBy: null, approvedAt: null },
|
|
@@ -16776,14 +17140,14 @@ function getProductionRunbook(dir, id) {
|
|
|
16776
17140
|
const root = join(dir, PRODUCTION_RUNBOOKS_DIR);
|
|
16777
17141
|
for (const name of readDir(root)) {
|
|
16778
17142
|
if (!name.toLowerCase().startsWith(`${id.toLowerCase()}-`) || !name.endsWith(".md")) continue;
|
|
16779
|
-
const
|
|
16780
|
-
const parsed = matter21(readFile(join(dir,
|
|
17143
|
+
const path10 = `${PRODUCTION_RUNBOOKS_DIR}/${name}`;
|
|
17144
|
+
const parsed = matter21(readFile(join(dir, path10)));
|
|
16781
17145
|
const data = parsed.data;
|
|
16782
17146
|
if (data.type !== PRODUCTION_RUNBOOK_ARTIFACT_TYPE) continue;
|
|
16783
17147
|
return {
|
|
16784
17148
|
id: stringValue(data.id) ?? id,
|
|
16785
17149
|
title: stringValue(data.title) ?? id,
|
|
16786
|
-
path:
|
|
17150
|
+
path: path10,
|
|
16787
17151
|
planId: stringValue(data.deprecation_plan) ?? "",
|
|
16788
17152
|
targetId: stringValue(data.deprecation_target) ?? "",
|
|
16789
17153
|
approval: parseApproval(data.approval),
|
|
@@ -16808,7 +17172,7 @@ function validateProductionRunbook(runbook) {
|
|
|
16808
17172
|
|
|
16809
17173
|
// src/core/okf/export.ts
|
|
16810
17174
|
import fs7 from "fs";
|
|
16811
|
-
import
|
|
17175
|
+
import path8 from "path";
|
|
16812
17176
|
|
|
16813
17177
|
// src/core/okf/mapping.ts
|
|
16814
17178
|
import matter22 from "gray-matter";
|
|
@@ -17051,16 +17415,16 @@ function frontmatter(data) {
|
|
|
17051
17415
|
return lines.join("\n");
|
|
17052
17416
|
}
|
|
17053
17417
|
function relLink(fromPath, toPath) {
|
|
17054
|
-
const rel =
|
|
17418
|
+
const rel = path8.posix.relative(path8.posix.dirname(fromPath), toPath);
|
|
17055
17419
|
return rel.startsWith(".") ? rel : `./${rel}`;
|
|
17056
17420
|
}
|
|
17057
17421
|
function rewriteBodyLinks(body, sourcePath, srcToBundle, selfBundlePath) {
|
|
17058
|
-
const srcDir =
|
|
17422
|
+
const srcDir = path8.posix.dirname(sourcePath);
|
|
17059
17423
|
return body.replace(/\]\(([^)]+)\)/g, (whole, href) => {
|
|
17060
17424
|
const raw = href.trim();
|
|
17061
17425
|
const bare = raw.split("#")[0].split(" ")[0];
|
|
17062
17426
|
if (!bare || /^(https?:|mailto:|#)/.test(bare)) return whole;
|
|
17063
|
-
const candidate = bare.startsWith("/") ? bare.replace(/^\/+/, "") :
|
|
17427
|
+
const candidate = bare.startsWith("/") ? bare.replace(/^\/+/, "") : path8.posix.normalize(path8.posix.join(srcDir, bare));
|
|
17064
17428
|
const target = srcToBundle.get(candidate);
|
|
17065
17429
|
if (!target) return whole;
|
|
17066
17430
|
const anchor = raw.includes("#") ? "#" + raw.split("#").slice(1).join("#") : "";
|
|
@@ -17137,22 +17501,22 @@ function sensitiveLabels(content) {
|
|
|
17137
17501
|
return [...new Set(SENSITIVE_PATTERNS.filter((p) => p.re.test(content)).map((p) => p.label))];
|
|
17138
17502
|
}
|
|
17139
17503
|
function assertSafeDestination(dir, outputDir) {
|
|
17140
|
-
const root =
|
|
17141
|
-
const out =
|
|
17504
|
+
const root = path8.resolve(dir);
|
|
17505
|
+
const out = path8.resolve(outputDir);
|
|
17142
17506
|
const within = (child, parent) => {
|
|
17143
|
-
const rel =
|
|
17144
|
-
return rel === "" || !rel.startsWith("..") && !
|
|
17507
|
+
const rel = path8.relative(parent, child);
|
|
17508
|
+
return rel === "" || !rel.startsWith("..") && !path8.isAbsolute(rel);
|
|
17145
17509
|
};
|
|
17146
17510
|
if (out === root) throw new OkfExportError("UNSAFE_DESTINATION", "Refusing to export onto the project root.");
|
|
17147
17511
|
if (within(root, out)) throw new OkfExportError("UNSAFE_DESTINATION", "Refusing to export onto a parent of the project.");
|
|
17148
17512
|
for (const protectedDir of ["knowledge", "packages", "apps", "src", "node_modules", ".git"]) {
|
|
17149
|
-
const p =
|
|
17513
|
+
const p = path8.join(root, protectedDir);
|
|
17150
17514
|
if (out === p || within(out, p)) throw new OkfExportError("UNSAFE_DESTINATION", `Refusing to export into a protected directory: ${protectedDir}/`);
|
|
17151
17515
|
}
|
|
17152
17516
|
if (fs7.existsSync(out)) {
|
|
17153
17517
|
try {
|
|
17154
17518
|
const entries = fs7.readdirSync(out);
|
|
17155
|
-
const looksOkf = entries.includes("index.md") && /okf_version/.test(fs7.readFileSync(
|
|
17519
|
+
const looksOkf = entries.includes("index.md") && /okf_version/.test(fs7.readFileSync(path8.join(out, "index.md"), "utf-8"));
|
|
17156
17520
|
if (entries.length > 0 && !looksOkf) {
|
|
17157
17521
|
throw new OkfExportError("UNSAFE_DESTINATION", `Destination is not empty and is not an OKF bundle: ${outputDir}. Use an empty or dedicated directory.`);
|
|
17158
17522
|
}
|
|
@@ -17177,7 +17541,7 @@ function detectCollisions(concepts) {
|
|
|
17177
17541
|
}
|
|
17178
17542
|
function exportOkf(dir, opts = {}) {
|
|
17179
17543
|
const outRel = opts.output ?? OKF_DEFAULT_OUTPUT;
|
|
17180
|
-
const outputDir =
|
|
17544
|
+
const outputDir = path8.isAbsolute(outRel) ? outRel : path8.join(dir, outRel);
|
|
17181
17545
|
assertSafeDestination(dir, outputDir);
|
|
17182
17546
|
const extraWarnings = [];
|
|
17183
17547
|
const artifacts = discoverKnowledge(dir);
|
|
@@ -17233,7 +17597,7 @@ ${c.body ?? ""}`;
|
|
|
17233
17597
|
const dirs = /* @__PURE__ */ new Map();
|
|
17234
17598
|
const childDirs = /* @__PURE__ */ new Map();
|
|
17235
17599
|
for (const c of concepts) {
|
|
17236
|
-
const d =
|
|
17600
|
+
const d = path8.posix.dirname(c.path);
|
|
17237
17601
|
(dirs.get(d) ?? dirs.set(d, []).get(d)).push(c);
|
|
17238
17602
|
const segs = d === "." ? [] : d.split("/");
|
|
17239
17603
|
for (let i = 0; i < segs.length; i++) {
|
|
@@ -17259,8 +17623,8 @@ ${c.body ?? ""}`;
|
|
|
17259
17623
|
try {
|
|
17260
17624
|
fs7.rmSync(staging, { recursive: true, force: true });
|
|
17261
17625
|
for (const [rel, content] of files) {
|
|
17262
|
-
const full =
|
|
17263
|
-
fs7.mkdirSync(
|
|
17626
|
+
const full = path8.join(staging, rel);
|
|
17627
|
+
fs7.mkdirSync(path8.dirname(full), { recursive: true });
|
|
17264
17628
|
fs7.writeFileSync(full, content, "utf-8");
|
|
17265
17629
|
}
|
|
17266
17630
|
const backup = `${outputDir}.old-${process.pid}-${Date.now()}`;
|
|
@@ -17289,13 +17653,13 @@ ${c.body ?? ""}`;
|
|
|
17289
17653
|
|
|
17290
17654
|
// src/core/okf/validate.ts
|
|
17291
17655
|
import fs8 from "fs";
|
|
17292
|
-
import
|
|
17656
|
+
import path9 from "path";
|
|
17293
17657
|
import matter23 from "gray-matter";
|
|
17294
17658
|
function walk(root) {
|
|
17295
17659
|
const out = [];
|
|
17296
17660
|
const rec = (d) => {
|
|
17297
17661
|
for (const entry of fs8.readdirSync(d)) {
|
|
17298
|
-
const full =
|
|
17662
|
+
const full = path9.join(d, entry);
|
|
17299
17663
|
const st = fs8.statSync(full);
|
|
17300
17664
|
if (st.isDirectory()) rec(full);
|
|
17301
17665
|
else if (entry.endsWith(".md")) out.push(full);
|
|
@@ -17317,24 +17681,24 @@ function internalLinks(body) {
|
|
|
17317
17681
|
}
|
|
17318
17682
|
function validateOkf(dir, opts = {}) {
|
|
17319
17683
|
const loc = opts.location ?? OKF_DEFAULT_OUTPUT;
|
|
17320
|
-
const bundleDir =
|
|
17684
|
+
const bundleDir = path9.isAbsolute(loc) ? loc : path9.join(dir, loc);
|
|
17321
17685
|
const findings = [];
|
|
17322
17686
|
if (!fs8.existsSync(bundleDir)) {
|
|
17323
17687
|
findings.push({ level: "conformance", message: `OKF bundle directory not found: ${loc}. Run \`kaddo okf export\` first.` });
|
|
17324
17688
|
return { dir: bundleDir, conformant: false, conceptCount: 0, findings, counts: { conformance: 1, warning: 0, info: 0 } };
|
|
17325
17689
|
}
|
|
17326
17690
|
const files = walk(bundleDir);
|
|
17327
|
-
const rel = (f) =>
|
|
17691
|
+
const rel = (f) => path9.relative(bundleDir, f).split(path9.sep).join("/");
|
|
17328
17692
|
const present = new Set(files.map(rel));
|
|
17329
17693
|
const idToFile = /* @__PURE__ */ new Map();
|
|
17330
17694
|
let conceptCount = 0;
|
|
17331
|
-
const rootIndex =
|
|
17695
|
+
const rootIndex = path9.join(bundleDir, "index.md");
|
|
17332
17696
|
if (!fs8.existsSync(rootIndex)) {
|
|
17333
17697
|
findings.push({ level: "warning", message: "No root index.md \u2014 the bundle has no top-level navigation entry." });
|
|
17334
17698
|
}
|
|
17335
17699
|
for (const file of files) {
|
|
17336
17700
|
const r = rel(file);
|
|
17337
|
-
const isIndex =
|
|
17701
|
+
const isIndex = path9.basename(file) === "index.md";
|
|
17338
17702
|
let data = {};
|
|
17339
17703
|
try {
|
|
17340
17704
|
data = matter23(fs8.readFileSync(file, "utf-8")).data ?? {};
|
|
@@ -17365,7 +17729,7 @@ function validateOkf(dir, opts = {}) {
|
|
|
17365
17729
|
}
|
|
17366
17730
|
})();
|
|
17367
17731
|
for (const href of internalLinks(body)) {
|
|
17368
|
-
const resolved =
|
|
17732
|
+
const resolved = path9.posix.normalize(path9.posix.join(path9.posix.dirname(r), href));
|
|
17369
17733
|
if (!present.has(resolved)) findings.push({ level: "info", file: r, message: `Internal link not resolvable yet: ${href}` });
|
|
17370
17734
|
}
|
|
17371
17735
|
}
|
|
@@ -17413,6 +17777,7 @@ export {
|
|
|
17413
17777
|
POC_REPORT_PREFIX,
|
|
17414
17778
|
PRODUCTION_RUNBOOKS_DIR,
|
|
17415
17779
|
PRODUCTION_RUNBOOK_ARTIFACT_TYPE,
|
|
17780
|
+
PlanningConflictError,
|
|
17416
17781
|
ProductionRunbookError,
|
|
17417
17782
|
REDACTED_COORDINATE,
|
|
17418
17783
|
RESOURCE_ARTIFACT_TYPE,
|
|
@@ -17477,6 +17842,7 @@ export {
|
|
|
17477
17842
|
deriveUnusedConfidence,
|
|
17478
17843
|
detectFormat,
|
|
17479
17844
|
disableIntegration,
|
|
17845
|
+
disassociateInitiativeFromEpic,
|
|
17480
17846
|
discoverDeliveryPlans,
|
|
17481
17847
|
discoverEpics,
|
|
17482
17848
|
discoverExternalWorkItems,
|
|
@@ -17500,14 +17866,17 @@ export {
|
|
|
17500
17866
|
getDeprecationPlan,
|
|
17501
17867
|
getDeprecationPlans,
|
|
17502
17868
|
getEpic,
|
|
17869
|
+
getEpicCollaboration,
|
|
17503
17870
|
getExternalWorkItem,
|
|
17504
17871
|
getImpactCandidates,
|
|
17505
17872
|
getInitiative,
|
|
17873
|
+
getInitiativeCollaboration,
|
|
17506
17874
|
getInitiativeContext,
|
|
17507
17875
|
getIntegration,
|
|
17508
17876
|
getIntegrationFilters,
|
|
17509
17877
|
getIntegrationSecretStatus,
|
|
17510
17878
|
getPlan,
|
|
17879
|
+
getPlanCollaboration,
|
|
17511
17880
|
getProductionRunbook,
|
|
17512
17881
|
getResource,
|
|
17513
17882
|
getResourceReferences,
|
|
@@ -17518,8 +17887,10 @@ export {
|
|
|
17518
17887
|
getStatus as getTelemetryStatus,
|
|
17519
17888
|
getWorkItem,
|
|
17520
17889
|
getWorkItemCaptureDefinition,
|
|
17890
|
+
getWorkItemCollaboration,
|
|
17521
17891
|
getWorkItemForEdit,
|
|
17522
17892
|
getWorkItems,
|
|
17893
|
+
getWorkItemsCollaboration,
|
|
17523
17894
|
getWorkItemsSummary,
|
|
17524
17895
|
importExternalWorkItem,
|
|
17525
17896
|
importWorkItem,
|
|
@@ -17585,6 +17956,7 @@ export {
|
|
|
17585
17956
|
renderDriftMarkdown,
|
|
17586
17957
|
renderImpactMarkdown,
|
|
17587
17958
|
renderSavingsMarkdown,
|
|
17959
|
+
revisionOf,
|
|
17588
17960
|
searchSystemNodes,
|
|
17589
17961
|
serializeConsolidationJson,
|
|
17590
17962
|
serializeDriftJson,
|
|
@@ -17598,13 +17970,17 @@ export {
|
|
|
17598
17970
|
topologyRevision,
|
|
17599
17971
|
transitionInitiative,
|
|
17600
17972
|
transitionWorkItem,
|
|
17973
|
+
updateDeliveryPlan,
|
|
17974
|
+
updateEpic,
|
|
17601
17975
|
updateInitiative,
|
|
17602
17976
|
updateIntegration,
|
|
17603
17977
|
updateIntegrationFilters,
|
|
17604
17978
|
updateResource,
|
|
17605
17979
|
updateTarget,
|
|
17606
17980
|
updateWorkItem,
|
|
17981
|
+
updateWorkItemAssignments,
|
|
17607
17982
|
validateConfigAgainstSchema,
|
|
17983
|
+
validateEpicDependencyChange,
|
|
17608
17984
|
validateOkf,
|
|
17609
17985
|
validatePlan,
|
|
17610
17986
|
validatePlanningGraph,
|