@aiwg/cli 2026.10.19 → 2026.11.1

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 (143) hide show
  1. package/README.md +1 -0
  2. package/agentic/code/providers/flue/README.md +2 -1
  3. package/dist/src/artifacts/cli.js +3 -2
  4. package/dist/src/artifacts/discover-facets.js +2 -0
  5. package/dist/src/artifacts/discover-session-facets.js +14 -0
  6. package/dist/src/artifacts/fortemi-core-query-adapter.js +4 -4
  7. package/dist/src/artifacts/framework-capabilities.js +7 -3
  8. package/dist/src/artifacts/index-builder.js +2 -3
  9. package/dist/src/artifacts/query-engine-discover-output.js +3 -3
  10. package/dist/src/artifacts/query-engine-discover.js +61 -14
  11. package/dist/src/artifacts/query-engine-entries.js +52 -9
  12. package/dist/src/artifacts/query-engine-installation.js +27 -0
  13. package/dist/src/artifacts/query-engine-rules.js +1 -2
  14. package/dist/src/artifacts/query-engine-scoring.js +33 -31
  15. package/dist/src/artifacts/query-engine-show-card.js +6 -2
  16. package/dist/src/artifacts/query-engine-show.js +2 -2
  17. package/dist/src/artifacts/relations.js +17 -10
  18. package/dist/src/cli/handlers/bundle-declaration.js +55 -0
  19. package/dist/src/cli/handlers/bundle-deployment-mode.js +71 -0
  20. package/dist/src/cli/handlers/bundle-hash-prune.js +37 -0
  21. package/dist/src/cli/handlers/bundle-reconciliation.js +140 -0
  22. package/dist/src/cli/handlers/checkpoint.js +143 -0
  23. package/dist/src/cli/handlers/help.js +1 -0
  24. package/dist/src/cli/handlers/index.js +4 -2
  25. package/dist/src/cli/handlers/models-resource-sample.js +7 -3
  26. package/dist/src/cli/handlers/ralph-launcher.js +1 -1
  27. package/dist/src/cli/handlers/refresh-bundles.js +35 -0
  28. package/dist/src/cli/handlers/refresh-rule-inventory.js +10 -0
  29. package/dist/src/cli/handlers/refresh.js +15 -52
  30. package/dist/src/cli/handlers/remove-bundled.js +7 -4
  31. package/dist/src/cli/handlers/remove-flue-modules.js +19 -0
  32. package/dist/src/cli/handlers/remove-historical-bundle.js +18 -0
  33. package/dist/src/cli/handlers/remove.js +8 -0
  34. package/dist/src/cli/handlers/script-runner.js +12 -1
  35. package/dist/src/cli/handlers/steward-signing.js +44 -0
  36. package/dist/src/cli/handlers/steward.js +5 -0
  37. package/dist/src/cli/handlers/subcommands-list-format.js +4 -4
  38. package/dist/src/cli/handlers/update.js +18 -8
  39. package/dist/src/cli/handlers/use-additive-bundles.js +87 -0
  40. package/dist/src/cli/handlers/use-bundle-counts.js +5 -1
  41. package/dist/src/cli/handlers/use-owned-counts.js +75 -0
  42. package/dist/src/cli/handlers/use-provider-results.js +17 -0
  43. package/dist/src/cli/handlers/use.js +53 -114
  44. package/dist/src/cli/router.js +12 -2
  45. package/dist/src/cli/services/deployment-verification.js +2 -1
  46. package/dist/src/cli/user-scope-mirror.js +3 -1
  47. package/dist/src/config/aiwg-config.js +15 -6
  48. package/dist/src/config/cli.js +1 -0
  49. package/dist/src/config/delivery-validation.js +21 -0
  50. package/dist/src/config/framework-aliases.js +14 -0
  51. package/dist/src/config/host-resource-report.d.mts +1 -1
  52. package/dist/src/config/host-resource-report.mjs +23 -4
  53. package/dist/src/config/host-resource-runtime.d.mts +8 -0
  54. package/dist/src/config/host-resource-runtime.mjs +67 -24
  55. package/dist/src/config/index-graph-overrides.js +4 -0
  56. package/dist/src/config/installed-selection.js +9 -1
  57. package/dist/src/config/installed-validation.js +35 -0
  58. package/dist/src/config/worker-attribution.d.mts +7 -0
  59. package/dist/src/config/worker-attribution.mjs +44 -0
  60. package/dist/src/delivery/git.js +62 -0
  61. package/dist/src/delivery/pr.js +149 -0
  62. package/dist/src/delivery/tracker.js +33 -0
  63. package/dist/src/discovery/interview.js +1 -1
  64. package/dist/src/extensions/claude-hooks-installer.js +1 -0
  65. package/dist/src/extensions/loader.js +2 -1
  66. package/dist/src/extensions/project-local-doctor.js +1 -1
  67. package/dist/src/extensions/project-local-remove.js +3 -3
  68. package/dist/src/issues/cli.js +12 -3
  69. package/dist/src/issues/external-cli.js +76 -0
  70. package/dist/src/issues/live.js +18 -1
  71. package/dist/src/issues/tracker-policy.js +17 -0
  72. package/dist/src/mcp/cli.mjs +12 -7
  73. package/dist/src/mcp/helpers.mjs +5 -1
  74. package/dist/src/mcp/http-options.mjs +101 -0
  75. package/dist/src/mcp/http-tools.mjs +51 -0
  76. package/dist/src/mcp/http-transport.mjs +201 -0
  77. package/dist/src/mcp/server.mjs +9 -7
  78. package/dist/src/mcp/tool-context.mjs +25 -0
  79. package/dist/src/mcp/tools/orchestration.mjs +2 -1
  80. package/dist/src/mcp/tools/worker-invoke.mjs +2 -1
  81. package/dist/src/mcp/tools/worker-stdin-runtime.mjs +12 -0
  82. package/dist/src/models/conductor-data-policy.d.mts +3 -2
  83. package/dist/src/models/conductor-data-policy.mjs +94 -5
  84. package/dist/src/models/worker-plan.js +3 -3
  85. package/dist/src/models/worker-selection-policy.js +2 -1
  86. package/dist/src/providers/deployment-lock.js +77 -0
  87. package/dist/src/providers/deployment-ownership.d.mts +12 -2
  88. package/dist/src/providers/deployment-ownership.mjs +127 -19
  89. package/dist/src/providers/deployment-preservation.d.mts +6 -0
  90. package/dist/src/providers/deployment-preservation.mjs +113 -0
  91. package/dist/src/providers/deployment-removal.js +4 -2
  92. package/dist/src/providers/flue-package-mode.js +19 -0
  93. package/dist/src/providers/provider-definitions.js +4 -0
  94. package/dist/src/providers/skill-ownership.mjs +1 -0
  95. package/dist/src/research/reference-match.js +4 -0
  96. package/dist/src/serve/worker-invocation-preparation.js +3 -1
  97. package/dist/src/serve/worker-invocation.js +2 -0
  98. package/dist/src/skills/run.js +5 -0
  99. package/dist/src/smiths/hook-bridge/codex-translator.js +3 -1
  100. package/dist/src/smiths/hook-bridge/hermes-translator.js +3 -1
  101. package/dist/src/smiths/hook-bridge/prompt-discovery-gaps.js +6 -0
  102. package/package.json +5 -2
  103. package/schemas/models/model-config-compatibility.v1.schema.json +4 -0
  104. package/tools/agents/deploy-agents.mjs +21 -1
  105. package/tools/agents/deploy-options.mjs +2 -0
  106. package/tools/agents/providers/base-contract.mjs +7 -1
  107. package/tools/agents/providers/base-inventory.mjs +41 -14
  108. package/tools/agents/providers/base-kernel-skills.mjs +9 -5
  109. package/tools/agents/providers/base-migrations.mjs +1 -0
  110. package/tools/agents/providers/base-skill-copy.mjs +9 -1
  111. package/tools/agents/providers/base.mjs +1 -1
  112. package/tools/agents/providers/claude.mjs +2 -1
  113. package/tools/agents/providers/codex.mjs +5 -1
  114. package/tools/agents/providers/conductor-data-guard.mjs +35 -11
  115. package/tools/agents/providers/flue-bundles.mjs +42 -0
  116. package/tools/agents/providers/flue-cloudflare.mjs +20 -0
  117. package/tools/agents/providers/flue-project.mjs +45 -6
  118. package/tools/agents/providers/flue-skill-copy.mjs +25 -0
  119. package/tools/agents/providers/flue-skills.mjs +45 -0
  120. package/tools/agents/providers/flue-specialists.mjs +36 -18
  121. package/tools/agents/providers/flue-validation.mjs +14 -0
  122. package/tools/agents/providers/flue.mjs +12 -8
  123. package/tools/agents/providers/hermes-skill-lifecycle.mjs +1 -0
  124. package/tools/agents/providers/muse-hooks.mjs +4 -0
  125. package/tools/agents/providers/muse-prompt-discovery.mjs +22 -0
  126. package/tools/agents/providers/provider-prepare-coordinator.mjs +15 -10
  127. package/tools/agents/providers/rule-delivery-surface.mjs +18 -1
  128. package/tools/agents/providers/rule-deployment-commit.mjs +24 -0
  129. package/tools/agents/providers/rule-deployment-prepare.mjs +4 -0
  130. package/tools/agents/providers/skill-copy-prune.mjs +49 -0
  131. package/tools/agents/providers/stale-artifact-prune.mjs +10 -8
  132. package/tools/ralph-external/lib/worker-capture.mjs +157 -0
  133. package/tools/ralph-external/lib/worker-health.mjs +3 -0
  134. package/tools/ralph-external/lib/worker-invocation-processes.mjs +9 -6
  135. package/tools/ralph-external/lib/worker-launch-cli.mjs +10 -1
  136. package/tools/ralph-external/lib/worker-process-identity.mjs +30 -0
  137. package/tools/ralph-external/lib/worker-retry-evidence.mjs +87 -6
  138. package/tools/ralph-external/lib/worker-termination.mjs +56 -6
  139. package/tools/ralph-external/process-monitor.mjs +12 -18
  140. package/tools/ralph-external/session-launcher.mjs +43 -29
  141. package/tools/skills/codex-skill-metadata.mjs +22 -0
  142. package/tools/skills/deploy-skills-codex.mjs +8 -7
  143. package/vscode-extension/schemas/aiwg.config.v1.json +59 -19
