@kaddo/cli 3.133.0 → 3.135.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-DR1_1O3v.js → architectureDiagram-3BPJPVTR-DkdJ073y.js} +1 -1
- package/dist/admin-dist/assets/{chunk-727SXJPM-COmzRt04.js → chunk-727SXJPM-DRof4aGT.js} +1 -1
- package/dist/admin-dist/assets/{chunk-AQP2D5EJ-CXMsTGWW.js → chunk-AQP2D5EJ-BOVZoYng.js} +1 -1
- package/dist/admin-dist/assets/{classDiagram-v2-Q7XG4LA2-D2dQFgos.js → classDiagram-4FO5ZUOK-cL_umCGu.js} +1 -1
- package/dist/admin-dist/assets/{classDiagram-4FO5ZUOK-D2dQFgos.js → classDiagram-v2-Q7XG4LA2-cL_umCGu.js} +1 -1
- package/dist/admin-dist/assets/{dagre-BM42HDAG-BMRsOxw1.js → dagre-BM42HDAG-Cvga2Wk-.js} +1 -1
- package/dist/admin-dist/assets/{diagram-2AECGRRQ-CRXNCxDY.js → diagram-2AECGRRQ-C4H51In7.js} +1 -1
- package/dist/admin-dist/assets/{diagram-5GNKFQAL-C9bO8FnC.js → diagram-5GNKFQAL-BW2-XCqV.js} +1 -1
- package/dist/admin-dist/assets/{diagram-LMA3HP47-ye8rGB9h.js → diagram-LMA3HP47-CQnSrSZs.js} +1 -1
- package/dist/admin-dist/assets/{diagram-OG6HWLK6-BL0joNkk.js → diagram-OG6HWLK6-BA6tBaOl.js} +1 -1
- package/dist/admin-dist/assets/{erDiagram-TEJ5UH35-lqVTGIq-.js → erDiagram-TEJ5UH35-DQK3b1Yu.js} +1 -1
- package/dist/admin-dist/assets/{flowDiagram-I6XJVG4X-DA2CLejf.js → flowDiagram-I6XJVG4X-BvtbwW59.js} +1 -1
- package/dist/admin-dist/assets/{ganttDiagram-6RSMTGT7-Dkr4jLLp.js → ganttDiagram-6RSMTGT7-Vb0T68-1.js} +1 -1
- package/dist/admin-dist/assets/index-F0fBD3Ys.js +96 -0
- package/dist/admin-dist/assets/{infoDiagram-5YYISTIA-PZDUmGz-.js → infoDiagram-5YYISTIA-8oD9uPZj.js} +1 -1
- package/dist/admin-dist/assets/{ishikawaDiagram-YF4QCWOH-BByxhIgY.js → ishikawaDiagram-YF4QCWOH-C32f84vy.js} +1 -1
- package/dist/admin-dist/assets/{kanban-definition-UN3LZRKU-BSTqfNBc.js → kanban-definition-UN3LZRKU-cJc_snn8.js} +1 -1
- package/dist/admin-dist/assets/{linear-DJE08IfY.js → linear-XcP0Xi-K.js} +1 -1
- package/dist/admin-dist/assets/{mindmap-definition-RKZ34NQL-CmiCyDY8.js → mindmap-definition-RKZ34NQL-jhlLOmXd.js} +1 -1
- package/dist/admin-dist/assets/{pieDiagram-4H26LBE5-BlMxq332.js → pieDiagram-4H26LBE5-cEiC5w8m.js} +1 -1
- package/dist/admin-dist/assets/{quadrantDiagram-W4KKPZXB-Cy0zZxaY.js → quadrantDiagram-W4KKPZXB-xjpfY5PD.js} +1 -1
- package/dist/admin-dist/assets/{requirementDiagram-4Y6WPE33-CAfQqVXA.js → requirementDiagram-4Y6WPE33-C5KtzYhy.js} +1 -1
- package/dist/admin-dist/assets/{sequenceDiagram-3UESZ5HK-CZYFDyTc.js → sequenceDiagram-3UESZ5HK-ByGOoS_6.js} +1 -1
- package/dist/admin-dist/assets/{stateDiagram-AJRCARHV-BTWDzbes.js → stateDiagram-AJRCARHV-d9g3cuV4.js} +1 -1
- package/dist/admin-dist/assets/{stateDiagram-v2-BHNVJYJU-BcExDjN4.js → stateDiagram-v2-BHNVJYJU-DJ9FtIdZ.js} +1 -1
- package/dist/admin-dist/assets/{timeline-definition-PNZ67QCA-Db_z8PtC.js → timeline-definition-PNZ67QCA-BB4Lz6CJ.js} +1 -1
- package/dist/admin-dist/assets/{vennDiagram-CIIHVFJN-Dkj99o7j.js → vennDiagram-CIIHVFJN-yj1GFfPu.js} +1 -1
- package/dist/admin-dist/assets/{wardleyDiagram-YWT4CUSO-DG8V20tb.js → wardleyDiagram-YWT4CUSO-5nw4MWMx.js} +1 -1
- package/dist/admin-dist/assets/{xychartDiagram-2RQKCTM6-B6EVudFe.js → xychartDiagram-2RQKCTM6-C0iogx2l.js} +1 -1
- package/dist/admin-dist/index.html +1 -1
- package/dist/admin-server/index.js +269 -6
- package/dist/core.js +822 -178
- package/dist/index.js +1235 -243
- package/package.json +1 -1
- package/dist/admin-dist/assets/index-CZPZGMX7.js +0 -96
package/dist/index.js
CHANGED
|
@@ -144,10 +144,10 @@ Status: pending
|
|
|
144
144
|
`;
|
|
145
145
|
}
|
|
146
146
|
function ensurePocArtifact(dir, projectName) {
|
|
147
|
-
const
|
|
148
|
-
if (exists(
|
|
147
|
+
const path18 = join(dir, POC_ARTIFACT_PATH);
|
|
148
|
+
if (exists(path18)) return false;
|
|
149
149
|
ensureDir(join(dir, "knowledge", "delivery"));
|
|
150
|
-
writeFile(
|
|
150
|
+
writeFile(path18, pocTemplate(projectName));
|
|
151
151
|
return true;
|
|
152
152
|
}
|
|
153
153
|
var PLACEHOLDER = /^[_<].*[_>]$|^(describe|list|document|what|how)\b/i;
|
|
@@ -162,13 +162,13 @@ function meaningful(text2) {
|
|
|
162
162
|
});
|
|
163
163
|
}
|
|
164
164
|
function readPocSummary(dir) {
|
|
165
|
-
const
|
|
166
|
-
if (!exists(
|
|
165
|
+
const path18 = join(dir, POC_ARTIFACT_PATH);
|
|
166
|
+
if (!exists(path18)) {
|
|
167
167
|
return { exists: false, hypothesisDefined: false, successCriteriaCount: 0, constraintsDefined: false, nonGoalsDefined: false, conclusion: "pending" };
|
|
168
168
|
}
|
|
169
169
|
let markdown = "";
|
|
170
170
|
try {
|
|
171
|
-
markdown = readFile(
|
|
171
|
+
markdown = readFile(path18);
|
|
172
172
|
} catch {
|
|
173
173
|
return { exists: false, hypothesisDefined: false, successCriteriaCount: 0, constraintsDefined: false, nonGoalsDefined: false, conclusion: "pending" };
|
|
174
174
|
}
|
|
@@ -688,8 +688,8 @@ function loadConfig(dir) {
|
|
|
688
688
|
const parsed = configSchema.safeParse(raw ?? {});
|
|
689
689
|
if (!parsed.success) {
|
|
690
690
|
const issues = parsed.error.issues.map((i) => {
|
|
691
|
-
const
|
|
692
|
-
return
|
|
691
|
+
const path18 = i.path.join(".");
|
|
692
|
+
return path18 ? ` - ${path18}: ${i.message}` : ` - ${i.message}`;
|
|
693
693
|
}).join("\n");
|
|
694
694
|
throw new ConfigError(`Invalid .kaddo/config.yml:
|
|
695
695
|
${issues}`);
|
|
@@ -5948,7 +5948,7 @@ function selectAgentFiles(opts) {
|
|
|
5948
5948
|
// src/modules/agents.ts
|
|
5949
5949
|
function withAgentFrontMatter(fileName, content) {
|
|
5950
5950
|
const name = fileName.replace(/\.md$/, "");
|
|
5951
|
-
const
|
|
5951
|
+
const fm3 = [
|
|
5952
5952
|
"---",
|
|
5953
5953
|
"type: agent",
|
|
5954
5954
|
`name: ${name}`,
|
|
@@ -5957,7 +5957,7 @@ function withAgentFrontMatter(fileName, content) {
|
|
|
5957
5957
|
"---",
|
|
5958
5958
|
""
|
|
5959
5959
|
].join("\n");
|
|
5960
|
-
return
|
|
5960
|
+
return fm3 + content.replace(/^\s+/, "");
|
|
5961
5961
|
}
|
|
5962
5962
|
var agentReadme = {
|
|
5963
5963
|
path: "knowledge/agents/README.md",
|
|
@@ -6678,7 +6678,7 @@ function formatList(items) {
|
|
|
6678
6678
|
return items.map((i) => `- ${i.trim()}`).join("\n");
|
|
6679
6679
|
}
|
|
6680
6680
|
function buildFrontMatter(id, type, level, title, answers) {
|
|
6681
|
-
const
|
|
6681
|
+
const today4 = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
6682
6682
|
const lines = [
|
|
6683
6683
|
"---",
|
|
6684
6684
|
`type: ${type}`,
|
|
@@ -6691,7 +6691,7 @@ function buildFrontMatter(id, type, level, title, answers) {
|
|
|
6691
6691
|
`initiative:`,
|
|
6692
6692
|
`domains: []`,
|
|
6693
6693
|
`code: []`,
|
|
6694
|
-
`created_at: ${
|
|
6694
|
+
`created_at: ${today4}`,
|
|
6695
6695
|
`source:`,
|
|
6696
6696
|
` type: manual`,
|
|
6697
6697
|
` inferred: false`,
|
|
@@ -6766,7 +6766,7 @@ _What did we learn from this change? Update after completion._
|
|
|
6766
6766
|
return sections.join("\n");
|
|
6767
6767
|
}
|
|
6768
6768
|
function buildModuleFrontMatter(id, modType, title, answers) {
|
|
6769
|
-
const
|
|
6769
|
+
const today4 = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
6770
6770
|
const extra = modType.extraFrontMatter ?? {};
|
|
6771
6771
|
const extraLines = Object.entries(extra).map(
|
|
6772
6772
|
([k, v]) => `${k}: ${JSON.stringify(v)}`
|
|
@@ -6782,7 +6782,7 @@ function buildModuleFrontMatter(id, modType, title, answers) {
|
|
|
6782
6782
|
`initiative:`,
|
|
6783
6783
|
`domains: []`,
|
|
6784
6784
|
`code: []`,
|
|
6785
|
-
`created_at: ${
|
|
6785
|
+
`created_at: ${today4}`,
|
|
6786
6786
|
`source: manual`,
|
|
6787
6787
|
`summary: "${title}"`,
|
|
6788
6788
|
...extraLines,
|
|
@@ -6930,7 +6930,7 @@ function resolveCandidateLevel(candidate, type) {
|
|
|
6930
6930
|
return getLevelForType(type);
|
|
6931
6931
|
}
|
|
6932
6932
|
function buildRoadmapFrontMatter(id, type, level, title, candidate, answers) {
|
|
6933
|
-
const
|
|
6933
|
+
const today4 = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
6934
6934
|
const summary = (answers.problem?.split(".")[0] ?? candidate.expectedValue ?? title).trim();
|
|
6935
6935
|
const initiative = candidate.initiative?.title ?? candidate.initiative?.id ?? "";
|
|
6936
6936
|
const q = (s) => s.replace(/"/g, "'");
|
|
@@ -6953,7 +6953,7 @@ function buildRoadmapFrontMatter(id, type, level, title, candidate, answers) {
|
|
|
6953
6953
|
...yamlList2("domains", domains),
|
|
6954
6954
|
...domains.length === 0 ? ["domains: []"] : [],
|
|
6955
6955
|
`code: []`,
|
|
6956
|
-
`created_at: ${
|
|
6956
|
+
`created_at: ${today4}`,
|
|
6957
6957
|
`source: roadmap`,
|
|
6958
6958
|
`source_id: ${candidate.id}`,
|
|
6959
6959
|
`source_initiative: ${candidate.initiative?.id ?? "unknown"}`,
|
|
@@ -7146,6 +7146,7 @@ async function runCreateFromRoadmap(dir, cliType) {
|
|
|
7146
7146
|
|
|
7147
7147
|
// src/services/git.ts
|
|
7148
7148
|
import { execa } from "execa";
|
|
7149
|
+
import path3 from "path";
|
|
7149
7150
|
async function getModifiedFiles(mode = "head") {
|
|
7150
7151
|
try {
|
|
7151
7152
|
let args;
|
|
@@ -7206,6 +7207,41 @@ async function getUntrackedFiles() {
|
|
|
7206
7207
|
return [];
|
|
7207
7208
|
}
|
|
7208
7209
|
}
|
|
7210
|
+
async function observeGit(dir, maxCommits = 100, repositoryId) {
|
|
7211
|
+
const limit = Math.max(1, Math.min(maxCommits, 250));
|
|
7212
|
+
const inspectedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
7213
|
+
try {
|
|
7214
|
+
const root = await getGitRoot(dir);
|
|
7215
|
+
if (!root) return { availability: "unavailable", repository: null, commits: [], branches: [], inspectedAt, limit };
|
|
7216
|
+
const [log2, refs] = await Promise.all([
|
|
7217
|
+
execa("git", ["log", `--max-count=${limit}`, "--format=%H%x1f%an%x1f%aI%x1f%s", "--name-only"], { cwd: root, timeout: 5e3 }),
|
|
7218
|
+
execa("git", ["for-each-ref", "--format=%(refname:short)", "refs/heads"], { cwd: root, timeout: 5e3 })
|
|
7219
|
+
]);
|
|
7220
|
+
const commits = [];
|
|
7221
|
+
let current = null;
|
|
7222
|
+
for (const line of log2.stdout.split(/\r?\n/)) {
|
|
7223
|
+
const parts = line.split("");
|
|
7224
|
+
if (parts.length === 4) {
|
|
7225
|
+
if (current) commits.push(current);
|
|
7226
|
+
current = { sha: parts[0], author: parts[1], date: parts[2], subject: parts[3], files: [] };
|
|
7227
|
+
} else if (current && line.trim()) current.files.push(line.trim());
|
|
7228
|
+
}
|
|
7229
|
+
if (current) commits.push(current);
|
|
7230
|
+
return {
|
|
7231
|
+
// The display identity is supplied by the caller when a project observes
|
|
7232
|
+
// several repositories. A basename alone is ambiguous in a multirepo
|
|
7233
|
+
// workspace (for example, two independent `api` folders).
|
|
7234
|
+
availability: "available",
|
|
7235
|
+
repository: repositoryId ?? path3.basename(root),
|
|
7236
|
+
commits,
|
|
7237
|
+
branches: refs.stdout.split(/\r?\n/).map((name) => name.trim()).filter(Boolean).slice(0, 100).map((name) => ({ name })),
|
|
7238
|
+
inspectedAt,
|
|
7239
|
+
limit
|
|
7240
|
+
};
|
|
7241
|
+
} catch {
|
|
7242
|
+
return { availability: "partial", repository: null, commits: [], branches: [], inspectedAt, limit };
|
|
7243
|
+
}
|
|
7244
|
+
}
|
|
7209
7245
|
|
|
7210
7246
|
// src/services/artifact-reader.ts
|
|
7211
7247
|
import matter from "gray-matter";
|
|
@@ -7402,14 +7438,14 @@ function discoverWorkItems(dir) {
|
|
|
7402
7438
|
|
|
7403
7439
|
// src/core/diff-analysis.ts
|
|
7404
7440
|
import { minimatch } from "minimatch";
|
|
7405
|
-
import
|
|
7441
|
+
import path4 from "path";
|
|
7406
7442
|
function toPosix2(p) {
|
|
7407
7443
|
return p.replace(/\\/g, "/");
|
|
7408
7444
|
}
|
|
7409
7445
|
function normalizeTouchedPathForProject(touchedPath, gitRoot, projectRoot) {
|
|
7410
7446
|
const t = toPosix2(touchedPath).replace(/^\.\//, "").replace(/^\/+/, "");
|
|
7411
7447
|
if (!gitRoot) return t;
|
|
7412
|
-
const prefix = toPosix2(
|
|
7448
|
+
const prefix = toPosix2(path4.relative(gitRoot, projectRoot)).replace(/^\.\//, "").replace(/\/+$/, "");
|
|
7413
7449
|
if (prefix === "" || prefix === ".") return t;
|
|
7414
7450
|
if (prefix.startsWith("..")) return t;
|
|
7415
7451
|
if (t === prefix) return null;
|
|
@@ -7475,10 +7511,10 @@ function analyzeGuard(touchedFiles, artifacts, silentWithoutOwnership) {
|
|
|
7475
7511
|
import { parse as parseYaml5, stringify as stringifyYaml4 } from "yaml";
|
|
7476
7512
|
var IGNORE_FILE = ".kaddo/ignores.yml";
|
|
7477
7513
|
function loadIgnores(dir) {
|
|
7478
|
-
const
|
|
7479
|
-
if (!exists(
|
|
7514
|
+
const path18 = join(dir, IGNORE_FILE);
|
|
7515
|
+
if (!exists(path18)) return [];
|
|
7480
7516
|
try {
|
|
7481
|
-
const raw = readFile(
|
|
7517
|
+
const raw = readFile(path18);
|
|
7482
7518
|
const parsed = parseYaml5(raw);
|
|
7483
7519
|
return Array.isArray(parsed) ? parsed : [];
|
|
7484
7520
|
} catch {
|
|
@@ -7486,7 +7522,7 @@ function loadIgnores(dir) {
|
|
|
7486
7522
|
}
|
|
7487
7523
|
}
|
|
7488
7524
|
function saveIgnore(dir, entry) {
|
|
7489
|
-
const
|
|
7525
|
+
const path18 = join(dir, IGNORE_FILE);
|
|
7490
7526
|
const existing = loadIgnores(dir);
|
|
7491
7527
|
const idx = existing.findIndex((e) => e.artifact_id === entry.artifact_id);
|
|
7492
7528
|
if (idx >= 0) {
|
|
@@ -7494,17 +7530,17 @@ function saveIgnore(dir, entry) {
|
|
|
7494
7530
|
} else {
|
|
7495
7531
|
existing.push(entry);
|
|
7496
7532
|
}
|
|
7497
|
-
writeFile(
|
|
7533
|
+
writeFile(path18, stringifyYaml4(existing));
|
|
7498
7534
|
}
|
|
7499
7535
|
function isIgnored(ignores, artifactId) {
|
|
7500
7536
|
return ignores.find((e) => e.artifact_id === artifactId);
|
|
7501
7537
|
}
|
|
7502
7538
|
function removeIgnore(dir, artifactId) {
|
|
7503
|
-
const
|
|
7539
|
+
const path18 = join(dir, IGNORE_FILE);
|
|
7504
7540
|
const existing = loadIgnores(dir);
|
|
7505
7541
|
const filtered = existing.filter((e) => e.artifact_id !== artifactId);
|
|
7506
7542
|
if (filtered.length === existing.length) return false;
|
|
7507
|
-
writeFile(
|
|
7543
|
+
writeFile(path18, stringifyYaml4(filtered));
|
|
7508
7544
|
return true;
|
|
7509
7545
|
}
|
|
7510
7546
|
|
|
@@ -7526,11 +7562,11 @@ function moduleArtifactCoverage(dir, id) {
|
|
|
7526
7562
|
};
|
|
7527
7563
|
}
|
|
7528
7564
|
function loadMappedModules(dir) {
|
|
7529
|
-
const
|
|
7530
|
-
if (!exists(
|
|
7565
|
+
const path18 = join(dir, DESCRIPTOR_PATH);
|
|
7566
|
+
if (!exists(path18)) return [];
|
|
7531
7567
|
let parsed;
|
|
7532
7568
|
try {
|
|
7533
|
-
parsed = parseYaml6(readFile(
|
|
7569
|
+
parsed = parseYaml6(readFile(path18));
|
|
7534
7570
|
} catch {
|
|
7535
7571
|
return [];
|
|
7536
7572
|
}
|
|
@@ -7727,8 +7763,8 @@ function analyzeMetadataHealth(dir) {
|
|
|
7727
7763
|
if (isFile(p) && entry.endsWith(".md")) {
|
|
7728
7764
|
try {
|
|
7729
7765
|
const raw = readFile(p);
|
|
7730
|
-
const
|
|
7731
|
-
if (
|
|
7766
|
+
const fm3 = matter2(raw).data;
|
|
7767
|
+
if (fm3.status === "done") {
|
|
7732
7768
|
const rel = p.replace(dir + "/", "").replace(dir + "\\", "").replace(/\\/g, "/");
|
|
7733
7769
|
findings.push({
|
|
7734
7770
|
file: rel,
|
|
@@ -7985,7 +8021,7 @@ function analyzeScopeCoverage(artifact, registeredModuleIds, frontendModuleIds)
|
|
|
7985
8021
|
}
|
|
7986
8022
|
|
|
7987
8023
|
// src/commands/guard.ts
|
|
7988
|
-
import
|
|
8024
|
+
import path5 from "path";
|
|
7989
8025
|
import { parse as parseYaml8 } from "yaml";
|
|
7990
8026
|
|
|
7991
8027
|
// src/plugins/prisma.ts
|
|
@@ -8274,7 +8310,7 @@ function buildGuardHistory(dir) {
|
|
|
8274
8310
|
const d = hotspotDir(t.code_path);
|
|
8275
8311
|
hotspotMap.set(d, (hotspotMap.get(d) ?? 0) + 1);
|
|
8276
8312
|
}
|
|
8277
|
-
const hotspots = [...hotspotMap.entries()].map(([
|
|
8313
|
+
const hotspots = [...hotspotMap.entries()].map(([path18, warnings]) => ({ path: path18, warnings })).sort((a, b) => b.warnings - a.warnings);
|
|
8278
8314
|
return {
|
|
8279
8315
|
available: true,
|
|
8280
8316
|
total_runs: sorted.length,
|
|
@@ -8396,7 +8432,7 @@ function printHeader(touchedFiles) {
|
|
|
8396
8432
|
function artifactLabel(artifact, dir) {
|
|
8397
8433
|
if (artifact.id) return artifact.id;
|
|
8398
8434
|
if (artifact.title) return artifact.title;
|
|
8399
|
-
const rel =
|
|
8435
|
+
const rel = path5.relative(dir, artifact.filePath).split(path5.sep).join("/");
|
|
8400
8436
|
return rel || artifact.filePath;
|
|
8401
8437
|
}
|
|
8402
8438
|
function printWorkspaceHeader(scan2) {
|
|
@@ -10532,7 +10568,7 @@ function getTemplate(id) {
|
|
|
10532
10568
|
}
|
|
10533
10569
|
|
|
10534
10570
|
// src/commands/modules-discover.ts
|
|
10535
|
-
import
|
|
10571
|
+
import path6 from "path";
|
|
10536
10572
|
import { parse as parseYaml9, stringify as stringifyYaml5 } from "yaml";
|
|
10537
10573
|
var CONFIG_PATH3 = ".kaddo/config.yml";
|
|
10538
10574
|
var MODULES_YML = ".kaddo/modules.yml";
|
|
@@ -10609,9 +10645,9 @@ function discoverModules(dir) {
|
|
|
10609
10645
|
const seenIds = /* @__PURE__ */ new Set();
|
|
10610
10646
|
const seenPaths = /* @__PURE__ */ new Set();
|
|
10611
10647
|
const results = [];
|
|
10612
|
-
const coreAbsPath =
|
|
10648
|
+
const coreAbsPath = path6.resolve(dir);
|
|
10613
10649
|
for (const root of roots) {
|
|
10614
|
-
const rootAbs =
|
|
10650
|
+
const rootAbs = path6.resolve(dir, root);
|
|
10615
10651
|
if (!exists(rootAbs) || !isDir(rootAbs)) continue;
|
|
10616
10652
|
let entries;
|
|
10617
10653
|
try {
|
|
@@ -10621,10 +10657,10 @@ function discoverModules(dir) {
|
|
|
10621
10657
|
}
|
|
10622
10658
|
for (const entry of entries) {
|
|
10623
10659
|
if (IGNORED_DIRS.has(entry)) continue;
|
|
10624
|
-
const candidateAbs =
|
|
10660
|
+
const candidateAbs = path6.resolve(rootAbs, entry);
|
|
10625
10661
|
if (!isDir(candidateAbs)) continue;
|
|
10626
10662
|
if (candidateAbs === coreAbsPath) continue;
|
|
10627
|
-
const relPath =
|
|
10663
|
+
const relPath = path6.relative(dir, candidateAbs).replace(/\\/g, "/");
|
|
10628
10664
|
const repoConfig = readRepoConfig(candidateAbs);
|
|
10629
10665
|
if (!repoConfig) {
|
|
10630
10666
|
results.push({
|
|
@@ -10707,7 +10743,7 @@ function discoverModules(dir) {
|
|
|
10707
10743
|
}
|
|
10708
10744
|
}
|
|
10709
10745
|
for (const m of existing.modules) {
|
|
10710
|
-
const absPath =
|
|
10746
|
+
const absPath = path6.resolve(dir, m.path);
|
|
10711
10747
|
if (!exists(absPath) && !results.some((r) => r.path === m.path)) {
|
|
10712
10748
|
results.push({
|
|
10713
10749
|
id: m.id,
|
|
@@ -10739,7 +10775,7 @@ function applyDiscovery(dir, discovered) {
|
|
|
10739
10775
|
path: d.path,
|
|
10740
10776
|
parent_system: d.parentSystem,
|
|
10741
10777
|
status: d.status,
|
|
10742
|
-
context: buildModuleContextPaths(
|
|
10778
|
+
context: buildModuleContextPaths(path6.resolve(dir, d.path))
|
|
10743
10779
|
};
|
|
10744
10780
|
if (existingIdx >= 0) {
|
|
10745
10781
|
yml.modules[existingIdx] = entry;
|
|
@@ -10801,7 +10837,7 @@ function runModulesValidate(dir = cwd()) {
|
|
|
10801
10837
|
}
|
|
10802
10838
|
console.log("");
|
|
10803
10839
|
for (const m of yml.modules) {
|
|
10804
|
-
const absPath =
|
|
10840
|
+
const absPath = path6.resolve(dir, m.path);
|
|
10805
10841
|
if (!exists(absPath)) {
|
|
10806
10842
|
console.log(`${m.id.padEnd(16)} missing`);
|
|
10807
10843
|
continue;
|
|
@@ -10912,10 +10948,10 @@ function slugify2(name) {
|
|
|
10912
10948
|
return name.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
10913
10949
|
}
|
|
10914
10950
|
function readModulesDescriptor(dir) {
|
|
10915
|
-
const
|
|
10916
|
-
if (!exists(
|
|
10951
|
+
const path18 = join(dir, DESCRIPTOR_PATH2);
|
|
10952
|
+
if (!exists(path18)) return { version: 1, modules: [] };
|
|
10917
10953
|
try {
|
|
10918
|
-
const parsed = parseYaml10(readFile(
|
|
10954
|
+
const parsed = parseYaml10(readFile(path18));
|
|
10919
10955
|
return { version: parsed.version ?? 1, modules: parsed.modules ?? [] };
|
|
10920
10956
|
} catch {
|
|
10921
10957
|
return { version: 1, modules: [] };
|
|
@@ -11219,7 +11255,7 @@ ${items.map((i) => `- ${i}`).join("\n")}
|
|
|
11219
11255
|
`;
|
|
11220
11256
|
}
|
|
11221
11257
|
function renderCapsuleMarkdown(c) {
|
|
11222
|
-
const
|
|
11258
|
+
const fm3 = [
|
|
11223
11259
|
"---",
|
|
11224
11260
|
"type: knowledge-capsule",
|
|
11225
11261
|
`system: ${c.system}`,
|
|
@@ -11231,7 +11267,7 @@ function renderCapsuleMarkdown(c) {
|
|
|
11231
11267
|
"---"
|
|
11232
11268
|
].join("\n");
|
|
11233
11269
|
const parts = [
|
|
11234
|
-
|
|
11270
|
+
fm3,
|
|
11235
11271
|
"",
|
|
11236
11272
|
`# ${c.system} \u2014 Knowledge Capsule`,
|
|
11237
11273
|
"",
|
|
@@ -11295,7 +11331,7 @@ function sectionParagraph(md, title) {
|
|
|
11295
11331
|
}
|
|
11296
11332
|
return "";
|
|
11297
11333
|
}
|
|
11298
|
-
function parseCapsule(id,
|
|
11334
|
+
function parseCapsule(id, path18, md) {
|
|
11299
11335
|
const { data } = matter3(md);
|
|
11300
11336
|
const updatedAt = data.updated_at ? String(data.updated_at) : void 0;
|
|
11301
11337
|
let ageDays = null;
|
|
@@ -11305,7 +11341,7 @@ function parseCapsule(id, path16, md) {
|
|
|
11305
11341
|
}
|
|
11306
11342
|
return {
|
|
11307
11343
|
id,
|
|
11308
|
-
path:
|
|
11344
|
+
path: path18,
|
|
11309
11345
|
system: data.system ? String(data.system) : id,
|
|
11310
11346
|
owner: data.owner ? String(data.owner) : void 0,
|
|
11311
11347
|
updatedAt,
|
|
@@ -11538,6 +11574,18 @@ var DELIVERY_PLANS_DIR = "knowledge/delivery/plans";
|
|
|
11538
11574
|
var EPICS_DIR = "knowledge/delivery/epics";
|
|
11539
11575
|
var PLAN_STATES = ["draft", "in-progress", "completed", "cancelled"];
|
|
11540
11576
|
var EPIC_STATES = ["planned", "in-progress", "completed", "cancelled"];
|
|
11577
|
+
var PLAN_TRANSITIONS = {
|
|
11578
|
+
draft: ["in-progress", "cancelled"],
|
|
11579
|
+
"in-progress": ["completed", "cancelled"],
|
|
11580
|
+
completed: [],
|
|
11581
|
+
cancelled: []
|
|
11582
|
+
};
|
|
11583
|
+
var EPIC_TRANSITIONS = {
|
|
11584
|
+
planned: ["in-progress", "cancelled"],
|
|
11585
|
+
"in-progress": ["completed", "cancelled"],
|
|
11586
|
+
completed: [],
|
|
11587
|
+
cancelled: []
|
|
11588
|
+
};
|
|
11541
11589
|
function toPosix5(p) {
|
|
11542
11590
|
return p.replace(/\\/g, "/");
|
|
11543
11591
|
}
|
|
@@ -11818,6 +11866,9 @@ function validatePlanningGraph(dir) {
|
|
|
11818
11866
|
findings.push({ level: "warning", kind: "pending_dependency", subject: e.id, message: `Epic ${e.id} is blocked by unfinished dependency ${d}.` });
|
|
11819
11867
|
return findings;
|
|
11820
11868
|
}
|
|
11869
|
+
function revisionOf(content) {
|
|
11870
|
+
return createHash("sha256").update(content, "utf8").digest("hex").slice(0, 16);
|
|
11871
|
+
}
|
|
11821
11872
|
|
|
11822
11873
|
// src/core/resources.ts
|
|
11823
11874
|
import matter6 from "gray-matter";
|
|
@@ -11937,40 +11988,40 @@ function purposeFromBody(body) {
|
|
|
11937
11988
|
}
|
|
11938
11989
|
function toDetail(filePath, relPath, raw) {
|
|
11939
11990
|
const parsed = matter6(raw);
|
|
11940
|
-
const
|
|
11991
|
+
const fm3 = parsed.data ?? {};
|
|
11941
11992
|
const body = parsed.content.trim();
|
|
11942
|
-
const id = str(
|
|
11993
|
+
const id = str(fm3.id) ?? "";
|
|
11943
11994
|
return {
|
|
11944
11995
|
id,
|
|
11945
|
-
title: str(
|
|
11946
|
-
resourceType: str(
|
|
11947
|
-
provider: str(
|
|
11948
|
-
environments: strArray(
|
|
11949
|
-
scope: parseScope(
|
|
11950
|
-
modules: strArray(
|
|
11996
|
+
title: str(fm3.title) ?? id,
|
|
11997
|
+
resourceType: str(fm3.resource_type),
|
|
11998
|
+
provider: str(fm3.provider),
|
|
11999
|
+
environments: strArray(fm3.environments),
|
|
12000
|
+
scope: parseScope(fm3.scope),
|
|
12001
|
+
modules: strArray(fm3.modules),
|
|
11951
12002
|
path: relPath,
|
|
11952
|
-
purpose: str(
|
|
11953
|
-
interfaces: parseInterfaces(
|
|
11954
|
-
boundaries: parseBoundaries(
|
|
12003
|
+
purpose: str(fm3.purpose) ?? purposeFromBody(body),
|
|
12004
|
+
interfaces: parseInterfaces(fm3.access_interfaces),
|
|
12005
|
+
boundaries: parseBoundaries(fm3.access_boundaries),
|
|
11955
12006
|
...(() => {
|
|
11956
|
-
const a = parseAuth(
|
|
12007
|
+
const a = parseAuth(fm3.authentication);
|
|
11957
12008
|
return { authRefs: a.refs, authMode: a.mode };
|
|
11958
12009
|
})(),
|
|
11959
|
-
connectionProfiles: parseConnectionProfiles(
|
|
12010
|
+
connectionProfiles: parseConnectionProfiles(fm3.connection_profiles),
|
|
11960
12011
|
markdownBody: body
|
|
11961
12012
|
};
|
|
11962
12013
|
}
|
|
11963
12014
|
function getResources(dir) {
|
|
11964
12015
|
return discoverKnowledge(dir).filter((a) => a.type === RESOURCE_ARTIFACT_TYPE).map((a) => {
|
|
11965
|
-
const
|
|
12016
|
+
const fm3 = a.rawFrontmatter;
|
|
11966
12017
|
return {
|
|
11967
|
-
id: a.id || str(
|
|
11968
|
-
title: a.title || str(
|
|
11969
|
-
resourceType: str(
|
|
11970
|
-
provider: str(
|
|
11971
|
-
environments: strArray(
|
|
11972
|
-
scope: parseScope(
|
|
11973
|
-
modules: strArray(
|
|
12018
|
+
id: a.id || str(fm3.id) || a.title,
|
|
12019
|
+
title: a.title || str(fm3.title) || a.id,
|
|
12020
|
+
resourceType: str(fm3.resource_type),
|
|
12021
|
+
provider: str(fm3.provider),
|
|
12022
|
+
environments: strArray(fm3.environments),
|
|
12023
|
+
scope: parseScope(fm3.scope),
|
|
12024
|
+
modules: strArray(fm3.modules),
|
|
11974
12025
|
path: a.relPath
|
|
11975
12026
|
};
|
|
11976
12027
|
}).sort((x, y) => x.id.localeCompare(y.id));
|
|
@@ -11983,8 +12034,8 @@ function getResource(dir, id) {
|
|
|
11983
12034
|
const raw = readFile(match.filePath);
|
|
11984
12035
|
return toDetail(match.filePath, match.relPath, raw);
|
|
11985
12036
|
}
|
|
11986
|
-
function parseWorkItemResources(
|
|
11987
|
-
const v =
|
|
12037
|
+
function parseWorkItemResources(fm3) {
|
|
12038
|
+
const v = fm3.resources;
|
|
11988
12039
|
if (!Array.isArray(v)) return [];
|
|
11989
12040
|
const out = [];
|
|
11990
12041
|
for (const raw of v) {
|
|
@@ -12036,8 +12087,8 @@ var EVIDENCE_SIGNALS = [
|
|
|
12036
12087
|
function str2(v) {
|
|
12037
12088
|
return typeof v === "string" && v.trim() ? v.trim() : null;
|
|
12038
12089
|
}
|
|
12039
|
-
function parseWorkItemDeprecationTargets(
|
|
12040
|
-
const v =
|
|
12090
|
+
function parseWorkItemDeprecationTargets(fm3) {
|
|
12091
|
+
const v = fm3.deprecation_targets;
|
|
12041
12092
|
if (!Array.isArray(v)) return [];
|
|
12042
12093
|
const out = [];
|
|
12043
12094
|
for (const raw of v) {
|
|
@@ -12171,13 +12222,13 @@ function purposeFromBody2(body) {
|
|
|
12171
12222
|
}
|
|
12172
12223
|
function getDeprecationPlans(dir) {
|
|
12173
12224
|
return discoverKnowledge(dir).filter((a) => a.type === DEPRECATION_ARTIFACT_TYPE).map((a) => {
|
|
12174
|
-
const
|
|
12175
|
-
const targets = parseTargets(
|
|
12225
|
+
const fm3 = a.rawFrontmatter;
|
|
12226
|
+
const targets = parseTargets(fm3.targets);
|
|
12176
12227
|
return {
|
|
12177
|
-
id: a.id || str2(
|
|
12178
|
-
title: a.title || str2(
|
|
12228
|
+
id: a.id || str2(fm3.id) || a.title,
|
|
12229
|
+
title: a.title || str2(fm3.title) || a.id,
|
|
12179
12230
|
path: a.relPath,
|
|
12180
|
-
status: str2(
|
|
12231
|
+
status: str2(fm3.status),
|
|
12181
12232
|
targetCount: targets.length,
|
|
12182
12233
|
lifecycleCounts: lifecycleCountsOf(targets)
|
|
12183
12234
|
};
|
|
@@ -12190,17 +12241,17 @@ function getDeprecationPlan(dir, id) {
|
|
|
12190
12241
|
if (!match) return null;
|
|
12191
12242
|
const raw = readFile(match.filePath);
|
|
12192
12243
|
const parsed = matter7(raw);
|
|
12193
|
-
const
|
|
12244
|
+
const fm3 = parsed.data ?? {};
|
|
12194
12245
|
const body = parsed.content.trim();
|
|
12195
|
-
const targets = parseTargets(
|
|
12246
|
+
const targets = parseTargets(fm3.targets);
|
|
12196
12247
|
return {
|
|
12197
|
-
id: str2(
|
|
12198
|
-
title: str2(
|
|
12248
|
+
id: str2(fm3.id) ?? match.id,
|
|
12249
|
+
title: str2(fm3.title) ?? match.title,
|
|
12199
12250
|
path: match.relPath,
|
|
12200
|
-
status: str2(
|
|
12251
|
+
status: str2(fm3.status),
|
|
12201
12252
|
targetCount: targets.length,
|
|
12202
12253
|
lifecycleCounts: lifecycleCountsOf(targets),
|
|
12203
|
-
purpose: str2(
|
|
12254
|
+
purpose: str2(fm3.purpose) ?? purposeFromBody2(body),
|
|
12204
12255
|
targets,
|
|
12205
12256
|
markdownBody: body
|
|
12206
12257
|
};
|
|
@@ -12287,9 +12338,9 @@ function buildGraph(dir, config, opts = {}, now = /* @__PURE__ */ new Date()) {
|
|
|
12287
12338
|
];
|
|
12288
12339
|
const presentLayers = [];
|
|
12289
12340
|
for (const layer2 of layerDocs) {
|
|
12290
|
-
const
|
|
12291
|
-
if (
|
|
12292
|
-
addNode({ id: layer2.id, type: layer2.type, label: layer2.label, path:
|
|
12341
|
+
const path18 = layer2.files.map((f) => `${KNOWLEDGE3}/${f}`).find((rel) => exists(join(dir, rel)));
|
|
12342
|
+
if (path18) {
|
|
12343
|
+
addNode({ id: layer2.id, type: layer2.type, label: layer2.label, path: path18 });
|
|
12293
12344
|
presentLayers.push(layer2.id);
|
|
12294
12345
|
}
|
|
12295
12346
|
}
|
|
@@ -12726,9 +12777,9 @@ var QUALITY_NOTE = {
|
|
|
12726
12777
|
sparse: "The graph has many nodes but few meaningful edges.",
|
|
12727
12778
|
empty: "The graph has almost no relationships."
|
|
12728
12779
|
};
|
|
12729
|
-
function yamlBlock(
|
|
12780
|
+
function yamlBlock(fm3) {
|
|
12730
12781
|
const lines = ["```yaml"];
|
|
12731
|
-
for (const [k, vals] of Object.entries(
|
|
12782
|
+
for (const [k, vals] of Object.entries(fm3)) {
|
|
12732
12783
|
lines.push(`${k}:`);
|
|
12733
12784
|
for (const v of vals) lines.push(` - ${v}`);
|
|
12734
12785
|
}
|
|
@@ -13857,11 +13908,11 @@ function redactSecrets(value) {
|
|
|
13857
13908
|
return line.replace(/([:=]\s*)\S+.*/, "$1[redacted]");
|
|
13858
13909
|
}).join("\n");
|
|
13859
13910
|
}
|
|
13860
|
-
function source(dir,
|
|
13861
|
-
const absolute = join(dir,
|
|
13911
|
+
function source(dir, path18, kind) {
|
|
13912
|
+
const absolute = join(dir, path18);
|
|
13862
13913
|
if (!exists(absolute)) return null;
|
|
13863
13914
|
const raw = readFile(absolute);
|
|
13864
|
-
return { path: posix(
|
|
13915
|
+
return { path: posix(path18), kind, digest: sha(raw), content: redactSecrets(raw) };
|
|
13865
13916
|
}
|
|
13866
13917
|
function reportFiles(dir) {
|
|
13867
13918
|
const delivery = join(dir, "knowledge", "delivery");
|
|
@@ -13901,9 +13952,9 @@ function buildPocReportContext(dir) {
|
|
|
13901
13952
|
};
|
|
13902
13953
|
}
|
|
13903
13954
|
const sources = [];
|
|
13904
|
-
const add = (
|
|
13905
|
-
if (sources.some((item2) => item2.path === posix(
|
|
13906
|
-
const item = source(dir,
|
|
13955
|
+
const add = (path18, kind) => {
|
|
13956
|
+
if (sources.some((item2) => item2.path === posix(path18))) return;
|
|
13957
|
+
const item = source(dir, path18, kind);
|
|
13907
13958
|
if (item) sources.push(item);
|
|
13908
13959
|
};
|
|
13909
13960
|
add(POC_ARTIFACT_PATH, "poc");
|
|
@@ -13931,7 +13982,7 @@ function buildPocReportContext(dir) {
|
|
|
13931
13982
|
const sourceFingerprint = sha(sources.map((item) => `${item.path}\0${item.digest}`).join("\n"));
|
|
13932
13983
|
const status = !latestReport ? "missing" : latestReport.sourceFingerprint === sourceFingerprint ? "current" : "stale";
|
|
13933
13984
|
const currentManifest = Object.fromEntries(sources.map((item) => [item.path, item.digest]));
|
|
13934
|
-
const changesSinceLatest = status === "stale" ? [.../* @__PURE__ */ new Set([...Object.keys(currentManifest), ...Object.keys(latestReport?.sourceManifest ?? {})])].filter((
|
|
13985
|
+
const changesSinceLatest = status === "stale" ? [.../* @__PURE__ */ new Set([...Object.keys(currentManifest), ...Object.keys(latestReport?.sourceManifest ?? {})])].filter((path18) => currentManifest[path18] !== latestReport?.sourceManifest[path18]).sort() : [];
|
|
13935
13986
|
const sourceList = sources.map((item) => `- ${item.path} (${item.kind})`).join("\n") || "- No sources selected.";
|
|
13936
13987
|
return {
|
|
13937
13988
|
eligible: true,
|
|
@@ -14082,10 +14133,10 @@ function resolveNextStep(dir, now = /* @__PURE__ */ new Date()) {
|
|
|
14082
14133
|
const q = (rel) => analyzeKnowledgeArtifact(dir, rel);
|
|
14083
14134
|
const resolveAgent = (agent) => {
|
|
14084
14135
|
const file = agent.endsWith(".md") ? agent : `${agent}.md`;
|
|
14085
|
-
const
|
|
14086
|
-
const installed = isFile(join(dir,
|
|
14136
|
+
const path18 = agentInstallPath(file);
|
|
14137
|
+
const installed = isFile(join(dir, path18));
|
|
14087
14138
|
const group = agentGroupOf(file);
|
|
14088
|
-
return { agentPath:
|
|
14139
|
+
return { agentPath: path18, agentInstalled: installed, installCommand: installed ? void 0 : `kaddo add agents --group ${group}` };
|
|
14089
14140
|
};
|
|
14090
14141
|
const moduleRepo = isModule(config);
|
|
14091
14142
|
const coreRepo = isCore(config);
|
|
@@ -15642,8 +15693,8 @@ function buildProjectExplanation(dir) {
|
|
|
15642
15693
|
};
|
|
15643
15694
|
}),
|
|
15644
15695
|
implementationEvidence: workItemArtifacts.filter((a) => a.affectedModules.length > 0).map((a) => {
|
|
15645
|
-
const
|
|
15646
|
-
const evidence =
|
|
15696
|
+
const fm3 = a.rawFrontmatter;
|
|
15697
|
+
const evidence = fm3.implementation_evidence;
|
|
15647
15698
|
const repos = evidence?.repositories ?? {};
|
|
15648
15699
|
const repoEvidence = {};
|
|
15649
15700
|
for (const [repoId, data] of Object.entries(repos)) {
|
|
@@ -15661,8 +15712,8 @@ function buildProjectExplanation(dir) {
|
|
|
15661
15712
|
validationStatus: a.validationStatus || historicalDefault,
|
|
15662
15713
|
releaseStatus: a.releaseStatus || "not-assessed",
|
|
15663
15714
|
affectedModules: a.affectedModules,
|
|
15664
|
-
releaseGates: Array.isArray(
|
|
15665
|
-
completionExceptions: Array.isArray(
|
|
15715
|
+
releaseGates: Array.isArray(fm3.release_gates) ? fm3.release_gates : [],
|
|
15716
|
+
completionExceptions: Array.isArray(fm3.completion_exceptions) ? fm3.completion_exceptions : [],
|
|
15666
15717
|
repoEvidence
|
|
15667
15718
|
};
|
|
15668
15719
|
})
|
|
@@ -16107,9 +16158,9 @@ function readConfig(dir) {
|
|
|
16107
16158
|
}
|
|
16108
16159
|
function filterBySince(artifacts, since) {
|
|
16109
16160
|
return artifacts.filter((a) => {
|
|
16110
|
-
const
|
|
16111
|
-
if (!
|
|
16112
|
-
return
|
|
16161
|
+
const fm3 = a;
|
|
16162
|
+
if (!fm3.created_at) return true;
|
|
16163
|
+
return fm3.created_at >= since;
|
|
16113
16164
|
});
|
|
16114
16165
|
}
|
|
16115
16166
|
function filterByScope(artifacts, scope) {
|
|
@@ -17638,7 +17689,7 @@ function runUnderstand() {
|
|
|
17638
17689
|
}
|
|
17639
17690
|
|
|
17640
17691
|
// src/core/classifier.ts
|
|
17641
|
-
import
|
|
17692
|
+
import path7 from "path";
|
|
17642
17693
|
var MIGRATION_PATTERNS = [
|
|
17643
17694
|
/supabase\/migrations\//,
|
|
17644
17695
|
/prisma\/migrations\//,
|
|
@@ -17677,7 +17728,7 @@ var DEP_PATTERNS = [
|
|
|
17677
17728
|
/^pom\.xml$/
|
|
17678
17729
|
];
|
|
17679
17730
|
function normalizePath2(p) {
|
|
17680
|
-
return p.split(
|
|
17731
|
+
return p.split(path7.sep).join("/");
|
|
17681
17732
|
}
|
|
17682
17733
|
function matchesAny2(file, patterns) {
|
|
17683
17734
|
const normalized = normalizePath2(file);
|
|
@@ -17920,7 +17971,7 @@ function runStatus() {
|
|
|
17920
17971
|
|
|
17921
17972
|
// src/commands/learn.ts
|
|
17922
17973
|
import fs3 from "fs";
|
|
17923
|
-
import
|
|
17974
|
+
import path8 from "path";
|
|
17924
17975
|
import matter13 from "gray-matter";
|
|
17925
17976
|
var ARCH_DIR9 = "knowledge";
|
|
17926
17977
|
var WORK_ITEMS_DIR2 = "knowledge/delivery/work-items";
|
|
@@ -17928,11 +17979,11 @@ function completedPathFor(filePath) {
|
|
|
17928
17979
|
const posix2 = filePath.replace(/\\/g, "/");
|
|
17929
17980
|
const m = posix2.match(/\/work-items\/(draft|ready|in-progress|blocked)\//);
|
|
17930
17981
|
if (!m) return filePath;
|
|
17931
|
-
const completedDir =
|
|
17982
|
+
const completedDir = path8.dirname(filePath).replace(
|
|
17932
17983
|
new RegExp(`[/\\\\]${m[1]}$`),
|
|
17933
|
-
|
|
17984
|
+
path8.sep + "completed"
|
|
17934
17985
|
);
|
|
17935
|
-
return
|
|
17986
|
+
return path8.join(completedDir, path8.basename(filePath));
|
|
17936
17987
|
}
|
|
17937
17988
|
function updateWorkItemFile(filePath, learning) {
|
|
17938
17989
|
const raw = readFile(filePath);
|
|
@@ -17964,7 +18015,7 @@ ${learning.trim()}
|
|
|
17964
18015
|
const newRaw = matter13.stringify(updatedContent, data);
|
|
17965
18016
|
const newPath = completedPathFor(filePath);
|
|
17966
18017
|
if (newPath !== filePath) {
|
|
17967
|
-
ensureDir(
|
|
18018
|
+
ensureDir(path8.dirname(newPath));
|
|
17968
18019
|
writeFile(newPath, newRaw);
|
|
17969
18020
|
fs3.unlinkSync(filePath);
|
|
17970
18021
|
} else {
|
|
@@ -18058,7 +18109,7 @@ async function runLearn(artifactId, opts = {}) {
|
|
|
18058
18109
|
}
|
|
18059
18110
|
const finalPath = updateWorkItemFile(filePath, enrichedLearning);
|
|
18060
18111
|
log.success(`${targetId} marked as completed`);
|
|
18061
|
-
log.success(`Learning recorded in ${finalPath.replace(dir +
|
|
18112
|
+
log.success(`Learning recorded in ${finalPath.replace(dir + path8.sep, "").replace(/\\/g, "/")}`);
|
|
18062
18113
|
if (hasExceptions) {
|
|
18063
18114
|
log.warn("Learning captured from a Work Item completed with validation exceptions.");
|
|
18064
18115
|
}
|
|
@@ -19161,8 +19212,8 @@ var DIR_TARGETS = ["knowledge/tech/decisions", "knowledge/tech/discovery", "know
|
|
|
19161
19212
|
function withLanguageDirective(content, language) {
|
|
19162
19213
|
if (language !== "es") return content;
|
|
19163
19214
|
const note = "> Idioma del proyecto: **espa\xF1ol**. Escribe este conocimiento en espa\xF1ol. Mant\xE9n en ingl\xE9s el c\xF3digo, los nombres de archivo, los comandos y las claves de configuraci\xF3n.\n";
|
|
19164
|
-
const
|
|
19165
|
-
if (
|
|
19215
|
+
const fm3 = content.match(/^---\n[\s\S]*?\n---\n/);
|
|
19216
|
+
if (fm3) return content.slice(0, fm3[0].length) + "\n" + note + content.slice(fm3[0].length);
|
|
19166
19217
|
return `${note}
|
|
19167
19218
|
${content}`;
|
|
19168
19219
|
}
|
|
@@ -19364,7 +19415,7 @@ function runGraphExport(opts = {}) {
|
|
|
19364
19415
|
// src/core/system-topology.ts
|
|
19365
19416
|
import { parse as parseYaml17, stringify as stringifyYaml9 } from "yaml";
|
|
19366
19417
|
import fs4 from "fs";
|
|
19367
|
-
import
|
|
19418
|
+
import path9 from "path";
|
|
19368
19419
|
import crypto from "crypto";
|
|
19369
19420
|
var TOPOLOGY_FILE = "knowledge/tech/system-topology.yml";
|
|
19370
19421
|
var SYSTEM_ENTITY_KINDS = /* @__PURE__ */ new Set([
|
|
@@ -19530,7 +19581,7 @@ function serializeTopology(entities, relationships) {
|
|
|
19530
19581
|
return stringifyYaml9(doc);
|
|
19531
19582
|
}
|
|
19532
19583
|
function atomicWrite(filePath, content) {
|
|
19533
|
-
fs4.mkdirSync(
|
|
19584
|
+
fs4.mkdirSync(path9.dirname(filePath), { recursive: true });
|
|
19534
19585
|
const tmp = `${filePath}.${process.pid}.${Date.now()}.tmp`;
|
|
19535
19586
|
fs4.writeFileSync(tmp, content, "utf-8");
|
|
19536
19587
|
try {
|
|
@@ -19644,7 +19695,7 @@ async function runTopologyApply(file, opts = {}) {
|
|
|
19644
19695
|
|
|
19645
19696
|
// src/core/resource-write.ts
|
|
19646
19697
|
import fs5 from "fs";
|
|
19647
|
-
import
|
|
19698
|
+
import path10 from "path";
|
|
19648
19699
|
import matter15 from "gray-matter";
|
|
19649
19700
|
var RESOURCES_DIR = "knowledge/tech/resources";
|
|
19650
19701
|
var ResourceWriteError = class extends Error {
|
|
@@ -19783,7 +19834,7 @@ ${(input.purpose ?? "").trim() || "TODO: describe what this resource is for."}`;
|
|
|
19783
19834
|
const relPath = `${RESOURCES_DIR}/${slug4(title) || slug4(id)}.md`;
|
|
19784
19835
|
const filePath = join(dir, relPath);
|
|
19785
19836
|
if (exists(filePath)) throw new ResourceWriteError("DUPLICATE", `Resource file already exists: ${relPath}`);
|
|
19786
|
-
ensureDir(
|
|
19837
|
+
ensureDir(path10.dirname(filePath));
|
|
19787
19838
|
atomicWrite2(filePath, serialize(data, body));
|
|
19788
19839
|
return { id, path: relPath, findings };
|
|
19789
19840
|
}
|
|
@@ -20269,7 +20320,7 @@ var CANDIDATE_DISCOVERY_GUIDANCE = [
|
|
|
20269
20320
|
|
|
20270
20321
|
// src/core/deprecation-write.ts
|
|
20271
20322
|
import fs6 from "fs";
|
|
20272
|
-
import
|
|
20323
|
+
import path11 from "path";
|
|
20273
20324
|
import matter16 from "gray-matter";
|
|
20274
20325
|
var DeprecationWriteError = class extends Error {
|
|
20275
20326
|
constructor(code, message) {
|
|
@@ -20385,7 +20436,7 @@ ${(input.purpose ?? "").trim() || "TODO: describe what this plan retires and why
|
|
|
20385
20436
|
const relPath = `${DEPRECATION_PLANS_DIR}/${id}-${slug5(title) || "plan"}.md`;
|
|
20386
20437
|
const filePath = join(dir, relPath);
|
|
20387
20438
|
if (exists(filePath)) throw new DeprecationWriteError("DUPLICATE", `Plan file already exists: ${relPath}`);
|
|
20388
|
-
ensureDir(
|
|
20439
|
+
ensureDir(path11.dirname(filePath));
|
|
20389
20440
|
atomicWrite3(filePath, serialize2(data, body));
|
|
20390
20441
|
return { id, path: relPath, findings: [] };
|
|
20391
20442
|
}
|
|
@@ -20404,7 +20455,7 @@ function addTarget(dir, planId, input) {
|
|
|
20404
20455
|
}
|
|
20405
20456
|
data.targets = [...targets, raw];
|
|
20406
20457
|
atomicWrite3(filePath, serialize2(data, body));
|
|
20407
|
-
return { planId, targetId, path: `${DEPRECATION_PLANS_DIR}/${
|
|
20458
|
+
return { planId, targetId, path: `${DEPRECATION_PLANS_DIR}/${path11.basename(filePath)}`, findings };
|
|
20408
20459
|
}
|
|
20409
20460
|
function updateTarget(dir, planId, targetId, patch) {
|
|
20410
20461
|
const { filePath, data, body } = loadPlanRaw(dir, planId);
|
|
@@ -20420,7 +20471,7 @@ function updateTarget(dir, planId, targetId, patch) {
|
|
|
20420
20471
|
next[idx] = merged;
|
|
20421
20472
|
data.targets = next;
|
|
20422
20473
|
atomicWrite3(filePath, serialize2(data, body));
|
|
20423
|
-
return { planId, targetId: String(targets[idx].id), path: `${DEPRECATION_PLANS_DIR}/${
|
|
20474
|
+
return { planId, targetId: String(targets[idx].id), path: `${DEPRECATION_PLANS_DIR}/${path11.basename(filePath)}`, findings };
|
|
20424
20475
|
}
|
|
20425
20476
|
function removeTarget(dir, planId, targetId, opts = {}) {
|
|
20426
20477
|
const { filePath, data, body } = loadPlanRaw(dir, planId);
|
|
@@ -20433,7 +20484,7 @@ function removeTarget(dir, planId, targetId, opts = {}) {
|
|
|
20433
20484
|
}
|
|
20434
20485
|
data.targets = targets.filter((t) => String(t.id ?? "").toUpperCase() !== targetId.toUpperCase());
|
|
20435
20486
|
atomicWrite3(filePath, serialize2(data, body));
|
|
20436
|
-
return { removed: true, path: `${DEPRECATION_PLANS_DIR}/${
|
|
20487
|
+
return { removed: true, path: `${DEPRECATION_PLANS_DIR}/${path11.basename(filePath)}` };
|
|
20437
20488
|
}
|
|
20438
20489
|
|
|
20439
20490
|
// src/core/deprecation-runbook.ts
|
|
@@ -20516,7 +20567,7 @@ function buildProductionRunbookContext(dir, planId, targetId) {
|
|
|
20516
20567
|
blockers.push(`Dependency ${dependency.id} is not retired (current: ${dependency.lifecycle}).`);
|
|
20517
20568
|
}
|
|
20518
20569
|
}
|
|
20519
|
-
const
|
|
20570
|
+
const path18 = runbookPath(dir, target);
|
|
20520
20571
|
return {
|
|
20521
20572
|
eligible: blockers.length === 0,
|
|
20522
20573
|
plan: { id: plan.id, title: plan.title, purpose: plan.purpose },
|
|
@@ -20524,7 +20575,7 @@ function buildProductionRunbookContext(dir, planId, targetId) {
|
|
|
20524
20575
|
resource: target.resource ? getResource(dir, target.resource) : null,
|
|
20525
20576
|
dependencies,
|
|
20526
20577
|
blockers,
|
|
20527
|
-
nextPath:
|
|
20578
|
+
nextPath: path18,
|
|
20528
20579
|
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."
|
|
20529
20580
|
};
|
|
20530
20581
|
}
|
|
@@ -20617,8 +20668,8 @@ function renderRunbook(context) {
|
|
|
20617
20668
|
function createProductionRunbook(dir, planId, targetId) {
|
|
20618
20669
|
const context = buildProductionRunbookContext(dir, planId, targetId);
|
|
20619
20670
|
if (!context.eligible) throw new ProductionRunbookError(context.blockers.join(" "));
|
|
20620
|
-
const
|
|
20621
|
-
const id =
|
|
20671
|
+
const path18 = context.nextPath;
|
|
20672
|
+
const id = path18.split("/").pop()?.match(/^(RB-\d+)-/)?.[1] ?? "";
|
|
20622
20673
|
const content = matter17.stringify(renderRunbook(context), {
|
|
20623
20674
|
id,
|
|
20624
20675
|
type: PRODUCTION_RUNBOOK_ARTIFACT_TYPE,
|
|
@@ -20628,13 +20679,13 @@ function createProductionRunbook(dir, planId, targetId) {
|
|
|
20628
20679
|
resource: context.target.resource,
|
|
20629
20680
|
approval: { required: true, status: "pending", approved_by: null, approved_at: null }
|
|
20630
20681
|
});
|
|
20631
|
-
const absolute = join(dir,
|
|
20632
|
-
if (exists(absolute)) throw new ProductionRunbookError(`Runbook already exists: ${
|
|
20682
|
+
const absolute = join(dir, path18);
|
|
20683
|
+
if (exists(absolute)) throw new ProductionRunbookError(`Runbook already exists: ${path18}`);
|
|
20633
20684
|
writeFile(absolute, content);
|
|
20634
20685
|
return {
|
|
20635
20686
|
id,
|
|
20636
20687
|
title: `Production runbook \u2014 ${context.target.title ?? context.target.id}`,
|
|
20637
|
-
path:
|
|
20688
|
+
path: path18,
|
|
20638
20689
|
planId: context.plan.id,
|
|
20639
20690
|
targetId: context.target.id,
|
|
20640
20691
|
approval: { required: true, status: "pending", approvedBy: null, approvedAt: null },
|
|
@@ -20645,14 +20696,14 @@ function getProductionRunbook(dir, id) {
|
|
|
20645
20696
|
const root = join(dir, PRODUCTION_RUNBOOKS_DIR);
|
|
20646
20697
|
for (const name of readDir(root)) {
|
|
20647
20698
|
if (!name.toLowerCase().startsWith(`${id.toLowerCase()}-`) || !name.endsWith(".md")) continue;
|
|
20648
|
-
const
|
|
20649
|
-
const parsed = matter17(readFile(join(dir,
|
|
20699
|
+
const path18 = `${PRODUCTION_RUNBOOKS_DIR}/${name}`;
|
|
20700
|
+
const parsed = matter17(readFile(join(dir, path18)));
|
|
20650
20701
|
const data = parsed.data;
|
|
20651
20702
|
if (data.type !== PRODUCTION_RUNBOOK_ARTIFACT_TYPE) continue;
|
|
20652
20703
|
return {
|
|
20653
20704
|
id: stringValue(data.id) ?? id,
|
|
20654
20705
|
title: stringValue(data.title) ?? id,
|
|
20655
|
-
path:
|
|
20706
|
+
path: path18,
|
|
20656
20707
|
planId: stringValue(data.deprecation_plan) ?? "",
|
|
20657
20708
|
targetId: stringValue(data.deprecation_target) ?? "",
|
|
20658
20709
|
approval: parseApproval(data.approval),
|
|
@@ -20991,7 +21042,7 @@ ${runbook.id} \u2014 ${payload.valid ? "valid" : "invalid"}`);
|
|
|
20991
21042
|
|
|
20992
21043
|
// src/core/okf/export.ts
|
|
20993
21044
|
import fs7 from "fs";
|
|
20994
|
-
import
|
|
21045
|
+
import path12 from "path";
|
|
20995
21046
|
|
|
20996
21047
|
// src/core/okf/mapping.ts
|
|
20997
21048
|
import matter18 from "gray-matter";
|
|
@@ -21061,9 +21112,9 @@ function conceptBundlePath(a, id) {
|
|
|
21061
21112
|
return `misc/${file}`;
|
|
21062
21113
|
}
|
|
21063
21114
|
}
|
|
21064
|
-
function workItemRelations(
|
|
21115
|
+
function workItemRelations(fm3) {
|
|
21065
21116
|
const out = [];
|
|
21066
|
-
const resources =
|
|
21117
|
+
const resources = fm3.resources;
|
|
21067
21118
|
if (Array.isArray(resources)) {
|
|
21068
21119
|
for (const r of resources) {
|
|
21069
21120
|
if (r && typeof r === "object") {
|
|
@@ -21072,16 +21123,16 @@ function workItemRelations(fm2) {
|
|
|
21072
21123
|
}
|
|
21073
21124
|
}
|
|
21074
21125
|
}
|
|
21075
|
-
const dep =
|
|
21126
|
+
const dep = fm3.deprecation_targets;
|
|
21076
21127
|
if (Array.isArray(dep)) {
|
|
21077
21128
|
for (const d of dep) {
|
|
21078
21129
|
const s = typeof d === "string" ? d : d && typeof d === "object" ? str3(d.plan) : null;
|
|
21079
21130
|
if (s) out.push({ id: s.includes("/") ? s.split("/")[0] : s, role: "deprecates-via" });
|
|
21080
21131
|
}
|
|
21081
21132
|
}
|
|
21082
|
-
const parent = str3(
|
|
21133
|
+
const parent = str3(fm3.parent);
|
|
21083
21134
|
if (parent) out.push({ id: parent, role: "child-of" });
|
|
21084
|
-
for (const dId of strArray3(
|
|
21135
|
+
for (const dId of strArray3(fm3.decisions)) out.push({ id: dId, role: "decided-by" });
|
|
21085
21136
|
return out;
|
|
21086
21137
|
}
|
|
21087
21138
|
function slugify5(s) {
|
|
@@ -22387,16 +22438,16 @@ function frontmatter(data) {
|
|
|
22387
22438
|
return lines.join("\n");
|
|
22388
22439
|
}
|
|
22389
22440
|
function relLink(fromPath, toPath) {
|
|
22390
|
-
const rel =
|
|
22441
|
+
const rel = path12.posix.relative(path12.posix.dirname(fromPath), toPath);
|
|
22391
22442
|
return rel.startsWith(".") ? rel : `./${rel}`;
|
|
22392
22443
|
}
|
|
22393
22444
|
function rewriteBodyLinks(body, sourcePath, srcToBundle, selfBundlePath) {
|
|
22394
|
-
const srcDir =
|
|
22445
|
+
const srcDir = path12.posix.dirname(sourcePath);
|
|
22395
22446
|
return body.replace(/\]\(([^)]+)\)/g, (whole, href) => {
|
|
22396
22447
|
const raw = href.trim();
|
|
22397
22448
|
const bare = raw.split("#")[0].split(" ")[0];
|
|
22398
22449
|
if (!bare || /^(https?:|mailto:|#)/.test(bare)) return whole;
|
|
22399
|
-
const candidate = bare.startsWith("/") ? bare.replace(/^\/+/, "") :
|
|
22450
|
+
const candidate = bare.startsWith("/") ? bare.replace(/^\/+/, "") : path12.posix.normalize(path12.posix.join(srcDir, bare));
|
|
22400
22451
|
const target = srcToBundle.get(candidate);
|
|
22401
22452
|
if (!target) return whole;
|
|
22402
22453
|
const anchor = raw.includes("#") ? "#" + raw.split("#").slice(1).join("#") : "";
|
|
@@ -22473,22 +22524,22 @@ function sensitiveLabels(content) {
|
|
|
22473
22524
|
return [...new Set(SENSITIVE_PATTERNS.filter((p) => p.re.test(content)).map((p) => p.label))];
|
|
22474
22525
|
}
|
|
22475
22526
|
function assertSafeDestination(dir, outputDir) {
|
|
22476
|
-
const root =
|
|
22477
|
-
const out =
|
|
22527
|
+
const root = path12.resolve(dir);
|
|
22528
|
+
const out = path12.resolve(outputDir);
|
|
22478
22529
|
const within = (child, parent) => {
|
|
22479
|
-
const rel =
|
|
22480
|
-
return rel === "" || !rel.startsWith("..") && !
|
|
22530
|
+
const rel = path12.relative(parent, child);
|
|
22531
|
+
return rel === "" || !rel.startsWith("..") && !path12.isAbsolute(rel);
|
|
22481
22532
|
};
|
|
22482
22533
|
if (out === root) throw new OkfExportError("UNSAFE_DESTINATION", "Refusing to export onto the project root.");
|
|
22483
22534
|
if (within(root, out)) throw new OkfExportError("UNSAFE_DESTINATION", "Refusing to export onto a parent of the project.");
|
|
22484
22535
|
for (const protectedDir of ["knowledge", "packages", "apps", "src", "node_modules", ".git"]) {
|
|
22485
|
-
const p =
|
|
22536
|
+
const p = path12.join(root, protectedDir);
|
|
22486
22537
|
if (out === p || within(out, p)) throw new OkfExportError("UNSAFE_DESTINATION", `Refusing to export into a protected directory: ${protectedDir}/`);
|
|
22487
22538
|
}
|
|
22488
22539
|
if (fs7.existsSync(out)) {
|
|
22489
22540
|
try {
|
|
22490
22541
|
const entries = fs7.readdirSync(out);
|
|
22491
|
-
const looksOkf = entries.includes("index.md") && /okf_version/.test(fs7.readFileSync(
|
|
22542
|
+
const looksOkf = entries.includes("index.md") && /okf_version/.test(fs7.readFileSync(path12.join(out, "index.md"), "utf-8"));
|
|
22492
22543
|
if (entries.length > 0 && !looksOkf) {
|
|
22493
22544
|
throw new OkfExportError("UNSAFE_DESTINATION", `Destination is not empty and is not an OKF bundle: ${outputDir}. Use an empty or dedicated directory.`);
|
|
22494
22545
|
}
|
|
@@ -22513,7 +22564,7 @@ function detectCollisions(concepts) {
|
|
|
22513
22564
|
}
|
|
22514
22565
|
function exportOkf(dir, opts = {}) {
|
|
22515
22566
|
const outRel = opts.output ?? OKF_DEFAULT_OUTPUT;
|
|
22516
|
-
const outputDir =
|
|
22567
|
+
const outputDir = path12.isAbsolute(outRel) ? outRel : path12.join(dir, outRel);
|
|
22517
22568
|
assertSafeDestination(dir, outputDir);
|
|
22518
22569
|
const extraWarnings = [];
|
|
22519
22570
|
const artifacts = discoverKnowledge(dir);
|
|
@@ -22569,7 +22620,7 @@ ${c.body ?? ""}`;
|
|
|
22569
22620
|
const dirs = /* @__PURE__ */ new Map();
|
|
22570
22621
|
const childDirs = /* @__PURE__ */ new Map();
|
|
22571
22622
|
for (const c of concepts) {
|
|
22572
|
-
const d =
|
|
22623
|
+
const d = path12.posix.dirname(c.path);
|
|
22573
22624
|
(dirs.get(d) ?? dirs.set(d, []).get(d)).push(c);
|
|
22574
22625
|
const segs = d === "." ? [] : d.split("/");
|
|
22575
22626
|
for (let i = 0; i < segs.length; i++) {
|
|
@@ -22595,8 +22646,8 @@ ${c.body ?? ""}`;
|
|
|
22595
22646
|
try {
|
|
22596
22647
|
fs7.rmSync(staging, { recursive: true, force: true });
|
|
22597
22648
|
for (const [rel, content] of files) {
|
|
22598
|
-
const full =
|
|
22599
|
-
fs7.mkdirSync(
|
|
22649
|
+
const full = path12.join(staging, rel);
|
|
22650
|
+
fs7.mkdirSync(path12.dirname(full), { recursive: true });
|
|
22600
22651
|
fs7.writeFileSync(full, content, "utf-8");
|
|
22601
22652
|
}
|
|
22602
22653
|
const backup = `${outputDir}.old-${process.pid}-${Date.now()}`;
|
|
@@ -22625,13 +22676,13 @@ ${c.body ?? ""}`;
|
|
|
22625
22676
|
|
|
22626
22677
|
// src/core/okf/validate.ts
|
|
22627
22678
|
import fs8 from "fs";
|
|
22628
|
-
import
|
|
22679
|
+
import path13 from "path";
|
|
22629
22680
|
import matter20 from "gray-matter";
|
|
22630
22681
|
function walk(root) {
|
|
22631
22682
|
const out = [];
|
|
22632
22683
|
const rec = (d) => {
|
|
22633
22684
|
for (const entry of fs8.readdirSync(d)) {
|
|
22634
|
-
const full =
|
|
22685
|
+
const full = path13.join(d, entry);
|
|
22635
22686
|
const st = fs8.statSync(full);
|
|
22636
22687
|
if (st.isDirectory()) rec(full);
|
|
22637
22688
|
else if (entry.endsWith(".md")) out.push(full);
|
|
@@ -22653,24 +22704,24 @@ function internalLinks(body) {
|
|
|
22653
22704
|
}
|
|
22654
22705
|
function validateOkf(dir, opts = {}) {
|
|
22655
22706
|
const loc = opts.location ?? OKF_DEFAULT_OUTPUT;
|
|
22656
|
-
const bundleDir =
|
|
22707
|
+
const bundleDir = path13.isAbsolute(loc) ? loc : path13.join(dir, loc);
|
|
22657
22708
|
const findings = [];
|
|
22658
22709
|
if (!fs8.existsSync(bundleDir)) {
|
|
22659
22710
|
findings.push({ level: "conformance", message: `OKF bundle directory not found: ${loc}. Run \`kaddo okf export\` first.` });
|
|
22660
22711
|
return { dir: bundleDir, conformant: false, conceptCount: 0, findings, counts: { conformance: 1, warning: 0, info: 0 } };
|
|
22661
22712
|
}
|
|
22662
22713
|
const files = walk(bundleDir);
|
|
22663
|
-
const rel = (f) =>
|
|
22714
|
+
const rel = (f) => path13.relative(bundleDir, f).split(path13.sep).join("/");
|
|
22664
22715
|
const present = new Set(files.map(rel));
|
|
22665
22716
|
const idToFile = /* @__PURE__ */ new Map();
|
|
22666
22717
|
let conceptCount = 0;
|
|
22667
|
-
const rootIndex =
|
|
22718
|
+
const rootIndex = path13.join(bundleDir, "index.md");
|
|
22668
22719
|
if (!fs8.existsSync(rootIndex)) {
|
|
22669
22720
|
findings.push({ level: "warning", message: "No root index.md \u2014 the bundle has no top-level navigation entry." });
|
|
22670
22721
|
}
|
|
22671
22722
|
for (const file of files) {
|
|
22672
22723
|
const r = rel(file);
|
|
22673
|
-
const isIndex =
|
|
22724
|
+
const isIndex = path13.basename(file) === "index.md";
|
|
22674
22725
|
let data = {};
|
|
22675
22726
|
try {
|
|
22676
22727
|
data = matter20(fs8.readFileSync(file, "utf-8")).data ?? {};
|
|
@@ -22701,7 +22752,7 @@ function validateOkf(dir, opts = {}) {
|
|
|
22701
22752
|
}
|
|
22702
22753
|
})();
|
|
22703
22754
|
for (const href of internalLinks(body)) {
|
|
22704
|
-
const resolved =
|
|
22755
|
+
const resolved = path13.posix.normalize(path13.posix.join(path13.posix.dirname(r), href));
|
|
22705
22756
|
if (!present.has(resolved)) findings.push({ level: "info", file: r, message: `Internal link not resolvable yet: ${href}` });
|
|
22706
22757
|
}
|
|
22707
22758
|
}
|
|
@@ -22771,7 +22822,7 @@ import { parse as parseYaml19, stringify as stringifyYaml10 } from "yaml";
|
|
|
22771
22822
|
|
|
22772
22823
|
// src/core/work-item-write.ts
|
|
22773
22824
|
import fs9 from "fs";
|
|
22774
|
-
import
|
|
22825
|
+
import path14 from "path";
|
|
22775
22826
|
import crypto2 from "crypto";
|
|
22776
22827
|
import matter21 from "gray-matter";
|
|
22777
22828
|
var WORK_ITEMS_DIR3 = "knowledge/delivery/work-items";
|
|
@@ -22783,7 +22834,8 @@ var WorkItemWriteError = class extends Error {
|
|
|
22783
22834
|
}
|
|
22784
22835
|
code;
|
|
22785
22836
|
};
|
|
22786
|
-
|
|
22837
|
+
var EDITABLE_STATES = ["draft"];
|
|
22838
|
+
function revisionOf2(raw) {
|
|
22787
22839
|
return crypto2.createHash("sha256").update(raw, "utf-8").digest("hex");
|
|
22788
22840
|
}
|
|
22789
22841
|
function slugify6(s) {
|
|
@@ -22808,7 +22860,7 @@ function nextWorkItemId2(dir) {
|
|
|
22808
22860
|
return `WI-${String(max + 1).padStart(3, "0")}`;
|
|
22809
22861
|
}
|
|
22810
22862
|
function atomicWrite4(filePath, content) {
|
|
22811
|
-
fs9.mkdirSync(
|
|
22863
|
+
fs9.mkdirSync(path14.dirname(filePath), { recursive: true });
|
|
22812
22864
|
const tmp = `${filePath}.${process.pid}.${Date.now()}.tmp`;
|
|
22813
22865
|
fs9.writeFileSync(tmp, content, "utf-8");
|
|
22814
22866
|
try {
|
|
@@ -22821,6 +22873,16 @@ function atomicWrite4(filePath, content) {
|
|
|
22821
22873
|
throw err;
|
|
22822
22874
|
}
|
|
22823
22875
|
}
|
|
22876
|
+
function findArtifact(dir, id) {
|
|
22877
|
+
const match = discoverWorkItems(dir).find((a) => (a.id || a.title) === id);
|
|
22878
|
+
if (!match) throw new WorkItemWriteError("WORK_ITEM_NOT_FOUND", `Work Item "${id}" was not found.`);
|
|
22879
|
+
return { filePath: match.filePath, relPath: match.relPath };
|
|
22880
|
+
}
|
|
22881
|
+
function validModuleIds(dir) {
|
|
22882
|
+
const ids = /* @__PURE__ */ new Set(["core"]);
|
|
22883
|
+
for (const m of loadMappedModules(dir)) ids.add(m.id);
|
|
22884
|
+
return ids;
|
|
22885
|
+
}
|
|
22824
22886
|
var SECTION_ORDER = [
|
|
22825
22887
|
"Actor",
|
|
22826
22888
|
"Outcome",
|
|
@@ -22832,6 +22894,35 @@ var SECTION_ORDER = [
|
|
|
22832
22894
|
"Acceptance criteria"
|
|
22833
22895
|
];
|
|
22834
22896
|
var KNOWN_HEADINGS = new Set(SECTION_ORDER.map((s) => s.toLowerCase()));
|
|
22897
|
+
function parseBody(content) {
|
|
22898
|
+
const lines = content.split(/\r?\n/);
|
|
22899
|
+
const preamble = [];
|
|
22900
|
+
const sections = [];
|
|
22901
|
+
let current = null;
|
|
22902
|
+
let buffer = [];
|
|
22903
|
+
let seenHeading = false;
|
|
22904
|
+
const flush2 = () => {
|
|
22905
|
+
if (current) {
|
|
22906
|
+
current.body = buffer.join("\n").trim();
|
|
22907
|
+
sections.push(current);
|
|
22908
|
+
}
|
|
22909
|
+
buffer = [];
|
|
22910
|
+
};
|
|
22911
|
+
for (const line of lines) {
|
|
22912
|
+
const m = line.match(/^##\s+(.*?)\s*$/);
|
|
22913
|
+
if (m) {
|
|
22914
|
+
seenHeading = true;
|
|
22915
|
+
flush2();
|
|
22916
|
+
current = { heading: m[1].trim(), normalized: m[1].trim().toLowerCase(), body: "" };
|
|
22917
|
+
} else if (!seenHeading) {
|
|
22918
|
+
preamble.push(line);
|
|
22919
|
+
} else {
|
|
22920
|
+
buffer.push(line);
|
|
22921
|
+
}
|
|
22922
|
+
}
|
|
22923
|
+
flush2();
|
|
22924
|
+
return { preamble, sections };
|
|
22925
|
+
}
|
|
22835
22926
|
function renderList(items) {
|
|
22836
22927
|
return items.map((i) => `- ${i.trim()}`).filter((l) => l.trim() !== "-").join("\n");
|
|
22837
22928
|
}
|
|
@@ -22881,6 +22972,77 @@ function serialize3(data, body) {
|
|
|
22881
22972
|
${body.trim()}
|
|
22882
22973
|
`, data);
|
|
22883
22974
|
}
|
|
22975
|
+
function toInput(data, content) {
|
|
22976
|
+
const { sections } = parseBody(content);
|
|
22977
|
+
const sec = (name) => {
|
|
22978
|
+
const s = sections.find((x) => x.normalized === name);
|
|
22979
|
+
return s && s.body.trim() ? s.body.trim() : void 0;
|
|
22980
|
+
};
|
|
22981
|
+
const bullets = (name) => {
|
|
22982
|
+
const body = sec(name);
|
|
22983
|
+
if (!body) return [];
|
|
22984
|
+
return body.split(/\r?\n/).map((l) => l.replace(/^\s*[-*+]\s+(\[[ xX]\]\s*)?/, "").trim()).filter(Boolean);
|
|
22985
|
+
};
|
|
22986
|
+
const criteria = (() => {
|
|
22987
|
+
const body = sec("acceptance criteria");
|
|
22988
|
+
if (!body) return [];
|
|
22989
|
+
const out = [];
|
|
22990
|
+
for (const line of body.split(/\r?\n/)) {
|
|
22991
|
+
const m = line.match(/^\s*[-*+]\s+(.*)$/);
|
|
22992
|
+
if (!m) continue;
|
|
22993
|
+
let text2 = m[1].trim();
|
|
22994
|
+
let checked = null;
|
|
22995
|
+
const cb = text2.match(/^\[([ xX])\]\s*(.*)$/);
|
|
22996
|
+
if (cb) {
|
|
22997
|
+
checked = cb[1].toLowerCase() === "x";
|
|
22998
|
+
text2 = cb[2].trim();
|
|
22999
|
+
}
|
|
23000
|
+
if (text2) out.push({ text: text2, checked });
|
|
23001
|
+
}
|
|
23002
|
+
return out;
|
|
23003
|
+
})();
|
|
23004
|
+
const sc = data.scope_confidence;
|
|
23005
|
+
const mc = data.module_coverage;
|
|
23006
|
+
const ia = data.impact_analysis?.surfaces;
|
|
23007
|
+
return {
|
|
23008
|
+
title: String(data.title ?? ""),
|
|
23009
|
+
type: String(data.type ?? "feature"),
|
|
23010
|
+
summary: data.summary ? String(data.summary) : void 0,
|
|
23011
|
+
actor: sec("actor"),
|
|
23012
|
+
outcome: sec("outcome"),
|
|
23013
|
+
currentBehavior: sec("current behavior"),
|
|
23014
|
+
targetBehavior: sec("target behavior"),
|
|
23015
|
+
entryPoints: sec("entry points"),
|
|
23016
|
+
endToEndFlow: sec("end-to-end flow"),
|
|
23017
|
+
scopeConfidence: sc && sc.level ? { level: String(sc.level), reasons: Array.isArray(sc.reasons) ? sc.reasons.map(String) : [] } : null,
|
|
23018
|
+
scopeUnknowns: bullets("scope unknowns"),
|
|
23019
|
+
affectedModules: Array.isArray(data.affected_modules) ? data.affected_modules.map(String) : [],
|
|
23020
|
+
moduleCoverage: mc ? Object.entries(mc).map(([id, v]) => ({ id, status: String(v.status ?? ""), ...v.reason ? { reason: String(v.reason) } : {} })) : [],
|
|
23021
|
+
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) } : {} })) : [],
|
|
23022
|
+
acceptanceCriteria: criteria,
|
|
23023
|
+
decisions: Array.isArray(data.decisions) ? data.decisions.map(String) : [],
|
|
23024
|
+
relatedKnowledge: Array.isArray(data.related_knowledge) ? data.related_knowledge.map(String) : [],
|
|
23025
|
+
owners: Array.isArray(data.owners) ? data.owners.map(String) : [],
|
|
23026
|
+
contributors: Array.isArray(data.contributors) ? data.contributors.map(String) : []
|
|
23027
|
+
};
|
|
23028
|
+
}
|
|
23029
|
+
function getWorkItemForEdit(dir, id) {
|
|
23030
|
+
const { filePath, relPath } = findArtifact(dir, id);
|
|
23031
|
+
const raw = readFile(filePath);
|
|
23032
|
+
const { data, content } = matter21(raw);
|
|
23033
|
+
const status = lifecycleStateOf({ status: String(data.status ?? ""), filePath });
|
|
23034
|
+
const input = toInput(data, content);
|
|
23035
|
+
const editable = EDITABLE_STATES.includes(status);
|
|
23036
|
+
return {
|
|
23037
|
+
...input,
|
|
23038
|
+
id,
|
|
23039
|
+
status,
|
|
23040
|
+
revision: revisionOf2(raw),
|
|
23041
|
+
path: relPath,
|
|
23042
|
+
editable,
|
|
23043
|
+
...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.` }
|
|
23044
|
+
};
|
|
23045
|
+
}
|
|
22884
23046
|
var CAPTURE_SECTIONS = [
|
|
22885
23047
|
{ field: "problem", heading: "Problem" },
|
|
22886
23048
|
{ field: "expected_result", heading: "Expected result" },
|
|
@@ -22910,7 +23072,7 @@ function createWorkItem(dir, opts) {
|
|
|
22910
23072
|
if (!type) throw new WorkItemWriteError("INVALID_INPUT", `Unknown Work Item type "${opts.type}".`);
|
|
22911
23073
|
const id = nextWorkItemId2(dir);
|
|
22912
23074
|
const title = intent.split(/\r?\n/)[0].trim().slice(0, 120);
|
|
22913
|
-
const
|
|
23075
|
+
const today4 = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
22914
23076
|
const summary = opts.summary?.trim() || intent;
|
|
22915
23077
|
const source2 = opts.source ? { ...opts.source, inferred: false } : { type: "manual", inferred: false };
|
|
22916
23078
|
const data = {
|
|
@@ -22919,7 +23081,7 @@ function createWorkItem(dir, opts) {
|
|
|
22919
23081
|
title,
|
|
22920
23082
|
status: "draft",
|
|
22921
23083
|
work_type: type,
|
|
22922
|
-
created_at:
|
|
23084
|
+
created_at: today4,
|
|
22923
23085
|
source: source2,
|
|
22924
23086
|
generated_by: "kaddo-admin",
|
|
22925
23087
|
affected_modules: [],
|
|
@@ -22947,7 +23109,86 @@ function createWorkItem(dir, opts) {
|
|
|
22947
23109
|
if (exists(filePath)) throw new WorkItemWriteError("INVALID_INPUT", `Work Item file already exists: ${relPath}`);
|
|
22948
23110
|
const raw = serialize3(data, body);
|
|
22949
23111
|
atomicWrite4(filePath, raw);
|
|
22950
|
-
return { id, path: relPath, revision:
|
|
23112
|
+
return { id, path: relPath, revision: revisionOf2(raw) };
|
|
23113
|
+
}
|
|
23114
|
+
function validateWorkItem(dir, id) {
|
|
23115
|
+
const { filePath } = findArtifact(dir, id);
|
|
23116
|
+
const raw = readFile(filePath);
|
|
23117
|
+
const { data, content } = matter21(raw);
|
|
23118
|
+
const input = toInput(data, content);
|
|
23119
|
+
const findings = [];
|
|
23120
|
+
const modules = validModuleIds(dir);
|
|
23121
|
+
for (const c of input.moduleCoverage) {
|
|
23122
|
+
if (c.status === "affected" && !input.affectedModules.includes(c.id)) {
|
|
23123
|
+
findings.push({ level: "blocking", message: `${c.id} is marked affected in module coverage but is missing from affected_modules.` });
|
|
23124
|
+
}
|
|
23125
|
+
}
|
|
23126
|
+
for (const m of input.affectedModules) {
|
|
23127
|
+
if (!modules.has(m)) findings.push({ level: "blocking", message: `Module "${m}" is not registered in this project.` });
|
|
23128
|
+
}
|
|
23129
|
+
if (!input.targetBehavior?.trim()) findings.push({ level: "warning", message: "Target behavior is not defined." });
|
|
23130
|
+
if (input.acceptanceCriteria.length === 0) findings.push({ level: "warning", message: "No acceptance criteria have been defined." });
|
|
23131
|
+
if (input.scopeConfidence?.level === "low") findings.push({ level: "warning", message: "Scope confidence is Low." });
|
|
23132
|
+
if (!input.scopeConfidence) findings.push({ level: "warning", message: "Scope confidence has not been assessed." });
|
|
23133
|
+
for (const c of input.moduleCoverage) {
|
|
23134
|
+
if (c.status === "reviewed-not-affected") findings.push({ level: "fyi", message: `${c.id} was reviewed and is not affected.` });
|
|
23135
|
+
}
|
|
23136
|
+
for (const s of input.impactAnalysis) {
|
|
23137
|
+
if (s.status === "unknown") findings.push({ level: "fyi", message: `Impact on ${s.surface} is unknown.` });
|
|
23138
|
+
}
|
|
23139
|
+
const topology = loadSystemTopology(dir);
|
|
23140
|
+
const entityById = new Map(topology.entities.map((e) => [e.id, e]));
|
|
23141
|
+
const fm3 = data;
|
|
23142
|
+
const idOf = (raw2) => typeof raw2 === "string" ? raw2 : raw2 && typeof raw2 === "object" ? String(raw2.id ?? "") : "";
|
|
23143
|
+
const affectedEntities = Array.isArray(fm3.affected_system_entities) ? fm3.affected_system_entities.map(idOf).filter(Boolean) : [];
|
|
23144
|
+
for (const eid of affectedEntities) {
|
|
23145
|
+
const e = entityById.get(eid);
|
|
23146
|
+
if (!e) {
|
|
23147
|
+
findings.push({ level: "blocking", message: `Affected system entity "${eid}" does not exist in the semantic topology.` });
|
|
23148
|
+
continue;
|
|
23149
|
+
}
|
|
23150
|
+
if (e.moduleId && !input.affectedModules.includes(e.moduleId)) {
|
|
23151
|
+
findings.push({ level: "warning", message: `System entity "${e.label}" belongs to module "${e.moduleId}", which is not in affected_modules.` });
|
|
23152
|
+
}
|
|
23153
|
+
}
|
|
23154
|
+
if (Array.isArray(fm3.reviewed_system_entities)) {
|
|
23155
|
+
for (const r of fm3.reviewed_system_entities) {
|
|
23156
|
+
const rid = r && typeof r === "object" ? String(r.id ?? "") : "";
|
|
23157
|
+
if (rid && !entityById.has(rid)) findings.push({ level: "warning", message: `Reviewed system entity "${rid}" does not exist in the semantic topology.` });
|
|
23158
|
+
}
|
|
23159
|
+
}
|
|
23160
|
+
const canMarkReady = !findings.some((f) => f.level === "blocking");
|
|
23161
|
+
return { findings, canMarkReady };
|
|
23162
|
+
}
|
|
23163
|
+
var ALLOWED = { draft: ["ready"], ready: ["draft", "in-progress"] };
|
|
23164
|
+
function transitionWorkItem(dir, id, to, expectedRevision) {
|
|
23165
|
+
const { filePath } = findArtifact(dir, id);
|
|
23166
|
+
const raw = readFile(filePath);
|
|
23167
|
+
if (revisionOf2(raw) !== expectedRevision) {
|
|
23168
|
+
throw new WorkItemWriteError("WORK_ITEM_CONFLICT", "This Work Item changed outside Kaddo Admin. Reload the latest version before continuing.");
|
|
23169
|
+
}
|
|
23170
|
+
const { data, content } = matter21(raw);
|
|
23171
|
+
const from = lifecycleStateOf({ status: String(data.status ?? ""), filePath });
|
|
23172
|
+
if (!(ALLOWED[from] ?? []).includes(to)) {
|
|
23173
|
+
throw new WorkItemWriteError("INVALID_TRANSITION", `Cannot transition a ${from} Work Item to ${to}.`);
|
|
23174
|
+
}
|
|
23175
|
+
if (to === "ready") {
|
|
23176
|
+
const { canMarkReady } = validateWorkItem(dir, id);
|
|
23177
|
+
if (!canMarkReady) throw new WorkItemWriteError("INVALID_TRANSITION", "This Work Item has blocking issues and cannot be marked Ready.");
|
|
23178
|
+
}
|
|
23179
|
+
const nextData = { ...data, status: to };
|
|
23180
|
+
const nextRaw = serialize3(nextData, content);
|
|
23181
|
+
const filename = path14.basename(filePath);
|
|
23182
|
+
const targetRel = `${WORK_ITEMS_DIR3}/${to}/${filename}`;
|
|
23183
|
+
const targetPath = join(dir, targetRel);
|
|
23184
|
+
atomicWrite4(targetPath, nextRaw);
|
|
23185
|
+
if (path14.resolve(targetPath) !== path14.resolve(filePath)) {
|
|
23186
|
+
try {
|
|
23187
|
+
fs9.rmSync(filePath, { force: true });
|
|
23188
|
+
} catch {
|
|
23189
|
+
}
|
|
23190
|
+
}
|
|
23191
|
+
return { revision: revisionOf2(nextRaw), status: to, path: targetRel };
|
|
22951
23192
|
}
|
|
22952
23193
|
|
|
22953
23194
|
// ../integrations/src/errors.ts
|
|
@@ -23634,8 +23875,8 @@ async function handleJiraResponse(res) {
|
|
|
23634
23875
|
}
|
|
23635
23876
|
return await res.json();
|
|
23636
23877
|
}
|
|
23637
|
-
async function jiraFetch(baseUrl,
|
|
23638
|
-
const url = new URL(
|
|
23878
|
+
async function jiraFetch(baseUrl, path18, auth, timeoutMs, params) {
|
|
23879
|
+
const url = new URL(path18, baseUrl + "/");
|
|
23639
23880
|
if (params) for (const [k, v] of Object.entries(params)) url.searchParams.set(k, v);
|
|
23640
23881
|
const controller = new AbortController();
|
|
23641
23882
|
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
@@ -23653,8 +23894,8 @@ async function jiraFetch(baseUrl, path16, auth, timeoutMs, params) {
|
|
|
23653
23894
|
clearTimeout(timer);
|
|
23654
23895
|
}
|
|
23655
23896
|
}
|
|
23656
|
-
async function jiraPost(baseUrl,
|
|
23657
|
-
const url = new URL(
|
|
23897
|
+
async function jiraPost(baseUrl, path18, auth, timeoutMs, body) {
|
|
23898
|
+
const url = new URL(path18, baseUrl + "/");
|
|
23658
23899
|
const controller = new AbortController();
|
|
23659
23900
|
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
23660
23901
|
try {
|
|
@@ -24609,7 +24850,7 @@ function runAssetsUpdate(kind, opts = {}) {
|
|
|
24609
24850
|
|
|
24610
24851
|
// src/commands/ready.ts
|
|
24611
24852
|
import fs11 from "fs";
|
|
24612
|
-
import
|
|
24853
|
+
import path15 from "path";
|
|
24613
24854
|
import matter23 from "gray-matter";
|
|
24614
24855
|
function validateReadiness(content, frontmatter2) {
|
|
24615
24856
|
const warnings = [];
|
|
@@ -24665,17 +24906,17 @@ function isResolvedSection(text2) {
|
|
|
24665
24906
|
function transitionToReady(filePath) {
|
|
24666
24907
|
const raw = readFile(filePath);
|
|
24667
24908
|
const { data, content } = matter23(raw);
|
|
24668
|
-
const
|
|
24909
|
+
const today4 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
24669
24910
|
data.status = "ready";
|
|
24670
|
-
data.ready_at =
|
|
24911
|
+
data.ready_at = today4;
|
|
24671
24912
|
const newContent = matter23.stringify(content, data);
|
|
24672
24913
|
const posix2 = filePath.replace(/\\/g, "/");
|
|
24673
24914
|
let newPath = filePath;
|
|
24674
24915
|
if (posix2.includes("/work-items/draft/")) {
|
|
24675
|
-
const readyDir =
|
|
24916
|
+
const readyDir = path15.dirname(filePath).replace(/[/\\]draft$/, path15.sep + "ready");
|
|
24676
24917
|
ensureDir(readyDir);
|
|
24677
|
-
const fileName =
|
|
24678
|
-
newPath =
|
|
24918
|
+
const fileName = path15.basename(filePath);
|
|
24919
|
+
newPath = path15.join(readyDir, fileName);
|
|
24679
24920
|
}
|
|
24680
24921
|
return { newPath, newContent };
|
|
24681
24922
|
}
|
|
@@ -24746,8 +24987,8 @@ async function runReady(id, opts = {}) {
|
|
|
24746
24987
|
fs11.unlinkSync(wi.filePath);
|
|
24747
24988
|
log.success(`Updated status: ready`);
|
|
24748
24989
|
log.success(`Moved file:`);
|
|
24749
|
-
log.info(` ${
|
|
24750
|
-
log.info(` \u2192 ${
|
|
24990
|
+
log.info(` ${path15.relative(dir, wi.filePath)}`);
|
|
24991
|
+
log.info(` \u2192 ${path15.relative(dir, newPath)}`);
|
|
24751
24992
|
} else {
|
|
24752
24993
|
writeFile(wi.filePath, newContent);
|
|
24753
24994
|
log.success(`Updated status: ready`);
|
|
@@ -24757,8 +24998,36 @@ async function runReady(id, opts = {}) {
|
|
|
24757
24998
|
outro(`Work Item ${wi.id} is ready.`);
|
|
24758
24999
|
}
|
|
24759
25000
|
|
|
25001
|
+
// src/commands/start.ts
|
|
25002
|
+
async function runStart(id, opts = {}) {
|
|
25003
|
+
intro(`kaddo start ${id}`);
|
|
25004
|
+
let edit;
|
|
25005
|
+
try {
|
|
25006
|
+
edit = getWorkItemForEdit(process.cwd(), id);
|
|
25007
|
+
} catch (error) {
|
|
25008
|
+
log.error(error.message);
|
|
25009
|
+
return;
|
|
25010
|
+
}
|
|
25011
|
+
if (edit.status !== "ready") {
|
|
25012
|
+
log.error(`Work Item ${id} is "${edit.status}". Only ready Work Items can be started.`);
|
|
25013
|
+
return;
|
|
25014
|
+
}
|
|
25015
|
+
if (!opts.yes && !await confirm({ message: "Start implementation and move this Work Item to in-progress?" })) {
|
|
25016
|
+
cancel("Cancelled.");
|
|
25017
|
+
return;
|
|
25018
|
+
}
|
|
25019
|
+
try {
|
|
25020
|
+
const result = transitionWorkItem(process.cwd(), id, "in-progress", edit.revision);
|
|
25021
|
+
log.success(`Updated status: ${result.status}`);
|
|
25022
|
+
log.success(`Moved file: ${result.path}`);
|
|
25023
|
+
outro(`Work Item ${id} is in progress.`);
|
|
25024
|
+
} catch (error) {
|
|
25025
|
+
log.error(error instanceof WorkItemWriteError ? error.message : error.message);
|
|
25026
|
+
}
|
|
25027
|
+
}
|
|
25028
|
+
|
|
24760
25029
|
// src/commands/admin.ts
|
|
24761
|
-
import
|
|
25030
|
+
import path16 from "path";
|
|
24762
25031
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
24763
25032
|
import net from "net";
|
|
24764
25033
|
function isPortAvailable(port, host) {
|
|
@@ -24773,17 +25042,17 @@ function isPortAvailable(port, host) {
|
|
|
24773
25042
|
});
|
|
24774
25043
|
}
|
|
24775
25044
|
function resolveStaticDir() {
|
|
24776
|
-
const __dirname =
|
|
25045
|
+
const __dirname = path16.dirname(fileURLToPath2(import.meta.url));
|
|
24777
25046
|
const candidates = [
|
|
24778
25047
|
// Monorepo development: prefer the freshly built admin over the copy bundled into the CLI dist.
|
|
24779
25048
|
// The CLI build copies admin/dist into dist/admin-dist, but that copy can be stale when the admin
|
|
24780
25049
|
// was rebuilt after the CLI (build order is not guaranteed in `pnpm -r build`). Serving the admin
|
|
24781
25050
|
// package's own dist first ensures `kaddo admin` always shows the current frontend in dev. This
|
|
24782
25051
|
// path does not exist in a published npm install (admin is private), so it falls back below.
|
|
24783
|
-
|
|
24784
|
-
|
|
25052
|
+
path16.resolve(__dirname, "..", "..", "admin", "dist"),
|
|
25053
|
+
path16.resolve(__dirname, "..", "node_modules", "@kaddo", "admin", "dist"),
|
|
24785
25054
|
// Bundled inside CLI dist (npm install)
|
|
24786
|
-
|
|
25055
|
+
path16.resolve(__dirname, "admin-dist")
|
|
24787
25056
|
];
|
|
24788
25057
|
for (const c of candidates) {
|
|
24789
25058
|
if (exists(join(c, "index.html"))) return c;
|
|
@@ -24825,8 +25094,8 @@ async function runAdmin(opts = {}) {
|
|
|
24825
25094
|
}
|
|
24826
25095
|
let adminServer;
|
|
24827
25096
|
try {
|
|
24828
|
-
const __dirname =
|
|
24829
|
-
const bundled =
|
|
25097
|
+
const __dirname = path16.dirname(fileURLToPath2(import.meta.url));
|
|
25098
|
+
const bundled = path16.resolve(__dirname, "admin-server", "index.js");
|
|
24830
25099
|
if (exists(bundled)) {
|
|
24831
25100
|
const { pathToFileURL } = await import("url");
|
|
24832
25101
|
adminServer = await import(pathToFileURL(bundled).href);
|
|
@@ -24918,7 +25187,9 @@ function toListItem(a) {
|
|
|
24918
25187
|
releaseStatus: a.releaseStatus || null,
|
|
24919
25188
|
affectedModules: a.affectedModules,
|
|
24920
25189
|
scopeConfidenceLevel: a.scopeConfidence?.level ?? null,
|
|
24921
|
-
initiative: a.initiative || null
|
|
25190
|
+
initiative: a.initiative || null,
|
|
25191
|
+
owners: Array.isArray(a.rawFrontmatter.owners) ? a.rawFrontmatter.owners.map(String).filter(Boolean) : [],
|
|
25192
|
+
contributors: Array.isArray(a.rawFrontmatter.contributors) ? a.rawFrontmatter.contributors.map(String).filter(Boolean) : []
|
|
24922
25193
|
};
|
|
24923
25194
|
}
|
|
24924
25195
|
function getWorkItem(dir, workItemId) {
|
|
@@ -24928,7 +25199,7 @@ function getWorkItem(dir, workItemId) {
|
|
|
24928
25199
|
const base = toListItem(match);
|
|
24929
25200
|
const body = readBody2(match.filePath);
|
|
24930
25201
|
const sections = splitSections(body);
|
|
24931
|
-
const
|
|
25202
|
+
const fm3 = match.rawFrontmatter;
|
|
24932
25203
|
const knowledge = discoverKnowledge(dir).filter((a) => !a.isWorkItem);
|
|
24933
25204
|
const knowledgeById = new Map(knowledge.filter((k) => k.id).map((k) => [k.id, k]));
|
|
24934
25205
|
const detail = {
|
|
@@ -24945,21 +25216,21 @@ function getWorkItem(dir, workItemId) {
|
|
|
24945
25216
|
moduleCoverage: normalizeCoverage(match.moduleCoverage),
|
|
24946
25217
|
impactAnalysis: normalizeImpact(match.impactAnalysis),
|
|
24947
25218
|
acceptanceCriteria: parseAcceptanceCriteria(sections),
|
|
24948
|
-
implementationEvidence: parseEvidence(
|
|
24949
|
-
releaseGates: parseReleaseGates(
|
|
24950
|
-
completionExceptions: parseExceptions(
|
|
25219
|
+
implementationEvidence: parseEvidence(fm3),
|
|
25220
|
+
releaseGates: parseReleaseGates(fm3),
|
|
25221
|
+
completionExceptions: parseExceptions(fm3),
|
|
24951
25222
|
decisions: parseDecisions(match.decisions, knowledgeById),
|
|
24952
|
-
relatedKnowledge: parseRelatedKnowledge(
|
|
24953
|
-
source: parseWorkItemSource(
|
|
24954
|
-
originalSnapshot: parseOriginalSnapshot(
|
|
25223
|
+
relatedKnowledge: parseRelatedKnowledge(fm3, knowledgeById),
|
|
25224
|
+
source: parseWorkItemSource(fm3),
|
|
25225
|
+
originalSnapshot: parseOriginalSnapshot(fm3),
|
|
24955
25226
|
path: match.relPath,
|
|
24956
25227
|
// Faithful source of truth: the artifact body already read above, not reconstructed (WI-025).
|
|
24957
25228
|
markdownBody: body.trim(),
|
|
24958
25229
|
// External systems this WI relates to (WI-030), separate from affectedModules (code).
|
|
24959
|
-
resources: parseWorkItemResources(
|
|
25230
|
+
resources: parseWorkItemResources(fm3),
|
|
24960
25231
|
// Deprecation Targets this WI retires (WI-050), referenced not copied.
|
|
24961
|
-
deprecationTargets: parseWorkItemDeprecationTargets(
|
|
24962
|
-
...parseSystemImpact(dir,
|
|
25232
|
+
deprecationTargets: parseWorkItemDeprecationTargets(fm3),
|
|
25233
|
+
...parseSystemImpact(dir, fm3)
|
|
24963
25234
|
};
|
|
24964
25235
|
return { ...detail, refinement: computeRefinementStatus(detail) };
|
|
24965
25236
|
}
|
|
@@ -24967,8 +25238,8 @@ function parseGraphReason(v) {
|
|
|
24967
25238
|
if (!v || typeof v !== "object") return null;
|
|
24968
25239
|
const o = v;
|
|
24969
25240
|
const relationship = typeof o.relationship === "string" && o.relationship.trim() ? o.relationship.trim() : null;
|
|
24970
|
-
const
|
|
24971
|
-
return relationship ||
|
|
25241
|
+
const path18 = Array.isArray(o.path) ? o.path.map(String).filter(Boolean) : [];
|
|
25242
|
+
return relationship || path18.length ? { relationship, path: path18 } : null;
|
|
24972
25243
|
}
|
|
24973
25244
|
function parseExplain(o) {
|
|
24974
25245
|
const refs = Array.isArray(o.evidence) ? o.evidence : Array.isArray(o.evidence_refs) ? o.evidence_refs : [];
|
|
@@ -24982,14 +25253,14 @@ function parseExplain(o) {
|
|
|
24982
25253
|
function emptyExplain() {
|
|
24983
25254
|
return { reason: null, graphReason: null, evidenceRefs: [], evidenceSummary: null };
|
|
24984
25255
|
}
|
|
24985
|
-
function parseSystemImpact(dir,
|
|
25256
|
+
function parseSystemImpact(dir, fm3) {
|
|
24986
25257
|
const topology = loadSystemTopology(dir);
|
|
24987
25258
|
const byId = new Map(topology.entities.map((e) => [e.id, e]));
|
|
24988
25259
|
const resolve = (id) => {
|
|
24989
25260
|
const e = byId.get(id);
|
|
24990
25261
|
return { id, nodeId: `sys:${id}`, label: e?.label ?? id, kind: e?.kind ?? "unknown", moduleId: e?.moduleId ?? null };
|
|
24991
25262
|
};
|
|
24992
|
-
const affected = Array.isArray(
|
|
25263
|
+
const affected = Array.isArray(fm3.affected_system_entities) ? fm3.affected_system_entities.map((raw) => {
|
|
24993
25264
|
if (typeof raw === "string") return raw ? { ...resolve(raw), ...emptyExplain() } : null;
|
|
24994
25265
|
if (raw && typeof raw === "object") {
|
|
24995
25266
|
const o = raw;
|
|
@@ -24998,13 +25269,13 @@ function parseSystemImpact(dir, fm2) {
|
|
|
24998
25269
|
}
|
|
24999
25270
|
return null;
|
|
25000
25271
|
}).filter((e) => e != null) : [];
|
|
25001
|
-
const reviewed = Array.isArray(
|
|
25002
|
-
const graphRevision = typeof
|
|
25272
|
+
const reviewed = Array.isArray(fm3.reviewed_system_entities) ? fm3.reviewed_system_entities.filter((r) => Boolean(r) && typeof r === "object").map((r) => ({ ...resolve(String(r.id ?? "")), ...parseExplain(r), status: String(r.status ?? "unknown") })).filter((r) => r.id) : [];
|
|
25273
|
+
const graphRevision = typeof fm3.graph_revision === "string" && fm3.graph_revision.trim() ? fm3.graph_revision.trim() : null;
|
|
25003
25274
|
const graphCoverage = topology.entities.length === 0 ? "unavailable" : topology.relationships.length > 0 ? "available" : "partial";
|
|
25004
25275
|
return { affectedSystemEntities: affected, reviewedSystemEntities: reviewed, graphRevision, graphCoverage };
|
|
25005
25276
|
}
|
|
25006
|
-
function parseOriginalSnapshot(
|
|
25007
|
-
const raw =
|
|
25277
|
+
function parseOriginalSnapshot(fm3) {
|
|
25278
|
+
const raw = fm3.original_snapshot;
|
|
25008
25279
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
25009
25280
|
const o = raw;
|
|
25010
25281
|
const title = typeof o.title === "string" ? o.title : void 0;
|
|
@@ -25111,8 +25382,8 @@ function optStr4(v) {
|
|
|
25111
25382
|
if (typeof v === "string" && v.trim()) return v.trim();
|
|
25112
25383
|
return void 0;
|
|
25113
25384
|
}
|
|
25114
|
-
function parseEvidence(
|
|
25115
|
-
const evidence =
|
|
25385
|
+
function parseEvidence(fm3) {
|
|
25386
|
+
const evidence = fm3.implementation_evidence;
|
|
25116
25387
|
const repos = evidence?.repositories;
|
|
25117
25388
|
if (!repos || typeof repos !== "object" || Array.isArray(repos)) return [];
|
|
25118
25389
|
const out = [];
|
|
@@ -25141,18 +25412,18 @@ function parseEvidence(fm2) {
|
|
|
25141
25412
|
}
|
|
25142
25413
|
return out;
|
|
25143
25414
|
}
|
|
25144
|
-
function parseReleaseGates(
|
|
25145
|
-
if (!Array.isArray(
|
|
25146
|
-
return
|
|
25415
|
+
function parseReleaseGates(fm3) {
|
|
25416
|
+
if (!Array.isArray(fm3.release_gates)) return [];
|
|
25417
|
+
return fm3.release_gates.filter((g) => g && typeof g === "object").map((g) => ({
|
|
25147
25418
|
id: String(g.id ?? ""),
|
|
25148
25419
|
status: String(g.status ?? "pending"),
|
|
25149
25420
|
...optStr4(g.reason) ? { reason: optStr4(g.reason) } : {},
|
|
25150
25421
|
...optStr4(g.required_for) ? { requiredFor: optStr4(g.required_for) } : {}
|
|
25151
25422
|
}));
|
|
25152
25423
|
}
|
|
25153
|
-
function parseExceptions(
|
|
25154
|
-
if (!Array.isArray(
|
|
25155
|
-
return
|
|
25424
|
+
function parseExceptions(fm3) {
|
|
25425
|
+
if (!Array.isArray(fm3.completion_exceptions)) return [];
|
|
25426
|
+
return fm3.completion_exceptions.filter((e) => e && typeof e === "object").map((e) => ({
|
|
25156
25427
|
id: String(e.id ?? ""),
|
|
25157
25428
|
status: String(e.status ?? "proposed"),
|
|
25158
25429
|
...optStr4(e.reason) ? { reason: optStr4(e.reason) } : {},
|
|
@@ -25170,10 +25441,10 @@ function parseDecisions(decisions, knowledgeById) {
|
|
|
25170
25441
|
};
|
|
25171
25442
|
});
|
|
25172
25443
|
}
|
|
25173
|
-
function parseRelatedKnowledge(
|
|
25444
|
+
function parseRelatedKnowledge(fm3, knowledgeById) {
|
|
25174
25445
|
const refs = /* @__PURE__ */ new Set();
|
|
25175
25446
|
for (const field of ["related_knowledge", "knowledge", "related"]) {
|
|
25176
|
-
const v =
|
|
25447
|
+
const v = fm3[field];
|
|
25177
25448
|
if (Array.isArray(v)) {
|
|
25178
25449
|
for (const r of v) if (typeof r === "string" && r.trim()) refs.add(r.trim());
|
|
25179
25450
|
}
|
|
@@ -25895,18 +26166,23 @@ function collectImplementationEvidence(dir, workItemId, input) {
|
|
|
25895
26166
|
} : {}
|
|
25896
26167
|
};
|
|
25897
26168
|
}
|
|
25898
|
-
return {
|
|
26169
|
+
return {
|
|
26170
|
+
repositories,
|
|
26171
|
+
...input.acVerifications.length > 0 ? {
|
|
26172
|
+
ac_verifications: input.acVerifications.map((verification) => ({ ...verification }))
|
|
26173
|
+
} : {}
|
|
26174
|
+
};
|
|
25899
26175
|
}
|
|
25900
26176
|
function verifyWorkItem(dir, workItemId, input) {
|
|
25901
26177
|
const evidence = collectImplementationEvidence(dir, workItemId, input);
|
|
25902
26178
|
const artifacts = discoverWorkItems(dir);
|
|
25903
26179
|
const match = artifacts.find((a) => (a.id || a.title) === workItemId);
|
|
25904
26180
|
const lifecycle = lifecycleStateOf({ status: match.status, filePath: match.filePath });
|
|
25905
|
-
const
|
|
26181
|
+
const fm3 = match.rawFrontmatter;
|
|
25906
26182
|
const acVerifications = mapACVerifications(input.acVerifications);
|
|
25907
26183
|
const acSummary = computeACSummary(acVerifications);
|
|
25908
|
-
const releaseGates = Array.isArray(
|
|
25909
|
-
const completionExceptions = Array.isArray(
|
|
26184
|
+
const releaseGates = Array.isArray(fm3.release_gates) ? fm3.release_gates : [];
|
|
26185
|
+
const completionExceptions = Array.isArray(fm3.completion_exceptions) ? fm3.completion_exceptions : [];
|
|
25910
26186
|
const plannedVsActual = computePlannedVsActual(match.affectedModules, input.repos);
|
|
25911
26187
|
const registeredModuleIds = loadMappedModules(dir).map((m) => m.id);
|
|
25912
26188
|
const modifiedRepoIds = input.repos.map((r) => r.repoId);
|
|
@@ -25917,7 +26193,7 @@ function verifyWorkItem(dir, workItemId, input) {
|
|
|
25917
26193
|
validationStatus: match.validationStatus || "not-started",
|
|
25918
26194
|
releaseStatus: match.releaseStatus || "not-assessed",
|
|
25919
26195
|
affectedModules: match.affectedModules,
|
|
25920
|
-
rawFrontmatter:
|
|
26196
|
+
rawFrontmatter: fm3,
|
|
25921
26197
|
registeredModuleIds,
|
|
25922
26198
|
modifiedRepoIds
|
|
25923
26199
|
});
|
|
@@ -25955,6 +26231,9 @@ function evaluateCompletion(verification) {
|
|
|
25955
26231
|
warnings.push(`Completion exception "${ex.id}" is still proposed (not yet accepted).`);
|
|
25956
26232
|
}
|
|
25957
26233
|
}
|
|
26234
|
+
if (verification.acSummary.total === 0) {
|
|
26235
|
+
blockers.push("No acceptance criteria were detected; completion evidence is insufficient.");
|
|
26236
|
+
}
|
|
25958
26237
|
if (verification.acSummary.failed > 0) {
|
|
25959
26238
|
const failedACs = verification.acVerifications.filter((ac) => ac.status === "failed");
|
|
25960
26239
|
for (const ac of failedACs) {
|
|
@@ -25966,10 +26245,16 @@ function evaluateCompletion(verification) {
|
|
|
25966
26245
|
blockers.push(f.message);
|
|
25967
26246
|
}
|
|
25968
26247
|
if (verification.acSummary.manualReview > 0) {
|
|
25969
|
-
|
|
26248
|
+
blockers.push(`${verification.acSummary.manualReview} AC(s) require manual review.`);
|
|
25970
26249
|
}
|
|
25971
26250
|
if (verification.acSummary.notVerified > 0) {
|
|
25972
|
-
|
|
26251
|
+
blockers.push(`${verification.acSummary.notVerified} AC(s) not yet verified.`);
|
|
26252
|
+
}
|
|
26253
|
+
if (verification.implementationStatus !== "completed") {
|
|
26254
|
+
blockers.push(`Implementation status is "${verification.implementationStatus}", not "completed".`);
|
|
26255
|
+
}
|
|
26256
|
+
if (!["passed", "accepted-with-exceptions"].includes(verification.validationStatus)) {
|
|
26257
|
+
blockers.push(`Validation status is "${verification.validationStatus}", not passed.`);
|
|
25973
26258
|
}
|
|
25974
26259
|
const warningFindings = verification.findings.filter((f) => f.severity === "warning");
|
|
25975
26260
|
for (const f of warningFindings) {
|
|
@@ -25986,8 +26271,8 @@ function evaluateCompletion(verification) {
|
|
|
25986
26271
|
}
|
|
25987
26272
|
let readiness;
|
|
25988
26273
|
if (blockers.length > 0) {
|
|
25989
|
-
const
|
|
25990
|
-
if (
|
|
26274
|
+
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"));
|
|
26275
|
+
if (needsEvidence) {
|
|
25991
26276
|
readiness = "NEEDS_WORK";
|
|
25992
26277
|
reasons.push("Acceptance criteria have failures that must be addressed.");
|
|
25993
26278
|
} else {
|
|
@@ -26069,17 +26354,46 @@ function deriveImplementationStatus(repos) {
|
|
|
26069
26354
|
}
|
|
26070
26355
|
|
|
26071
26356
|
// src/commands/verify.ts
|
|
26357
|
+
function normalizeAC(text2) {
|
|
26358
|
+
return text2.trim().toLowerCase().replace(/\s+/g, " ");
|
|
26359
|
+
}
|
|
26360
|
+
function storedACVerifications(value) {
|
|
26361
|
+
if (!Array.isArray(value)) return /* @__PURE__ */ new Map();
|
|
26362
|
+
return new Map(value.filter((entry) => Boolean(entry) && typeof entry === "object").filter((entry) => typeof entry.criterion === "string").map((entry) => [normalizeAC(entry.criterion), entry]));
|
|
26363
|
+
}
|
|
26364
|
+
function buildACVerifications(acs, persisted) {
|
|
26365
|
+
const persistedACs = storedACVerifications(persisted);
|
|
26366
|
+
return acs.map((ac) => {
|
|
26367
|
+
const stored = persistedACs.get(normalizeAC(ac.criterion));
|
|
26368
|
+
const validStatus = stored?.status === "passed" || stored?.status === "failed" || stored?.status === "not-verified" || stored?.status === "manual-review-required" ? stored.status : "not-verified";
|
|
26369
|
+
const hasEvidence = typeof stored?.evidence === "string" && stored.evidence.trim().length > 0 && typeof stored?.reference === "string" && stored.reference.trim().length > 0;
|
|
26370
|
+
return {
|
|
26371
|
+
criterion: ac.criterion,
|
|
26372
|
+
status: validStatus === "passed" && !hasEvidence ? "not-verified" : validStatus,
|
|
26373
|
+
...typeof stored?.evidence === "string" ? { evidence: stored.evidence } : {},
|
|
26374
|
+
...typeof stored?.reference === "string" ? { reference: stored.reference } : {},
|
|
26375
|
+
...stored?.method === "automated" || stored?.method === "manual" ? { method: stored.method } : {}
|
|
26376
|
+
};
|
|
26377
|
+
});
|
|
26378
|
+
}
|
|
26072
26379
|
function extractACsFromBody(body) {
|
|
26073
26380
|
const lines = body.split(/\r?\n/);
|
|
26074
|
-
let
|
|
26381
|
+
let acLevel = 0;
|
|
26075
26382
|
const acs = [];
|
|
26076
26383
|
for (const line of lines) {
|
|
26077
|
-
|
|
26078
|
-
|
|
26384
|
+
const heading = line.match(/^(#{1,6})\s+(.*)$/);
|
|
26385
|
+
if (heading) {
|
|
26386
|
+
const level = heading[1].length;
|
|
26387
|
+
if (acLevel === 0) {
|
|
26388
|
+
if (/^(?:\d+(?:\.\d+)*\.?\s+)?(acceptance\s+criteria|criterios\s+de\s+aceptaci[oó]n)\s*$/i.test(heading[2].trim())) {
|
|
26389
|
+
acLevel = level;
|
|
26390
|
+
}
|
|
26391
|
+
continue;
|
|
26392
|
+
}
|
|
26393
|
+
if (level <= acLevel) break;
|
|
26079
26394
|
continue;
|
|
26080
26395
|
}
|
|
26081
|
-
if (
|
|
26082
|
-
if (inAC) {
|
|
26396
|
+
if (acLevel > 0) {
|
|
26083
26397
|
const m = line.match(/^\s*[-*+]\s+(?:\[([ xX])\]\s*)?(.+)$/);
|
|
26084
26398
|
if (m) {
|
|
26085
26399
|
const text2 = m[2].trim();
|
|
@@ -26120,9 +26434,9 @@ async function runVerify(workItemId, opts = {}) {
|
|
|
26120
26434
|
const changedPaths = await getModifiedFiles("head");
|
|
26121
26435
|
const raw = readFile(match.filePath);
|
|
26122
26436
|
const parsed = matter26(raw);
|
|
26123
|
-
const
|
|
26437
|
+
const fm3 = parsed.data;
|
|
26124
26438
|
const acs = extractACsFromBody(parsed.content);
|
|
26125
|
-
const existingEvidence =
|
|
26439
|
+
const existingEvidence = fm3.implementation_evidence;
|
|
26126
26440
|
const existingRepos = existingEvidence?.repositories ?? {};
|
|
26127
26441
|
const repos = Object.keys(existingRepos).length > 0 ? Object.entries(existingRepos).map(([repoId, data]) => {
|
|
26128
26442
|
const d = data;
|
|
@@ -26143,11 +26457,7 @@ async function runVerify(workItemId, opts = {}) {
|
|
|
26143
26457
|
})) : void 0
|
|
26144
26458
|
};
|
|
26145
26459
|
}) : [{ repoId: "core", changedPaths, validations: [] }];
|
|
26146
|
-
const acVerifications = acs
|
|
26147
|
-
criterion: ac.criterion,
|
|
26148
|
-
status: ac.checked ? "passed" : "not-verified",
|
|
26149
|
-
...ac.checked ? { evidence: "Explicitly checked in the Work Item acceptance criteria." } : {}
|
|
26150
|
-
}));
|
|
26460
|
+
const acVerifications = buildACVerifications(acs, existingEvidence?.ac_verifications);
|
|
26151
26461
|
const input = {
|
|
26152
26462
|
repos,
|
|
26153
26463
|
acVerifications
|
|
@@ -26322,15 +26632,15 @@ function longestSharedRun(a, b) {
|
|
|
26322
26632
|
let bestSnippet = "";
|
|
26323
26633
|
for (const block of a.blocks) {
|
|
26324
26634
|
let run = 0;
|
|
26325
|
-
let
|
|
26635
|
+
let runStart2 = 0;
|
|
26326
26636
|
for (let i = 0; i + SHINGLE_SIZE <= block.length; i++) {
|
|
26327
26637
|
const key = block.slice(i, i + SHINGLE_SIZE).join(" ");
|
|
26328
26638
|
if (b.set.has(key)) {
|
|
26329
|
-
if (run === 0)
|
|
26639
|
+
if (run === 0) runStart2 = i;
|
|
26330
26640
|
run += 1;
|
|
26331
26641
|
if (run > best) {
|
|
26332
26642
|
best = run;
|
|
26333
|
-
bestSnippet = block.slice(
|
|
26643
|
+
bestSnippet = block.slice(runStart2, runStart2 + SHINGLE_SIZE + run - 1).join(" ");
|
|
26334
26644
|
}
|
|
26335
26645
|
} else {
|
|
26336
26646
|
run = 0;
|
|
@@ -27084,6 +27394,246 @@ function materializeCandidate(dir, id, candidateId) {
|
|
|
27084
27394
|
return { workItemId: wiId, fileName, initiative: updated };
|
|
27085
27395
|
}
|
|
27086
27396
|
|
|
27397
|
+
// src/core/delivery-verification.ts
|
|
27398
|
+
function normalizeCriterion(text2) {
|
|
27399
|
+
return text2.trim().toLowerCase().replace(/\s+/g, " ");
|
|
27400
|
+
}
|
|
27401
|
+
var STATUSES = ["passed", "failed", "not-verified", "manual-review-required"];
|
|
27402
|
+
function optStr5(v) {
|
|
27403
|
+
if (typeof v === "string" && v.trim()) return v.trim();
|
|
27404
|
+
if (typeof v === "number") return String(v);
|
|
27405
|
+
return void 0;
|
|
27406
|
+
}
|
|
27407
|
+
function parseEvidenceList(raw) {
|
|
27408
|
+
if (!Array.isArray(raw)) return [];
|
|
27409
|
+
const out = [];
|
|
27410
|
+
for (const entry of raw) {
|
|
27411
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) continue;
|
|
27412
|
+
const o = entry;
|
|
27413
|
+
const criterion = optStr5(o.criterion);
|
|
27414
|
+
if (!criterion) continue;
|
|
27415
|
+
const statusRaw = optStr5(o.status);
|
|
27416
|
+
const status = STATUSES.includes(statusRaw ?? "") ? statusRaw : "not-verified";
|
|
27417
|
+
const method = optStr5(o.method);
|
|
27418
|
+
out.push({
|
|
27419
|
+
criterion,
|
|
27420
|
+
status,
|
|
27421
|
+
...optStr5(o.evidence) ? { evidence: optStr5(o.evidence) } : {},
|
|
27422
|
+
...optStr5(o.reference) ? { reference: optStr5(o.reference) } : {},
|
|
27423
|
+
...method === "automated" || method === "manual" ? { method } : {},
|
|
27424
|
+
...optStr5(o.verified_at) ? { verified_at: optStr5(o.verified_at) } : {},
|
|
27425
|
+
...optStr5(o.verified_by) ? { verified_by: optStr5(o.verified_by) } : {}
|
|
27426
|
+
});
|
|
27427
|
+
}
|
|
27428
|
+
return out;
|
|
27429
|
+
}
|
|
27430
|
+
function parseExceptions2(raw) {
|
|
27431
|
+
if (!Array.isArray(raw)) return [];
|
|
27432
|
+
const out = [];
|
|
27433
|
+
for (const entry of raw) {
|
|
27434
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) continue;
|
|
27435
|
+
const o = entry;
|
|
27436
|
+
const id = optStr5(o.id);
|
|
27437
|
+
if (!id) continue;
|
|
27438
|
+
const st = optStr5(o.status);
|
|
27439
|
+
const status = st === "accepted" || st === "rejected" ? st : "proposed";
|
|
27440
|
+
out.push({
|
|
27441
|
+
id,
|
|
27442
|
+
status,
|
|
27443
|
+
...optStr5(o.criterion) ? { criterion: optStr5(o.criterion) } : {},
|
|
27444
|
+
...optStr5(o.reason) ? { reason: optStr5(o.reason) } : {}
|
|
27445
|
+
});
|
|
27446
|
+
}
|
|
27447
|
+
return out;
|
|
27448
|
+
}
|
|
27449
|
+
function buildOutcomeVerification(declared, evidence, exceptions = []) {
|
|
27450
|
+
const byCriterion = /* @__PURE__ */ new Map();
|
|
27451
|
+
for (const e of evidence) byCriterion.set(normalizeCriterion(e.criterion), e);
|
|
27452
|
+
const declaredKeys = new Set(declared.map(normalizeCriterion));
|
|
27453
|
+
const counts = /* @__PURE__ */ new Map();
|
|
27454
|
+
for (const c of declared) counts.set(normalizeCriterion(c), (counts.get(normalizeCriterion(c)) ?? 0) + 1);
|
|
27455
|
+
const ambiguousKeys = new Set([...counts.entries()].filter(([, n]) => n > 1).map(([k]) => k));
|
|
27456
|
+
const waived = new Set(
|
|
27457
|
+
exceptions.filter((x) => x.status === "accepted" && x.reason?.trim() && x.criterion && declaredKeys.has(normalizeCriterion(x.criterion)) && !ambiguousKeys.has(normalizeCriterion(x.criterion))).map((x) => normalizeCriterion(x.criterion))
|
|
27458
|
+
);
|
|
27459
|
+
const criteria = declared.map((criterion) => {
|
|
27460
|
+
const key = normalizeCriterion(criterion);
|
|
27461
|
+
const ambiguous = ambiguousKeys.has(key);
|
|
27462
|
+
const e = ambiguous ? void 0 : byCriterion.get(key);
|
|
27463
|
+
return {
|
|
27464
|
+
criterion,
|
|
27465
|
+
status: e?.status ?? "not-verified",
|
|
27466
|
+
...e?.evidence ? { evidence: e.evidence } : {},
|
|
27467
|
+
...e?.reference ? { reference: e.reference } : {},
|
|
27468
|
+
...e?.method ? { method: e.method } : {},
|
|
27469
|
+
...e?.verified_at ? { verifiedAt: e.verified_at } : {},
|
|
27470
|
+
...e?.verified_by ? { verifiedBy: e.verified_by } : {},
|
|
27471
|
+
...!ambiguous && waived.has(key) ? { waived: true } : {},
|
|
27472
|
+
...ambiguous ? { ambiguous: true } : {}
|
|
27473
|
+
};
|
|
27474
|
+
});
|
|
27475
|
+
const stale = evidence.filter((e) => !declaredKeys.has(normalizeCriterion(e.criterion)));
|
|
27476
|
+
return {
|
|
27477
|
+
total: criteria.length,
|
|
27478
|
+
// An ambiguous criterion is never counted as passed/waived; it counts as unverified until disambiguated.
|
|
27479
|
+
passed: criteria.filter((c) => !c.ambiguous && (c.status === "passed" || c.waived)).length,
|
|
27480
|
+
failed: criteria.filter((c) => !c.ambiguous && c.status === "failed" && !c.waived).length,
|
|
27481
|
+
notVerified: criteria.filter((c) => c.ambiguous || c.status === "not-verified" && !c.waived).length,
|
|
27482
|
+
manualReview: criteria.filter((c) => !c.ambiguous && c.status === "manual-review-required" && !c.waived).length,
|
|
27483
|
+
ambiguous: criteria.filter((c) => c.ambiguous).length,
|
|
27484
|
+
criteria,
|
|
27485
|
+
stale
|
|
27486
|
+
};
|
|
27487
|
+
}
|
|
27488
|
+
function fm2(entity, key) {
|
|
27489
|
+
return entity.rawFrontmatter?.[key];
|
|
27490
|
+
}
|
|
27491
|
+
function epicOutcomeVerification(epic) {
|
|
27492
|
+
return buildOutcomeVerification(
|
|
27493
|
+
epic.successCriteria,
|
|
27494
|
+
parseEvidenceList(fm2(epic, "outcome_verifications")),
|
|
27495
|
+
parseExceptions2(fm2(epic, "completion_exceptions"))
|
|
27496
|
+
);
|
|
27497
|
+
}
|
|
27498
|
+
function planOutcomeVerification(plan) {
|
|
27499
|
+
return buildOutcomeVerification(
|
|
27500
|
+
plan.successCriteria,
|
|
27501
|
+
parseEvidenceList(fm2(plan, "outcome_verifications")),
|
|
27502
|
+
parseExceptions2(fm2(plan, "completion_exceptions"))
|
|
27503
|
+
);
|
|
27504
|
+
}
|
|
27505
|
+
function planMilestoneVerifications(plan) {
|
|
27506
|
+
const rawMs = Array.isArray(fm2(plan, "milestones")) ? fm2(plan, "milestones") : [];
|
|
27507
|
+
return plan.milestones.map((m) => {
|
|
27508
|
+
const rawEntry = rawMs.find((r) => r && typeof r === "object" && optStr5(r.id)?.toLowerCase() === m.id.toLowerCase());
|
|
27509
|
+
const evidence = parseEvidenceList(rawEntry?.exit_verifications);
|
|
27510
|
+
return { id: m.id, title: m.title, outcome: buildOutcomeVerification(m.exitCriteria, evidence) };
|
|
27511
|
+
});
|
|
27512
|
+
}
|
|
27513
|
+
function decide(blockers, softBlocks, hasAcceptedExceptions) {
|
|
27514
|
+
if (blockers.length > 0) return "BLOCKED";
|
|
27515
|
+
if (softBlocks.length > 0) return "NEEDS_WORK";
|
|
27516
|
+
return hasAcceptedExceptions ? "READY_WITH_EXCEPTIONS" : "READY_TO_COMPLETE";
|
|
27517
|
+
}
|
|
27518
|
+
function evaluateEpicCompletion(dir, epic) {
|
|
27519
|
+
const prog = computeEpicProgress(dir, epic);
|
|
27520
|
+
const exceptions = parseExceptions2(fm2(epic, "completion_exceptions"));
|
|
27521
|
+
const outcome = epicOutcomeVerification(epic);
|
|
27522
|
+
const blockers = [];
|
|
27523
|
+
const softBlocks = [];
|
|
27524
|
+
const reasons = [];
|
|
27525
|
+
const warnings = [];
|
|
27526
|
+
for (const d of prog.readiness.blockingDependencies) blockers.push(`Blocked by unfinished dependency ${d}.`);
|
|
27527
|
+
for (const f of integrityBlockers(dir, epic.id)) blockers.push(f);
|
|
27528
|
+
evaluateOutcomeInto(epic.outcome, true, outcome, blockers, softBlocks, reasons, warnings);
|
|
27529
|
+
if (prog.delivery.total > 0 && prog.delivery.completed < prog.delivery.total) {
|
|
27530
|
+
softBlocks.push("committed-work-incomplete");
|
|
27531
|
+
reasons.push(`Committed work is incomplete (${prog.delivery.completed}/${prog.delivery.total} Work Items completed).`);
|
|
27532
|
+
}
|
|
27533
|
+
const readiness = decide(blockers, softBlocks, exceptions.some((x) => x.status === "accepted"));
|
|
27534
|
+
pushReadinessReason(readiness, reasons);
|
|
27535
|
+
return {
|
|
27536
|
+
id: epic.id,
|
|
27537
|
+
kind: "epic",
|
|
27538
|
+
status: epic.status,
|
|
27539
|
+
readiness,
|
|
27540
|
+
reasons,
|
|
27541
|
+
blockers,
|
|
27542
|
+
warnings,
|
|
27543
|
+
outcome,
|
|
27544
|
+
delivery: { total: prog.delivery.total, completed: prog.delivery.completed, blocked: prog.delivery.blocked },
|
|
27545
|
+
blockingDependencies: prog.readiness.blockingDependencies,
|
|
27546
|
+
exceptions
|
|
27547
|
+
};
|
|
27548
|
+
}
|
|
27549
|
+
function evaluatePlanCompletion(dir, plan) {
|
|
27550
|
+
const prog = computePlanProgress(dir, plan);
|
|
27551
|
+
const exceptions = parseExceptions2(fm2(plan, "completion_exceptions"));
|
|
27552
|
+
const outcome = planOutcomeVerification(plan);
|
|
27553
|
+
const milestones = planMilestoneVerifications(plan);
|
|
27554
|
+
const epics = epicsInPlan(dir, plan.id).map((e) => ({ id: e.id, status: e.status }));
|
|
27555
|
+
const blockers = [];
|
|
27556
|
+
const softBlocks = [];
|
|
27557
|
+
const reasons = [];
|
|
27558
|
+
const warnings = [];
|
|
27559
|
+
for (const d of prog.readiness.blockingDependencies) blockers.push(`Blocked by unfinished dependency ${d}.`);
|
|
27560
|
+
for (const f of integrityBlockers(dir, plan.id)) blockers.push(f);
|
|
27561
|
+
evaluateOutcomeInto(plan.objective, false, outcome, blockers, softBlocks, reasons, warnings);
|
|
27562
|
+
if (!plan.objective) warnings.push("No objective is declared for this Plan (optional, but recommended for completion review).");
|
|
27563
|
+
if (prog.delivery.total > 0 && prog.delivery.completed < prog.delivery.total) {
|
|
27564
|
+
softBlocks.push("committed-work-incomplete");
|
|
27565
|
+
reasons.push(`Committed work is incomplete (${prog.delivery.completed}/${prog.delivery.total} Work Items completed).`);
|
|
27566
|
+
}
|
|
27567
|
+
if (epics.length === 0 && prog.delivery.total === 0) {
|
|
27568
|
+
softBlocks.push("no-committed-work");
|
|
27569
|
+
reasons.push("No Epics and no committed Work Items \u2014 the Plan has no verifiable deliverables yet.");
|
|
27570
|
+
}
|
|
27571
|
+
const openEpics = epics.filter((e) => e.status !== "completed" && e.status !== "cancelled");
|
|
27572
|
+
if (openEpics.length > 0) {
|
|
27573
|
+
softBlocks.push("epics-open");
|
|
27574
|
+
reasons.push(`${openEpics.length} Epic(s) not yet completed: ${openEpics.map((e) => e.id).join(", ")}.`);
|
|
27575
|
+
}
|
|
27576
|
+
for (const m of milestones) {
|
|
27577
|
+
if (m.outcome.failed > 0) {
|
|
27578
|
+
blockers.push(`Milestone ${m.id} has a failed exit criterion.`);
|
|
27579
|
+
}
|
|
27580
|
+
const pending = m.outcome.notVerified + m.outcome.manualReview;
|
|
27581
|
+
if (pending > 0) {
|
|
27582
|
+
softBlocks.push(`milestone-${m.id}-pending`);
|
|
27583
|
+
reasons.push(`Milestone ${m.id}: ${pending} exit criterion(s) not verified.`);
|
|
27584
|
+
}
|
|
27585
|
+
if (m.outcome.stale.length > 0) warnings.push(`Milestone ${m.id} has stale exit-criteria evidence.`);
|
|
27586
|
+
}
|
|
27587
|
+
const readiness = decide(blockers, softBlocks, exceptions.some((x) => x.status === "accepted"));
|
|
27588
|
+
pushReadinessReason(readiness, reasons);
|
|
27589
|
+
return {
|
|
27590
|
+
id: plan.id,
|
|
27591
|
+
kind: "plan",
|
|
27592
|
+
status: plan.status,
|
|
27593
|
+
readiness,
|
|
27594
|
+
reasons,
|
|
27595
|
+
blockers,
|
|
27596
|
+
warnings,
|
|
27597
|
+
outcome,
|
|
27598
|
+
delivery: { total: prog.delivery.total, completed: prog.delivery.completed, blocked: prog.delivery.blocked },
|
|
27599
|
+
blockingDependencies: prog.readiness.blockingDependencies,
|
|
27600
|
+
milestones,
|
|
27601
|
+
epics,
|
|
27602
|
+
exceptions
|
|
27603
|
+
};
|
|
27604
|
+
}
|
|
27605
|
+
function integrityBlockers(dir, subjectId) {
|
|
27606
|
+
return validatePlanningGraph(dir).filter((f) => f.level === "error" && f.subject.toLowerCase() === subjectId.toLowerCase()).map((f) => f.message);
|
|
27607
|
+
}
|
|
27608
|
+
function evaluateOutcomeInto(declaredOutcome, requireDeclaredOutcome, outcome, blockers, softBlocks, reasons, warnings) {
|
|
27609
|
+
if (requireDeclaredOutcome && !declaredOutcome) {
|
|
27610
|
+
softBlocks.push("no-outcome");
|
|
27611
|
+
reasons.push("No expected outcome is declared.");
|
|
27612
|
+
}
|
|
27613
|
+
if (outcome.total === 0) {
|
|
27614
|
+
softBlocks.push("no-success-criteria");
|
|
27615
|
+
reasons.push("No success criteria to verify \u2014 completion cannot be judged by outcome.");
|
|
27616
|
+
}
|
|
27617
|
+
if (outcome.ambiguous > 0) {
|
|
27618
|
+
softBlocks.push("criteria-ambiguous");
|
|
27619
|
+
reasons.push(`${outcome.ambiguous} success criterion(s) collide in text \u2014 rename to disambiguate before verifying.`);
|
|
27620
|
+
}
|
|
27621
|
+
if (outcome.failed > 0) {
|
|
27622
|
+
softBlocks.push("criteria-failed");
|
|
27623
|
+
reasons.push(`${outcome.failed} success criterion(s) failed verification.`);
|
|
27624
|
+
}
|
|
27625
|
+
const pending = outcome.notVerified + outcome.manualReview - outcome.ambiguous;
|
|
27626
|
+
if (pending > 0) {
|
|
27627
|
+
softBlocks.push("criteria-unverified");
|
|
27628
|
+
reasons.push(`${pending} success criterion(s) not verified (no or insufficient evidence).`);
|
|
27629
|
+
}
|
|
27630
|
+
if (outcome.stale.length > 0) warnings.push(`${outcome.stale.length} evidence record(s) no longer match a declared criterion (stale).`);
|
|
27631
|
+
}
|
|
27632
|
+
function pushReadinessReason(readiness, reasons) {
|
|
27633
|
+
if (readiness === "READY_TO_COMPLETE") reasons.unshift("All success criteria are verified and committed work is complete. Human approval is still required to close.");
|
|
27634
|
+
else if (readiness === "READY_WITH_EXCEPTIONS") reasons.unshift("Remaining gaps are covered by accepted exceptions. Human approval is still required to close.");
|
|
27635
|
+
}
|
|
27636
|
+
|
|
27087
27637
|
// src/core/delivery-planning-write.ts
|
|
27088
27638
|
var DeliveryPlanningWriteError = class extends Error {
|
|
27089
27639
|
constructor(message) {
|
|
@@ -27091,6 +27641,23 @@ var DeliveryPlanningWriteError = class extends Error {
|
|
|
27091
27641
|
this.name = "DeliveryPlanningWriteError";
|
|
27092
27642
|
}
|
|
27093
27643
|
};
|
|
27644
|
+
var PlanningConflictError = class extends Error {
|
|
27645
|
+
constructor(id, expectedRevision, actualRevision) {
|
|
27646
|
+
super(`"${id}" was modified since it was loaded (expected revision ${expectedRevision}, found ${actualRevision}). Reload and try again.`);
|
|
27647
|
+
this.id = id;
|
|
27648
|
+
this.expectedRevision = expectedRevision;
|
|
27649
|
+
this.actualRevision = actualRevision;
|
|
27650
|
+
this.name = "PlanningConflictError";
|
|
27651
|
+
}
|
|
27652
|
+
id;
|
|
27653
|
+
expectedRevision;
|
|
27654
|
+
actualRevision;
|
|
27655
|
+
};
|
|
27656
|
+
function assertFreshRevision(id, currentContent, opts) {
|
|
27657
|
+
if (!opts?.expectedRevision) return;
|
|
27658
|
+
const actual = revisionOf(currentContent);
|
|
27659
|
+
if (actual !== opts.expectedRevision) throw new PlanningConflictError(id, opts.expectedRevision, actual);
|
|
27660
|
+
}
|
|
27094
27661
|
function slugify8(s) {
|
|
27095
27662
|
return s.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "item";
|
|
27096
27663
|
}
|
|
@@ -27151,6 +27718,163 @@ function associateInitiativeWithEpic(dir, initiativeId, epicId) {
|
|
|
27151
27718
|
if (!getEpic(dir, epicId)) throw new DeliveryPlanningWriteError(`Epic ${epicId} does not exist.`);
|
|
27152
27719
|
return updateInitiative(dir, ini.id, { epic: epicId });
|
|
27153
27720
|
}
|
|
27721
|
+
function today3() {
|
|
27722
|
+
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
27723
|
+
}
|
|
27724
|
+
var PlanningNotReadyError = class extends DeliveryPlanningWriteError {
|
|
27725
|
+
constructor(evaluation) {
|
|
27726
|
+
super(`${evaluation.kind === "plan" ? "Plan" : "Epic"} ${evaluation.id} is not ready to complete (${evaluation.readiness}).`);
|
|
27727
|
+
this.evaluation = evaluation;
|
|
27728
|
+
this.name = "PlanningNotReadyError";
|
|
27729
|
+
}
|
|
27730
|
+
evaluation;
|
|
27731
|
+
};
|
|
27732
|
+
function transitionDeliveryPlan(dir, id, to, opts) {
|
|
27733
|
+
const plan = getPlan(dir, id);
|
|
27734
|
+
if (!plan) throw new DeliveryPlanningWriteError(`Plan ${id} does not exist.`);
|
|
27735
|
+
if (!PLAN_STATES.includes(to)) throw new DeliveryPlanningWriteError(`Invalid plan status: ${to}.`);
|
|
27736
|
+
if (to === "completed") throw new DeliveryPlanningWriteError(`Completing Plan ${id} requires evidence-based review \u2014 use completeDeliveryPlan.`);
|
|
27737
|
+
const raw = readFile(plan.filePath);
|
|
27738
|
+
assertFreshRevision(plan.id, raw, opts);
|
|
27739
|
+
if (plan.status === to) return plan;
|
|
27740
|
+
if (!PLAN_TRANSITIONS[plan.status].includes(to)) throw new DeliveryPlanningWriteError(`Invalid transition ${plan.status} \u2192 ${to} for Plan ${id}.`);
|
|
27741
|
+
const { data, content } = matter29(raw, {});
|
|
27742
|
+
data.status = to;
|
|
27743
|
+
if (to === "completed") data.completed_at = today3();
|
|
27744
|
+
const newContent = matter29.stringify(content, data);
|
|
27745
|
+
writeFile(plan.filePath, newContent);
|
|
27746
|
+
const updated = parseDeliveryPlan(dir, plan.filePath, newContent);
|
|
27747
|
+
if (!updated) throw new DeliveryPlanningWriteError("Failed to parse the Plan after transition.");
|
|
27748
|
+
return updated;
|
|
27749
|
+
}
|
|
27750
|
+
function transitionEpic(dir, id, to, opts) {
|
|
27751
|
+
const epic = getEpic(dir, id);
|
|
27752
|
+
if (!epic) throw new DeliveryPlanningWriteError(`Epic ${id} does not exist.`);
|
|
27753
|
+
if (!EPIC_STATES.includes(to)) throw new DeliveryPlanningWriteError(`Invalid epic status: ${to}.`);
|
|
27754
|
+
if (to === "completed") throw new DeliveryPlanningWriteError(`Completing Epic ${id} requires evidence-based review \u2014 use completeEpic.`);
|
|
27755
|
+
const raw = readFile(epic.filePath);
|
|
27756
|
+
assertFreshRevision(epic.id, raw, opts);
|
|
27757
|
+
if (epic.status === to) return epic;
|
|
27758
|
+
if (!EPIC_TRANSITIONS[epic.status].includes(to)) throw new DeliveryPlanningWriteError(`Invalid transition ${epic.status} \u2192 ${to} for Epic ${id}.`);
|
|
27759
|
+
const { data, content } = matter29(raw, {});
|
|
27760
|
+
data.status = to;
|
|
27761
|
+
if (to === "completed") data.completed_at = today3();
|
|
27762
|
+
const newContent = matter29.stringify(content, data);
|
|
27763
|
+
writeFile(epic.filePath, newContent);
|
|
27764
|
+
const updated = parseEpic(dir, epic.filePath, newContent);
|
|
27765
|
+
if (!updated) throw new DeliveryPlanningWriteError("Failed to parse the Epic after transition.");
|
|
27766
|
+
return updated;
|
|
27767
|
+
}
|
|
27768
|
+
function assertCriterionDeclared(declared, criterion, kind) {
|
|
27769
|
+
const key = normalizeCriterion(criterion);
|
|
27770
|
+
const matches = declared.filter((c) => normalizeCriterion(c) === key).length;
|
|
27771
|
+
if (matches === 0) throw new DeliveryPlanningWriteError(`"${criterion}" is not a declared ${kind} criterion.`);
|
|
27772
|
+
if (matches > 1) throw new DeliveryPlanningWriteError(`"${criterion}" matches more than one declared ${kind} criterion \u2014 rename them to disambiguate before recording evidence.`);
|
|
27773
|
+
}
|
|
27774
|
+
function upsertEvidence(existing, input) {
|
|
27775
|
+
const list2 = Array.isArray(existing) ? existing.filter((e) => e && typeof e === "object" && !Array.isArray(e)) : [];
|
|
27776
|
+
const key = normalizeCriterion(input.criterion);
|
|
27777
|
+
const kept = list2.filter((e) => normalizeCriterion(String(e.criterion ?? "")) !== key);
|
|
27778
|
+
const obj = { criterion: input.criterion.trim(), status: input.status };
|
|
27779
|
+
if (input.evidence?.trim()) obj.evidence = input.evidence.trim();
|
|
27780
|
+
if (input.reference?.trim()) obj.reference = input.reference.trim();
|
|
27781
|
+
if (input.method) obj.method = input.method;
|
|
27782
|
+
obj.verified_at = today3();
|
|
27783
|
+
if (input.verifiedBy?.trim()) obj.verified_by = input.verifiedBy.trim();
|
|
27784
|
+
return [...kept, obj];
|
|
27785
|
+
}
|
|
27786
|
+
function recordEpicOutcomeVerification(dir, id, input, opts) {
|
|
27787
|
+
const epic = getEpic(dir, id);
|
|
27788
|
+
if (!epic) throw new DeliveryPlanningWriteError(`Epic ${id} does not exist.`);
|
|
27789
|
+
assertCriterionDeclared(epic.successCriteria, input.criterion, "success");
|
|
27790
|
+
const raw = readFile(epic.filePath);
|
|
27791
|
+
assertFreshRevision(epic.id, raw, opts);
|
|
27792
|
+
const { data, content } = matter29(raw, {});
|
|
27793
|
+
data.outcome_verifications = upsertEvidence(data.outcome_verifications, input);
|
|
27794
|
+
const newContent = matter29.stringify(content, data);
|
|
27795
|
+
writeFile(epic.filePath, newContent);
|
|
27796
|
+
const updated = parseEpic(dir, epic.filePath, newContent);
|
|
27797
|
+
if (!updated) throw new DeliveryPlanningWriteError("Failed to parse the Epic after recording evidence.");
|
|
27798
|
+
return updated;
|
|
27799
|
+
}
|
|
27800
|
+
function recordPlanOutcomeVerification(dir, id, input, opts) {
|
|
27801
|
+
const plan = getPlan(dir, id);
|
|
27802
|
+
if (!plan) throw new DeliveryPlanningWriteError(`Plan ${id} does not exist.`);
|
|
27803
|
+
assertCriterionDeclared(plan.successCriteria, input.criterion, "success");
|
|
27804
|
+
const raw = readFile(plan.filePath);
|
|
27805
|
+
assertFreshRevision(plan.id, raw, opts);
|
|
27806
|
+
const { data, content } = matter29(raw, {});
|
|
27807
|
+
data.outcome_verifications = upsertEvidence(data.outcome_verifications, input);
|
|
27808
|
+
const newContent = matter29.stringify(content, data);
|
|
27809
|
+
writeFile(plan.filePath, newContent);
|
|
27810
|
+
const updated = parseDeliveryPlan(dir, plan.filePath, newContent);
|
|
27811
|
+
if (!updated) throw new DeliveryPlanningWriteError("Failed to parse the Plan after recording evidence.");
|
|
27812
|
+
return updated;
|
|
27813
|
+
}
|
|
27814
|
+
function recordMilestoneExitVerification(dir, planId, milestoneId, input, opts) {
|
|
27815
|
+
const plan = getPlan(dir, planId);
|
|
27816
|
+
if (!plan) throw new DeliveryPlanningWriteError(`Plan ${planId} does not exist.`);
|
|
27817
|
+
const milestone = plan.milestones.find((m) => m.id.toLowerCase() === milestoneId.toLowerCase());
|
|
27818
|
+
if (!milestone) throw new DeliveryPlanningWriteError(`Milestone ${milestoneId} is not defined in ${planId}.`);
|
|
27819
|
+
assertCriterionDeclared(milestone.exitCriteria, input.criterion, "exit");
|
|
27820
|
+
const raw = readFile(plan.filePath);
|
|
27821
|
+
assertFreshRevision(plan.id, raw, opts);
|
|
27822
|
+
const { data, content } = matter29(raw, {});
|
|
27823
|
+
const rawMs = Array.isArray(data.milestones) ? data.milestones : [];
|
|
27824
|
+
const entry = rawMs.find((m) => m && typeof m === "object" && String(m.id ?? "").toLowerCase() === milestoneId.toLowerCase());
|
|
27825
|
+
if (!entry) throw new DeliveryPlanningWriteError(`Milestone ${milestoneId} entry not found in ${planId} frontmatter.`);
|
|
27826
|
+
entry.exit_verifications = upsertEvidence(entry.exit_verifications, input);
|
|
27827
|
+
data.milestones = rawMs;
|
|
27828
|
+
const newContent = matter29.stringify(content, data);
|
|
27829
|
+
writeFile(plan.filePath, newContent);
|
|
27830
|
+
const updated = parseDeliveryPlan(dir, plan.filePath, newContent);
|
|
27831
|
+
if (!updated) throw new DeliveryPlanningWriteError("Failed to parse the Plan after recording milestone evidence.");
|
|
27832
|
+
return updated;
|
|
27833
|
+
}
|
|
27834
|
+
function completionDecisionRecord(evaluation, input) {
|
|
27835
|
+
const rec = { readiness: evaluation.readiness, decided_at: today3(), reasons: evaluation.reasons };
|
|
27836
|
+
if (input.decidedBy?.trim()) rec.decided_by = input.decidedBy.trim();
|
|
27837
|
+
if (input.note?.trim()) rec.note = input.note.trim();
|
|
27838
|
+
const acceptedExceptions = evaluation.exceptions.filter((x) => x.status === "accepted");
|
|
27839
|
+
if (acceptedExceptions.length > 0) rec.exceptions = acceptedExceptions;
|
|
27840
|
+
return rec;
|
|
27841
|
+
}
|
|
27842
|
+
function completeEpic(dir, id, input = {}, opts) {
|
|
27843
|
+
const epic = getEpic(dir, id);
|
|
27844
|
+
if (!epic) throw new DeliveryPlanningWriteError(`Epic ${id} does not exist.`);
|
|
27845
|
+
const evaluation = evaluateEpicCompletion(dir, epic);
|
|
27846
|
+
if (evaluation.readiness !== "READY_TO_COMPLETE" && evaluation.readiness !== "READY_WITH_EXCEPTIONS") throw new PlanningNotReadyError(evaluation);
|
|
27847
|
+
if (!EPIC_TRANSITIONS[epic.status].includes("completed")) throw new DeliveryPlanningWriteError(`Epic ${id} cannot move from ${epic.status} to completed.`);
|
|
27848
|
+
const raw = readFile(epic.filePath);
|
|
27849
|
+
assertFreshRevision(epic.id, raw, opts);
|
|
27850
|
+
const { data, content } = matter29(raw, {});
|
|
27851
|
+
data.status = "completed";
|
|
27852
|
+
data.completed_at = today3();
|
|
27853
|
+
data.completion_decision = completionDecisionRecord(evaluation, input);
|
|
27854
|
+
const newContent = matter29.stringify(content, data);
|
|
27855
|
+
writeFile(epic.filePath, newContent);
|
|
27856
|
+
const updated = parseEpic(dir, epic.filePath, newContent);
|
|
27857
|
+
if (!updated) throw new DeliveryPlanningWriteError("Failed to parse the Epic after completion.");
|
|
27858
|
+
return updated;
|
|
27859
|
+
}
|
|
27860
|
+
function completeDeliveryPlan(dir, id, input = {}, opts) {
|
|
27861
|
+
const plan = getPlan(dir, id);
|
|
27862
|
+
if (!plan) throw new DeliveryPlanningWriteError(`Plan ${id} does not exist.`);
|
|
27863
|
+
const evaluation = evaluatePlanCompletion(dir, plan);
|
|
27864
|
+
if (evaluation.readiness !== "READY_TO_COMPLETE" && evaluation.readiness !== "READY_WITH_EXCEPTIONS") throw new PlanningNotReadyError(evaluation);
|
|
27865
|
+
if (!PLAN_TRANSITIONS[plan.status].includes("completed")) throw new DeliveryPlanningWriteError(`Plan ${id} cannot move from ${plan.status} to completed.`);
|
|
27866
|
+
const raw = readFile(plan.filePath);
|
|
27867
|
+
assertFreshRevision(plan.id, raw, opts);
|
|
27868
|
+
const { data, content } = matter29(raw, {});
|
|
27869
|
+
data.status = "completed";
|
|
27870
|
+
data.completed_at = today3();
|
|
27871
|
+
data.completion_decision = completionDecisionRecord(evaluation, input);
|
|
27872
|
+
const newContent = matter29.stringify(content, data);
|
|
27873
|
+
writeFile(plan.filePath, newContent);
|
|
27874
|
+
const updated = parseDeliveryPlan(dir, plan.filePath, newContent);
|
|
27875
|
+
if (!updated) throw new DeliveryPlanningWriteError("Failed to parse the Plan after completion.");
|
|
27876
|
+
return updated;
|
|
27877
|
+
}
|
|
27154
27878
|
|
|
27155
27879
|
// src/commands/plan.ts
|
|
27156
27880
|
function requireInit(dir) {
|
|
@@ -27343,6 +28067,186 @@ async function runEpicAssociate(epicId, initiativeId) {
|
|
|
27343
28067
|
process.exit(1);
|
|
27344
28068
|
}
|
|
27345
28069
|
}
|
|
28070
|
+
var EVIDENCE_STATUSES = ["passed", "failed", "not-verified", "manual-review-required"];
|
|
28071
|
+
function printEvaluation(ev) {
|
|
28072
|
+
log.info(` Readiness: ${ev.readiness}`);
|
|
28073
|
+
const o = ev.outcome;
|
|
28074
|
+
log.info(` Outcome criteria: ${o.passed}/${o.total} passed${o.failed ? ` \xB7 ${o.failed} failed` : ""}${o.notVerified ? ` \xB7 ${o.notVerified} unverified` : ""}${o.ambiguous ? ` \xB7 ${o.ambiguous} ambiguous` : ""}`);
|
|
28075
|
+
for (const c of o.criteria) log.info(` [${c.status}${c.waived ? "/waived" : ""}${c.ambiguous ? "/ambiguous" : ""}] ${c.criterion}`);
|
|
28076
|
+
if (o.stale.length) log.warn(` Stale evidence (criterion changed): ${o.stale.map((s) => s.criterion).join("; ")}`);
|
|
28077
|
+
if (ev.milestones) for (const m of ev.milestones) log.info(` Milestone ${m.id}: ${m.outcome.passed}/${m.outcome.total} exit criteria verified`);
|
|
28078
|
+
if (ev.blockingDependencies.length) log.warn(` Blocking dependencies: ${ev.blockingDependencies.join(", ")}`);
|
|
28079
|
+
for (const b of ev.blockers) log.warn(` Blocker: ${b}`);
|
|
28080
|
+
for (const w of ev.warnings) log.warn(` Warning: ${w}`);
|
|
28081
|
+
for (const r of ev.reasons) log.info(` ${r}`);
|
|
28082
|
+
log.info(" Completion is never automatic \u2014 it always requires an explicit human decision.");
|
|
28083
|
+
}
|
|
28084
|
+
function evidenceInput(opts) {
|
|
28085
|
+
if (!opts.criterion?.trim()) {
|
|
28086
|
+
log.error("A --criterion is required.");
|
|
28087
|
+
process.exit(1);
|
|
28088
|
+
}
|
|
28089
|
+
const status = opts.status ?? "passed";
|
|
28090
|
+
if (!EVIDENCE_STATUSES.includes(status)) {
|
|
28091
|
+
log.error(`--status must be one of: ${EVIDENCE_STATUSES.join(", ")}.`);
|
|
28092
|
+
process.exit(1);
|
|
28093
|
+
}
|
|
28094
|
+
const method = opts.method === "automated" || opts.method === "manual" ? opts.method : void 0;
|
|
28095
|
+
return { criterion: opts.criterion.trim(), status, evidence: opts.evidence, reference: opts.reference, method, verifiedBy: opts.by };
|
|
28096
|
+
}
|
|
28097
|
+
function runPlanStart(id) {
|
|
28098
|
+
const dir = cwd();
|
|
28099
|
+
requireInit(dir);
|
|
28100
|
+
intro(`kaddo plan start ${id}`);
|
|
28101
|
+
try {
|
|
28102
|
+
const p = transitionDeliveryPlan(dir, id, "in-progress");
|
|
28103
|
+
log.success(`Plan ${p.id} is now ${p.status}.`);
|
|
28104
|
+
outro("Started.");
|
|
28105
|
+
} catch (err) {
|
|
28106
|
+
log.error(err instanceof DeliveryPlanningWriteError ? err.message : String(err));
|
|
28107
|
+
process.exit(1);
|
|
28108
|
+
}
|
|
28109
|
+
}
|
|
28110
|
+
function runPlanVerify(id, opts = {}) {
|
|
28111
|
+
const dir = cwd();
|
|
28112
|
+
requireInit(dir);
|
|
28113
|
+
const plan = getPlan(dir, id);
|
|
28114
|
+
if (!plan) {
|
|
28115
|
+
if (opts.json) console.log(JSON.stringify({ error: `Plan ${id} not found.` }));
|
|
28116
|
+
else log.error(`Plan ${id} not found.`);
|
|
28117
|
+
process.exit(1);
|
|
28118
|
+
}
|
|
28119
|
+
const ev = evaluatePlanCompletion(dir, plan);
|
|
28120
|
+
if (opts.json) {
|
|
28121
|
+
console.log(JSON.stringify(ev, null, 2));
|
|
28122
|
+
return;
|
|
28123
|
+
}
|
|
28124
|
+
intro(`kaddo plan verify ${id}`);
|
|
28125
|
+
printEvaluation(ev);
|
|
28126
|
+
outro(`Plan ${id} \u2014 ${ev.readiness}.`);
|
|
28127
|
+
}
|
|
28128
|
+
async function runPlanComplete(id, opts = {}) {
|
|
28129
|
+
const dir = cwd();
|
|
28130
|
+
requireInit(dir);
|
|
28131
|
+
intro(`kaddo plan complete ${id}`);
|
|
28132
|
+
const plan = getPlan(dir, id);
|
|
28133
|
+
if (!plan) {
|
|
28134
|
+
log.error(`Plan ${id} not found.`);
|
|
28135
|
+
process.exit(1);
|
|
28136
|
+
}
|
|
28137
|
+
const ev = evaluatePlanCompletion(dir, plan);
|
|
28138
|
+
printEvaluation(ev);
|
|
28139
|
+
if (ev.readiness !== "READY_TO_COMPLETE" && ev.readiness !== "READY_WITH_EXCEPTIONS") {
|
|
28140
|
+
log.error(`Plan ${id} is not ready to complete (${ev.readiness}).`);
|
|
28141
|
+
process.exit(1);
|
|
28142
|
+
}
|
|
28143
|
+
const ok = opts.yes === true || await confirm({ message: `Complete Plan ${id}? This records a human completion decision.` }) === true;
|
|
28144
|
+
if (!ok) {
|
|
28145
|
+
cancel("Cancelled.");
|
|
28146
|
+
return;
|
|
28147
|
+
}
|
|
28148
|
+
try {
|
|
28149
|
+
const done = completeDeliveryPlan(dir, id, { decidedBy: opts.by });
|
|
28150
|
+
log.success(`Plan ${done.id} completed (${ev.readiness}).`);
|
|
28151
|
+
outro("Completion decision recorded.");
|
|
28152
|
+
} catch (err) {
|
|
28153
|
+
log.error(err instanceof DeliveryPlanningWriteError ? err.message : String(err));
|
|
28154
|
+
process.exit(1);
|
|
28155
|
+
}
|
|
28156
|
+
}
|
|
28157
|
+
function runPlanEvidence(id, opts = {}) {
|
|
28158
|
+
const dir = cwd();
|
|
28159
|
+
requireInit(dir);
|
|
28160
|
+
intro(`kaddo plan evidence ${id}`);
|
|
28161
|
+
const input = evidenceInput(opts);
|
|
28162
|
+
try {
|
|
28163
|
+
if (opts.milestone) {
|
|
28164
|
+
recordMilestoneExitVerification(dir, id, opts.milestone, input);
|
|
28165
|
+
log.success(`Recorded evidence for milestone ${opts.milestone} criterion.`);
|
|
28166
|
+
} else {
|
|
28167
|
+
recordPlanOutcomeVerification(dir, id, input);
|
|
28168
|
+
log.success("Recorded Plan outcome evidence.");
|
|
28169
|
+
}
|
|
28170
|
+
outro(`[${input.status}] ${input.criterion}`);
|
|
28171
|
+
} catch (err) {
|
|
28172
|
+
log.error(err instanceof DeliveryPlanningWriteError ? err.message : String(err));
|
|
28173
|
+
process.exit(1);
|
|
28174
|
+
}
|
|
28175
|
+
}
|
|
28176
|
+
function runEpicStart(id) {
|
|
28177
|
+
const dir = cwd();
|
|
28178
|
+
requireInit(dir);
|
|
28179
|
+
intro(`kaddo epic start ${id}`);
|
|
28180
|
+
try {
|
|
28181
|
+
const e = transitionEpic(dir, id, "in-progress");
|
|
28182
|
+
log.success(`Epic ${e.id} is now ${e.status}.`);
|
|
28183
|
+
outro("Started.");
|
|
28184
|
+
} catch (err) {
|
|
28185
|
+
log.error(err instanceof DeliveryPlanningWriteError ? err.message : String(err));
|
|
28186
|
+
process.exit(1);
|
|
28187
|
+
}
|
|
28188
|
+
}
|
|
28189
|
+
function runEpicVerify(id, opts = {}) {
|
|
28190
|
+
const dir = cwd();
|
|
28191
|
+
requireInit(dir);
|
|
28192
|
+
const epic = getEpic(dir, id);
|
|
28193
|
+
if (!epic) {
|
|
28194
|
+
if (opts.json) console.log(JSON.stringify({ error: `Epic ${id} not found.` }));
|
|
28195
|
+
else log.error(`Epic ${id} not found.`);
|
|
28196
|
+
process.exit(1);
|
|
28197
|
+
}
|
|
28198
|
+
const ev = evaluateEpicCompletion(dir, epic);
|
|
28199
|
+
if (opts.json) {
|
|
28200
|
+
console.log(JSON.stringify(ev, null, 2));
|
|
28201
|
+
return;
|
|
28202
|
+
}
|
|
28203
|
+
intro(`kaddo epic verify ${id}`);
|
|
28204
|
+
printEvaluation(ev);
|
|
28205
|
+
outro(`Epic ${id} \u2014 ${ev.readiness}.`);
|
|
28206
|
+
}
|
|
28207
|
+
async function runEpicComplete(id, opts = {}) {
|
|
28208
|
+
const dir = cwd();
|
|
28209
|
+
requireInit(dir);
|
|
28210
|
+
intro(`kaddo epic complete ${id}`);
|
|
28211
|
+
const epic = getEpic(dir, id);
|
|
28212
|
+
if (!epic) {
|
|
28213
|
+
log.error(`Epic ${id} not found.`);
|
|
28214
|
+
process.exit(1);
|
|
28215
|
+
}
|
|
28216
|
+
const ev = evaluateEpicCompletion(dir, epic);
|
|
28217
|
+
printEvaluation(ev);
|
|
28218
|
+
if (ev.readiness !== "READY_TO_COMPLETE" && ev.readiness !== "READY_WITH_EXCEPTIONS") {
|
|
28219
|
+
log.error(`Epic ${id} is not ready to complete (${ev.readiness}).`);
|
|
28220
|
+
process.exit(1);
|
|
28221
|
+
}
|
|
28222
|
+
const ok = opts.yes === true || await confirm({ message: `Complete Epic ${id}? This records a human completion decision.` }) === true;
|
|
28223
|
+
if (!ok) {
|
|
28224
|
+
cancel("Cancelled.");
|
|
28225
|
+
return;
|
|
28226
|
+
}
|
|
28227
|
+
try {
|
|
28228
|
+
const done = completeEpic(dir, id, { decidedBy: opts.by });
|
|
28229
|
+
log.success(`Epic ${done.id} completed (${ev.readiness}).`);
|
|
28230
|
+
outro("Completion decision recorded.");
|
|
28231
|
+
} catch (err) {
|
|
28232
|
+
log.error(err instanceof PlanningNotReadyError || err instanceof DeliveryPlanningWriteError ? err.message : String(err));
|
|
28233
|
+
process.exit(1);
|
|
28234
|
+
}
|
|
28235
|
+
}
|
|
28236
|
+
function runEpicEvidence(id, opts = {}) {
|
|
28237
|
+
const dir = cwd();
|
|
28238
|
+
requireInit(dir);
|
|
28239
|
+
intro(`kaddo epic evidence ${id}`);
|
|
28240
|
+
const input = evidenceInput(opts);
|
|
28241
|
+
try {
|
|
28242
|
+
recordEpicOutcomeVerification(dir, id, input);
|
|
28243
|
+
log.success("Recorded Epic outcome evidence.");
|
|
28244
|
+
outro(`[${input.status}] ${input.criterion}`);
|
|
28245
|
+
} catch (err) {
|
|
28246
|
+
log.error(err instanceof DeliveryPlanningWriteError ? err.message : String(err));
|
|
28247
|
+
process.exit(1);
|
|
28248
|
+
}
|
|
28249
|
+
}
|
|
27346
28250
|
|
|
27347
28251
|
// src/core/telemetry.ts
|
|
27348
28252
|
import crypto6 from "crypto";
|
|
@@ -27387,9 +28291,9 @@ function markRegistered(dir, identity) {
|
|
|
27387
28291
|
ensureDir(join(dir, TELEMETRY_DIR));
|
|
27388
28292
|
writeFile(identityPath(dir), JSON.stringify(identity, null, 2));
|
|
27389
28293
|
}
|
|
27390
|
-
function signPayload(identity, method,
|
|
28294
|
+
function signPayload(identity, method, path18, timestamp, nonce, bodySha256) {
|
|
27391
28295
|
const canonical = `${method}
|
|
27392
|
-
${
|
|
28296
|
+
${path18}
|
|
27393
28297
|
${identity.installationId}
|
|
27394
28298
|
${timestamp}
|
|
27395
28299
|
${nonce}
|
|
@@ -27614,6 +28518,75 @@ function runTelemetryDisable() {
|
|
|
27614
28518
|
outro("Run `kaddo telemetry enable` to re-enable.");
|
|
27615
28519
|
}
|
|
27616
28520
|
|
|
28521
|
+
// src/core/collaboration.ts
|
|
28522
|
+
import path17 from "path";
|
|
28523
|
+
function matchesWorkItemReference(value, id) {
|
|
28524
|
+
return new RegExp(`(^|[^A-Za-z0-9_-])${id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?=$|[^A-Za-z0-9_-])`, "i").test(value);
|
|
28525
|
+
}
|
|
28526
|
+
async function observationsForProject(dir) {
|
|
28527
|
+
const corePath = path17.resolve(dir);
|
|
28528
|
+
const mapped = loadMappedModules(dir).filter((module) => Boolean(module.repoPath)).map((module) => ({ path: path17.resolve(corePath, module.repoPath), repositoryId: `module:${module.id}` }));
|
|
28529
|
+
const candidates = [{ path: corePath, repositoryId: "core" }, ...mapped];
|
|
28530
|
+
const resolved = await Promise.all(candidates.map(async (candidate) => ({ ...candidate, root: await getGitRoot(candidate.path) })));
|
|
28531
|
+
const repositories = /* @__PURE__ */ new Map();
|
|
28532
|
+
for (const item of resolved) if (item.root && !repositories.has(item.root)) repositories.set(item.root, { root: item.root, repositoryId: item.repositoryId });
|
|
28533
|
+
const observations = await Promise.all([...repositories.values()].map((repo) => observeGit(repo.root, 100, repo.repositoryId)));
|
|
28534
|
+
return observations;
|
|
28535
|
+
}
|
|
28536
|
+
async function collaborationForWorkItems(dir, ids) {
|
|
28537
|
+
const observations = await observationsForProject(dir);
|
|
28538
|
+
return ids.map((id) => {
|
|
28539
|
+
const wi = getWorkItem(dir, id);
|
|
28540
|
+
const linkedCommits = [];
|
|
28541
|
+
const relatedBranches = [];
|
|
28542
|
+
for (const observation of observations) {
|
|
28543
|
+
const repository = observation.repository ?? "local";
|
|
28544
|
+
for (const commit of observation.commits) {
|
|
28545
|
+
if (!matchesWorkItemReference(commit.subject, wi.id)) continue;
|
|
28546
|
+
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.` });
|
|
28547
|
+
}
|
|
28548
|
+
for (const branch of observation.branches) {
|
|
28549
|
+
if (!matchesWorkItemReference(branch.name, wi.id)) continue;
|
|
28550
|
+
relatedBranches.push({ repository, name: branch.name, attribution: "branch-associated", evidence: `Exact reference ${wi.id} in local branch name.` });
|
|
28551
|
+
}
|
|
28552
|
+
}
|
|
28553
|
+
const inspectedCommits = observations.reduce((total, observation) => total + observation.commits.length, 0);
|
|
28554
|
+
const available = observations.filter((observation) => observation.availability === "available").length;
|
|
28555
|
+
const availability = available === observations.length ? "available" : available > 0 ? "partial" : observations.some((observation) => observation.availability === "partial") ? "partial" : "unavailable";
|
|
28556
|
+
return {
|
|
28557
|
+
workItemId: wi.id,
|
|
28558
|
+
responsibility: { owners: wi.owners, contributors: wi.contributors },
|
|
28559
|
+
git: {
|
|
28560
|
+
availability,
|
|
28561
|
+
repositories: observations.flatMap((observation) => observation.repository ? [observation.repository] : []),
|
|
28562
|
+
observedAuthors: [...new Set(linkedCommits.map((commit) => commit.author))],
|
|
28563
|
+
linkedCommits,
|
|
28564
|
+
relatedBranches,
|
|
28565
|
+
unattributedActivityCount: Math.max(0, inspectedCommits - linkedCommits.length),
|
|
28566
|
+
inspectedAt: observations.map((observation) => observation.inspectedAt).sort().at(-1) ?? null,
|
|
28567
|
+
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." }
|
|
28568
|
+
}
|
|
28569
|
+
};
|
|
28570
|
+
});
|
|
28571
|
+
}
|
|
28572
|
+
async function getWorkItemCollaboration(dir, id) {
|
|
28573
|
+
return (await collaborationForWorkItems(dir, [id]))[0];
|
|
28574
|
+
}
|
|
28575
|
+
|
|
28576
|
+
// src/commands/collaboration.ts
|
|
28577
|
+
async function runCollaborationShow(dir, id) {
|
|
28578
|
+
try {
|
|
28579
|
+
console.log(JSON.stringify(await getWorkItemCollaboration(dir, id), null, 2));
|
|
28580
|
+
} catch (err) {
|
|
28581
|
+
if (err instanceof WorkItemNotFoundError) {
|
|
28582
|
+
console.error(err.message);
|
|
28583
|
+
process.exitCode = 1;
|
|
28584
|
+
return;
|
|
28585
|
+
}
|
|
28586
|
+
throw err;
|
|
28587
|
+
}
|
|
28588
|
+
}
|
|
28589
|
+
|
|
27617
28590
|
// src/core/initiative-analysis.ts
|
|
27618
28591
|
var SUCCESS_HEADING_RE = /^#{1,6}\s*(success criteria|criterios de[ét]xito|criterios de éxito)\s*$/i;
|
|
27619
28592
|
var HEADING_RE2 = /^#{1,6}\s+/;
|
|
@@ -27961,6 +28934,9 @@ program.command("create [type]").description("Create a work item (feature, bugfi
|
|
|
27961
28934
|
program.command("ready <id>").description("Mark a draft Work Item as ready for implementation after human review").option("--yes", "Skip confirmation prompt").action(async (id, opts) => {
|
|
27962
28935
|
await runReady(id, opts);
|
|
27963
28936
|
});
|
|
28937
|
+
program.command("start <id>").description("Start a ready Work Item and move it to in-progress").option("--yes", "Skip confirmation prompt").action(async (id, opts) => {
|
|
28938
|
+
await runStart(id, opts);
|
|
28939
|
+
});
|
|
27964
28940
|
var pocCmd = program.command("poc").description("Proof of Concept lifecycle helpers");
|
|
27965
28941
|
pocCmd.command("report").description("Prepare a deterministic final POC report handoff (no LLM call, no write)").option("--json", "Output the report context as JSON").action((opts) => {
|
|
27966
28942
|
runPocReport(opts);
|
|
@@ -27969,8 +28945,8 @@ var capsuleCmd = program.command("capsule").description("Export this project as
|
|
|
27969
28945
|
capsuleCmd.command("export").description("Write a Knowledge Capsule about this project to .kaddo/exports/").option("--scope <scope>", 'Export scope: "system" includes all mapped modules').option("--module <id>", "Export a capsule for a specific mapped module").action((opts) => {
|
|
27970
28946
|
runCapsuleExport(opts);
|
|
27971
28947
|
});
|
|
27972
|
-
capsuleCmd.command("add <path>").description("Register an external Knowledge Capsule as project context (.kaddo/external.yml)").action((
|
|
27973
|
-
runCapsuleAdd(
|
|
28948
|
+
capsuleCmd.command("add <path>").description("Register an external Knowledge Capsule as project context (.kaddo/external.yml)").action((path18) => {
|
|
28949
|
+
runCapsuleAdd(path18);
|
|
27974
28950
|
});
|
|
27975
28951
|
var graphCmd = program.command("graph").description("Export the lightweight, file-based knowledge graph of the project");
|
|
27976
28952
|
graphCmd.command("export").description("Write the knowledge graph to .kaddo/graph.json and .kaddo/graph.mmd").option("--scope <scope>", "Graph scope: active (default) or all").option("--format <format>", "Output format: json, mermaid (default: both)").action((opts) => {
|
|
@@ -27987,6 +28963,12 @@ planCmd.command("progress <id>").description("Planning coverage, delivery progre
|
|
|
27987
28963
|
planCmd.command("create").description("Create a new delivery plan (interactive)").action(() => {
|
|
27988
28964
|
void runPlanCreate();
|
|
27989
28965
|
});
|
|
28966
|
+
planCmd.command("start <id>").description("Transition a Delivery Plan to in-progress (WI-078)").action((id) => runPlanStart(id));
|
|
28967
|
+
planCmd.command("verify <id>").description("Evidence-based completion readiness of a Plan (read-only)").option("--json", "Machine-readable output").action((id, o) => runPlanVerify(id, o));
|
|
28968
|
+
planCmd.command("evidence <id>").description("Record outcome (or milestone exit) verification evidence").requiredOption("--criterion <text>", "The declared success / exit criterion").option("--status <status>", "passed | failed | not-verified | manual-review-required", "passed").option("--evidence <text>", "What the evidence shows").option("--reference <ref>", "File, test, ADR or report").option("--method <method>", "automated | manual").option("--milestone <id>", "Verify a milestone exit criterion instead of a Plan success criterion").option("--by <who>", "Who verified it").action((id, o) => runPlanEvidence(id, o));
|
|
28969
|
+
planCmd.command("complete <id>").description("Complete a Plan after an evidence-based review (human-gated)").option("-y, --yes", "Skip the confirmation prompt").option("--by <who>", "Who approved the completion").action((id, o) => {
|
|
28970
|
+
void runPlanComplete(id, o);
|
|
28971
|
+
});
|
|
27990
28972
|
var epicCmd = program.command("epic").description("Delivery Epics \u2014 significant outcomes spanning Initiatives and Work Items (WI-074)");
|
|
27991
28973
|
epicCmd.command("list").description("List epics with progress").action(() => runEpicList());
|
|
27992
28974
|
epicCmd.command("show <id>").description("Show an epic, its plan/milestone and initiatives").action((id) => runEpicShow(id));
|
|
@@ -27997,6 +28979,12 @@ epicCmd.command("create").description("Create a new epic (interactive)").action(
|
|
|
27997
28979
|
epicCmd.command("associate <epicId> <initiativeId>").description("Associate an existing Initiative with an Epic").action((e, i) => {
|
|
27998
28980
|
void runEpicAssociate(e, i);
|
|
27999
28981
|
});
|
|
28982
|
+
epicCmd.command("start <id>").description("Transition an Epic to in-progress (WI-078)").action((id) => runEpicStart(id));
|
|
28983
|
+
epicCmd.command("verify <id>").description("Evidence-based completion readiness of an Epic (read-only)").option("--json", "Machine-readable output").action((id, o) => runEpicVerify(id, o));
|
|
28984
|
+
epicCmd.command("evidence <id>").description("Record outcome verification evidence for a success criterion").requiredOption("--criterion <text>", "The declared success criterion").option("--status <status>", "passed | failed | not-verified | manual-review-required", "passed").option("--evidence <text>", "What the evidence shows").option("--reference <ref>", "File, test, ADR or report").option("--method <method>", "automated | manual").option("--by <who>", "Who verified it").action((id, o) => runEpicEvidence(id, o));
|
|
28985
|
+
epicCmd.command("complete <id>").description("Complete an Epic after an evidence-based review (human-gated)").option("-y, --yes", "Skip the confirmation prompt").option("--by <who>", "Who approved the completion").action((id, o) => {
|
|
28986
|
+
void runEpicComplete(id, o);
|
|
28987
|
+
});
|
|
28000
28988
|
var topologyCmd = program.command("topology").description("Validate and apply a semantic system topology proposal (agent proposes, human confirms, Core applies)");
|
|
28001
28989
|
topologyCmd.command("validate <file>").description("Validate a topology proposal file deterministically (no write)").action((file) => {
|
|
28002
28990
|
runTopologyValidate(file);
|
|
@@ -28203,6 +29191,10 @@ initiativeCmd.command("analyze <id>").description("Analyze an initiative: succes
|
|
|
28203
29191
|
initiativeCmd.command("complete <id>").description("Review completion readiness and mark an initiative completed (human-confirmed)").option("--yes", "Skip the confirmation prompt").action(async (id, opts) => {
|
|
28204
29192
|
await runInitiativeComplete(id, opts);
|
|
28205
29193
|
});
|
|
29194
|
+
var collaborationCmd = program.command("collaboration").description("Read declared responsibility and bounded, read-only local Git evidence");
|
|
29195
|
+
collaborationCmd.command("show <id>").description("Show collaboration evidence for one Work Item").action(async (id) => {
|
|
29196
|
+
await runCollaborationShow(cwd(), id);
|
|
29197
|
+
});
|
|
28206
29198
|
var telemetryCmd = program.command("telemetry").description("Manage anonymous usage telemetry");
|
|
28207
29199
|
telemetryCmd.command("status").description("Show telemetry status (enabled, registered, pending events)").action(() => {
|
|
28208
29200
|
runTelemetryStatus();
|