@aiwg/cli 2026.10.5 → 2026.10.6

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 (212) hide show
  1. package/agentic/code/addons/composition-engine/lib/runtime.mjs +1401 -0
  2. package/agentic/code/addons/composition-engine/lib/validator.mjs +513 -0
  3. package/agentic/code/addons/composition-engine/schemas/flow-graph.schema.json +372 -0
  4. package/agentic/code/providers/model-capabilities.v1.json +74 -50
  5. package/bin/aiwg.mjs +3 -1
  6. package/dist/src/artifacts/browser-export.js +1 -0
  7. package/dist/src/artifacts/citation-parser.js +8 -1
  8. package/dist/src/artifacts/cli.js +57 -6
  9. package/dist/src/artifacts/fortemi-core-query-adapter.js +2 -0
  10. package/dist/src/artifacts/fortemi-core-sync.js +26 -8
  11. package/dist/src/artifacts/graph-query.js +18 -8
  12. package/dist/src/artifacts/index-adapters.js +339 -0
  13. package/dist/src/artifacts/index-builder.js +143 -14
  14. package/dist/src/artifacts/index-files.js +15 -4
  15. package/dist/src/artifacts/index-reader.js +44 -0
  16. package/dist/src/artifacts/index-refresh.js +114 -55
  17. package/dist/src/artifacts/index-status.js +20 -5
  18. package/dist/src/artifacts/memory-maintenance.js +503 -0
  19. package/dist/src/artifacts/prebuilt-relations.js +3 -1
  20. package/dist/src/artifacts/query-engine.js +263 -108
  21. package/dist/src/artifacts/relations-builder.js +2 -2
  22. package/dist/src/artifacts/source-graph.js +2 -2
  23. package/dist/src/artifacts/types.js +9 -1
  24. package/dist/src/cli/handlers/decision.js +19 -1
  25. package/dist/src/cli/handlers/guided-setup.js +470 -0
  26. package/dist/src/cli/handlers/help.js +2 -2
  27. package/dist/src/cli/handlers/housekeeper.js +1110 -0
  28. package/dist/src/cli/handlers/index.js +4 -2
  29. package/dist/src/cli/handlers/init.js +41 -6
  30. package/dist/src/cli/handlers/local-executor.js +5 -3
  31. package/dist/src/cli/handlers/mc.js +509 -53
  32. package/dist/src/cli/handlers/models.js +32 -2
  33. package/dist/src/cli/handlers/ralph-launcher.js +76 -4
  34. package/dist/src/cli/handlers/rules.js +1 -1
  35. package/dist/src/cli/handlers/script-runner.js +73 -2
  36. package/dist/src/cli/handlers/serve.js +5 -3
  37. package/dist/src/cli/handlers/sessions.js +1 -0
  38. package/dist/src/cli/handlers/setup.js +428 -1
  39. package/dist/src/cli/handlers/skill-lint.js +1 -1
  40. package/dist/src/cli/handlers/subcommands.js +118 -8
  41. package/dist/src/cli/handlers/use.js +279 -93
  42. package/dist/src/cli/handlers/workspace.js +3 -1
  43. package/dist/src/cli/prompt-utils.js +8 -0
  44. package/dist/src/cli/router.js +16 -1
  45. package/dist/src/config/aiwg-config.js +42 -0
  46. package/dist/src/config/cli.js +7 -3
  47. package/dist/src/config/decision-config.js +14 -1
  48. package/dist/src/config/native-sandbox-warnings.js +25 -0
  49. package/dist/src/contributors/validation.js +6 -5
  50. package/dist/src/decision/admission.js +7 -3
  51. package/dist/src/decision/benchmark.js +469 -0
  52. package/dist/src/decision/ledger.js +22 -3
  53. package/dist/src/decision/pricing.js +147 -0
  54. package/dist/src/decision/qualification/gate-evidence.js +18 -15
  55. package/dist/src/decision/qualification/load-staged.js +539 -0
  56. package/dist/src/decision/qualification/load.js +109 -33
  57. package/dist/src/decision/qualification/runner.js +5 -2
  58. package/dist/src/decision/review/service.js +6 -4
  59. package/dist/src/decision/review/validate.js +23 -2
  60. package/dist/src/decision/savings.js +8 -3
  61. package/dist/src/discovery/index.js +492 -0
  62. package/dist/src/discovery/interview.js +233 -0
  63. package/dist/src/discovery/plan-apply.js +571 -0
  64. package/dist/src/discovery/plan-store.js +171 -0
  65. package/dist/src/discovery/plan-types.js +2 -0
  66. package/dist/src/discovery/plan-validation.js +139 -0
  67. package/dist/src/discovery/types.js +2 -0
  68. package/dist/src/extensions/commands/definitions.js +49 -9
  69. package/dist/src/extensions/manifest.js +71 -44
  70. package/dist/src/extensions/project-local-discovery.js +1 -1
  71. package/dist/src/extensions/project-quickref.js +18 -17
  72. package/dist/src/extensions/validation.js +32 -29
  73. package/dist/src/housekeeper/daemon-config.js +148 -0
  74. package/dist/src/housekeeper/ipc.js +84 -0
  75. package/dist/src/housekeeper/lifecycle.js +148 -0
  76. package/dist/src/housekeeper/platform.js +35 -0
  77. package/dist/src/housekeeper/status.js +70 -0
  78. package/dist/src/housekeeper/units.js +114 -0
  79. package/dist/src/jobs/flow.js +22 -21
  80. package/dist/src/lint/rule-activation.js +20 -5
  81. package/dist/src/lint/runner.js +1 -1
  82. package/dist/src/mcp/cli.mjs +5 -6
  83. package/dist/src/mcp/config-file.mjs +6 -2
  84. package/dist/src/mcp/config-layers.mjs +23 -7
  85. package/dist/src/mcp/profiles.js +18 -31
  86. package/dist/src/mcp/profiles.mjs +18 -32
  87. package/dist/src/mcp/registry.js +7 -27
  88. package/dist/src/mcp/registry.mjs +7 -28
  89. package/dist/src/mcp/server.mjs +34 -1
  90. package/dist/src/mcp/tools/agentic-sandbox.mjs +8 -7
  91. package/dist/src/mcp/tools/command-run.mjs +3 -2
  92. package/dist/src/mcp/tools/decision.mjs +49 -48
  93. package/dist/src/mcp/tools/discovery.mjs +46 -21
  94. package/dist/src/mcp/tools/orchestration.mjs +22 -22
  95. package/dist/src/mcp/tools/subsystems.mjs +9 -8
  96. package/dist/src/mcp/tools/worker-invoke.mjs +17 -4
  97. package/dist/src/mcp/tools/writer-profiles.mjs +1 -1
  98. package/dist/src/memory/audit.js +719 -0
  99. package/dist/src/memory/canonical-context.js +392 -13
  100. package/dist/src/memory/canonical-maintenance.js +95 -0
  101. package/dist/src/memory/cli-result.js +22 -0
  102. package/dist/src/memory/cli.js +176 -0
  103. package/dist/src/memory/context-pack.js +57 -6
  104. package/dist/src/memory/cost.js +512 -0
  105. package/dist/src/memory/firewall-classification.d.mts +7 -0
  106. package/dist/src/memory/firewall-classification.mjs +32 -0
  107. package/dist/src/memory/index.js +8 -0
  108. package/dist/src/memory/line-maintenance.js +68 -0
  109. package/dist/src/memory/maintenance-cli.js +286 -0
  110. package/dist/src/memory/maintenance-contract.js +136 -0
  111. package/dist/src/memory/maintenance-index.js +18 -0
  112. package/dist/src/memory/maintenance-owner.js +2 -0
  113. package/dist/src/memory/maintenance-record.js +138 -0
  114. package/dist/src/memory/maintenance.js +254 -0
  115. package/dist/src/memory/provider-memory-adapter.js +154 -0
  116. package/dist/src/memory/recommend-cli.js +83 -0
  117. package/dist/src/memory/recommend.js +269 -0
  118. package/dist/src/memory/scheduled.js +81 -0
  119. package/dist/src/memory/taxonomy.js +44 -0
  120. package/dist/src/mission-protocol/codecs.js +19 -9
  121. package/dist/src/models/config-loader.js +11 -1
  122. package/dist/src/models/model-capabilities.v1.json +74 -50
  123. package/dist/src/models/provider-policy.js +125 -62
  124. package/dist/src/models/resolver.js +45 -8
  125. package/dist/src/models/worker-installation.d.mts +7 -0
  126. package/dist/src/models/worker-installation.mjs +169 -37
  127. package/dist/src/models/wrapper-route.js +1 -1
  128. package/dist/src/output-modes/registry.js +8 -7
  129. package/dist/src/plugin/metadata-validator.js +1 -1
  130. package/dist/src/providers/deploy-version.d.mts +1 -0
  131. package/dist/src/providers/deploy-version.mjs +17 -0
  132. package/dist/src/providers/provider-definitions.js +19 -16
  133. package/dist/src/providers/skill-ownership.d.mts +11 -2
  134. package/dist/src/providers/skill-ownership.mjs +35 -17
  135. package/dist/src/rules/activation.d.mts +11 -2
  136. package/dist/src/rules/activation.mjs +82 -6
  137. package/dist/src/rules/inventory.js +1 -1
  138. package/dist/src/rules/rule-frontmatter.schema.json +2 -0
  139. package/dist/src/schema/zod-validation.d.mts +6 -0
  140. package/dist/src/schema/zod-validation.mjs +50 -0
  141. package/dist/src/serve/executor-registry.js +297 -20
  142. package/dist/src/serve/executor-token.d.mts +1 -0
  143. package/dist/src/serve/executor-token.mjs +8 -0
  144. package/dist/src/serve/shared-host-scheduler.js +1102 -31
  145. package/dist/src/serve/worker-invocation.js +114 -15
  146. package/dist/src/sessions/adapters/claude.js +19 -18
  147. package/dist/src/sessions/adapters/codex.js +10 -9
  148. package/dist/src/sessions/adapters/copilot.js +14 -13
  149. package/dist/src/sessions/adapters/cursor.js +19 -18
  150. package/dist/src/sessions/adapters/deepseek-harness.js +9 -8
  151. package/dist/src/sessions/adapters/factory.js +11 -10
  152. package/dist/src/sessions/adapters/generic.js +32 -23
  153. package/dist/src/sessions/adapters/grokbot.js +35 -35
  154. package/dist/src/sessions/adapters/hermes.js +20 -19
  155. package/dist/src/sessions/adapters/muse.js +50 -49
  156. package/dist/src/sessions/adapters/omp.js +5 -4
  157. package/dist/src/sessions/adapters/openclaw.js +30 -29
  158. package/dist/src/sessions/adapters/opencode.js +26 -26
  159. package/dist/src/sessions/adapters/openhuman.js +24 -23
  160. package/dist/src/sessions/adapters/pi.js +5 -4
  161. package/dist/src/sessions/adapters/windsurf.js +8 -8
  162. package/dist/src/sessions/analytics.js +10 -9
  163. package/dist/src/sessions/candidates.js +7 -6
  164. package/dist/src/sessions/contracts.js +63 -53
  165. package/dist/src/sessions/output-registration.js +11 -10
  166. package/dist/src/sessions/workspace-discovery.js +3 -4
  167. package/dist/src/smiths/context-pipeline/aiwg-md.js +18 -1
  168. package/dist/src/smiths/context-pipeline/claude-hook.js +42 -6
  169. package/dist/src/smiths/context-pipeline/parallelism-section.js +72 -5
  170. package/dist/src/smiths/context-pipeline/workspace-context.js +106 -10
  171. package/dist/src/update/checker.d.mts +4 -0
  172. package/dist/src/update/checker.mjs +14 -0
  173. package/dist/src/writing/exemplar-selection.js +6 -6
  174. package/dist/src/writing/voice-evaluation.js +24 -23
  175. package/dist/src/writing/writer-migration.js +14 -13
  176. package/dist/src/writing/writer-profile.js +19 -18
  177. package/dist/src/writing/writing-brief.js +18 -17
  178. package/dist/src/writing/writing-receipt.js +47 -46
  179. package/package.json +5 -2
  180. package/schemas/decision/DecisionReview.schema.json +78 -1
  181. package/schemas/mission-v1.schema.json +3 -0
  182. package/tools/agents/deploy-agents.mjs +67 -39
  183. package/tools/agents/providers/antigravity.mjs +6 -1
  184. package/tools/agents/providers/base.mjs +19 -13
  185. package/tools/agents/providers/claude.mjs +1 -1
  186. package/tools/agents/providers/codex.mjs +50 -56
  187. package/tools/agents/providers/copilot.mjs +8 -2
  188. package/tools/agents/providers/cursor.mjs +1 -1
  189. package/tools/agents/providers/deepseek-harness.mjs +1 -1
  190. package/tools/agents/providers/factory.mjs +7 -1
  191. package/tools/agents/providers/grok-build.mjs +18 -2
  192. package/tools/agents/providers/grokbot.mjs +1 -1
  193. package/tools/agents/providers/hermes.mjs +7 -13
  194. package/tools/agents/providers/muse-hooks.mjs +21 -14
  195. package/tools/agents/providers/muse.mjs +7 -2
  196. package/tools/agents/providers/omp.mjs +28 -4
  197. package/tools/agents/providers/opencode.mjs +14 -5
  198. package/tools/agents/providers/openhuman.mjs +1 -1
  199. package/tools/agents/providers/pi.mjs +1 -1
  200. package/tools/agents/providers/provider-prepare-coordinator.mjs +29 -9
  201. package/tools/agents/providers/rule-delivery.mjs +263 -71
  202. package/tools/agents/providers/windsurf.mjs +7 -0
  203. package/tools/cli/workspace-status.mjs +5 -0
  204. package/tools/commands/deploy-prompts-codex.mjs +11 -8
  205. package/tools/ralph-external/lib/codex-adapter.mjs +6 -2
  206. package/tools/ralph-external/lib/muse-adapter.mjs +12 -2
  207. package/tools/ralph-external/lib/worker-health.mjs +1 -1
  208. package/tools/ralph-external/lib/worker-isolation.mjs +65 -9
  209. package/tools/ralph-external/process-monitor.mjs +7 -4
  210. package/tools/ralph-external/session-launcher.mjs +280 -32
  211. package/tools/skills/deploy-skills-codex.mjs +11 -7
  212. package/vscode-extension/schemas/aiwg.config.v1.json +11 -1
