@kaddo/cli 3.27.1 → 3.27.2
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/README.md +1 -0
- package/dist/index.js +138 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -519,6 +519,7 @@ create --from roadmap → owners → guard → explain`.
|
|
|
519
519
|
| v3.26 | Open-questions readiness gate: `kaddo questions`/`readiness`, blocking/important/deferred classification; MCP open-questions + roadmap-readiness resources + tool; roadmap/work-item/implementation/bootstrap agents check it |
|
|
520
520
|
| v3.27 | Codex adapter: `kaddo adapters install codex` (alias `kaddo export codex`) generates a compact `AGENTS.md` projection (`--dry-run`/`--force`) |
|
|
521
521
|
| v3.27.1 | Codex adapter command fallbacks: AGENTS.md tells Codex to try `corepack pnpm exec` / `pnpm exec` / `npx` kaddo when the global binary isn't on PATH |
|
|
522
|
+
| v3.27.2 | Codex adapter safe merge: `kaddo adapters install codex --inject` adds/updates only a delimited Kaddo block in an existing AGENTS.md, preserving team content |
|
|
522
523
|
|
|
523
524
|
**Optional modules (installed with `kaddo add`):**
|
|
524
525
|
|
package/dist/index.js
CHANGED
|
@@ -12493,6 +12493,94 @@ function renderAgentsMd(ctx) {
|
|
|
12493
12493
|
L.push("");
|
|
12494
12494
|
return L.join("\n");
|
|
12495
12495
|
}
|
|
12496
|
+
var KADDO_BEGIN_MARKER = "<!-- BEGIN KADDO CODEX ADAPTER -->";
|
|
12497
|
+
var KADDO_END_MARKER = "<!-- END KADDO CODEX ADAPTER -->";
|
|
12498
|
+
var GENERATED_HEADER = "Generated by `kaddo adapters install codex`";
|
|
12499
|
+
function detectAgentsState(content) {
|
|
12500
|
+
if (content === null) return "missing";
|
|
12501
|
+
const hasBegin = content.includes(KADDO_BEGIN_MARKER);
|
|
12502
|
+
const hasEnd = content.includes(KADDO_END_MARKER);
|
|
12503
|
+
if (hasBegin !== hasEnd) return "invalid_kaddo_block";
|
|
12504
|
+
if (hasBegin && hasEnd) return "existing_with_kaddo_block";
|
|
12505
|
+
if (content.includes(GENERATED_HEADER)) return "generated_by_kaddo";
|
|
12506
|
+
return "existing_external";
|
|
12507
|
+
}
|
|
12508
|
+
function renderKaddoBlock(ctx) {
|
|
12509
|
+
const L = [];
|
|
12510
|
+
L.push(KADDO_BEGIN_MARKER, "");
|
|
12511
|
+
L.push("## Kaddo guidance", "");
|
|
12512
|
+
if (ctx.projectName) L.push(`Project: **${ctx.projectName}**${ctx.projectType ? ` (${ctx.projectType})` : ""}.`, "");
|
|
12513
|
+
L.push("This repository uses **Kaddo** for Knowledge Driven Development. Kaddo keeps business,");
|
|
12514
|
+
L.push("product, technical and delivery knowledge close to the code. Read the relevant Kaddo");
|
|
12515
|
+
L.push("knowledge before changing code.");
|
|
12516
|
+
L.push("");
|
|
12517
|
+
L.push("### Kaddo knowledge map", "");
|
|
12518
|
+
L.push("Primary knowledge:");
|
|
12519
|
+
for (const p2 of ctx.knowledgePaths.length > 0 ? ctx.knowledgePaths : KNOWLEDGE_PATHS) L.push(`- \`${p2}\``);
|
|
12520
|
+
L.push("");
|
|
12521
|
+
L.push("Generated context (do not edit by hand):");
|
|
12522
|
+
for (const p2 of ctx.generatedPaths) L.push(`- \`${p2}\``);
|
|
12523
|
+
L.push("");
|
|
12524
|
+
L.push("### Kaddo operating rules", "");
|
|
12525
|
+
L.push("- Do not generate a roadmap without checking open-questions readiness.");
|
|
12526
|
+
L.push("- Do not implement without reading the active Work Item.");
|
|
12527
|
+
L.push("- Do not implement outside the scope of the active Work Item unless the user confirms.");
|
|
12528
|
+
L.push("- Do not modify `.kaddo/` manually; it is generated output.");
|
|
12529
|
+
L.push("- Do not commit without user confirmation.");
|
|
12530
|
+
L.push("");
|
|
12531
|
+
L.push("### Command fallback", "");
|
|
12532
|
+
L.push("Prefer `kaddo <command>`. If the global `kaddo` is not on `PATH`, try the local runner");
|
|
12533
|
+
L.push("before reporting Kaddo is unavailable:");
|
|
12534
|
+
L.push("```bash");
|
|
12535
|
+
L.push("corepack pnpm exec kaddo <command>");
|
|
12536
|
+
L.push("pnpm exec kaddo <command>");
|
|
12537
|
+
L.push("npx kaddo <command>");
|
|
12538
|
+
L.push("```");
|
|
12539
|
+
L.push("Do not assume Kaddo is unavailable until these fallbacks have been attempted.");
|
|
12540
|
+
L.push("");
|
|
12541
|
+
L.push("### Before roadmap work", "");
|
|
12542
|
+
L.push("Check open-questions readiness first. If blocking open questions exist, ask the user to");
|
|
12543
|
+
L.push("resolve, assume or defer them before generating the roadmap.");
|
|
12544
|
+
L.push("");
|
|
12545
|
+
L.push("### Before implementation", "");
|
|
12546
|
+
L.push("Read the target Work Item in `knowledge/delivery/work-items/`, `.kaddo/context-pack.md`,");
|
|
12547
|
+
L.push("`.kaddo/understand.md`, and related knowledge and skills.");
|
|
12548
|
+
L.push("");
|
|
12549
|
+
L.push("### After implementation", "");
|
|
12550
|
+
L.push("Suggest running `kaddo guard`, `kaddo impact`, `kaddo savings` and `kaddo drift`. If guard");
|
|
12551
|
+
L.push("reports drift, explain it and ask before updating knowledge.");
|
|
12552
|
+
L.push("");
|
|
12553
|
+
if (ctx.hasAgents) {
|
|
12554
|
+
L.push(`### Kaddo agents`, "");
|
|
12555
|
+
L.push(`Installed under \`knowledge/agents/\`: ${ctx.agents.map((a) => `\`${a}\``).join(", ")}.`);
|
|
12556
|
+
L.push("");
|
|
12557
|
+
}
|
|
12558
|
+
if (ctx.hasSkills) {
|
|
12559
|
+
L.push(`### Kaddo skills`, "");
|
|
12560
|
+
L.push(`Installed under \`knowledge/skills/\`: ${ctx.skills.map((s) => `\`${s}\``).join(", ")}. Read only what's relevant.`);
|
|
12561
|
+
L.push("");
|
|
12562
|
+
}
|
|
12563
|
+
L.push(KADDO_END_MARKER);
|
|
12564
|
+
return L.join("\n");
|
|
12565
|
+
}
|
|
12566
|
+
function injectKaddoBlock(existing, ctx) {
|
|
12567
|
+
const block = renderKaddoBlock(ctx);
|
|
12568
|
+
const begin = existing.indexOf(KADDO_BEGIN_MARKER);
|
|
12569
|
+
const end = existing.indexOf(KADDO_END_MARKER);
|
|
12570
|
+
if (begin === -1 !== (end === -1)) {
|
|
12571
|
+
throw new Error("Invalid Kaddo adapter block: found one marker without its pair.");
|
|
12572
|
+
}
|
|
12573
|
+
if (begin !== -1 && end !== -1) {
|
|
12574
|
+
if (end < begin) throw new Error("Invalid Kaddo adapter block: END marker before BEGIN marker.");
|
|
12575
|
+
const before = existing.slice(0, begin);
|
|
12576
|
+
const after = existing.slice(end + KADDO_END_MARKER.length);
|
|
12577
|
+
return { content: `${before}${block}${after}`, status: "updated" };
|
|
12578
|
+
}
|
|
12579
|
+
const sep = existing.endsWith("\n") ? "\n" : "\n\n";
|
|
12580
|
+
return { content: `${existing.replace(/\s*$/, "")}
|
|
12581
|
+
${sep}${block}
|
|
12582
|
+
`, status: "injected" };
|
|
12583
|
+
}
|
|
12496
12584
|
|
|
12497
12585
|
// src/commands/adapters.ts
|
|
12498
12586
|
function runAdaptersInstall(adapter, opts = {}) {
|
|
@@ -12502,20 +12590,62 @@ function runAdaptersInstall(adapter, opts = {}) {
|
|
|
12502
12590
|
console.error(`Unknown adapter: "${adapter}". Available: codex.`);
|
|
12503
12591
|
process.exit(1);
|
|
12504
12592
|
}
|
|
12505
|
-
const
|
|
12593
|
+
const ctx = buildCodexAdapterContext(dir);
|
|
12594
|
+
const rel = "AGENTS.md";
|
|
12595
|
+
const full = join(dir, rel);
|
|
12596
|
+
const existed = exists(full);
|
|
12597
|
+
const existing = existed ? readFile(full) : null;
|
|
12598
|
+
if (opts.inject) {
|
|
12599
|
+
const state = detectAgentsState(existing);
|
|
12600
|
+
if (state === "invalid_kaddo_block") {
|
|
12601
|
+
console.error("Invalid Kaddo adapter block detected in AGENTS.md.");
|
|
12602
|
+
console.error("Found one marker without its pair. Fix the file manually or use --force to overwrite.");
|
|
12603
|
+
console.error("Nothing changed.");
|
|
12604
|
+
process.exit(1);
|
|
12605
|
+
}
|
|
12606
|
+
if (existing === null) {
|
|
12607
|
+
const content2 = renderAgentsMd(ctx);
|
|
12608
|
+
if (opts.dryRun) {
|
|
12609
|
+
console.log("# AGENTS.md preview", "");
|
|
12610
|
+
console.log(content2);
|
|
12611
|
+
return;
|
|
12612
|
+
}
|
|
12613
|
+
intro2("kaddo adapters install codex --inject");
|
|
12614
|
+
writeFile(full, content2);
|
|
12615
|
+
log2.success("Created AGENTS.md for Codex.");
|
|
12616
|
+
printCommandFooter("adapters install codex");
|
|
12617
|
+
outro2("AGENTS.md ready.");
|
|
12618
|
+
return;
|
|
12619
|
+
}
|
|
12620
|
+
const merged = injectKaddoBlock(existing, ctx);
|
|
12621
|
+
if (opts.dryRun) {
|
|
12622
|
+
console.log("# AGENTS.md preview (inject)", "");
|
|
12623
|
+
console.log(merged.content);
|
|
12624
|
+
return;
|
|
12625
|
+
}
|
|
12626
|
+
intro2("kaddo adapters install codex --inject");
|
|
12627
|
+
writeFile(full, merged.content);
|
|
12628
|
+
if (merged.status === "updated") {
|
|
12629
|
+
log2.success("Updated existing Kaddo guidance block in AGENTS.md.");
|
|
12630
|
+
} else {
|
|
12631
|
+
log2.success("Injected Kaddo guidance block into AGENTS.md.");
|
|
12632
|
+
}
|
|
12633
|
+
log2.info("Content outside the Kaddo markers was preserved.");
|
|
12634
|
+
printCommandFooter("adapters install codex");
|
|
12635
|
+
outro2("AGENTS.md ready.");
|
|
12636
|
+
return;
|
|
12637
|
+
}
|
|
12638
|
+
const content = renderAgentsMd(ctx);
|
|
12506
12639
|
if (opts.dryRun) {
|
|
12507
12640
|
console.log("# AGENTS.md preview", "");
|
|
12508
12641
|
console.log(content);
|
|
12509
12642
|
return;
|
|
12510
12643
|
}
|
|
12511
12644
|
intro2("kaddo adapters install codex");
|
|
12512
|
-
const rel = "AGENTS.md";
|
|
12513
|
-
const full = join(dir, rel);
|
|
12514
|
-
const existed = exists(full);
|
|
12515
12645
|
if (existed && !opts.force) {
|
|
12516
12646
|
log2.warn("AGENTS.md already exists.");
|
|
12517
|
-
log2.info("Use `
|
|
12518
|
-
log2.info("
|
|
12647
|
+
log2.info("Use `--inject` to add or update only the Kaddo block,");
|
|
12648
|
+
log2.info("`--force` to overwrite, or `--dry-run` to preview.");
|
|
12519
12649
|
outro2("Nothing changed.");
|
|
12520
12650
|
return;
|
|
12521
12651
|
}
|
|
@@ -12580,10 +12710,10 @@ var questionsAction = (opts) => runQuestions(opts);
|
|
|
12580
12710
|
program.command("questions").description("Open-questions readiness gate: blocking/important/deferred decisions before the roadmap").option("--json", "Output JSON instead of a summary").option("--output <path>", "Write the report to a file (e.g. .kaddo/reports/questions-report.md)").action(questionsAction);
|
|
12581
12711
|
program.command("readiness").description("Alias for `kaddo questions`").option("--json", "Output JSON instead of a summary").option("--output <path>", "Write the report to a file").action(questionsAction);
|
|
12582
12712
|
var adaptersCmd = program.command("adapters").description("Generate adapters that project Kaddo knowledge for external coding agents");
|
|
12583
|
-
adaptersCmd.command("install <adapter>").description("Generate an adapter file (codex \u2192 AGENTS.md) from Kaddo knowledge").option("--force", "Overwrite an existing output file").option("--dry-run", "Print the content without writing files").action((adapter, opts) => {
|
|
12713
|
+
adaptersCmd.command("install <adapter>").description("Generate an adapter file (codex \u2192 AGENTS.md) from Kaddo knowledge").option("--force", "Overwrite an existing output file").option("--inject", "Add or update only the Kaddo block in an existing file, preserving the rest").option("--dry-run", "Print the content without writing files").action((adapter, opts) => {
|
|
12584
12714
|
runAdaptersInstall(adapter, opts);
|
|
12585
12715
|
});
|
|
12586
|
-
program.command("export <adapter>").description("Alias for `kaddo adapters install <adapter>` (codex \u2192 AGENTS.md)").option("--force", "Overwrite an existing output file").option("--dry-run", "Print the content without writing files").action((adapter, opts) => {
|
|
12716
|
+
program.command("export <adapter>").description("Alias for `kaddo adapters install <adapter>` (codex \u2192 AGENTS.md)").option("--force", "Overwrite an existing output file").option("--inject", "Add or update only the Kaddo block in an existing file, preserving the rest").option("--dry-run", "Print the content without writing files").action((adapter, opts) => {
|
|
12587
12717
|
runAdaptersInstall(adapter, opts);
|
|
12588
12718
|
});
|
|
12589
12719
|
program.command("guard").description("Check if modified code has related artifacts that were not updated").option("--staged", "Check only staged files").option("--no-interactive", "Disable interactive ignore prompts").option("--ci", "CI mode: output JSON, no prompts, non-blocking").option("--json", "Output JSON (alias for --ci)").option("--workspace", "Also check local mapped module repos from .kaddo/modules.yml (opt-in)").option("--include-archived", "Include archived Work Items in ownership matching (excluded by default)").option("--record", "Record this run to .kaddo/history/ for drift trend reporting").action(async (opts) => {
|