@kaddo/cli 3.114.0 → 3.116.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-eYr0CQIi.js → architectureDiagram-3BPJPVTR-DP6srEcc.js} +1 -1
- package/dist/admin-dist/assets/{chunk-727SXJPM-DrnpGnui.js → chunk-727SXJPM-DnQC9siX.js} +1 -1
- package/dist/admin-dist/assets/{chunk-AQP2D5EJ-CEGy8SpK.js → chunk-AQP2D5EJ-BpyJpCJ-.js} +1 -1
- package/dist/admin-dist/assets/{classDiagram-v2-Q7XG4LA2-DA001cdf.js → classDiagram-4FO5ZUOK-CGoPFtaR.js} +1 -1
- package/dist/admin-dist/assets/{classDiagram-4FO5ZUOK-DA001cdf.js → classDiagram-v2-Q7XG4LA2-CGoPFtaR.js} +1 -1
- package/dist/admin-dist/assets/{dagre-BM42HDAG-BRJ0nXQb.js → dagre-BM42HDAG-CRZz5h6U.js} +1 -1
- package/dist/admin-dist/assets/{diagram-2AECGRRQ-xd6Livp4.js → diagram-2AECGRRQ-2IUax-pn.js} +1 -1
- package/dist/admin-dist/assets/{diagram-5GNKFQAL-o9d2ix0l.js → diagram-5GNKFQAL-Dbar3g31.js} +1 -1
- package/dist/admin-dist/assets/{diagram-LMA3HP47-DcnWjF35.js → diagram-LMA3HP47-CDpppwwZ.js} +1 -1
- package/dist/admin-dist/assets/{diagram-OG6HWLK6-Cw5XQicu.js → diagram-OG6HWLK6-CxJNrhOa.js} +1 -1
- package/dist/admin-dist/assets/{erDiagram-TEJ5UH35-DRxLZQPp.js → erDiagram-TEJ5UH35-CqGkUDrY.js} +1 -1
- package/dist/admin-dist/assets/{flowDiagram-I6XJVG4X-Pb5MivY8.js → flowDiagram-I6XJVG4X-Dj-jj3Xs.js} +1 -1
- package/dist/admin-dist/assets/{ganttDiagram-6RSMTGT7-Cm7UHfMW.js → ganttDiagram-6RSMTGT7-BsslcFFi.js} +1 -1
- package/dist/admin-dist/assets/{index-M8TdCEku.js → index-DVXcBuvj.js} +6 -6
- package/dist/admin-dist/assets/{infoDiagram-5YYISTIA-Bwq-Ae1z.js → infoDiagram-5YYISTIA-Bm8y-W5K.js} +1 -1
- package/dist/admin-dist/assets/{ishikawaDiagram-YF4QCWOH-CN8u3lkW.js → ishikawaDiagram-YF4QCWOH-B1q-JfoS.js} +1 -1
- package/dist/admin-dist/assets/{kanban-definition-UN3LZRKU-DFp13Kfy.js → kanban-definition-UN3LZRKU-iEF70R2u.js} +1 -1
- package/dist/admin-dist/assets/{linear-sB0c581b.js → linear-Cp_M7piX.js} +1 -1
- package/dist/admin-dist/assets/{mindmap-definition-RKZ34NQL-Ds_AH-UF.js → mindmap-definition-RKZ34NQL-IS3zSxy4.js} +1 -1
- package/dist/admin-dist/assets/{pieDiagram-4H26LBE5-CT6aVbJD.js → pieDiagram-4H26LBE5-FRW3jbwa.js} +1 -1
- package/dist/admin-dist/assets/{quadrantDiagram-W4KKPZXB-QacGkpjr.js → quadrantDiagram-W4KKPZXB-BWvrA0U2.js} +1 -1
- package/dist/admin-dist/assets/{requirementDiagram-4Y6WPE33-UjzvMQAY.js → requirementDiagram-4Y6WPE33-BDo5C4-W.js} +1 -1
- package/dist/admin-dist/assets/{sequenceDiagram-3UESZ5HK-Drii4Z9H.js → sequenceDiagram-3UESZ5HK-BqkNcdXk.js} +1 -1
- package/dist/admin-dist/assets/{stateDiagram-AJRCARHV-Cu5M1jgm.js → stateDiagram-AJRCARHV-BPRhmY_L.js} +1 -1
- package/dist/admin-dist/assets/{stateDiagram-v2-BHNVJYJU-Dnkqr8wc.js → stateDiagram-v2-BHNVJYJU-DqC9KnuP.js} +1 -1
- package/dist/admin-dist/assets/{timeline-definition-PNZ67QCA-BmCLa1NQ.js → timeline-definition-PNZ67QCA-BKU6Xg5t.js} +1 -1
- package/dist/admin-dist/assets/{vennDiagram-CIIHVFJN-BhHRtC9_.js → vennDiagram-CIIHVFJN-BRePJms1.js} +1 -1
- package/dist/admin-dist/assets/{wardleyDiagram-YWT4CUSO-BzHZzKlk.js → wardleyDiagram-YWT4CUSO-BZP5Do-p.js} +1 -1
- package/dist/admin-dist/assets/{xychartDiagram-2RQKCTM6-uU2Utuv0.js → xychartDiagram-2RQKCTM6-Cf0SjuRr.js} +1 -1
- package/dist/admin-dist/index.html +1 -1
- package/dist/admin-server/index.js +90 -0
- package/dist/core.js +482 -92
- package/dist/index.js +664 -115
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1390,8 +1390,8 @@ function loadConfig(dir) {
|
|
|
1390
1390
|
const parsed = configSchema.safeParse(raw ?? {});
|
|
1391
1391
|
if (!parsed.success) {
|
|
1392
1392
|
const issues = parsed.error.issues.map((i) => {
|
|
1393
|
-
const
|
|
1394
|
-
return
|
|
1393
|
+
const path13 = i.path.join(".");
|
|
1394
|
+
return path13 ? ` - ${path13}: ${i.message}` : ` - ${i.message}`;
|
|
1395
1395
|
}).join("\n");
|
|
1396
1396
|
throw new ConfigError(`Invalid .kaddo/config.yml:
|
|
1397
1397
|
${issues}`);
|
|
@@ -2499,8 +2499,13 @@ dependencies.
|
|
|
2499
2499
|
flags, content/copy, authentication/authorization, notifications, analytics, documentation,
|
|
2500
2500
|
operations/release \u2014 as affected, reviewed-not-affected, unknown, or not-applicable.
|
|
2501
2501
|
4. **Module review** \u2014 for multirepo, evaluate each mapped module with the same statuses.
|
|
2502
|
-
5. **
|
|
2503
|
-
|
|
2502
|
+
5. **Resource review** \u2014 ask: does this change need to observe, modify, validate or deliver against a
|
|
2503
|
+
known external resource of the project (a Project Resource under \`knowledge/tech/resources/\` \u2014
|
|
2504
|
+
database, cloud, API, queue, storage\u2026)? If so, declare it in the WI front matter \`resources:\` with
|
|
2505
|
+
a role (\`affected\`, \`implementation\`, \`validation\`, \`delivery\`). Resources are external systems,
|
|
2506
|
+
distinct from \`affected_modules\` (code). Not every WI needs resources (e.g. a CSS change does not).
|
|
2507
|
+
6. **Completeness review** \u2014 confirm: outcome covered, journey covered, modules assessed, resources
|
|
2508
|
+
assessed, unknowns visible, acceptance criteria end-to-end, scope and out-of-scope coherent.
|
|
2504
2509
|
|
|
2505
2510
|
## Rules
|
|
2506
2511
|
|
|
@@ -2511,6 +2516,8 @@ dependencies.
|
|
|
2511
2516
|
- Include at least one end-to-end acceptance criterion for user-facing changes.
|
|
2512
2517
|
- Do not reduce a product intent to the first technical implementation found.
|
|
2513
2518
|
- Evaluate surfaces and modules before proposing files.
|
|
2519
|
+
- Consider Project Resources when the scope justifies it; never invent resources not backed by
|
|
2520
|
+
project knowledge, and keep \`resources\` (external systems) separate from \`affected_modules\` (code).
|
|
2514
2521
|
- This skill refines scope and acceptance criteria but does not approve implementation readiness.
|
|
2515
2522
|
Readiness requires human confirmation through \`kaddo ready\` or the MCP \`mark_work_item_ready\` action.
|
|
2516
2523
|
|
|
@@ -3678,6 +3685,16 @@ supporting notes as \`knowledge/tech/discovery/architecture-notes.md\` and decis
|
|
|
3678
3685
|
under \`knowledge/tech/decisions/\`. Kaddo still reads the legacy root locations for backward
|
|
3679
3686
|
compatibility, but new output should use \`discovery/\`.
|
|
3680
3687
|
|
|
3688
|
+
## Project Resource candidates
|
|
3689
|
+
|
|
3690
|
+
When the knowledge describes an external system the project depends on (a database, cloud account,
|
|
3691
|
+
API, queue, storage, service\u2026), you may propose it as a **candidate** Project Resource \u2014 never create
|
|
3692
|
+
it silently. Discovery \u2260 creation: present candidates for human review and materialize only through
|
|
3693
|
+
\`kaddo_create_resource\` / \`kaddo resources create\` with explicit confirmation. Ground every
|
|
3694
|
+
candidate in the knowledge (no guessing from ambiguous names). Model the stable system, not its access
|
|
3695
|
+
interface (CLI/MCP/SQL/API are interfaces); keep \`resources\` separate from \`affected_modules\`; and
|
|
3696
|
+
never include secret values \u2014 only reference names.
|
|
3697
|
+
|
|
3681
3698
|
## Quality Checklist
|
|
3682
3699
|
|
|
3683
3700
|
- Every component is backed by evidence from the context pack.
|
|
@@ -6442,8 +6459,8 @@ async function runCreate(type, opts = {}) {
|
|
|
6442
6459
|
answers[question.frontMatterField] = answer.trim();
|
|
6443
6460
|
}
|
|
6444
6461
|
const id = nextWorkItemId(dir);
|
|
6445
|
-
const
|
|
6446
|
-
const fileName = `${id}-${
|
|
6462
|
+
const slug5 = slugify(title);
|
|
6463
|
+
const fileName = `${id}-${slug5}.md`;
|
|
6447
6464
|
const filePath = join(dir, DRAFT_DIR, fileName);
|
|
6448
6465
|
const frontMatter2 = buildFrontMatter(id, workItemType, level, title.trim(), answers);
|
|
6449
6466
|
const body = buildBody(workItemType, level, title.trim(), answers, levelDef.qualityGate);
|
|
@@ -6476,8 +6493,8 @@ async function runCreateModule(dir, modType) {
|
|
|
6476
6493
|
answers[q.frontMatterField] = answer.trim();
|
|
6477
6494
|
}
|
|
6478
6495
|
const id = nextWorkItemId(dir);
|
|
6479
|
-
const
|
|
6480
|
-
const fileName = `${id}-${
|
|
6496
|
+
const slug5 = slugify(title);
|
|
6497
|
+
const fileName = `${id}-${slug5}.md`;
|
|
6481
6498
|
const filePath = join(dir, DRAFT_DIR, fileName);
|
|
6482
6499
|
const frontMatter2 = buildModuleFrontMatter(id, modType, title.trim(), answers);
|
|
6483
6500
|
const body = buildModuleBody(modType, title.trim(), answers);
|
|
@@ -6642,8 +6659,8 @@ function buildRoadmapWorkItem(opts) {
|
|
|
6642
6659
|
const { id, type, level, candidate } = opts;
|
|
6643
6660
|
const answers = opts.answers ?? {};
|
|
6644
6661
|
const title = candidate.title.trim();
|
|
6645
|
-
const
|
|
6646
|
-
const fileName = `${id}-${
|
|
6662
|
+
const slug5 = slugify(title);
|
|
6663
|
+
const fileName = `${id}-${slug5}.md`;
|
|
6647
6664
|
const qualityGate = getLevel(level).qualityGate;
|
|
6648
6665
|
const frontMatter2 = buildRoadmapFrontMatter(id, type, level, title, candidate, answers);
|
|
6649
6666
|
const body = buildRoadmapBody(type, level, title, candidate, answers, qualityGate);
|
|
@@ -7044,10 +7061,10 @@ function analyzeGuard(touchedFiles, artifacts, silentWithoutOwnership) {
|
|
|
7044
7061
|
import { parse as parseYaml5, stringify as stringifyYaml3 } from "yaml";
|
|
7045
7062
|
var IGNORE_FILE = ".kaddo/ignores.yml";
|
|
7046
7063
|
function loadIgnores(dir) {
|
|
7047
|
-
const
|
|
7048
|
-
if (!exists(
|
|
7064
|
+
const path13 = join(dir, IGNORE_FILE);
|
|
7065
|
+
if (!exists(path13)) return [];
|
|
7049
7066
|
try {
|
|
7050
|
-
const raw = readFile(
|
|
7067
|
+
const raw = readFile(path13);
|
|
7051
7068
|
const parsed = parseYaml5(raw);
|
|
7052
7069
|
return Array.isArray(parsed) ? parsed : [];
|
|
7053
7070
|
} catch {
|
|
@@ -7055,7 +7072,7 @@ function loadIgnores(dir) {
|
|
|
7055
7072
|
}
|
|
7056
7073
|
}
|
|
7057
7074
|
function saveIgnore(dir, entry) {
|
|
7058
|
-
const
|
|
7075
|
+
const path13 = join(dir, IGNORE_FILE);
|
|
7059
7076
|
const existing = loadIgnores(dir);
|
|
7060
7077
|
const idx = existing.findIndex((e) => e.artifact_id === entry.artifact_id);
|
|
7061
7078
|
if (idx >= 0) {
|
|
@@ -7063,17 +7080,17 @@ function saveIgnore(dir, entry) {
|
|
|
7063
7080
|
} else {
|
|
7064
7081
|
existing.push(entry);
|
|
7065
7082
|
}
|
|
7066
|
-
writeFile(
|
|
7083
|
+
writeFile(path13, stringifyYaml3(existing));
|
|
7067
7084
|
}
|
|
7068
7085
|
function isIgnored(ignores, artifactId) {
|
|
7069
7086
|
return ignores.find((e) => e.artifact_id === artifactId);
|
|
7070
7087
|
}
|
|
7071
7088
|
function removeIgnore(dir, artifactId) {
|
|
7072
|
-
const
|
|
7089
|
+
const path13 = join(dir, IGNORE_FILE);
|
|
7073
7090
|
const existing = loadIgnores(dir);
|
|
7074
7091
|
const filtered = existing.filter((e) => e.artifact_id !== artifactId);
|
|
7075
7092
|
if (filtered.length === existing.length) return false;
|
|
7076
|
-
writeFile(
|
|
7093
|
+
writeFile(path13, stringifyYaml3(filtered));
|
|
7077
7094
|
return true;
|
|
7078
7095
|
}
|
|
7079
7096
|
|
|
@@ -7095,11 +7112,11 @@ function moduleArtifactCoverage(dir, id) {
|
|
|
7095
7112
|
};
|
|
7096
7113
|
}
|
|
7097
7114
|
function loadMappedModules(dir) {
|
|
7098
|
-
const
|
|
7099
|
-
if (!exists(
|
|
7115
|
+
const path13 = join(dir, DESCRIPTOR_PATH);
|
|
7116
|
+
if (!exists(path13)) return [];
|
|
7100
7117
|
let parsed;
|
|
7101
7118
|
try {
|
|
7102
|
-
parsed = parseYaml6(readFile(
|
|
7119
|
+
parsed = parseYaml6(readFile(path13));
|
|
7103
7120
|
} catch {
|
|
7104
7121
|
return [];
|
|
7105
7122
|
}
|
|
@@ -7843,7 +7860,7 @@ function buildGuardHistory(dir) {
|
|
|
7843
7860
|
const d = hotspotDir(t.code_path);
|
|
7844
7861
|
hotspotMap.set(d, (hotspotMap.get(d) ?? 0) + 1);
|
|
7845
7862
|
}
|
|
7846
|
-
const hotspots = [...hotspotMap.entries()].map(([
|
|
7863
|
+
const hotspots = [...hotspotMap.entries()].map(([path13, warnings]) => ({ path: path13, warnings })).sort((a, b) => b.warnings - a.warnings);
|
|
7847
7864
|
return {
|
|
7848
7865
|
available: true,
|
|
7849
7866
|
total_runs: sorted.length,
|
|
@@ -8363,7 +8380,7 @@ function runIgnoreRemove(artifactId) {
|
|
|
8363
8380
|
}
|
|
8364
8381
|
|
|
8365
8382
|
// src/commands/explain.ts
|
|
8366
|
-
import
|
|
8383
|
+
import matter8 from "gray-matter";
|
|
8367
8384
|
import { parse as parseYaml13 } from "yaml";
|
|
8368
8385
|
|
|
8369
8386
|
// src/core/delivery-phase.ts
|
|
@@ -10481,10 +10498,10 @@ function slugify2(name) {
|
|
|
10481
10498
|
return name.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
10482
10499
|
}
|
|
10483
10500
|
function readModulesDescriptor(dir) {
|
|
10484
|
-
const
|
|
10485
|
-
if (!exists(
|
|
10501
|
+
const path13 = join(dir, DESCRIPTOR_PATH2);
|
|
10502
|
+
if (!exists(path13)) return { version: 1, modules: [] };
|
|
10486
10503
|
try {
|
|
10487
|
-
const parsed = parseYaml10(readFile(
|
|
10504
|
+
const parsed = parseYaml10(readFile(path13));
|
|
10488
10505
|
return { version: parsed.version ?? 1, modules: parsed.modules ?? [] };
|
|
10489
10506
|
} catch {
|
|
10490
10507
|
return { version: 1, modules: [] };
|
|
@@ -10864,7 +10881,7 @@ function sectionParagraph(md, title) {
|
|
|
10864
10881
|
}
|
|
10865
10882
|
return "";
|
|
10866
10883
|
}
|
|
10867
|
-
function parseCapsule(id,
|
|
10884
|
+
function parseCapsule(id, path13, md) {
|
|
10868
10885
|
const { data } = matter3(md);
|
|
10869
10886
|
const updatedAt = data.updated_at ? String(data.updated_at) : void 0;
|
|
10870
10887
|
let ageDays = null;
|
|
@@ -10874,7 +10891,7 @@ function parseCapsule(id, path12, md) {
|
|
|
10874
10891
|
}
|
|
10875
10892
|
return {
|
|
10876
10893
|
id,
|
|
10877
|
-
path:
|
|
10894
|
+
path: path13,
|
|
10878
10895
|
system: data.system ? String(data.system) : id,
|
|
10879
10896
|
owner: data.owner ? String(data.owner) : void 0,
|
|
10880
10897
|
updatedAt,
|
|
@@ -11097,8 +11114,145 @@ function computeInitiativeProgress(dir, ini) {
|
|
|
11097
11114
|
};
|
|
11098
11115
|
}
|
|
11099
11116
|
|
|
11117
|
+
// src/core/resources.ts
|
|
11118
|
+
import matter5 from "gray-matter";
|
|
11119
|
+
var RESOURCE_ARTIFACT_TYPE = "project-resource";
|
|
11120
|
+
var RESOURCE_TYPES = [
|
|
11121
|
+
"database",
|
|
11122
|
+
"cloud",
|
|
11123
|
+
"api",
|
|
11124
|
+
"queue",
|
|
11125
|
+
"storage",
|
|
11126
|
+
"repository",
|
|
11127
|
+
"platform",
|
|
11128
|
+
"service",
|
|
11129
|
+
"other"
|
|
11130
|
+
];
|
|
11131
|
+
var INTERFACE_TYPES = ["cli", "mcp", "api", "sql", "sdk", "iac", "console", "other"];
|
|
11132
|
+
function str(v) {
|
|
11133
|
+
return typeof v === "string" && v.trim() ? v.trim() : null;
|
|
11134
|
+
}
|
|
11135
|
+
function strArray(v) {
|
|
11136
|
+
if (Array.isArray(v)) return v.map((x) => String(x).trim()).filter(Boolean);
|
|
11137
|
+
if (typeof v === "string" && v.trim()) return [v.trim()];
|
|
11138
|
+
return [];
|
|
11139
|
+
}
|
|
11140
|
+
function parseInterfaces(v) {
|
|
11141
|
+
if (!Array.isArray(v)) return [];
|
|
11142
|
+
const out = [];
|
|
11143
|
+
for (const raw of v) {
|
|
11144
|
+
if (!raw || typeof raw !== "object") continue;
|
|
11145
|
+
const o = raw;
|
|
11146
|
+
const type = str(o.type);
|
|
11147
|
+
if (!type) continue;
|
|
11148
|
+
out.push({
|
|
11149
|
+
type,
|
|
11150
|
+
tool: str(o.tool),
|
|
11151
|
+
provider: str(o.provider),
|
|
11152
|
+
purpose: str(o.purpose),
|
|
11153
|
+
operations: strArray(o.operations),
|
|
11154
|
+
environments: strArray(o.environments),
|
|
11155
|
+
constraints: str(o.constraints)
|
|
11156
|
+
});
|
|
11157
|
+
}
|
|
11158
|
+
return out;
|
|
11159
|
+
}
|
|
11160
|
+
function parseBoundaries(v) {
|
|
11161
|
+
if (!v || typeof v !== "object" || Array.isArray(v)) return {};
|
|
11162
|
+
const out = {};
|
|
11163
|
+
for (const [env, val] of Object.entries(v)) {
|
|
11164
|
+
const list2 = strArray(val);
|
|
11165
|
+
if (list2.length > 0) out[env] = list2;
|
|
11166
|
+
}
|
|
11167
|
+
return out;
|
|
11168
|
+
}
|
|
11169
|
+
function parseAuth(v) {
|
|
11170
|
+
if (!v || typeof v !== "object" || Array.isArray(v)) return { mode: null, refs: [] };
|
|
11171
|
+
const o = v;
|
|
11172
|
+
const refs = strArray(o.refs).filter((r) => !r.includes("=") && /^[A-Za-z0-9_.-]+$/.test(r));
|
|
11173
|
+
return { mode: str(o.mode), refs };
|
|
11174
|
+
}
|
|
11175
|
+
function parseScope(v) {
|
|
11176
|
+
if (!v || typeof v !== "object" || Array.isArray(v)) return null;
|
|
11177
|
+
const o = v;
|
|
11178
|
+
const type = str(o.type);
|
|
11179
|
+
if (!type) return null;
|
|
11180
|
+
return { type, module: str(o.module) };
|
|
11181
|
+
}
|
|
11182
|
+
function purposeFromBody(body) {
|
|
11183
|
+
const m = body.match(/^#{1,2}\s+Purpose\s*\n+([\s\S]*?)(?=\n#{1,2}\s|\s*$)/m);
|
|
11184
|
+
const text2 = m ? m[1].trim() : "";
|
|
11185
|
+
return text2 || null;
|
|
11186
|
+
}
|
|
11187
|
+
function toDetail(filePath, relPath, raw) {
|
|
11188
|
+
const parsed = matter5(raw);
|
|
11189
|
+
const fm2 = parsed.data ?? {};
|
|
11190
|
+
const body = parsed.content.trim();
|
|
11191
|
+
const id = str(fm2.id) ?? "";
|
|
11192
|
+
return {
|
|
11193
|
+
id,
|
|
11194
|
+
title: str(fm2.title) ?? id,
|
|
11195
|
+
resourceType: str(fm2.resource_type),
|
|
11196
|
+
provider: str(fm2.provider),
|
|
11197
|
+
environments: strArray(fm2.environments),
|
|
11198
|
+
scope: parseScope(fm2.scope),
|
|
11199
|
+
modules: strArray(fm2.modules),
|
|
11200
|
+
path: relPath,
|
|
11201
|
+
purpose: str(fm2.purpose) ?? purposeFromBody(body),
|
|
11202
|
+
interfaces: parseInterfaces(fm2.access_interfaces),
|
|
11203
|
+
boundaries: parseBoundaries(fm2.access_boundaries),
|
|
11204
|
+
...(() => {
|
|
11205
|
+
const a = parseAuth(fm2.authentication);
|
|
11206
|
+
return { authRefs: a.refs, authMode: a.mode };
|
|
11207
|
+
})(),
|
|
11208
|
+
markdownBody: body
|
|
11209
|
+
};
|
|
11210
|
+
}
|
|
11211
|
+
function getResources(dir) {
|
|
11212
|
+
return discoverKnowledge(dir).filter((a) => a.type === RESOURCE_ARTIFACT_TYPE).map((a) => {
|
|
11213
|
+
const fm2 = a.rawFrontmatter;
|
|
11214
|
+
return {
|
|
11215
|
+
id: a.id || str(fm2.id) || a.title,
|
|
11216
|
+
title: a.title || str(fm2.title) || a.id,
|
|
11217
|
+
resourceType: str(fm2.resource_type),
|
|
11218
|
+
provider: str(fm2.provider),
|
|
11219
|
+
environments: strArray(fm2.environments),
|
|
11220
|
+
scope: parseScope(fm2.scope),
|
|
11221
|
+
modules: strArray(fm2.modules),
|
|
11222
|
+
path: a.relPath
|
|
11223
|
+
};
|
|
11224
|
+
}).sort((x, y) => x.id.localeCompare(y.id));
|
|
11225
|
+
}
|
|
11226
|
+
function getResource(dir, id) {
|
|
11227
|
+
const match = discoverKnowledge(dir).find(
|
|
11228
|
+
(a) => a.type === RESOURCE_ARTIFACT_TYPE && (a.id === id || a.title === id)
|
|
11229
|
+
);
|
|
11230
|
+
if (!match) return null;
|
|
11231
|
+
const raw = readFile(match.filePath);
|
|
11232
|
+
return toDetail(match.filePath, match.relPath, raw);
|
|
11233
|
+
}
|
|
11234
|
+
function parseWorkItemResources(fm2) {
|
|
11235
|
+
const v = fm2.resources;
|
|
11236
|
+
if (!Array.isArray(v)) return [];
|
|
11237
|
+
const out = [];
|
|
11238
|
+
for (const raw of v) {
|
|
11239
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) continue;
|
|
11240
|
+
const o = raw;
|
|
11241
|
+
const id = str(o.id);
|
|
11242
|
+
if (!id) continue;
|
|
11243
|
+
out.push({ id, role: str(o.role) ?? "affected" });
|
|
11244
|
+
}
|
|
11245
|
+
return out;
|
|
11246
|
+
}
|
|
11247
|
+
|
|
11100
11248
|
// src/core/graph.ts
|
|
11101
11249
|
var KNOWLEDGE3 = "knowledge";
|
|
11250
|
+
var RESOURCE_ROLE_EDGE = {
|
|
11251
|
+
affected: "affects",
|
|
11252
|
+
implementation: "uses",
|
|
11253
|
+
validation: "validates_with",
|
|
11254
|
+
delivery: "delivers_through"
|
|
11255
|
+
};
|
|
11102
11256
|
var ACTIVE_STATUSES = ["draft", "ready", "in-progress", "blocked"];
|
|
11103
11257
|
var ALL_STATUSES = ["draft", "ready", "in-progress", "blocked", "completed"];
|
|
11104
11258
|
function scopeStatuses(scope) {
|
|
@@ -11135,9 +11289,9 @@ function buildGraph(dir, config, opts = {}, now = /* @__PURE__ */ new Date()) {
|
|
|
11135
11289
|
];
|
|
11136
11290
|
const presentLayers = [];
|
|
11137
11291
|
for (const layer2 of layerDocs) {
|
|
11138
|
-
const
|
|
11139
|
-
if (
|
|
11140
|
-
addNode({ id: layer2.id, type: layer2.type, label: layer2.label, path:
|
|
11292
|
+
const path13 = layer2.files.map((f) => `${KNOWLEDGE3}/${f}`).find((rel) => exists(join(dir, rel)));
|
|
11293
|
+
if (path13) {
|
|
11294
|
+
addNode({ id: layer2.id, type: layer2.type, label: layer2.label, path: path13 });
|
|
11141
11295
|
presentLayers.push(layer2.id);
|
|
11142
11296
|
}
|
|
11143
11297
|
}
|
|
@@ -11177,6 +11331,24 @@ function buildGraph(dir, config, opts = {}, now = /* @__PURE__ */ new Date()) {
|
|
|
11177
11331
|
if (cand.materializedAs) addEdge(candId, `wi:${cand.materializedAs}`, "materialized_as");
|
|
11178
11332
|
}
|
|
11179
11333
|
}
|
|
11334
|
+
const resourceTitleById = /* @__PURE__ */ new Map();
|
|
11335
|
+
for (const r of getResources(dir)) {
|
|
11336
|
+
resourceTitleById.set(r.id, r.title);
|
|
11337
|
+
const resId = `resource:${r.id}`;
|
|
11338
|
+
addNode({
|
|
11339
|
+
id: resId,
|
|
11340
|
+
type: "project-resource",
|
|
11341
|
+
label: r.title ? `${r.id} ${r.title}`.trim() : r.id,
|
|
11342
|
+
path: r.path
|
|
11343
|
+
});
|
|
11344
|
+
const depModules = new Set(r.modules);
|
|
11345
|
+
if (r.scope?.type === "module" && r.scope.module) depModules.add(r.scope.module);
|
|
11346
|
+
for (const mod of depModules) {
|
|
11347
|
+
const modId = `module:${mod}`;
|
|
11348
|
+
addNode({ id: modId, type: "module", label: mod });
|
|
11349
|
+
addEdge(modId, resId, "depends_on");
|
|
11350
|
+
}
|
|
11351
|
+
}
|
|
11180
11352
|
for (const wi of selectedWIs) {
|
|
11181
11353
|
const id = wi.id || wi.title;
|
|
11182
11354
|
if (!id || !id.trim()) continue;
|
|
@@ -11201,6 +11373,12 @@ function buildGraph(dir, config, opts = {}, now = /* @__PURE__ */ new Date()) {
|
|
|
11201
11373
|
addNode({ id: capId, type: "capability", label: cap });
|
|
11202
11374
|
addEdge(wiNodeId, capId, "implements");
|
|
11203
11375
|
}
|
|
11376
|
+
for (const rel of parseWorkItemResources(wi.rawFrontmatter)) {
|
|
11377
|
+
const resId = `resource:${rel.id}`;
|
|
11378
|
+
const title = resourceTitleById.get(rel.id);
|
|
11379
|
+
addNode({ id: resId, type: "project-resource", label: title ? `${rel.id} ${title}`.trim() : rel.id });
|
|
11380
|
+
addEdge(wiNodeId, resId, RESOURCE_ROLE_EDGE[rel.role] ?? "uses");
|
|
11381
|
+
}
|
|
11204
11382
|
for (const dec of wi.decisions) {
|
|
11205
11383
|
if (!dec || !dec.trim()) continue;
|
|
11206
11384
|
const adrId = `adr:${dec}`;
|
|
@@ -11579,7 +11757,7 @@ function loadGraphHints(dir) {
|
|
|
11579
11757
|
}
|
|
11580
11758
|
|
|
11581
11759
|
// src/services/installed-skills.ts
|
|
11582
|
-
import
|
|
11760
|
+
import matter6 from "gray-matter";
|
|
11583
11761
|
var SKILLS_DIR = join("knowledge", "skills");
|
|
11584
11762
|
function discoverInstalledSkills(dir) {
|
|
11585
11763
|
const base = join(dir, SKILLS_DIR);
|
|
@@ -11589,7 +11767,7 @@ function discoverInstalledSkills(dir) {
|
|
|
11589
11767
|
const skillFile = join(base, entry, "skill.md");
|
|
11590
11768
|
if (!isFile(skillFile)) continue;
|
|
11591
11769
|
try {
|
|
11592
|
-
const { data } =
|
|
11770
|
+
const { data } = matter6(readFile(skillFile));
|
|
11593
11771
|
if (data.type && String(data.type) !== "skill") continue;
|
|
11594
11772
|
const id = String(data.id ?? entry);
|
|
11595
11773
|
out.push({
|
|
@@ -12700,10 +12878,10 @@ function resolveNextStep(dir, now = /* @__PURE__ */ new Date()) {
|
|
|
12700
12878
|
const q = (rel) => analyzeKnowledgeArtifact(dir, rel);
|
|
12701
12879
|
const resolveAgent = (agent) => {
|
|
12702
12880
|
const file = agent.endsWith(".md") ? agent : `${agent}.md`;
|
|
12703
|
-
const
|
|
12704
|
-
const installed = isFile(join(dir,
|
|
12881
|
+
const path13 = agentInstallPath(file);
|
|
12882
|
+
const installed = isFile(join(dir, path13));
|
|
12705
12883
|
const group = agentGroupOf(file);
|
|
12706
|
-
return { agentPath:
|
|
12884
|
+
return { agentPath: path13, agentInstalled: installed, installCommand: installed ? void 0 : `kaddo add agents --group ${group}` };
|
|
12707
12885
|
};
|
|
12708
12886
|
const moduleRepo = isModule(config);
|
|
12709
12887
|
const coreRepo = isCore(config);
|
|
@@ -13133,7 +13311,7 @@ function deriveDeliveryCompletedStatus(dir) {
|
|
|
13133
13311
|
}
|
|
13134
13312
|
|
|
13135
13313
|
// src/core/assets.ts
|
|
13136
|
-
import
|
|
13314
|
+
import matter7 from "gray-matter";
|
|
13137
13315
|
function canonicalAgents() {
|
|
13138
13316
|
return AGENT_PROMPTS.map((a) => ({
|
|
13139
13317
|
name: a.fileName.replace(/\.md$/, ""),
|
|
@@ -13146,7 +13324,7 @@ function canonicalSkills() {
|
|
|
13146
13324
|
}
|
|
13147
13325
|
function versionOf(content) {
|
|
13148
13326
|
try {
|
|
13149
|
-
const v =
|
|
13327
|
+
const v = matter7(content).data.version;
|
|
13150
13328
|
return v === void 0 || v === null ? null : String(v);
|
|
13151
13329
|
} catch {
|
|
13152
13330
|
return null;
|
|
@@ -14629,7 +14807,7 @@ function readKnowledge(dir) {
|
|
|
14629
14807
|
if (!exists(knowledgePath)) return null;
|
|
14630
14808
|
try {
|
|
14631
14809
|
const raw = readFile(knowledgePath);
|
|
14632
|
-
const { data, content } =
|
|
14810
|
+
const { data, content } = matter8(raw);
|
|
14633
14811
|
return { content, data };
|
|
14634
14812
|
} catch {
|
|
14635
14813
|
return null;
|
|
@@ -14640,7 +14818,7 @@ function readRoadmap(dir) {
|
|
|
14640
14818
|
if (!exists(roadmapPath)) return null;
|
|
14641
14819
|
try {
|
|
14642
14820
|
const raw = readFile(roadmapPath);
|
|
14643
|
-
const { content } =
|
|
14821
|
+
const { content } = matter8(raw);
|
|
14644
14822
|
return content.trim();
|
|
14645
14823
|
} catch {
|
|
14646
14824
|
return null;
|
|
@@ -14809,7 +14987,7 @@ function runExplain(opts) {
|
|
|
14809
14987
|
}
|
|
14810
14988
|
|
|
14811
14989
|
// src/core/context-pack.ts
|
|
14812
|
-
import
|
|
14990
|
+
import matter9 from "gray-matter";
|
|
14813
14991
|
var CONTEXT_PACK_VERSION = "1";
|
|
14814
14992
|
var ARCH_DIR6 = "knowledge";
|
|
14815
14993
|
function readScanJson(dir) {
|
|
@@ -14822,7 +15000,7 @@ function readScanJson(dir) {
|
|
|
14822
15000
|
}
|
|
14823
15001
|
}
|
|
14824
15002
|
function firstParagraph2(markdown) {
|
|
14825
|
-
const body =
|
|
15003
|
+
const body = matter9(markdown).content.trim();
|
|
14826
15004
|
const para = body.split("\n\n").map((p) => p.trim()).find((p) => p && !p.startsWith("#"));
|
|
14827
15005
|
return para ?? "";
|
|
14828
15006
|
}
|
|
@@ -14876,6 +15054,8 @@ function toContextWorkItem(a) {
|
|
|
14876
15054
|
wi.validationStatus = a.validationStatus || (isHistorical ? "not-assessed" : void 0);
|
|
14877
15055
|
wi.releaseStatus = a.releaseStatus || (isHistorical ? "not-assessed" : void 0);
|
|
14878
15056
|
if (a.affectedModules.length > 0) wi.affectedModules = a.affectedModules;
|
|
15057
|
+
const wiResources = parseWorkItemResources(a.rawFrontmatter);
|
|
15058
|
+
if (wiResources.length > 0) wi.resources = wiResources;
|
|
14879
15059
|
if (a.scopeConfidence) wi.scopeConfidence = a.scopeConfidence;
|
|
14880
15060
|
if (a.moduleCoverage) wi.moduleCoverage = a.moduleCoverage;
|
|
14881
15061
|
if (a.impactAnalysis) wi.impactAnalysis = a.impactAnalysis;
|
|
@@ -16444,7 +16624,7 @@ function runStatus() {
|
|
|
16444
16624
|
// src/commands/learn.ts
|
|
16445
16625
|
import fs3 from "fs";
|
|
16446
16626
|
import path7 from "path";
|
|
16447
|
-
import
|
|
16627
|
+
import matter10 from "gray-matter";
|
|
16448
16628
|
var ARCH_DIR9 = "knowledge";
|
|
16449
16629
|
var WORK_ITEMS_DIR2 = "knowledge/delivery/work-items";
|
|
16450
16630
|
function completedPathFor(filePath) {
|
|
@@ -16459,7 +16639,7 @@ function completedPathFor(filePath) {
|
|
|
16459
16639
|
}
|
|
16460
16640
|
function updateWorkItemFile(filePath, learning) {
|
|
16461
16641
|
const raw = readFile(filePath);
|
|
16462
|
-
const { data, content } =
|
|
16642
|
+
const { data, content } = matter10(raw);
|
|
16463
16643
|
data.status = "completed";
|
|
16464
16644
|
data.completed_at = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
16465
16645
|
let updatedContent = content;
|
|
@@ -16484,7 +16664,7 @@ ${learning.trim()}
|
|
|
16484
16664
|
${learning.trim()}
|
|
16485
16665
|
`;
|
|
16486
16666
|
}
|
|
16487
|
-
const newRaw =
|
|
16667
|
+
const newRaw = matter10.stringify(updatedContent, data);
|
|
16488
16668
|
const newPath = completedPathFor(filePath);
|
|
16489
16669
|
if (newPath !== filePath) {
|
|
16490
16670
|
ensureDir(path7.dirname(newPath));
|
|
@@ -16536,7 +16716,7 @@ async function runLearn(artifactId, opts = {}) {
|
|
|
16536
16716
|
process.exit(1);
|
|
16537
16717
|
}
|
|
16538
16718
|
const wiRaw = readFile(filePath);
|
|
16539
|
-
const wiData =
|
|
16719
|
+
const wiData = matter10(wiRaw).data;
|
|
16540
16720
|
if (!opts.force) {
|
|
16541
16721
|
const completionBlockers = [];
|
|
16542
16722
|
const releaseGates = Array.isArray(wiData.release_gates) ? wiData.release_gates : [];
|
|
@@ -16792,7 +16972,7 @@ function runAdd(moduleName, opts = {}, dir = cwd()) {
|
|
|
16792
16972
|
}
|
|
16793
16973
|
|
|
16794
16974
|
// src/core/ownership-suggest.ts
|
|
16795
|
-
import
|
|
16975
|
+
import matter11 from "gray-matter";
|
|
16796
16976
|
var SCAN_PATH = ".kaddo/scan.json";
|
|
16797
16977
|
function normalizeGlob(input) {
|
|
16798
16978
|
let g = input.trim().replace(/\\/g, "/");
|
|
@@ -16914,11 +17094,11 @@ function suggestGlobs(artifact, signals) {
|
|
|
16914
17094
|
return [...new Set(out)];
|
|
16915
17095
|
}
|
|
16916
17096
|
function applyOwnership(raw, globs, mode = "replace") {
|
|
16917
|
-
const parsed =
|
|
17097
|
+
const parsed = matter11(raw);
|
|
16918
17098
|
const existing = toStringArray3(parsed.data.code);
|
|
16919
17099
|
const next = mode === "append" ? [.../* @__PURE__ */ new Set([...existing, ...globs])] : [...new Set(globs)];
|
|
16920
17100
|
const data = { ...parsed.data, code: next };
|
|
16921
|
-
return
|
|
17101
|
+
return matter11.stringify(parsed.content, data);
|
|
16922
17102
|
}
|
|
16923
17103
|
|
|
16924
17104
|
// src/commands/owners.ts
|
|
@@ -18008,15 +18188,372 @@ async function runTopologyApply(file, opts = {}) {
|
|
|
18008
18188
|
}
|
|
18009
18189
|
}
|
|
18010
18190
|
|
|
18011
|
-
// src/
|
|
18191
|
+
// src/core/resource-write.ts
|
|
18192
|
+
import fs5 from "fs";
|
|
18193
|
+
import path9 from "path";
|
|
18012
18194
|
import matter12 from "gray-matter";
|
|
18195
|
+
var RESOURCES_DIR = "knowledge/tech/resources";
|
|
18196
|
+
var ResourceWriteError = class extends Error {
|
|
18197
|
+
constructor(code, message) {
|
|
18198
|
+
super(message);
|
|
18199
|
+
this.code = code;
|
|
18200
|
+
this.name = "ResourceWriteError";
|
|
18201
|
+
}
|
|
18202
|
+
code;
|
|
18203
|
+
};
|
|
18204
|
+
function slug4(s) {
|
|
18205
|
+
return s.toLowerCase().trim().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60);
|
|
18206
|
+
}
|
|
18207
|
+
function atomicWrite2(filePath, content) {
|
|
18208
|
+
const tmp = `${filePath}.tmp-${process.pid}-${Date.now()}`;
|
|
18209
|
+
fs5.writeFileSync(tmp, content, "utf-8");
|
|
18210
|
+
fs5.renameSync(tmp, filePath);
|
|
18211
|
+
}
|
|
18212
|
+
function sanitizeRefs(refs) {
|
|
18213
|
+
if (!Array.isArray(refs)) return [];
|
|
18214
|
+
return refs.map((r) => String(r).trim()).filter((r) => r && !r.includes("=") && /^[A-Za-z0-9_.-]+$/.test(r));
|
|
18215
|
+
}
|
|
18216
|
+
function allResourceArtifacts(dir) {
|
|
18217
|
+
return discoverKnowledge(dir).filter((a) => a.type === RESOURCE_ARTIFACT_TYPE);
|
|
18218
|
+
}
|
|
18219
|
+
function nextResourceId(dir, title, explicit) {
|
|
18220
|
+
const existing = new Set(allResourceArtifacts(dir).map((a) => (a.id || "").toUpperCase()));
|
|
18221
|
+
if (explicit && explicit.trim()) return explicit.trim();
|
|
18222
|
+
const base = `RES-${slug4(title) || "resource"}`;
|
|
18223
|
+
if (!existing.has(base.toUpperCase())) return base;
|
|
18224
|
+
for (let i = 2; i < 1e3; i++) {
|
|
18225
|
+
const candidate = `${base}-${i}`;
|
|
18226
|
+
if (!existing.has(candidate.toUpperCase())) return candidate;
|
|
18227
|
+
}
|
|
18228
|
+
throw new ResourceWriteError("ID_EXHAUSTED", `Could not derive a unique id for "${title}".`);
|
|
18229
|
+
}
|
|
18230
|
+
function validateResource(dir, input) {
|
|
18231
|
+
const findings = [];
|
|
18232
|
+
if (input.resourceType && !RESOURCE_TYPES.includes(input.resourceType)) {
|
|
18233
|
+
findings.push({ level: "warning", message: `Unknown resource_type "${input.resourceType}" (not in the known set).` });
|
|
18234
|
+
}
|
|
18235
|
+
for (const i of input.accessInterfaces ?? []) {
|
|
18236
|
+
if (i.type && !INTERFACE_TYPES.includes(i.type)) {
|
|
18237
|
+
findings.push({ level: "warning", message: `Unknown access interface type "${i.type}".` });
|
|
18238
|
+
}
|
|
18239
|
+
}
|
|
18240
|
+
const mapped = loadMappedModules(dir).map((m) => m.id);
|
|
18241
|
+
if (mapped.length > 0) {
|
|
18242
|
+
const refs = /* @__PURE__ */ new Set();
|
|
18243
|
+
if (input.scope?.type === "module" && input.scope.module) refs.add(input.scope.module);
|
|
18244
|
+
for (const m of input.modules ?? []) refs.add(m);
|
|
18245
|
+
for (const m of refs) {
|
|
18246
|
+
if (!mapped.includes(m)) findings.push({ level: "warning", message: `Module "${m}" is not in .kaddo/modules.yml.` });
|
|
18247
|
+
}
|
|
18248
|
+
}
|
|
18249
|
+
if (input.scope && input.scope.type === "module" && !input.scope.module) {
|
|
18250
|
+
findings.push({ level: "error", message: 'scope.type "module" requires a module id.' });
|
|
18251
|
+
}
|
|
18252
|
+
return findings;
|
|
18253
|
+
}
|
|
18254
|
+
function buildFrontmatter(id, input, base = {}) {
|
|
18255
|
+
const data = { ...base };
|
|
18256
|
+
data.type = RESOURCE_ARTIFACT_TYPE;
|
|
18257
|
+
data.id = id;
|
|
18258
|
+
if (input.title != null) data.title = input.title;
|
|
18259
|
+
if (input.resourceType != null) data.resource_type = input.resourceType;
|
|
18260
|
+
if (input.provider != null) data.provider = input.provider;
|
|
18261
|
+
if (input.environments != null) data.environments = input.environments;
|
|
18262
|
+
if (input.scope != null) data.scope = input.scope.module ? { type: input.scope.type, module: input.scope.module } : { type: input.scope.type };
|
|
18263
|
+
if (input.modules != null) data.modules = input.modules;
|
|
18264
|
+
if (input.accessInterfaces != null) data.access_interfaces = input.accessInterfaces;
|
|
18265
|
+
if (input.accessBoundaries != null) data.access_boundaries = input.accessBoundaries;
|
|
18266
|
+
if (input.authentication != null) {
|
|
18267
|
+
const mode = input.authentication.mode;
|
|
18268
|
+
const refs = sanitizeRefs(input.authentication.refs);
|
|
18269
|
+
data.authentication = { ...mode ? { mode } : {}, ...refs.length ? { refs } : {} };
|
|
18270
|
+
}
|
|
18271
|
+
return data;
|
|
18272
|
+
}
|
|
18273
|
+
function serialize(data, body) {
|
|
18274
|
+
return matter12.stringify(`
|
|
18275
|
+
${body.trim()}
|
|
18276
|
+
`, data);
|
|
18277
|
+
}
|
|
18278
|
+
function createResource(dir, input) {
|
|
18279
|
+
const title = (input.title ?? "").trim();
|
|
18280
|
+
if (!title) throw new ResourceWriteError("INVALID_INPUT", "A resource title is required.");
|
|
18281
|
+
const resourceType = (input.resourceType ?? "").trim();
|
|
18282
|
+
if (!resourceType) throw new ResourceWriteError("INVALID_INPUT", "A resource_type is required.");
|
|
18283
|
+
const findings = validateResource(dir, input);
|
|
18284
|
+
if (findings.some((f) => f.level === "error")) {
|
|
18285
|
+
throw new ResourceWriteError("VALIDATION_FAILED", findings.filter((f) => f.level === "error").map((f) => f.message).join("; "));
|
|
18286
|
+
}
|
|
18287
|
+
const existing = allResourceArtifacts(dir);
|
|
18288
|
+
if (input.id && existing.some((a) => (a.id || "").toUpperCase() === input.id.toUpperCase())) {
|
|
18289
|
+
throw new ResourceWriteError("DUPLICATE", `A resource with id "${input.id}" already exists.`);
|
|
18290
|
+
}
|
|
18291
|
+
if (existing.some((a) => (a.title || "").toLowerCase() === title.toLowerCase())) {
|
|
18292
|
+
throw new ResourceWriteError("DUPLICATE", `A resource titled "${title}" already exists.`);
|
|
18293
|
+
}
|
|
18294
|
+
const id = nextResourceId(dir, title, input.id);
|
|
18295
|
+
const data = buildFrontmatter(id, input);
|
|
18296
|
+
const body = `# Purpose
|
|
18297
|
+
|
|
18298
|
+
${(input.purpose ?? "").trim() || "TODO: describe what this resource is for."}`;
|
|
18299
|
+
const relPath = `${RESOURCES_DIR}/${slug4(title) || slug4(id)}.md`;
|
|
18300
|
+
const filePath = join(dir, relPath);
|
|
18301
|
+
if (exists(filePath)) throw new ResourceWriteError("DUPLICATE", `Resource file already exists: ${relPath}`);
|
|
18302
|
+
ensureDir(path9.dirname(filePath));
|
|
18303
|
+
atomicWrite2(filePath, serialize(data, body));
|
|
18304
|
+
return { id, path: relPath, findings };
|
|
18305
|
+
}
|
|
18306
|
+
function updateResource(dir, id, input) {
|
|
18307
|
+
const match = allResourceArtifacts(dir).find((a) => a.id === id || a.title === id);
|
|
18308
|
+
if (!match) throw new ResourceWriteError("NOT_FOUND", `Project Resource "${id}" not found.`);
|
|
18309
|
+
const findings = validateResource(dir, input);
|
|
18310
|
+
if (findings.some((f) => f.level === "error")) {
|
|
18311
|
+
throw new ResourceWriteError("VALIDATION_FAILED", findings.filter((f) => f.level === "error").map((f) => f.message).join("; "));
|
|
18312
|
+
}
|
|
18313
|
+
const raw = readFile(match.filePath);
|
|
18314
|
+
const parsed = matter12(raw);
|
|
18315
|
+
const base = parsed.data ?? {};
|
|
18316
|
+
const data = buildFrontmatter(match.id || id, input, base);
|
|
18317
|
+
let body = parsed.content.trim();
|
|
18318
|
+
if (input.purpose != null) {
|
|
18319
|
+
const purpose = `# Purpose
|
|
18320
|
+
|
|
18321
|
+
${input.purpose.trim()}`;
|
|
18322
|
+
body = /^#\s+Purpose/m.test(body) ? body.replace(/#\s+Purpose[\s\S]*?(?=\n#\s|\n*$)/, purpose + "\n") : `${purpose}
|
|
18323
|
+
|
|
18324
|
+
${body}`.trim();
|
|
18325
|
+
}
|
|
18326
|
+
atomicWrite2(match.filePath, serialize(data, body));
|
|
18327
|
+
return { id: match.id || id, path: match.relPath, findings };
|
|
18328
|
+
}
|
|
18329
|
+
function getResourceReferences(dir, id) {
|
|
18330
|
+
const refs = [];
|
|
18331
|
+
for (const wi of discoverWorkItems(dir)) {
|
|
18332
|
+
for (const rel of parseWorkItemResources(wi.rawFrontmatter)) {
|
|
18333
|
+
if (rel.id === id) refs.push({ kind: "work-item", id: wi.id || wi.title, role: rel.role, path: wi.relPath });
|
|
18334
|
+
}
|
|
18335
|
+
}
|
|
18336
|
+
return refs;
|
|
18337
|
+
}
|
|
18338
|
+
function deleteResource(dir, id, opts = {}) {
|
|
18339
|
+
const match = allResourceArtifacts(dir).find((a) => a.id === id || a.title === id);
|
|
18340
|
+
if (!match) throw new ResourceWriteError("NOT_FOUND", `Project Resource "${id}" not found.`);
|
|
18341
|
+
const references = getResourceReferences(dir, match.id || id);
|
|
18342
|
+
if (!opts.confirm) {
|
|
18343
|
+
return { deleted: false, preview: { id: match.id || id, references } };
|
|
18344
|
+
}
|
|
18345
|
+
fs5.rmSync(match.filePath, { force: true });
|
|
18346
|
+
return { deleted: true, path: match.relPath };
|
|
18347
|
+
}
|
|
18348
|
+
|
|
18349
|
+
// src/commands/resources.ts
|
|
18350
|
+
function printFindings2(findings) {
|
|
18351
|
+
for (const f of findings) {
|
|
18352
|
+
if (f.level === "error") log.error(f.message);
|
|
18353
|
+
else log.warn(f.message);
|
|
18354
|
+
}
|
|
18355
|
+
}
|
|
18356
|
+
function runResourcesList(dir = cwd(), opts = {}) {
|
|
18357
|
+
const resources = getResources(dir);
|
|
18358
|
+
if (opts.json) {
|
|
18359
|
+
console.log(JSON.stringify(resources, null, 2));
|
|
18360
|
+
return;
|
|
18361
|
+
}
|
|
18362
|
+
if (resources.length === 0) {
|
|
18363
|
+
console.log("");
|
|
18364
|
+
console.log("No Project Resources are defined for this project.");
|
|
18365
|
+
console.log("");
|
|
18366
|
+
console.log("Add one under:");
|
|
18367
|
+
console.log(" knowledge/tech/resources/");
|
|
18368
|
+
console.log("");
|
|
18369
|
+
return;
|
|
18370
|
+
}
|
|
18371
|
+
console.log("");
|
|
18372
|
+
console.log("Project Resources:");
|
|
18373
|
+
for (const r of resources) {
|
|
18374
|
+
const type = r.resourceType ?? "\u2014";
|
|
18375
|
+
const provider = r.provider ? ` (${r.provider})` : "";
|
|
18376
|
+
const envs = r.environments.length > 0 ? ` [${r.environments.join(", ")}]` : "";
|
|
18377
|
+
console.log(` ${r.id.padEnd(22)} ${type.padEnd(12)}${provider}${envs}`);
|
|
18378
|
+
}
|
|
18379
|
+
console.log("");
|
|
18380
|
+
}
|
|
18381
|
+
function runResourcesGet(id, dir = cwd(), opts = {}) {
|
|
18382
|
+
const resource = getResource(dir, id);
|
|
18383
|
+
if (!resource) {
|
|
18384
|
+
if (opts.json) {
|
|
18385
|
+
console.log(JSON.stringify({ error: `Resource "${id}" not found.` }, null, 2));
|
|
18386
|
+
} else {
|
|
18387
|
+
console.error(`Project Resource "${id}" not found under knowledge/tech/resources/.`);
|
|
18388
|
+
}
|
|
18389
|
+
process.exit(1);
|
|
18390
|
+
}
|
|
18391
|
+
if (opts.json) {
|
|
18392
|
+
console.log(JSON.stringify(resource, null, 2));
|
|
18393
|
+
return;
|
|
18394
|
+
}
|
|
18395
|
+
const r = resource;
|
|
18396
|
+
console.log("");
|
|
18397
|
+
console.log(`${r.id} \u2014 ${r.title}`);
|
|
18398
|
+
console.log("");
|
|
18399
|
+
console.log(` Type: ${r.resourceType ?? "\u2014"}`);
|
|
18400
|
+
console.log(` Provider: ${r.provider ?? "\u2014"}`);
|
|
18401
|
+
if (r.environments.length > 0) console.log(` Environments: ${r.environments.join(", ")}`);
|
|
18402
|
+
if (r.purpose) console.log(` Purpose: ${r.purpose}`);
|
|
18403
|
+
if (r.interfaces.length > 0) {
|
|
18404
|
+
console.log("");
|
|
18405
|
+
console.log(" Access interfaces:");
|
|
18406
|
+
for (const i of r.interfaces) {
|
|
18407
|
+
const tool = i.tool ?? i.provider ?? "";
|
|
18408
|
+
const label = tool ? `${i.type} (${tool})` : i.type;
|
|
18409
|
+
console.log(` - ${label}`);
|
|
18410
|
+
if (i.purpose) console.log(` purpose: ${i.purpose}`);
|
|
18411
|
+
if (i.operations.length > 0) console.log(` operations: ${i.operations.join(", ")}`);
|
|
18412
|
+
if (i.environments.length > 0) console.log(` environments: ${i.environments.join(", ")}`);
|
|
18413
|
+
if (i.constraints) console.log(` constraints: ${i.constraints}`);
|
|
18414
|
+
}
|
|
18415
|
+
}
|
|
18416
|
+
const boundaryEnvs = Object.keys(r.boundaries);
|
|
18417
|
+
if (boundaryEnvs.length > 0) {
|
|
18418
|
+
console.log("");
|
|
18419
|
+
console.log(" Access boundaries:");
|
|
18420
|
+
for (const env of boundaryEnvs) {
|
|
18421
|
+
console.log(` - ${env}: ${r.boundaries[env].join(", ")}`);
|
|
18422
|
+
}
|
|
18423
|
+
}
|
|
18424
|
+
if (r.authRefs.length > 0 || r.authMode) {
|
|
18425
|
+
console.log("");
|
|
18426
|
+
console.log(" Authentication (references only \u2014 never values):");
|
|
18427
|
+
if (r.authMode) console.log(` mode: ${r.authMode}`);
|
|
18428
|
+
if (r.authRefs.length > 0) console.log(` refs: ${r.authRefs.join(", ")}`);
|
|
18429
|
+
}
|
|
18430
|
+
console.log("");
|
|
18431
|
+
}
|
|
18432
|
+
async function runResourcesCreate(opts = {}, dir = cwd()) {
|
|
18433
|
+
let title = opts.title?.trim();
|
|
18434
|
+
let type = opts.type?.trim();
|
|
18435
|
+
let provider = opts.provider?.trim();
|
|
18436
|
+
let scopeType = opts.scope?.trim() || (opts.module ? "module" : "system");
|
|
18437
|
+
let moduleId = opts.module?.trim();
|
|
18438
|
+
const interactive = !opts.json && process.stdin.isTTY && (!title || !type);
|
|
18439
|
+
if (interactive) {
|
|
18440
|
+
intro("kaddo resources create");
|
|
18441
|
+
if (!title) title = (await text({ message: "Resource name", placeholder: "Supabase Main" })).trim();
|
|
18442
|
+
if (!type) type = await select({
|
|
18443
|
+
message: "Resource type",
|
|
18444
|
+
options: ["database", "cloud", "api", "queue", "storage", "repository", "platform", "service", "other"].map((v) => ({ value: v, label: v }))
|
|
18445
|
+
});
|
|
18446
|
+
if (!provider) provider = (await text({ message: "Provider (optional)", placeholder: "supabase", defaultValue: "" })).trim() || void 0;
|
|
18447
|
+
scopeType = await select({ message: "Scope", options: [{ value: "system", label: "system" }, { value: "module", label: "module" }] });
|
|
18448
|
+
if (scopeType === "module") moduleId = (await text({ message: "Module id", placeholder: "orders-api" })).trim();
|
|
18449
|
+
}
|
|
18450
|
+
if (!title || !type) {
|
|
18451
|
+
console.error("A resource title and type are required. Use --title and --type (or run interactively).");
|
|
18452
|
+
process.exit(1);
|
|
18453
|
+
}
|
|
18454
|
+
const input = { title, resourceType: type };
|
|
18455
|
+
if (provider) input.provider = provider;
|
|
18456
|
+
input.scope = scopeType === "module" ? { type: "module", module: moduleId } : { type: "system" };
|
|
18457
|
+
try {
|
|
18458
|
+
const res = createResource(dir, input);
|
|
18459
|
+
if (opts.json) {
|
|
18460
|
+
console.log(JSON.stringify(res, null, 2));
|
|
18461
|
+
return;
|
|
18462
|
+
}
|
|
18463
|
+
printFindings2(res.findings);
|
|
18464
|
+
log.success(`Created ${res.id}`);
|
|
18465
|
+
if (interactive) outro(`Resource created at ${res.path}. Enrich it with \`kaddo resources update ${res.id}\`.`);
|
|
18466
|
+
else {
|
|
18467
|
+
console.log(` ${res.path}`);
|
|
18468
|
+
console.log(` Enrich it later with: kaddo resources update ${res.id}`);
|
|
18469
|
+
}
|
|
18470
|
+
} catch (err) {
|
|
18471
|
+
console.error(err instanceof ResourceWriteError ? err.message : String(err));
|
|
18472
|
+
process.exit(1);
|
|
18473
|
+
}
|
|
18474
|
+
}
|
|
18475
|
+
function runResourcesUpdate(id, opts = {}, dir = cwd()) {
|
|
18476
|
+
const input = {};
|
|
18477
|
+
if (opts.title != null) input.title = opts.title;
|
|
18478
|
+
if (opts.type != null) input.resourceType = opts.type;
|
|
18479
|
+
if (opts.provider != null) input.provider = opts.provider;
|
|
18480
|
+
if (opts.purpose != null) input.purpose = opts.purpose;
|
|
18481
|
+
if (opts.scope != null || opts.module != null) {
|
|
18482
|
+
const scopeType = opts.scope || (opts.module ? "module" : "system");
|
|
18483
|
+
input.scope = scopeType === "module" ? { type: "module", module: opts.module } : { type: "system" };
|
|
18484
|
+
}
|
|
18485
|
+
if (Object.keys(input).length === 0) {
|
|
18486
|
+
console.error("Nothing to update. Pass at least one field (e.g. --provider, --purpose, --module).");
|
|
18487
|
+
process.exit(1);
|
|
18488
|
+
}
|
|
18489
|
+
try {
|
|
18490
|
+
const res = updateResource(dir, id, input);
|
|
18491
|
+
if (opts.json) {
|
|
18492
|
+
console.log(JSON.stringify(res, null, 2));
|
|
18493
|
+
return;
|
|
18494
|
+
}
|
|
18495
|
+
printFindings2(res.findings);
|
|
18496
|
+
console.log(`Updated ${res.id} (${res.path}).`);
|
|
18497
|
+
} catch (err) {
|
|
18498
|
+
console.error(err instanceof ResourceWriteError ? err.message : String(err));
|
|
18499
|
+
process.exit(1);
|
|
18500
|
+
}
|
|
18501
|
+
}
|
|
18502
|
+
async function runResourcesDelete(id, opts = {}, dir = cwd()) {
|
|
18503
|
+
let preview;
|
|
18504
|
+
try {
|
|
18505
|
+
preview = deleteResource(dir, id);
|
|
18506
|
+
} catch (err) {
|
|
18507
|
+
console.error(err instanceof ResourceWriteError ? err.message : String(err));
|
|
18508
|
+
process.exit(1);
|
|
18509
|
+
}
|
|
18510
|
+
const refs = preview.preview?.references ?? [];
|
|
18511
|
+
if (opts.json && !opts.yes) {
|
|
18512
|
+
console.log(JSON.stringify(preview.preview, null, 2));
|
|
18513
|
+
return;
|
|
18514
|
+
}
|
|
18515
|
+
if (refs.length > 0) {
|
|
18516
|
+
console.log("");
|
|
18517
|
+
console.log(`Resource "${id}" is referenced by:`);
|
|
18518
|
+
for (const r of refs) console.log(` - ${r.id} (${r.kind}, role: ${r.role})`);
|
|
18519
|
+
console.log("");
|
|
18520
|
+
console.log("Deleting the resource will NOT remove these references.");
|
|
18521
|
+
}
|
|
18522
|
+
let proceed = opts.yes === true;
|
|
18523
|
+
if (!proceed) {
|
|
18524
|
+
if (process.stdin.isTTY) {
|
|
18525
|
+
proceed = await confirm({ message: `Delete resource "${id}"?`, initialValue: false });
|
|
18526
|
+
} else {
|
|
18527
|
+
console.error(`Refusing to delete without confirmation. Re-run with --yes to delete "${id}".`);
|
|
18528
|
+
process.exit(1);
|
|
18529
|
+
}
|
|
18530
|
+
}
|
|
18531
|
+
if (!proceed) {
|
|
18532
|
+
console.log("Aborted.");
|
|
18533
|
+
return;
|
|
18534
|
+
}
|
|
18535
|
+
try {
|
|
18536
|
+
const done = deleteResource(dir, id, { confirm: true });
|
|
18537
|
+
if (opts.json) {
|
|
18538
|
+
console.log(JSON.stringify(done, null, 2));
|
|
18539
|
+
return;
|
|
18540
|
+
}
|
|
18541
|
+
log.success(`Deleted ${id} (${done.path}).`);
|
|
18542
|
+
} catch (err) {
|
|
18543
|
+
console.error(err instanceof ResourceWriteError ? err.message : String(err));
|
|
18544
|
+
process.exit(1);
|
|
18545
|
+
}
|
|
18546
|
+
}
|
|
18547
|
+
|
|
18548
|
+
// src/services/integrations.ts
|
|
18549
|
+
import matter14 from "gray-matter";
|
|
18013
18550
|
import { parse as parseYaml18, stringify as stringifyYaml9 } from "yaml";
|
|
18014
18551
|
|
|
18015
18552
|
// src/core/work-item-write.ts
|
|
18016
|
-
import
|
|
18017
|
-
import
|
|
18553
|
+
import fs6 from "fs";
|
|
18554
|
+
import path10 from "path";
|
|
18018
18555
|
import crypto2 from "crypto";
|
|
18019
|
-
import
|
|
18556
|
+
import matter13 from "gray-matter";
|
|
18020
18557
|
var WORK_ITEMS_DIR3 = "knowledge/delivery/work-items";
|
|
18021
18558
|
var WorkItemWriteError = class extends Error {
|
|
18022
18559
|
constructor(code, message) {
|
|
@@ -18037,7 +18574,7 @@ function nextWorkItemId2(dir) {
|
|
|
18037
18574
|
let max = 0;
|
|
18038
18575
|
const walk = (d) => {
|
|
18039
18576
|
if (!exists(d)) return;
|
|
18040
|
-
for (const entry of
|
|
18577
|
+
for (const entry of fs6.readdirSync(d)) {
|
|
18041
18578
|
const full = join(d, entry);
|
|
18042
18579
|
if (isFile(full)) {
|
|
18043
18580
|
const m = entry.match(/WI-(\d+)/);
|
|
@@ -18050,15 +18587,15 @@ function nextWorkItemId2(dir) {
|
|
|
18050
18587
|
walk(wiDir);
|
|
18051
18588
|
return `WI-${String(max + 1).padStart(3, "0")}`;
|
|
18052
18589
|
}
|
|
18053
|
-
function
|
|
18054
|
-
|
|
18590
|
+
function atomicWrite3(filePath, content) {
|
|
18591
|
+
fs6.mkdirSync(path10.dirname(filePath), { recursive: true });
|
|
18055
18592
|
const tmp = `${filePath}.${process.pid}.${Date.now()}.tmp`;
|
|
18056
|
-
|
|
18593
|
+
fs6.writeFileSync(tmp, content, "utf-8");
|
|
18057
18594
|
try {
|
|
18058
|
-
|
|
18595
|
+
fs6.renameSync(tmp, filePath);
|
|
18059
18596
|
} catch (err) {
|
|
18060
18597
|
try {
|
|
18061
|
-
|
|
18598
|
+
fs6.rmSync(tmp, { force: true });
|
|
18062
18599
|
} catch {
|
|
18063
18600
|
}
|
|
18064
18601
|
throw err;
|
|
@@ -18119,8 +18656,8 @@ function ensureH1(body, title) {
|
|
|
18119
18656
|
|
|
18120
18657
|
${trimmed}`;
|
|
18121
18658
|
}
|
|
18122
|
-
function
|
|
18123
|
-
return
|
|
18659
|
+
function serialize2(data, body) {
|
|
18660
|
+
return matter13.stringify(`
|
|
18124
18661
|
${body.trim()}
|
|
18125
18662
|
`, data);
|
|
18126
18663
|
}
|
|
@@ -18188,8 +18725,8 @@ function createWorkItem(dir, opts) {
|
|
|
18188
18725
|
const relPath = `${WORK_ITEMS_DIR3}/draft/${id}-${slugify5(title)}.md`;
|
|
18189
18726
|
const filePath = join(dir, relPath);
|
|
18190
18727
|
if (exists(filePath)) throw new WorkItemWriteError("INVALID_INPUT", `Work Item file already exists: ${relPath}`);
|
|
18191
|
-
const raw =
|
|
18192
|
-
|
|
18728
|
+
const raw = serialize2(data, body);
|
|
18729
|
+
atomicWrite3(filePath, raw);
|
|
18193
18730
|
return { id, path: relPath, revision: revisionOf(raw) };
|
|
18194
18731
|
}
|
|
18195
18732
|
|
|
@@ -18877,8 +19414,8 @@ async function handleJiraResponse(res) {
|
|
|
18877
19414
|
}
|
|
18878
19415
|
return await res.json();
|
|
18879
19416
|
}
|
|
18880
|
-
async function jiraFetch(baseUrl,
|
|
18881
|
-
const url = new URL(
|
|
19417
|
+
async function jiraFetch(baseUrl, path13, auth, timeoutMs, params) {
|
|
19418
|
+
const url = new URL(path13, baseUrl + "/");
|
|
18882
19419
|
if (params) for (const [k, v] of Object.entries(params)) url.searchParams.set(k, v);
|
|
18883
19420
|
const controller = new AbortController();
|
|
18884
19421
|
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
@@ -18896,8 +19433,8 @@ async function jiraFetch(baseUrl, path12, auth, timeoutMs, params) {
|
|
|
18896
19433
|
clearTimeout(timer);
|
|
18897
19434
|
}
|
|
18898
19435
|
}
|
|
18899
|
-
async function jiraPost(baseUrl,
|
|
18900
|
-
const url = new URL(
|
|
19436
|
+
async function jiraPost(baseUrl, path13, auth, timeoutMs, body) {
|
|
19437
|
+
const url = new URL(path13, baseUrl + "/");
|
|
18901
19438
|
const controller = new AbortController();
|
|
18902
19439
|
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
18903
19440
|
try {
|
|
@@ -19197,7 +19734,7 @@ function findLinkedWorkItem(dir, integrationId, externalId) {
|
|
|
19197
19734
|
for (const art of discoverWorkItems(dir)) {
|
|
19198
19735
|
let data;
|
|
19199
19736
|
try {
|
|
19200
|
-
data =
|
|
19737
|
+
data = matter14(readFile(art.filePath)).data;
|
|
19201
19738
|
} catch {
|
|
19202
19739
|
continue;
|
|
19203
19740
|
}
|
|
@@ -19410,7 +19947,7 @@ async function runIntegrationsImport(dir, id, externalId, opts) {
|
|
|
19410
19947
|
}
|
|
19411
19948
|
|
|
19412
19949
|
// src/core/impact-report.ts
|
|
19413
|
-
import
|
|
19950
|
+
import matter15 from "gray-matter";
|
|
19414
19951
|
function isBroadGlob(glob) {
|
|
19415
19952
|
if (!glob.endsWith("/**")) return false;
|
|
19416
19953
|
const prefix = glob.slice(0, -3);
|
|
@@ -19479,7 +20016,7 @@ function buildImpactReport(dir, opts = {}, now = /* @__PURE__ */ new Date()) {
|
|
|
19479
20016
|
}
|
|
19480
20017
|
}
|
|
19481
20018
|
try {
|
|
19482
|
-
const body =
|
|
20019
|
+
const body = matter15(readFile(wi.filePath)).content;
|
|
19483
20020
|
if (hasSection(body, /acceptance|criterios de aceptaci/i)) withAcceptance++;
|
|
19484
20021
|
else gaps.missing_acceptance_criteria.push(gapItem(wi, "Add an `## Acceptance Criteria` section."));
|
|
19485
20022
|
if (hasSection(body, /definition of done|^#{1,6}\s*dod\b|definici[oó]n de (terminado|hecho)/i)) withDoD++;
|
|
@@ -20556,7 +21093,7 @@ function runAdr(opts = {}) {
|
|
|
20556
21093
|
}
|
|
20557
21094
|
|
|
20558
21095
|
// src/commands/tech.ts
|
|
20559
|
-
import
|
|
21096
|
+
import fs7 from "fs";
|
|
20560
21097
|
var DISCOVERY_FILES = ["architecture-notes.md", "decision-candidates.md"];
|
|
20561
21098
|
var DISCOVERY_DIR = "knowledge/tech/discovery";
|
|
20562
21099
|
function runTechOrganize(dir = cwd()) {
|
|
@@ -20573,7 +21110,7 @@ function runTechOrganize(dir = cwd()) {
|
|
|
20573
21110
|
continue;
|
|
20574
21111
|
}
|
|
20575
21112
|
ensureDir(join(dir, DISCOVERY_DIR));
|
|
20576
|
-
|
|
21113
|
+
fs7.renameSync(from, to);
|
|
20577
21114
|
moved.push(`knowledge/tech/${file} \u2192 ${DISCOVERY_DIR}/${file}`);
|
|
20578
21115
|
}
|
|
20579
21116
|
if (moved.length > 0) {
|
|
@@ -20655,9 +21192,9 @@ function runAssetsUpdate(kind, opts = {}) {
|
|
|
20655
21192
|
}
|
|
20656
21193
|
|
|
20657
21194
|
// src/commands/ready.ts
|
|
20658
|
-
import
|
|
20659
|
-
import
|
|
20660
|
-
import
|
|
21195
|
+
import fs8 from "fs";
|
|
21196
|
+
import path11 from "path";
|
|
21197
|
+
import matter16 from "gray-matter";
|
|
20661
21198
|
function validateReadiness(content, frontmatter) {
|
|
20662
21199
|
const warnings = [];
|
|
20663
21200
|
const body = content.replace(/^---[\s\S]*?---/, "").trim();
|
|
@@ -20711,18 +21248,18 @@ function isResolvedSection(text2) {
|
|
|
20711
21248
|
}
|
|
20712
21249
|
function transitionToReady(filePath) {
|
|
20713
21250
|
const raw = readFile(filePath);
|
|
20714
|
-
const { data, content } =
|
|
21251
|
+
const { data, content } = matter16(raw);
|
|
20715
21252
|
const today3 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
20716
21253
|
data.status = "ready";
|
|
20717
21254
|
data.ready_at = today3;
|
|
20718
|
-
const newContent =
|
|
21255
|
+
const newContent = matter16.stringify(content, data);
|
|
20719
21256
|
const posix = filePath.replace(/\\/g, "/");
|
|
20720
21257
|
let newPath = filePath;
|
|
20721
21258
|
if (posix.includes("/work-items/draft/")) {
|
|
20722
|
-
const readyDir =
|
|
21259
|
+
const readyDir = path11.dirname(filePath).replace(/[/\\]draft$/, path11.sep + "ready");
|
|
20723
21260
|
ensureDir(readyDir);
|
|
20724
|
-
const fileName =
|
|
20725
|
-
newPath =
|
|
21261
|
+
const fileName = path11.basename(filePath);
|
|
21262
|
+
newPath = path11.join(readyDir, fileName);
|
|
20726
21263
|
}
|
|
20727
21264
|
return { newPath, newContent };
|
|
20728
21265
|
}
|
|
@@ -20755,7 +21292,7 @@ async function runReady(id, opts = {}) {
|
|
|
20755
21292
|
process.exit(1);
|
|
20756
21293
|
}
|
|
20757
21294
|
const raw = readFile(wi.filePath);
|
|
20758
|
-
const { data } =
|
|
21295
|
+
const { data } = matter16(raw);
|
|
20759
21296
|
const source = parseWorkItemSource(data);
|
|
20760
21297
|
const warnings = validateReadiness(raw, data);
|
|
20761
21298
|
log.info(`Work Item found:`);
|
|
@@ -20790,11 +21327,11 @@ async function runReady(id, opts = {}) {
|
|
|
20790
21327
|
const { newPath, newContent } = transitionToReady(wi.filePath);
|
|
20791
21328
|
if (newPath !== wi.filePath) {
|
|
20792
21329
|
writeFile(newPath, newContent);
|
|
20793
|
-
|
|
21330
|
+
fs8.unlinkSync(wi.filePath);
|
|
20794
21331
|
log.success(`Updated status: ready`);
|
|
20795
21332
|
log.success(`Moved file:`);
|
|
20796
|
-
log.info(` ${
|
|
20797
|
-
log.info(` \u2192 ${
|
|
21333
|
+
log.info(` ${path11.relative(dir, wi.filePath)}`);
|
|
21334
|
+
log.info(` \u2192 ${path11.relative(dir, newPath)}`);
|
|
20798
21335
|
} else {
|
|
20799
21336
|
writeFile(wi.filePath, newContent);
|
|
20800
21337
|
log.success(`Updated status: ready`);
|
|
@@ -20805,7 +21342,7 @@ async function runReady(id, opts = {}) {
|
|
|
20805
21342
|
}
|
|
20806
21343
|
|
|
20807
21344
|
// src/commands/admin.ts
|
|
20808
|
-
import
|
|
21345
|
+
import path12 from "path";
|
|
20809
21346
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
20810
21347
|
import net from "net";
|
|
20811
21348
|
function isPortAvailable(port, host) {
|
|
@@ -20820,17 +21357,17 @@ function isPortAvailable(port, host) {
|
|
|
20820
21357
|
});
|
|
20821
21358
|
}
|
|
20822
21359
|
function resolveStaticDir() {
|
|
20823
|
-
const __dirname =
|
|
21360
|
+
const __dirname = path12.dirname(fileURLToPath2(import.meta.url));
|
|
20824
21361
|
const candidates = [
|
|
20825
21362
|
// Monorepo development: prefer the freshly built admin over the copy bundled into the CLI dist.
|
|
20826
21363
|
// The CLI build copies admin/dist into dist/admin-dist, but that copy can be stale when the admin
|
|
20827
21364
|
// was rebuilt after the CLI (build order is not guaranteed in `pnpm -r build`). Serving the admin
|
|
20828
21365
|
// package's own dist first ensures `kaddo admin` always shows the current frontend in dev. This
|
|
20829
21366
|
// path does not exist in a published npm install (admin is private), so it falls back below.
|
|
20830
|
-
|
|
20831
|
-
|
|
21367
|
+
path12.resolve(__dirname, "..", "..", "admin", "dist"),
|
|
21368
|
+
path12.resolve(__dirname, "..", "node_modules", "@kaddo", "admin", "dist"),
|
|
20832
21369
|
// Bundled inside CLI dist (npm install)
|
|
20833
|
-
|
|
21370
|
+
path12.resolve(__dirname, "admin-dist")
|
|
20834
21371
|
];
|
|
20835
21372
|
for (const c of candidates) {
|
|
20836
21373
|
if (exists(join(c, "index.html"))) return c;
|
|
@@ -20872,8 +21409,8 @@ async function runAdmin(opts = {}) {
|
|
|
20872
21409
|
}
|
|
20873
21410
|
let adminServer;
|
|
20874
21411
|
try {
|
|
20875
|
-
const __dirname =
|
|
20876
|
-
const bundled =
|
|
21412
|
+
const __dirname = path12.dirname(fileURLToPath2(import.meta.url));
|
|
21413
|
+
const bundled = path12.resolve(__dirname, "admin-server", "index.js");
|
|
20877
21414
|
if (exists(bundled)) {
|
|
20878
21415
|
const { pathToFileURL } = await import("url");
|
|
20879
21416
|
adminServer = await import(pathToFileURL(bundled).href);
|
|
@@ -20930,11 +21467,11 @@ async function runAdmin(opts = {}) {
|
|
|
20930
21467
|
|
|
20931
21468
|
// src/core/work-item-import.ts
|
|
20932
21469
|
import crypto3 from "crypto";
|
|
20933
|
-
import
|
|
20934
|
-
import
|
|
21470
|
+
import fs9 from "fs";
|
|
21471
|
+
import matter18 from "gray-matter";
|
|
20935
21472
|
|
|
20936
21473
|
// src/core/work-items.ts
|
|
20937
|
-
import
|
|
21474
|
+
import matter17 from "gray-matter";
|
|
20938
21475
|
function computeRefinementStatus(wi) {
|
|
20939
21476
|
const aspects = {
|
|
20940
21477
|
outcome: Boolean(wi.currentBehavior?.trim() || wi.targetBehavior?.trim()),
|
|
@@ -21002,6 +21539,8 @@ function getWorkItem(dir, workItemId) {
|
|
|
21002
21539
|
path: match.relPath,
|
|
21003
21540
|
// Faithful source of truth: the artifact body already read above, not reconstructed (WI-025).
|
|
21004
21541
|
markdownBody: body.trim(),
|
|
21542
|
+
// External systems this WI relates to (WI-030), separate from affectedModules (code).
|
|
21543
|
+
resources: parseWorkItemResources(fm2),
|
|
21005
21544
|
...parseSystemImpact(dir, fm2)
|
|
21006
21545
|
};
|
|
21007
21546
|
return { ...detail, refinement: computeRefinementStatus(detail) };
|
|
@@ -21010,8 +21549,8 @@ function parseGraphReason(v) {
|
|
|
21010
21549
|
if (!v || typeof v !== "object") return null;
|
|
21011
21550
|
const o = v;
|
|
21012
21551
|
const relationship = typeof o.relationship === "string" && o.relationship.trim() ? o.relationship.trim() : null;
|
|
21013
|
-
const
|
|
21014
|
-
return relationship ||
|
|
21552
|
+
const path13 = Array.isArray(o.path) ? o.path.map(String).filter(Boolean) : [];
|
|
21553
|
+
return relationship || path13.length ? { relationship, path: path13 } : null;
|
|
21015
21554
|
}
|
|
21016
21555
|
function parseExplain(o) {
|
|
21017
21556
|
const refs = Array.isArray(o.evidence) ? o.evidence : Array.isArray(o.evidence_refs) ? o.evidence_refs : [];
|
|
@@ -21066,7 +21605,7 @@ function parseOriginalSnapshot(fm2) {
|
|
|
21066
21605
|
function readBody(filePath) {
|
|
21067
21606
|
try {
|
|
21068
21607
|
const raw = readFile(filePath);
|
|
21069
|
-
return
|
|
21608
|
+
return matter17(raw).content;
|
|
21070
21609
|
} catch {
|
|
21071
21610
|
return "";
|
|
21072
21611
|
}
|
|
@@ -21525,7 +22064,7 @@ function detectFormat(raw) {
|
|
|
21525
22064
|
if (!trimmed) throw new ImportError("EMPTY_INPUT", "Import content is empty.");
|
|
21526
22065
|
if (trimmed.startsWith("---")) {
|
|
21527
22066
|
try {
|
|
21528
|
-
const { data } =
|
|
22067
|
+
const { data } = matter18(trimmed);
|
|
21529
22068
|
if (data && typeof data === "object" && Object.keys(data).length > 0) {
|
|
21530
22069
|
const d = data;
|
|
21531
22070
|
if (d.type === "work-item" || d.id && typeof d.id === "string" && /^WI-\d+/.test(d.id)) {
|
|
@@ -21547,7 +22086,7 @@ function parseContent(raw) {
|
|
|
21547
22086
|
let bodyText = trimmed;
|
|
21548
22087
|
if (format === "kaddo-frontmatter" || format === "markdown-frontmatter") {
|
|
21549
22088
|
try {
|
|
21550
|
-
const parsed =
|
|
22089
|
+
const parsed = matter18(trimmed);
|
|
21551
22090
|
frontmatterFields = parsed.data ?? {};
|
|
21552
22091
|
bodyText = parsed.content.trim();
|
|
21553
22092
|
} catch {
|
|
@@ -21644,7 +22183,7 @@ function findDuplicateByHash(dir, hash) {
|
|
|
21644
22183
|
const raw = readFile(item.filePath);
|
|
21645
22184
|
if (!raw) continue;
|
|
21646
22185
|
try {
|
|
21647
|
-
const { data } =
|
|
22186
|
+
const { data } = matter18(raw);
|
|
21648
22187
|
const source = data?.source;
|
|
21649
22188
|
if (source && typeof source === "object" && !Array.isArray(source)) {
|
|
21650
22189
|
const s = source;
|
|
@@ -21711,7 +22250,7 @@ function importWorkItem(dir, opts) {
|
|
|
21711
22250
|
};
|
|
21712
22251
|
}
|
|
21713
22252
|
if (opts.onConflict === "replace") {
|
|
21714
|
-
|
|
22253
|
+
fs9.rmSync(existing.filePath, { force: true });
|
|
21715
22254
|
replacedWorkItem = existing.workItemId;
|
|
21716
22255
|
}
|
|
21717
22256
|
}
|
|
@@ -21860,7 +22399,7 @@ async function runWorkItemImport(dir, fileOrText, opts) {
|
|
|
21860
22399
|
}
|
|
21861
22400
|
|
|
21862
22401
|
// src/commands/verify.ts
|
|
21863
|
-
import
|
|
22402
|
+
import matter19 from "gray-matter";
|
|
21864
22403
|
|
|
21865
22404
|
// src/core/implementation-evidence.ts
|
|
21866
22405
|
var WorkItemNotInProgressError = class extends Error {
|
|
@@ -22137,7 +22676,7 @@ async function runVerify(workItemId, opts = {}) {
|
|
|
22137
22676
|
}
|
|
22138
22677
|
const changedPaths = await getModifiedFiles("head");
|
|
22139
22678
|
const raw = readFile(match.filePath);
|
|
22140
|
-
const parsed =
|
|
22679
|
+
const parsed = matter19(raw);
|
|
22141
22680
|
const fm2 = parsed.data;
|
|
22142
22681
|
const acs = extractACsFromBody(parsed.content);
|
|
22143
22682
|
const existingEvidence = fm2.implementation_evidence;
|
|
@@ -22254,13 +22793,13 @@ async function runVerify(workItemId, opts = {}) {
|
|
|
22254
22793
|
if (shouldPersist) {
|
|
22255
22794
|
const filePath = match.filePath;
|
|
22256
22795
|
const wiRaw = readFile(filePath);
|
|
22257
|
-
const wiParsed =
|
|
22796
|
+
const wiParsed = matter19(wiRaw);
|
|
22258
22797
|
const data = wiParsed.data;
|
|
22259
22798
|
data.implementation_evidence = verification.implementationEvidence;
|
|
22260
22799
|
data.implementation_status = verification.implementationStatus;
|
|
22261
22800
|
data.validation_status = verification.validationStatus;
|
|
22262
22801
|
data.verified_at = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
22263
|
-
const newRaw =
|
|
22802
|
+
const newRaw = matter19.stringify(wiParsed.content, data);
|
|
22264
22803
|
writeFile(filePath, newRaw);
|
|
22265
22804
|
log.success("Work Item frontmatter updated with verification evidence.");
|
|
22266
22805
|
}
|
|
@@ -22310,9 +22849,9 @@ function markRegistered(dir, identity) {
|
|
|
22310
22849
|
ensureDir(join(dir, TELEMETRY_DIR));
|
|
22311
22850
|
writeFile(identityPath(dir), JSON.stringify(identity, null, 2));
|
|
22312
22851
|
}
|
|
22313
|
-
function signPayload(identity, method,
|
|
22852
|
+
function signPayload(identity, method, path13, timestamp, nonce, bodySha256) {
|
|
22314
22853
|
const canonical = `${method}
|
|
22315
|
-
${
|
|
22854
|
+
${path13}
|
|
22316
22855
|
${identity.installationId}
|
|
22317
22856
|
${timestamp}
|
|
22318
22857
|
${nonce}
|
|
@@ -22538,7 +23077,7 @@ function runTelemetryDisable() {
|
|
|
22538
23077
|
}
|
|
22539
23078
|
|
|
22540
23079
|
// src/core/initiative-write.ts
|
|
22541
|
-
import
|
|
23080
|
+
import matter20 from "gray-matter";
|
|
22542
23081
|
var WORK_ITEMS_DIR4 = "knowledge/delivery/work-items";
|
|
22543
23082
|
var DRAFT_DIR2 = `${WORK_ITEMS_DIR4}/draft`;
|
|
22544
23083
|
var InitiativeWriteError = class extends Error {
|
|
@@ -22650,7 +23189,7 @@ function buildInitiativeContent(id, input) {
|
|
|
22650
23189
|
if (input.priority) data.priority = input.priority;
|
|
22651
23190
|
if (input.source) data.source = input.source;
|
|
22652
23191
|
if (input.sourceId) data.source_id = input.sourceId;
|
|
22653
|
-
return
|
|
23192
|
+
return matter20.stringify("\n" + (input.body ?? defaultBody(input.title.trim())), data);
|
|
22654
23193
|
}
|
|
22655
23194
|
function createInitiative(dir, input) {
|
|
22656
23195
|
if (!input.title?.trim()) throw new InitiativeWriteError("Initiative title is required.");
|
|
@@ -22674,10 +23213,10 @@ function transitionInitiative(dir, id, to) {
|
|
|
22674
23213
|
throw new InitiativeWriteError(`Invalid transition ${ini.status} \u2192 ${to}.`);
|
|
22675
23214
|
}
|
|
22676
23215
|
const raw = readFile(ini.filePath);
|
|
22677
|
-
const { data, content } =
|
|
23216
|
+
const { data, content } = matter20(raw, {});
|
|
22678
23217
|
data.status = to;
|
|
22679
23218
|
if (to === "completed") data.completed_at = today2();
|
|
22680
|
-
const newContent =
|
|
23219
|
+
const newContent = matter20.stringify(content, data);
|
|
22681
23220
|
writeFile(ini.filePath, newContent);
|
|
22682
23221
|
const updated = parseInitiative(dir, ini.filePath, newContent);
|
|
22683
23222
|
if (!updated) throw new InitiativeWriteError("Failed to parse the Initiative after transition.");
|
|
@@ -22746,7 +23285,7 @@ function buildWorkItemContent(wiId, iniId, candidate) {
|
|
|
22746
23285
|
"_What did we learn? Update after completion._",
|
|
22747
23286
|
""
|
|
22748
23287
|
].join("\n");
|
|
22749
|
-
return
|
|
23288
|
+
return matter20.stringify("\n" + body, data);
|
|
22750
23289
|
}
|
|
22751
23290
|
function materializeCandidate(dir, id, candidateId) {
|
|
22752
23291
|
const ini = getInitiative(dir, id);
|
|
@@ -22763,13 +23302,13 @@ function materializeCandidate(dir, id, candidateId) {
|
|
|
22763
23302
|
ensureDir(join(dir, DRAFT_DIR2));
|
|
22764
23303
|
writeFile(join(dir, DRAFT_DIR2, fileName), buildWorkItemContent(wiId, ini.id, candidate));
|
|
22765
23304
|
const raw = readFile(ini.filePath);
|
|
22766
|
-
const { data, content } =
|
|
23305
|
+
const { data, content } = matter20(raw, {});
|
|
22767
23306
|
const cands = Array.isArray(data.candidates) ? data.candidates : [];
|
|
22768
23307
|
for (const c of cands) {
|
|
22769
23308
|
if (c && typeof c === "object" && String(c.id) === candidateId) c.materialized_as = wiId;
|
|
22770
23309
|
}
|
|
22771
23310
|
data.candidates = cands;
|
|
22772
|
-
const newContent =
|
|
23311
|
+
const newContent = matter20.stringify(content, data);
|
|
22773
23312
|
writeFile(ini.filePath, newContent);
|
|
22774
23313
|
const updated = parseInitiative(dir, ini.filePath, newContent);
|
|
22775
23314
|
if (!updated) throw new InitiativeWriteError("Failed to parse the Initiative after materialization.");
|
|
@@ -23123,8 +23662,8 @@ var capsuleCmd = program.command("capsule").description("Export this project as
|
|
|
23123
23662
|
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) => {
|
|
23124
23663
|
runCapsuleExport(opts);
|
|
23125
23664
|
});
|
|
23126
|
-
capsuleCmd.command("add <path>").description("Register an external Knowledge Capsule as project context (.kaddo/external.yml)").action((
|
|
23127
|
-
runCapsuleAdd(
|
|
23665
|
+
capsuleCmd.command("add <path>").description("Register an external Knowledge Capsule as project context (.kaddo/external.yml)").action((path13) => {
|
|
23666
|
+
runCapsuleAdd(path13);
|
|
23128
23667
|
});
|
|
23129
23668
|
var graphCmd = program.command("graph").description("Export the lightweight, file-based knowledge graph of the project");
|
|
23130
23669
|
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) => {
|
|
@@ -23137,6 +23676,16 @@ topologyCmd.command("validate <file>").description("Validate a topology proposal
|
|
|
23137
23676
|
topologyCmd.command("apply <file>").description("Apply a validated topology proposal to the canonical artifact after human confirmation").option("-y, --yes", "Skip the confirmation prompt (for already-approved automation)").action((file, opts) => {
|
|
23138
23677
|
runTopologyApply(file, opts);
|
|
23139
23678
|
});
|
|
23679
|
+
var resourcesCmd = program.command("resources").description("List and inspect Project Resources \u2014 external systems the project uses (read-only, no secrets)");
|
|
23680
|
+
resourcesCmd.command("list").description("List Project Resources defined under knowledge/tech/resources/").option("--json", "Output JSON").action((opts) => runResourcesList(cwd(), opts));
|
|
23681
|
+
resourcesCmd.command("get <id>").description("Show one Project Resource: purpose, interfaces, boundaries and auth references").option("--json", "Output JSON").action((id, opts) => runResourcesGet(id, cwd(), opts));
|
|
23682
|
+
resourcesCmd.command("create").description("Create a Project Resource (interactive, or with --title/--type). Writes via Core.").option("--title <title>", "Resource name").option("--type <type>", "Resource type (database, cloud, api, queue, storage, repository, platform, service, other)").option("--provider <provider>", "Provider/platform").option("--scope <scope>", "Ownership scope: system | module").option("--module <id>", "Module id (implies module scope)").option("--json", "Output JSON").action(async (opts) => {
|
|
23683
|
+
await runResourcesCreate(opts, cwd());
|
|
23684
|
+
});
|
|
23685
|
+
resourcesCmd.command("update <id>").description("Update a Project Resource (no-lossy). Pass the fields to change.").option("--title <title>", "New title").option("--type <type>", "New resource type").option("--provider <provider>", "New provider").option("--purpose <purpose>", "New purpose").option("--scope <scope>", "Ownership scope: system | module").option("--module <id>", "Module id (implies module scope)").option("--json", "Output JSON").action((id, opts) => runResourcesUpdate(id, opts, cwd()));
|
|
23686
|
+
resourcesCmd.command("delete <id>").description("Delete a Project Resource after showing what references it (requires confirmation)").option("-y, --yes", "Skip the confirmation prompt").option("--json", "Output JSON").action(async (id, opts) => {
|
|
23687
|
+
await runResourcesDelete(id, opts, cwd());
|
|
23688
|
+
});
|
|
23140
23689
|
var integrationsCmd = program.command("integrations").description("Connect Kaddo to external work systems (read-first; import requires human confirmation)");
|
|
23141
23690
|
integrationsCmd.command("list").description("List configured integrations and their capabilities").option("--json", "Output JSON").action((opts) => runIntegrationsList(cwd(), opts));
|
|
23142
23691
|
integrationsCmd.command("status").description("Verify each enabled integration and report its connection status").option("--json", "Output JSON").action(async (opts) => {
|