@@ -0,0 +1,35 @@
1
+ // Redeploy each selected bundle only to its declared providers.
2
+ import { bundleCopyArgs } from './bundle-deployment-mode.js';
3
+ import { withInstalledSelection } from '../../config/installed-selection.js';
4
+ import { bundleProviders, bundleUseName, pruneUndeclaredBundles, pruneAfterScopedDeployments } from './bundle-reconciliation.js';
5
+ export async function refreshDeclaredBundles(ctx, config, frameworks, requested, opts) {
6
+ const failed = [];
7
+ if (await pruneUndeclaredBundles(ctx.cwd, config, requested, opts.dryRun, opts.frameworkRoot))
8
+ failed.push('prune');
9
+ if (!frameworks.length && !opts.quiet)
10
+ console.log(' No installed frameworks or addons to re-deploy');
11
+ for (const fw of frameworks)
12
+ for (const provider of bundleProviders(config?.installed ?? {}, fw, requested)) {
13
+ const copyArgs = bundleCopyArgs(config?.installed ?? {}, fw, provider);
14
+ if (opts.dryRun) {
15
+ console.log(` Would re-deploy: ${fw} for ${provider} — aiwg use ${bundleUseName(fw)} --provider ${provider}${copyArgs.length ? ` ${copyArgs.join(' ')}` : ''}`);
16
+ continue;
17
+ }
18
+ const result = await withInstalledSelection(ctx.cwd, config?.installed, () => opts.handler.execute({ ...ctx, frameworkRoot: opts.frameworkRoot,
19
+ args: [bundleUseName(fw), '--provider', provider, '--target', ctx.cwd, '--yes', '--json', ...copyArgs,
20
+ ...(opts.forceDeploy ? ['--force'] : []), ...(ctx.args.includes('--allow-over-budget') ? ['--allow-over-budget'] : []), ...opts.modelDeployArgs],
21
+ rawArgs: ['use', fw],
22
+ }));
23
+ if (result.exitCode) {
24
+ failed.push(fw);
25
+ if (!opts.quiet)
26
+ console.warn(`Deploy issue: ${fw} for ${provider} (exit ${result.exitCode}): ${result.message || ''}`);
27
+ }
28
+ else if (!opts.quiet)
29
+ console.log(`Deployed: ${fw} for ${provider}`);
30
+ }
31
+ if (!opts.dryRun && await pruneAfterScopedDeployments(ctx.cwd, config, requested, opts.frameworkRoot))
32
+ failed.push('prune');
33
+ return failed;
34
+ }
35
+ //# sourceMappingURL=refresh-bundles.js.map
@@ -0,0 +1,10 @@
1
+ // Include native core projections when inventorying still-shipped rule files.
2
+ import fs from 'node:fs/promises';
3
+ import path from 'node:path';
4
+ import { parseRuleFrontmatter } from '../../rules/activation.mjs';
5
+ export async function bundledRuleOutputNames(file) {
6
+ const name = path.basename(file);
7
+ const parsed = parseRuleFrontmatter(await fs.readFile(file, 'utf8'));
8
+ return parsed.valid && parsed.rule?.activation === 'core' ? [name, `core-${name}`] : [name];
9
+ }
10
+ //# sourceMappingURL=refresh-rule-inventory.js.map
@@ -19,6 +19,9 @@ import { promisify } from 'node:util';
19
19
  const execFileAsync = promisify(execFile);
