@kaddo/cli 3.106.0 → 3.108.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/core.js +438 -267
- package/dist/index.js +466 -257
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8363,7 +8363,7 @@ function runIgnoreRemove(artifactId) {
|
|
|
8363
8363
|
}
|
|
8364
8364
|
|
|
8365
8365
|
// src/commands/explain.ts
|
|
8366
|
-
import
|
|
8366
|
+
import matter7 from "gray-matter";
|
|
8367
8367
|
import { parse as parseYaml13 } from "yaml";
|
|
8368
8368
|
|
|
8369
8369
|
// src/core/delivery-phase.ts
|
|
@@ -10922,6 +10922,181 @@ function loadExternalCapsules(dir) {
|
|
|
10922
10922
|
return out;
|
|
10923
10923
|
}
|
|
10924
10924
|
|
|
10925
|
+
// src/core/initiative.ts
|
|
10926
|
+
import matter4 from "gray-matter";
|
|
10927
|
+
var INITIATIVES_DIR = "knowledge/delivery/initiatives";
|
|
10928
|
+
var INITIATIVE_STATES = [
|
|
10929
|
+
"candidate",
|
|
10930
|
+
"planned",
|
|
10931
|
+
"in-progress",
|
|
10932
|
+
"completed",
|
|
10933
|
+
"deferred",
|
|
10934
|
+
"cancelled"
|
|
10935
|
+
];
|
|
10936
|
+
var INITIATIVE_TRANSITIONS = {
|
|
10937
|
+
candidate: ["planned", "cancelled"],
|
|
10938
|
+
planned: ["in-progress", "deferred", "cancelled"],
|
|
10939
|
+
"in-progress": ["completed", "deferred", "cancelled"],
|
|
10940
|
+
deferred: ["planned", "cancelled"],
|
|
10941
|
+
completed: [],
|
|
10942
|
+
cancelled: []
|
|
10943
|
+
};
|
|
10944
|
+
var STATUS_SET = new Set(INITIATIVE_STATES);
|
|
10945
|
+
function isValidInitiativeStatus(s) {
|
|
10946
|
+
return STATUS_SET.has(s);
|
|
10947
|
+
}
|
|
10948
|
+
function isValidInitiativeTransition(from, to) {
|
|
10949
|
+
return INITIATIVE_TRANSITIONS[from].includes(to);
|
|
10950
|
+
}
|
|
10951
|
+
function toPosix4(p) {
|
|
10952
|
+
return p.replace(/\\/g, "/");
|
|
10953
|
+
}
|
|
10954
|
+
function optStr(v) {
|
|
10955
|
+
if (typeof v === "string" && v.trim()) return v.trim();
|
|
10956
|
+
if (typeof v === "number") return String(v);
|
|
10957
|
+
return void 0;
|
|
10958
|
+
}
|
|
10959
|
+
function strList(v) {
|
|
10960
|
+
if (!Array.isArray(v)) return [];
|
|
10961
|
+
return v.map((x) => typeof x === "string" ? x.trim() : String(x)).filter(Boolean);
|
|
10962
|
+
}
|
|
10963
|
+
function parseCandidates(data) {
|
|
10964
|
+
const raw = data.candidates;
|
|
10965
|
+
if (!Array.isArray(raw)) return [];
|
|
10966
|
+
const out = [];
|
|
10967
|
+
for (const entry of raw) {
|
|
10968
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) continue;
|
|
10969
|
+
const o = entry;
|
|
10970
|
+
const id = optStr(o.id);
|
|
10971
|
+
const title = optStr(o.title);
|
|
10972
|
+
if (!id || !title) continue;
|
|
10973
|
+
out.push({
|
|
10974
|
+
id,
|
|
10975
|
+
title,
|
|
10976
|
+
type: optStr(o.type),
|
|
10977
|
+
suggestedKnowledgeLevel: optStr(o.suggested_knowledge_level ?? o.knowledge_level),
|
|
10978
|
+
expectedValue: optStr(o.expected_value),
|
|
10979
|
+
notes: optStr(o.notes),
|
|
10980
|
+
sourceSignals: strList(o.source_signals),
|
|
10981
|
+
dependencies: strList(o.dependencies),
|
|
10982
|
+
materializedAs: optStr(o.materialized_as) ?? null
|
|
10983
|
+
});
|
|
10984
|
+
}
|
|
10985
|
+
return out;
|
|
10986
|
+
}
|
|
10987
|
+
function parseExternalLinks(data) {
|
|
10988
|
+
const raw = data.external_links;
|
|
10989
|
+
if (!Array.isArray(raw)) return [];
|
|
10990
|
+
const out = [];
|
|
10991
|
+
for (const entry of raw) {
|
|
10992
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) continue;
|
|
10993
|
+
const o = entry;
|
|
10994
|
+
const integration = optStr(o.integration);
|
|
10995
|
+
const externalId = optStr(o.external_id);
|
|
10996
|
+
if (!integration || !externalId) continue;
|
|
10997
|
+
out.push({
|
|
10998
|
+
integration,
|
|
10999
|
+
externalId,
|
|
11000
|
+
externalType: optStr(o.external_type),
|
|
11001
|
+
url: optStr(o.url),
|
|
11002
|
+
externalStatus: optStr(o.external_status)
|
|
11003
|
+
});
|
|
11004
|
+
}
|
|
11005
|
+
return out;
|
|
11006
|
+
}
|
|
11007
|
+
function parseInitiative(dir, filePath, raw) {
|
|
11008
|
+
let parsed;
|
|
11009
|
+
try {
|
|
11010
|
+
parsed = matter4(raw, {});
|
|
11011
|
+
} catch {
|
|
11012
|
+
return null;
|
|
11013
|
+
}
|
|
11014
|
+
const data = parsed.data;
|
|
11015
|
+
if (optStr(data.type) !== "initiative") return null;
|
|
11016
|
+
const id = optStr(data.id);
|
|
11017
|
+
if (!id) return null;
|
|
11018
|
+
const statusRaw = optStr(data.status) ?? "planned";
|
|
11019
|
+
const status = isValidInitiativeStatus(statusRaw) ? statusRaw : "planned";
|
|
11020
|
+
return {
|
|
11021
|
+
id,
|
|
11022
|
+
title: optStr(data.title) ?? id,
|
|
11023
|
+
status,
|
|
11024
|
+
horizon: optStr(data.horizon) ?? null,
|
|
11025
|
+
priority: optStr(data.priority) ?? null,
|
|
11026
|
+
knowledgeLevel: optStr(data.knowledge_level) ?? null,
|
|
11027
|
+
domains: strList(data.domains),
|
|
11028
|
+
relatedCapabilities: strList(data.related_capabilities),
|
|
11029
|
+
source: optStr(data.source) ?? null,
|
|
11030
|
+
sourceId: optStr(data.source_id) ?? null,
|
|
11031
|
+
createdAt: optStr(data.created_at) ?? null,
|
|
11032
|
+
externalLinks: parseExternalLinks(data),
|
|
11033
|
+
candidates: parseCandidates(data),
|
|
11034
|
+
filePath,
|
|
11035
|
+
relPath: toPosix4(filePath).startsWith(toPosix4(dir) + "/") ? toPosix4(filePath).slice(toPosix4(dir).length + 1) : toPosix4(filePath),
|
|
11036
|
+
body: parsed.content.trim(),
|
|
11037
|
+
rawFrontmatter: data
|
|
11038
|
+
};
|
|
11039
|
+
}
|
|
11040
|
+
function discoverInitiatives(dir) {
|
|
11041
|
+
const iniDir = join(dir, INITIATIVES_DIR);
|
|
11042
|
+
if (!exists(iniDir)) return [];
|
|
11043
|
+
const out = [];
|
|
11044
|
+
for (const entry of readDir(iniDir)) {
|
|
11045
|
+
if (!entry.endsWith(".md")) continue;
|
|
11046
|
+
const full = join(iniDir, entry);
|
|
11047
|
+
if (!isFile(full)) continue;
|
|
11048
|
+
const ini = parseInitiative(dir, full, readFile(full));
|
|
11049
|
+
if (ini) out.push(ini);
|
|
11050
|
+
}
|
|
11051
|
+
return out.sort((a, b) => a.id.localeCompare(b.id));
|
|
11052
|
+
}
|
|
11053
|
+
function getInitiative(dir, id) {
|
|
11054
|
+
const want = id.trim().toLowerCase();
|
|
11055
|
+
return discoverInitiatives(dir).find((i) => i.id.toLowerCase() === want) ?? null;
|
|
11056
|
+
}
|
|
11057
|
+
function nextInitiativeId(dir) {
|
|
11058
|
+
const iniDir = join(dir, INITIATIVES_DIR);
|
|
11059
|
+
let max = 0;
|
|
11060
|
+
if (exists(iniDir)) {
|
|
11061
|
+
for (const entry of readDir(iniDir)) {
|
|
11062
|
+
const m = entry.match(/INI-(\d+)/);
|
|
11063
|
+
if (m) max = Math.max(max, parseInt(m[1], 10));
|
|
11064
|
+
}
|
|
11065
|
+
}
|
|
11066
|
+
return `INI-${String(max + 1).padStart(3, "0")}`;
|
|
11067
|
+
}
|
|
11068
|
+
function workItemBelongsToInitiative(workItemInitiative, iniId) {
|
|
11069
|
+
const v = (workItemInitiative ?? "").trim().toLowerCase();
|
|
11070
|
+
return v !== "" && v === iniId.trim().toLowerCase();
|
|
11071
|
+
}
|
|
11072
|
+
function associatedWorkItems(dir, iniId) {
|
|
11073
|
+
return discoverWorkItems(dir).filter((wi) => workItemBelongsToInitiative(wi.initiative, iniId)).map((wi) => ({
|
|
11074
|
+
id: wi.id,
|
|
11075
|
+
title: wi.title,
|
|
11076
|
+
status: wi.lifecycle ?? "ready"
|
|
11077
|
+
})).sort((a, b) => a.id.localeCompare(b.id));
|
|
11078
|
+
}
|
|
11079
|
+
function computeInitiativeProgress(dir, ini) {
|
|
11080
|
+
const totalCandidates = ini.candidates.length;
|
|
11081
|
+
const materialized = ini.candidates.filter((c) => c.materializedAs).length;
|
|
11082
|
+
const byState = emptyLifecycleCounts();
|
|
11083
|
+
const associated = associatedWorkItems(dir, ini.id);
|
|
11084
|
+
for (const wi of associated) byState[wi.status]++;
|
|
11085
|
+
return {
|
|
11086
|
+
initiative: ini.id,
|
|
11087
|
+
status: ini.status,
|
|
11088
|
+
planning: {
|
|
11089
|
+
totalCandidates,
|
|
11090
|
+
materialized,
|
|
11091
|
+
remaining: Math.max(0, totalCandidates - materialized)
|
|
11092
|
+
},
|
|
11093
|
+
delivery: {
|
|
11094
|
+
total: associated.length,
|
|
11095
|
+
byState
|
|
11096
|
+
}
|
|
11097
|
+
};
|
|
11098
|
+
}
|
|
11099
|
+
|
|
10925
11100
|
// src/core/graph.ts
|
|
10926
11101
|
var KNOWLEDGE3 = "knowledge";
|
|
10927
11102
|
var ACTIVE_STATUSES = ["draft", "ready", "in-progress", "blocked"];
|
|
@@ -10929,14 +11104,14 @@ var ALL_STATUSES = ["draft", "ready", "in-progress", "blocked", "completed"];
|
|
|
10929
11104
|
function scopeStatuses(scope) {
|
|
10930
11105
|
return scope === "all" ? { included: ALL_STATUSES, excluded: ["archived"] } : { included: ACTIVE_STATUSES, excluded: ["completed", "archived"] };
|
|
10931
11106
|
}
|
|
10932
|
-
function
|
|
11107
|
+
function toPosix5(p) {
|
|
10933
11108
|
return p.replace(/\\/g, "/");
|
|
10934
11109
|
}
|
|
10935
11110
|
function slug(s) {
|
|
10936
11111
|
return s.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
10937
11112
|
}
|
|
10938
11113
|
function isAdr(a) {
|
|
10939
|
-
return
|
|
11114
|
+
return toPosix5(a.filePath).includes("/tech/decisions/") && Boolean(a.type);
|
|
10940
11115
|
}
|
|
10941
11116
|
function buildGraph(dir, config, opts = {}, now = /* @__PURE__ */ new Date()) {
|
|
10942
11117
|
const scope = opts.scope ?? "active";
|
|
@@ -10975,6 +11150,33 @@ function buildGraph(dir, config, opts = {}, now = /* @__PURE__ */ new Date()) {
|
|
|
10975
11150
|
const includedSet = new Set(included);
|
|
10976
11151
|
const activeWICount = workItems.filter((a) => a.lifecycle && isActiveState(a.lifecycle)).length;
|
|
10977
11152
|
const selectedWIs = workItems.filter((a) => a.lifecycle && includedSet.has(a.lifecycle));
|
|
11153
|
+
for (const ini of discoverInitiatives(dir)) {
|
|
11154
|
+
const iniNodeId = `initiative:${slug(ini.id) || ini.id}`;
|
|
11155
|
+
addNode({
|
|
11156
|
+
id: iniNodeId,
|
|
11157
|
+
type: "initiative",
|
|
11158
|
+
label: `${ini.id} ${ini.title}`.trim(),
|
|
11159
|
+
path: ini.relPath,
|
|
11160
|
+
status: ini.status
|
|
11161
|
+
});
|
|
11162
|
+
for (const cap of ini.relatedCapabilities) {
|
|
11163
|
+
if (!cap.trim()) continue;
|
|
11164
|
+
const capId = `capability:${slug(cap) || cap}`;
|
|
11165
|
+
addNode({ id: capId, type: "capability", label: cap });
|
|
11166
|
+
addEdge(iniNodeId, capId, "targets");
|
|
11167
|
+
}
|
|
11168
|
+
for (const link of ini.externalLinks) {
|
|
11169
|
+
const extId = `external-item:${slug(link.integration) || link.integration}:${slug(link.externalId) || link.externalId}`;
|
|
11170
|
+
addNode({ id: extId, type: "external-item", label: `${link.integration}:${link.externalId}`, path: link.url });
|
|
11171
|
+
addEdge(iniNodeId, extId, "references_external");
|
|
11172
|
+
}
|
|
11173
|
+
for (const cand of ini.candidates) {
|
|
11174
|
+
const candId = `candidate:${cand.id}`;
|
|
11175
|
+
addNode({ id: candId, type: "roadmap-candidate", label: cand.id });
|
|
11176
|
+
addEdge(candId, iniNodeId, "belongs_to");
|
|
11177
|
+
if (cand.materializedAs) addEdge(candId, `wi:${cand.materializedAs}`, "materialized_as");
|
|
11178
|
+
}
|
|
11179
|
+
}
|
|
10978
11180
|
for (const wi of selectedWIs) {
|
|
10979
11181
|
const id = wi.id || wi.title;
|
|
10980
11182
|
if (!id || !id.trim()) continue;
|
|
@@ -11135,14 +11337,14 @@ function loadGraphSummary(dir) {
|
|
|
11135
11337
|
|
|
11136
11338
|
// src/core/graph-hints.ts
|
|
11137
11339
|
var KNOWLEDGE4 = "knowledge";
|
|
11138
|
-
function
|
|
11340
|
+
function toPosix6(p) {
|
|
11139
11341
|
return p.replace(/\\/g, "/");
|
|
11140
11342
|
}
|
|
11141
11343
|
function slug2(s) {
|
|
11142
11344
|
return s.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
11143
11345
|
}
|
|
11144
11346
|
function isAdr2(a) {
|
|
11145
|
-
return
|
|
11347
|
+
return toPosix6(a.filePath).includes("/tech/decisions/") && Boolean(a.type);
|
|
11146
11348
|
}
|
|
11147
11349
|
function capabilityHeadings(dir) {
|
|
11148
11350
|
const p = join(dir, KNOWLEDGE4, "product", "capabilities.md");
|
|
@@ -11377,7 +11579,7 @@ function loadGraphHints(dir) {
|
|
|
11377
11579
|
}
|
|
11378
11580
|
|
|
11379
11581
|
// src/services/installed-skills.ts
|
|
11380
|
-
import
|
|
11582
|
+
import matter5 from "gray-matter";
|
|
11381
11583
|
var SKILLS_DIR = join("knowledge", "skills");
|
|
11382
11584
|
function discoverInstalledSkills(dir) {
|
|
11383
11585
|
const base = join(dir, SKILLS_DIR);
|
|
@@ -11387,7 +11589,7 @@ function discoverInstalledSkills(dir) {
|
|
|
11387
11589
|
const skillFile = join(base, entry, "skill.md");
|
|
11388
11590
|
if (!isFile(skillFile)) continue;
|
|
11389
11591
|
try {
|
|
11390
|
-
const { data } =
|
|
11592
|
+
const { data } = matter5(readFile(skillFile));
|
|
11391
11593
|
if (data.type && String(data.type) !== "skill") continue;
|
|
11392
11594
|
const id = String(data.id ?? entry);
|
|
11393
11595
|
out.push({
|
|
@@ -12931,7 +13133,7 @@ function deriveDeliveryCompletedStatus(dir) {
|
|
|
12931
13133
|
}
|
|
12932
13134
|
|
|
12933
13135
|
// src/core/assets.ts
|
|
12934
|
-
import
|
|
13136
|
+
import matter6 from "gray-matter";
|
|
12935
13137
|
function canonicalAgents() {
|
|
12936
13138
|
return AGENT_PROMPTS.map((a) => ({
|
|
12937
13139
|
name: a.fileName.replace(/\.md$/, ""),
|
|
@@ -12944,7 +13146,7 @@ function canonicalSkills() {
|
|
|
12944
13146
|
}
|
|
12945
13147
|
function versionOf(content) {
|
|
12946
13148
|
try {
|
|
12947
|
-
const v =
|
|
13149
|
+
const v = matter6(content).data.version;
|
|
12948
13150
|
return v === void 0 || v === null ? null : String(v);
|
|
12949
13151
|
} catch {
|
|
12950
13152
|
return null;
|
|
@@ -13099,19 +13301,19 @@ function parseWorkItemSource(frontmatter) {
|
|
|
13099
13301
|
const rawSource = frontmatter.source;
|
|
13100
13302
|
if (rawSource != null && typeof rawSource === "object" && !Array.isArray(rawSource)) {
|
|
13101
13303
|
const obj = rawSource;
|
|
13102
|
-
const t =
|
|
13304
|
+
const t = optStr2(obj.type);
|
|
13103
13305
|
const type = t && isValidSource(t) ? t : "unknown";
|
|
13104
13306
|
return {
|
|
13105
13307
|
type,
|
|
13106
|
-
id:
|
|
13107
|
-
title:
|
|
13108
|
-
context:
|
|
13109
|
-
provider:
|
|
13110
|
-
integration:
|
|
13111
|
-
url:
|
|
13112
|
-
imported_at:
|
|
13113
|
-
external_updated_at:
|
|
13114
|
-
synced_at:
|
|
13308
|
+
id: optStr2(obj.id) ?? optStr2(frontmatter.source_id),
|
|
13309
|
+
title: optStr2(obj.title) ?? optStr2(frontmatter.source_title),
|
|
13310
|
+
context: optStr2(obj.context) ?? optStr2(frontmatter.source_context),
|
|
13311
|
+
provider: optStr2(obj.provider) ?? optStr2(frontmatter.source_provider),
|
|
13312
|
+
integration: optStr2(obj.integration) ?? optStr2(frontmatter.source_integration),
|
|
13313
|
+
url: optStr2(obj.url) ?? optStr2(frontmatter.source_url),
|
|
13314
|
+
imported_at: optStr2(obj.imported_at) ?? optStr2(frontmatter.source_imported_at),
|
|
13315
|
+
external_updated_at: optStr2(obj.external_updated_at) ?? optStr2(frontmatter.source_external_updated_at),
|
|
13316
|
+
synced_at: optStr2(obj.synced_at) ?? optStr2(frontmatter.source_synced_at),
|
|
13115
13317
|
inferred: obj.inferred === true || obj.inferred === "true",
|
|
13116
13318
|
reason: t && !isValidSource(t) ? `Invalid source type in object: "${t}".` : void 0
|
|
13117
13319
|
};
|
|
@@ -13120,28 +13322,28 @@ function parseWorkItemSource(frontmatter) {
|
|
|
13120
13322
|
if (raw && isValidSource(raw)) {
|
|
13121
13323
|
return {
|
|
13122
13324
|
type: raw,
|
|
13123
|
-
id:
|
|
13124
|
-
title:
|
|
13125
|
-
context:
|
|
13126
|
-
provider:
|
|
13127
|
-
url:
|
|
13128
|
-
imported_at:
|
|
13129
|
-
external_updated_at:
|
|
13130
|
-
synced_at:
|
|
13325
|
+
id: optStr2(frontmatter.source_id),
|
|
13326
|
+
title: optStr2(frontmatter.source_title),
|
|
13327
|
+
context: optStr2(frontmatter.source_context),
|
|
13328
|
+
provider: optStr2(frontmatter.source_provider),
|
|
13329
|
+
url: optStr2(frontmatter.source_url),
|
|
13330
|
+
imported_at: optStr2(frontmatter.source_imported_at),
|
|
13331
|
+
external_updated_at: optStr2(frontmatter.source_external_updated_at),
|
|
13332
|
+
synced_at: optStr2(frontmatter.source_synced_at),
|
|
13131
13333
|
inferred: false
|
|
13132
13334
|
};
|
|
13133
13335
|
}
|
|
13134
13336
|
if (raw && !isValidSource(raw)) {
|
|
13135
13337
|
return {
|
|
13136
13338
|
type: "unknown",
|
|
13137
|
-
id:
|
|
13138
|
-
title:
|
|
13139
|
-
context:
|
|
13140
|
-
provider:
|
|
13141
|
-
url:
|
|
13142
|
-
imported_at:
|
|
13143
|
-
external_updated_at:
|
|
13144
|
-
synced_at:
|
|
13339
|
+
id: optStr2(frontmatter.source_id),
|
|
13340
|
+
title: optStr2(frontmatter.source_title),
|
|
13341
|
+
context: optStr2(frontmatter.source_context),
|
|
13342
|
+
provider: optStr2(frontmatter.source_provider),
|
|
13343
|
+
url: optStr2(frontmatter.source_url),
|
|
13344
|
+
imported_at: optStr2(frontmatter.source_imported_at),
|
|
13345
|
+
external_updated_at: optStr2(frontmatter.source_external_updated_at),
|
|
13346
|
+
synced_at: optStr2(frontmatter.source_synced_at),
|
|
13145
13347
|
inferred: true,
|
|
13146
13348
|
reason: `Invalid source value: "${raw}".`
|
|
13147
13349
|
};
|
|
@@ -13149,8 +13351,8 @@ function parseWorkItemSource(frontmatter) {
|
|
|
13149
13351
|
if (frontmatter.source_work_item_candidate || frontmatter.source_roadmap_initiative) {
|
|
13150
13352
|
return {
|
|
13151
13353
|
type: "roadmap",
|
|
13152
|
-
id:
|
|
13153
|
-
title:
|
|
13354
|
+
id: optStr2(frontmatter.source_id) ?? optStr2(frontmatter.source_work_item_candidate),
|
|
13355
|
+
title: optStr2(frontmatter.source_initiative_title),
|
|
13154
13356
|
inferred: true,
|
|
13155
13357
|
reason: "Inferred from legacy roadmap fields."
|
|
13156
13358
|
};
|
|
@@ -13158,7 +13360,7 @@ function parseWorkItemSource(frontmatter) {
|
|
|
13158
13360
|
if (frontmatter.source_id) {
|
|
13159
13361
|
return {
|
|
13160
13362
|
type: "unknown",
|
|
13161
|
-
id:
|
|
13363
|
+
id: optStr2(frontmatter.source_id),
|
|
13162
13364
|
inferred: true,
|
|
13163
13365
|
reason: "Has source_id but no source type."
|
|
13164
13366
|
};
|
|
@@ -13174,7 +13376,7 @@ function renderSourceCompact(source) {
|
|
|
13174
13376
|
if (source.id) parts.push(source.id);
|
|
13175
13377
|
return parts.join(" \xB7 ");
|
|
13176
13378
|
}
|
|
13177
|
-
function
|
|
13379
|
+
function optStr2(v) {
|
|
13178
13380
|
if (typeof v === "string" && v.trim()) return v.trim();
|
|
13179
13381
|
return void 0;
|
|
13180
13382
|
}
|
|
@@ -14427,7 +14629,7 @@ function readKnowledge(dir) {
|
|
|
14427
14629
|
if (!exists(knowledgePath)) return null;
|
|
14428
14630
|
try {
|
|
14429
14631
|
const raw = readFile(knowledgePath);
|
|
14430
|
-
const { data, content } =
|
|
14632
|
+
const { data, content } = matter7(raw);
|
|
14431
14633
|
return { content, data };
|
|
14432
14634
|
} catch {
|
|
14433
14635
|
return null;
|
|
@@ -14438,7 +14640,7 @@ function readRoadmap(dir) {
|
|
|
14438
14640
|
if (!exists(roadmapPath)) return null;
|
|
14439
14641
|
try {
|
|
14440
14642
|
const raw = readFile(roadmapPath);
|
|
14441
|
-
const { content } =
|
|
14643
|
+
const { content } = matter7(raw);
|
|
14442
14644
|
return content.trim();
|
|
14443
14645
|
} catch {
|
|
14444
14646
|
return null;
|
|
@@ -14607,7 +14809,7 @@ function runExplain(opts) {
|
|
|
14607
14809
|
}
|
|
14608
14810
|
|
|
14609
14811
|
// src/core/context-pack.ts
|
|
14610
|
-
import
|
|
14812
|
+
import matter8 from "gray-matter";
|
|
14611
14813
|
var CONTEXT_PACK_VERSION = "1";
|
|
14612
14814
|
var ARCH_DIR6 = "knowledge";
|
|
14613
14815
|
function readScanJson(dir) {
|
|
@@ -14620,7 +14822,7 @@ function readScanJson(dir) {
|
|
|
14620
14822
|
}
|
|
14621
14823
|
}
|
|
14622
14824
|
function firstParagraph2(markdown) {
|
|
14623
|
-
const body =
|
|
14825
|
+
const body = matter8(markdown).content.trim();
|
|
14624
14826
|
const para = body.split("\n\n").map((p) => p.trim()).find((p) => p && !p.startsWith("#"));
|
|
14625
14827
|
return para ?? "";
|
|
14626
14828
|
}
|
|
@@ -16240,7 +16442,7 @@ function runStatus() {
|
|
|
16240
16442
|
}
|
|
16241
16443
|
|
|
16242
16444
|
// src/commands/learn.ts
|
|
16243
|
-
import
|
|
16445
|
+
import matter9 from "gray-matter";
|
|
16244
16446
|
var ARCH_DIR9 = "knowledge";
|
|
16245
16447
|
var WORK_ITEMS_DIR2 = "knowledge/delivery/work-items";
|
|
16246
16448
|
function findWorkItemFile(dir, id) {
|
|
@@ -16252,7 +16454,7 @@ function findWorkItemFile(dir, id) {
|
|
|
16252
16454
|
}
|
|
16253
16455
|
function updateWorkItemFile(filePath, learning) {
|
|
16254
16456
|
const raw = readFile(filePath);
|
|
16255
|
-
const { data, content } =
|
|
16457
|
+
const { data, content } = matter9(raw);
|
|
16256
16458
|
data.status = "completed";
|
|
16257
16459
|
data.completed_at = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
16258
16460
|
let updatedContent = content;
|
|
@@ -16277,7 +16479,7 @@ ${learning.trim()}
|
|
|
16277
16479
|
${learning.trim()}
|
|
16278
16480
|
`;
|
|
16279
16481
|
}
|
|
16280
|
-
const newRaw =
|
|
16482
|
+
const newRaw = matter9.stringify(updatedContent, data);
|
|
16281
16483
|
writeFile(filePath, newRaw);
|
|
16282
16484
|
}
|
|
16283
16485
|
async function runLearn(artifactId, opts = {}) {
|
|
@@ -16318,7 +16520,7 @@ async function runLearn(artifactId, opts = {}) {
|
|
|
16318
16520
|
process.exit(1);
|
|
16319
16521
|
}
|
|
16320
16522
|
const wiRaw = readFile(filePath);
|
|
16321
|
-
const wiData =
|
|
16523
|
+
const wiData = matter9(wiRaw).data;
|
|
16322
16524
|
if (!opts.force) {
|
|
16323
16525
|
const completionBlockers = [];
|
|
16324
16526
|
const releaseGates = Array.isArray(wiData.release_gates) ? wiData.release_gates : [];
|
|
@@ -16574,7 +16776,7 @@ function runAdd(moduleName, opts = {}, dir = cwd()) {
|
|
|
16574
16776
|
}
|
|
16575
16777
|
|
|
16576
16778
|
// src/core/ownership-suggest.ts
|
|
16577
|
-
import
|
|
16779
|
+
import matter10 from "gray-matter";
|
|
16578
16780
|
var SCAN_PATH = ".kaddo/scan.json";
|
|
16579
16781
|
function normalizeGlob(input) {
|
|
16580
16782
|
let g = input.trim().replace(/\\/g, "/");
|
|
@@ -16696,11 +16898,11 @@ function suggestGlobs(artifact, signals) {
|
|
|
16696
16898
|
return [...new Set(out)];
|
|
16697
16899
|
}
|
|
16698
16900
|
function applyOwnership(raw, globs, mode = "replace") {
|
|
16699
|
-
const parsed =
|
|
16901
|
+
const parsed = matter10(raw);
|
|
16700
16902
|
const existing = toStringArray3(parsed.data.code);
|
|
16701
16903
|
const next = mode === "append" ? [.../* @__PURE__ */ new Set([...existing, ...globs])] : [...new Set(globs)];
|
|
16702
16904
|
const data = { ...parsed.data, code: next };
|
|
16703
|
-
return
|
|
16905
|
+
return matter10.stringify(parsed.content, data);
|
|
16704
16906
|
}
|
|
16705
16907
|
|
|
16706
16908
|
// src/commands/owners.ts
|
|
@@ -17542,7 +17744,7 @@ var PROVENANCE = /* @__PURE__ */ new Set(["declared", "derived", "agent-reviewed
|
|
|
17542
17744
|
function isRelative(p) {
|
|
17543
17745
|
return typeof p === "string" && p.trim() !== "" && !/^([a-zA-Z]:[\\/]|\/)/.test(p) && !p.includes("..");
|
|
17544
17746
|
}
|
|
17545
|
-
function
|
|
17747
|
+
function strList2(v) {
|
|
17546
17748
|
return Array.isArray(v) ? v.map((x) => typeof x === "string" ? x.trim() : "").filter(Boolean) : [];
|
|
17547
17749
|
}
|
|
17548
17750
|
function loadSystemTopology(dir) {
|
|
@@ -17583,7 +17785,7 @@ function parseTopologyContent(raw, dir) {
|
|
|
17583
17785
|
const moduleRaw = typeof e.module === "string" ? e.module.trim() : void 0;
|
|
17584
17786
|
if (moduleRaw && !validModules.has(moduleRaw)) findings.push({ level: "warning", message: `Entity "${id}" references unregistered module "${moduleRaw}".` });
|
|
17585
17787
|
const rawImpl = e.implementation ?? e.implementation_refs;
|
|
17586
|
-
const implementation =
|
|
17788
|
+
const implementation = strList2(rawImpl).filter((p) => {
|
|
17587
17789
|
if (isRelative(p)) return true;
|
|
17588
17790
|
findings.push({ level: "warning", message: `Entity "${id}" implementation ref "${p}" is not a safe relative path and was dropped.` });
|
|
17589
17791
|
return false;
|
|
@@ -17591,7 +17793,7 @@ function parseTopologyContent(raw, dir) {
|
|
|
17591
17793
|
const prov = e.provenance;
|
|
17592
17794
|
const provOrigin = typeof prov === "string" ? prov : prov && typeof prov === "object" && typeof prov.origin === "string" ? String(prov.origin) : void 0;
|
|
17593
17795
|
const provenance = provOrigin && PROVENANCE.has(provOrigin) ? provOrigin : void 0;
|
|
17594
|
-
const evidence =
|
|
17796
|
+
const evidence = strList2(e.evidence ?? (prov && typeof prov === "object" ? prov.evidence_refs : void 0)).filter(isRelative);
|
|
17595
17797
|
seenIds.add(id);
|
|
17596
17798
|
entities.push({
|
|
17597
17799
|
id,
|
|
@@ -17600,7 +17802,7 @@ function parseTopologyContent(raw, dir) {
|
|
|
17600
17802
|
...typeof e.purpose === "string" && e.purpose.trim() ? { purpose: e.purpose.trim() } : {},
|
|
17601
17803
|
...moduleRaw && validModules.has(moduleRaw) ? { moduleId: moduleRaw } : {},
|
|
17602
17804
|
implementationRefs: implementation,
|
|
17603
|
-
knowledgeRefs:
|
|
17805
|
+
knowledgeRefs: strList2(e.knowledge ?? e.knowledge_refs),
|
|
17604
17806
|
...provenance ? { provenance } : {},
|
|
17605
17807
|
evidence
|
|
17606
17808
|
});
|
|
@@ -17634,7 +17836,7 @@ function parseTopologyContent(raw, dir) {
|
|
|
17634
17836
|
}
|
|
17635
17837
|
seenRels.add(key);
|
|
17636
17838
|
const prov = r.provenance;
|
|
17637
|
-
relationships.push({ from, to, type, evidence:
|
|
17839
|
+
relationships.push({ from, to, type, evidence: strList2(r.evidence ?? prov?.evidence_refs).filter(isRelative) });
|
|
17638
17840
|
}
|
|
17639
17841
|
return { entities, relationships, findings, ...sourceRevision ? { sourceRevision } : {} };
|
|
17640
17842
|
}
|
|
@@ -17788,14 +17990,14 @@ async function runTopologyApply(file, opts = {}) {
|
|
|
17788
17990
|
}
|
|
17789
17991
|
|
|
17790
17992
|
// src/services/integrations.ts
|
|
17791
|
-
import
|
|
17993
|
+
import matter12 from "gray-matter";
|
|
17792
17994
|
import { parse as parseYaml18, stringify as stringifyYaml9 } from "yaml";
|
|
17793
17995
|
|
|
17794
17996
|
// src/core/work-item-write.ts
|
|
17795
17997
|
import fs4 from "fs";
|
|
17796
17998
|
import path8 from "path";
|
|
17797
17999
|
import crypto2 from "crypto";
|
|
17798
|
-
import
|
|
18000
|
+
import matter11 from "gray-matter";
|
|
17799
18001
|
var WORK_ITEMS_DIR3 = "knowledge/delivery/work-items";
|
|
17800
18002
|
var WorkItemWriteError = class extends Error {
|
|
17801
18003
|
constructor(code, message) {
|
|
@@ -17891,7 +18093,7 @@ ${out.join("\n\n")}
|
|
|
17891
18093
|
`.replace(/\n{3,}/g, "\n\n");
|
|
17892
18094
|
}
|
|
17893
18095
|
function serialize(data, body) {
|
|
17894
|
-
return
|
|
18096
|
+
return matter11.stringify(`
|
|
17895
18097
|
${body.trim()}
|
|
17896
18098
|
`, data);
|
|
17897
18099
|
}
|
|
@@ -18966,7 +19168,7 @@ function findLinkedWorkItem(dir, integrationId, externalId) {
|
|
|
18966
19168
|
for (const art of discoverWorkItems(dir)) {
|
|
18967
19169
|
let data;
|
|
18968
19170
|
try {
|
|
18969
|
-
data =
|
|
19171
|
+
data = matter12(readFile(art.filePath)).data;
|
|
18970
19172
|
} catch {
|
|
18971
19173
|
continue;
|
|
18972
19174
|
}
|
|
@@ -19179,7 +19381,7 @@ async function runIntegrationsImport(dir, id, externalId, opts) {
|
|
|
19179
19381
|
}
|
|
19180
19382
|
|
|
19181
19383
|
// src/core/impact-report.ts
|
|
19182
|
-
import
|
|
19384
|
+
import matter13 from "gray-matter";
|
|
19183
19385
|
function isBroadGlob(glob) {
|
|
19184
19386
|
if (!glob.endsWith("/**")) return false;
|
|
19185
19387
|
const prefix = glob.slice(0, -3);
|
|
@@ -19248,7 +19450,7 @@ function buildImpactReport(dir, opts = {}, now = /* @__PURE__ */ new Date()) {
|
|
|
19248
19450
|
}
|
|
19249
19451
|
}
|
|
19250
19452
|
try {
|
|
19251
|
-
const body =
|
|
19453
|
+
const body = matter13(readFile(wi.filePath)).content;
|
|
19252
19454
|
if (hasSection(body, /acceptance|criterios de aceptaci/i)) withAcceptance++;
|
|
19253
19455
|
else gaps.missing_acceptance_criteria.push(gapItem(wi, "Add an `## Acceptance Criteria` section."));
|
|
19254
19456
|
if (hasSection(body, /definition of done|^#{1,6}\s*dod\b|definici[oó]n de (terminado|hecho)/i)) withDoD++;
|
|
@@ -20426,7 +20628,7 @@ function runAssetsUpdate(kind, opts = {}) {
|
|
|
20426
20628
|
// src/commands/ready.ts
|
|
20427
20629
|
import fs6 from "fs";
|
|
20428
20630
|
import path9 from "path";
|
|
20429
|
-
import
|
|
20631
|
+
import matter14 from "gray-matter";
|
|
20430
20632
|
function validateReadiness(content, frontmatter) {
|
|
20431
20633
|
const warnings = [];
|
|
20432
20634
|
const body = content.replace(/^---[\s\S]*?---/, "").trim();
|
|
@@ -20480,11 +20682,11 @@ function isResolvedSection(text2) {
|
|
|
20480
20682
|
}
|
|
20481
20683
|
function transitionToReady(filePath) {
|
|
20482
20684
|
const raw = readFile(filePath);
|
|
20483
|
-
const { data, content } =
|
|
20685
|
+
const { data, content } = matter14(raw);
|
|
20484
20686
|
const today3 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
20485
20687
|
data.status = "ready";
|
|
20486
20688
|
data.ready_at = today3;
|
|
20487
|
-
const newContent =
|
|
20689
|
+
const newContent = matter14.stringify(content, data);
|
|
20488
20690
|
const posix = filePath.replace(/\\/g, "/");
|
|
20489
20691
|
let newPath = filePath;
|
|
20490
20692
|
if (posix.includes("/work-items/draft/")) {
|
|
@@ -20524,7 +20726,7 @@ async function runReady(id, opts = {}) {
|
|
|
20524
20726
|
process.exit(1);
|
|
20525
20727
|
}
|
|
20526
20728
|
const raw = readFile(wi.filePath);
|
|
20527
|
-
const { data } =
|
|
20729
|
+
const { data } = matter14(raw);
|
|
20528
20730
|
const source = parseWorkItemSource(data);
|
|
20529
20731
|
const warnings = validateReadiness(raw, data);
|
|
20530
20732
|
log.info(`Work Item found:`);
|
|
@@ -20696,10 +20898,10 @@ async function runAdmin(opts = {}) {
|
|
|
20696
20898
|
// src/core/work-item-import.ts
|
|
20697
20899
|
import crypto3 from "crypto";
|
|
20698
20900
|
import fs7 from "fs";
|
|
20699
|
-
import
|
|
20901
|
+
import matter16 from "gray-matter";
|
|
20700
20902
|
|
|
20701
20903
|
// src/core/work-items.ts
|
|
20702
|
-
import
|
|
20904
|
+
import matter15 from "gray-matter";
|
|
20703
20905
|
function computeRefinementStatus(wi) {
|
|
20704
20906
|
const aspects = {
|
|
20705
20907
|
outcome: Boolean(wi.currentBehavior?.trim() || wi.targetBehavior?.trim()),
|
|
@@ -20829,7 +21031,7 @@ function parseOriginalSnapshot(fm2) {
|
|
|
20829
21031
|
function readBody(filePath) {
|
|
20830
21032
|
try {
|
|
20831
21033
|
const raw = readFile(filePath);
|
|
20832
|
-
return
|
|
21034
|
+
return matter15(raw).content;
|
|
20833
21035
|
} catch {
|
|
20834
21036
|
return "";
|
|
20835
21037
|
}
|
|
@@ -20913,7 +21115,7 @@ function normalizeImpact(ia) {
|
|
|
20913
21115
|
...v.question ? { question: v.question } : {}
|
|
20914
21116
|
}));
|
|
20915
21117
|
}
|
|
20916
|
-
function
|
|
21118
|
+
function optStr3(v) {
|
|
20917
21119
|
if (typeof v === "string" && v.trim()) return v.trim();
|
|
20918
21120
|
return void 0;
|
|
20919
21121
|
}
|
|
@@ -20928,13 +21130,13 @@ function parseEvidence(fm2) {
|
|
|
20928
21130
|
const validations = Array.isArray(d.validations) ? d.validations.map((v) => ({
|
|
20929
21131
|
command: String(v.command ?? ""),
|
|
20930
21132
|
status: String(v.status ?? "unknown"),
|
|
20931
|
-
...
|
|
21133
|
+
...optStr3(v.reason) ? { reason: optStr3(v.reason) } : {}
|
|
20932
21134
|
})) : [];
|
|
20933
21135
|
const migrations = Array.isArray(d.migrations) ? d.migrations.map((m) => ({
|
|
20934
21136
|
id: String(m.id ?? ""),
|
|
20935
21137
|
environment: String(m.environment ?? ""),
|
|
20936
21138
|
status: String(m.status ?? "unknown"),
|
|
20937
|
-
...
|
|
21139
|
+
...optStr3(m.reason) ? { reason: optStr3(m.reason) } : {}
|
|
20938
21140
|
})) : [];
|
|
20939
21141
|
out.push({
|
|
20940
21142
|
module,
|
|
@@ -20952,8 +21154,8 @@ function parseReleaseGates(fm2) {
|
|
|
20952
21154
|
return fm2.release_gates.filter((g) => g && typeof g === "object").map((g) => ({
|
|
20953
21155
|
id: String(g.id ?? ""),
|
|
20954
21156
|
status: String(g.status ?? "pending"),
|
|
20955
|
-
...
|
|
20956
|
-
...
|
|
21157
|
+
...optStr3(g.reason) ? { reason: optStr3(g.reason) } : {},
|
|
21158
|
+
...optStr3(g.required_for) ? { requiredFor: optStr3(g.required_for) } : {}
|
|
20957
21159
|
}));
|
|
20958
21160
|
}
|
|
20959
21161
|
function parseExceptions(fm2) {
|
|
@@ -20961,9 +21163,9 @@ function parseExceptions(fm2) {
|
|
|
20961
21163
|
return fm2.completion_exceptions.filter((e) => e && typeof e === "object").map((e) => ({
|
|
20962
21164
|
id: String(e.id ?? ""),
|
|
20963
21165
|
status: String(e.status ?? "proposed"),
|
|
20964
|
-
...
|
|
20965
|
-
...
|
|
20966
|
-
...
|
|
21166
|
+
...optStr3(e.reason) ? { reason: optStr3(e.reason) } : {},
|
|
21167
|
+
...optStr3(e.category) ? { category: optStr3(e.category) } : {},
|
|
21168
|
+
...optStr3(e.impact) ? { impact: optStr3(e.impact) } : {}
|
|
20967
21169
|
}));
|
|
20968
21170
|
}
|
|
20969
21171
|
function parseDecisions(decisions, knowledgeById) {
|
|
@@ -21288,7 +21490,7 @@ function detectFormat(raw) {
|
|
|
21288
21490
|
if (!trimmed) throw new ImportError("EMPTY_INPUT", "Import content is empty.");
|
|
21289
21491
|
if (trimmed.startsWith("---")) {
|
|
21290
21492
|
try {
|
|
21291
|
-
const { data } =
|
|
21493
|
+
const { data } = matter16(trimmed);
|
|
21292
21494
|
if (data && typeof data === "object" && Object.keys(data).length > 0) {
|
|
21293
21495
|
const d = data;
|
|
21294
21496
|
if (d.type === "work-item" || d.id && typeof d.id === "string" && /^WI-\d+/.test(d.id)) {
|
|
@@ -21310,7 +21512,7 @@ function parseContent(raw) {
|
|
|
21310
21512
|
let bodyText = trimmed;
|
|
21311
21513
|
if (format === "kaddo-frontmatter" || format === "markdown-frontmatter") {
|
|
21312
21514
|
try {
|
|
21313
|
-
const parsed =
|
|
21515
|
+
const parsed = matter16(trimmed);
|
|
21314
21516
|
frontmatterFields = parsed.data ?? {};
|
|
21315
21517
|
bodyText = parsed.content.trim();
|
|
21316
21518
|
} catch {
|
|
@@ -21401,7 +21603,7 @@ function findDuplicateByHash(dir, hash) {
|
|
|
21401
21603
|
const raw = readFile(item.filePath);
|
|
21402
21604
|
if (!raw) continue;
|
|
21403
21605
|
try {
|
|
21404
|
-
const { data } =
|
|
21606
|
+
const { data } = matter16(raw);
|
|
21405
21607
|
const source = data?.source;
|
|
21406
21608
|
if (source && typeof source === "object" && !Array.isArray(source)) {
|
|
21407
21609
|
const s = source;
|
|
@@ -21615,7 +21817,7 @@ async function runWorkItemImport(dir, fileOrText, opts) {
|
|
|
21615
21817
|
}
|
|
21616
21818
|
|
|
21617
21819
|
// src/commands/verify.ts
|
|
21618
|
-
import
|
|
21820
|
+
import matter17 from "gray-matter";
|
|
21619
21821
|
|
|
21620
21822
|
// src/core/implementation-evidence.ts
|
|
21621
21823
|
var WorkItemNotInProgressError = class extends Error {
|
|
@@ -21892,7 +22094,7 @@ async function runVerify(workItemId, opts = {}) {
|
|
|
21892
22094
|
}
|
|
21893
22095
|
const changedPaths = await getModifiedFiles("head");
|
|
21894
22096
|
const raw = readFile(match.filePath);
|
|
21895
|
-
const parsed =
|
|
22097
|
+
const parsed = matter17(raw);
|
|
21896
22098
|
const fm2 = parsed.data;
|
|
21897
22099
|
const acs = extractACsFromBody(parsed.content);
|
|
21898
22100
|
const existingEvidence = fm2.implementation_evidence;
|
|
@@ -22009,13 +22211,13 @@ async function runVerify(workItemId, opts = {}) {
|
|
|
22009
22211
|
if (shouldPersist) {
|
|
22010
22212
|
const filePath = match.filePath;
|
|
22011
22213
|
const wiRaw = readFile(filePath);
|
|
22012
|
-
const wiParsed =
|
|
22214
|
+
const wiParsed = matter17(wiRaw);
|
|
22013
22215
|
const data = wiParsed.data;
|
|
22014
22216
|
data.implementation_evidence = verification.implementationEvidence;
|
|
22015
22217
|
data.implementation_status = verification.implementationStatus;
|
|
22016
22218
|
data.validation_status = verification.validationStatus;
|
|
22017
22219
|
data.verified_at = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
22018
|
-
const newRaw =
|
|
22220
|
+
const newRaw = matter17.stringify(wiParsed.content, data);
|
|
22019
22221
|
writeFile(filePath, newRaw);
|
|
22020
22222
|
log.success("Work Item frontmatter updated with verification evidence.");
|
|
22021
22223
|
}
|
|
@@ -22292,180 +22494,6 @@ function runTelemetryDisable() {
|
|
|
22292
22494
|
outro("Run `kaddo telemetry enable` to re-enable.");
|
|
22293
22495
|
}
|
|
22294
22496
|
|
|
22295
|
-
// src/core/initiative.ts
|
|
22296
|
-
import matter17 from "gray-matter";
|
|
22297
|
-
var INITIATIVES_DIR = "knowledge/delivery/initiatives";
|
|
22298
|
-
var INITIATIVE_STATES = [
|
|
22299
|
-
"candidate",
|
|
22300
|
-
"planned",
|
|
22301
|
-
"in-progress",
|
|
22302
|
-
"completed",
|
|
22303
|
-
"deferred",
|
|
22304
|
-
"cancelled"
|
|
22305
|
-
];
|
|
22306
|
-
var INITIATIVE_TRANSITIONS = {
|
|
22307
|
-
candidate: ["planned", "cancelled"],
|
|
22308
|
-
planned: ["in-progress", "deferred", "cancelled"],
|
|
22309
|
-
"in-progress": ["completed", "deferred", "cancelled"],
|
|
22310
|
-
deferred: ["planned", "cancelled"],
|
|
22311
|
-
completed: [],
|
|
22312
|
-
cancelled: []
|
|
22313
|
-
};
|
|
22314
|
-
var STATUS_SET = new Set(INITIATIVE_STATES);
|
|
22315
|
-
function isValidInitiativeStatus(s) {
|
|
22316
|
-
return STATUS_SET.has(s);
|
|
22317
|
-
}
|
|
22318
|
-
function isValidInitiativeTransition(from, to) {
|
|
22319
|
-
return INITIATIVE_TRANSITIONS[from].includes(to);
|
|
22320
|
-
}
|
|
22321
|
-
function toPosix6(p) {
|
|
22322
|
-
return p.replace(/\\/g, "/");
|
|
22323
|
-
}
|
|
22324
|
-
function optStr3(v) {
|
|
22325
|
-
if (typeof v === "string" && v.trim()) return v.trim();
|
|
22326
|
-
if (typeof v === "number") return String(v);
|
|
22327
|
-
return void 0;
|
|
22328
|
-
}
|
|
22329
|
-
function strList2(v) {
|
|
22330
|
-
if (!Array.isArray(v)) return [];
|
|
22331
|
-
return v.map((x) => typeof x === "string" ? x.trim() : String(x)).filter(Boolean);
|
|
22332
|
-
}
|
|
22333
|
-
function parseCandidates(data) {
|
|
22334
|
-
const raw = data.candidates;
|
|
22335
|
-
if (!Array.isArray(raw)) return [];
|
|
22336
|
-
const out = [];
|
|
22337
|
-
for (const entry of raw) {
|
|
22338
|
-
if (!entry || typeof entry !== "object" || Array.isArray(entry)) continue;
|
|
22339
|
-
const o = entry;
|
|
22340
|
-
const id = optStr3(o.id);
|
|
22341
|
-
const title = optStr3(o.title);
|
|
22342
|
-
if (!id || !title) continue;
|
|
22343
|
-
out.push({
|
|
22344
|
-
id,
|
|
22345
|
-
title,
|
|
22346
|
-
type: optStr3(o.type),
|
|
22347
|
-
suggestedKnowledgeLevel: optStr3(o.suggested_knowledge_level ?? o.knowledge_level),
|
|
22348
|
-
expectedValue: optStr3(o.expected_value),
|
|
22349
|
-
notes: optStr3(o.notes),
|
|
22350
|
-
sourceSignals: strList2(o.source_signals),
|
|
22351
|
-
dependencies: strList2(o.dependencies),
|
|
22352
|
-
materializedAs: optStr3(o.materialized_as) ?? null
|
|
22353
|
-
});
|
|
22354
|
-
}
|
|
22355
|
-
return out;
|
|
22356
|
-
}
|
|
22357
|
-
function parseExternalLinks(data) {
|
|
22358
|
-
const raw = data.external_links;
|
|
22359
|
-
if (!Array.isArray(raw)) return [];
|
|
22360
|
-
const out = [];
|
|
22361
|
-
for (const entry of raw) {
|
|
22362
|
-
if (!entry || typeof entry !== "object" || Array.isArray(entry)) continue;
|
|
22363
|
-
const o = entry;
|
|
22364
|
-
const integration = optStr3(o.integration);
|
|
22365
|
-
const externalId = optStr3(o.external_id);
|
|
22366
|
-
if (!integration || !externalId) continue;
|
|
22367
|
-
out.push({
|
|
22368
|
-
integration,
|
|
22369
|
-
externalId,
|
|
22370
|
-
externalType: optStr3(o.external_type),
|
|
22371
|
-
url: optStr3(o.url)
|
|
22372
|
-
});
|
|
22373
|
-
}
|
|
22374
|
-
return out;
|
|
22375
|
-
}
|
|
22376
|
-
function parseInitiative(dir, filePath, raw) {
|
|
22377
|
-
let parsed;
|
|
22378
|
-
try {
|
|
22379
|
-
parsed = matter17(raw, {});
|
|
22380
|
-
} catch {
|
|
22381
|
-
return null;
|
|
22382
|
-
}
|
|
22383
|
-
const data = parsed.data;
|
|
22384
|
-
if (optStr3(data.type) !== "initiative") return null;
|
|
22385
|
-
const id = optStr3(data.id);
|
|
22386
|
-
if (!id) return null;
|
|
22387
|
-
const statusRaw = optStr3(data.status) ?? "planned";
|
|
22388
|
-
const status = isValidInitiativeStatus(statusRaw) ? statusRaw : "planned";
|
|
22389
|
-
return {
|
|
22390
|
-
id,
|
|
22391
|
-
title: optStr3(data.title) ?? id,
|
|
22392
|
-
status,
|
|
22393
|
-
horizon: optStr3(data.horizon) ?? null,
|
|
22394
|
-
priority: optStr3(data.priority) ?? null,
|
|
22395
|
-
knowledgeLevel: optStr3(data.knowledge_level) ?? null,
|
|
22396
|
-
domains: strList2(data.domains),
|
|
22397
|
-
relatedCapabilities: strList2(data.related_capabilities),
|
|
22398
|
-
source: optStr3(data.source) ?? null,
|
|
22399
|
-
sourceId: optStr3(data.source_id) ?? null,
|
|
22400
|
-
createdAt: optStr3(data.created_at) ?? null,
|
|
22401
|
-
externalLinks: parseExternalLinks(data),
|
|
22402
|
-
candidates: parseCandidates(data),
|
|
22403
|
-
filePath,
|
|
22404
|
-
relPath: toPosix6(filePath).startsWith(toPosix6(dir) + "/") ? toPosix6(filePath).slice(toPosix6(dir).length + 1) : toPosix6(filePath),
|
|
22405
|
-
body: parsed.content.trim(),
|
|
22406
|
-
rawFrontmatter: data
|
|
22407
|
-
};
|
|
22408
|
-
}
|
|
22409
|
-
function discoverInitiatives(dir) {
|
|
22410
|
-
const iniDir = join(dir, INITIATIVES_DIR);
|
|
22411
|
-
if (!exists(iniDir)) return [];
|
|
22412
|
-
const out = [];
|
|
22413
|
-
for (const entry of readDir(iniDir)) {
|
|
22414
|
-
if (!entry.endsWith(".md")) continue;
|
|
22415
|
-
const full = join(iniDir, entry);
|
|
22416
|
-
if (!isFile(full)) continue;
|
|
22417
|
-
const ini = parseInitiative(dir, full, readFile(full));
|
|
22418
|
-
if (ini) out.push(ini);
|
|
22419
|
-
}
|
|
22420
|
-
return out.sort((a, b) => a.id.localeCompare(b.id));
|
|
22421
|
-
}
|
|
22422
|
-
function getInitiative(dir, id) {
|
|
22423
|
-
const want = id.trim().toLowerCase();
|
|
22424
|
-
return discoverInitiatives(dir).find((i) => i.id.toLowerCase() === want) ?? null;
|
|
22425
|
-
}
|
|
22426
|
-
function nextInitiativeId(dir) {
|
|
22427
|
-
const iniDir = join(dir, INITIATIVES_DIR);
|
|
22428
|
-
let max = 0;
|
|
22429
|
-
if (exists(iniDir)) {
|
|
22430
|
-
for (const entry of readDir(iniDir)) {
|
|
22431
|
-
const m = entry.match(/INI-(\d+)/);
|
|
22432
|
-
if (m) max = Math.max(max, parseInt(m[1], 10));
|
|
22433
|
-
}
|
|
22434
|
-
}
|
|
22435
|
-
return `INI-${String(max + 1).padStart(3, "0")}`;
|
|
22436
|
-
}
|
|
22437
|
-
function workItemBelongsToInitiative(workItemInitiative, iniId) {
|
|
22438
|
-
const v = (workItemInitiative ?? "").trim().toLowerCase();
|
|
22439
|
-
return v !== "" && v === iniId.trim().toLowerCase();
|
|
22440
|
-
}
|
|
22441
|
-
function associatedWorkItems(dir, iniId) {
|
|
22442
|
-
return discoverWorkItems(dir).filter((wi) => workItemBelongsToInitiative(wi.initiative, iniId)).map((wi) => ({
|
|
22443
|
-
id: wi.id,
|
|
22444
|
-
title: wi.title,
|
|
22445
|
-
status: wi.lifecycle ?? "ready"
|
|
22446
|
-
})).sort((a, b) => a.id.localeCompare(b.id));
|
|
22447
|
-
}
|
|
22448
|
-
function computeInitiativeProgress(dir, ini) {
|
|
22449
|
-
const totalCandidates = ini.candidates.length;
|
|
22450
|
-
const materialized = ini.candidates.filter((c) => c.materializedAs).length;
|
|
22451
|
-
const byState = emptyLifecycleCounts();
|
|
22452
|
-
const associated = associatedWorkItems(dir, ini.id);
|
|
22453
|
-
for (const wi of associated) byState[wi.status]++;
|
|
22454
|
-
return {
|
|
22455
|
-
initiative: ini.id,
|
|
22456
|
-
status: ini.status,
|
|
22457
|
-
planning: {
|
|
22458
|
-
totalCandidates,
|
|
22459
|
-
materialized,
|
|
22460
|
-
remaining: Math.max(0, totalCandidates - materialized)
|
|
22461
|
-
},
|
|
22462
|
-
delivery: {
|
|
22463
|
-
total: associated.length,
|
|
22464
|
-
byState
|
|
22465
|
-
}
|
|
22466
|
-
};
|
|
22467
|
-
}
|
|
22468
|
-
|
|
22469
22497
|
// src/core/initiative-write.ts
|
|
22470
22498
|
import matter18 from "gray-matter";
|
|
22471
22499
|
var WORK_ITEMS_DIR4 = "knowledge/delivery/work-items";
|
|
@@ -22497,6 +22525,7 @@ function externalLinkToData(l) {
|
|
|
22497
22525
|
const out = { integration: l.integration, external_id: l.externalId };
|
|
22498
22526
|
if (l.externalType) out.external_type = l.externalType;
|
|
22499
22527
|
if (l.url) out.url = l.url;
|
|
22528
|
+
if (l.externalStatus) out.external_status = l.externalStatus;
|
|
22500
22529
|
return out;
|
|
22501
22530
|
}
|
|
22502
22531
|
function normalizeCandidate(input, fallbackId) {
|
|
@@ -22704,6 +22733,112 @@ function materializeCandidate(dir, id, candidateId) {
|
|
|
22704
22733
|
return { workItemId: wiId, fileName, initiative: updated };
|
|
22705
22734
|
}
|
|
22706
22735
|
|
|
22736
|
+
// src/core/initiative-analysis.ts
|
|
22737
|
+
var SUCCESS_HEADING_RE = /^#{1,6}\s*(success criteria|criterios de[ét]xito|criterios de éxito)\s*$/i;
|
|
22738
|
+
var HEADING_RE2 = /^#{1,6}\s+/;
|
|
22739
|
+
var CHECK_ITEM_RE = /^\s*[-*]\s+\[([ xX])\]\s+(.*)$/;
|
|
22740
|
+
var BULLET_RE2 = /^\s*[-*]\s+(.*)$/;
|
|
22741
|
+
var PLACEHOLDER_RE = /^_.*_$/;
|
|
22742
|
+
function parseSuccessCriteria(body) {
|
|
22743
|
+
const lines = body.split(/\r?\n/);
|
|
22744
|
+
const out = [];
|
|
22745
|
+
let capture = false;
|
|
22746
|
+
for (const line of lines) {
|
|
22747
|
+
if (capture && HEADING_RE2.test(line)) break;
|
|
22748
|
+
if (!capture) {
|
|
22749
|
+
if (SUCCESS_HEADING_RE.test(line.trim())) capture = true;
|
|
22750
|
+
continue;
|
|
22751
|
+
}
|
|
22752
|
+
const check = line.match(CHECK_ITEM_RE);
|
|
22753
|
+
if (check) {
|
|
22754
|
+
const text2 = check[2].trim();
|
|
22755
|
+
if (text2 && !PLACEHOLDER_RE.test(text2)) {
|
|
22756
|
+
out.push({ text: text2, checked: check[1].toLowerCase() === "x" });
|
|
22757
|
+
}
|
|
22758
|
+
continue;
|
|
22759
|
+
}
|
|
22760
|
+
const bullet = line.match(BULLET_RE2);
|
|
22761
|
+
if (bullet) {
|
|
22762
|
+
const text2 = bullet[1].trim();
|
|
22763
|
+
if (text2 && !PLACEHOLDER_RE.test(text2)) out.push({ text: text2, checked: null });
|
|
22764
|
+
}
|
|
22765
|
+
}
|
|
22766
|
+
return out;
|
|
22767
|
+
}
|
|
22768
|
+
function analyzeInitiative(dir, ini) {
|
|
22769
|
+
const progress = computeInitiativeProgress(dir, ini);
|
|
22770
|
+
const successCriteria = parseSuccessCriteria(ini.body);
|
|
22771
|
+
const pendingCandidates = ini.candidates.filter((c) => !c.materializedAs);
|
|
22772
|
+
const associated = associatedWorkItems(dir, ini.id);
|
|
22773
|
+
const findings = [];
|
|
22774
|
+
if (successCriteria.length === 0) {
|
|
22775
|
+
findings.push({
|
|
22776
|
+
code: "no-success-criteria",
|
|
22777
|
+
severity: "warning",
|
|
22778
|
+
message: "The Initiative has no explicit Success Criteria; completion cannot be judged by outcome, only by delivery."
|
|
22779
|
+
});
|
|
22780
|
+
} else {
|
|
22781
|
+
const uncovered = successCriteria.filter((c) => c.checked === false);
|
|
22782
|
+
if (uncovered.length > 0) {
|
|
22783
|
+
findings.push({
|
|
22784
|
+
code: "uncovered-success-criteria",
|
|
22785
|
+
severity: "blocking",
|
|
22786
|
+
message: `${uncovered.length} success criterion/criteria remain uncovered.`,
|
|
22787
|
+
items: uncovered.map((c) => c.text)
|
|
22788
|
+
});
|
|
22789
|
+
}
|
|
22790
|
+
}
|
|
22791
|
+
if (pendingCandidates.length > 0) {
|
|
22792
|
+
findings.push({
|
|
22793
|
+
code: "pending-candidates",
|
|
22794
|
+
severity: "blocking",
|
|
22795
|
+
message: `${pendingCandidates.length} committed candidate(s) not yet materialized into Work Items.`,
|
|
22796
|
+
items: pendingCandidates.map((c) => `${c.id}: ${c.title}`)
|
|
22797
|
+
});
|
|
22798
|
+
}
|
|
22799
|
+
const notCompleted = associated.filter((w) => w.status !== "completed" && w.status !== "archived");
|
|
22800
|
+
if (associated.length === 0) {
|
|
22801
|
+
findings.push({
|
|
22802
|
+
code: "no-delivery",
|
|
22803
|
+
severity: "info",
|
|
22804
|
+
message: "No Work Items are associated with this Initiative yet."
|
|
22805
|
+
});
|
|
22806
|
+
} else if (notCompleted.length > 0) {
|
|
22807
|
+
findings.push({
|
|
22808
|
+
code: "incomplete-delivery",
|
|
22809
|
+
severity: "blocking",
|
|
22810
|
+
message: `${notCompleted.length} associated Work Item(s) are not completed.`,
|
|
22811
|
+
items: notCompleted.map((w) => `${w.id} (${w.status})`)
|
|
22812
|
+
});
|
|
22813
|
+
}
|
|
22814
|
+
return {
|
|
22815
|
+
initiative: ini.id,
|
|
22816
|
+
status: ini.status,
|
|
22817
|
+
progress,
|
|
22818
|
+
successCriteria,
|
|
22819
|
+
pendingCandidates,
|
|
22820
|
+
findings,
|
|
22821
|
+
suggestedCandidates: pendingCandidates
|
|
22822
|
+
};
|
|
22823
|
+
}
|
|
22824
|
+
function evaluateInitiativeCompletion(dir, ini) {
|
|
22825
|
+
const analysis = analyzeInitiative(dir, ini);
|
|
22826
|
+
const reasons = [];
|
|
22827
|
+
for (const f of analysis.findings) {
|
|
22828
|
+
if (f.severity === "blocking") reasons.push(f.message);
|
|
22829
|
+
}
|
|
22830
|
+
if (analysis.progress.delivery.total === 0 && analysis.pendingCandidates.length === 0) {
|
|
22831
|
+
reasons.push("Nothing has been delivered or committed under this Initiative.");
|
|
22832
|
+
}
|
|
22833
|
+
const ready = reasons.length === 0;
|
|
22834
|
+
return {
|
|
22835
|
+
initiative: ini.id,
|
|
22836
|
+
ready,
|
|
22837
|
+
readiness: ready ? "ready" : "not-ready",
|
|
22838
|
+
reasons
|
|
22839
|
+
};
|
|
22840
|
+
}
|
|
22841
|
+
|
|
22707
22842
|
// src/commands/initiative.ts
|
|
22708
22843
|
function requireInit(dir) {
|
|
22709
22844
|
if (!loadConfig(dir)) {
|
|
@@ -22837,6 +22972,74 @@ async function runInitiativeUpdate(id, opts) {
|
|
|
22837
22972
|
process.exit(1);
|
|
22838
22973
|
}
|
|
22839
22974
|
}
|
|
22975
|
+
function runInitiativeAnalyze(id) {
|
|
22976
|
+
const dir = cwd();
|
|
22977
|
+
requireInit(dir);
|
|
22978
|
+
intro(`kaddo initiative analyze ${id}`);
|
|
22979
|
+
const ini = getInitiative(dir, id);
|
|
22980
|
+
if (!ini) {
|
|
22981
|
+
log.error(`Initiative ${id} not found.`);
|
|
22982
|
+
process.exit(1);
|
|
22983
|
+
}
|
|
22984
|
+
const analysis = analyzeInitiative(dir, ini);
|
|
22985
|
+
log.info(` Status: ${analysis.status}`);
|
|
22986
|
+
log.info(` Success criteria: ${analysis.successCriteria.length}`);
|
|
22987
|
+
log.info(` Planning: ${analysis.progress.planning.materialized}/${analysis.progress.planning.totalCandidates} materialized`);
|
|
22988
|
+
log.info(` Delivery: ${analysis.progress.delivery.byState.completed}/${analysis.progress.delivery.total} completed`);
|
|
22989
|
+
if (analysis.findings.length === 0) {
|
|
22990
|
+
log.success("No gaps detected.");
|
|
22991
|
+
} else {
|
|
22992
|
+
log.info("");
|
|
22993
|
+
for (const f of analysis.findings) {
|
|
22994
|
+
const line = ` [${f.severity}] ${f.message}`;
|
|
22995
|
+
if (f.severity === "blocking") log.warn(line);
|
|
22996
|
+
else log.info(line);
|
|
22997
|
+
for (const item of f.items ?? []) log.info(` - ${item}`);
|
|
22998
|
+
}
|
|
22999
|
+
}
|
|
23000
|
+
if (analysis.suggestedCandidates.length > 0) {
|
|
23001
|
+
log.info("");
|
|
23002
|
+
log.info(" Suggested (pending) candidates to materialize:");
|
|
23003
|
+
for (const c of analysis.suggestedCandidates) log.info(` - ${c.id}: ${c.title}`);
|
|
23004
|
+
}
|
|
23005
|
+
outro(`Analysis for ${ini.id}.`);
|
|
23006
|
+
}
|
|
23007
|
+
async function runInitiativeComplete(id, opts = {}) {
|
|
23008
|
+
const dir = cwd();
|
|
23009
|
+
requireInit(dir);
|
|
23010
|
+
intro(`kaddo initiative complete ${id}`);
|
|
23011
|
+
const ini = getInitiative(dir, id);
|
|
23012
|
+
if (!ini) {
|
|
23013
|
+
log.error(`Initiative ${id} not found.`);
|
|
23014
|
+
process.exit(1);
|
|
23015
|
+
}
|
|
23016
|
+
const readiness = evaluateInitiativeCompletion(dir, ini);
|
|
23017
|
+
if (readiness.ready) {
|
|
23018
|
+
log.success("Completion readiness: ready.");
|
|
23019
|
+
} else {
|
|
23020
|
+
log.warn("Completion readiness: NOT ready.");
|
|
23021
|
+
for (const r of readiness.reasons) log.warn(` - ${r}`);
|
|
23022
|
+
}
|
|
23023
|
+
if (!opts.yes) {
|
|
23024
|
+
log.info("");
|
|
23025
|
+
const proceed = await confirm({
|
|
23026
|
+
message: readiness.ready ? "Mark this Initiative as completed?" : "This Initiative is not ready. Complete it anyway?",
|
|
23027
|
+
initialValue: false
|
|
23028
|
+
});
|
|
23029
|
+
if (!proceed) {
|
|
23030
|
+
cancel("Cancelled. Initiative not completed.");
|
|
23031
|
+
return;
|
|
23032
|
+
}
|
|
23033
|
+
}
|
|
23034
|
+
try {
|
|
23035
|
+
const done = transitionInitiative(dir, id, "completed");
|
|
23036
|
+
log.success(`Status: ${done.status}`);
|
|
23037
|
+
outro(`Initiative ${done.id} completed.`);
|
|
23038
|
+
} catch (err) {
|
|
23039
|
+
log.error(err instanceof InitiativeWriteError ? err.message : String(err));
|
|
23040
|
+
process.exit(1);
|
|
23041
|
+
}
|
|
23042
|
+
}
|
|
22840
23043
|
function runInitiativeMaterialize(id, candidateId) {
|
|
22841
23044
|
const dir = cwd();
|
|
22842
23045
|
requireInit(dir);
|
|
@@ -23052,6 +23255,12 @@ initiativeCmd.command("update <id>").description("Update an initiative status (v
|
|
|
23052
23255
|
initiativeCmd.command("materialize <id> <candidateId>").description("Materialize an initiative candidate into a draft Work Item").action((id, candidateId) => {
|
|
23053
23256
|
runInitiativeMaterialize(id, candidateId);
|
|
23054
23257
|
});
|
|
23258
|
+
initiativeCmd.command("analyze <id>").description("Analyze an initiative: success-criteria coverage, gaps, and suggested candidates").action((id) => {
|
|
23259
|
+
runInitiativeAnalyze(id);
|
|
23260
|
+
});
|
|
23261
|
+
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) => {
|
|
23262
|
+
await runInitiativeComplete(id, opts);
|
|
23263
|
+
});
|
|
23055
23264
|
var telemetryCmd = program.command("telemetry").description("Manage anonymous usage telemetry");
|
|
23056
23265
|
telemetryCmd.command("status").description("Show telemetry status (enabled, registered, pending events)").action(() => {
|
|
23057
23266
|
runTelemetryStatus();
|