@@ -32,6 +32,7 @@
32
32
  * --model-tier <tier> Override all artifacts with economy|standard|premium
33
33
  * --as-agents-md Aggregate to single AGENTS.md (OpenAI/Codex)
34
34
  * --create-agents-md Create/update AGENTS.md template
35
+ --no-context-files Preserve WORKSPACE.md, AIWG.md and AGENTS.md (including managed blocks)
35
36
  * --skip-commands-migration Skip deleting the commands directory (warns about duplicate TUI entries) (Factory/Codex/OpenCode/Cursor)
36
37
  * --deploy-source <name> Managed-marker source for deployed artifacts (default: bundled)
37
38
  * --deploy-version <version> Managed-marker version for deployed artifacts (default: source package.json)
@@ -75,6 +76,8 @@ const staticModelCatalog = _require('../../agentic/code/providers/model-catalog.
75
76
  let fs;
76
77
  try { const gfs = _require('graceful-fs'); gfs.gracefulify(realFs); fs = realFs; } catch { fs = realFs; }
77
78
  import path from 'path';
79
+ import { importImpl } from '../_resolve-impl.mjs';
80
+ const { resolveDeployVersion } = await importImpl(import.meta.url, 'providers/deploy-version.mjs');
78
81
  import os from 'os';
79
82
  import readline from 'readline';
80
83
  import { fileURLToPath } from 'url';
@@ -96,20 +99,6 @@ import {
96
99
  resolveAiwgRoot,
97
100
  updateSidecarManifest,
98
101
  } from './providers/base.mjs';
99
- const modelCatalog = loadRuntimeModelCatalog(staticModelCatalog);
100
-
101
- /**
102
- * Read version from package.json at the source root.
103
- * Falls back to 'unknown' if unavailable.
104
- */
105
- function getDeployVersion(srcRoot) {
106
- try {
107
- const pkg = JSON.parse(fs.readFileSync(path.join(srcRoot, 'package.json'), 'utf8'));
108
- return pkg.version || 'unknown';
109
- } catch {
110
- return 'unknown';
111
- }
112
- }
113
102
 
114
103
  // ============================================================================
115
104
  // Provider Registry
@@ -421,10 +410,8 @@ function pruneStaleAiwgArtifacts(provider, target, srcRoot, opts, explicitSource
421
410
  }
422
411
 
423
412
  if (opts.kernelOnly) {
424
- // A kernel-only run deploys skills and nothing else (deployCommands /
425
- // deployRules / deployBehaviors are all forced false above), so it has no
426
- // basis for judging any flat artifact stale. The empty desired set below
427
- // exists for one narrow migration: clearing agents/commands/rules left by
413
+ // Kernel-only delivers skills and rules. The empty desired set below
414
+ // applies only to bulk agents/commands left by
428
415
  // the pre-#152 bulk default, when the bulk install is the only thing this
429
416
  // project ever deployed.
430
417
  //
@@ -438,7 +425,7 @@ function pruneStaleAiwgArtifacts(provider, target, srcRoot, opts, explicitSource
438
425
  }
439
426
  return;
440
427
  }
441
- for (const type of ['agents', 'commands', 'rules']) {
428
+ for (const type of ['agents', 'commands']) {
442
429
  const relPath = provider.paths?.[type];
443
430
  if (!relPath || relPath.endsWith('.md')) continue;
444
431
  const destDir = path.isAbsolute(relPath) ? relPath : path.join(target, relPath);
@@ -499,6 +486,8 @@ export function parseArgs(args = process.argv.slice(2)) {
499
486
  efficiencyModel: null,
500
487
  asAgentsMd: false,
501
488
  createAgentsMd: false,
489
+ contextFiles: true,
490
+ projectScope: false,
502
491
  deployCommands: false,
503
492
  deploySkills: false,
504
493
  deployRules: false,
@@ -509,6 +498,8 @@ export function parseArgs(args = process.argv.slice(2)) {
509
498
  strict: false,
510
499
  reportOnly: true,
511
500
  kernelOnly: false,
501
+ deferRuleProjection: false,
502
+ additionalSources: [],
512
503
  filter: null, // Glob pattern for agent names
513
504
  filterRole: null, // Filter by role: reasoning|coding|efficiency
514
505
  save: false, // Save model config to project models.json
@@ -532,6 +523,11 @@ export function parseArgs(args = process.argv.slice(2)) {
532
523
  for (let i = 0; i < args.length; i++) {
533
524
  const a = args[i];
534
525
  if (a === '--source' && args[i + 1]) cfg.source = path.resolve(args[++i]);
526
+ else if (a === '--additional-source') {
527
+ const source = args[++i];
528
+ if (!source || source.startsWith('--')) throw new Error('--additional-source requires a source directory');
529
+ cfg.additionalSources.push(path.resolve(source));
530
+ }
535
531
  else if (a === '--target' && args[i + 1]) cfg.target = path.resolve(args[++i]);
536
532
  else if (a === '--mode' && args[i + 1]) cfg.mode = String(args[++i]).toLowerCase();
537
533
  else if (a === '--scope') {
@@ -540,6 +536,7 @@ export function parseArgs(args = process.argv.slice(2)) {
540
536
  throw new Error(`--scope expected 'user' or 'project', got '${scope ?? '(missing)'}'`);
541
537
  }
542
538
  cfg.userScope = scope === 'user';
539
+ cfg.projectScope = scope === 'project';
543
540
  }
544
541
  else if (a === '--user') cfg.userScope = true;
545
542
  else if (a === '--dry-run') cfg.dryRun = true;
@@ -563,6 +560,8 @@ export function parseArgs(args = process.argv.slice(2)) {
563
560
  else if (a === '--allow-over-budget') cfg.allowOverBudget = true;
564
561
  else if (a === '--report-only') cfg.reportOnly = true;
565
562
  else if (a === '--kernel-only') cfg.kernelOnly = true;
563
+ // Internal use orchestration: the final source owns rule presentation.
564
+ else if (a === '--defer-rule-projection') cfg.deferRuleProjection = true;
566
565
  else if (a === '--deploy-behaviors') cfg.deployBehaviors = true;
567
566
  else if (a === '--filter' && args[i + 1]) cfg.filter = args[++i];
568
567
  else if (a === '--filter-role' && args[i + 1]) cfg.filterRole = args[++i];
@@ -579,12 +578,12 @@ export function parseArgs(args = process.argv.slice(2)) {
579
578
  // managed-hooks opt-out (default on, mirroring the Claude autoInstall policy).
580
579
  else if (a === '--mcp') cfg.mcp = true;
581
580
  else if (a === '--no-hooks') cfg.hooks = false;
581
+ else if (a === '--no-context-files') cfg.contextFiles = false;
582
582
  else if (a === '--deploy-source' && args[i + 1]) cfg.deploySource = String(args[++i]);
583
583
  else if (a === '--listing-budget') cfg.listingBudget = true;
584
584
  else if (a === '--deploy-version' && args[i + 1]) cfg.deployVersion = String(args[++i]);
585
585
  else if (a === '--help' || a === '-h') {
586
- printHelp();
587
- process.exit(0);
586
+ cfg.help = true;
588
587
  }
589
588
  }
590
589
  return cfg;
@@ -610,7 +609,7 @@ Options:
610
609
  --commands-only Deploy only commands (skip agents)
611
610
  --skills-only Deploy only skills (skip agents)
612
611
  --rules-only Deploy only rules (skip agents)
613
- --kernel-only Deploy kernel skills only and prune managed bulk artifacts
612
+ --kernel-only Deploy kernel skills and rules; prune managed bulk agents/commands
614
613
  --dry-run Show what would be deployed without writing
615
614
  --force Overwrite existing files
616
615
  --provider <name> Target provider (see below)
@@ -630,6 +629,7 @@ Options:
630
629
  (.muse/hooks.json; installed by default)
631
630
  --as-agents-md Aggregate to single AGENTS.md (Codex)
632
631
  --create-agents-md Create/update AGENTS.md template
632
+ --no-context-files Preserve WORKSPACE.md, AIWG.md and AGENTS.md (including managed blocks)
633
633
  --skip-commands-migration Skip deleting the commands directory before skills deployment
634
634
  --listing-budget Honor the provider startup-listing cap even with --copy-all
635
635
  --deploy-source <name> Managed-marker source stamped into deployed artifacts.
@@ -743,7 +743,7 @@ function resolveProvider(name) {
743
743
  console.error('');
744
744
  for (const line of UNSUPPORTED_PROVIDER_HINTS[candidate]) console.error(line);
745
745
  }
746
- process.exit(1);
746
+ throw new Error(`Unknown provider: ${name}`);
747
747
  }
748
748
  return resolved;
749
749
  }
@@ -753,14 +753,17 @@ function resolveProvider(name) {
753
753
  */
754
754
  async function loadProvider(providerName) {
755
755
  const resolved = resolveProvider(providerName);
756
- const providerPath = `./providers/${resolved}.mjs`;
756
+ // Resolve against this module, not the caller's cwd: in-process callers
757
+ // (including module runners such as Vitest) cannot resolve a bare relative
758
+ // specifier held in a variable.
759
+ const providerUrl = new URL(`./providers/${resolved}.mjs`, import.meta.url).href;
757
760
 
758
761
  try {
759
- const provider = await import(providerPath);
762
+ const provider = await import(providerUrl);
760
763
  return provider.default || provider;
761
764
  } catch (err) {
762
765
  console.error(`Failed to load provider '${resolved}':`, err.message);
763
- process.exit(1);
766
+ throw err;
764
767
  }
765
768
  }
766
769
 
@@ -896,7 +899,7 @@ function deepMerge(target, source) {
896
899
  * @param {string} targetDir - Resolved target directory
897
900
  * @returns {Promise<boolean>} true = proceed with migration, false = skip
898
901
  */
899
- async function promptCommandsMigration(cfg, provider, targetDir) {
902
+ async function promptCommandsMigration(cfg, provider, targetDir, interactive = process.stdout.isTTY) {
900
903
  // Home-directory providers share commands across projects — do not delete.
901
904
  if (provider.capabilities?.homeDirectoryDeploy) return false;
902
905
  // Some providers intentionally expose both surfaces with different runtime
@@ -914,7 +917,7 @@ async function promptCommandsMigration(cfg, provider, targetDir) {
914
917
  if (entries.length === 0) return false;
915
918
 
916
919
  // Non-interactive context: migrate silently.
917
- if (cfg.quiet || !process.stdout.isTTY) return true;
920
+ if (cfg.quiet || !interactive) return true;
918
921
 
919
922
  const rel = path.relative(process.cwd(), commandsDir);
920
923
  console.log(`\n⚠ Commands → Skills Migration`);
@@ -948,6 +951,8 @@ async function promptCommandsMigration(cfg, provider, targetDir) {
948
951
 
949
952
  export async function main(args = process.argv.slice(2), internal = {}) {
950
953
  const cfg = parseArgs(args);
954
+ if (cfg.help) { printHelp(); return 0; }
955
+ const modelCatalog = loadRuntimeModelCatalog(staticModelCatalog);
951
956
 
952
957
  // Resolve source directory (default to repo root relative to this script)
953
958
  const __filename = fileURLToPath(import.meta.url);
@@ -956,8 +961,7 @@ export async function main(args = process.argv.slice(2), internal = {}) {
956
961
 
957
962
  // Validate source directory
958
963
  if (!fs.existsSync(srcRoot)) {
959
- console.error(`Source directory not found: ${srcRoot}`);
960
- process.exit(1);
964
+ throw new Error(`Source directory not found: ${srcRoot}`);
961
965
  }
962
966
 
963
967
  // Validate target directory
@@ -1020,6 +1024,10 @@ export async function main(args = process.argv.slice(2), internal = {}) {
1020
1024
 
1021
1025
  // Load provider module
1022
1026
  const provider = await loadProvider(cfg.provider);
1027
+ if (cfg.additionalSources.length && provider.name !== 'omp') throw new Error('--additional-source requires the OMP provider');
1028
+ for (const source of cfg.additionalSources) {
1029
+ if (!fs.statSync(source).isDirectory()) throw new Error(`Additional source is not a directory: ${source}`);
1030
+ }
1023
1031
  if (!cfg.quiet) console.log(`\nLoaded provider: ${provider.name}`);
1024
1032
 
1025
1033
  // Build options for provider
@@ -1038,11 +1046,15 @@ export async function main(args = process.argv.slice(2), internal = {}) {
1038
1046
  codingModel: cfg.codingModel,
1039
1047
  efficiencyModel: cfg.efficiencyModel,
1040
1048
  modelsConfig,
1049
+ modelCatalog,
1050
+ // Warnings belong to this pass, just as they do in an isolated CLI run.
1051
+ warnedCommandsDirs: new Set(),
1041
1052
  asAgentsMd: cfg.asAgentsMd,
1042
- createAgentsMd: cfg.createAgentsMd,
1053
+ createAgentsMd: cfg.contextFiles && cfg.createAgentsMd,
1054
+ contextFiles: cfg.contextFiles,
1043
1055
  deployCommands: cfg.kernelOnly ? false : cfg.deployCommands,
1044
1056
  deploySkills: cfg.kernelOnly ? true : cfg.deploySkills,
1045
- deployRules: cfg.kernelOnly ? false : cfg.deployRules,
1057
+ deployRules: !cfg.deferRuleProjection && (cfg.kernelOnly || cfg.deployRules),
1046
1058
  deployBehaviors: cfg.kernelOnly ? false : cfg.deployBehaviors,
1047
1059
  commandsOnly: cfg.commandsOnly,
1048
1060
  skillsOnly: cfg.skillsOnly || cfg.kernelOnly,
@@ -1051,6 +1063,8 @@ export async function main(args = process.argv.slice(2), internal = {}) {
1051
1063
  reportOnly: cfg.reportOnly,
1052
1064
  allowOverBudget: cfg.allowOverBudget === true,
1053
1065
  kernelOnly: cfg.kernelOnly,
1066
+ deferRuleProjection: cfg.deferRuleProjection,
1067
+ additionalSources: cfg.additionalSources,
1054
1068
  filter: cfg.filter,
1055
1069
  filterRole: cfg.filterRole,
1056
1070
  save: cfg.save,
@@ -1070,17 +1084,23 @@ export async function main(args = process.argv.slice(2), internal = {}) {
1070
1084
  mcp: cfg.mcp === true,
1071
1085
  hooks: cfg.hooks !== false,
1072
1086
  listingBudget: cfg.listingBudget === true,
1073
- deployVersion: cfg.deployVersion || getDeployVersion(srcRoot),
1087
+ deployVersion: resolveDeployVersion(resolveAiwgRoot(srcRoot) || srcRoot, cfg.deployVersion),
1074
1088
  deploySource: cfg.deploySource || 'bundled',
1075
1089
  };
1076
- const { isRuleDeploymentPreparationActive } = await import('./providers/rule-delivery.mjs');
1077
- const preparationActive = isRuleDeploymentPreparationActive();
1090
+ if (provider.name === 'hermes' && cfg.projectScope && !cfg.userScope) {
1091
+ throw new Error('Hermes does not support --scope project: skills are discovered only under HERMES_HOME/skills (default ~/.hermes/skills). Use --scope user or an isolated HERMES_HOME profile shared with Hermes.');
1092
+ }
1093
+ // Deferred kernel source passes must not load the projection dependency
1094
+ // graph. Preparation still owns their staged deployment when a hook is active.
1095
+ const preparationActive = cfg.kernelOnly && cfg.deferRuleProjection
1096
+ ? Boolean(globalThis[Symbol.for('aiwg.provider-preparation-hook.v1')])
1097
+ : (await import('./providers/rule-delivery.mjs')).isRuleDeploymentPreparationActive();
1078
1098
 
1079
1099
  // Commands → Skills migration: prompt then delete the commands directory
1080
1100
  // so stale command files don't create duplicates in the provider TUI.
1081
1101
  if (!preparationActive && !internal.finalizeOnly) {
1082
1102
  if (!cfg.dryRun && !cfg.skipCommandsMigration) {
1083
- const doMigrate = await promptCommandsMigration(cfg, provider, cfg.target);
1103
+ const doMigrate = await promptCommandsMigration(cfg, provider, cfg.target, internal.capture ? false : process.stdout.isTTY);
1084
1104
  if (doMigrate) {
1085
1105
  const commandsRelPath = provider.paths?.commands;
1086
1106
  if (commandsRelPath) {
@@ -1106,7 +1126,13 @@ export async function main(args = process.argv.slice(2), internal = {}) {
1106
1126
 
1107
1127
  // Delegate to provider
1108
1128
  try {
1109
- if (!internal.finalizeOnly) await provider.deploy(opts);
1129
+ if (!internal.finalizeOnly) {
1130
+ if (cfg.kernelOnly && (!cfg.deferRuleProjection || preparationActive)
1131
+ && !['claude', 'codex', 'cursor', 'hermes', 'warp', 'openclaw', 'pi', 'copilot', 'factory', 'opencode', 'windsurf', 'antigravity', 'muse', 'omp', 'grok-build'].includes(provider.name)) {
1132
+ const { deployWithRuleDelivery } = await import('./providers/rule-delivery.mjs');
1133
+ await deployWithRuleDelivery(opts, provider, staged => provider.deploy(staged));
1134
+ } else await provider.deploy(opts);
1135
+ }
1110
1136
  if (preparationActive) return;
1111
1137
 
1112
1138
  const mirroredCommandCount = mirrorSkillsAsCommands(provider, cfg.target, srcRoot, opts);
@@ -1138,11 +1164,13 @@ export async function main(args = process.argv.slice(2), internal = {}) {
1138
1164
  if (cfg.dryRun) {
1139
1165
  console.error('(dry-run mode - no files were modified)');
1140
1166
  }
1141
- process.exit(1);
1167
+ return 1;
1142
1168
  }
1169
+ return 0;
1143
1170
  }
1144
1171
 
1145
1172
  const invokedPath = process.argv[1] ? path.resolve(process.argv[1]) : null;
1146
1173
  if (invokedPath === fileURLToPath(import.meta.url)) {
1147
- await main();
1174
+ try { process.exitCode = (await main()) ?? 0; }
1175
+ catch (error) { console.error(error.message); process.exitCode = 1; }
1148
1176
  }
@@ -2,6 +2,7 @@
2
2
  import fs from 'node:fs';
3
3
  import path from 'node:path';
4
4
  import {
5
+ withRuleDeployment,
5
6
  collectFrameworkArtifacts,
6
7
  createAgentsMdFromTemplate,
7
8
  deployFiles,
@@ -96,7 +97,7 @@ export async function postDeploy(target, opts) {
96
97
  throw new Error('Antigravity global skill deployment is disabled: official 1.1.26 path documentation conflicts');
97
98
  }
98
99
  if (opts.createAgentsMd || (!opts.commandsOnly && !opts.skillsOnly && !opts.rulesOnly)) {
99
- createAgentsMd(target, opts.srcRoot, opts.dryRun);
100
+ if (opts.contextFiles !== false) createAgentsMd(target, opts.srcRoot, opts.dryRun);
100
101
  }
101
102
  if (!opts.quiet) {
102
103
  console.log('Antigravity resources are project scoped. Restart agy after resource changes; authenticate with the provider separately.');
@@ -106,6 +107,10 @@ export async function postDeploy(target, opts) {
106
107
  export function getFileExtension() { return '.md'; }
107
108
 
108
109
  export async function deploy(opts) {
110
+ return withRuleDeployment(opts, { name, paths, kernelSkillsPath }, deploySelected);
111
+ }
112
+
113
+ async function deploySelected(opts) {
109
114
  if (opts.global || opts.user || opts.scope === 'user') {
110
115
  throw new Error('Antigravity global skill deployment is disabled: official 1.1.26 path documentation conflicts');
111
116
  }
@@ -104,7 +104,7 @@ export function listMdFiles(dir, excludePatterns = []) {
104
104
  const excluded = [...defaultExcluded, ...excludePatterns];
105
105
  return fs
106
106
  .readdirSync(dir, { withFileTypes: true })
107
- .filter((e) => e.isFile() && e.name.toLowerCase().endsWith('.md') && !e.name.toLowerCase().endsWith('.soul.md') && !excluded.includes(e.name))
107
+ .filter((e) => e.isFile() && e.name.toLowerCase().endsWith('.md') && !e.name.toLowerCase().endsWith('.soul.md') && !e.name.toLowerCase().endsWith('.core.md') && !excluded.includes(e.name))
108
108
  .map((e) => path.join(dir, e.name));
109
109
  }
110
110
 
@@ -2474,7 +2474,7 @@ export function applyInlineRuleBudget(ruleFiles) {
2474
2474
  /**
2475
2475
  * Tier gate (#1673, enforcement-tiered deployment ADR). Only CRITICAL and HIGH
2476
2476
  * rules are inlined into a provider's always-on rule directory; MEDIUM/LOW are
2477
- * left on-demand (reachable via `aiwg show rule <name>` and the assembled
2477
+ * left on-demand (reachable via `aiwg show rule <name> --body` and the assembled
2478
2478
  * RULES-INDEX pointer index). Index files and rules with no enforcement marker
2479
2479
  * default to always-on, so an un-triaged or structural file is never dropped.
2480
2480
  */
@@ -2558,17 +2558,17 @@ export function renderOnDemandRuleSection(onDemandFiles, opts = {}) {
2558
2558
  'on demand:',
2559
2559
  '',
2560
2560
  '```bash',
2561
- 'aiwg show rule <name>',
2561
+ 'aiwg show rule <name> --body',
2562
2562
  '```',
2563
2563
  '',
2564
- ...names.map((n) => `- \`${n}\` — \`aiwg show rule ${n}\``),
2564
+ ...names.map((n) => `- \`${n}\` — \`aiwg show rule ${n} --body\``),
2565
2565
  ].join('\n');
2566
2566
  }
2567
2567
 
2568
2568
  /**
2569
2569
  * Write a compact on-demand rule index (#1673) into a provider's rule dir.
2570
2570
  * Lists the MEDIUM/LOW rules that are NOT inlined at startup, with the
2571
- * `aiwg show rule <name>` fetch hint. Removes a stale index when empty.
2571
+ * `aiwg show rule <name> --body` fetch hint. Removes a stale index when empty.
2572
2572
  */
2573
2573
  export function writeOnDemandRuleIndex(destDir, onDemandFiles, opts = {}) {
2574
2574
  const indexPath = path.join(destDir, 'RULES-ONDEMAND.md');
@@ -2588,10 +2588,10 @@ export function writeOnDemandRuleIndex(destDir, onDemandFiles, opts = {}) {
2588
2588
  'fetch any rule body on demand:',
2589
2589
  '',
2590
2590
  '```bash',
2591
- 'aiwg show rule <name>',
2591
+ 'aiwg show rule <name> --body',
2592
2592
  '```',
2593
2593
  '',
2594
- ...names.map((n) => `- \`${n}\` — \`aiwg show rule ${n}\``),
2594
+ ...names.map((n) => `- \`${n}\` — \`aiwg show rule ${n} --body\``),
2595
2595
  '',
2596
2596
  ];
2597
2597
  if (demotedNames.length > 0) {
@@ -2605,7 +2605,7 @@ export function writeOnDemandRuleIndex(destDir, onDemandFiles, opts = {}) {
2605
2605
  '(AIWG_RULES_INLINE_BUDGET_TOKENS) and break subagent dispatch with "Prompt is too long".',
2606
2606
  'Fetch any of them before work they govern:',
2607
2607
  '',
2608
- ...demotedNames.map((n) => `- \`${n}\` — \`aiwg show rule ${n}\``),
2608
+ ...demotedNames.map((n) => `- \`${n}\` — \`aiwg show rule ${n} --body\``),
2609
2609
  '',
2610
2610
  );
2611
2611
  }
@@ -2803,7 +2803,9 @@ export function getAddonFiles(srcRoot, options = {}) {
2803
2803
  // ============================================================================
2804
2804
 
2805
2805
  /**
2806
- * Load rules manifest from source directory
2806
+ * Load rules manifest from source directory.
2807
+ * Inventory metadata only: delivery is decided by rule `activation` (rule-delivery.mjs);
2808
+ * the former manifest `tiers` deploy policy was never consulted and was removed (#3450).
2807
2809
  * @param {string} srcRoot - Source root directory
2808
2810
  * @returns {object|null} - Parsed manifest or null if not found
2809
2811
  */
@@ -3168,8 +3170,9 @@ export function migrateCommandsDirectory(commandsDir, opts = {}) {
3168
3170
  const rel = path.relative(process.cwd(), commandsDir);
3169
3171
  // The condition is a property of the directory, not of each deployed unit;
3170
3172
  // emit it once per run no matter how many units pass through.
3171
- if (warnedCommandsDirs.has(commandsDir)) return false;
3172
- warnedCommandsDirs.add(commandsDir);
3173
+ const warned = opts.warnedCommandsDirs || warnedCommandsDirs;
3174
+ if (warned.has(commandsDir)) return false;
3175
+ warned.add(commandsDir);
3173
3176
 
3174
3177
  const stale = listManagedCommandFiles(commandsDir);
3175
3178
  if (stale.length === 0) return false;
@@ -3338,7 +3341,7 @@ export function replaceBoundRulesBlock(content, rules = []) {
3338
3341
  const unique = [...new Map(rules.map(rule => [rule.name, rule])).values()]
3339
3342
  .sort((a, b) => a.name.localeCompare(b.name));
3340
3343
  return `${clean}${clean.endsWith('\n') ? '' : '\n'}\n<!-- AIWG:bound-rules:start -->\n## Bound rules\n\nRequired reading on every invocation: fetch and follow every bound rule below before starting governed work. A summary or discovery pointer does not discharge this obligation.\n\n${unique.map(rule =>
3341
- `- ${rule.name} — ${rule.summary}\n Fetch and follow before governed work: \`aiwg show rule ${rule.name}\`.`
3344
+ `- ${rule.name} — ${rule.summary}\n Fetch and follow before governed work: \`aiwg show rule ${rule.name} --body\`.`
3342
3345
  ).join('\n')}\n<!-- AIWG:bound-rules:end -->\n`;
3343
3346
  }
3344
3347
 
@@ -3347,8 +3350,11 @@ export function injectBoundRules(content, source, opts = {}) {
3347
3350
  return replaceBoundRulesBlock(content, opts.ruleDelivery.bindings.get(path.resolve(source)) || []);
3348
3351
  }
3349
3352
 
3350
- /** All provider output is staged; the complete startup guard runs before promotion. */
3353
+ /** Rule delivery stages output and guards startup before promotion. Deferred
3354
+ * kernel passes leave rule delivery to the final source in the invocation. */
3351
3355
  export async function withRuleDeployment(opts, provider, deploy) {
3356
+ if (opts.kernelOnly && opts.deferRuleProjection && provider.name !== 'warp'
3357
+ && !globalThis[Symbol.for('aiwg.provider-preparation-hook.v1')]) return deploy(opts);
3352
3358
  const { deployWithRuleDelivery } = await import('./rule-delivery.mjs');
3353
3359
  return deployWithRuleDelivery(opts, provider, deploy);
3354
3360
  }
@@ -416,7 +416,7 @@ export async function postDeploy(targetDir, opts) {
416
416
  }
417
417
 
418
418
  // Hook file architecture: write AIWG.md and wire @AIWG.md into CLAUDE.md
419
- if (opts.srcRoot) {
419
+ if (opts.srcRoot && opts.contextFiles !== false) {
420
420
  deployHookFile(targetDir, opts);
421
421
  }
422
422
  }
@@ -35,6 +35,7 @@ const staticModelCatalog = _require('../../../agentic/code/providers/model-catal
35
35
  import path from 'path';
36
36
  import os from 'os';
37
37
  import { spawn } from 'child_process';
38
+ import { pathToFileURL } from 'node:url';
38
39
  import { load as loadYaml } from 'js-yaml';
39
40
  import { classifyModelRole, modelForRole } from './model-role.mjs';
40
41
  import {
@@ -66,7 +67,6 @@ import {
66
67
  parseFrontmatter,
67
68
  resolveAiwgRoot
68
69
  } from './base.mjs';
69
- const modelCatalog = loadRuntimeModelCatalog(staticModelCatalog);
70
70
 
71
71
  function resolveCodexHelperRoot(srcRoot) {
72
72
  const resolved = resolveAiwgRoot(srcRoot);
@@ -101,7 +101,6 @@ export const kernelSkillsPath = '.agents/skills/';
101
101
  // Legacy home-dir skills location written by AIWG versions prior to the #766
102
102
  // regression fix. Pruned on every codex skill deploy so codex-rs stops listing
103
103
  // each AIWG skill twice. Never touches non-AIWG (unmarked) skills.
104
- const legacyHomeSkillsDir = path.join(os.homedir(), '.codex', 'skills');
105
104
 
106
105
  export const support = {
107
106
  agents: 'native',
@@ -125,6 +124,7 @@ export const capabilities = {
125
124
  * Map model shorthand to OpenAI/GPT format
126
125
  */
127
126
  export function mapModel(originalModel, modelCfg, modelsConfig) {
127
+ const modelCatalog = modelCfg.modelCatalog || loadRuntimeModelCatalog(staticModelCatalog);
128
128
  const gptModels = {
129
129
  'opus': modelCatalog.providers.codex.roles.reasoning.id,
130
130
  'sonnet': modelCatalog.providers.codex.roles.coding.id,
@@ -204,7 +204,7 @@ export function renderAgentToml(srcPath, content, models) {
204
204
  */
205
205
  export function transformAgent(srcPath, content, opts) {
206
206
  const { reasoningModel, codingModel, efficiencyModel } = opts;
207
- const catalogModels = modelCatalog.providers.codex.roles;
207
+ const catalogModels = (opts.modelCatalog || loadRuntimeModelCatalog(staticModelCatalog)).providers.codex.roles;
208
208
 
209
209
  const models = {
210
210
  reasoning: reasoningModel || catalogModels.reasoning.id,
@@ -239,6 +239,27 @@ export function deployAgents(agentFiles, targetDir, opts) {
239
239
  }, transformAgent);
240
240
  }
241
241
 
242
+ /** Run the helper in this pass; retain process isolation for troubleshooting. */
243
+ async function runCodexDeployer(scriptPath, args, helperRoot, opts) {
244
+ if (process.env.AIWG_DEPLOY_SUBPROCESS !== '1') {
245
+ const deployer = await import(pathToFileURL(scriptPath).href);
246
+ await deployer.main(args, { homeDir: opts.deploymentHome || os.homedir() });
247
+ return;
248
+ }
249
+ await new Promise((resolve, reject) => {
250
+ const child = spawn('node', [scriptPath, ...args], {
251
+ stdio: 'inherit',
252
+ cwd: helperRoot,
253
+ env: opts.deploymentHome ? { ...process.env, HOME: opts.deploymentHome } : process.env,
254
+ });
255
+ child.on('close', code => {
256
+ if (code === 0) resolve();
257
+ else reject(new Error(`${path.basename(scriptPath)} exited with code ${code}`));
258
+ });
259
+ child.on('error', reject);
260
+ });
261
+ }
262
+
242
263
  /**
243
264
  * Deploy commands via external script
244
265
  *
@@ -257,30 +278,16 @@ export async function deployCommands(targetDir, srcRoot, opts) {
257
278
 
258
279
  console.log('Delegating command deployment to deploy-prompts-codex.mjs (~/.codex/prompts/)...');
259
280
 
260
- return new Promise((resolve, reject) => {
261
- // NOTE: Do NOT pass --target - Codex prompts belong in ~/.codex/prompts/ (home)
262
- const args = ['--source', srcRoot];
263
- if (opts.dryRun) args.push('--dry-run');
264
- if (opts.force) args.push('--force');
265
- if (opts.mode) args.push('--mode', opts.mode);
266
- if (opts.copyStandardSkills === true) args.push('--copy-all');
267
- // A copy-all the deployer forced on the caller's behalf (project-local
268
- // bundles) still honors the startup listing cap (#2561).
269
- if (opts.listingBudget === true) args.push('--listing-budget');
270
-
271
- const child = spawn('node', [scriptPath, ...args], {
272
- stdio: 'inherit',
273
- cwd: helperRoot,
274
- env: opts.deploymentHome ? { ...process.env, HOME: opts.deploymentHome } : process.env
275
- });
276
-
277
- child.on('close', (code) => {
278
- if (code === 0) resolve();
279
- else reject(new Error(`deploy-prompts-codex.mjs exited with code ${code}`));
280
- });
281
-
282
- child.on('error', reject);
283
- });
281
+ // NOTE: Do NOT pass --target - Codex prompts belong in ~/.codex/prompts/ (home)
282
+ const args = ['--source', srcRoot];
283
+ if (opts.dryRun) args.push('--dry-run');
284
+ if (opts.force) args.push('--force');
285
+ if (opts.mode) args.push('--mode', opts.mode);
286
+ if (opts.copyStandardSkills === true) args.push('--copy-all');
287
+ // A copy-all the deployer forced on the caller's behalf (project-local
288
+ // bundles) still honors the startup listing cap (#2561).
289
+ if (opts.listingBudget === true) args.push('--listing-budget');
290
+ await runCodexDeployer(scriptPath, args, helperRoot, opts);
284
291
  }
285
292
 
286
293
  /**
@@ -305,37 +312,23 @@ export async function deploySkills(targetDir, srcRoot, opts) {
305
312
  const crossAgentSkillsDir = path.join(targetDir, '.agents', 'skills');
306
313
  console.log(`Deploying skills to ${crossAgentSkillsDir} (.agents/skills — codex-scanned path)...`);
307
314
 
308
- await new Promise((resolve, reject) => {
309
- const args = ['--source', srcRoot, '--target', crossAgentSkillsDir];
310
- // Overflow past Codex's startup listing cap lands here instead of being
311
- // deployed over the cap (#2561); the index still reaches these skills.
312
- args.push('--standard-target', path.join(targetDir, ...paths.skills.split('/').filter(Boolean)));
313
- if (opts.dryRun) args.push('--dry-run');
314
- if (opts.force) args.push('--force');
315
- if (opts.mode) args.push('--mode', opts.mode);
316
- if (opts.copyStandardSkills === true) args.push('--copy-all');
317
- // A copy-all the deployer forced on the caller's behalf (project-local
318
- // bundles) still honors the startup listing cap (#2561).
319
- if (opts.listingBudget === true) args.push('--listing-budget');
320
-
321
- const child = spawn('node', [scriptPath, ...args], {
322
- stdio: 'inherit',
323
- cwd: helperRoot,
324
- env: opts.deploymentHome ? { ...process.env, HOME: opts.deploymentHome } : process.env
325
- });
326
-
327
- child.on('close', (code) => {
328
- if (code === 0) resolve();
329
- else reject(new Error(`deploy-skills-codex.mjs exited with code ${code}`));
330
- });
331
-
332
- child.on('error', reject);
333
- });
315
+ const args = ['--source', srcRoot, '--target', crossAgentSkillsDir];
316
+ // Overflow past Codex's startup listing cap lands here instead of being
317
+ // deployed over the cap (#2561); the index still reaches these skills.
318
+ args.push('--standard-target', path.join(targetDir, ...paths.skills.split('/').filter(Boolean)));
319
+ if (opts.dryRun) args.push('--dry-run');
320
+ if (opts.force) args.push('--force');
321
+ if (opts.mode) args.push('--mode', opts.mode);
322
+ if (opts.copyStandardSkills === true) args.push('--copy-all');
323
+ // A copy-all the deployer forced on the caller's behalf (project-local
324
+ // bundles) still honors the startup listing cap (#2561).
325
+ if (opts.listingBudget === true) args.push('--listing-budget');
326
+ await runCodexDeployer(scriptPath, args, helperRoot, opts);
334
327
 
335
328
  // Self-heal: prune AIWG-managed skill dirs left behind in the legacy
336
329
  // ~/.codex/skills/ home location by pre-fix versions, so codex-rs stops
337
330
  // listing each skill twice.
338
- pruneLegacyCodexSkills(opts, opts.legacyCodexSkills || legacyHomeSkillsDir);
331
+ pruneLegacyCodexSkills(opts, opts.legacyCodexSkills || path.join(os.homedir(), '.codex', 'skills'));
339
332
  }
340
333
 
341
334
  /**
@@ -346,7 +339,7 @@ export async function deploySkills(targetDir, srcRoot, opts) {
346
339
  * the `.aiwg-managed` marker are removed — user-authored skills are never
347
340
  * touched. The now-empty legacy dir is removed if AIWG owned everything in it.
348
341
  */
349
- export function pruneLegacyCodexSkills(opts = {}, legacyDir = legacyHomeSkillsDir) {
342
+ export function pruneLegacyCodexSkills(opts = {}, legacyDir = path.join(os.homedir(), '.codex', 'skills')) {
350
343
  let entries;
351
344
  try {
352
345
  entries = fs.readdirSync(legacyDir, { withFileTypes: true });
@@ -401,6 +394,7 @@ export function deployRules(ruleFiles, targetDir, opts) {
401
394
  * Aggregate agents to single AGENTS.md file
402
395
  */
403
396
  export function aggregateToAgentsMd(agentFiles, destPath, opts) {
397
+ if (opts.contextFiles === false) return 0;
404
398
  const lines = ['# AIWG agent definitions', '', 'Read the selected definition before invoking an agent.', ''];
405
399
  for (const file of agentFiles) {
406
400
  const { metadata } = parseFrontmatter(fs.readFileSync(file, 'utf8'));
@@ -518,7 +512,7 @@ export async function postDeploy(targetDir, opts) {
518
512
  initializeFrameworkWorkspace(targetDir, opts.mode, opts.dryRun, opts.srcRoot);
519
513
 
520
514
  if (opts.createAgentsMd) {
521
- createAgentsMd(targetDir, opts.srcRoot, opts.dryRun);
515
+ if (opts.contextFiles !== false) createAgentsMd(targetDir, opts.srcRoot, opts.dryRun);
522
516
  }
523
517
  }
524
518