20
20
  import { createScriptRunner } from './script-runner.js';
21
21
  import { createUseHandler } from './use.js';
22
+ import { automaticRemovalAllowed } from '../../providers/deployment-preservation.mjs';
23
+ import { refreshDeclaredBundles } from './refresh-bundles.js';
24
+ import { bundledRuleOutputNames } from './refresh-rule-inventory.js';
22
25
  import { getFrameworkRoot } from '../../channel/manager.mjs';
23
26
  import { refreshAllPackages } from '../../packages/registry.js';
24
27
  import { resolveActiveProvider } from '../provider-resolution.js';
@@ -76,8 +79,10 @@ export async function currentBundledRuleBasenames(frameworkRoot) {
76
79
  continue;
77
80
  }
78
81
  for (const entry of entries) {
79
- if (entry.isFile() && entry.name.endsWith('.md'))
80
- names.add(entry.name);
82
+ if (entry.isFile() && entry.name.endsWith('.md')) {
83
+ for (const name of await bundledRuleOutputNames(path.join(rulesDir, entry.name)))
84
+ names.add(name);
85
+ }
81
86
  }
82
87
  }
83
88
  }
@@ -278,6 +283,8 @@ export async function pruneStaleManagedAgentFiles(options) {
278
283
  record(trackedSkipped, provider, hit.relativePath);
279
284
  continue;
280
285
  }
286
+ if (!automaticRemovalAllowed(options.projectRoot, provider, hit.absolutePath))
287
+ continue;
281
288
  if (!options.dryRun)
282
289
  await fs.rm(hit.absolutePath, { force: true });
283
290
  record(removals, provider, hit.relativePath);
