cadre-ai 2.0.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,9 +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
95
+ - repository-authored `cadre/skills/<skill-id>/skill.json` rule manifests with generated `SKILL.md` human projections
75
96
 
76
97
  Setup also initializes native Cadre state, can configure shared-sync merge
77
98
  attributes, and can scaffold hosted CI checks when requested.
@@ -83,6 +104,12 @@ so ownership, leases, review state, blockers, and available work are visible to
83
104
  everyone. Product code publication still happens through ship/land workflows;
84
105
  shared sync is for the Cadre control plane.
85
106
 
107
+ Project skills are local to the active repository. Maintainers add them through
108
+ normal reviewed Git changes; Cadre selects them by workflow and optional
109
+ polyrepo `repos` targeting, returns bounded instructions in workflow packets,
110
+ and exposes references lazily through MCP resources. Project skills never fall
111
+ back to a global catalog and never execute scripts automatically.
112
+
86
113
  Compact MCP resources provide bounded views for larger teams:
87
114
 
88
115
  - team board and next actions
@@ -105,8 +132,10 @@ pnpm --filter cadre-ai check
105
132
  ```
106
133
 
107
134
  Generated plugin bundles under `.agents/`, `.claude/`, and `plugins/` are
108
- rebuilt from master sources. They contain only platform manifests, MCP config,
109
- 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/`.
110
139
 
111
140
  Public documentation lives in the repo-root `docs/` Next.js app. Markdown page
112
141
  source is in `docs/content/`:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cadre-ai",
