@kaddo/cli 3.27.2 → 3.28.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.
Files changed (3) hide show
  1. package/README.md +2 -0
  2. package/dist/index.js +85 -63
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -520,6 +520,8 @@ create --from roadmap → owners → guard → explain`.
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
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 |
523
+ | v3.27.3 | Codex adapter reference stabilization: package-manager-aware command fallbacks (lockfile detection) + Adapter Contract & Custom Adapters docs (reference for future adapters) |
524
+ | v3.28 | Claude Code adapter: `kaddo adapters install claude` (alias `kaddo export claude`) generates a `CLAUDE.md` projection reusing the shared adapter common core (`--dry-run`/`--force`) |
523
525
 
524
526
  **Optional modules (installed with `kaddo add`):**
525
527
 
package/dist/index.js CHANGED
@@ -12337,6 +12337,7 @@ function buildCodexAdapterContext(dir) {
12337
12337
  projectName: config?.project.name,
12338
12338
  projectType: config?.project.state,
12339
12339
  language: config ? config.project.language : void 0,
12340
+ packageManager: detectPackageManager2(dir),
12340
12341
  hasAgents: agents.length > 0,
12341
12342
  agents,
12342
12343
  hasSkills: skills.length > 0,
@@ -12346,6 +12347,48 @@ function buildCodexAdapterContext(dir) {
12346
12347
  generatedPaths: GENERATED_PATHS
12347
12348
  };
12348
12349
  }
12350
+ function detectPackageManager2(dir) {
12351
+ if (exists(join(dir, "pnpm-lock.yaml"))) return "pnpm";
12352
+ if (exists(join(dir, "yarn.lock"))) return "yarn";
12353
+ if (exists(join(dir, "bun.lockb")) || exists(join(dir, "bun.lock"))) return "bun";
12354
+ if (exists(join(dir, "package-lock.json"))) return "npm";
12355
+ return void 0;
12356
+ }
12357
+ function commandFallbacks(pm) {
12358
+ switch (pm) {
12359
+ case "pnpm":
12360
+ return ["corepack pnpm exec kaddo <command>", "pnpm exec kaddo <command>", "npx kaddo <command>"];
12361
+ case "yarn":
12362
+ return ["yarn kaddo <command>", "yarn dlx kaddo <command>", "npx kaddo <command>"];
12363
+ case "bun":
12364
+ return ["bunx kaddo <command>", "npx kaddo <command>"];
12365
+ case "npm":
12366
+ return ["npm exec kaddo <command>", "npx kaddo <command>"];
12367
+ default:
12368
+ return ["corepack pnpm exec kaddo <command>", "pnpm exec kaddo <command>", "npm exec kaddo <command>", "npx kaddo <command>"];
12369
+ }
12370
+ }
12371
+ function commandFallbackSection(pm, heading) {
12372
+ const L = [];
12373
+ const pmNote = pm ? ` (detected package manager: \`${pm}\`)` : " (no package manager detected \u2014 generic options)";
12374
+ L.push(`${heading}Command fallback`, "");
12375
+ L.push(`Prefer the global \`kaddo\` command when available:`, "");
12376
+ L.push("```bash");
12377
+ L.push("kaddo <command>");
12378
+ L.push("```");
12379
+ L.push("");
12380
+ L.push(`If \`kaddo\` is not available in \`PATH\`, try the local project runner${pmNote} before`);
12381
+ L.push("reporting that Kaddo is unavailable:", "");
12382
+ L.push("```bash");
12383
+ for (const f of commandFallbacks(pm)) L.push(f);
12384
+ L.push("```");
12385
+ L.push("");
12386
+ L.push("Do not fail immediately just because the global `kaddo` binary is missing. When you use a");
12387
+ L.push('fallback, mention it briefly (e.g. "the global `kaddo` was not available, so I used the local');
12388
+ L.push('runner").');
12389
+ L.push("");
12390
+ return L;
12391
+ }
12349
12392
  function detectMcpHint(dir) {
12350
12393
  for (const f of [".mcp.json", "mcp.json", ".cursor/mcp.json"]) {
12351
12394
  if (exists(join(dir, f))) return true;
@@ -12361,11 +12404,13 @@ var ROLE_HINTS = {
12361
12404
  "graph-agent": "use to turn graph hints into front matter.",
12362
12405
  "capsule-agent": "use to refine a Knowledge Capsule for sharing."
12363
12406
  };
12364
- function renderAgentsMd(ctx) {
12407
+ var TARGET_FILE = { codex: "AGENTS.md", claude: "CLAUDE.md" };
12408
+ function renderAdapterMarkdown(ctx, target) {
12409
+ const file = TARGET_FILE[target];
12365
12410
  const L = [];
12366
- L.push("<!-- Generated by `kaddo adapters install codex`. Kaddo is the source of truth \u2014");
12411
+ L.push(`<!-- Generated by \`kaddo adapters install ${target}\`. Kaddo is the source of truth \u2014`);
12367
12412
  L.push(" regenerate this file instead of editing it by hand. Do not treat it as primary. -->");
12368
- L.push("# AGENTS.md", "");
12413
+ L.push(`# ${file}`, "");
12369
12414
  L.push("## Project guidance", "");
12370
12415
  if (ctx.projectName) L.push(`Project: **${ctx.projectName}**${ctx.projectType ? ` (${ctx.projectType})` : ""}.`, "");
12371
12416
  L.push("This repository uses **Kaddo** for Knowledge Driven Development. Kaddo keeps business,");
@@ -12441,32 +12486,7 @@ function renderAgentsMd(ctx) {
12441
12486
  }
12442
12487
  L.push("");
12443
12488
  }
12444
- L.push("## Command fallback", "");
12445
- L.push("Prefer the direct command when available:", "");
12446
- L.push("```bash");
12447
- L.push("kaddo <command>");
12448
- L.push("```");
12449
- L.push("");
12450
- L.push("If the global `kaddo` command is not available in `PATH`, try the local project runner");
12451
- L.push("before reporting that Kaddo is unavailable:", "");
12452
- L.push("```bash");
12453
- L.push("corepack pnpm exec kaddo <command>");
12454
- L.push("```");
12455
- L.push("");
12456
- L.push("If that is not available, try:", "");
12457
- L.push("```bash");
12458
- L.push("pnpm exec kaddo <command>");
12459
- L.push("```");
12460
- L.push("");
12461
- L.push("As a last resort (may resolve/download the package):", "");
12462
- L.push("```bash");
12463
- L.push("npx kaddo <command>");
12464
- L.push("```");
12465
- L.push("");
12466
- L.push("Do not assume Kaddo is unavailable until these local fallbacks have been attempted. When you");
12467
- L.push('use a fallback, mention it briefly (e.g. "the global `kaddo` was not available, so I used');
12468
- L.push('`corepack pnpm exec kaddo`").');
12469
- L.push("");
12489
+ for (const line of commandFallbackSection(ctx.packageManager, "## ")) L.push(line);
12470
12490
  L.push("## Useful Kaddo commands", "");
12471
12491
  L.push("```bash");
12472
12492
  for (const c of ["kaddo context", "kaddo understand", "kaddo explain", "kaddo graph export", "kaddo questions", "kaddo guard", "kaddo impact", "kaddo savings", "kaddo drift"]) {
@@ -12493,6 +12513,9 @@ function renderAgentsMd(ctx) {
12493
12513
  L.push("");
12494
12514
  return L.join("\n");
12495
12515
  }
12516
+ function renderAgentsMd(ctx) {
12517
+ return renderAdapterMarkdown(ctx, "codex");
12518
+ }
12496
12519
  var KADDO_BEGIN_MARKER = "<!-- BEGIN KADDO CODEX ADAPTER -->";
12497
12520
  var KADDO_END_MARKER = "<!-- END KADDO CODEX ADAPTER -->";
12498
12521
  var GENERATED_HEADER = "Generated by `kaddo adapters install codex`";
@@ -12528,16 +12551,7 @@ function renderKaddoBlock(ctx) {
12528
12551
  L.push("- Do not modify `.kaddo/` manually; it is generated output.");
12529
12552
  L.push("- Do not commit without user confirmation.");
12530
12553
  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("");
12554
+ for (const line of commandFallbackSection(ctx.packageManager, "### ")) L.push(line);
12541
12555
  L.push("### Before roadmap work", "");
12542
12556
  L.push("Check open-questions readiness first. If blocking open questions exist, ask the user to");
12543
12557
  L.push("resolve, assume or defer them before generating the roadmap.");
@@ -12583,77 +12597,85 @@ ${sep}${block}
12583
12597
  }
12584
12598
 
12585
12599
  // src/commands/adapters.ts
12600
+ var TARGETS2 = {
12601
+ codex: { target: "codex", file: "AGENTS.md", label: "Codex", supportsInject: true },
12602
+ claude: { target: "claude", file: "CLAUDE.md", label: "Claude Code", supportsInject: false }
12603
+ };
12586
12604
  function runAdaptersInstall(adapter, opts = {}) {
12587
12605
  const dir = cwd();
12588
12606
  requireConfig(dir);
12589
- if (adapter !== "codex") {
12590
- console.error(`Unknown adapter: "${adapter}". Available: codex.`);
12607
+ const spec = TARGETS2[adapter];
12608
+ if (!spec) {
12609
+ console.error(`Unknown adapter: "${adapter}". Available: ${Object.keys(TARGETS2).join(", ")}.`);
12591
12610
  process.exit(1);
12611
+ return;
12592
12612
  }
12593
12613
  const ctx = buildCodexAdapterContext(dir);
12594
- const rel = "AGENTS.md";
12614
+ const rel = spec.file;
12595
12615
  const full = join(dir, rel);
12596
12616
  const existed = exists(full);
12597
12617
  const existing = existed ? readFile(full) : null;
12598
- if (opts.inject) {
12618
+ const cmd = `kaddo adapters install ${adapter}`;
12619
+ if (opts.inject && spec.supportsInject) {
12599
12620
  const state = detectAgentsState(existing);
12600
12621
  if (state === "invalid_kaddo_block") {
12601
- console.error("Invalid Kaddo adapter block detected in AGENTS.md.");
12622
+ console.error(`Invalid Kaddo adapter block detected in ${rel}.`);
12602
12623
  console.error("Found one marker without its pair. Fix the file manually or use --force to overwrite.");
12603
12624
  console.error("Nothing changed.");
12604
12625
  process.exit(1);
12626
+ return;
12605
12627
  }
12606
12628
  if (existing === null) {
12607
12629
  const content2 = renderAgentsMd(ctx);
12608
12630
  if (opts.dryRun) {
12609
- console.log("# AGENTS.md preview", "");
12631
+ console.log(`# ${rel} preview`, "");
12610
12632
  console.log(content2);
12611
12633
  return;
12612
12634
  }
12613
- intro2("kaddo adapters install codex --inject");
12635
+ intro2(`${cmd} --inject`);
12614
12636
  writeFile(full, content2);
12615
- log2.success("Created AGENTS.md for Codex.");
12637
+ log2.success(`Created ${rel} for ${spec.label}.`);
12616
12638
  printCommandFooter("adapters install codex");
12617
- outro2("AGENTS.md ready.");
12639
+ outro2(`${rel} ready.`);
12618
12640
  return;
12619
12641
  }
12620
12642
  const merged = injectKaddoBlock(existing, ctx);
12621
12643
  if (opts.dryRun) {
12622
- console.log("# AGENTS.md preview (inject)", "");
12644
+ console.log(`# ${rel} preview (inject)`, "");
12623
12645
  console.log(merged.content);
12624
12646
  return;
12625
12647
  }
12626
- intro2("kaddo adapters install codex --inject");
12648
+ intro2(`${cmd} --inject`);
12627
12649
  writeFile(full, merged.content);
12628
12650
  if (merged.status === "updated") {
12629
- log2.success("Updated existing Kaddo guidance block in AGENTS.md.");
12651
+ log2.success(`Updated existing Kaddo guidance block in ${rel}.`);
12630
12652
  } else {
12631
- log2.success("Injected Kaddo guidance block into AGENTS.md.");
12653
+ log2.success(`Injected Kaddo guidance block into ${rel}.`);
12632
12654
  }
12633
12655
  log2.info("Content outside the Kaddo markers was preserved.");
12634
12656
  printCommandFooter("adapters install codex");
12635
- outro2("AGENTS.md ready.");
12657
+ outro2(`${rel} ready.`);
12636
12658
  return;
12637
12659
  }
12638
- const content = renderAgentsMd(ctx);
12660
+ const content = renderAdapterMarkdown(ctx, spec.target);
12639
12661
  if (opts.dryRun) {
12640
- console.log("# AGENTS.md preview", "");
12662
+ console.log(`# ${rel} preview`, "");
12641
12663
  console.log(content);
12642
12664
  return;
12643
12665
  }
12644
- intro2("kaddo adapters install codex");
12666
+ intro2(cmd);
12645
12667
  if (existed && !opts.force) {
12646
- log2.warn("AGENTS.md already exists.");
12647
- log2.info("Use `--inject` to add or update only the Kaddo block,");
12648
- log2.info("`--force` to overwrite, or `--dry-run` to preview.");
12668
+ log2.warn(`${rel} already exists.`);
12669
+ if (spec.supportsInject) log2.info("Use `--inject` to add or update only the Kaddo block,");
12670
+ log2.info(`Use \`--force\` to overwrite, or \`--dry-run\` to preview.`);
12649
12671
  outro2("Nothing changed.");
12650
12672
  return;
12651
12673
  }
12652
12674
  writeFile(full, content);
12653
- log2.success(`${existed ? "Overwrote" : "Created"} AGENTS.md for Codex.`);
12675
+ log2.success(`${existed ? "Overwrote" : "Created"} ${rel} for ${spec.label}.`);
12654
12676
  log2.info("Source: Kaddo project knowledge. Regenerate it instead of editing by hand.");
12655
12677
  printCommandFooter("adapters install codex");
12656
- outro2("AGENTS.md ready.");
12678
+ outro2(`${rel} ready.`);
12657
12679
  }
12658
12680
 
12659
12681
  // src/index.ts
@@ -12710,10 +12732,10 @@ var questionsAction = (opts) => runQuestions(opts);
12710
12732
  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);
12711
12733
  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);
12712
12734
  var adaptersCmd = program.command("adapters").description("Generate adapters that project Kaddo knowledge for external coding agents");
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) => {
12735
+ adaptersCmd.command("install <adapter>").description("Generate an adapter file (codex \u2192 AGENTS.md, claude \u2192 CLAUDE.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) => {
12714
12736
  runAdaptersInstall(adapter, opts);
12715
12737
  });
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) => {
12738
+ program.command("export <adapter>").description("Alias for `kaddo adapters install <adapter>` (codex \u2192 AGENTS.md, claude \u2192 CLAUDE.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) => {
12717
12739
  runAdaptersInstall(adapter, opts);
12718
12740
  });
12719
12741
  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) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaddo/cli",
3
- "version": "3.27.2",
3
+ "version": "3.28.0",
4
4
  "description": "Knowledge Driven Development toolkit",
5
5
  "license": "MIT",
6
6
  "repository": {