@@ -331,15 +338,15 @@ async function reconcileDeployedToAfterPrune(projectRoot, removals, refreshedPro
331
338
  let outstanding = removal.paths.length;
332
339
  const byAgentsDesc = entries
333
340
  .slice()
334
- .sort((a, b) => b.deployedTo[removal.provider].agents - a.deployedTo[removal.provider].agents);
341
+ .sort((a, b) => (b.deployedTo[removal.provider].agents ?? 0) - (a.deployedTo[removal.provider].agents ?? 0));
335
342
  for (const entry of byAgentsDesc) {
336
343
  if (outstanding <= 0)
337
344
  break;
338
345
  const counts = entry.deployedTo[removal.provider];
339
- const deduct = Math.min(counts.agents, outstanding);
346
+ const deduct = Math.min(counts.agents ?? 0, outstanding);
340
347
  if (deduct <= 0)
341
348
  continue;
342
- counts.agents -= deduct;
349
+ counts.agents = (counts.agents ?? 0) - deduct;
343
350
  outstanding -= deduct;
344
351
  changed = true;
345
352
  }
@@ -550,53 +557,9 @@ export const refreshHandler = {
550
557
  : requestedFrameworks;
551
558
  if (!quiet)
552
559
  ui.info(dryRun ? 'Would re-deploy frameworks...' : 'Re-deploying frameworks...');
553
- if (!dryRun) {
554
- if (frameworks.length === 0 && !quiet) {
555
- ui.dim(' No installed frameworks or addons to re-deploy');
556
- }
557
- for (const fw of frameworks) {
558
- // Invoke the active installation's handler directly. The historical
559
- // deploy.mjs bridge shells out to the first `aiwg` on PATH, which can
560
- // be a different version/root and therefore cannot safely refresh
561
- // addons installed by this package (#143/#2102).
562
- const useResult = await activeUseHandler.execute({
563
- ...ctx,
564
- cwd: ctx.cwd,
565
- frameworkRoot,
566
- args: [
567
- fw,
568
- '--provider', detectedProvider,
569
- '--target', ctx.cwd,
570
- '--yes',
571
- '--json',
572
- // #2507: give operators a reclaim path for artifacts an older
573
- // AIWG left behind without a managed marker.
574
- ...(forceDeploy ? ['--force'] : []),
575
- ...(hasFlag(ctx.args, '--allow-over-budget') ? ['--allow-over-budget'] : []),
576
- ...modelDeployArgs,
577
- ],
578
- rawArgs: ['use', fw],
579
- });
580
- if (useResult.exitCode === 0) {
581
- if (!quiet)
582
- ui.success(`Deployed: ${fw}`);
583
- }
584
- else {
585
- deploymentFailures.push(fw);
586
- if (!quiet)
587
- ui.warn(`Deploy issue: ${fw} (exit ${useResult.exitCode})`);
588
- }
589
- }
590
- }
591
- else {
592
- if (!quiet) {
593
- if (frameworks.length === 0)
594
- ui.dim(' No installed frameworks or addons');
595
- for (const fw of frameworks) {
596
- ui.dim(` Would re-deploy: ${fw}`);
597
- }
598
- }
599
- }
560
+ deploymentFailures.push(...await refreshDeclaredBundles(ctx, refreshConfig, frameworks, provider, {
561
+ handler: activeUseHandler, frameworkRoot, dryRun, quiet, forceDeploy, modelDeployArgs,
562
+ }));
600
563
  // Runtime updates can change the corpus even when there are no recorded
601
564
  // deployments. Refresh both discovery representations, independently of use.
602
565
  if (!dryRun) {
@@ -6,6 +6,7 @@ import { resolveProjectAiwgDir } from '../../config/project-artifacts.js';
6
6
  import { removeClaudeAttribution } from '../../extensions/claude-hooks-installer.js';
7
7
  import { planDeploymentRemoval } from '../../providers/deployment-removal.js';
8
8
  import { applyRemovalTransaction } from '../../providers/removal-transaction.js';
9
+ import { refreshRemainingFlueModules } from './remove-flue-modules.js';
9
10
  function counts(decisions) {
10
11
  const result = { agents: 0, commands: 0, skills: 0, rules: 0 };
11
12
  for (const item of decisions) {
@@ -22,7 +23,7 @@ function counts(decisions) {
22
23
  }
23
24
  return result;
24
25
  }
25
- const summary = (value) => `${value.agents} agents, ${value.commands} commands, ${value.rules} rules, ${value.skills} skills`;
26
+ const summary = (value) => `${value.agents ?? 0} agents, ${value.commands ?? 0} commands, ${value.rules ?? 0} rules, ${value.skills ?? 0} skills`;
26
27
  export async function removeBundledDeployment(project, id, owner, config, providers, opts) {
27
28
  const entry = config.installed[id];
28
29
  const configBefore = JSON.stringify(config);
@@ -31,7 +32,7 @@ export async function removeBundledDeployment(project, id, owner, config, provid
31
32
  let removed = 0, modern = false;
32
33
  try {
33
34
  for (const provider of providers) {
34
- const plan = planDeploymentRemoval(project, provider, owner, providers.length === Object.keys(entry.deployedTo).length);
35
+ const plan = planDeploymentRemoval(project, provider, owner, opts.includeProject ?? providers.length === Object.keys(entry.deployedTo).length, opts.preserveRoots);
35
36
  modern ||= !plan.legacy;
36
37
  lines.push(` Provider ${provider}:`);
37
38
  lines.push(` Receipt inventory: ${summary(counts(plan.decisions))}; ${plan.recorded.length} owned file record(s).`);
@@ -62,12 +63,12 @@ export async function removeBundledDeployment(project, id, owner, config, provid
62
63
  const residual = counts(retained);
63
64
  let unverifiable = 0;
64
65
  for (const kind of Object.keys(residual)) {
65
- const gap = Math.max(0, entry.deployedTo[provider][kind] - inventory[kind]);
66
+ const gap = Math.max(0, (entry.deployedTo[provider][kind] ?? 0) - inventory[kind]);
66
67
  residual[kind] += gap;
67
68
  unverifiable += gap;
68
69
  }
69
70
  if (retained.length || unverifiable) {
70
- entry.deployedTo[provider] = residual;
71
+ entry.deployedTo[provider] = { ...residual, ...(entry.deployedTo[provider].copy === undefined ? {} : { copy: entry.deployedTo[provider].copy }) };
71
72
  if (unverifiable)
72
73
  lines.push(` Retained ${unverifiable} unverifiable historical artifact count(s); no ownership inferred.`);
73
74
  lines.push(` Partial removal: ${retained.length} owned file record(s) retained; deployedTo counts reconciled.`);
@@ -123,6 +124,8 @@ export async function removeBundledDeployment(project, id, owner, config, provid
123
124
  catch { /* Nonempty directories preserve operator files and remaining receipts. */ }
124
125
  }
125
126
  }
127
+ if (!opts.dryRun && !opts.keepRegistry && providers.includes('flue'))
128
+ await refreshRemainingFlueModules(project, config);
126
129
  lines.push(`${opts.dryRun ? 'Would remove' : 'Removed'} ${removed} unchanged recorded file(s); operator files preserved.`);
127
130
  return { exitCode: 0, message: lines.join('\n') };
128
131
  }
@@ -0,0 +1,19 @@
1
+ // Regenerate shared Flue app modules after a bundle's files are removed.
2
+ import { getFrameworkRoot } from '../../channel/manager.mjs';
3
+ import { REGISTRY_ID_TO_USE_NAME } from '../../config/framework-aliases.js';
4
+ import { bundleCopyArgs } from './bundle-deployment-mode.js';
5
+ import { withInstalledSelection } from '../../config/installed-selection.js';
6
+ export async function refreshRemainingFlueModules(project, config) {
7
+ const id = Object.keys(config.installed).find(id => config.installed[id].deployedTo.flue?.skills !== undefined);
8
+ if (!id)
9
+ return;
10
+ const { useHandler } = await import('./use.js');
11
+ const name = REGISTRY_ID_TO_USE_NAME[id] ?? id;
12
+ const frameworkRoot = await getFrameworkRoot();
13
+ const result = await withInstalledSelection(project, config.installed, () => useHandler.execute({
14
+ cwd: project, frameworkRoot, args: [name, '--provider', 'flue', '--target', project, '--yes', '--json', ...bundleCopyArgs(config.installed, id, 'flue')], rawArgs: ['use', name],
15
+ }));
16
+ if (result.exitCode)
17
+ throw new Error(`Flue module regeneration failed: ${result.message || name}`);
18
+ }
19
+ //# sourceMappingURL=remove-flue-modules.js.map
@@ -0,0 +1,18 @@
1
+ import { frameworkRegistryId } from '../../config/framework-aliases.js';
2
+ import { bundleDeploymentHistory } from './bundle-deployment-mode.js';
3
+ import { refreshRemainingFlueModules } from './remove-flue-modules.js';
4
+ import { removeBundledDeployment } from './remove-bundled.js';
5
+ export async function removeHistoricalBundle(project, id, provider, config, dryRun) {
6
+ const owner = frameworkRegistryId(id);
7
+ const history = bundleDeploymentHistory(project);
8
+ const providers = Object.keys(history).filter(p => (!provider || p === provider) && history[p][owner]);
9
+ if (!providers.length)
10
+ return undefined;
11
+ const historical = structuredClone(config);
12
+ historical.installed[id] = { deployedTo: Object.fromEntries(providers.map(p => [p, {}])) };
13
+ const result = await removeBundledDeployment(project, id, owner, historical, providers, { dryRun, keepRegistry: true });
14
+ if (!dryRun && !result.exitCode && providers.includes('flue'))
15
+ await refreshRemainingFlueModules(project, config);
16
+ return result;
17
+ }
18
+ //# sourceMappingURL=remove-historical-bundle.js.map
@@ -29,6 +29,7 @@ export const removeHandler = {
29
29
  'Project-local removal reverts deployed artifacts using recorded hashes; bundle source is preserved.',
30
30
  '',
31
31
  'Options:',
32
+ ' --declare Drop the provider declaration without removing files (requires --provider).',
32
33
  ' --dry-run List planned removals and preserved paths with reasons; write nothing.',
33
34
  ' --provider <p> Select one recorded provider deployment.',
34
35
  ' --keep-registry Keep project installed/deployedTo records after removal. By default,',
@@ -56,6 +57,8 @@ export const removeHandler = {
56
57
  ].join('\n') };
57
58
  },
58
59
  async execute(ctx) {
60
+ if (ctx.args.includes('--declare'))
61
+ return (await import('./bundle-declaration.js')).declareBundle(ctx, true);
59
62
  // Explicit provider removal is separate from framework removal. The native
60
63
  // adapter validates receipt hashes and preserves operator modifications.
61
64
  const nativeRemovalProvider = parseRemoveProvider(ctx.args);
@@ -131,6 +134,11 @@ export const removeHandler = {
131
134
  const projectDir = getProjectDir({ cwd: ctx.cwd }, ctx.args);
132
135
  const config = await readAiwgConfig(projectDir);
133
136
  const entry = config?.installed?.[positionalArg];
137
+ if (config && !entry) {
138
+ const result = await (await import('./remove-historical-bundle.js')).removeHistoricalBundle(projectDir, positionalArg, providerParse.provider, config, ctx.args.includes('--dry-run'));
139
+ if (result)
140
+ return result;
141
+ }
134
142
  if (config && entry && entry.source !== 'project-local') {
135
143
  const { resolveFrameworkDir } = await import('./use.js');
136
144
  const { removeBundledDeployment } = await import('./remove-bundled.js');
@@ -15,9 +15,15 @@ import { pathToFileURL } from 'node:url';
15
15
  import { Console } from 'node:console';
16
16
  import { Writable } from 'node:stream';
17
17
  import { writeSync } from 'node:fs';
18
+ import { providerDeploymentLockEnvironment } from '../../providers/deployment-lock.js';
18
19
  // Embedded deployers use process-wide console/environment APIs. Serialize the
19
20
  // complete invocation (including import), and restore them even after failure.
20
21
  let deploymentQueue = Promise.resolve();
22
+ function reportFlueWarnings(message, sink = console) {
23
+ for (const line of message.split(/\r?\n/))
24
+ if (line.startsWith('Flue (experimental):'))
25
+ sink.warn(line);
26
+ }
21
27
  /**
22
28
  * Default script runner implementation
23
29
  *
@@ -57,7 +63,7 @@ export class DefaultScriptRunner {
57
63
  const stdio = options.capture
58
64
  ? ['pipe', options.stdoutFd ?? 'pipe', 'pipe']
59
65
  : 'inherit';
60
- const environment = { ...process.env, ...options.env };
66
+ const environment = { ...process.env, ...providerDeploymentLockEnvironment(), ...options.env };
61
67
  for (const name of options.omitEnv ?? [])
62
68
  delete environment[name];
63
69
  const child = spawn('node', [fullPath, ...args], {
@@ -130,6 +136,9 @@ export class DefaultScriptRunner {
130
136
  });
131
137
  }
132
138
  else {
139
+ if (options.capture && code === 0 && scriptPath === 'tools/agents/deploy-agents.mjs') {
140
+ reportFlueWarnings(Buffer.concat(capturedStderr).toString());
141
+ }
133
142
  resolve({
134
143
  exitCode: code ?? 0,
135
144
  });
@@ -187,6 +196,8 @@ export class DefaultScriptRunner {
187
196
  const exitCode = (await deployer.main(args, { capture: options.capture === true })) ?? 0;
188
197
  const message = Buffer.concat(diagnostics).toString().trim()
189
198
  || (exitCode ? `Deployment script exited with code ${exitCode}: ${path.basename(fullPath)}` : '');
199
+ if (exitCode === 0 && options.capture)
200
+ reportFlueWarnings(message, previousConsole);
190
201
  return exitCode || message ? { exitCode, message } : { exitCode };
191
202
  }
192
203
  catch (error) {
@@ -0,0 +1,44 @@
1
+ // Offer optional signed local merges with a reviewable preview and an explicit config-only apply.
2
+ import { readAiwgConfig, writeAiwgConfig } from '../../config/aiwg-config.js';
3
+ export async function stewardSignedMerges(args, cwd) {
4
+ const values = new Map();
5
+ for (let i = 0; i < args.length; i++) {
6
+ if (['--apply', '--skip', '--help'].includes(args[i]))
7
+ continue;
8
+ if (!['--key', '--key-file', '--name', '--email', '--format', '--program'].includes(args[i]) || !args[i + 1] || args[i + 1].startsWith('--'))
9
+ throw new Error('Invalid signed-merges option');
10
+ values.set(args[i], args[++i]);
11
+ }
12
+ if (args.includes('--skip')) {
13
+ console.log('Signed merge setup skipped; project configuration preserved.');
14
+ return;
15
+ }
16
+ const config = await readAiwgConfig(cwd);
17
+ if (!config)
18
+ throw new Error('Signed merge setup requires .aiwg/aiwg.config');
19
+ const existing = config.delivery;
20
+ const key = values.get('--key') ?? existing?.signing?.key;
21
+ const name = values.get('--name') ?? existing?.committer?.name;
22
+ const email = values.get('--email') ?? existing?.committer?.email;
23
+ const format = values.get('--format') ?? existing?.signing?.format ?? 'openpgp';
24
+ if (!['openpgp', 'ssh', 'x509'].includes(format))
25
+ throw new Error('Signing format must be openpgp, ssh, or x509');
26
+ if (args.includes('--help') || !key || !name || !email) {
27
+ console.log('Recommended, optional: set up signed merges using an existing signing key and permitted repository policy. Skip when signing is unavailable or unwanted.\naiwg steward signed-merges --key <fingerprint> --name <committer> --email <email> [--format openpgp|ssh|x509] [--key-file <path>] [--program <path>]\nReview the preview, then add --apply to save. Use --skip to preserve unsigned delivery. SSH signing uses --key SHA256:... for verification and --key-file for the signing key path. This step creates no keys and changes no repository policies.');
28
+ if (args.includes('--apply'))
29
+ throw new Error('Applying signed merges requires key, name, and email');
30
+ return;
31
+ }
32
+ const delivery = { ...existing, merge: 'local-signed', require_signed_commits: true,
33
+ committer: { name, email }, signing: { ...existing?.signing, key, format: format, enforce: 'commits',
34
+ ...(values.has('--key-file') ? { key_file: values.get('--key-file') } : {}),
35
+ ...(values.has('--program') ? { program: values.get('--program') } : {}) } };
36
+ console.log(JSON.stringify({ delivery }, null, 2));
37
+ if (args.includes('--apply')) {
38
+ await writeAiwgConfig(cwd, { ...config, delivery });
39
+ console.log('Signed local merge configuration saved.');
40
+ }
41
+ else
42
+ console.log('Preview only. Add --apply to save, or --skip to keep current delivery.');
43
+ }
44
+ //# sourceMappingURL=steward-signing.js.map
@@ -100,6 +100,7 @@ async function handleSteward(args, ctx) {
100
100
  aiwg steward — Provider capability awareness and command routing
101
101
 
102
102
  Usage:
103
+ aiwg steward signed-merges [--apply|--skip] Optional signed local merge setup
103
104
  aiwg steward decision-offload [--json] Offline advisory readiness and adoption report
104
105
  aiwg steward capabilities --provider <name> Capabilities for a specific provider
105
106
  aiwg steward capabilities --feature <name> Provider support matrix for a feature
@@ -129,6 +130,10 @@ async function handleSteward(args, ctx) {
129
130
  `);
130
131
  return;
131
132
  }
133
+ if (subcommand === 'signed-merges') {
134
+ const { stewardSignedMerges } = await import('./steward-signing.js');
135
+ return stewardSignedMerges(args.slice(1), ctx ? getProjectDir(ctx, args) : process.cwd());
136
+ }
132
137
  if (subcommand === 'decision-offload') {
133
138
  const unknown = args.slice(1).filter(arg => arg !== '--json');
134
139
  if (unknown.length)
@@ -110,13 +110,13 @@ export async function formatUserScopeRegistry() {
110
110
  const providers = Object.entries(entry.deployedTo);
111
111
  for (const [provider, counts] of providers) {
112
112
  const parts = [];
113
- if (counts.agents > 0)
113
+ if ((counts.agents ?? 0) > 0)
114
114
  parts.push(`${counts.agents} agents`);
115
- if (counts.commands > 0)
115
+ if ((counts.commands ?? 0) > 0)
116
116
  parts.push(`${counts.commands} commands`);
117
- if (counts.skills > 0)
117
+ if ((counts.skills ?? 0) > 0)
118
118
  parts.push(`${counts.skills} skills`);
119
- if (counts.rules > 0)
119
+ if ((counts.rules ?? 0) > 0)
120
120
  parts.push(`${counts.rules} rules`);
121
121
  output += ` ${provider}: ${parts.length > 0 ? parts.join(', ') : '(empty)'}\n`;
122
122
  }
@@ -4,6 +4,9 @@ import { updateInstallation } from '../../update/service.mjs';
4
4
  import { useHandler as useFrameworkHandler } from './use.js';
5
5
  import { projectAiwgPath } from '../../config/project-artifacts.js';
6
6
  import { getConfigPath } from '../../config/aiwg-config.js';
7
+ import { bundleCopyArgs } from './bundle-deployment-mode.js';
8
+ import { bundleProviders, pruneUndeclaredBundles, pruneAfterScopedDeployments } from './bundle-reconciliation.js';
9
+ import { readAiwgConfig } from '../../config/aiwg-config.js';
7
10
  import { withInstalledSelection } from '../../config/installed-selection.js';
8
11
  import { REGISTRY_ID_TO_USE_NAME } from '../../config/framework-aliases.js';
9
12
  /**
@@ -107,34 +110,41 @@ export const updateHandler = {
107
110
  console.log(`Skipped legacy registry frameworks: ${skipped.map(item => item.id).join(', ')}`);
108
111
  }
109
112
  const installedFrameworks = deployAll ? ['all'] : [...new Set((configured ?? registry?.frameworks.map(item => item.id) ?? []).map(useName))];
113
+ let pruneFailures = !deployAll && installed !== undefined
114
+ ? await pruneUndeclaredBundles(ctx.cwd, await readAiwgConfig(ctx.cwd), providerArgs[1], dryRun, ctx.frameworkRoot) : 0;
115
+ const deployments = installedFrameworks.flatMap(fw => installed === undefined || deployAll
116
+ ? [{ fw, args: providerArgs }]
117
+ : bundleProviders(installed, fw, providerArgs[1]).map(provider => ({ fw, args: ['--provider', provider, ...bundleCopyArgs(installed, fw, provider)] })));
110
118
  if (installedFrameworks.length === 0) {
111
119
  console.log('No installed frameworks to re-deploy. Use aiwg use <framework> to install one.');
112
- return { exitCode: 0 };
120
+ return { exitCode: pruneFailures ? 1 : 0 };
113
121
  }
114
122
  // Report what will be updated
115
123
  console.log(`Installed frameworks: ${installedFrameworks.join(', ')}`);
116
124
  console.log('');
117
125
  if (dryRun) {
118
126
  console.log('Dry run: Would re-deploy the following frameworks:');
119
- for (const fw of installedFrameworks) {
120
- console.log(` - aiwg use ${[fw, ...providerArgs].join(' ')}`);
127
+ for (const { fw, args } of deployments) {
128
+ console.log(` - aiwg use ${[fw, ...args].join(' ')}`);
121
129
  }
122
- return { exitCode: 0 };
130
+ return { exitCode: pruneFailures ? 1 : 0 };
123
131
  }
124
132
  // Step 3: Re-deploy each installed framework
125
133
  const results = [];
126
- for (const fw of installedFrameworks) {
134
+ for (const { fw, args } of deployments) {
127
135
  console.log(`Re-deploying ${fw}...`);
128
136
  const deploy = () => useFrameworkHandler.execute({
129
137
  ...ctx,
130
- args: [fw, ...providerArgs],
138
+ args: [fw, ...args],
131
139
  });
132
140
  const result = await (deployAll ? deploy() : withInstalledSelection(ctx.cwd, installed, deploy));
133
141
  results.push({ framework: fw, exitCode: result.exitCode });
134
142
  if (result.exitCode !== 0) {
135
- console.error(`Warning: Failed to re-deploy ${fw}`);
143
+ console.error(`Warning: Failed to re-deploy ${fw}: ${result.message || `exit ${result.exitCode}`}`);
136
144
  }
137
145
  }
146
+ if (!deployAll)
147
+ pruneFailures += await pruneAfterScopedDeployments(ctx.cwd, await readAiwgConfig(ctx.cwd), providerArgs[1], ctx.frameworkRoot);
138
148
  // Step 4: Report summary
139
149
  console.log('');
140
150
  console.log('Update Summary:');
@@ -147,7 +157,7 @@ export const updateHandler = {
147
157
  console.log('');
148
158
  console.log(`Updated: ${succeeded.length}/${results.length}`);
149
159
  return {
150
- exitCode: failed.length > 0 ? 1 : 0,
160
+ exitCode: failed.length > 0 || pruneFailures ? 1 : 0,
151
161
  message: failed.length > 0
152
162
  ? `Some frameworks failed to update: ${failed.map(f => f.framework).join(', ')}`
153
163
  : `Successfully updated ${succeeded.length} framework(s)`,
@@ -0,0 +1,87 @@
1
+ // Discover additive framework bundles once for deployment and reconciliation.
2
+ import fs from 'node:fs/promises';
3
+ import path from 'node:path';
4
+ /**
5
+ * Addons excluded from `aiwg use all`.
6
+ * aiwg-dev is contributor-only tooling — not for end users.
7
+ */
8
+ export const USE_ALL_DISALLOW = new Set(['aiwg-dev']);
9
+ /**
10
+ * Whether an addon's manifest keeps it out of bulk deploys (#2641).
11
+ *
12
+ * `devOnly` marks contributor tooling; `explicitInstall` marks an addon that is
13
+ * deployed only when named, such as `aiwg use decision-engine`. Both match
14
+ * `discoverAddons()` in tools/agents/providers/base.mjs, which applies the same
15
+ * rule to framework-mode deploys.
16
+ *
17
+ * `autoInstall: false` is deliberately NOT an exclusion signal: most addons
18
+ * declare it (and the extension manifest schema defaults to it), so honoring
19
+ * it would drop most addons from `all` for existing users.
20
+ */
21
+ async function isExplicitOnlyAddon(addonDir) {
22
+ try {
23
+ const manifest = JSON.parse(await fs.readFile(path.join(addonDir, 'manifest.json'), 'utf8'));
24
+ return manifest?.devOnly === true || manifest?.explicitInstall === true;
25
+ }
26
+ catch {
27
+ return false;
28
+ }
29
+ }
30
+ /**
31
+ * Discover all addon names from the filesystem, minus the disallow list and
32
+ * addons whose manifest restricts them to explicit installs.
33
+ */
34
+ export async function getAllAddons(frameworkRoot) {
35
+ const addonsDir = path.join(frameworkRoot, 'agentic/code/addons');
36
+ const entries = await fs.readdir(addonsDir, { withFileTypes: true });
37
+ const candidates = entries.filter(e => e.isDirectory() && !USE_ALL_DISALLOW.has(e.name));
38
+ const excluded = await Promise.all(candidates.map(e => isExplicitOnlyAddon(path.join(addonsDir, e.name))));
39
+ return candidates.filter((_, index) => !excluded[index]).map(e => e.name);
40
+ }
41
+ /**
42
+ * Extensions excluded from `aiwg use all` deployment.
43
+ * `api-adapter` is an OpenAPI spec, not a deployable artifact bundle.
44
+ */
45
+ export const USE_ALL_EXTENSIONS_DISALLOW = new Set(['api-adapter']);
46
+ /**
47
+ * Discover all extension names from `agentic/code/extensions/*` (#1221).
48
+ *
49
+ * Extensions are addon-shaped bundles with their own `manifest.json`,
50
+ * `skills/`, `rules/`, and `templates/` directories. Only directories
51
+ * containing a `manifest.json` are considered deployable; bare directories
52
+ * (e.g. `api-adapter` which only ships an OpenAPI spec) are skipped.
53
+ */
54
+ export async function getAllExtensions(frameworkRoot) {
55
+ const extensionsDir = path.join(frameworkRoot, 'agentic/code/extensions');
56
+ let entries;
57
+ try {
58
+ entries = await fs.readdir(extensionsDir, { withFileTypes: true });
59
+ }
60
+ catch {
61
+ return [];
62
+ }
63
+ const result = [];
64
+ for (const entry of entries) {
65
+ if (!entry.isDirectory())
66
+ continue;
67
+ if (USE_ALL_EXTENSIONS_DISALLOW.has(entry.name))
68
+ continue;
69
+ const manifestPath = path.join(extensionsDir, entry.name, 'manifest.json');
70
+ try {
71
+ await fs.access(manifestPath);
72
+ result.push(entry.name);
73
+ }
74
+ catch {
75
+ // Directory without a manifest is not deployable as an extension.
76
+ continue;
77
+ }
78
+ }
79
+ return result;
80
+ }
81
+ /** The same provider and kernel gates govern use passes and expected receipt owners. */
82
+ export async function frameworkAdditiveBundles(frameworkRoot, provider, skipUtils = false, kernelOnly = false) {
83
+ const addons = skipUtils || provider === 'flue' ? [] : await getAllAddons(frameworkRoot);
84
+ const extensions = skipUtils || kernelOnly || provider === 'flue' ? [] : await getAllExtensions(frameworkRoot);
85
+ return { addons, extensions };
86
+ }
87
+ //# sourceMappingURL=use-additive-bundles.js.map
@@ -2,6 +2,7 @@
2
2
  import { promises as fs } from 'node:fs';
3
3
  import path from 'node:path';
4
4
  import { createHash } from 'node:crypto';
5
+ import { receiptIncludesOwner } from './use-owned-counts.js';
5
6
  import { parseRuleFrontmatter } from '../../rules/activation.mjs';
6
7
  export async function countDeployedBundleRules(bundlePath, target, deployPath, provider) {
7
8
  if (!deployPath && !provider)
@@ -75,7 +76,10 @@ export async function countDeployedBundleFiles(bundlePath, subdir, target, deplo
75
76
  for (const name of names) {
76
77
  for (const extension of extensions) {
77
78
  try {
78
- await fs.access(path.join(path.resolve(target, deployPath), path.basename(name, '.md') + extension));
79
+ const file = path.join(path.resolve(target, deployPath), path.basename(name, '.md') + extension);
80
+ await fs.access(file);
81
+ if (!await receiptIncludesOwner(file, new Set([path.basename(bundlePath)])))
82
+ continue;
79
83
  count++;
80
84
  break;
81
85
  }