3
- "version": "2.0.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-cli.test.js scripts/mcp/cadre-server.test.js scripts/protocol-packet-only.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: |\n Context-driven development methodology for organized, spec-first coding. Use when:\n - Project has a `cadre/` directory\n - User mentions specs, plans, tracks, or context-driven development\n - Files like `cadre/tracks.json`, `cadre/product.json`, or `cadre/workflow.json` exist\n - User asks about project status, implementation progress, or track management\n - User wants to organize development work with TDD practices\n - User asks for a `cadre-*` workflow (setup, newtrack, implement, debug, status, revert, validate, flag, revise, review, ship, land, archive, release, handoff, refresh, formula, artifacts)\n - User mentions documentation is outdated or wants to sync context with codebase changes\n - Project is a polyrepo control repo (`cadre/repos.json` with mode \"polyrepo\") spanning git-submodule product repos\n\n Interoperable across Claude Code, OpenAI Codex, Copilot, and Antigravity.\n Uses native Cadre state for persistent task memory across sessions.\n---\n\n# Cadre Skill Shim\n\nCadre MCP is required for every Cadre workflow. Before acting, verify the MCP\nruntime with `cadre_project` using `{\"action\":\"ping\"}`. If Cadre MCP tools or\nresources are unavailable, halt and ask the user to install, enable, or restart\nthe Cadre plugin.\n\nLoad `cadre://skill-contract` for the authoritative `cadre.skill.v1` contract.\nUse `cadre://workflow-protocols` to discover workflow protocol resources, then\nload `cadre://workflow-protocol?workflow=<name>` for the active workflow.\nReferences and template inventory are also MCP-served through Cadre resources.\n\nFor staged approvals, stay on Cadre's packet-led review path: use the returned\n`approval.current_stage` and current review output first. Target mode may have\n`manifest_path:null`, `mutates_worktree:true`, and `files[].target_path` /\n`review_path`; bundle mode uses the manifest and temp review paths. Ask for\nexplicit user approval before sending approval fields. Avoid extra inspection\nunless packet evidence cannot answer the current stage question.\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;
@@ -144,18 +146,9 @@ function uninstallCommands(target, paths, scope) {
144
146
 
145
147
  // src/cli/client-approvals.ts
146
148
  var CADRE_MCP_TOOLS = [
147
- "cadre_resource",
148
149
  "cadre_workflow",
149
- "cadre_project",
150
- "cadre_status",
151
- "cadre_track",
152
- "cadre_parallel",
153
- "cadre_mutate",
154
- "cadre_complete_task",
155
- "cadre_job",
156
- "cadre_review",
157
- "cadre_intel",
158
- "cadre_artifact"
150
+ "cadre_action",
151
+ "cadre_read"
159
152
  ];
160
153
  var CLAUDE_CADRE_ALLOW_RULES = [
161
154
  "mcp__plugin_cadre_cadre__*",
@@ -390,32 +383,78 @@ function isRecord(value) {
390
383
  var import_node_fs2 = __toESM(require("node:fs"));
391
384
  var import_node_path3 = __toESM(require("node:path"));
392
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
393
408
  function runCommand(plan) {
394
409
  const result = (0, import_node_child_process2.spawnSync)(plan.command, plan.args, { encoding: "utf8" });
395
410
  return { ok: result.status === 0, status: result.status, stderr: result.stderr || "" };
396
411
  }
397
412
  function pingMcp(runtime) {
398
413
  if (!import_node_fs2.default.existsSync(runtime.mcpServer)) return { ok: false, reason: `missing MCP server: ${runtime.mcpServer}` };
399
- const request = {
400
- jsonrpc: "2.0",
401
- id: 1,
402
- method: "tools/call",
403
- params: { name: "cadre_project", arguments: { action: "ping" } }
404
- };
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
+ ];
405
433
  const result = (0, import_node_child_process2.spawnSync)(runtime.nodePath, [runtime.mcpServer], {
406
434
  cwd: runtime.runtimeRoot,
407
- input: `${JSON.stringify(request)}
435
+ input: `${messages.map((message) => JSON.stringify(message)).join("\n")}
408
436
  `,
409
437
  encoding: "utf8",
410
438
  timeout: 3e3
411
439
  });
412
440
  if (result.status !== 0 && !result.stdout.trim()) return { ok: false, reason: result.stderr || `MCP exited with ${result.status}` };
413
- const line = result.stdout.split(/\r?\n/).find((entry) => entry.trim());
414
- if (!line) return { ok: false, reason: "MCP returned no JSON-RPC response" };
415
441
  try {
416
- const parsed = JSON.parse(line);
417
- if (parsed.error) return { ok: false, reason: parsed.error.message || "MCP returned an error" };
418
- 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);
419
458
  const body = text ? JSON.parse(text) : null;
420
459
  return body?.data?.ok === true ? { ok: true } : { ok: false, reason: "MCP ping did not return ok:true" };
421
460
  } catch (error) {
@@ -450,20 +489,83 @@ function checkMcpConfig(target, file, runtime) {
450
489
  }
451
490
  return errors;
452
491
  }
453
- 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) {
454
551
  const errors = [];
455
552
  for (const skillRoot of paths.skillRoots) {
456
553
  const skill = import_node_path3.default.join(skillRoot, "SKILL.md");
457
554
  if (!import_node_fs2.default.existsSync(skill)) errors.push(`missing ${skill}`);
458
555
  }
459
556
  for (const pluginRoot of paths.pluginRoots) {
460
- const skill = import_node_path3.default.join(pluginRoot, "skills", "cadre", "SKILL.md");
461
- 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
+ }
462
561
  const files = pluginConfigFiles(target, pluginRoot);
463
562
  if (!import_node_fs2.default.existsSync(files.manifest)) errors.push(`missing ${files.manifest}`);
464
563
  if (!import_node_fs2.default.existsSync(files.mcp)) errors.push(`missing ${files.mcp}`);
465
564
  errors.push(...forbiddenThinPayload(pluginRoot).map((entry) => `thin plugin contains forbidden payload ${entry}`));
466
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
+ }
467
569
  }
468
570
  if (paths.marketplaceFile && !import_node_fs2.default.existsSync(paths.marketplaceFile)) errors.push(`missing ${paths.marketplaceFile}`);
469
571
  return errors;
@@ -592,9 +694,31 @@ function writeText(file, text) {
592
694
  import_node_fs3.default.writeFileSync(file, text.endsWith("\n") ? text : `${text}
593
695
  `);
594
696
  }
595
- 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
+ }
596
716
  import_node_fs3.default.rmSync(pluginRoot, { recursive: true, force: true });
597
- 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
+ }
598
722
  if (target === "codex") {
599
723
  writeJson(import_node_path4.default.join(pluginRoot, ".codex-plugin", "plugin.json"), pluginManifest(target, runtime));
600
724
  writeJson(import_node_path4.default.join(pluginRoot, ".mcp.json"), mcpConfig(target, runtime));
@@ -609,8 +733,8 @@ function writePluginRoot(target, pluginRoot, runtime, skillShim) {
609
733
  writeJson(import_node_path4.default.join(pluginRoot, "mcp_config.json"), mcpConfig(target, runtime));
610
734
  }
611
735
  }
612
- function writeTarget(target, paths, runtime, skillShim) {
613
- 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);
614
738
  for (const skillRoot of paths.skillRoots) {
615
739
  import_node_fs3.default.rmSync(skillRoot, { recursive: true, force: true });
616
740
  writeText(import_node_path4.default.join(skillRoot, "SKILL.md"), skillShim);
@@ -752,8 +876,8 @@ function runInstall(argv, context) {
752
876
  `);
753
877
  continue;
754
878
  }
755
- if (!options.check) writeTarget(target, paths, runtime, context.skillShim);
756
- 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);
757
881
  if (!options.check) {
758
882
  const approvals = bootstrapClientApprovals(target);
759
883
  if (!approvals.ok) errors.push(`${target} approval bootstrap failed: ${approvals.error || approvals.path}`);
@@ -867,9 +991,83 @@ async function runCli(argv, context) {
867
991
  if (code !== 0) process.exit(code);
868
992
  }
869
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
+
870
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__ : [];
871
1065
  runCli(process.argv.slice(2), {
872
- 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
+ }
873
1071
  }).catch((error) => {
874
1072
  const message = error instanceof Error ? error.message : String(error);
875
1073
  process.stderr.write(`${message}