@kaddo/cli 3.102.0 → 3.103.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/chunk-ZT3DUU53.js +51 -0
- package/dist/core.js +3 -1
- package/dist/index.js +629 -615
- package/dist/ui-PS2ZLJWL.js +21 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
cancel,
|
|
4
|
+
confirm,
|
|
5
|
+
intro,
|
|
6
|
+
log,
|
|
7
|
+
multiselect,
|
|
8
|
+
outro,
|
|
9
|
+
select,
|
|
10
|
+
text
|
|
11
|
+
} from "./chunk-ZT3DUU53.js";
|
|
2
12
|
|
|
3
13
|
// src/index.ts
|
|
4
14
|
import { createRequire } from "module";
|
|
@@ -7,11 +17,11 @@ import { Command } from "commander";
|
|
|
7
17
|
// src/utils/fs.ts
|
|
8
18
|
import fs from "fs";
|
|
9
19
|
import path from "path";
|
|
10
|
-
function exists(
|
|
11
|
-
return fs.existsSync(
|
|
20
|
+
function exists(p) {
|
|
21
|
+
return fs.existsSync(p);
|
|
12
22
|
}
|
|
13
|
-
function readFile(
|
|
14
|
-
return fs.readFileSync(
|
|
23
|
+
function readFile(p) {
|
|
24
|
+
return fs.readFileSync(p, "utf-8");
|
|
15
25
|
}
|
|
16
26
|
function writeFile(filePath, content) {
|
|
17
27
|
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
@@ -24,11 +34,11 @@ function readDir(dirPath) {
|
|
|
24
34
|
if (!exists(dirPath)) return [];
|
|
25
35
|
return fs.readdirSync(dirPath);
|
|
26
36
|
}
|
|
27
|
-
function isFile(
|
|
28
|
-
return exists(
|
|
37
|
+
function isFile(p) {
|
|
38
|
+
return exists(p) && fs.statSync(p).isFile();
|
|
29
39
|
}
|
|
30
|
-
function isDir(
|
|
31
|
-
return exists(
|
|
40
|
+
function isDir(p) {
|
|
41
|
+
return exists(p) && fs.statSync(p).isDirectory();
|
|
32
42
|
}
|
|
33
43
|
function cwd() {
|
|
34
44
|
return process.cwd();
|
|
@@ -39,47 +49,6 @@ function join(...parts) {
|
|
|
39
49
|
|
|
40
50
|
// src/commands/init.ts
|
|
41
51
|
import path2 from "path";
|
|
42
|
-
|
|
43
|
-
// src/utils/ui.ts
|
|
44
|
-
import * as p from "@clack/prompts";
|
|
45
|
-
var intro2 = (title) => p.intro(title);
|
|
46
|
-
var outro2 = (msg) => p.outro(msg);
|
|
47
|
-
var log2 = p.log;
|
|
48
|
-
var cancel2 = (msg) => p.cancel(msg);
|
|
49
|
-
async function text2(opts) {
|
|
50
|
-
const val = await p.text(opts);
|
|
51
|
-
if (p.isCancel(val)) {
|
|
52
|
-
p.cancel("Operation cancelled.");
|
|
53
|
-
process.exit(0);
|
|
54
|
-
}
|
|
55
|
-
return val;
|
|
56
|
-
}
|
|
57
|
-
async function confirm2(opts) {
|
|
58
|
-
const val = await p.confirm(opts);
|
|
59
|
-
if (p.isCancel(val)) {
|
|
60
|
-
p.cancel("Operation cancelled.");
|
|
61
|
-
process.exit(0);
|
|
62
|
-
}
|
|
63
|
-
return val;
|
|
64
|
-
}
|
|
65
|
-
async function select2(opts) {
|
|
66
|
-
const val = await p.select(opts);
|
|
67
|
-
if (p.isCancel(val)) {
|
|
68
|
-
p.cancel("Operation cancelled.");
|
|
69
|
-
process.exit(0);
|
|
70
|
-
}
|
|
71
|
-
return val;
|
|
72
|
-
}
|
|
73
|
-
async function multiselect2(opts) {
|
|
74
|
-
const val = await p.multiselect(opts);
|
|
75
|
-
if (p.isCancel(val)) {
|
|
76
|
-
p.cancel("Operation cancelled.");
|
|
77
|
-
process.exit(0);
|
|
78
|
-
}
|
|
79
|
-
return val;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// src/commands/init.ts
|
|
83
52
|
var KADDO_DIR = ".kaddo";
|
|
84
53
|
var ARCH_DIR = "knowledge";
|
|
85
54
|
function inferProjectName(dir) {
|
|
@@ -293,28 +262,28 @@ _Ideas and intentions not yet committed._
|
|
|
293
262
|
}
|
|
294
263
|
async function runInit() {
|
|
295
264
|
const dir = cwd();
|
|
296
|
-
|
|
265
|
+
intro("kaddo init");
|
|
297
266
|
if (!hasGit(dir)) {
|
|
298
|
-
|
|
267
|
+
log.warn("No Git repository detected. Kaddo works best inside a Git repo.");
|
|
299
268
|
}
|
|
300
269
|
const kaddoExists = exists(join(dir, KADDO_DIR, "config.yml"));
|
|
301
270
|
if (kaddoExists) {
|
|
302
|
-
const overwrite = await
|
|
271
|
+
const overwrite = await confirm({
|
|
303
272
|
message: "Kaddo is already initialized. Overwrite configuration?",
|
|
304
273
|
initialValue: false
|
|
305
274
|
});
|
|
306
275
|
if (!overwrite) {
|
|
307
|
-
|
|
276
|
+
outro("Nothing changed.");
|
|
308
277
|
return;
|
|
309
278
|
}
|
|
310
279
|
}
|
|
311
280
|
const inferredName = inferProjectName(dir);
|
|
312
|
-
const projectName = await
|
|
281
|
+
const projectName = await text({
|
|
313
282
|
message: "Project name",
|
|
314
283
|
initialValue: inferredName,
|
|
315
284
|
validate: (v) => v.trim().length === 0 ? "Project name is required." : void 0
|
|
316
285
|
});
|
|
317
|
-
const structure = await
|
|
286
|
+
const structure = await select({
|
|
318
287
|
message: "Repository structure",
|
|
319
288
|
options: [
|
|
320
289
|
{ value: "monorepo", label: "Monorepo" },
|
|
@@ -327,7 +296,7 @@ async function runInit() {
|
|
|
327
296
|
let parentSystem;
|
|
328
297
|
let modId;
|
|
329
298
|
if (structure === "multirepo") {
|
|
330
|
-
role = await
|
|
299
|
+
role = await select({
|
|
331
300
|
message: "What is the role of this repository?",
|
|
332
301
|
options: [
|
|
333
302
|
{ value: "core", label: "Core / system orchestrator" },
|
|
@@ -335,26 +304,26 @@ async function runInit() {
|
|
|
335
304
|
]
|
|
336
305
|
});
|
|
337
306
|
if (role === "core") {
|
|
338
|
-
systemName3 = await
|
|
307
|
+
systemName3 = await text({
|
|
339
308
|
message: "System name",
|
|
340
309
|
placeholder: "e.g. tryckers",
|
|
341
310
|
validate: (v) => v.trim().length === 0 ? "System name is required." : void 0
|
|
342
311
|
});
|
|
343
312
|
}
|
|
344
313
|
if (role === "module") {
|
|
345
|
-
parentSystem = await
|
|
314
|
+
parentSystem = await text({
|
|
346
315
|
message: "Parent system name",
|
|
347
316
|
placeholder: "e.g. tryckers",
|
|
348
317
|
validate: (v) => v.trim().length === 0 ? "Parent system name is required." : void 0
|
|
349
318
|
});
|
|
350
|
-
modId = await
|
|
319
|
+
modId = await text({
|
|
351
320
|
message: "Module ID",
|
|
352
321
|
placeholder: "e.g. frontend",
|
|
353
322
|
validate: (v) => v.trim().length === 0 ? "Module ID is required." : void 0
|
|
354
323
|
});
|
|
355
324
|
}
|
|
356
325
|
}
|
|
357
|
-
const state = await
|
|
326
|
+
const state = await select({
|
|
358
327
|
message: "What kind of project is this?",
|
|
359
328
|
options: [
|
|
360
329
|
{ value: "new", label: "New", hint: "Starting from scratch" },
|
|
@@ -363,7 +332,7 @@ async function runInit() {
|
|
|
363
332
|
],
|
|
364
333
|
initialValue: "pre-ai"
|
|
365
334
|
});
|
|
366
|
-
const language = await
|
|
335
|
+
const language = await select({
|
|
367
336
|
message: "Project knowledge language (the CLI stays in English)",
|
|
368
337
|
options: [
|
|
369
338
|
{ value: "en", label: "English" },
|
|
@@ -371,7 +340,7 @@ async function runInit() {
|
|
|
371
340
|
],
|
|
372
341
|
initialValue: "en"
|
|
373
342
|
});
|
|
374
|
-
const teamSize = await
|
|
343
|
+
const teamSize = await select({
|
|
375
344
|
message: "Team size",
|
|
376
345
|
options: [
|
|
377
346
|
{ value: "indie", label: "Indie", hint: "1 person" },
|
|
@@ -394,7 +363,7 @@ async function runInit() {
|
|
|
394
363
|
};
|
|
395
364
|
const kaddoConfigPath = join(dir, KADDO_DIR, "config.yml");
|
|
396
365
|
writeFile(kaddoConfigPath, buildConfig(meta));
|
|
397
|
-
|
|
366
|
+
log.success("Created .kaddo/config.yml");
|
|
398
367
|
if (role === "module") {
|
|
399
368
|
ensureDir(join(dir, ARCH_DIR, "tech", "module"));
|
|
400
369
|
writeFile(
|
|
@@ -407,10 +376,10 @@ async function runInit() {
|
|
|
407
376
|
if (!exists(join(dir, ARCH_DIR, "tech", "codebase.md"))) {
|
|
408
377
|
writeFile(join(dir, ARCH_DIR, "tech", "codebase.md"), buildKnowledge(projectName.trim()));
|
|
409
378
|
}
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
379
|
+
log.success("Created knowledge/tech/module/module-context.md");
|
|
380
|
+
log.success("Created knowledge/tech/current-state.md");
|
|
381
|
+
log.success("Created knowledge/tech/codebase.md");
|
|
382
|
+
log.info("Next: run `kaddo scan` to detect your stack, then use module-context-agent to refine module-context.md.");
|
|
414
383
|
} else if (role === "core") {
|
|
415
384
|
const sysName = systemName3?.trim() ?? projectName.trim();
|
|
416
385
|
ensureDir(join(dir, ARCH_DIR, "delivery", "work-items"));
|
|
@@ -423,22 +392,22 @@ async function runInit() {
|
|
|
423
392
|
writeFile(join(dir, ARCH_DIR, "tech", "system", "system-context.md"), buildSystemContext(sysName));
|
|
424
393
|
writeFile(join(dir, ARCH_DIR, "tech", "modules", "modules.md"), buildModulesFile(sysName));
|
|
425
394
|
writeFile(join(dir, KADDO_DIR, "modules.yml"), buildModulesYml(sysName));
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
395
|
+
log.success("Created knowledge/knowledge.md");
|
|
396
|
+
log.success("Created knowledge/delivery/roadmap.md");
|
|
397
|
+
log.success("Created knowledge/tech/system/system-context.md");
|
|
398
|
+
log.success("Created knowledge/tech/modules/modules.md");
|
|
399
|
+
log.success("Created .kaddo/modules.yml");
|
|
400
|
+
log.info("Next: run `kaddo scan` then `kaddo modules discover` to find sibling modules.");
|
|
432
401
|
} else {
|
|
433
402
|
ensureDir(join(dir, ARCH_DIR, "delivery", "work-items"));
|
|
434
403
|
writeFile(join(dir, ARCH_DIR, "knowledge.md"), buildKnowledge(projectName.trim()));
|
|
435
404
|
writeFile(join(dir, ARCH_DIR, "delivery", "roadmap.md"), buildRoadmap(projectName.trim()));
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
405
|
+
log.success("Created knowledge/knowledge.md");
|
|
406
|
+
log.success("Created knowledge/delivery/roadmap.md");
|
|
407
|
+
log.success("Created knowledge/delivery/work-items/");
|
|
408
|
+
log.info("Next: run `kaddo scan` to detect your stack.");
|
|
440
409
|
}
|
|
441
|
-
|
|
410
|
+
outro("Kaddo initialized.");
|
|
442
411
|
}
|
|
443
412
|
|
|
444
413
|
// src/core/scan-signals.ts
|
|
@@ -839,10 +808,10 @@ function detectEnvironment(dir) {
|
|
|
839
808
|
const envFiles = [".env.example", ".env.local.example", ".env.template", ".env.sample"];
|
|
840
809
|
const varNames = /* @__PURE__ */ new Set();
|
|
841
810
|
for (const ef of envFiles) {
|
|
842
|
-
const
|
|
843
|
-
if (!exists(
|
|
811
|
+
const p = join(dir, ef);
|
|
812
|
+
if (!exists(p)) continue;
|
|
844
813
|
try {
|
|
845
|
-
const lines = readFile(
|
|
814
|
+
const lines = readFile(p).split(/\r?\n/);
|
|
846
815
|
for (const line of lines) {
|
|
847
816
|
const m = line.match(/^([A-Z][A-Z0-9_]+)\s*=/);
|
|
848
817
|
if (m) varNames.add(m[1]);
|
|
@@ -1345,7 +1314,9 @@ var configSchema = z.object({
|
|
|
1345
1314
|
guard: z.unknown().optional(),
|
|
1346
1315
|
scan: z.unknown().optional(),
|
|
1347
1316
|
telemetry: z.object({
|
|
1348
|
-
|
|
1317
|
+
consent: z.enum(["enabled", "disabled"]).optional(),
|
|
1318
|
+
consentVersion: z.number().optional(),
|
|
1319
|
+
enabled: z.boolean().optional()
|
|
1349
1320
|
}).passthrough().optional()
|
|
1350
1321
|
}).passthrough();
|
|
1351
1322
|
function configPathFor(dir) {
|
|
@@ -1594,21 +1565,21 @@ async function writeBaselineArtifacts(dir, result) {
|
|
|
1594
1565
|
const baseline = buildBaseline(result, context);
|
|
1595
1566
|
const scanJsonPath = join(dir, ".kaddo", "scan.json");
|
|
1596
1567
|
writeFile(scanJsonPath, serializeBaseline(baseline));
|
|
1597
|
-
|
|
1568
|
+
log.success("Wrote .kaddo/scan.json");
|
|
1598
1569
|
const inventoryPath = join(dir, "knowledge", "inventory.md");
|
|
1599
1570
|
const inventoryExists = exists(inventoryPath);
|
|
1600
1571
|
let writeInventory = true;
|
|
1601
1572
|
if (inventoryExists) {
|
|
1602
|
-
writeInventory = await
|
|
1573
|
+
writeInventory = await confirm({
|
|
1603
1574
|
message: "knowledge/inventory.md already exists. Overwrite it?",
|
|
1604
1575
|
initialValue: true
|
|
1605
1576
|
});
|
|
1606
1577
|
}
|
|
1607
1578
|
if (writeInventory) {
|
|
1608
1579
|
writeFile(inventoryPath, renderInventory(baseline));
|
|
1609
|
-
|
|
1580
|
+
log.success(`${inventoryExists ? "Updated" : "Wrote"} knowledge/inventory.md`);
|
|
1610
1581
|
} else {
|
|
1611
|
-
|
|
1582
|
+
log.info("Kept existing knowledge/inventory.md.");
|
|
1612
1583
|
}
|
|
1613
1584
|
}
|
|
1614
1585
|
function printStateAwareNextStep(dir) {
|
|
@@ -1617,37 +1588,37 @@ function printStateAwareNextStep(dir) {
|
|
|
1617
1588
|
config = loadConfig(dir);
|
|
1618
1589
|
} catch (err) {
|
|
1619
1590
|
if (err instanceof ConfigError) {
|
|
1620
|
-
|
|
1591
|
+
log.warn(err.message);
|
|
1621
1592
|
return;
|
|
1622
1593
|
}
|
|
1623
1594
|
throw err;
|
|
1624
1595
|
}
|
|
1625
1596
|
if (!config) return;
|
|
1626
|
-
|
|
1627
|
-
|
|
1597
|
+
log.info(`This is a ${describeProject(config)}.`);
|
|
1598
|
+
log.info(`Next: ${nextStepsForState(config.project.state)}`);
|
|
1628
1599
|
}
|
|
1629
1600
|
async function runScan() {
|
|
1630
1601
|
const dir = cwd();
|
|
1631
|
-
|
|
1602
|
+
intro("kaddo scan");
|
|
1632
1603
|
const result = scan(dir);
|
|
1633
1604
|
printResult(result);
|
|
1634
1605
|
await writeBaselineArtifacts(dir, result);
|
|
1635
1606
|
const kaddoExists = exists(join(dir, ".kaddo", "config.yml"));
|
|
1636
1607
|
if (kaddoExists) {
|
|
1637
|
-
const save = await
|
|
1608
|
+
const save = await confirm({
|
|
1638
1609
|
message: "Save scan results to .kaddo/config.yml?",
|
|
1639
1610
|
initialValue: true
|
|
1640
1611
|
});
|
|
1641
1612
|
if (save) {
|
|
1642
1613
|
updateConfig(dir, result);
|
|
1643
|
-
|
|
1614
|
+
log.success("Scan results saved to .kaddo/config.yml");
|
|
1644
1615
|
}
|
|
1645
1616
|
} else {
|
|
1646
|
-
|
|
1617
|
+
log.warn("No .kaddo/config.yml found. Run `kaddo init` first to record project context.");
|
|
1647
1618
|
}
|
|
1648
1619
|
printStateAwareNextStep(dir);
|
|
1649
1620
|
printCommandFooter("scan");
|
|
1650
|
-
|
|
1621
|
+
outro("Scan complete.");
|
|
1651
1622
|
}
|
|
1652
1623
|
|
|
1653
1624
|
// src/core/knowledge-levels.ts
|
|
@@ -5390,7 +5361,7 @@ var AGENT_PROMPTS = [
|
|
|
5390
5361
|
// Graph relationship quality (metadata hints → precise front matter — VS-056)
|
|
5391
5362
|
{ fileName: "graph-agent.md", content: GRAPH_AGENT }
|
|
5392
5363
|
// Every official prompt ends with its responsibility boundaries + Agent Trace footer.
|
|
5393
|
-
].map((
|
|
5364
|
+
].map((p) => ({ fileName: p.fileName, content: withResponsibilityTrace(p.fileName, p.content) }));
|
|
5394
5365
|
|
|
5395
5366
|
// src/agents/groups.ts
|
|
5396
5367
|
var AGENT_GROUPS = {
|
|
@@ -6024,10 +5995,10 @@ function splitRow(line) {
|
|
|
6024
5995
|
function isSeparatorRow(cells) {
|
|
6025
5996
|
return cells.length > 0 && cells.every((c) => SEPARATOR_CELL_RE.test(c) || c === "");
|
|
6026
5997
|
}
|
|
6027
|
-
function initiativeFromHeading(
|
|
6028
|
-
const rm =
|
|
5998
|
+
function initiativeFromHeading(text2) {
|
|
5999
|
+
const rm = text2.match(/^(RM-[\w.-]+)\s*[:\-–]?\s*(.*)$/);
|
|
6029
6000
|
if (rm) return { id: rm[1], title: rm[2].trim() || void 0 };
|
|
6030
|
-
return { title:
|
|
6001
|
+
return { title: text2.trim() || void 0 };
|
|
6031
6002
|
}
|
|
6032
6003
|
function extractDeps(cell) {
|
|
6033
6004
|
if (!cell) return void 0;
|
|
@@ -6149,16 +6120,16 @@ var ROADMAP_PATH = "knowledge/delivery/roadmap.md";
|
|
|
6149
6120
|
function ensureWorkItemsDir(dir) {
|
|
6150
6121
|
if (exists(join(dir, WORK_ITEMS_DIR))) return;
|
|
6151
6122
|
if (!exists(join(dir, ".kaddo", "config.yml"))) {
|
|
6152
|
-
|
|
6123
|
+
log.warn("Kaddo is not initialized. Run `kaddo init` first.");
|
|
6153
6124
|
process.exit(1);
|
|
6154
6125
|
}
|
|
6155
6126
|
ensureDir(join(dir, WORK_ITEMS_DIR));
|
|
6156
|
-
|
|
6127
|
+
log.info(`Created ${WORK_ITEMS_DIR}/`);
|
|
6157
6128
|
}
|
|
6158
6129
|
async function collectAcceptanceCriteria() {
|
|
6159
6130
|
const criteria = [];
|
|
6160
6131
|
while (true) {
|
|
6161
|
-
const criterion = await
|
|
6132
|
+
const criterion = await text({
|
|
6162
6133
|
message: criteria.length === 0 ? "Acceptance criterion" : "Acceptance criterion",
|
|
6163
6134
|
placeholder: "e.g. Users see confirmation after checkout",
|
|
6164
6135
|
validate: (v) => criteria.length === 0 && v.trim().length === 0 ? "At least one criterion is required." : void 0
|
|
@@ -6170,7 +6141,7 @@ async function collectAcceptanceCriteria() {
|
|
|
6170
6141
|
} else {
|
|
6171
6142
|
criteria.push(trimmed);
|
|
6172
6143
|
}
|
|
6173
|
-
const addMore = await
|
|
6144
|
+
const addMore = await confirm({ message: "Add another acceptance criterion?" });
|
|
6174
6145
|
if (!addMore) break;
|
|
6175
6146
|
}
|
|
6176
6147
|
return criteria.join("\n");
|
|
@@ -6188,13 +6159,13 @@ function printStateGuidance(dir) {
|
|
|
6188
6159
|
config = loadConfig(dir);
|
|
6189
6160
|
} catch (err) {
|
|
6190
6161
|
if (err instanceof ConfigError) {
|
|
6191
|
-
|
|
6162
|
+
log.warn(err.message);
|
|
6192
6163
|
return;
|
|
6193
6164
|
}
|
|
6194
6165
|
throw err;
|
|
6195
6166
|
}
|
|
6196
6167
|
if (!config) return;
|
|
6197
|
-
|
|
6168
|
+
log.info(createGuidanceForState(config.project.state));
|
|
6198
6169
|
}
|
|
6199
6170
|
function nextWorkItemId(dir) {
|
|
6200
6171
|
const wiDir = join(dir, WORK_ITEMS_DIR);
|
|
@@ -6393,11 +6364,11 @@ async function runCreate(type, opts = {}) {
|
|
|
6393
6364
|
}
|
|
6394
6365
|
const level = getLevelForType(workItemType);
|
|
6395
6366
|
const levelDef = getLevel(level);
|
|
6396
|
-
|
|
6397
|
-
|
|
6367
|
+
intro(`kaddo create ${workItemType}`);
|
|
6368
|
+
log.info(`Knowledge level: ${level} \u2014 ${levelDef.description}`);
|
|
6398
6369
|
printStateGuidance(dir);
|
|
6399
6370
|
ensureWorkItemsDir(dir);
|
|
6400
|
-
const title = await
|
|
6371
|
+
const title = await text({
|
|
6401
6372
|
message: "Title for this work item",
|
|
6402
6373
|
placeholder: `e.g. ${workItemType === "feature" ? "Add email verification to checkout" : workItemType === "hotfix" ? "Fix null pointer in payment handler" : workItemType === "bugfix" ? "Fix broken pagination on orders list" : workItemType === "chore" ? "Configure Vitest and CI pipeline" : "Explore caching strategies for API responses"}`,
|
|
6403
6374
|
validate: (v) => v.trim().length === 0 ? "Title is required." : void 0
|
|
@@ -6408,7 +6379,7 @@ async function runCreate(type, opts = {}) {
|
|
|
6408
6379
|
answers.acceptance_criteria = await collectAcceptanceCriteria();
|
|
6409
6380
|
continue;
|
|
6410
6381
|
}
|
|
6411
|
-
const answer = await
|
|
6382
|
+
const answer = await text({
|
|
6412
6383
|
message: question.prompt,
|
|
6413
6384
|
placeholder: question.placeholder,
|
|
6414
6385
|
validate: question.required ? (v) => v.trim().length === 0 ? "This field is required." : void 0 : void 0
|
|
@@ -6425,24 +6396,24 @@ async function runCreate(type, opts = {}) {
|
|
|
6425
6396
|
|
|
6426
6397
|
${body}`;
|
|
6427
6398
|
writeFile(filePath, content);
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
|
|
6399
|
+
log.success(`Created ${DRAFT_DIR}/${fileName}`);
|
|
6400
|
+
log.info(`New Work Items start in \`draft\`. Move to \`ready\` when scope and acceptance are set.`);
|
|
6401
|
+
log.info(`Add code globs to the front matter \`code:\` field to enable Guard Lite.`);
|
|
6402
|
+
outro(`Work item ${id} created.`);
|
|
6432
6403
|
}
|
|
6433
6404
|
async function runCreateModule(dir, modType) {
|
|
6434
|
-
|
|
6435
|
-
|
|
6405
|
+
intro(`kaddo create ${modType.name}`);
|
|
6406
|
+
log.info(`Knowledge level: ${modType.knowledgeLevel} \u2014 ${modType.description}`);
|
|
6436
6407
|
printStateGuidance(dir);
|
|
6437
6408
|
ensureWorkItemsDir(dir);
|
|
6438
|
-
const title = await
|
|
6409
|
+
const title = await text({
|
|
6439
6410
|
message: "Title for this work item",
|
|
6440
6411
|
placeholder: `e.g. ${modType.questions[0]?.placeholder ?? modType.description}`,
|
|
6441
6412
|
validate: (v) => v.trim().length === 0 ? "Title is required." : void 0
|
|
6442
6413
|
});
|
|
6443
6414
|
const answers = {};
|
|
6444
6415
|
for (const q of modType.questions) {
|
|
6445
|
-
const answer = await
|
|
6416
|
+
const answer = await text({
|
|
6446
6417
|
message: q.prompt,
|
|
6447
6418
|
placeholder: q.placeholder,
|
|
6448
6419
|
validate: q.required ? (v) => v.trim().length === 0 ? "This field is required." : void 0 : void 0
|
|
@@ -6459,9 +6430,9 @@ async function runCreateModule(dir, modType) {
|
|
|
6459
6430
|
|
|
6460
6431
|
${body}`;
|
|
6461
6432
|
writeFile(filePath, content);
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6433
|
+
log.success(`Created ${DRAFT_DIR}/${fileName}`);
|
|
6434
|
+
log.info(`Add code globs to the front matter \`code:\` field to enable Guard Lite.`);
|
|
6435
|
+
outro(`Work item ${id} created.`);
|
|
6465
6436
|
}
|
|
6466
6437
|
var K_LEVEL_RE = /^K[0-4]$/;
|
|
6467
6438
|
function resolveCandidateType(candidate, cliType) {
|
|
@@ -6626,7 +6597,7 @@ function buildRoadmapWorkItem(opts) {
|
|
|
6626
6597
|
${body}` };
|
|
6627
6598
|
}
|
|
6628
6599
|
async function runCreateFromRoadmap(dir, cliType) {
|
|
6629
|
-
|
|
6600
|
+
intro("kaddo create --from roadmap");
|
|
6630
6601
|
ensureWorkItemsDir(dir);
|
|
6631
6602
|
const roadmapFull = join(dir, ROADMAP_PATH);
|
|
6632
6603
|
if (!exists(roadmapFull)) {
|
|
@@ -6640,7 +6611,7 @@ async function runCreateFromRoadmap(dir, cliType) {
|
|
|
6640
6611
|
console.error("Make sure your roadmap uses the Kaddo Roadmap Agent format.");
|
|
6641
6612
|
process.exit(1);
|
|
6642
6613
|
}
|
|
6643
|
-
const candidateId = candidates.length === 1 ? candidates[0].id : await
|
|
6614
|
+
const candidateId = candidates.length === 1 ? candidates[0].id : await select({
|
|
6644
6615
|
message: "Which roadmap candidate do you want to create?",
|
|
6645
6616
|
options: candidates.map((c) => ({
|
|
6646
6617
|
value: c.id,
|
|
@@ -6651,7 +6622,7 @@ async function runCreateFromRoadmap(dir, cliType) {
|
|
|
6651
6622
|
const candidate = candidates.find((c) => c.id === candidateId);
|
|
6652
6623
|
let type = resolveCandidateType(candidate, cliType);
|
|
6653
6624
|
if (!type) {
|
|
6654
|
-
type = await
|
|
6625
|
+
type = await select({
|
|
6655
6626
|
message: candidate.type ? `Roadmap suggests type "${candidate.type}" (not a Kaddo type). Choose a Work Item type:` : "No type in roadmap candidate. Choose a Work Item type:",
|
|
6656
6627
|
options: [
|
|
6657
6628
|
{ value: "feature", label: "feature" },
|
|
@@ -6664,14 +6635,14 @@ async function runCreateFromRoadmap(dir, cliType) {
|
|
|
6664
6635
|
}
|
|
6665
6636
|
const level = resolveCandidateLevel(candidate, type);
|
|
6666
6637
|
const levelDef = getLevel(level);
|
|
6667
|
-
|
|
6638
|
+
log.info(`Knowledge level: ${level} \u2014 ${levelDef.description}`);
|
|
6668
6639
|
const answers = {};
|
|
6669
6640
|
if (candidate.expectedValue) answers.expected_result = candidate.expectedValue;
|
|
6670
6641
|
if (candidate.impact) answers.impact = candidate.impact;
|
|
6671
6642
|
if (candidate.risk) answers.risks = candidate.risk;
|
|
6672
6643
|
for (const question of levelDef.questions) {
|
|
6673
6644
|
if (answers[question.frontMatterField]?.trim()) continue;
|
|
6674
|
-
const answer = await
|
|
6645
|
+
const answer = await text({
|
|
6675
6646
|
message: question.prompt,
|
|
6676
6647
|
placeholder: question.placeholder,
|
|
6677
6648
|
validate: question.required ? (v) => v.trim().length === 0 ? "This field is required." : void 0 : void 0
|
|
@@ -6681,10 +6652,10 @@ async function runCreateFromRoadmap(dir, cliType) {
|
|
|
6681
6652
|
const id = nextWorkItemId(dir);
|
|
6682
6653
|
const { fileName, content } = buildRoadmapWorkItem({ id, type, level, candidate, answers });
|
|
6683
6654
|
writeFile(join(dir, DRAFT_DIR, fileName), content);
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6655
|
+
log.success(`Created ${DRAFT_DIR}/${fileName}`);
|
|
6656
|
+
log.info(`Traced to roadmap candidate ${candidate.id}${candidate.initiative?.id ? ` (initiative ${candidate.initiative.id})` : ""}.`);
|
|
6657
|
+
log.info(`Add code globs to the front matter \`code:\` field to enable Guard Lite.`);
|
|
6658
|
+
outro(`Work item ${id} created from roadmap.`);
|
|
6688
6659
|
}
|
|
6689
6660
|
|
|
6690
6661
|
// src/services/git.ts
|
|
@@ -6879,8 +6850,8 @@ function isActiveState(s) {
|
|
|
6879
6850
|
return ACTIVE_STATES.includes(s);
|
|
6880
6851
|
}
|
|
6881
6852
|
function lifecycleFolderOf(filePath) {
|
|
6882
|
-
const
|
|
6883
|
-
const m =
|
|
6853
|
+
const p = filePath.replace(/\\/g, "/");
|
|
6854
|
+
const m = p.match(/\/delivery\/work-items\/([^/]+)\//);
|
|
6884
6855
|
if (m && isLifecycleState(m[1])) return m[1];
|
|
6885
6856
|
return null;
|
|
6886
6857
|
}
|
|
@@ -6903,8 +6874,8 @@ function lifecycleCounts(states) {
|
|
|
6903
6874
|
|
|
6904
6875
|
// src/services/knowledge-artifacts.ts
|
|
6905
6876
|
var ARCH_DIR2 = "knowledge";
|
|
6906
|
-
function toPosix(
|
|
6907
|
-
return
|
|
6877
|
+
function toPosix(p) {
|
|
6878
|
+
return p.replace(/\\/g, "/");
|
|
6908
6879
|
}
|
|
6909
6880
|
function relativeTo(dir, filePath) {
|
|
6910
6881
|
const base = toPosix(dir).replace(/\/+$/, "");
|
|
@@ -6946,8 +6917,8 @@ function discoverWorkItems(dir) {
|
|
|
6946
6917
|
// src/core/diff-analysis.ts
|
|
6947
6918
|
import { minimatch } from "minimatch";
|
|
6948
6919
|
import path3 from "path";
|
|
6949
|
-
function toPosix2(
|
|
6950
|
-
return
|
|
6920
|
+
function toPosix2(p) {
|
|
6921
|
+
return p.replace(/\\/g, "/");
|
|
6951
6922
|
}
|
|
6952
6923
|
function normalizeTouchedPathForProject(touchedPath, gitRoot, projectRoot) {
|
|
6953
6924
|
const t = toPosix2(touchedPath).replace(/^\.\//, "").replace(/^\/+/, "");
|
|
@@ -6959,8 +6930,8 @@ function normalizeTouchedPathForProject(touchedPath, gitRoot, projectRoot) {
|
|
|
6959
6930
|
if (t.startsWith(prefix + "/")) return t.slice(prefix.length + 1);
|
|
6960
6931
|
return null;
|
|
6961
6932
|
}
|
|
6962
|
-
function normalizePath(
|
|
6963
|
-
return
|
|
6933
|
+
function normalizePath(p) {
|
|
6934
|
+
return p.replace(/\\/g, "/");
|
|
6964
6935
|
}
|
|
6965
6936
|
function fileMatchesGlob(file, glob) {
|
|
6966
6937
|
return minimatch(normalizePath(file), glob, { matchBase: false, dot: true });
|
|
@@ -7144,10 +7115,10 @@ function detectModuleStatus(coreDir, repoPath) {
|
|
|
7144
7115
|
function readModuleContext(coreDir, repoPath) {
|
|
7145
7116
|
const newPath = join(coreDir, repoPath, "knowledge", "tech", "module", "module-context.md");
|
|
7146
7117
|
const legacyPath = join(coreDir, repoPath, "knowledge", "module", "module-context.md");
|
|
7147
|
-
const
|
|
7148
|
-
if (!exists(
|
|
7118
|
+
const p = exists(newPath) ? newPath : legacyPath;
|
|
7119
|
+
if (!exists(p)) return null;
|
|
7149
7120
|
try {
|
|
7150
|
-
return readFile(
|
|
7121
|
+
return readFile(p);
|
|
7151
7122
|
} catch {
|
|
7152
7123
|
return null;
|
|
7153
7124
|
}
|
|
@@ -7233,11 +7204,11 @@ function analyzeMetadataHealth(dir) {
|
|
|
7233
7204
|
let healthy = 0;
|
|
7234
7205
|
let drifted = 0;
|
|
7235
7206
|
for (const rel of KNOWLEDGE_FILES) {
|
|
7236
|
-
const
|
|
7237
|
-
if (!exists(
|
|
7207
|
+
const p = join(dir, rel);
|
|
7208
|
+
if (!exists(p)) continue;
|
|
7238
7209
|
let data;
|
|
7239
7210
|
try {
|
|
7240
|
-
const raw = readFile(
|
|
7211
|
+
const raw = readFile(p);
|
|
7241
7212
|
data = matter2(raw).data;
|
|
7242
7213
|
} catch {
|
|
7243
7214
|
continue;
|
|
@@ -7266,13 +7237,13 @@ function analyzeMetadataHealth(dir) {
|
|
|
7266
7237
|
if (exists(wiDir)) {
|
|
7267
7238
|
const walkWIs = (d) => {
|
|
7268
7239
|
for (const entry of readDir(d)) {
|
|
7269
|
-
const
|
|
7270
|
-
if (isFile(
|
|
7240
|
+
const p = join(d, entry);
|
|
7241
|
+
if (isFile(p) && entry.endsWith(".md")) {
|
|
7271
7242
|
try {
|
|
7272
|
-
const raw = readFile(
|
|
7243
|
+
const raw = readFile(p);
|
|
7273
7244
|
const fm2 = matter2(raw).data;
|
|
7274
7245
|
if (fm2.status === "done") {
|
|
7275
|
-
const rel =
|
|
7246
|
+
const rel = p.replace(dir + "/", "").replace(dir + "\\", "").replace(/\\/g, "/");
|
|
7276
7247
|
findings.push({
|
|
7277
7248
|
file: rel,
|
|
7278
7249
|
field: "status",
|
|
@@ -7282,8 +7253,8 @@ function analyzeMetadataHealth(dir) {
|
|
|
7282
7253
|
}
|
|
7283
7254
|
} catch {
|
|
7284
7255
|
}
|
|
7285
|
-
} else if (!isFile(
|
|
7286
|
-
walkWIs(
|
|
7256
|
+
} else if (!isFile(p) && !entry.startsWith(".")) {
|
|
7257
|
+
walkWIs(p);
|
|
7287
7258
|
}
|
|
7288
7259
|
}
|
|
7289
7260
|
};
|
|
@@ -7660,7 +7631,7 @@ var AVAILABLE_PLUGINS = {
|
|
|
7660
7631
|
openapi: openapiPlugin
|
|
7661
7632
|
};
|
|
7662
7633
|
function resolvePlugins(enabledNames) {
|
|
7663
|
-
return enabledNames.map((name) => AVAILABLE_PLUGINS[name]).filter((
|
|
7634
|
+
return enabledNames.map((name) => AVAILABLE_PLUGINS[name]).filter((p) => p !== void 0);
|
|
7664
7635
|
}
|
|
7665
7636
|
function runPlugins(plugins, touchedFiles, readFile2) {
|
|
7666
7637
|
const signals = [];
|
|
@@ -7716,14 +7687,14 @@ import fs2 from "fs";
|
|
|
7716
7687
|
var HISTORY_DIR = ".kaddo/history";
|
|
7717
7688
|
var RUNS_PATH = `${HISTORY_DIR}/guard-runs.jsonl`;
|
|
7718
7689
|
var SUMMARY_PATH = `${HISTORY_DIR}/guard-summary.json`;
|
|
7719
|
-
function toPosix3(
|
|
7720
|
-
return
|
|
7690
|
+
function toPosix3(p) {
|
|
7691
|
+
return p.replace(/\\/g, "/");
|
|
7721
7692
|
}
|
|
7722
7693
|
function loadGuardRuns(dir) {
|
|
7723
|
-
const
|
|
7724
|
-
if (!exists(
|
|
7694
|
+
const p = join(dir, RUNS_PATH);
|
|
7695
|
+
if (!exists(p)) return [];
|
|
7725
7696
|
const out = [];
|
|
7726
|
-
for (const line of readFile(
|
|
7697
|
+
for (const line of readFile(p).split(/\r?\n/)) {
|
|
7727
7698
|
const t = line.trim();
|
|
7728
7699
|
if (!t) continue;
|
|
7729
7700
|
try {
|
|
@@ -7884,10 +7855,10 @@ function parseRisks(content) {
|
|
|
7884
7855
|
const area = areaMatch?.[1]?.trim() ?? "";
|
|
7885
7856
|
const blastRadius = blastMatch?.[1]?.trim() ?? "unknown";
|
|
7886
7857
|
const confidence = confMatch?.[1]?.trim() ?? "unknown";
|
|
7887
|
-
const areaPatterns = area.split(/[,;]/).map((
|
|
7888
|
-
if (
|
|
7889
|
-
if (
|
|
7890
|
-
return [`**/${
|
|
7858
|
+
const areaPatterns = area.split(/[,;]/).map((p) => p.trim()).filter((p) => p.length > 0).flatMap((p) => {
|
|
7859
|
+
if (p.includes("*")) return [p];
|
|
7860
|
+
if (p.includes("/")) return [`${p}/**`, `${p}*`];
|
|
7861
|
+
return [`**/${p}/**`, `**/${p}*`, `**/*${p}*`];
|
|
7891
7862
|
});
|
|
7892
7863
|
risks.push({ id, title, area, blastRadius, confidence, areaPatterns });
|
|
7893
7864
|
}
|
|
@@ -7986,12 +7957,12 @@ function printPluginSignals(signals) {
|
|
|
7986
7957
|
}
|
|
7987
7958
|
async function offerIgnore(dir, match) {
|
|
7988
7959
|
const id = match.artifact.id || match.artifact.title;
|
|
7989
|
-
const shouldIgnore = await
|
|
7960
|
+
const shouldIgnore = await confirm({
|
|
7990
7961
|
message: `Ignore ${id} in future guard runs?`,
|
|
7991
7962
|
initialValue: false
|
|
7992
7963
|
});
|
|
7993
7964
|
if (!shouldIgnore) return false;
|
|
7994
|
-
const reason = await
|
|
7965
|
+
const reason = await text({
|
|
7995
7966
|
message: "Reason for ignoring",
|
|
7996
7967
|
placeholder: "e.g. This file was moved, not functionally changed",
|
|
7997
7968
|
validate: (v) => v.trim().length === 0 ? "Reason is required." : void 0
|
|
@@ -8002,7 +7973,7 @@ async function offerIgnore(dir, match) {
|
|
|
8002
7973
|
created_at: (/* @__PURE__ */ new Date()).toISOString().split("T")[0],
|
|
8003
7974
|
files: match.matchedFiles
|
|
8004
7975
|
});
|
|
8005
|
-
|
|
7976
|
+
log.success(`${id} added to .kaddo/ignores.yml`);
|
|
8006
7977
|
return true;
|
|
8007
7978
|
}
|
|
8008
7979
|
function printCIJson(dir, touchedFiles, activeMatches, ignoredCount, pluginSignals, affectedOwners, workspace, includeArchived, normalizedFiles, outsideProjectFiles) {
|
|
@@ -8070,9 +8041,9 @@ async function runGuard(opts = {}) {
|
|
|
8070
8041
|
raw,
|
|
8071
8042
|
project: normalizeTouchedPathForProject(raw, gitRoot, dir)
|
|
8072
8043
|
}));
|
|
8073
|
-
const inProjectPairs = currentPairs.filter((
|
|
8074
|
-
const currentFiles = inProjectPairs.map((
|
|
8075
|
-
const outsideProjectFiles = currentPairs.filter((
|
|
8044
|
+
const inProjectPairs = currentPairs.filter((p) => p.project !== null);
|
|
8045
|
+
const currentFiles = inProjectPairs.map((p) => p.project);
|
|
8046
|
+
const outsideProjectFiles = currentPairs.filter((p) => p.project === null).map((p) => p.raw);
|
|
8076
8047
|
const untrackedFiles = opts.staged ? [] : (await getUntrackedFiles()).map((f) => normalizeTouchedPathForProject(f, gitRoot, dir)).filter((f) => f !== null);
|
|
8077
8048
|
const printUntracked = () => {
|
|
8078
8049
|
if (untrackedFiles.length === 0 || jsonMode) return;
|
|
@@ -8088,7 +8059,7 @@ async function runGuard(opts = {}) {
|
|
|
8088
8059
|
}
|
|
8089
8060
|
const workspaceFiles = workspaceScan ? workspaceScan.changedFiles.map((c) => c.normalizedPath) : [];
|
|
8090
8061
|
const touchedFiles = [.../* @__PURE__ */ new Set([...currentFiles, ...workspaceFiles])];
|
|
8091
|
-
const displayTouched = [.../* @__PURE__ */ new Set([...inProjectPairs.map((
|
|
8062
|
+
const displayTouched = [.../* @__PURE__ */ new Set([...inProjectPairs.map((p) => p.raw), ...workspaceFiles])];
|
|
8092
8063
|
if (touchedFiles.length === 0) {
|
|
8093
8064
|
if (workspaceScan) printWorkspaceHeader(workspaceScan);
|
|
8094
8065
|
console.log("kaddo guard: no modified files detected.");
|
|
@@ -8165,7 +8136,7 @@ async function runGuard(opts = {}) {
|
|
|
8165
8136
|
const ownerMapCI = loadOwners(dir);
|
|
8166
8137
|
const matchedDomainsCI = collectMatchedDomains(activeMatches.map((m) => m.artifact.domains));
|
|
8167
8138
|
const affectedOwnersCI = resolveAffectedOwners(matchedDomainsCI, ownerMapCI);
|
|
8168
|
-
printCIJson(dir, touchedFiles, activeMatches, alreadyIgnoredMatches.length, pluginSignals, affectedOwnersCI, workspaceScan, includeArchived, inProjectPairs.map((
|
|
8139
|
+
printCIJson(dir, touchedFiles, activeMatches, alreadyIgnoredMatches.length, pluginSignals, affectedOwnersCI, workspaceScan, includeArchived, inProjectPairs.map((p) => ({ raw_path: p.raw, project_path: p.project })), outsideProjectFiles);
|
|
8169
8140
|
return;
|
|
8170
8141
|
}
|
|
8171
8142
|
if (result.silenced && pluginSignals.length === 0) {
|
|
@@ -8308,7 +8279,7 @@ function runIgnore(artifactId, reason) {
|
|
|
8308
8279
|
created_at: (/* @__PURE__ */ new Date()).toISOString().split("T")[0],
|
|
8309
8280
|
files: []
|
|
8310
8281
|
});
|
|
8311
|
-
|
|
8282
|
+
log.success(`${artifactId} added to .kaddo/ignores.yml \u2014 "${reason}"`);
|
|
8312
8283
|
}
|
|
8313
8284
|
function runIgnoreList() {
|
|
8314
8285
|
const dir = cwd();
|
|
@@ -8330,9 +8301,9 @@ function runIgnoreRemove(artifactId) {
|
|
|
8330
8301
|
const dir = cwd();
|
|
8331
8302
|
const removed = removeIgnore(dir, artifactId);
|
|
8332
8303
|
if (removed) {
|
|
8333
|
-
|
|
8304
|
+
log.success(`${artifactId} removed from .kaddo/ignores.yml`);
|
|
8334
8305
|
} else {
|
|
8335
|
-
|
|
8306
|
+
log.warn(`${artifactId} was not in .kaddo/ignores.yml`);
|
|
8336
8307
|
}
|
|
8337
8308
|
}
|
|
8338
8309
|
|
|
@@ -10094,10 +10065,10 @@ var IGNORED_DIRS = /* @__PURE__ */ new Set([
|
|
|
10094
10065
|
".kaddo"
|
|
10095
10066
|
]);
|
|
10096
10067
|
function readModulesYml(dir) {
|
|
10097
|
-
const
|
|
10098
|
-
if (!exists(
|
|
10068
|
+
const p = join(dir, MODULES_YML);
|
|
10069
|
+
if (!exists(p)) return { version: 1, system: "", workspace_roots: [".."], modules: [] };
|
|
10099
10070
|
try {
|
|
10100
|
-
const parsed = parseYaml8(readFile(
|
|
10071
|
+
const parsed = parseYaml8(readFile(p));
|
|
10101
10072
|
return {
|
|
10102
10073
|
version: parsed.version ?? 1,
|
|
10103
10074
|
system: parsed.system ?? "",
|
|
@@ -10385,7 +10356,7 @@ function detectLegacyPaths(dir) {
|
|
|
10385
10356
|
}
|
|
10386
10357
|
async function runModulesDiscover(opts = {}) {
|
|
10387
10358
|
const dir = cwd();
|
|
10388
|
-
|
|
10359
|
+
intro("kaddo modules discover");
|
|
10389
10360
|
const config = loadConfig(dir);
|
|
10390
10361
|
if (!config) {
|
|
10391
10362
|
console.error("Kaddo is not initialized. Run `kaddo init` first.");
|
|
@@ -10397,8 +10368,8 @@ async function runModulesDiscover(opts = {}) {
|
|
|
10397
10368
|
}
|
|
10398
10369
|
const discovered = discoverModules(dir);
|
|
10399
10370
|
if (discovered.length === 0) {
|
|
10400
|
-
|
|
10401
|
-
|
|
10371
|
+
log.info("No sibling repositories found in workspace roots.");
|
|
10372
|
+
outro("Discovery complete.");
|
|
10402
10373
|
return;
|
|
10403
10374
|
}
|
|
10404
10375
|
console.log("");
|
|
@@ -10415,26 +10386,26 @@ async function runModulesDiscover(opts = {}) {
|
|
|
10415
10386
|
const eligible = discovered.filter((d) => d.eligibleForMapping && d.status === "configured");
|
|
10416
10387
|
console.log(`Eligible for mapping: ${eligible.length}`);
|
|
10417
10388
|
if (eligible.length === 0) {
|
|
10418
|
-
|
|
10389
|
+
outro("Discovery complete.");
|
|
10419
10390
|
return;
|
|
10420
10391
|
}
|
|
10421
10392
|
if (opts.apply) {
|
|
10422
|
-
const confirmed = await
|
|
10393
|
+
const confirmed = await confirm({
|
|
10423
10394
|
message: `Map ${eligible.length} configured Kaddo modules?`,
|
|
10424
10395
|
initialValue: true
|
|
10425
10396
|
});
|
|
10426
10397
|
if (!confirmed) {
|
|
10427
|
-
|
|
10398
|
+
outro("No changes applied.");
|
|
10428
10399
|
return;
|
|
10429
10400
|
}
|
|
10430
10401
|
const result = applyDiscovery(dir, discovered);
|
|
10431
|
-
|
|
10432
|
-
|
|
10433
|
-
|
|
10434
|
-
|
|
10402
|
+
log.success(`Mapped ${result.mapped} configured modules.`);
|
|
10403
|
+
log.success("Updated .kaddo/modules.yml.");
|
|
10404
|
+
log.success("Updated knowledge/tech/modules/modules.md.");
|
|
10405
|
+
outro("Discovery applied.");
|
|
10435
10406
|
} else {
|
|
10436
|
-
|
|
10437
|
-
|
|
10407
|
+
log.info("Run `kaddo modules discover --apply` to persist eligible modules.");
|
|
10408
|
+
outro("Discovery complete.");
|
|
10438
10409
|
}
|
|
10439
10410
|
}
|
|
10440
10411
|
|
|
@@ -10597,7 +10568,7 @@ function mapModule(dir, input) {
|
|
|
10597
10568
|
return { module: mod, written, skipped, alreadyRegistered };
|
|
10598
10569
|
}
|
|
10599
10570
|
async function runModulesMap(dir = cwd(), modulePath) {
|
|
10600
|
-
|
|
10571
|
+
intro("kaddo modules map");
|
|
10601
10572
|
if (!exists(join(dir, CONFIG_PATH4))) {
|
|
10602
10573
|
console.error("Kaddo is not initialized in this project.");
|
|
10603
10574
|
console.error("Run `kaddo init` first.");
|
|
@@ -10607,7 +10578,7 @@ async function runModulesMap(dir = cwd(), modulePath) {
|
|
|
10607
10578
|
if (modulePath) {
|
|
10608
10579
|
repoPath = modulePath;
|
|
10609
10580
|
} else {
|
|
10610
|
-
repoPath = await
|
|
10581
|
+
repoPath = await text({
|
|
10611
10582
|
message: "Repository path (relative to this repo)",
|
|
10612
10583
|
placeholder: "e.g. ../frontend",
|
|
10613
10584
|
validate: (v) => v.trim().length === 0 ? "Repository path is required." : void 0
|
|
@@ -10615,21 +10586,21 @@ async function runModulesMap(dir = cwd(), modulePath) {
|
|
|
10615
10586
|
}
|
|
10616
10587
|
const targetDir = join(dir, repoPath.trim());
|
|
10617
10588
|
if (!exists(targetDir)) {
|
|
10618
|
-
|
|
10589
|
+
log.warn(`Path "${repoPath.trim()}" does not exist.`);
|
|
10619
10590
|
} else {
|
|
10620
10591
|
const st = detectModuleStatus(dir, repoPath.trim());
|
|
10621
10592
|
if (st.status === "not_configured") {
|
|
10622
|
-
|
|
10593
|
+
log.warn(`${repoPath.trim()} does not have Kaddo configured. Run \`kaddo init\` inside that repository first.`);
|
|
10623
10594
|
} else if (st.status === "invalid") {
|
|
10624
|
-
|
|
10595
|
+
log.warn(`${repoPath.trim()} has Kaddo but is not configured as a module.`);
|
|
10625
10596
|
}
|
|
10626
10597
|
}
|
|
10627
|
-
const name = await
|
|
10598
|
+
const name = await text({
|
|
10628
10599
|
message: "Module name",
|
|
10629
10600
|
placeholder: "e.g. Frontend Web",
|
|
10630
10601
|
validate: (v) => v.trim().length === 0 ? "Name is required." : void 0
|
|
10631
10602
|
});
|
|
10632
|
-
const type = await
|
|
10603
|
+
const type = await select({
|
|
10633
10604
|
message: "Module type",
|
|
10634
10605
|
options: MODULE_TYPES.map((t) => ({ value: t, label: t }))
|
|
10635
10606
|
});
|
|
@@ -10638,10 +10609,10 @@ async function runModulesMap(dir = cwd(), modulePath) {
|
|
|
10638
10609
|
repoPath,
|
|
10639
10610
|
type
|
|
10640
10611
|
});
|
|
10641
|
-
for (const
|
|
10642
|
-
for (const
|
|
10643
|
-
|
|
10644
|
-
|
|
10612
|
+
for (const p of result.written) log.success(`Created ${p}`);
|
|
10613
|
+
for (const p of result.skipped) log.info(`Kept existing ${p}`);
|
|
10614
|
+
log.success(`Module "${result.module.id}" recorded in ${DESCRIPTOR_PATH2}`);
|
|
10615
|
+
outro("Module mapped.");
|
|
10645
10616
|
}
|
|
10646
10617
|
function runModulesList(dir = cwd()) {
|
|
10647
10618
|
const yml = readModulesYml(dir);
|
|
@@ -10683,8 +10654,8 @@ function firstParagraph(md) {
|
|
|
10683
10654
|
return "";
|
|
10684
10655
|
}
|
|
10685
10656
|
function readIf(dir, rel) {
|
|
10686
|
-
const
|
|
10687
|
-
return exists(
|
|
10657
|
+
const p = join(dir, rel);
|
|
10658
|
+
return exists(p) ? readFile(p) : null;
|
|
10688
10659
|
}
|
|
10689
10660
|
function headings(md) {
|
|
10690
10661
|
return md.split(/\r?\n/).map((l) => l.match(/^#{2,3}\s+(.+?)\s*$/)).filter((m) => Boolean(m)).map((m) => m[1].trim()).filter((h) => !/^(summary|resumen|overview|risks|owners|out of scope)$/i.test(h));
|
|
@@ -10801,10 +10772,10 @@ function serializeCapsuleJson(c) {
|
|
|
10801
10772
|
}
|
|
10802
10773
|
var EXTERNAL_PATH = ".kaddo/external.yml";
|
|
10803
10774
|
function loadExternalRegistry(dir) {
|
|
10804
|
-
const
|
|
10805
|
-
if (!exists(
|
|
10775
|
+
const p = join(dir, EXTERNAL_PATH);
|
|
10776
|
+
if (!exists(p)) return [];
|
|
10806
10777
|
try {
|
|
10807
|
-
const parsed = parseYaml10(readFile(
|
|
10778
|
+
const parsed = parseYaml10(readFile(p));
|
|
10808
10779
|
return Array.isArray(parsed?.external) ? parsed.external : [];
|
|
10809
10780
|
} catch {
|
|
10810
10781
|
return [];
|
|
@@ -10903,8 +10874,8 @@ var ALL_STATUSES = ["draft", "ready", "in-progress", "blocked", "completed"];
|
|
|
10903
10874
|
function scopeStatuses(scope) {
|
|
10904
10875
|
return scope === "all" ? { included: ALL_STATUSES, excluded: ["archived"] } : { included: ACTIVE_STATUSES, excluded: ["completed", "archived"] };
|
|
10905
10876
|
}
|
|
10906
|
-
function toPosix4(
|
|
10907
|
-
return
|
|
10877
|
+
function toPosix4(p) {
|
|
10878
|
+
return p.replace(/\\/g, "/");
|
|
10908
10879
|
}
|
|
10909
10880
|
function slug(s) {
|
|
10910
10881
|
return s.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -11079,10 +11050,10 @@ function renderGraphMermaid(graph) {
|
|
|
11079
11050
|
}
|
|
11080
11051
|
var ACTIVE_WI_STATES = /* @__PURE__ */ new Set(["draft", "ready", "in-progress", "blocked"]);
|
|
11081
11052
|
function loadGraphSummary(dir) {
|
|
11082
|
-
const
|
|
11083
|
-
if (!exists(
|
|
11053
|
+
const p = join(dir, ".kaddo", "graph.json");
|
|
11054
|
+
if (!exists(p)) return null;
|
|
11084
11055
|
try {
|
|
11085
|
-
const graph = JSON.parse(readFile(
|
|
11056
|
+
const graph = JSON.parse(readFile(p));
|
|
11086
11057
|
const nodes = Array.isArray(graph.nodes) ? graph.nodes : [];
|
|
11087
11058
|
const edges = Array.isArray(graph.edges) ? graph.edges : [];
|
|
11088
11059
|
const activeWiIds = new Set(
|
|
@@ -11109,8 +11080,8 @@ function loadGraphSummary(dir) {
|
|
|
11109
11080
|
|
|
11110
11081
|
// src/core/graph-hints.ts
|
|
11111
11082
|
var KNOWLEDGE4 = "knowledge";
|
|
11112
|
-
function toPosix5(
|
|
11113
|
-
return
|
|
11083
|
+
function toPosix5(p) {
|
|
11084
|
+
return p.replace(/\\/g, "/");
|
|
11114
11085
|
}
|
|
11115
11086
|
function slug2(s) {
|
|
11116
11087
|
return s.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -11119,9 +11090,9 @@ function isAdr2(a) {
|
|
|
11119
11090
|
return toPosix5(a.filePath).includes("/tech/decisions/") && Boolean(a.type);
|
|
11120
11091
|
}
|
|
11121
11092
|
function capabilityHeadings(dir) {
|
|
11122
|
-
const
|
|
11123
|
-
if (!exists(
|
|
11124
|
-
return readFile(
|
|
11093
|
+
const p = join(dir, KNOWLEDGE4, "product", "capabilities.md");
|
|
11094
|
+
if (!exists(p)) return [];
|
|
11095
|
+
return readFile(p).split(/\r?\n/).map((l) => l.match(/^#{2,3}\s+(.+?)\s*$/)).filter((m) => Boolean(m)).map((m) => m[1].trim()).filter((h) => !/^(summary|resumen|overview|capabilities|capacidades)$/i.test(h));
|
|
11125
11096
|
}
|
|
11126
11097
|
function humanMissing(field) {
|
|
11127
11098
|
switch (field) {
|
|
@@ -11332,10 +11303,10 @@ function serializeGraphHintsJson(report) {
|
|
|
11332
11303
|
return JSON.stringify(report, null, 2) + "\n";
|
|
11333
11304
|
}
|
|
11334
11305
|
function loadGraphHints(dir) {
|
|
11335
|
-
const
|
|
11336
|
-
if (!exists(
|
|
11306
|
+
const p = join(dir, ".kaddo", "graph-hints.json");
|
|
11307
|
+
if (!exists(p)) return null;
|
|
11337
11308
|
try {
|
|
11338
|
-
const report = JSON.parse(readFile(
|
|
11309
|
+
const report = JSON.parse(readFile(p));
|
|
11339
11310
|
const hints = Array.isArray(report.hints) ? report.hints : [];
|
|
11340
11311
|
return {
|
|
11341
11312
|
scope: String(report.scope ?? "active"),
|
|
@@ -11428,15 +11399,15 @@ function layerForType(type) {
|
|
|
11428
11399
|
return null;
|
|
11429
11400
|
}
|
|
11430
11401
|
function layerFromPath(filePath) {
|
|
11431
|
-
const
|
|
11432
|
-
if (
|
|
11433
|
-
if (
|
|
11434
|
-
if (
|
|
11435
|
-
if (
|
|
11402
|
+
const p = filePath.replace(/\\/g, "/");
|
|
11403
|
+
if (p.includes(`/${KNOWLEDGE5}/business/`)) return "Business";
|
|
11404
|
+
if (p.includes(`/${KNOWLEDGE5}/product/`)) return "Product";
|
|
11405
|
+
if (p.includes(`/${KNOWLEDGE5}/tech/`)) return "Tech";
|
|
11406
|
+
if (p.includes(`/${KNOWLEDGE5}/delivery/`)) return "Delivery";
|
|
11436
11407
|
return null;
|
|
11437
11408
|
}
|
|
11438
|
-
function basename(
|
|
11439
|
-
return
|
|
11409
|
+
function basename(p) {
|
|
11410
|
+
return p.replace(/\\/g, "/").split("/").pop() ?? p;
|
|
11440
11411
|
}
|
|
11441
11412
|
function discoverLayers(dir) {
|
|
11442
11413
|
const acc = {
|
|
@@ -11566,10 +11537,10 @@ function analyzeContent(md) {
|
|
|
11566
11537
|
return "weak";
|
|
11567
11538
|
}
|
|
11568
11539
|
function analyzeKnowledgeArtifact(dir, rel) {
|
|
11569
|
-
const
|
|
11570
|
-
if (!exists(
|
|
11540
|
+
const p = join(dir, rel);
|
|
11541
|
+
if (!exists(p)) return "missing";
|
|
11571
11542
|
try {
|
|
11572
|
-
return analyzeContent(readFile(
|
|
11543
|
+
return analyzeContent(readFile(p));
|
|
11573
11544
|
} catch {
|
|
11574
11545
|
return "missing";
|
|
11575
11546
|
}
|
|
@@ -11713,8 +11684,8 @@ var IMPORTANT = [
|
|
|
11713
11684
|
"permis",
|
|
11714
11685
|
"permission"
|
|
11715
11686
|
];
|
|
11716
|
-
function matchesAny(
|
|
11717
|
-
return keywords.some((k) =>
|
|
11687
|
+
function matchesAny(text2, keywords) {
|
|
11688
|
+
return keywords.some((k) => text2.includes(k));
|
|
11718
11689
|
}
|
|
11719
11690
|
function classifyQuestion(question) {
|
|
11720
11691
|
const t = question.toLowerCase();
|
|
@@ -11746,8 +11717,8 @@ function extractFromMarkdown(md) {
|
|
|
11746
11717
|
if (m) {
|
|
11747
11718
|
const bullet = m[1].trim();
|
|
11748
11719
|
if (!bullet || /^_.*_$/.test(bullet)) continue;
|
|
11749
|
-
const { text:
|
|
11750
|
-
if (
|
|
11720
|
+
const { text: text2, resolution_status } = parseResolution(bullet);
|
|
11721
|
+
if (text2) out.push({ text: text2, resolution_status, line: i + 1, raw: line.trim() });
|
|
11751
11722
|
}
|
|
11752
11723
|
}
|
|
11753
11724
|
return out;
|
|
@@ -11773,11 +11744,11 @@ function buildOpenQuestionsReport(dir, now = /* @__PURE__ */ new Date()) {
|
|
|
11773
11744
|
const questions = [];
|
|
11774
11745
|
let seq = 0;
|
|
11775
11746
|
for (const source of SOURCES) {
|
|
11776
|
-
const
|
|
11777
|
-
if (!exists(
|
|
11747
|
+
const p = join(dir, source);
|
|
11748
|
+
if (!exists(p)) continue;
|
|
11778
11749
|
let md;
|
|
11779
11750
|
try {
|
|
11780
|
-
md = readFile(
|
|
11751
|
+
md = readFile(p);
|
|
11781
11752
|
} catch {
|
|
11782
11753
|
continue;
|
|
11783
11754
|
}
|
|
@@ -11947,7 +11918,7 @@ function buildCodexAdapterContext(dir) {
|
|
|
11947
11918
|
hasSkills: skills.length > 0,
|
|
11948
11919
|
skills,
|
|
11949
11920
|
hasMcpHint: detectMcpHint(dir),
|
|
11950
|
-
knowledgePaths: KNOWLEDGE_PATHS.filter((
|
|
11921
|
+
knowledgePaths: KNOWLEDGE_PATHS.filter((p) => exists(join(dir, p))),
|
|
11951
11922
|
generatedPaths: GENERATED_PATHS
|
|
11952
11923
|
};
|
|
11953
11924
|
}
|
|
@@ -12031,10 +12002,10 @@ function renderAdapterMarkdown(ctx, target) {
|
|
|
12031
12002
|
L.push("");
|
|
12032
12003
|
L.push("## Kaddo knowledge map", "");
|
|
12033
12004
|
L.push("Primary knowledge lives in:", "");
|
|
12034
|
-
for (const
|
|
12005
|
+
for (const p of ctx.knowledgePaths.length > 0 ? ctx.knowledgePaths : KNOWLEDGE_PATHS) L.push(`- \`${p}\``);
|
|
12035
12006
|
L.push("");
|
|
12036
12007
|
L.push("Derived context (generated \u2014 do not edit by hand) lives in:", "");
|
|
12037
|
-
for (const
|
|
12008
|
+
for (const p of ctx.generatedPaths) L.push(`- \`${p}\``);
|
|
12038
12009
|
L.push("");
|
|
12039
12010
|
L.push("## Operating rules", "");
|
|
12040
12011
|
L.push("- Do not generate a roadmap without checking open-questions readiness.");
|
|
@@ -12158,10 +12129,10 @@ function renderKaddoBlock(ctx) {
|
|
|
12158
12129
|
L.push("");
|
|
12159
12130
|
L.push("### Kaddo knowledge map", "");
|
|
12160
12131
|
L.push("Primary knowledge:");
|
|
12161
|
-
for (const
|
|
12132
|
+
for (const p of ctx.knowledgePaths.length > 0 ? ctx.knowledgePaths : KNOWLEDGE_PATHS) L.push(`- \`${p}\``);
|
|
12162
12133
|
L.push("");
|
|
12163
12134
|
L.push("Generated context (do not edit by hand):");
|
|
12164
|
-
for (const
|
|
12135
|
+
for (const p of ctx.generatedPaths) L.push(`- \`${p}\``);
|
|
12165
12136
|
L.push("");
|
|
12166
12137
|
L.push("### Kaddo operating rules", "");
|
|
12167
12138
|
L.push("- Do not generate a roadmap without checking open-questions readiness.");
|
|
@@ -12419,19 +12390,19 @@ function hasRegisteredModules(modulesYmlPath) {
|
|
|
12419
12390
|
return false;
|
|
12420
12391
|
}
|
|
12421
12392
|
}
|
|
12422
|
-
function safeRead(
|
|
12393
|
+
function safeRead(p) {
|
|
12423
12394
|
try {
|
|
12424
|
-
return readFile(
|
|
12395
|
+
return readFile(p);
|
|
12425
12396
|
} catch {
|
|
12426
12397
|
return null;
|
|
12427
12398
|
}
|
|
12428
12399
|
}
|
|
12429
12400
|
function roadmapSignal(dir) {
|
|
12430
|
-
const
|
|
12431
|
-
if (!exists(
|
|
12401
|
+
const p = join(dir, "knowledge/delivery/roadmap.md");
|
|
12402
|
+
if (!exists(p)) return "missing";
|
|
12432
12403
|
let md;
|
|
12433
12404
|
try {
|
|
12434
|
-
md = readFile(
|
|
12405
|
+
md = readFile(p);
|
|
12435
12406
|
} catch {
|
|
12436
12407
|
return "missing";
|
|
12437
12408
|
}
|
|
@@ -13020,10 +12991,10 @@ function parseRoadmapCandidateQuality(md) {
|
|
|
13020
12991
|
}
|
|
13021
12992
|
function buildRoadmapQuality(dir) {
|
|
13022
12993
|
let md = "";
|
|
13023
|
-
const
|
|
13024
|
-
if (exists(
|
|
12994
|
+
const p = join(dir, ROADMAP_PATH2);
|
|
12995
|
+
if (exists(p)) {
|
|
13025
12996
|
try {
|
|
13026
|
-
md = readFile(
|
|
12997
|
+
md = readFile(p);
|
|
13027
12998
|
} catch {
|
|
13028
12999
|
md = "";
|
|
13029
13000
|
}
|
|
@@ -14508,7 +14479,7 @@ function explainForAgent(dir, artifacts, opts) {
|
|
|
14508
14479
|
since: opts.since ?? null
|
|
14509
14480
|
};
|
|
14510
14481
|
if (knowledge) {
|
|
14511
|
-
const firstParagraph3 = knowledge.content.trim().split("\n\n").find((
|
|
14482
|
+
const firstParagraph3 = knowledge.content.trim().split("\n\n").find((p) => p.trim() && !p.startsWith("#"));
|
|
14512
14483
|
output.knowledge_summary = firstParagraph3?.trim() ?? "";
|
|
14513
14484
|
}
|
|
14514
14485
|
const mappedArtifacts = artifacts.filter((a) => a.type !== "current-state" && a.type !== "roadmap").map((a) => ({
|
|
@@ -14595,14 +14566,14 @@ function readScanJson(dir) {
|
|
|
14595
14566
|
}
|
|
14596
14567
|
function firstParagraph2(markdown) {
|
|
14597
14568
|
const body = matter7(markdown).content.trim();
|
|
14598
|
-
const para = body.split("\n\n").map((
|
|
14569
|
+
const para = body.split("\n\n").map((p) => p.trim()).find((p) => p && !p.startsWith("#"));
|
|
14599
14570
|
return para ?? "";
|
|
14600
14571
|
}
|
|
14601
14572
|
function readMarkdownSummary(dir, file) {
|
|
14602
|
-
const
|
|
14603
|
-
if (!exists(
|
|
14573
|
+
const p = join(dir, ARCH_DIR6, file);
|
|
14574
|
+
if (!exists(p)) return null;
|
|
14604
14575
|
try {
|
|
14605
|
-
return firstParagraph2(readFile(
|
|
14576
|
+
return firstParagraph2(readFile(p));
|
|
14606
14577
|
} catch {
|
|
14607
14578
|
return null;
|
|
14608
14579
|
}
|
|
@@ -14705,8 +14676,8 @@ function buildContextPack(dir, config, now = /* @__PURE__ */ new Date()) {
|
|
|
14705
14676
|
const roadmap = roadmapStats(exists(roadmapPath) ? readFile(roadmapPath) : null, materialized);
|
|
14706
14677
|
const deliveryMix = {};
|
|
14707
14678
|
for (const a of allArtifacts) {
|
|
14708
|
-
const
|
|
14709
|
-
if (!a.type || !
|
|
14679
|
+
const p = a.filePath.replace(/\\/g, "/");
|
|
14680
|
+
if (!a.type || !p.includes("/delivery/work-items/")) continue;
|
|
14710
14681
|
if (!isActiveState(lifecycleStateOf({ status: a.status, filePath: a.filePath }))) continue;
|
|
14711
14682
|
deliveryMix[a.type] = (deliveryMix[a.type] ?? 0) + 1;
|
|
14712
14683
|
}
|
|
@@ -15240,7 +15211,7 @@ function renderContextPack(pack) {
|
|
|
15240
15211
|
// src/commands/context.ts
|
|
15241
15212
|
function runContext(opts = {}) {
|
|
15242
15213
|
const dir = cwd();
|
|
15243
|
-
|
|
15214
|
+
intro("kaddo context");
|
|
15244
15215
|
let config;
|
|
15245
15216
|
try {
|
|
15246
15217
|
config = loadConfig(dir);
|
|
@@ -15261,19 +15232,19 @@ function runContext(opts = {}) {
|
|
|
15261
15232
|
if (writeJson) {
|
|
15262
15233
|
const jsonPath = join(dir, ".kaddo", "context-pack.json");
|
|
15263
15234
|
writeFile(jsonPath, serializeContextPackJson(pack));
|
|
15264
|
-
|
|
15235
|
+
log.success("Wrote .kaddo/context-pack.json");
|
|
15265
15236
|
}
|
|
15266
15237
|
if (writeMarkdown) {
|
|
15267
15238
|
const mdPath = join(dir, ".kaddo", "context-pack.md");
|
|
15268
15239
|
writeFile(mdPath, renderContextPack(pack));
|
|
15269
|
-
|
|
15240
|
+
log.success("Wrote .kaddo/context-pack.md");
|
|
15270
15241
|
}
|
|
15271
15242
|
if (pack.missing.length > 0) {
|
|
15272
|
-
|
|
15243
|
+
log.warn(`Some context is missing (${pack.missing.length} item(s)) \u2014 see the pack's "Missing Context" section.`);
|
|
15273
15244
|
}
|
|
15274
|
-
|
|
15245
|
+
log.info("Paste .kaddo/context-pack.md into your LLM chat alongside a Kaddo agent prompt.");
|
|
15275
15246
|
printCommandFooter("context");
|
|
15276
|
-
|
|
15247
|
+
outro("Context pack ready.");
|
|
15277
15248
|
}
|
|
15278
15249
|
|
|
15279
15250
|
// src/core/understand.ts
|
|
@@ -15489,7 +15460,7 @@ function renderUnderstand(plan) {
|
|
|
15489
15460
|
parts.push("## Agent Prompts\n");
|
|
15490
15461
|
if (agentPaths.length > 1) {
|
|
15491
15462
|
parts.push("Use:\n");
|
|
15492
|
-
parts.push(agentPaths.map((
|
|
15463
|
+
parts.push(agentPaths.map((p) => `- \`${p}\``).join("\n") + "\n");
|
|
15493
15464
|
} else {
|
|
15494
15465
|
parts.push(`- \`${plan.contextPackPath}\`
|
|
15495
15466
|
`);
|
|
@@ -15536,7 +15507,7 @@ function renderUnderstand(plan) {
|
|
|
15536
15507
|
);
|
|
15537
15508
|
} else if (agentPaths.length > 1) {
|
|
15538
15509
|
parts.push("Paste the following into your LLM chat:\n");
|
|
15539
|
-
parts.push(agentPaths.map((
|
|
15510
|
+
parts.push(agentPaths.map((p, i) => `${i + 1}. \`${p}\``).join("\n") + "\n");
|
|
15540
15511
|
if (rec?.agent) {
|
|
15541
15512
|
parts.push(`Ask the LLM to follow the ${agentName(rec.agent)} instructions.
|
|
15542
15513
|
`);
|
|
@@ -15733,7 +15704,7 @@ function renderDeliveryLifecycle(wi) {
|
|
|
15733
15704
|
// src/commands/understand.ts
|
|
15734
15705
|
function runUnderstand() {
|
|
15735
15706
|
const dir = cwd();
|
|
15736
|
-
|
|
15707
|
+
intro("kaddo understand");
|
|
15737
15708
|
let config;
|
|
15738
15709
|
try {
|
|
15739
15710
|
config = loadConfig(dir);
|
|
@@ -15749,16 +15720,16 @@ function runUnderstand() {
|
|
|
15749
15720
|
}
|
|
15750
15721
|
const scanAvailable = exists(join(dir, ".kaddo", "scan.json"));
|
|
15751
15722
|
if (!scanAvailable) {
|
|
15752
|
-
|
|
15723
|
+
log.warn("No scan baseline found. Run `kaddo scan` first for a richer context pack.");
|
|
15753
15724
|
}
|
|
15754
15725
|
const pack = buildContextPack(dir, config);
|
|
15755
15726
|
writeFile(join(dir, ".kaddo", "context-pack.json"), serializeContextPackJson(pack));
|
|
15756
15727
|
writeFile(join(dir, ".kaddo", "context-pack.md"), renderContextPack(pack));
|
|
15757
|
-
|
|
15728
|
+
log.success("Refreshed .kaddo/context-pack.md");
|
|
15758
15729
|
const plan = buildUnderstandPlan(dir, config);
|
|
15759
15730
|
const earlyRec = resolveNextStep(dir);
|
|
15760
15731
|
if (earlyRec.id !== "bootstrap" && plan.missingAgents.length > 0) {
|
|
15761
|
-
|
|
15732
|
+
log.warn(
|
|
15762
15733
|
`Agents are not installed (${plan.missingAgents.map((a) => a.replace(/\.md$/, "")).join(", ")}). Run \`kaddo add agents\`.`
|
|
15763
15734
|
);
|
|
15764
15735
|
}
|
|
@@ -15927,9 +15898,9 @@ function runUnderstand() {
|
|
|
15927
15898
|
metadataHealth: analyzeMetadataHealth(dir)
|
|
15928
15899
|
});
|
|
15929
15900
|
writeFile(join(dir, ".kaddo", "understand.md"), renderUnderstand(enrichedPlan));
|
|
15930
|
-
|
|
15901
|
+
log.success("Wrote .kaddo/understand.md");
|
|
15931
15902
|
printCommandFooter("understand");
|
|
15932
|
-
|
|
15903
|
+
outro("Handoff ready. CLI prepares context \u2014 your LLM creates the understanding.");
|
|
15933
15904
|
}
|
|
15934
15905
|
|
|
15935
15906
|
// src/core/classifier.ts
|
|
@@ -15971,12 +15942,12 @@ var DEP_PATTERNS = [
|
|
|
15971
15942
|
/^Cargo\.lock$/,
|
|
15972
15943
|
/^pom\.xml$/
|
|
15973
15944
|
];
|
|
15974
|
-
function normalizePath2(
|
|
15975
|
-
return
|
|
15945
|
+
function normalizePath2(p) {
|
|
15946
|
+
return p.split(path6.sep).join("/");
|
|
15976
15947
|
}
|
|
15977
15948
|
function matchesAny2(file, patterns) {
|
|
15978
15949
|
const normalized = normalizePath2(file);
|
|
15979
|
-
return patterns.some((
|
|
15950
|
+
return patterns.some((p) => p.test(normalized));
|
|
15980
15951
|
}
|
|
15981
15952
|
function detectSignals(touchedFiles) {
|
|
15982
15953
|
const signals = [];
|
|
@@ -16154,10 +16125,10 @@ import { parse as parseYaml14 } from "yaml";
|
|
|
16154
16125
|
var ARCH_DIR8 = "knowledge";
|
|
16155
16126
|
var CONFIG_PATH6 = ".kaddo/config.yml";
|
|
16156
16127
|
function loadConfig3(dir) {
|
|
16157
|
-
const
|
|
16158
|
-
if (!exists(
|
|
16128
|
+
const p = join(dir, CONFIG_PATH6);
|
|
16129
|
+
if (!exists(p)) return {};
|
|
16159
16130
|
try {
|
|
16160
|
-
return parseYaml14(readFile(
|
|
16131
|
+
return parseYaml14(readFile(p));
|
|
16161
16132
|
} catch {
|
|
16162
16133
|
return {};
|
|
16163
16134
|
}
|
|
@@ -16260,14 +16231,14 @@ async function runLearn(artifactId, opts = {}) {
|
|
|
16260
16231
|
console.error("No knowledge/ directory found. Run `kaddo init` first.");
|
|
16261
16232
|
process.exit(1);
|
|
16262
16233
|
}
|
|
16263
|
-
|
|
16234
|
+
intro("kaddo learn");
|
|
16264
16235
|
const artifacts = readArtifacts(join(dir, ARCH_DIR9));
|
|
16265
16236
|
const closable = artifacts.filter(
|
|
16266
16237
|
(a) => (a.status === "in-progress" || a.status === "completed" || a.status === "done") && a.type !== "current-state" && a.type !== "roadmap"
|
|
16267
16238
|
);
|
|
16268
16239
|
if (closable.length === 0) {
|
|
16269
|
-
|
|
16270
|
-
|
|
16240
|
+
log.warn("No in-progress or completed work items found.");
|
|
16241
|
+
outro("Nothing to close.");
|
|
16271
16242
|
return;
|
|
16272
16243
|
}
|
|
16273
16244
|
let targetId;
|
|
@@ -16275,9 +16246,9 @@ async function runLearn(artifactId, opts = {}) {
|
|
|
16275
16246
|
targetId = artifactId;
|
|
16276
16247
|
} else if (closable.length === 1) {
|
|
16277
16248
|
targetId = closable[0].id || closable[0].title;
|
|
16278
|
-
|
|
16249
|
+
log.info(`Closing: ${targetId} \u2014 ${closable[0].summary || closable[0].title}`);
|
|
16279
16250
|
} else {
|
|
16280
|
-
const chosen = await
|
|
16251
|
+
const chosen = await select({
|
|
16281
16252
|
message: "Which work item are you closing?",
|
|
16282
16253
|
options: closable.map((a) => ({
|
|
16283
16254
|
value: a.id || a.title,
|
|
@@ -16288,7 +16259,7 @@ async function runLearn(artifactId, opts = {}) {
|
|
|
16288
16259
|
}
|
|
16289
16260
|
const filePath = findWorkItemFile(dir, targetId);
|
|
16290
16261
|
if (!filePath) {
|
|
16291
|
-
|
|
16262
|
+
log.error(`Work item "${targetId}" not found in ${WORK_ITEMS_DIR2}/`);
|
|
16292
16263
|
process.exit(1);
|
|
16293
16264
|
}
|
|
16294
16265
|
const wiRaw = readFile(filePath);
|
|
@@ -16311,14 +16282,14 @@ async function runLearn(artifactId, opts = {}) {
|
|
|
16311
16282
|
completionBlockers.push('Validation status is "failed".');
|
|
16312
16283
|
}
|
|
16313
16284
|
if (completionBlockers.length > 0) {
|
|
16314
|
-
|
|
16315
|
-
for (const b of completionBlockers)
|
|
16316
|
-
|
|
16317
|
-
|
|
16285
|
+
log.error("Completion blocked:");
|
|
16286
|
+
for (const b of completionBlockers) log.error(` \u2717 ${b}`);
|
|
16287
|
+
log.info("Run `kaddo verify` to review evidence, or use `kaddo learn --force` to override.");
|
|
16288
|
+
outro("Cannot complete Work Item.");
|
|
16318
16289
|
return;
|
|
16319
16290
|
}
|
|
16320
16291
|
}
|
|
16321
|
-
const learning = await
|
|
16292
|
+
const learning = await text({
|
|
16322
16293
|
message: "What did you learn from this change?",
|
|
16323
16294
|
placeholder: "e.g. The retry logic needed a separate queue to avoid blocking the main flow",
|
|
16324
16295
|
validate: (v) => v.trim().length === 0 ? "Learning is required." : void 0
|
|
@@ -16336,13 +16307,13 @@ async function runLearn(artifactId, opts = {}) {
|
|
|
16336
16307
|
enrichedLearning += "\n\n> " + notes.join(" ");
|
|
16337
16308
|
}
|
|
16338
16309
|
updateWorkItemFile(filePath, enrichedLearning);
|
|
16339
|
-
|
|
16340
|
-
|
|
16310
|
+
log.success(`${targetId} marked as completed`);
|
|
16311
|
+
log.success(`Learning recorded in ${filePath.replace(dir + "/", "")}`);
|
|
16341
16312
|
if (hasExceptions) {
|
|
16342
|
-
|
|
16313
|
+
log.warn("Learning captured from a Work Item completed with validation exceptions.");
|
|
16343
16314
|
}
|
|
16344
|
-
|
|
16345
|
-
|
|
16315
|
+
log.info("Consider updating knowledge/knowledge.md if this changes the current state.");
|
|
16316
|
+
outro("Work item closed.");
|
|
16346
16317
|
}
|
|
16347
16318
|
|
|
16348
16319
|
// src/commands/history.ts
|
|
@@ -16467,7 +16438,7 @@ function runAdd(moduleName, opts = {}, dir = cwd()) {
|
|
|
16467
16438
|
console.error(`Available: ${listModules().map((m) => m.name).join(", ")}`);
|
|
16468
16439
|
process.exit(1);
|
|
16469
16440
|
}
|
|
16470
|
-
|
|
16441
|
+
intro(`kaddo add ${mod.name}`);
|
|
16471
16442
|
if (!exists(join(dir, CONFIG_PATH7))) {
|
|
16472
16443
|
console.error("Kaddo is not initialized in this project.");
|
|
16473
16444
|
console.error("Run `kaddo init` first.");
|
|
@@ -16487,7 +16458,7 @@ function runAdd(moduleName, opts = {}, dir = cwd()) {
|
|
|
16487
16458
|
try {
|
|
16488
16459
|
const sel = selectAgentModuleFiles(mod.files, opts, readProjectState(dir));
|
|
16489
16460
|
filesToInstall = sel.files;
|
|
16490
|
-
|
|
16461
|
+
log.info(`Installing agents (${sel.label}).`);
|
|
16491
16462
|
} catch (err) {
|
|
16492
16463
|
console.error(err instanceof Error ? err.message : String(err));
|
|
16493
16464
|
process.exit(1);
|
|
@@ -16496,7 +16467,7 @@ function runAdd(moduleName, opts = {}, dir = cwd()) {
|
|
|
16496
16467
|
try {
|
|
16497
16468
|
const sel = selectSkillModuleFiles(mod.files, opts);
|
|
16498
16469
|
filesToInstall = sel.files;
|
|
16499
|
-
|
|
16470
|
+
log.info(`Installing skills (${sel.label}).`);
|
|
16500
16471
|
} catch (err) {
|
|
16501
16472
|
console.error(err instanceof Error ? err.message : String(err));
|
|
16502
16473
|
process.exit(1);
|
|
@@ -16513,38 +16484,38 @@ function runAdd(moduleName, opts = {}, dir = cwd()) {
|
|
|
16513
16484
|
written.push(file.path);
|
|
16514
16485
|
}
|
|
16515
16486
|
}
|
|
16516
|
-
for (const
|
|
16517
|
-
for (const
|
|
16487
|
+
for (const p of written) log.success(`Created ${p}`);
|
|
16488
|
+
for (const p of skipped) log.info(`Kept existing ${p}`);
|
|
16518
16489
|
if (alreadyInstalled && written.length === 0) {
|
|
16519
|
-
|
|
16490
|
+
outro(`Module "${mod.name}" is already installed. Nothing changed.`);
|
|
16520
16491
|
return;
|
|
16521
16492
|
}
|
|
16522
16493
|
markModuleInstalled(dir, mod.configKey, mod.name);
|
|
16523
|
-
|
|
16494
|
+
log.success(`Module "${mod.name}" installed.`);
|
|
16524
16495
|
if (mod.name === "agents") {
|
|
16525
|
-
|
|
16496
|
+
log.info("Next:");
|
|
16526
16497
|
console.log(" 1. Run `kaddo context`");
|
|
16527
16498
|
console.log(" 2. Open your preferred LLM chat");
|
|
16528
16499
|
console.log(" 3. Paste `.kaddo/context-pack.md`");
|
|
16529
16500
|
console.log(" 4. Use the recommended agent for your project state");
|
|
16530
|
-
|
|
16531
|
-
|
|
16501
|
+
log.info("More agents: `kaddo add agents --all` or `--group <business|product|tech|delivery|utilities>`.");
|
|
16502
|
+
outro("Agents installed. Kaddo prepares context \u2014 your LLM does the interpretation.");
|
|
16532
16503
|
return;
|
|
16533
16504
|
}
|
|
16534
16505
|
if (mod.name === "skills") {
|
|
16535
|
-
|
|
16536
|
-
|
|
16537
|
-
|
|
16538
|
-
|
|
16506
|
+
log.info("Skills are reusable capabilities agents apply \u2014 they never run anything.");
|
|
16507
|
+
log.info("More skills: `kaddo add skills --all` or `--group <delivery|tech|integration>`.");
|
|
16508
|
+
log.info("Read them in `knowledge/skills/` or via the Kaddo MCP server (`kaddo://skills`).");
|
|
16509
|
+
outro("Skills installed. Agents orchestrate; skills standardize.");
|
|
16539
16510
|
return;
|
|
16540
16511
|
}
|
|
16541
16512
|
if (mod.workItemTypes.length > 0) {
|
|
16542
|
-
|
|
16513
|
+
log.info(`New work item types available:`);
|
|
16543
16514
|
for (const t of mod.workItemTypes) {
|
|
16544
16515
|
console.log(` kaddo create ${t.name} [${t.knowledgeLevel}] \u2014 ${t.description}`);
|
|
16545
16516
|
}
|
|
16546
16517
|
}
|
|
16547
|
-
|
|
16518
|
+
outro(`Done. Run \`kaddo create ${mod.workItemTypes[0]?.name ?? mod.name}\` to get started.`);
|
|
16548
16519
|
}
|
|
16549
16520
|
|
|
16550
16521
|
// src/core/ownership-suggest.ts
|
|
@@ -16730,7 +16701,7 @@ function artifactLabel2(a) {
|
|
|
16730
16701
|
async function chooseGlobs(suggested) {
|
|
16731
16702
|
const chosen = [];
|
|
16732
16703
|
if (suggested.length > 0) {
|
|
16733
|
-
const picked = await
|
|
16704
|
+
const picked = await multiselect({
|
|
16734
16705
|
message: "Select ownership globs (space to toggle, enter to confirm):",
|
|
16735
16706
|
options: [
|
|
16736
16707
|
...suggested.map((g) => ({ value: g, label: g })),
|
|
@@ -16738,35 +16709,35 @@ async function chooseGlobs(suggested) {
|
|
|
16738
16709
|
],
|
|
16739
16710
|
required: false
|
|
16740
16711
|
});
|
|
16741
|
-
for (const
|
|
16742
|
-
if (
|
|
16712
|
+
for (const p of picked) {
|
|
16713
|
+
if (p !== CUSTOM_GLOB) chosen.push(p);
|
|
16743
16714
|
}
|
|
16744
16715
|
if (!picked.includes(CUSTOM_GLOB) && chosen.length > 0) return [...new Set(chosen)];
|
|
16745
16716
|
}
|
|
16746
16717
|
let addMore = suggested.length === 0 || chosen.length === 0;
|
|
16747
16718
|
if (!addMore) {
|
|
16748
|
-
addMore = await
|
|
16719
|
+
addMore = await confirm({ message: "Add a custom glob?", initialValue: true });
|
|
16749
16720
|
}
|
|
16750
16721
|
while (addMore) {
|
|
16751
|
-
const glob = await
|
|
16722
|
+
const glob = await text({
|
|
16752
16723
|
message: "Enter a code glob (e.g. src/payments/**)",
|
|
16753
16724
|
placeholder: "src/payments/**",
|
|
16754
16725
|
validate: (v) => v.trim().length === 0 ? "A glob is required." : void 0
|
|
16755
16726
|
});
|
|
16756
16727
|
const analysis = analyzeGlob(cwd(), glob);
|
|
16757
|
-
for (const w of analysis.warnings)
|
|
16728
|
+
for (const w of analysis.warnings) log.warn(w);
|
|
16758
16729
|
let value = analysis.normalized;
|
|
16759
16730
|
if (analysis.suggestion) {
|
|
16760
|
-
const useSuggested = await
|
|
16731
|
+
const useSuggested = await confirm({
|
|
16761
16732
|
message: `Use ${analysis.suggestion} instead?`,
|
|
16762
16733
|
initialValue: true
|
|
16763
16734
|
});
|
|
16764
16735
|
if (useSuggested) value = analysis.suggestion;
|
|
16765
16736
|
} else if (analysis.normalized !== glob.trim()) {
|
|
16766
|
-
|
|
16737
|
+
log.info(`Normalized to ${analysis.normalized}`);
|
|
16767
16738
|
}
|
|
16768
16739
|
chosen.push(value);
|
|
16769
|
-
addMore = await
|
|
16740
|
+
addMore = await confirm({ message: "Add another glob?", initialValue: false });
|
|
16770
16741
|
}
|
|
16771
16742
|
return [...new Set(chosen)];
|
|
16772
16743
|
}
|
|
@@ -16776,28 +16747,28 @@ async function runOwnersSuggest() {
|
|
|
16776
16747
|
console.error("No .kaddo/config.yml found. Run `kaddo init` first.");
|
|
16777
16748
|
process.exit(1);
|
|
16778
16749
|
}
|
|
16779
|
-
|
|
16750
|
+
intro("kaddo owners suggest");
|
|
16780
16751
|
const artifacts = findWorkItemArtifacts(dir);
|
|
16781
16752
|
if (artifacts.length === 0) {
|
|
16782
|
-
|
|
16753
|
+
log.warn(
|
|
16783
16754
|
"No Work Items found under knowledge/delivery/work-items/ (searched recursively, including draft/ ready/ in-progress/ \u2026)."
|
|
16784
16755
|
);
|
|
16785
|
-
|
|
16786
|
-
|
|
16756
|
+
log.info("Create one with `kaddo create` or `kaddo create --from roadmap`.");
|
|
16757
|
+
outro("Nothing to do.");
|
|
16787
16758
|
return;
|
|
16788
16759
|
}
|
|
16789
16760
|
const missing = artifactsMissingOwnership(artifacts);
|
|
16790
16761
|
if (missing.length === 0) {
|
|
16791
|
-
|
|
16762
|
+
log.success(
|
|
16792
16763
|
`Found ${artifacts.length} Work Item${artifacts.length === 1 ? "" : "s"}; all already declare code ownership.`
|
|
16793
16764
|
);
|
|
16794
|
-
|
|
16765
|
+
outro("Nothing to do.");
|
|
16795
16766
|
return;
|
|
16796
16767
|
}
|
|
16797
|
-
|
|
16768
|
+
log.info(
|
|
16798
16769
|
`Found ${artifacts.length} Work Item${artifacts.length === 1 ? "" : "s"}; ${missing.length} missing code ownership.`
|
|
16799
16770
|
);
|
|
16800
|
-
const relPath = missing.length === 1 ? missing[0].relPath : await
|
|
16771
|
+
const relPath = missing.length === 1 ? missing[0].relPath : await select({
|
|
16801
16772
|
message: "Which artifact needs ownership?",
|
|
16802
16773
|
options: missing.map((a) => ({
|
|
16803
16774
|
value: a.relPath,
|
|
@@ -16808,18 +16779,18 @@ async function runOwnersSuggest() {
|
|
|
16808
16779
|
const artifact = missing.find((a) => a.relPath === relPath);
|
|
16809
16780
|
const signals = loadScanSignals2(dir);
|
|
16810
16781
|
if (!signals) {
|
|
16811
|
-
|
|
16782
|
+
log.warn("No .kaddo/scan.json found \u2014 run `kaddo scan` for suggestions. You can enter globs manually.");
|
|
16812
16783
|
}
|
|
16813
16784
|
const suggested = suggestGlobs(artifact, signals);
|
|
16814
16785
|
const globs = await chooseGlobs(suggested);
|
|
16815
16786
|
if (globs.length === 0) {
|
|
16816
|
-
|
|
16817
|
-
|
|
16787
|
+
log.warn("No globs selected. Nothing was changed.");
|
|
16788
|
+
outro("Cancelled.");
|
|
16818
16789
|
return;
|
|
16819
16790
|
}
|
|
16820
16791
|
let mode = "replace";
|
|
16821
16792
|
if (artifact.codeGlobs.length > 0) {
|
|
16822
|
-
mode = await
|
|
16793
|
+
mode = await select({
|
|
16823
16794
|
message: `${artifact.id || artifact.relPath} already declares code globs. Append or replace?`,
|
|
16824
16795
|
options: [
|
|
16825
16796
|
{ value: "append", label: "Append to existing globs" },
|
|
@@ -16827,24 +16798,24 @@ async function runOwnersSuggest() {
|
|
|
16827
16798
|
]
|
|
16828
16799
|
});
|
|
16829
16800
|
}
|
|
16830
|
-
|
|
16801
|
+
log.info(`Preview:
|
|
16831
16802
|
|
|
16832
16803
|
code:
|
|
16833
16804
|
${globs.map((g) => ` - ${g}`).join("\n")}`);
|
|
16834
|
-
const ok = await
|
|
16805
|
+
const ok = await confirm({
|
|
16835
16806
|
message: `Update ${artifact.relPath}?`,
|
|
16836
16807
|
initialValue: true
|
|
16837
16808
|
});
|
|
16838
16809
|
if (!ok) {
|
|
16839
|
-
|
|
16840
|
-
|
|
16810
|
+
log.warn("No changes written.");
|
|
16811
|
+
outro("Cancelled.");
|
|
16841
16812
|
return;
|
|
16842
16813
|
}
|
|
16843
16814
|
const updated = applyOwnership(readFile(artifact.filePath), globs, mode);
|
|
16844
16815
|
writeFile(artifact.filePath, updated);
|
|
16845
|
-
|
|
16846
|
-
|
|
16847
|
-
|
|
16816
|
+
log.success(`Updated ${artifact.relPath}`);
|
|
16817
|
+
log.info("Run `kaddo guard` after changing related code to detect possible knowledge drift.");
|
|
16818
|
+
outro("Ownership declared.");
|
|
16848
16819
|
}
|
|
16849
16820
|
|
|
16850
16821
|
// src/core/bootstrap-templates.ts
|
|
@@ -17334,7 +17305,7 @@ function bootstrap(dir) {
|
|
|
17334
17305
|
return { state, written, skipped, createdDirs };
|
|
17335
17306
|
}
|
|
17336
17307
|
async function runBootstrap(dir = cwd()) {
|
|
17337
|
-
|
|
17308
|
+
intro("kaddo bootstrap");
|
|
17338
17309
|
if (!exists(join(dir, CONFIG_PATH9))) {
|
|
17339
17310
|
console.error("Kaddo is not initialized in this project.");
|
|
17340
17311
|
console.error("Run `kaddo init` first.");
|
|
@@ -17349,27 +17320,27 @@ async function runBootstrap(dir = cwd()) {
|
|
|
17349
17320
|
process.exit(1);
|
|
17350
17321
|
}
|
|
17351
17322
|
const stateLabel3 = state === "pre-ai" ? "pre-ai" : state;
|
|
17352
|
-
|
|
17353
|
-
|
|
17354
|
-
|
|
17323
|
+
log.info(`Project state: ${stateLabel3}`);
|
|
17324
|
+
log.info(`Creating ${stateLabel3} knowledge baseline.`);
|
|
17325
|
+
log.info("Existing files will not be overwritten.");
|
|
17355
17326
|
const result = bootstrap(dir);
|
|
17356
17327
|
console.log("");
|
|
17357
17328
|
if (result.written.length > 0 || result.createdDirs.length > 0) {
|
|
17358
17329
|
console.log("Created:");
|
|
17359
|
-
for (const
|
|
17330
|
+
for (const p of result.written) console.log(` - ${p}`);
|
|
17360
17331
|
for (const d of result.createdDirs) console.log(` - ${d}`);
|
|
17361
17332
|
}
|
|
17362
17333
|
if (result.skipped.length > 0) {
|
|
17363
17334
|
console.log("");
|
|
17364
17335
|
console.log("Skipped (kept existing):");
|
|
17365
|
-
for (const
|
|
17336
|
+
for (const p of result.skipped) console.log(` - ${p}`);
|
|
17366
17337
|
}
|
|
17367
17338
|
console.log("");
|
|
17368
|
-
|
|
17339
|
+
log.info(
|
|
17369
17340
|
"When you pass the context pack to your LLM/coding agent, it must never commit, push or merge without your confirmation \u2014 and create a branch before implementing."
|
|
17370
17341
|
);
|
|
17371
17342
|
printCommandFooter("bootstrap");
|
|
17372
|
-
|
|
17343
|
+
outro(
|
|
17373
17344
|
`${stateLabel3} knowledge baseline ready. Next: \`kaddo add agents\` (then \`kaddo add skills\`), and refine the knowledge with the relevant agents.`
|
|
17374
17345
|
);
|
|
17375
17346
|
}
|
|
@@ -17381,7 +17352,7 @@ function slug3(s) {
|
|
|
17381
17352
|
function runCapsuleExport(opts = {}) {
|
|
17382
17353
|
const dir = cwd();
|
|
17383
17354
|
const config = requireConfig(dir);
|
|
17384
|
-
|
|
17355
|
+
intro("kaddo capsule export");
|
|
17385
17356
|
let capsule;
|
|
17386
17357
|
let name;
|
|
17387
17358
|
if (opts.module) {
|
|
@@ -17402,16 +17373,16 @@ function runCapsuleExport(opts = {}) {
|
|
|
17402
17373
|
const jsonPath = join(".kaddo", "exports", `${name}.capsule.json`);
|
|
17403
17374
|
writeFile(join(dir, mdPath), renderCapsuleMarkdown(capsule));
|
|
17404
17375
|
writeFile(join(dir, jsonPath), serializeCapsuleJson(capsule));
|
|
17405
|
-
|
|
17406
|
-
|
|
17407
|
-
|
|
17376
|
+
log.success(`Wrote ${mdPath}`);
|
|
17377
|
+
log.success(`Wrote ${jsonPath}`);
|
|
17378
|
+
log.info("Refine it with the capsule-agent before sharing \u2014 and never include secrets or source code.");
|
|
17408
17379
|
printCommandFooter("capsule export");
|
|
17409
|
-
|
|
17380
|
+
outro("Knowledge Capsule exported.");
|
|
17410
17381
|
}
|
|
17411
17382
|
function runCapsuleAdd(srcPath) {
|
|
17412
17383
|
const dir = cwd();
|
|
17413
17384
|
requireConfig(dir);
|
|
17414
|
-
|
|
17385
|
+
intro("kaddo capsule add");
|
|
17415
17386
|
if (!srcPath) {
|
|
17416
17387
|
console.error("Usage: kaddo capsule add <path-to-capsule.md>");
|
|
17417
17388
|
process.exit(1);
|
|
@@ -17424,20 +17395,20 @@ function runCapsuleAdd(srcPath) {
|
|
|
17424
17395
|
}
|
|
17425
17396
|
const result = addExternalCapsule(dir, source);
|
|
17426
17397
|
if (!result.isCapsuleType) {
|
|
17427
|
-
|
|
17398
|
+
log.warn("This file is not marked as a knowledge-capsule (front matter `type: knowledge-capsule`).");
|
|
17428
17399
|
}
|
|
17429
|
-
|
|
17430
|
-
|
|
17431
|
-
|
|
17400
|
+
log.success(`Imported capsule "${result.id}" \u2192 ${result.destRel}`);
|
|
17401
|
+
log.success("Registered in .kaddo/external.yml");
|
|
17402
|
+
log.info('Run `kaddo context` \u2014 the pack now includes an "External Knowledge" section.');
|
|
17432
17403
|
printCommandFooter("capsule add");
|
|
17433
|
-
|
|
17404
|
+
outro("External capsule registered.");
|
|
17434
17405
|
}
|
|
17435
17406
|
|
|
17436
17407
|
// src/commands/graph.ts
|
|
17437
17408
|
function runGraphExport(opts = {}) {
|
|
17438
17409
|
const dir = cwd();
|
|
17439
17410
|
const config = requireConfig(dir);
|
|
17440
|
-
|
|
17411
|
+
intro("kaddo graph export");
|
|
17441
17412
|
const scope = opts.scope === "all" ? "all" : "active";
|
|
17442
17413
|
const format = opts.format;
|
|
17443
17414
|
const writeJson = format !== "mermaid";
|
|
@@ -17458,26 +17429,26 @@ function runGraphExport(opts = {}) {
|
|
|
17458
17429
|
writeFile(join(dir, ".kaddo", "graph-hints.md"), renderGraphHintsMarkdown(hints));
|
|
17459
17430
|
writeFile(join(dir, ".kaddo", "graph-hints.json"), serializeGraphHintsJson(hints));
|
|
17460
17431
|
written.push(".kaddo/graph-hints.md", ".kaddo/graph-hints.json");
|
|
17461
|
-
|
|
17462
|
-
|
|
17463
|
-
|
|
17432
|
+
log.success(`Knowledge graph exported with ${scope} scope.`);
|
|
17433
|
+
log.info(`Scope: ${scope} \xB7 Nodes: ${graph.nodes.length} \xB7 Edges: ${graph.edges.length}`);
|
|
17434
|
+
log.info(`Relationship quality: ${hints.quality}`);
|
|
17464
17435
|
const hasWorkItemNodes = graph.nodes.some((n) => n.type === "work-item");
|
|
17465
17436
|
if (scope === "active" && !hasWorkItemNodes) {
|
|
17466
|
-
|
|
17467
|
-
|
|
17468
|
-
|
|
17437
|
+
log.warn("No active Work Items found.");
|
|
17438
|
+
log.info("The active graph only includes knowledge layers.");
|
|
17439
|
+
log.info("Run `kaddo graph export --scope all` to include completed Work Items.");
|
|
17469
17440
|
}
|
|
17470
17441
|
if (hints.hints.length > 0) {
|
|
17471
17442
|
const shown = hints.hints.slice(0, 5);
|
|
17472
|
-
|
|
17473
|
-
for (const h of shown)
|
|
17443
|
+
log.warn(`${hints.hints.length} metadata hint(s) available:`);
|
|
17444
|
+
for (const h of shown) log.info(`- ${h.message}`);
|
|
17474
17445
|
if (hints.hints.length > shown.length) {
|
|
17475
|
-
|
|
17446
|
+
log.info(`\u2026and ${hints.hints.length - shown.length} more \u2014 see .kaddo/graph-hints.md`);
|
|
17476
17447
|
}
|
|
17477
17448
|
}
|
|
17478
|
-
for (const f of written)
|
|
17449
|
+
for (const f of written) log.info(`- ${f}`);
|
|
17479
17450
|
printCommandFooter("graph export");
|
|
17480
|
-
|
|
17451
|
+
outro("Knowledge graph ready.");
|
|
17481
17452
|
}
|
|
17482
17453
|
|
|
17483
17454
|
// src/core/system-topology.ts
|
|
@@ -17513,8 +17484,8 @@ var TECHNICAL_RELATIONSHIP_TYPES = /* @__PURE__ */ new Set([
|
|
|
17513
17484
|
"implemented-by"
|
|
17514
17485
|
]);
|
|
17515
17486
|
var PROVENANCE = /* @__PURE__ */ new Set(["declared", "derived", "agent-reviewed"]);
|
|
17516
|
-
function isRelative(
|
|
17517
|
-
return typeof
|
|
17487
|
+
function isRelative(p) {
|
|
17488
|
+
return typeof p === "string" && p.trim() !== "" && !/^([a-zA-Z]:[\\/]|\/)/.test(p) && !p.includes("..");
|
|
17518
17489
|
}
|
|
17519
17490
|
function strList(v) {
|
|
17520
17491
|
return Array.isArray(v) ? v.map((x) => typeof x === "string" ? x.trim() : "").filter(Boolean) : [];
|
|
@@ -17557,9 +17528,9 @@ function parseTopologyContent(raw, dir) {
|
|
|
17557
17528
|
const moduleRaw = typeof e.module === "string" ? e.module.trim() : void 0;
|
|
17558
17529
|
if (moduleRaw && !validModules.has(moduleRaw)) findings.push({ level: "warning", message: `Entity "${id}" references unregistered module "${moduleRaw}".` });
|
|
17559
17530
|
const rawImpl = e.implementation ?? e.implementation_refs;
|
|
17560
|
-
const implementation = strList(rawImpl).filter((
|
|
17561
|
-
if (isRelative(
|
|
17562
|
-
findings.push({ level: "warning", message: `Entity "${id}" implementation ref "${
|
|
17531
|
+
const implementation = strList(rawImpl).filter((p) => {
|
|
17532
|
+
if (isRelative(p)) return true;
|
|
17533
|
+
findings.push({ level: "warning", message: `Entity "${id}" implementation ref "${p}" is not a safe relative path and was dropped.` });
|
|
17563
17534
|
return false;
|
|
17564
17535
|
});
|
|
17565
17536
|
const prov = e.provenance;
|
|
@@ -17697,64 +17668,64 @@ function applyTopologyProposal(dir, proposalYaml, expectedRevision) {
|
|
|
17697
17668
|
// src/commands/topology.ts
|
|
17698
17669
|
function requireProject(dir) {
|
|
17699
17670
|
if (!loadConfig(dir)) {
|
|
17700
|
-
|
|
17671
|
+
log.error("No Kaddo project was found in the current directory.");
|
|
17701
17672
|
process.exit(1);
|
|
17702
17673
|
}
|
|
17703
17674
|
}
|
|
17704
17675
|
function readProposal(dir, file) {
|
|
17705
17676
|
const abs = join(dir, file);
|
|
17706
17677
|
if (!exists(abs) && !exists(file)) {
|
|
17707
|
-
|
|
17678
|
+
log.error(`Proposal file not found: ${file}`);
|
|
17708
17679
|
process.exit(1);
|
|
17709
17680
|
}
|
|
17710
17681
|
return readFile(exists(abs) ? abs : file);
|
|
17711
17682
|
}
|
|
17712
17683
|
function printFindings(v) {
|
|
17713
|
-
|
|
17714
|
-
|
|
17684
|
+
log.info(`${v.entityCount} entities \xB7 ${v.relationshipCount} relationships`);
|
|
17685
|
+
log.info(`${v.blocking} blocking \xB7 ${v.warning} warning`);
|
|
17715
17686
|
for (const f of v.findings) {
|
|
17716
17687
|
const line = `[${f.level}] ${f.message}`;
|
|
17717
|
-
if (f.level === "blocking")
|
|
17718
|
-
else
|
|
17688
|
+
if (f.level === "blocking") log.error(line);
|
|
17689
|
+
else log.warn(line);
|
|
17719
17690
|
}
|
|
17720
17691
|
}
|
|
17721
17692
|
async function runTopologyValidate(file) {
|
|
17722
17693
|
const dir = cwd();
|
|
17723
17694
|
requireProject(dir);
|
|
17724
|
-
|
|
17695
|
+
intro("kaddo topology validate");
|
|
17725
17696
|
const proposal = readProposal(dir, file);
|
|
17726
17697
|
const v = validateTopologyProposal(dir, proposal);
|
|
17727
17698
|
printFindings(v);
|
|
17728
|
-
if (v.canApply)
|
|
17699
|
+
if (v.canApply) outro("Proposal is valid. Apply it with `kaddo topology apply`.");
|
|
17729
17700
|
else {
|
|
17730
|
-
|
|
17701
|
+
outro("Proposal has blocking findings and cannot be applied.");
|
|
17731
17702
|
process.exit(1);
|
|
17732
17703
|
}
|
|
17733
17704
|
}
|
|
17734
17705
|
async function runTopologyApply(file, opts = {}) {
|
|
17735
17706
|
const dir = cwd();
|
|
17736
17707
|
requireProject(dir);
|
|
17737
|
-
|
|
17708
|
+
intro("kaddo topology apply");
|
|
17738
17709
|
const proposal = readProposal(dir, file);
|
|
17739
17710
|
const v = validateTopologyProposal(dir, proposal);
|
|
17740
17711
|
printFindings(v);
|
|
17741
17712
|
if (!v.canApply) {
|
|
17742
|
-
|
|
17713
|
+
cancel("Cannot apply: the proposal has blocking findings.");
|
|
17743
17714
|
process.exit(1);
|
|
17744
17715
|
}
|
|
17745
17716
|
if (!opts.yes) {
|
|
17746
|
-
const ok = await
|
|
17717
|
+
const ok = await confirm({ message: `Apply this topology enrichment to ${join("", "knowledge/tech/system-topology.yml")}? (writes the project artifact; no Git commit is created)` });
|
|
17747
17718
|
if (!ok) {
|
|
17748
|
-
|
|
17719
|
+
cancel("Apply cancelled.");
|
|
17749
17720
|
process.exit(0);
|
|
17750
17721
|
}
|
|
17751
17722
|
}
|
|
17752
17723
|
try {
|
|
17753
17724
|
const result = applyTopologyProposal(dir, proposal, topologyRevision(dir));
|
|
17754
|
-
|
|
17725
|
+
outro(`Applied. ${result.entitiesNew} new / ${result.entitiesUpdated} updated entities, ${result.relationshipsNew} new relationships.`);
|
|
17755
17726
|
} catch (err) {
|
|
17756
17727
|
if (err instanceof TopologyWriteError) {
|
|
17757
|
-
|
|
17728
|
+
cancel(err.message);
|
|
17758
17729
|
process.exit(1);
|
|
17759
17730
|
}
|
|
17760
17731
|
throw err;
|
|
@@ -19007,7 +18978,7 @@ ${item.description}` : item.title;
|
|
|
19007
18978
|
// src/commands/integrations.ts
|
|
19008
18979
|
function requireProject2(dir) {
|
|
19009
18980
|
if (!loadConfig(dir)) {
|
|
19010
|
-
|
|
18981
|
+
log.error("No Kaddo project was found in the current directory.");
|
|
19011
18982
|
process.exit(1);
|
|
19012
18983
|
}
|
|
19013
18984
|
}
|
|
@@ -19015,26 +18986,26 @@ function printJson(value) {
|
|
|
19015
18986
|
console.log(JSON.stringify(value, null, 2));
|
|
19016
18987
|
}
|
|
19017
18988
|
function fail(err) {
|
|
19018
|
-
if (err instanceof IntegrationError)
|
|
19019
|
-
else if (err instanceof IntegrationServiceError)
|
|
19020
|
-
else
|
|
18989
|
+
if (err instanceof IntegrationError) log.error(`[${err.code}] ${err.safeMessage}`);
|
|
18990
|
+
else if (err instanceof IntegrationServiceError) log.error(`[${err.code}] ${err.message}`);
|
|
18991
|
+
else log.error("The integration operation failed.");
|
|
19021
18992
|
process.exit(1);
|
|
19022
18993
|
}
|
|
19023
18994
|
function runIntegrationsList(dir, opts) {
|
|
19024
18995
|
requireProject2(dir);
|
|
19025
18996
|
const items = listIntegrations(dir);
|
|
19026
18997
|
if (opts.json) return printJson(items.map((i) => ({ id: i.id, adapter: i.adapter, enabled: i.enabled, status: i.status, capabilities: i.capabilities })));
|
|
19027
|
-
|
|
18998
|
+
intro("Kaddo integrations");
|
|
19028
18999
|
if (items.length === 0) {
|
|
19029
|
-
|
|
19030
|
-
return
|
|
19000
|
+
log.info("No integrations are configured. Add them to .kaddo/integrations.yml.");
|
|
19001
|
+
return outro("Done.");
|
|
19031
19002
|
}
|
|
19032
19003
|
for (const i of items) {
|
|
19033
|
-
|
|
19034
|
-
if (i.capabilities)
|
|
19035
|
-
for (const f of i.findings)
|
|
19004
|
+
log.info(`${i.id} \xB7 adapter ${i.adapter} \xB7 ${i.status}${i.enabled ? "" : " (disabled)"}`);
|
|
19005
|
+
if (i.capabilities) log.message(` read: ${i.capabilities.workItems.read ? "\u2713" : "\u2717"} list: ${i.capabilities.workItems.list ? "\u2713" : "\u2717"} import: ${i.capabilities.workItems.import ? "\u2713" : "\u2717"}`);
|
|
19006
|
+
for (const f of i.findings) log.warn(` [${f.level}] ${f.message}`);
|
|
19036
19007
|
}
|
|
19037
|
-
|
|
19008
|
+
outro("Done.");
|
|
19038
19009
|
}
|
|
19039
19010
|
async function runIntegrationsStatus(dir, opts) {
|
|
19040
19011
|
requireProject2(dir);
|
|
@@ -19049,25 +19020,25 @@ async function runIntegrationsStatus(dir, opts) {
|
|
|
19049
19020
|
}
|
|
19050
19021
|
}));
|
|
19051
19022
|
if (opts.json) return printJson(results);
|
|
19052
|
-
|
|
19023
|
+
intro("Integration status");
|
|
19053
19024
|
for (const r of results) {
|
|
19054
19025
|
const line = `${r.id} \xB7 ${r.status}${r.message ? ` \u2014 ${r.message}` : ""}`;
|
|
19055
|
-
if (r.status === "available" || r.status === "configured")
|
|
19056
|
-
else
|
|
19026
|
+
if (r.status === "available" || r.status === "configured") log.info(line);
|
|
19027
|
+
else log.warn(line);
|
|
19057
19028
|
}
|
|
19058
|
-
|
|
19029
|
+
outro("Done.");
|
|
19059
19030
|
}
|
|
19060
19031
|
async function runIntegrationsVerify(dir, id, opts) {
|
|
19061
19032
|
requireProject2(dir);
|
|
19062
19033
|
try {
|
|
19063
19034
|
const v = await verifyIntegration(dir, id);
|
|
19064
19035
|
if (opts.json) return printJson({ id: v.id, status: v.status, message: v.message, missingCredentials: v.missingCredentials });
|
|
19065
|
-
|
|
19036
|
+
intro(`Verify ${id}`);
|
|
19066
19037
|
const line = `Status: ${v.status}${v.message ? ` \u2014 ${v.message}` : ""}`;
|
|
19067
|
-
if (v.status === "available")
|
|
19068
|
-
else
|
|
19069
|
-
if (v.missingCredentials.length)
|
|
19070
|
-
|
|
19038
|
+
if (v.status === "available") log.info(line);
|
|
19039
|
+
else log.warn(line);
|
|
19040
|
+
if (v.missingCredentials.length) log.warn(`Missing credentials: ${v.missingCredentials.join(", ")}`);
|
|
19041
|
+
outro("Done.");
|
|
19071
19042
|
} catch (err) {
|
|
19072
19043
|
fail(err);
|
|
19073
19044
|
}
|
|
@@ -19084,10 +19055,10 @@ async function runIntegrationsWorkItems(dir, id, opts) {
|
|
|
19084
19055
|
filters
|
|
19085
19056
|
});
|
|
19086
19057
|
if (opts.json) return printJson(page);
|
|
19087
|
-
|
|
19088
|
-
for (const it of page.items)
|
|
19089
|
-
if (page.hasMore)
|
|
19090
|
-
|
|
19058
|
+
intro(`External work items \xB7 ${id}`);
|
|
19059
|
+
for (const it of page.items) log.info(`${it.externalId} \xB7 ${it.title}${it.status ? ` [${it.status}]` : ""}`);
|
|
19060
|
+
if (page.hasMore) log.message(`More available \u2014 next cursor: ${page.nextCursor}`);
|
|
19061
|
+
outro(`${page.items.length} item(s).`);
|
|
19091
19062
|
} catch (err) {
|
|
19092
19063
|
fail(err);
|
|
19093
19064
|
}
|
|
@@ -19097,18 +19068,18 @@ async function runIntegrationsWorkItem(dir, id, externalId, opts) {
|
|
|
19097
19068
|
try {
|
|
19098
19069
|
const item = await getExternalWorkItem(dir, id, externalId);
|
|
19099
19070
|
if (!item) {
|
|
19100
|
-
|
|
19071
|
+
log.error(`External work item "${externalId}" was not found.`);
|
|
19101
19072
|
process.exit(1);
|
|
19102
19073
|
}
|
|
19103
19074
|
if (opts.json) return printJson(item);
|
|
19104
|
-
|
|
19105
|
-
|
|
19106
|
-
if (item.status)
|
|
19107
|
-
if (item.type)
|
|
19108
|
-
if (item.url)
|
|
19109
|
-
if (item.description)
|
|
19075
|
+
intro(`${item.provider} \xB7 ${item.externalId}`);
|
|
19076
|
+
log.info(item.title);
|
|
19077
|
+
if (item.status) log.message(`Status: ${item.status}`);
|
|
19078
|
+
if (item.type) log.message(`Type: ${item.type}`);
|
|
19079
|
+
if (item.url) log.message(`URL: ${item.url}`);
|
|
19080
|
+
if (item.description) log.message(`
|
|
19110
19081
|
${item.description}`);
|
|
19111
|
-
|
|
19082
|
+
outro("Done.");
|
|
19112
19083
|
} catch (err) {
|
|
19113
19084
|
fail(err);
|
|
19114
19085
|
}
|
|
@@ -19117,36 +19088,36 @@ async function runIntegrationsImport(dir, id, externalId, opts) {
|
|
|
19117
19088
|
requireProject2(dir);
|
|
19118
19089
|
try {
|
|
19119
19090
|
const { preview, duplicate } = await previewImport(dir, id, externalId, { type: opts.type });
|
|
19120
|
-
|
|
19091
|
+
intro("Import external work item");
|
|
19121
19092
|
if (duplicate) {
|
|
19122
|
-
|
|
19123
|
-
|
|
19093
|
+
log.warn(`Already imported as ${duplicate.workItemId} \u2014 "${duplicate.title}".`);
|
|
19094
|
+
outro("No duplicate was created.");
|
|
19124
19095
|
return;
|
|
19125
19096
|
}
|
|
19126
|
-
|
|
19127
|
-
|
|
19128
|
-
|
|
19129
|
-
if (preview.externalType)
|
|
19130
|
-
|
|
19097
|
+
log.info(`Source: ${preview.source.provider} \xB7 ${preview.source.externalId}`);
|
|
19098
|
+
log.message(`Captured intent: ${preview.capturedIntent}`);
|
|
19099
|
+
log.message("Will create: a Draft Work Item (needs refinement).");
|
|
19100
|
+
if (preview.externalType) log.message(`External type: ${preview.externalType} (Kaddo type is chosen, never inferred)`);
|
|
19101
|
+
log.message("No project files have been modified yet.");
|
|
19131
19102
|
if (!opts.type) {
|
|
19132
|
-
|
|
19103
|
+
log.error("A Kaddo Work Item type is required. Re-run with --type <feature|fix|chore|\u2026>.");
|
|
19133
19104
|
process.exit(1);
|
|
19134
19105
|
}
|
|
19135
19106
|
if (!opts.yes) {
|
|
19136
|
-
const ok = await
|
|
19107
|
+
const ok = await confirm({ message: `Import ${preview.source.displayKey} as a Draft ${opts.type} Work Item?` });
|
|
19137
19108
|
if (ok !== true) {
|
|
19138
|
-
|
|
19109
|
+
cancel("Import cancelled. No files were changed.");
|
|
19139
19110
|
process.exit(0);
|
|
19140
19111
|
}
|
|
19141
19112
|
}
|
|
19142
19113
|
const result = await importExternalWorkItem(dir, id, externalId, { type: opts.type });
|
|
19143
19114
|
if (!result.created) {
|
|
19144
|
-
|
|
19145
|
-
|
|
19115
|
+
log.warn(`Already imported as ${result.duplicateOf}.`);
|
|
19116
|
+
outro("No duplicate was created.");
|
|
19146
19117
|
return;
|
|
19147
19118
|
}
|
|
19148
|
-
|
|
19149
|
-
|
|
19119
|
+
log.info(`Created ${result.workItemId} (Draft, needs refinement).`);
|
|
19120
|
+
outro("Done. Refine it next with the Work Item refinement handoff.");
|
|
19150
19121
|
} catch (err) {
|
|
19151
19122
|
fail(err);
|
|
19152
19123
|
}
|
|
@@ -19587,12 +19558,12 @@ function runReportImpact(opts = {}) {
|
|
|
19587
19558
|
const report = buildImpactReport(dir, { scope });
|
|
19588
19559
|
const content = opts.json ? serializeImpactJson(report) : renderImpactMarkdown(report);
|
|
19589
19560
|
if (opts.output) {
|
|
19590
|
-
|
|
19561
|
+
intro("kaddo report impact");
|
|
19591
19562
|
const rel = opts.output;
|
|
19592
19563
|
writeFile(join(dir, rel), content);
|
|
19593
|
-
|
|
19564
|
+
log.success(`Wrote ${rel.replace(/\\/g, "/")}`);
|
|
19594
19565
|
printCommandFooter("report impact");
|
|
19595
|
-
|
|
19566
|
+
outro("Impact report written.");
|
|
19596
19567
|
return;
|
|
19597
19568
|
}
|
|
19598
19569
|
console.log(content);
|
|
@@ -19614,10 +19585,10 @@ var DEFAULT_ASSUMPTIONS = {
|
|
|
19614
19585
|
};
|
|
19615
19586
|
var SAVINGS_PATH = ".kaddo/savings.yml";
|
|
19616
19587
|
function loadAssumptions(dir) {
|
|
19617
|
-
const
|
|
19618
|
-
if (!exists(
|
|
19588
|
+
const p = join(dir, SAVINGS_PATH);
|
|
19589
|
+
if (!exists(p)) return { assumptions: { ...DEFAULT_ASSUMPTIONS }, source: "default" };
|
|
19619
19590
|
try {
|
|
19620
|
-
const raw = parseYaml18(readFile(
|
|
19591
|
+
const raw = parseYaml18(readFile(p));
|
|
19621
19592
|
const a = raw?.assumptions ?? {};
|
|
19622
19593
|
const t = raw?.team ?? {};
|
|
19623
19594
|
const num = (v, d) => typeof v === "number" && Number.isFinite(v) ? v : d;
|
|
@@ -19871,11 +19842,11 @@ function runSavings(opts = {}) {
|
|
|
19871
19842
|
const report = buildSavingsReport(dir, { scope });
|
|
19872
19843
|
const content = opts.json ? serializeSavingsJson(report) : renderSavingsMarkdown(report);
|
|
19873
19844
|
if (opts.output) {
|
|
19874
|
-
|
|
19845
|
+
intro("kaddo savings");
|
|
19875
19846
|
writeFile(join(dir, opts.output), content);
|
|
19876
|
-
|
|
19847
|
+
log.success(`Wrote ${opts.output.replace(/\\/g, "/")}`);
|
|
19877
19848
|
printCommandFooter("savings");
|
|
19878
|
-
|
|
19849
|
+
outro("Savings report written.");
|
|
19879
19850
|
return;
|
|
19880
19851
|
}
|
|
19881
19852
|
console.log(content);
|
|
@@ -19883,18 +19854,18 @@ function runSavings(opts = {}) {
|
|
|
19883
19854
|
function runSavingsInit(opts = {}) {
|
|
19884
19855
|
const dir = cwd();
|
|
19885
19856
|
requireConfig(dir);
|
|
19886
|
-
|
|
19857
|
+
intro("kaddo savings init");
|
|
19887
19858
|
const rel = ".kaddo/savings.yml";
|
|
19888
19859
|
const full = join(dir, rel);
|
|
19889
19860
|
if (exists(full) && !opts.force) {
|
|
19890
|
-
|
|
19891
|
-
|
|
19861
|
+
log.warn(`${rel} already exists. Use --force to overwrite.`);
|
|
19862
|
+
outro("Nothing changed.");
|
|
19892
19863
|
return;
|
|
19893
19864
|
}
|
|
19894
19865
|
writeFile(full, savingsTemplate());
|
|
19895
|
-
|
|
19896
|
-
|
|
19897
|
-
|
|
19866
|
+
log.success(`Wrote ${rel}`);
|
|
19867
|
+
log.info("Edit the assumptions, then run `kaddo savings`.");
|
|
19868
|
+
outro("Savings assumptions ready.");
|
|
19898
19869
|
}
|
|
19899
19870
|
|
|
19900
19871
|
// src/core/drift-report.ts
|
|
@@ -20016,11 +19987,11 @@ function runDrift(opts = {}) {
|
|
|
20016
19987
|
const report = buildDriftReport(dir);
|
|
20017
19988
|
const content = opts.json ? serializeDriftJson(report) : renderDriftMarkdown(report);
|
|
20018
19989
|
if (opts.output) {
|
|
20019
|
-
|
|
19990
|
+
intro("kaddo drift");
|
|
20020
19991
|
writeFile(join(dir, opts.output), content);
|
|
20021
|
-
|
|
19992
|
+
log.success(`Wrote ${opts.output.replace(/\\/g, "/")}`);
|
|
20022
19993
|
printCommandFooter("drift");
|
|
20023
|
-
|
|
19994
|
+
outro("Drift report written.");
|
|
20024
19995
|
return;
|
|
20025
19996
|
}
|
|
20026
19997
|
console.log(content);
|
|
@@ -20033,11 +20004,11 @@ function runQuestions(opts = {}) {
|
|
|
20033
20004
|
const es = projectLanguage(config) === "es";
|
|
20034
20005
|
const report = buildOpenQuestionsReport(dir);
|
|
20035
20006
|
if (opts.output) {
|
|
20036
|
-
|
|
20007
|
+
intro("kaddo questions");
|
|
20037
20008
|
writeFile(join(dir, opts.output), opts.json ? serializeOpenQuestionsJson(report) : renderOpenQuestionsMarkdown(report));
|
|
20038
|
-
|
|
20009
|
+
log.success(`Wrote ${opts.output.replace(/\\/g, "/")}`);
|
|
20039
20010
|
printCommandFooter("questions");
|
|
20040
|
-
|
|
20011
|
+
outro("Questions report written.");
|
|
20041
20012
|
return;
|
|
20042
20013
|
}
|
|
20043
20014
|
if (opts.json) {
|
|
@@ -20138,12 +20109,12 @@ function runAdaptersInstall(adapter, opts = {}) {
|
|
|
20138
20109
|
return;
|
|
20139
20110
|
}
|
|
20140
20111
|
if (state === "generated_by_kaddo") {
|
|
20141
|
-
|
|
20142
|
-
|
|
20143
|
-
|
|
20144
|
-
|
|
20145
|
-
|
|
20146
|
-
|
|
20112
|
+
intro(`${cmd} --inject`);
|
|
20113
|
+
log.warn(`${rel} is already fully generated by Kaddo.`);
|
|
20114
|
+
log.info("Nothing injected to avoid duplicated Kaddo guidance.");
|
|
20115
|
+
log.info(`Use \`${cmd} --force\` to regenerate the full file.`);
|
|
20116
|
+
log.info(`\`--inject\` is for team-owned files: keep your own ${rel} and run \`${cmd} --inject\` to add the Kaddo block.`);
|
|
20117
|
+
outro("Nothing changed.");
|
|
20147
20118
|
return;
|
|
20148
20119
|
}
|
|
20149
20120
|
if (existing === null) {
|
|
@@ -20153,11 +20124,11 @@ function runAdaptersInstall(adapter, opts = {}) {
|
|
|
20153
20124
|
console.log(content2);
|
|
20154
20125
|
return;
|
|
20155
20126
|
}
|
|
20156
|
-
|
|
20127
|
+
intro(`${cmd} --inject`);
|
|
20157
20128
|
writeFile(full, content2);
|
|
20158
|
-
|
|
20129
|
+
log.success(`Created ${rel} for ${spec.label}.`);
|
|
20159
20130
|
printCommandFooter("adapters install codex");
|
|
20160
|
-
|
|
20131
|
+
outro(`${rel} ready.`);
|
|
20161
20132
|
return;
|
|
20162
20133
|
}
|
|
20163
20134
|
const merged = injectKaddoBlock(existing, ctx);
|
|
@@ -20166,16 +20137,16 @@ function runAdaptersInstall(adapter, opts = {}) {
|
|
|
20166
20137
|
console.log(merged.content);
|
|
20167
20138
|
return;
|
|
20168
20139
|
}
|
|
20169
|
-
|
|
20140
|
+
intro(`${cmd} --inject`);
|
|
20170
20141
|
writeFile(full, merged.content);
|
|
20171
20142
|
if (merged.status === "updated") {
|
|
20172
|
-
|
|
20143
|
+
log.success(`Updated existing Kaddo guidance block in ${rel}.`);
|
|
20173
20144
|
} else {
|
|
20174
|
-
|
|
20145
|
+
log.success(`Injected Kaddo guidance block into ${rel}.`);
|
|
20175
20146
|
}
|
|
20176
|
-
|
|
20147
|
+
log.info("Content outside the Kaddo markers was preserved.");
|
|
20177
20148
|
printCommandFooter("adapters install codex");
|
|
20178
|
-
|
|
20149
|
+
outro(`${rel} ready.`);
|
|
20179
20150
|
return;
|
|
20180
20151
|
}
|
|
20181
20152
|
const content = renderAdapterMarkdown(ctx, spec.id);
|
|
@@ -20184,19 +20155,19 @@ function runAdaptersInstall(adapter, opts = {}) {
|
|
|
20184
20155
|
console.log(content);
|
|
20185
20156
|
return;
|
|
20186
20157
|
}
|
|
20187
|
-
|
|
20158
|
+
intro(cmd);
|
|
20188
20159
|
if (existed && !opts.force) {
|
|
20189
|
-
|
|
20190
|
-
if (spec.supportsInject)
|
|
20191
|
-
|
|
20192
|
-
|
|
20160
|
+
log.warn(`${rel} already exists.`);
|
|
20161
|
+
if (spec.supportsInject) log.info("Use `--inject` to add or update only the Kaddo block,");
|
|
20162
|
+
log.info(`Use \`--force\` to overwrite, or \`--dry-run\` to preview.`);
|
|
20163
|
+
outro("Nothing changed.");
|
|
20193
20164
|
return;
|
|
20194
20165
|
}
|
|
20195
20166
|
writeFile(full, content);
|
|
20196
|
-
|
|
20197
|
-
|
|
20167
|
+
log.success(`${existed ? "Overwrote" : "Created"} ${rel} for ${spec.label}.`);
|
|
20168
|
+
log.info("Source: Kaddo project knowledge. Regenerate it instead of editing by hand.");
|
|
20198
20169
|
printCommandFooter("adapters install codex");
|
|
20199
|
-
|
|
20170
|
+
outro(`${rel} ready.`);
|
|
20200
20171
|
}
|
|
20201
20172
|
function runAdaptersList(opts = {}) {
|
|
20202
20173
|
if (opts.json) {
|
|
@@ -20304,7 +20275,7 @@ var DISCOVERY_FILES = ["architecture-notes.md", "decision-candidates.md"];
|
|
|
20304
20275
|
var DISCOVERY_DIR = "knowledge/tech/discovery";
|
|
20305
20276
|
function runTechOrganize(dir = cwd()) {
|
|
20306
20277
|
requireConfig(dir);
|
|
20307
|
-
|
|
20278
|
+
intro("kaddo tech organize");
|
|
20308
20279
|
const moved = [];
|
|
20309
20280
|
const skipped = [];
|
|
20310
20281
|
for (const file of DISCOVERY_FILES) {
|
|
@@ -20320,17 +20291,17 @@ function runTechOrganize(dir = cwd()) {
|
|
|
20320
20291
|
moved.push(`knowledge/tech/${file} \u2192 ${DISCOVERY_DIR}/${file}`);
|
|
20321
20292
|
}
|
|
20322
20293
|
if (moved.length > 0) {
|
|
20323
|
-
|
|
20294
|
+
log.success("Moved:");
|
|
20324
20295
|
for (const m of moved) console.log(` - ${m}`);
|
|
20325
20296
|
}
|
|
20326
20297
|
for (const file of skipped) {
|
|
20327
|
-
|
|
20298
|
+
log.warn(`Cannot move ${file} because knowledge/tech/discovery/${file} already exists. Review both files manually.`);
|
|
20328
20299
|
}
|
|
20329
20300
|
if (moved.length === 0 && skipped.length === 0) {
|
|
20330
|
-
|
|
20301
|
+
log.info("Nothing to organize \u2014 no discovery files in the legacy `knowledge/tech/` root.");
|
|
20331
20302
|
}
|
|
20332
20303
|
printCommandFooter("tech organize");
|
|
20333
|
-
|
|
20304
|
+
outro("Tech knowledge organized.");
|
|
20334
20305
|
}
|
|
20335
20306
|
|
|
20336
20307
|
// src/commands/assets.ts
|
|
@@ -20367,7 +20338,7 @@ function runAssetsStatus(kind, opts = {}) {
|
|
|
20367
20338
|
function runAssetsUpdate(kind, opts = {}) {
|
|
20368
20339
|
const dir = cwd();
|
|
20369
20340
|
requireConfig(dir);
|
|
20370
|
-
|
|
20341
|
+
intro(`kaddo ${kind}s update`);
|
|
20371
20342
|
const summary = assetStatus(dir, kind);
|
|
20372
20343
|
const catalog = kind === "agent" ? canonicalAgents() : canonicalSkills();
|
|
20373
20344
|
const byPath = new Map(catalog.map((a) => [a.path, a.content]));
|
|
@@ -20386,15 +20357,15 @@ function runAssetsUpdate(kind, opts = {}) {
|
|
|
20386
20357
|
}
|
|
20387
20358
|
}
|
|
20388
20359
|
if (updated.length > 0) {
|
|
20389
|
-
|
|
20360
|
+
log.success("Updated:");
|
|
20390
20361
|
for (const u of updated) console.log(` - ${u}`);
|
|
20391
20362
|
} else {
|
|
20392
|
-
|
|
20363
|
+
log.info(`No ${kind}s to update.`);
|
|
20393
20364
|
}
|
|
20394
|
-
for (const s of skipped)
|
|
20395
|
-
if (summary.missing > 0)
|
|
20365
|
+
for (const s of skipped) log.warn(`Skipped ${s}`);
|
|
20366
|
+
if (summary.missing > 0) log.info(`${summary.missing} ${kind}(s) not installed \u2014 run \`kaddo add ${kind}s\` to add them.`);
|
|
20396
20367
|
printCommandFooter(`${kind}s status`);
|
|
20397
|
-
|
|
20368
|
+
outro(`${LABEL[kind]} update complete.`);
|
|
20398
20369
|
}
|
|
20399
20370
|
|
|
20400
20371
|
// src/commands/ready.ts
|
|
@@ -20448,8 +20419,8 @@ function extractSection(body, headerPattern) {
|
|
|
20448
20419
|
}
|
|
20449
20420
|
return capture ? result.join("\n").trim() : null;
|
|
20450
20421
|
}
|
|
20451
|
-
function isResolvedSection(
|
|
20452
|
-
const t =
|
|
20422
|
+
function isResolvedSection(text2) {
|
|
20423
|
+
const t = text2.trim().toLowerCase();
|
|
20453
20424
|
return t === "" || /^(none|ninguna|resolved|resueltas|deferred|diferidas)\.?$/i.test(t);
|
|
20454
20425
|
}
|
|
20455
20426
|
function transitionToReady(filePath) {
|
|
@@ -20475,58 +20446,58 @@ function findWorkItem(dir, id) {
|
|
|
20475
20446
|
}
|
|
20476
20447
|
async function runReady(id, opts = {}) {
|
|
20477
20448
|
const dir = process.cwd();
|
|
20478
|
-
|
|
20449
|
+
intro("kaddo ready " + id);
|
|
20479
20450
|
const config = loadConfig(dir);
|
|
20480
20451
|
if (!config) {
|
|
20481
|
-
|
|
20452
|
+
log.error("Kaddo is not initialized. Run `kaddo init` first.");
|
|
20482
20453
|
process.exit(1);
|
|
20483
20454
|
}
|
|
20484
20455
|
const wi = findWorkItem(dir, id);
|
|
20485
20456
|
if (!wi) {
|
|
20486
|
-
|
|
20487
|
-
|
|
20457
|
+
log.error(`Work Item ${id} not found.`);
|
|
20458
|
+
log.info("Run `kaddo history` or check knowledge/delivery/work-items/ for available IDs.");
|
|
20488
20459
|
process.exit(1);
|
|
20489
20460
|
}
|
|
20490
20461
|
if (wi.lifecycle === "ready") {
|
|
20491
|
-
|
|
20492
|
-
|
|
20493
|
-
|
|
20462
|
+
log.info(`Work Item ${wi.id} is already ready.`);
|
|
20463
|
+
log.info("Suggested next: kaddo context && kaddo understand");
|
|
20464
|
+
outro("Nothing to do.");
|
|
20494
20465
|
return;
|
|
20495
20466
|
}
|
|
20496
20467
|
if (wi.lifecycle !== "draft") {
|
|
20497
|
-
|
|
20468
|
+
log.error(`Work Item ${wi.id} is in state "${wi.lifecycle}", not "draft". Only draft Work Items can be marked as ready.`);
|
|
20498
20469
|
process.exit(1);
|
|
20499
20470
|
}
|
|
20500
20471
|
const raw = readFile(wi.filePath);
|
|
20501
20472
|
const { data } = matter13(raw);
|
|
20502
20473
|
const source = parseWorkItemSource(data);
|
|
20503
20474
|
const warnings = validateReadiness(raw, data);
|
|
20504
|
-
|
|
20505
|
-
|
|
20506
|
-
|
|
20507
|
-
|
|
20508
|
-
|
|
20509
|
-
|
|
20510
|
-
|
|
20511
|
-
|
|
20475
|
+
log.info(`Work Item found:`);
|
|
20476
|
+
log.info(` ${wi.id} \u2014 ${wi.title}`);
|
|
20477
|
+
log.info("");
|
|
20478
|
+
log.info(` Status: draft \u2192 ready`);
|
|
20479
|
+
log.info(` Type: ${wi.type}`);
|
|
20480
|
+
log.info(` Knowledge level: ${wi.knowledgeLevel || "unset"}`);
|
|
20481
|
+
log.info(` Domains: ${wi.domains.length > 0 ? wi.domains.join(", ") : "none"}`);
|
|
20482
|
+
log.info(` Source: ${renderSourceCompact(source)}`);
|
|
20512
20483
|
if (wi.codeGlobs.length > 0) {
|
|
20513
|
-
|
|
20514
|
-
for (const g of wi.codeGlobs)
|
|
20484
|
+
log.info(` Code ownership:`);
|
|
20485
|
+
for (const g of wi.codeGlobs) log.info(` - ${g}`);
|
|
20515
20486
|
} else {
|
|
20516
|
-
|
|
20487
|
+
log.info(` Code ownership: none`);
|
|
20517
20488
|
}
|
|
20518
20489
|
if (warnings.length > 0) {
|
|
20519
|
-
|
|
20520
|
-
|
|
20490
|
+
log.warn("");
|
|
20491
|
+
log.warn("This Work Item may not be ready:");
|
|
20521
20492
|
for (const w of warnings) {
|
|
20522
|
-
|
|
20493
|
+
log.warn(` - ${w.message}`);
|
|
20523
20494
|
}
|
|
20524
20495
|
}
|
|
20525
20496
|
if (!opts.yes) {
|
|
20526
|
-
|
|
20527
|
-
const proceed = await
|
|
20497
|
+
log.info("");
|
|
20498
|
+
const proceed = await confirm({ message: "Mark this Work Item as ready for implementation?" });
|
|
20528
20499
|
if (!proceed) {
|
|
20529
|
-
|
|
20500
|
+
cancel("Cancelled.");
|
|
20530
20501
|
return;
|
|
20531
20502
|
}
|
|
20532
20503
|
}
|
|
@@ -20534,17 +20505,17 @@ async function runReady(id, opts = {}) {
|
|
|
20534
20505
|
if (newPath !== wi.filePath) {
|
|
20535
20506
|
writeFile(newPath, newContent);
|
|
20536
20507
|
fs6.unlinkSync(wi.filePath);
|
|
20537
|
-
|
|
20538
|
-
|
|
20539
|
-
|
|
20540
|
-
|
|
20508
|
+
log.success(`Updated status: ready`);
|
|
20509
|
+
log.success(`Moved file:`);
|
|
20510
|
+
log.info(` ${path9.relative(dir, wi.filePath)}`);
|
|
20511
|
+
log.info(` \u2192 ${path9.relative(dir, newPath)}`);
|
|
20541
20512
|
} else {
|
|
20542
20513
|
writeFile(wi.filePath, newContent);
|
|
20543
|
-
|
|
20514
|
+
log.success(`Updated status: ready`);
|
|
20544
20515
|
}
|
|
20545
|
-
|
|
20546
|
-
|
|
20547
|
-
|
|
20516
|
+
log.info("");
|
|
20517
|
+
log.info("Run `kaddo context && kaddo understand` to refresh the handoff.");
|
|
20518
|
+
outro(`Work Item ${wi.id} is ready.`);
|
|
20548
20519
|
}
|
|
20549
20520
|
|
|
20550
20521
|
// src/commands/admin.ts
|
|
@@ -20829,8 +20800,8 @@ function splitSections(body) {
|
|
|
20829
20800
|
flush2();
|
|
20830
20801
|
return sections;
|
|
20831
20802
|
}
|
|
20832
|
-
function isPlaceholder(
|
|
20833
|
-
const t =
|
|
20803
|
+
function isPlaceholder(text2) {
|
|
20804
|
+
const t = text2.trim();
|
|
20834
20805
|
if (!t) return true;
|
|
20835
20806
|
if (/^tbd$/i.test(t)) return true;
|
|
20836
20807
|
if (/^_[^_]*_$/.test(t) && !t.includes("\n")) return true;
|
|
@@ -20857,15 +20828,15 @@ function extractBullets(body) {
|
|
|
20857
20828
|
for (const line of body.split(/\r?\n/)) {
|
|
20858
20829
|
const m = line.match(/^\s*[-*+]\s+(.*)$/);
|
|
20859
20830
|
if (!m) continue;
|
|
20860
|
-
let
|
|
20831
|
+
let text2 = m[1].trim();
|
|
20861
20832
|
let checked = null;
|
|
20862
|
-
const cb =
|
|
20833
|
+
const cb = text2.match(/^\[([ xX])\]\s*(.*)$/);
|
|
20863
20834
|
if (cb) {
|
|
20864
20835
|
checked = cb[1].toLowerCase() === "x";
|
|
20865
|
-
|
|
20836
|
+
text2 = cb[2].trim();
|
|
20866
20837
|
}
|
|
20867
|
-
if (!
|
|
20868
|
-
out.push({ text:
|
|
20838
|
+
if (!text2 || isPlaceholder(text2)) continue;
|
|
20839
|
+
out.push({ text: text2, checked });
|
|
20869
20840
|
}
|
|
20870
20841
|
return out;
|
|
20871
20842
|
}
|
|
@@ -21484,7 +21455,7 @@ var ImportError = class extends Error {
|
|
|
21484
21455
|
// src/commands/work-item.ts
|
|
21485
21456
|
function requireProject3(dir) {
|
|
21486
21457
|
if (!loadConfig(dir)) {
|
|
21487
|
-
|
|
21458
|
+
log.error("No Kaddo project was found in the current directory.");
|
|
21488
21459
|
process.exit(1);
|
|
21489
21460
|
}
|
|
21490
21461
|
}
|
|
@@ -21495,12 +21466,12 @@ async function runWorkItemImport(dir, fileOrText, opts) {
|
|
|
21495
21466
|
content = opts.text;
|
|
21496
21467
|
} else if (fileOrText) {
|
|
21497
21468
|
if (!exists(fileOrText)) {
|
|
21498
|
-
|
|
21469
|
+
log.error(`File not found: ${fileOrText}`);
|
|
21499
21470
|
process.exit(1);
|
|
21500
21471
|
}
|
|
21501
21472
|
content = readFile(fileOrText) ?? void 0;
|
|
21502
21473
|
if (!content?.trim()) {
|
|
21503
|
-
|
|
21474
|
+
log.error(`File is empty: ${fileOrText}`);
|
|
21504
21475
|
process.exit(1);
|
|
21505
21476
|
}
|
|
21506
21477
|
} else if (!process.stdin.isTTY) {
|
|
@@ -21509,28 +21480,28 @@ async function runWorkItemImport(dir, fileOrText, opts) {
|
|
|
21509
21480
|
content = Buffer.concat(chunks).toString("utf-8");
|
|
21510
21481
|
}
|
|
21511
21482
|
if (!content?.trim()) {
|
|
21512
|
-
|
|
21483
|
+
log.error("No content provided. Use a file path, --text, or pipe content via stdin.");
|
|
21513
21484
|
process.exit(1);
|
|
21514
21485
|
}
|
|
21515
21486
|
try {
|
|
21516
|
-
|
|
21487
|
+
intro("Import external Work Item");
|
|
21517
21488
|
const parsed = parseContent(content);
|
|
21518
21489
|
const hash = computeContentHash(content);
|
|
21519
21490
|
const duplicate = findDuplicateByHash(dir, hash);
|
|
21520
21491
|
if (duplicate) {
|
|
21521
|
-
|
|
21522
|
-
|
|
21492
|
+
log.warn(`Already imported as ${duplicate.workItemId}.`);
|
|
21493
|
+
outro("No duplicate was created.");
|
|
21523
21494
|
return;
|
|
21524
21495
|
}
|
|
21525
|
-
|
|
21526
|
-
|
|
21527
|
-
|
|
21528
|
-
|
|
21529
|
-
|
|
21496
|
+
log.info(`Format: ${parsed.format}`);
|
|
21497
|
+
log.info(`Title: ${parsed.title}`);
|
|
21498
|
+
log.message(`Type: ${opts.type ?? parsed.type ?? "feature"}`);
|
|
21499
|
+
log.message("Will create: a Draft Work Item (needs refinement).");
|
|
21500
|
+
log.message("No project files have been modified yet.");
|
|
21530
21501
|
if (!opts.yes) {
|
|
21531
|
-
const ok = await
|
|
21502
|
+
const ok = await confirm({ message: "Import this content as a Draft Work Item?" });
|
|
21532
21503
|
if (ok !== true) {
|
|
21533
|
-
|
|
21504
|
+
cancel("Import cancelled. No files were changed.");
|
|
21534
21505
|
process.exit(0);
|
|
21535
21506
|
}
|
|
21536
21507
|
}
|
|
@@ -21542,8 +21513,8 @@ async function runWorkItemImport(dir, fileOrText, opts) {
|
|
|
21542
21513
|
});
|
|
21543
21514
|
if (result.conflict) {
|
|
21544
21515
|
const { importedId, existingPath } = result.conflict;
|
|
21545
|
-
|
|
21546
|
-
const resolution = await
|
|
21516
|
+
log.warn(`The imported content has id "${importedId}" which already exists at ${existingPath}.`);
|
|
21517
|
+
const resolution = await select({
|
|
21547
21518
|
message: `How should Kaddo handle this conflict?`,
|
|
21548
21519
|
options: [
|
|
21549
21520
|
{ value: "new-id", label: "Assign a new consecutive ID", hint: "keeps the existing Work Item intact" },
|
|
@@ -21560,30 +21531,30 @@ async function runWorkItemImport(dir, fileOrText, opts) {
|
|
|
21560
21531
|
}
|
|
21561
21532
|
if (!result.created) {
|
|
21562
21533
|
if (result.duplicateOf) {
|
|
21563
|
-
|
|
21564
|
-
|
|
21534
|
+
log.warn(`Already imported as ${result.duplicateOf}.`);
|
|
21535
|
+
outro("No duplicate was created.");
|
|
21565
21536
|
}
|
|
21566
21537
|
return;
|
|
21567
21538
|
}
|
|
21568
|
-
|
|
21569
|
-
|
|
21539
|
+
log.info(`Created ${result.workItemId} (Draft, needs refinement).`);
|
|
21540
|
+
log.info(`Path: ${result.path}`);
|
|
21570
21541
|
if (result.replacedWorkItem) {
|
|
21571
|
-
|
|
21542
|
+
log.warn(`Replaced existing Work Item ${result.replacedWorkItem}.`);
|
|
21572
21543
|
}
|
|
21573
21544
|
if (result.discardedFields?.length) {
|
|
21574
|
-
|
|
21575
|
-
|
|
21545
|
+
log.warn(`Lifecycle fields discarded from import: ${result.discardedFields.join(", ")}`);
|
|
21546
|
+
log.message("Kaddo always generates its own id and status \u2014 external values are ignored.");
|
|
21576
21547
|
}
|
|
21577
|
-
|
|
21548
|
+
log.message("executed = false \u2014 the Work Item has NOT been implemented.");
|
|
21578
21549
|
if (result.refinementHandoff) {
|
|
21579
|
-
|
|
21580
|
-
|
|
21581
|
-
|
|
21550
|
+
log.step("Refinement handoff");
|
|
21551
|
+
log.message(`Agent: ${result.refinementHandoff.recommendedAgent}`);
|
|
21552
|
+
log.message(`Skill: ${result.refinementHandoff.recommendedSkill}`);
|
|
21582
21553
|
}
|
|
21583
|
-
|
|
21554
|
+
outro("Done. Refine it next with the Work Item refinement handoff.");
|
|
21584
21555
|
} catch (err) {
|
|
21585
|
-
if (err instanceof ImportError)
|
|
21586
|
-
else
|
|
21556
|
+
if (err instanceof ImportError) log.error(`[${err.code}] ${err.message}`);
|
|
21557
|
+
else log.error("The import operation failed.");
|
|
21587
21558
|
process.exit(1);
|
|
21588
21559
|
}
|
|
21589
21560
|
}
|
|
@@ -21613,7 +21584,7 @@ var SECRET_PATTERNS = [
|
|
|
21613
21584
|
/\.pfx$/i
|
|
21614
21585
|
];
|
|
21615
21586
|
function filterSecretPaths(paths) {
|
|
21616
|
-
return paths.filter((
|
|
21587
|
+
return paths.filter((p) => !SECRET_PATTERNS.some((re) => re.test(p)));
|
|
21617
21588
|
}
|
|
21618
21589
|
function collectImplementationEvidence(dir, workItemId, input) {
|
|
21619
21590
|
const artifacts = discoverWorkItems(dir);
|
|
@@ -21829,9 +21800,9 @@ function extractACsFromBody(body) {
|
|
|
21829
21800
|
if (inAC) {
|
|
21830
21801
|
const m = line.match(/^\s*[-*+]\s+(?:\[[ xX]\]\s*)?(.+)$/);
|
|
21831
21802
|
if (m) {
|
|
21832
|
-
const
|
|
21833
|
-
if (
|
|
21834
|
-
acs.push(
|
|
21803
|
+
const text2 = m[1].trim();
|
|
21804
|
+
if (text2 && !/^_.*_$/.test(text2) && !/^tbd$/i.test(text2)) {
|
|
21805
|
+
acs.push(text2);
|
|
21835
21806
|
}
|
|
21836
21807
|
}
|
|
21837
21808
|
}
|
|
@@ -21844,14 +21815,14 @@ async function runVerify(workItemId, opts = {}) {
|
|
|
21844
21815
|
console.error("No knowledge/ directory found. Run `kaddo init` first.");
|
|
21845
21816
|
process.exit(1);
|
|
21846
21817
|
}
|
|
21847
|
-
if (!opts.json)
|
|
21818
|
+
if (!opts.json) intro("kaddo verify");
|
|
21848
21819
|
const artifacts = discoverWorkItems(dir);
|
|
21849
21820
|
const match = artifacts.find((a) => (a.id || a.title) === workItemId);
|
|
21850
21821
|
if (!match) {
|
|
21851
21822
|
if (opts.json) {
|
|
21852
21823
|
console.log(JSON.stringify({ error: `Work Item "${workItemId}" not found.` }));
|
|
21853
21824
|
} else {
|
|
21854
|
-
|
|
21825
|
+
log.error(`Work Item "${workItemId}" not found.`);
|
|
21855
21826
|
}
|
|
21856
21827
|
process.exit(1);
|
|
21857
21828
|
}
|
|
@@ -21860,7 +21831,7 @@ async function runVerify(workItemId, opts = {}) {
|
|
|
21860
21831
|
if (opts.json) {
|
|
21861
21832
|
console.log(JSON.stringify({ error: `Work Item "${workItemId}" is "${lifecycle}", expected "in-progress".` }));
|
|
21862
21833
|
} else {
|
|
21863
|
-
|
|
21834
|
+
log.error(`Work Item "${workItemId}" is "${lifecycle}". Only in-progress Work Items can be verified.`);
|
|
21864
21835
|
}
|
|
21865
21836
|
process.exit(1);
|
|
21866
21837
|
}
|
|
@@ -21906,7 +21877,7 @@ async function runVerify(workItemId, opts = {}) {
|
|
|
21906
21877
|
if (opts.json) {
|
|
21907
21878
|
console.log(JSON.stringify({ error: e.message }));
|
|
21908
21879
|
} else {
|
|
21909
|
-
|
|
21880
|
+
log.error(e.message);
|
|
21910
21881
|
}
|
|
21911
21882
|
process.exit(1);
|
|
21912
21883
|
}
|
|
@@ -21917,10 +21888,10 @@ async function runVerify(workItemId, opts = {}) {
|
|
|
21917
21888
|
console.log(JSON.stringify({ verification, evaluation }, null, 2));
|
|
21918
21889
|
return;
|
|
21919
21890
|
}
|
|
21920
|
-
|
|
21921
|
-
|
|
21922
|
-
|
|
21923
|
-
|
|
21891
|
+
log.info(`Work Item: ${workItemId}`);
|
|
21892
|
+
log.info(`Lifecycle: ${verification.lifecycle}`);
|
|
21893
|
+
log.info(`Implementation: ${verification.implementationStatus}`);
|
|
21894
|
+
log.info(`Validation: ${verification.validationStatus}`);
|
|
21924
21895
|
console.log("");
|
|
21925
21896
|
if (verification.acVerifications.length > 0) {
|
|
21926
21897
|
console.log("Acceptance Criteria:");
|
|
@@ -21976,7 +21947,7 @@ async function runVerify(workItemId, opts = {}) {
|
|
|
21976
21947
|
for (const w of evaluation.warnings) console.log(` ! ${w}`);
|
|
21977
21948
|
}
|
|
21978
21949
|
console.log("");
|
|
21979
|
-
const shouldPersist = opts.yes || await
|
|
21950
|
+
const shouldPersist = opts.yes || await confirm({
|
|
21980
21951
|
message: "Update Work Item frontmatter with verification evidence?",
|
|
21981
21952
|
initialValue: true
|
|
21982
21953
|
});
|
|
@@ -21991,9 +21962,9 @@ async function runVerify(workItemId, opts = {}) {
|
|
|
21991
21962
|
data.verified_at = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
21992
21963
|
const newRaw = matter16.stringify(wiParsed.content, data);
|
|
21993
21964
|
writeFile(filePath, newRaw);
|
|
21994
|
-
|
|
21965
|
+
log.success("Work Item frontmatter updated with verification evidence.");
|
|
21995
21966
|
}
|
|
21996
|
-
if (!opts.json)
|
|
21967
|
+
if (!opts.json) outro("Verification complete.");
|
|
21997
21968
|
}
|
|
21998
21969
|
|
|
21999
21970
|
// src/core/telemetry.ts
|
|
@@ -22007,10 +21978,10 @@ function identityPath(dir) {
|
|
|
22007
21978
|
return join(dir, TELEMETRY_DIR, IDENTITY_FILE);
|
|
22008
21979
|
}
|
|
22009
21980
|
function loadIdentity(dir) {
|
|
22010
|
-
const
|
|
22011
|
-
if (!exists(
|
|
21981
|
+
const p = identityPath(dir);
|
|
21982
|
+
if (!exists(p)) return null;
|
|
22012
21983
|
try {
|
|
22013
|
-
return JSON.parse(readFile(
|
|
21984
|
+
return JSON.parse(readFile(p));
|
|
22014
21985
|
} catch {
|
|
22015
21986
|
return null;
|
|
22016
21987
|
}
|
|
@@ -22074,10 +22045,10 @@ function bufferPath(dir) {
|
|
|
22074
22045
|
return join(dir, TELEMETRY_DIR2, BUFFER_FILE);
|
|
22075
22046
|
}
|
|
22076
22047
|
function readBuffer(dir) {
|
|
22077
|
-
const
|
|
22078
|
-
if (!exists(
|
|
22048
|
+
const p = bufferPath(dir);
|
|
22049
|
+
if (!exists(p)) return [];
|
|
22079
22050
|
try {
|
|
22080
|
-
const data = JSON.parse(readFile(
|
|
22051
|
+
const data = JSON.parse(readFile(p));
|
|
22081
22052
|
return Array.isArray(data) ? data : [];
|
|
22082
22053
|
} catch {
|
|
22083
22054
|
return [];
|
|
@@ -22090,13 +22061,56 @@ function enqueue(dir, events) {
|
|
|
22090
22061
|
writeFile(bufferPath(dir), JSON.stringify(combined, null, 2));
|
|
22091
22062
|
}
|
|
22092
22063
|
function clearBuffer(dir) {
|
|
22093
|
-
const
|
|
22094
|
-
if (exists(
|
|
22064
|
+
const p = bufferPath(dir);
|
|
22065
|
+
if (exists(p)) writeFile(p, "[]");
|
|
22095
22066
|
}
|
|
22096
22067
|
function bufferSize(dir) {
|
|
22097
22068
|
return readBuffer(dir).length;
|
|
22098
22069
|
}
|
|
22099
22070
|
|
|
22071
|
+
// src/core/telemetry-consent.ts
|
|
22072
|
+
import { parse as parseYaml19, stringify as stringifyYaml9 } from "yaml";
|
|
22073
|
+
var CURRENT_CONSENT_VERSION = 1;
|
|
22074
|
+
function getConsentState(config) {
|
|
22075
|
+
if (!config) return "unset";
|
|
22076
|
+
const t = config.telemetry;
|
|
22077
|
+
if (!t) return "unset";
|
|
22078
|
+
if (t.consent === "enabled") return "enabled";
|
|
22079
|
+
if (t.consent === "disabled") return "disabled";
|
|
22080
|
+
if (t.consent === void 0) {
|
|
22081
|
+
if (t.enabled === true) return "enabled";
|
|
22082
|
+
if (t.enabled === false) return "disabled";
|
|
22083
|
+
}
|
|
22084
|
+
return "unset";
|
|
22085
|
+
}
|
|
22086
|
+
function isInteractive() {
|
|
22087
|
+
if (process.env.CI) return false;
|
|
22088
|
+
if (!process.stdin.isTTY) return false;
|
|
22089
|
+
if (!process.stdout.isTTY) return false;
|
|
22090
|
+
return true;
|
|
22091
|
+
}
|
|
22092
|
+
function persistConsent(dir, consent) {
|
|
22093
|
+
const configPath = join(dir, ".kaddo", "config.yml");
|
|
22094
|
+
if (!exists(configPath)) return;
|
|
22095
|
+
const raw = readFile(configPath);
|
|
22096
|
+
const doc = parseYaml19(raw) ?? {};
|
|
22097
|
+
const prev = doc.telemetry ?? {};
|
|
22098
|
+
delete prev.enabled;
|
|
22099
|
+
doc.telemetry = { ...prev, consent, consentVersion: CURRENT_CONSENT_VERSION };
|
|
22100
|
+
writeFile(configPath, stringifyYaml9(doc));
|
|
22101
|
+
}
|
|
22102
|
+
async function ensureTelemetryConsent(dir, config) {
|
|
22103
|
+
const state = getConsentState(config);
|
|
22104
|
+
if (state !== "unset") return;
|
|
22105
|
+
if (!isInteractive()) return;
|
|
22106
|
+
const { confirm: confirm2 } = await import("./ui-PS2ZLJWL.js");
|
|
22107
|
+
const accepted = await confirm2({
|
|
22108
|
+
message: "Help improve Kaddo by sharing anonymous usage telemetry?\n Collects: command usage, version, lifecycle events.\n Never collects: source code, knowledge, prompts or PII.\n Change anytime: kaddo telemetry enable/disable",
|
|
22109
|
+
initialValue: false
|
|
22110
|
+
});
|
|
22111
|
+
persistConsent(dir, accepted ? "enabled" : "disabled");
|
|
22112
|
+
}
|
|
22113
|
+
|
|
22100
22114
|
// src/core/telemetry.ts
|
|
22101
22115
|
var TELEMETRY_ENDPOINT = "https://telemetry.kaddo.org";
|
|
22102
22116
|
var EVENTS_PATH = "/v1/events";
|
|
@@ -22104,15 +22118,15 @@ var REGISTRATION_PATH = "/v1/installations";
|
|
|
22104
22118
|
var REQUEST_TIMEOUT_MS = 5e3;
|
|
22105
22119
|
var MAX_BATCH_SIZE = 25;
|
|
22106
22120
|
function isEnabled(config) {
|
|
22107
|
-
|
|
22108
|
-
const t = config.telemetry;
|
|
22109
|
-
return t?.enabled === true;
|
|
22121
|
+
return getConsentState(config) === "enabled";
|
|
22110
22122
|
}
|
|
22111
22123
|
function getStatus(dir) {
|
|
22112
22124
|
const config = loadConfig(dir);
|
|
22113
|
-
const
|
|
22125
|
+
const consent = getConsentState(config);
|
|
22126
|
+
const enabled = consent === "enabled";
|
|
22114
22127
|
const identity = loadIdentity(dir);
|
|
22115
22128
|
return {
|
|
22129
|
+
consent,
|
|
22116
22130
|
enabled,
|
|
22117
22131
|
registered: identity?.registered ?? false,
|
|
22118
22132
|
pendingEvents: enabled ? bufferSize(dir) : 0,
|
|
@@ -22129,8 +22143,8 @@ async function httpPost(url, body, headers) {
|
|
|
22129
22143
|
body,
|
|
22130
22144
|
signal: controller.signal
|
|
22131
22145
|
});
|
|
22132
|
-
const
|
|
22133
|
-
return { status: res.status, body:
|
|
22146
|
+
const text2 = await res.text();
|
|
22147
|
+
return { status: res.status, body: text2 };
|
|
22134
22148
|
} finally {
|
|
22135
22149
|
clearTimeout(timeout);
|
|
22136
22150
|
}
|
|
@@ -22230,52 +22244,40 @@ async function flush(dir) {
|
|
|
22230
22244
|
}
|
|
22231
22245
|
|
|
22232
22246
|
// src/commands/telemetry.ts
|
|
22233
|
-
import { parse as parseYaml19, stringify as stringifyYaml9 } from "yaml";
|
|
22234
22247
|
function runTelemetryStatus() {
|
|
22235
22248
|
const dir = process.cwd();
|
|
22236
|
-
|
|
22249
|
+
intro("kaddo telemetry status");
|
|
22237
22250
|
const config = loadConfig(dir);
|
|
22238
22251
|
if (!config) {
|
|
22239
|
-
|
|
22252
|
+
log.error("Kaddo is not initialized. Run `kaddo init` first.");
|
|
22240
22253
|
process.exit(1);
|
|
22241
22254
|
}
|
|
22242
22255
|
const status = getStatus(dir);
|
|
22243
|
-
|
|
22244
|
-
|
|
22245
|
-
|
|
22246
|
-
if (
|
|
22247
|
-
|
|
22248
|
-
|
|
22256
|
+
log.info(` Consent: ${status.consent}`);
|
|
22257
|
+
log.info(` Registered: ${status.registered}`);
|
|
22258
|
+
log.info(` Pending events: ${status.pendingEvents}`);
|
|
22259
|
+
if (status.consent === "unset") {
|
|
22260
|
+
log.info("");
|
|
22261
|
+
log.info("Enable with: kaddo telemetry enable");
|
|
22249
22262
|
}
|
|
22250
|
-
|
|
22263
|
+
outro("Telemetry status.");
|
|
22251
22264
|
}
|
|
22252
22265
|
function runTelemetryEnable() {
|
|
22253
22266
|
const dir = process.cwd();
|
|
22254
|
-
|
|
22255
|
-
|
|
22256
|
-
|
|
22257
|
-
|
|
22258
|
-
|
|
22259
|
-
|
|
22267
|
+
intro("kaddo telemetry enable");
|
|
22268
|
+
persistConsent(dir, "enabled");
|
|
22269
|
+
log.success("Telemetry enabled.");
|
|
22270
|
+
log.info("Kaddo will send anonymous usage metadata to telemetry.kaddo.org.");
|
|
22271
|
+
log.info("No project content, source code, prompts or PII is ever transmitted.");
|
|
22272
|
+
outro("Run `kaddo telemetry status` to check the current state.");
|
|
22260
22273
|
}
|
|
22261
22274
|
function runTelemetryDisable() {
|
|
22262
22275
|
const dir = process.cwd();
|
|
22263
|
-
|
|
22264
|
-
|
|
22265
|
-
|
|
22266
|
-
|
|
22267
|
-
|
|
22268
|
-
}
|
|
22269
|
-
function setTelemetryEnabled(dir, enabled) {
|
|
22270
|
-
const configPath = join(dir, ".kaddo", "config.yml");
|
|
22271
|
-
if (!exists(configPath)) {
|
|
22272
|
-
log2.error("Kaddo is not initialized. Run `kaddo init` first.");
|
|
22273
|
-
process.exit(1);
|
|
22274
|
-
}
|
|
22275
|
-
const raw = readFile(configPath);
|
|
22276
|
-
const doc = parseYaml19(raw) ?? {};
|
|
22277
|
-
doc.telemetry = { ...doc.telemetry ?? {}, enabled };
|
|
22278
|
-
writeFile(configPath, stringifyYaml9(doc));
|
|
22276
|
+
intro("kaddo telemetry disable");
|
|
22277
|
+
persistConsent(dir, "disabled");
|
|
22278
|
+
log.success("Telemetry disabled.");
|
|
22279
|
+
log.info("No telemetry requests will be made.");
|
|
22280
|
+
outro("Run `kaddo telemetry enable` to re-enable.");
|
|
22279
22281
|
}
|
|
22280
22282
|
|
|
22281
22283
|
// src/index.ts
|
|
@@ -22478,6 +22480,18 @@ var CAPSULE_EVENTS = {
|
|
|
22478
22480
|
export: "capsule_exported",
|
|
22479
22481
|
add: "capsule_imported"
|
|
22480
22482
|
};
|
|
22483
|
+
var CONSENT_SKIP_COMMANDS = /* @__PURE__ */ new Set(["status", "enable", "disable"]);
|
|
22484
|
+
program.hook("preAction", async (_thisCommand, actionCommand) => {
|
|
22485
|
+
const name = actionCommand.name();
|
|
22486
|
+
const parent = actionCommand.parent?.name();
|
|
22487
|
+
if (parent === "telemetry" && CONSENT_SKIP_COMMANDS.has(name)) return;
|
|
22488
|
+
try {
|
|
22489
|
+
const dir = cwd();
|
|
22490
|
+
const config = loadConfig(dir);
|
|
22491
|
+
if (config) await ensureTelemetryConsent(dir, config);
|
|
22492
|
+
} catch {
|
|
22493
|
+
}
|
|
22494
|
+
});
|
|
22481
22495
|
var commandStart = Date.now();
|
|
22482
22496
|
program.hook("postAction", (_thisCommand, actionCommand) => {
|
|
22483
22497
|
const name = actionCommand.name();
|