cadre-ai 2.1.0 → 2.2.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/README.md CHANGED
@@ -23,7 +23,10 @@ Public docs: [https://cadre-docs.pages.dev/](https://cadre-docs.pages.dev/)
23
23
  workspace diagnostics, LSP setup, warm LSP review, and async job artifacts.
24
24
  - **Four agent surfaces:** Claude Code, OpenAI Codex, GitHub Copilot, and
25
25
  Google Antigravity plugins are thin MCP entrypoints. The global `cadre-mcp`
26
- runtime owns the skill contract, protocols, references, templates, and packet
26
+ runtime owns three public packet tools, the validated resource registry, and
27
+ the setup templates needed at runtime.
28
+ - **Codex and Claude workflow pickers:** explicit `$cadre:*` and `/cadre:*`
29
+ entries make every registered workflow discoverable without adding MCP
27
30
  tools.
28
31
 
29
32
  ## Install
@@ -38,17 +41,33 @@ cadre doctor
38
41
 
39
42
  ## Use
40
43
 
41
- In a target project, activate the Cadre skill and ask for the workflow you need:
44
+ In Codex, type `$cadre:`; in Claude Code, type `/cadre:`:
42
45
 
43
46
  ```text
44
- $cadre
45
- cadre-setup
46
- cadre-newtrack "Add OAuth login"
47
- cadre-implement
48
- cadre-review
49
- cadre-ship
47
+ # Codex
48
+ $cadre:setup
49
+ $cadre:newtrack Add OAuth login
50
+ $cadre:implement
51
+ $cadre:review
52
+ $cadre:ship
53
+
54
+ # Claude Code
55
+ /cadre:setup
56
+ /cadre:newtrack Add OAuth login
57
+ /cadre:implement
58
+ /cadre:review
59
+ /cadre:ship
50
60
  ```
51
61
 
62
+ Both clients expose the same 19 registered workflows: `setup`, `newtrack`,
63
+ `implement`, `debug`, `status`, `validate`, `flag`, `revise`, `review`, `ship`,
64
+ `land`, `handoff`, `archive`, `release`, `refresh`, `revert`, `formula`,
65
+ `artifacts`, and `skill`. Neither exposes a redundant `$cadre:cadre` or
66
+ `/cadre:cadre` option. After an upgrade, restart Codex or open a new task; in
67
+ Claude Code, run `/reload-plugins` or restart. Copilot and Antigravity retain
68
+ the single Cadre skill and accept the same `cadre-*` workflow names as
69
+ requests.
70
+
52
71
  Cadre workflows are packet-owned. The agent verifies Cadre MCP, passes a
53
72
  per-call `root`, and lets the runtime perform state reads/writes, formula work,
54
73
  parallel worker state, provider evidence write-back, and shared sync. Do not
@@ -60,7 +79,7 @@ maintain Cadre state by hand.
60
79
 
61
80
  - `cadre/product.json` plus generated `cadre/product.md`
62
81
  - `cadre/product_guidelines.json` plus generated `cadre/product_guidelines.md`
63
- - `cadre/tech-stack.json`
82
+ - `cadre/tech-stack.json` plus generated `cadre/tech-stack.md`
64
83
  - `cadre/workflow.json` plus generated `cadre/workflow.md`
65
84
  - `cadre/tracks.json` as the generated track index
66
85
  - `cadre/patterns.jsonl` plus generated `cadre/patterns.md`
@@ -69,10 +88,11 @@ maintain Cadre state by hand.
69
88
  - `cadre/messages/outbox.jsonl` and `cadre/messages/inbox.jsonl`
70
89
  - `cadre/formulas/*.json` when formulas are added
71
90
  - git-ignored `cadre/local/wisps/*.json` for local ephemeral formula runs
72
- - `cadre/styleguides/*.json` plus generated `cadre/code_styleguides/*.md`
73
- - optional `cadre/repos.json` for polyrepo topology
91
+ - `cadre/styleguides/index.json` plus generated `cadre/styleguides/README.md`
92
+ - `cadre/styleguides/<id>.json` plus generated `cadre/styleguides/<id>.md`
93
+ - optional `cadre/repos.json` plus generated `cadre/repos.md` for polyrepo topology
74
94
  - optional `cadre/lsp.json` for LSP recommendations
75
- - repository-authored `cadre/skills/<skill-id>/skill.json` rule manifests with optional `SKILL.md` human projections
95
+ - repository-authored `cadre/skills/<skill-id>/skill.json` rule manifests with generated `SKILL.md` human projections
76
96
 
77
97
  Setup also initializes native Cadre state, can configure shared-sync merge
78
98
  attributes, and can scaffold hosted CI checks when requested.
@@ -112,8 +132,10 @@ pnpm --filter cadre-ai check
112
132
  ```
113
133
 
114
134
  Generated plugin bundles under `.agents/`, `.claude/`, and `plugins/` are
115
- rebuilt from master sources. They contain only platform manifests, MCP config,
116
- and `SKILL.md`; the embedded MCP runtime is built under `scripts/`.
135
+ rebuilt from master sources. They contain platform manifests, MCP config, and
136
+ thin skill shims; the Codex and Claude plugin fixtures also contain the same 19
137
+ explicit workflow-picker skills. The embedded MCP runtime is built under
138
+ `scripts/`.
117
139
 
118
140
  Public documentation lives in the repo-root `docs/` Next.js app. Markdown page
119
141
  source is in `docs/content/`:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cadre-ai",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "MCP-first Cadre workflows for context-driven development.",
5
5
  "author": {
6
6
  "name": "Vishal Kumar",
@@ -38,8 +38,6 @@
38
38
  "README.md",
39
39
  "scripts/cadre-cli.js",
40
40
  "scripts/cadre-core.js",
41
- "scripts/cadre-job-runner.js",
42
- "scripts/cadre-lsp-daemon.js",
43
41
  "scripts/cadre-lsp-review.js",
44
42
  "scripts/cadre-lsp-setup.js",
45
43
  "scripts/mcp/cadre-server.js"
@@ -53,7 +51,7 @@
53
51
  "check:runtime": "pnpm build:runtime",
54
52
  "check:generated": "bash scripts/generate-skills.sh --check",
55
53
  "check:test": "pnpm test",
56
- "test": "node --test scripts/source-architecture.test.js scripts/cadre-core.test.js scripts/cadre-skill.test.js scripts/cadre-cli.test.js scripts/mcp/cadre-server.test.js scripts/protocol-packet-only.test.js scripts/token-efficiency.test.js && node scripts/cadre-team-scale-sim.js",
54
+ "test": "node --test scripts/source-architecture.test.js scripts/cadre-core.test.js scripts/cadre-skill.test.js scripts/cadre-cli.test.js scripts/mcp/cadre-server.test.js scripts/mcp/lifecycle.test.js scripts/mcp-resource-registry.test.js scripts/mcp-packet-contracts.test.js scripts/protocol-packet-only.test.js scripts/token-efficiency.test.js && node scripts/cadre-team-scale-sim.js",
57
55
  "typecheck": "tsc --noEmit"
58
56
  },
59
57
  "devDependencies": {
@@ -1,7 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  // AUTO-GENERATED by pnpm build from src/*.ts -- do not edit by hand.
3
3
  // Edit TypeScript sources under src/ instead.
4
- const __CADRE_SKILL_SHIM__ = "---\nname: cadre\ndescription: Packet-led context-driven development for Cadre projects and workflows.\n---\n\n# Cadre\n\nCall `cadre_workflow` directly with the current root candidate, workflow name,\nand structured `input`. The call itself verifies Cadre and resolves the root.\nFollow the returned `decision`, load only returned resource URIs, and execute at\nmost the single returned `next` call.\n\nUse `cadre_action` only for a namespaced action returned by a packet and\n`cadre_read` only for a relevant resource. Cadre owns control-plane, approval,\nprovider, worker, merge, and generated-projection state. Never recreate that\nstate with shell commands or treat Markdown projections as canonical.\n\nSend `approval` only after explicit user approval of the current stage. If a\npacket is blocked, report its error or requested narrowing; do not truncate or\ninvent required project-skill rules.\n";
4
+ const __CADRE_SKILL_SHIM__ = "---\nname: cadre\ndescription: Packet-led context-driven development for Cadre projects and workflows.\n---\n\n# Cadre\n\nCall `cadre_workflow` directly with one nested request:\n`{root, workflow, input, execute, approval}`. The call itself verifies Cadre\nand resolves the root. Follow the returned `decision` and load only returned\nresource URIs. A non-null `next` is the sole typed continuation: invoke exactly\n`next.tool` with `next.arguments`, at most once for that packet. It is the sole\nimmediate single-agent Cadre continuation. The only typed callbacks outside\n`next` are `decision.required.write_back`, used after collecting the requested\nexternal provider evidence, and each parallel worker's\n`data.workers[].dispatch.record_finish_packet`, used once with that worker's\nresult. While workers remain incomplete or need recovery, Cadre reissues their\nexact callbacks under `data.worker_callbacks[].record_finish_packet`. Never\ninfer a callback from prose or hardcode later merge or cleanup actions; a\nsubsequent packet returns those operations through `next` only when safe.\n\nUse `cadre_action` only as `{root, action, input, execute}` for the namespaced\naction returned by a packet. Use `cadre_read` only as `{uri}` for a relevant\nresource. Cadre owns control-plane, approval, provider, worker, merge, and\ngenerated-projection state. Never recreate that state with shell commands or\ntreat Markdown projections as canonical.\n\nSend `approval` only after explicit user approval of the current human-facing\ndocument. Its canonical JSON/JSONL and generated projection are one immutable\nreview pair and never receive separate approvals. `execute:true` authorizes a\nmutation or side effect; it is not document approval. If a packet is blocked,\nreport its error or requested narrowing; do not truncate or invent required\nproject-skill rules.\n";
5
+ const __CADRE_COMMAND_SKILL_TEMPLATE__ = "---\nname: \"{{command}}\"\ndescription: \"Use when the user invokes {{command}} or asks to start or continue the Cadre {{workflow}} workflow.\"\n---\n\n# {{command}}\n\nStart or continue Cadre's `{{workflow}}` workflow through the packet-owned MCP\ncontract.\n\n1. Call `cadre_workflow` with one nested request containing the resolved\n project `root`, `workflow:\"{{workflow}}\"`, workflow-specific `input`, and\n `execute:false`. Keep workflow fields inside `input` and omit `approval` on\n the initial call.\n2. Follow the returned `decision`. If `next` is non-null, invoke exactly\n `next.tool` with `next.arguments` once for that packet.\n3. Use `cadre_action` and `cadre_read` only when the packet returns that exact\n action or resource. Outside `next`, use only an exact returned\n `decision.required.write_back`, `data.workers[].dispatch.record_finish_packet`,\n or `data.worker_callbacks[].record_finish_packet`; never invent merge or\n cleanup callbacks.\n4. Send `approval` only after explicit user approval of the current reviewed\n document and its canonical pair. Treat `execute:true` as mutation\n authorization, not approval.\n\nDo not infer later actions from prose, edit Cadre-owned state manually, or treat\nMarkdown projections as canonical input. If required project-skill rules do not\nfit, report the requested narrowing instead of truncating them.\n";
6
+ const __CADRE_WORKFLOW_COMMANDS__ = ["setup","newtrack","implement","debug","status","validate","flag","revise","review","ship","land","handoff","archive","release","refresh","revert","formula","artifacts","skill"];
5
7
  "use strict";
6
8
  var __create = Object.create;
7
9
  var __defProp = Object.defineProperty;
@@ -381,32 +383,78 @@ function isRecord(value) {
381
383
  var import_node_fs2 = __toESM(require("node:fs"));
382
384
  var import_node_path3 = __toESM(require("node:path"));
383
385
  var import_node_child_process2 = require("node:child_process");
386
+
387
+ // src/guards.ts
388
+ function isRecord2(value) {
389
+ return typeof value === "object" && value !== null && !Array.isArray(value);
390
+ }
391
+ function asJsonObject(value) {
392
+ return isRecord2(value) ? value : {};
393
+ }
394
+ function asOptionalString(value) {
395
+ return typeof value === "string" ? value : void 0;
396
+ }
397
+
398
+ // src/mcp/domain/tool-catalog.ts
399
+ var SUPPORTED_PROTOCOL_VERSIONS = ["2025-11-25", "2025-06-18"];
400
+ var PROTOCOL_VERSION = SUPPORTED_PROTOCOL_VERSIONS[0];
401
+ var SERVER_INSTRUCTIONS = [
402
+ "Cadre is a packet-led runtime. Call cadre_workflow first for workflows, cadre_action for a packet named by a workflow response, and cadre_read only for a relevant resource URI.",
403
+ "Pass a root candidate to project-scoped calls. Cadre resolves it internally; setup accepts an uninitialized directory.",
404
+ "Cadre owns control-plane, provider, worker, approval, merge, and generated projection state."
405
+ ].join(" ");
406
+
407
+ // src/cli/install-checks.ts
384
408
  function runCommand(plan) {
385
409
  const result = (0, import_node_child_process2.spawnSync)(plan.command, plan.args, { encoding: "utf8" });
386
410
  return { ok: result.status === 0, status: result.status, stderr: result.stderr || "" };
387
411
  }
388
412
  function pingMcp(runtime) {
389
413
  if (!import_node_fs2.default.existsSync(runtime.mcpServer)) return { ok: false, reason: `missing MCP server: ${runtime.mcpServer}` };
390
- const request = {
391
- jsonrpc: "2.0",
392
- id: 1,
393
- method: "tools/call",
394
- params: { name: "cadre_action", arguments: { action: "project.ping" } }
395
- };
414
+ const messages = [
415
+ {
416
+ jsonrpc: "2.0",
417
+ id: 1,
418
+ method: "initialize",
419
+ params: {
420
+ protocolVersion: PROTOCOL_VERSION,
421
+ capabilities: {},
422
+ clientInfo: { name: "cadre-installer", version: "1" }
423
+ }
424
+ },
425
+ { jsonrpc: "2.0", method: "notifications/initialized" },
426
+ {
427
+ jsonrpc: "2.0",
428
+ id: 2,
429
+ method: "tools/call",
430
+ params: { name: "cadre_action", arguments: { action: "project.ping" } }
431
+ }
432
+ ];
396
433
  const result = (0, import_node_child_process2.spawnSync)(runtime.nodePath, [runtime.mcpServer], {
397
434
  cwd: runtime.runtimeRoot,
398
- input: `${JSON.stringify(request)}
435
+ input: `${messages.map((message) => JSON.stringify(message)).join("\n")}
399
436
  `,
400
437
  encoding: "utf8",
401
438
  timeout: 3e3
402
439
  });
403
440
  if (result.status !== 0 && !result.stdout.trim()) return { ok: false, reason: result.stderr || `MCP exited with ${result.status}` };
404
- const line = result.stdout.split(/\r?\n/).find((entry) => entry.trim());
405
- if (!line) return { ok: false, reason: "MCP returned no JSON-RPC response" };
406
441
  try {
407
- const parsed = JSON.parse(line);
408
- if (parsed.error) return { ok: false, reason: parsed.error.message || "MCP returned an error" };
409
- const text = parsed.result?.content?.[0]?.text;
442
+ const responses = result.stdout.split(/\r?\n/).filter((entry) => entry.trim()).map((entry) => asJsonObject(JSON.parse(entry)));
443
+ const initialize = responses.find((response) => response.id === 1);
444
+ const ping = responses.find((response) => response.id === 2);
445
+ if (!initialize) return { ok: false, reason: "MCP returned no initialize response" };
446
+ const initializeError = asJsonObject(initialize.error);
447
+ if (Object.keys(initializeError).length > 0) return { ok: false, reason: asOptionalString(initializeError.message) || "MCP initialize returned an error" };
448
+ const initializeResult = asJsonObject(initialize.result);
449
+ if (initializeResult.protocolVersion !== PROTOCOL_VERSION) {
450
+ return { ok: false, reason: `MCP negotiated ${initializeResult.protocolVersion || "no protocol version"}; expected ${PROTOCOL_VERSION}` };
451
+ }
452
+ if (!ping) return { ok: false, reason: "MCP returned no ping response after initialization" };
453
+ const pingError = asJsonObject(ping.error);
454
+ if (Object.keys(pingError).length > 0) return { ok: false, reason: asOptionalString(pingError.message) || "MCP ping returned an error" };
455
+ const pingResult = asJsonObject(ping.result);
456
+ const content = Array.isArray(pingResult.content) ? pingResult.content : [];
457
+ const text = asOptionalString(asJsonObject(content[0]).text);
410
458
  const body = text ? JSON.parse(text) : null;
411
459
  return body?.data?.ok === true ? { ok: true } : { ok: false, reason: "MCP ping did not return ok:true" };
412
460
  } catch (error) {
@@ -441,20 +489,83 @@ function checkMcpConfig(target, file, runtime) {
441
489
  }
442
490
  return errors;
443
491
  }
444
- function checkTarget(target, paths, runtime) {
492
+ function checkCommandSkills(platform, pluginRoot, commandSkills) {
493
+ const errors = [];
494
+ if (Object.keys(commandSkills).length === 0) return [`Cadre ${platform} workflow commands are missing`];
495
+ for (const [command, files] of Object.entries(commandSkills)) {
496
+ const commandRoot = import_node_path3.default.join(pluginRoot, "skills", command);
497
+ if (import_node_fs2.default.existsSync(commandRoot) && !import_node_fs2.default.lstatSync(commandRoot).isDirectory()) {
498
+ errors.push(`invalid Cadre command skill directory ${commandRoot}`);
499
+ continue;
500
+ }
501
+ const expectedFiles = new Set(Object.keys(files).map((relative) => relative.replace(/\\/g, "/")));
502
+ const expectedDirectories = /* @__PURE__ */ new Set();
503
+ for (const relative of expectedFiles) {
504
+ const parts = relative.split("/");
505
+ for (let index = 1; index < parts.length; index += 1) {
506
+ expectedDirectories.add(parts.slice(0, index).join("/"));
507
+ }
508
+ }
509
+ for (const [relative, expected] of Object.entries(files)) {
510
+ const file = import_node_path3.default.join(pluginRoot, "skills", command, ...relative.replace(/\\/g, "/").split("/"));
511
+ if (!import_node_fs2.default.existsSync(file)) {
512
+ errors.push(`missing ${file}`);
513
+ continue;
514
+ }
515
+ if (!import_node_fs2.default.lstatSync(file).isFile()) {
516
+ errors.push(`invalid Cadre command skill file ${file}`);
517
+ continue;
518
+ }
519
+ const actual = import_node_fs2.default.readFileSync(file, "utf8");
520
+ const normalizedExpected = expected.endsWith("\n") ? expected : `${expected}
521
+ `;
522
+ if (actual !== normalizedExpected) errors.push(`stale Cadre command skill ${file}`);
523
+ }
524
+ if (import_node_fs2.default.existsSync(commandRoot)) {
525
+ const visit = (directory, relativeRoot = "") => {
526
+ for (const entry of import_node_fs2.default.readdirSync(directory, { withFileTypes: true })) {
527
+ const relative = import_node_path3.default.posix.join(relativeRoot, entry.name);
528
+ if (entry.isDirectory()) {
529
+ if (expectedDirectories.has(relative)) visit(import_node_path3.default.join(directory, entry.name), relative);
530
+ else errors.push(`unexpected Cadre command skill directory ${import_node_path3.default.join(commandRoot, ...relative.split("/"))}`);
531
+ } else if (!expectedFiles.has(relative)) {
532
+ errors.push(`unexpected Cadre command skill file ${import_node_path3.default.join(commandRoot, ...relative.split("/"))}`);
533
+ }
534
+ }
535
+ };
536
+ visit(commandRoot);
537
+ }
538
+ }
539
+ const skillsRoot = import_node_path3.default.join(pluginRoot, "skills");
540
+ const expectedCommands = new Set(Object.keys(commandSkills));
541
+ if (import_node_fs2.default.existsSync(skillsRoot)) {
542
+ for (const entry of import_node_fs2.default.readdirSync(skillsRoot, { withFileTypes: true })) {
543
+ if (!entry.isDirectory() || !expectedCommands.has(entry.name)) {
544
+ errors.push(`unexpected Cadre command skill ${import_node_path3.default.join(skillsRoot, entry.name)}`);
545
+ }
546
+ }
547
+ }
548
+ return errors;
549
+ }
550
+ function checkTarget(target, paths, runtime, commandSkillSets) {
445
551
  const errors = [];
446
552
  for (const skillRoot of paths.skillRoots) {
447
553
  const skill = import_node_path3.default.join(skillRoot, "SKILL.md");
448
554
  if (!import_node_fs2.default.existsSync(skill)) errors.push(`missing ${skill}`);
449
555
  }
450
556
  for (const pluginRoot of paths.pluginRoots) {
451
- const skill = import_node_path3.default.join(pluginRoot, "skills", "cadre", "SKILL.md");
452
- if (!import_node_fs2.default.existsSync(skill)) errors.push(`missing ${skill}`);
557
+ if (target !== "codex" && target !== "claude") {
558
+ const skill = import_node_path3.default.join(pluginRoot, "skills", "cadre", "SKILL.md");
559
+ if (!import_node_fs2.default.existsSync(skill)) errors.push(`missing ${skill}`);
560
+ }
453
561
  const files = pluginConfigFiles(target, pluginRoot);
454
562
  if (!import_node_fs2.default.existsSync(files.manifest)) errors.push(`missing ${files.manifest}`);
455
563
  if (!import_node_fs2.default.existsSync(files.mcp)) errors.push(`missing ${files.mcp}`);
456
564
  errors.push(...forbiddenThinPayload(pluginRoot).map((entry) => `thin plugin contains forbidden payload ${entry}`));
457
565
  if (import_node_fs2.default.existsSync(files.mcp)) errors.push(...checkMcpConfig(target, files.mcp, runtime));
566
+ if (target === "codex" || target === "claude") {
567
+ errors.push(...checkCommandSkills(target, pluginRoot, commandSkillSets[target]));
568
+ }
458
569
  }
459
570
  if (paths.marketplaceFile && !import_node_fs2.default.existsSync(paths.marketplaceFile)) errors.push(`missing ${paths.marketplaceFile}`);
460
571
  return errors;
@@ -583,9 +694,31 @@ function writeText(file, text) {
583
694
  import_node_fs3.default.writeFileSync(file, text.endsWith("\n") ? text : `${text}
584
695
  `);
585
696
  }
586
- function writePluginRoot(target, pluginRoot, runtime, skillShim) {
697
+ function writeCommandSkills(pluginRoot, commandSkills) {
698
+ for (const [command, files] of Object.entries(commandSkills)) {
699
+ if (command === "cadre" || !/^[a-z][a-z0-9-]*$/.test(command)) {
700
+ throw new Error(`Invalid Cadre command skill: ${command}`);
701
+ }
702
+ for (const [relative, content] of Object.entries(files)) {
703
+ const normalized = relative.replace(/\\/g, "/");
704
+ if (!normalized || normalized.startsWith("/") || normalized.split("/").some((part) => !part || part === "." || part === "..")) {
705
+ throw new Error(`Invalid Cadre command skill file: ${command}/${relative}`);
706
+ }
707
+ writeText(import_node_path4.default.join(pluginRoot, "skills", command, ...normalized.split("/")), content);
708
+ }
709
+ }
710
+ }
711
+ function writePluginRoot(target, pluginRoot, runtime, skillShim, commandSkillSets) {
712
+ const commandSkills = target === "codex" || target === "claude" ? commandSkillSets[target] : null;
713
+ if (commandSkills && Object.keys(commandSkills).length === 0) {
714
+ throw new Error(`Cadre ${target} workflow commands are missing`);
715
+ }
587
716
  import_node_fs3.default.rmSync(pluginRoot, { recursive: true, force: true });
588
- writeText(import_node_path4.default.join(pluginRoot, "skills", "cadre", "SKILL.md"), skillShim);
717
+ if (commandSkills) {
718
+ writeCommandSkills(pluginRoot, commandSkills);
719
+ } else {
720
+ writeText(import_node_path4.default.join(pluginRoot, "skills", "cadre", "SKILL.md"), skillShim);
721
+ }
589
722
  if (target === "codex") {
590
723
  writeJson(import_node_path4.default.join(pluginRoot, ".codex-plugin", "plugin.json"), pluginManifest(target, runtime));
591
724
  writeJson(import_node_path4.default.join(pluginRoot, ".mcp.json"), mcpConfig(target, runtime));
@@ -600,8 +733,8 @@ function writePluginRoot(target, pluginRoot, runtime, skillShim) {
600
733
  writeJson(import_node_path4.default.join(pluginRoot, "mcp_config.json"), mcpConfig(target, runtime));
601
734
  }
602
735
  }
603
- function writeTarget(target, paths, runtime, skillShim) {
604
- for (const pluginRoot of paths.pluginRoots) writePluginRoot(target, pluginRoot, runtime, skillShim);
736
+ function writeTarget(target, paths, runtime, skillShim, commandSkillSets) {
737
+ for (const pluginRoot of paths.pluginRoots) writePluginRoot(target, pluginRoot, runtime, skillShim, commandSkillSets);
605
738
  for (const skillRoot of paths.skillRoots) {
606
739
  import_node_fs3.default.rmSync(skillRoot, { recursive: true, force: true });
607
740
  writeText(import_node_path4.default.join(skillRoot, "SKILL.md"), skillShim);
@@ -743,8 +876,8 @@ function runInstall(argv, context) {
743
876
  `);
744
877
  continue;
745
878
  }
746
- if (!options.check) writeTarget(target, paths, runtime, context.skillShim);
747
- const errors = checkTarget(target, paths, runtime);
879
+ if (!options.check) writeTarget(target, paths, runtime, context.skillShim, context.commandSkills);
880
+ const errors = checkTarget(target, paths, runtime, context.commandSkills);
748
881
  if (!options.check) {
749
882
  const approvals = bootstrapClientApprovals(target);
750
883
  if (!approvals.ok) errors.push(`${target} approval bootstrap failed: ${approvals.error || approvals.path}`);
@@ -858,9 +991,83 @@ async function runCli(argv, context) {
858
991
  if (code !== 0) process.exit(code);
859
992
  }
860
993
 
994
+ // src/cli/workflow-command-skills.ts
995
+ var workflowPattern = /^[a-z][a-z0-9-]*$/;
996
+ var claudeFrontmatterEnd = "\n---\n";
997
+ var WORKFLOW_COMMAND_PLATFORMS = ["codex", "claude"];
998
+ function workflowDisplayName(workflow) {
999
+ if (workflow === "newtrack") return "New Track";
1000
+ return workflow.split("-").map((part) => `${part.charAt(0).toUpperCase()}${part.slice(1)}`).join(" ");
1001
+ }
1002
+ function commandAgentManifest(workflow) {
1003
+ const displayName = workflowDisplayName(workflow);
1004
+ return [
1005
+ "interface:",
1006
+ ` display_name: "Cadre ${displayName}"`,
1007
+ ` short_description: "Start or continue the Cadre ${displayName} workflow"`,
1008
+ ` default_prompt: "Start or continue the Cadre ${workflow} workflow for this project."`,
1009
+ "policy:",
1010
+ " allow_implicit_invocation: false",
1011
+ ""
1012
+ ].join("\n");
1013
+ }
1014
+ function claudeCommandSkill(content) {
1015
+ if (!content.startsWith("---\n")) {
1016
+ throw new Error("Cadre workflow command template is missing YAML frontmatter");
1017
+ }
1018
+ const frontmatterEnd = content.indexOf(claudeFrontmatterEnd, 4);
1019
+ if (frontmatterEnd < 0) {
1020
+ throw new Error("Cadre workflow command template has unterminated YAML frontmatter");
1021
+ }
1022
+ const frontmatter = content.slice(4, frontmatterEnd);
1023
+ if (/^disable-model-invocation:/m.test(frontmatter)) {
1024
+ throw new Error("Cadre workflow command template must keep Claude invocation policy platform-specific");
1025
+ }
1026
+ return `${content.slice(0, frontmatterEnd)}
1027
+ disable-model-invocation: true${content.slice(frontmatterEnd)}`;
1028
+ }
1029
+ function commandFiles(platform, workflow, content) {
1030
+ if (platform === "claude") {
1031
+ return { "SKILL.md": claudeCommandSkill(content) };
1032
+ }
1033
+ return {
1034
+ "SKILL.md": content,
1035
+ "agents/openai.yaml": commandAgentManifest(workflow)
1036
+ };
1037
+ }
1038
+ function renderWorkflowCommandSkills(template, workflows, options = {}) {
1039
+ const platform = options.platform ?? "codex";
1040
+ if (!WORKFLOW_COMMAND_PLATFORMS.includes(platform)) {
1041
+ throw new Error(`Unsupported Cadre workflow command platform: ${String(platform)}`);
1042
+ }
1043
+ if (!template.includes("{{command}}") || !template.includes("{{workflow}}")) {
1044
+ throw new Error("Cadre workflow command template is missing required placeholders");
1045
+ }
1046
+ const unique = /* @__PURE__ */ new Set();
1047
+ const commandSkills = {};
1048
+ for (const workflow of workflows) {
1049
+ if (!workflowPattern.test(workflow) || workflow === "cadre" || unique.has(workflow)) {
1050
+ throw new Error(`Invalid Cadre workflow command id: ${workflow}`);
1051
+ }
1052
+ unique.add(workflow);
1053
+ const content = template.replaceAll("{{command}}", workflow).replaceAll("{{workflow}}", workflow);
1054
+ if (content.includes("{{")) {
1055
+ throw new Error(`Unresolved workflow command placeholder: ${workflow}`);
1056
+ }
1057
+ commandSkills[workflow] = commandFiles(platform, workflow, content);
1058
+ }
1059
+ return commandSkills;
1060
+ }
1061
+
861
1062
  // src/cli.ts
1063
+ var commandSkillTemplate = typeof __CADRE_COMMAND_SKILL_TEMPLATE__ === "string" ? __CADRE_COMMAND_SKILL_TEMPLATE__ : "";
1064
+ var workflowCommands = typeof __CADRE_WORKFLOW_COMMANDS__ !== "undefined" && Array.isArray(__CADRE_WORKFLOW_COMMANDS__) ? __CADRE_WORKFLOW_COMMANDS__ : [];
862
1065
  runCli(process.argv.slice(2), {
863
- skillShim: typeof __CADRE_SKILL_SHIM__ === "string" ? __CADRE_SKILL_SHIM__ : ""
1066
+ skillShim: typeof __CADRE_SKILL_SHIM__ === "string" ? __CADRE_SKILL_SHIM__ : "",
1067
+ commandSkills: {
1068
+ codex: renderWorkflowCommandSkills(commandSkillTemplate, workflowCommands, { platform: "codex" }),
1069
+ claude: renderWorkflowCommandSkills(commandSkillTemplate, workflowCommands, { platform: "claude" })
1070
+ }
864
1071
  }).catch((error) => {
865
1072
  const message = error instanceof Error ? error.message : String(error);
866
1073
  process.stderr.write(`${message}