@lesliechan721/aw 0.1.0-beta.85 → 0.1.0-beta.86

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 (233) hide show
  1. package/dist/authoring/assets/command-runtime-config.d.mts +9 -0
  2. package/dist/authoring/assets/command-runtime-config.mjs +106 -0
  3. package/dist/authoring/assets/command-runtime-config.mjs.map +1 -0
  4. package/dist/authoring/scripts/validate-plugin.mjs +17 -22
  5. package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
  6. package/dist/scripts/aw-skill-eval-materializer.d.ts +4 -0
  7. package/dist/scripts/aw-skill-eval-materializer.js +27 -0
  8. package/dist/scripts/aw-skill-eval-materializer.js.map +1 -1
  9. package/dist/scripts/bundle-plugins.js +1 -1
  10. package/dist/scripts/bundle-plugins.js.map +1 -1
  11. package/dist/scripts/test-plugin-scripts.js +13 -2
  12. package/dist/scripts/test-plugin-scripts.js.map +1 -1
  13. package/dist/src/commands/aw-capabilities.d.ts +1 -1
  14. package/dist/src/commands/aw-capabilities.js +2 -2
  15. package/dist/src/commands/catalog-source.d.ts +2 -1
  16. package/dist/src/commands/catalog-source.js +8 -7
  17. package/dist/src/commands/catalog-source.js.map +1 -1
  18. package/dist/src/commands/deployment-confirmation.d.ts +8 -1
  19. package/dist/src/commands/deployment-confirmation.js +79 -11
  20. package/dist/src/commands/deployment-confirmation.js.map +1 -1
  21. package/dist/src/commands/lifecycle-command-package.d.ts +44 -0
  22. package/dist/src/commands/lifecycle-command-package.js +195 -0
  23. package/dist/src/commands/lifecycle-command-package.js.map +1 -0
  24. package/dist/src/commands/managed-commands.d.ts +6 -0
  25. package/dist/src/commands/managed-commands.js +203 -152
  26. package/dist/src/commands/managed-commands.js.map +1 -1
  27. package/dist/src/commands/operation-plan.d.ts +22 -21
  28. package/dist/src/commands/operation-plan.js +2 -5
  29. package/dist/src/commands/operation-plan.js.map +1 -1
  30. package/dist/src/commands/permission-batch.d.ts +5 -0
  31. package/dist/src/commands/permission-batch.js +80 -0
  32. package/dist/src/commands/permission-batch.js.map +1 -0
  33. package/dist/src/commands/plugin-capabilities.js +17 -13
  34. package/dist/src/commands/plugin-capabilities.js.map +1 -1
  35. package/dist/src/commands/public-config-confirmation.d.ts +8 -2
  36. package/dist/src/commands/public-config-confirmation.js +22 -5
  37. package/dist/src/commands/public-config-confirmation.js.map +1 -1
  38. package/dist/src/commands/public-lifecycle-result.d.ts +4 -4
  39. package/dist/src/commands/public-lifecycle-result.js +55 -14
  40. package/dist/src/commands/public-lifecycle-result.js.map +1 -1
  41. package/dist/src/commands/public-lifecycle.js +49 -8
  42. package/dist/src/commands/public-lifecycle.js.map +1 -1
  43. package/dist/src/commands/rebuild-command.d.ts +4 -0
  44. package/dist/src/commands/rebuild-command.js +131 -45
  45. package/dist/src/commands/rebuild-command.js.map +1 -1
  46. package/dist/src/commands/rebuild-integration.d.ts +11 -3
  47. package/dist/src/commands/rebuild-integration.js +47 -164
  48. package/dist/src/commands/rebuild-integration.js.map +1 -1
  49. package/dist/src/commands/rebuild-operations.d.ts +2 -1
  50. package/dist/src/commands/rebuild-operations.js +2 -0
  51. package/dist/src/commands/rebuild-operations.js.map +1 -1
  52. package/dist/src/commands/rebuild-platform-integration.d.ts +5 -3
  53. package/dist/src/commands/rebuild-platform-integration.js +166 -135
  54. package/dist/src/commands/rebuild-platform-integration.js.map +1 -1
  55. package/dist/src/commands/skill-eval.js +10 -1
  56. package/dist/src/commands/skill-eval.js.map +1 -1
  57. package/dist/src/generators/local-plugin.js +14 -15
  58. package/dist/src/generators/local-plugin.js.map +1 -1
  59. package/dist/src/generators/permissions.d.ts +14 -6
  60. package/dist/src/generators/permissions.js +59 -61
  61. package/dist/src/generators/permissions.js.map +1 -1
  62. package/dist/src/index.js +77 -40
  63. package/dist/src/index.js.map +1 -1
  64. package/dist/src/output/command-receipt.js +7 -8
  65. package/dist/src/output/command-receipt.js.map +1 -1
  66. package/dist/src/output/component-delivery.d.ts +7 -0
  67. package/dist/src/output/component-delivery.js +59 -3
  68. package/dist/src/output/component-delivery.js.map +1 -1
  69. package/dist/src/output/public-result.d.ts +15 -0
  70. package/dist/src/output/public-result.js +75 -12
  71. package/dist/src/output/public-result.js.map +1 -1
  72. package/dist/src/output/rebuild-progress.js +7 -4
  73. package/dist/src/output/rebuild-progress.js.map +1 -1
  74. package/dist/src/output/receipt-projection.js +39 -27
  75. package/dist/src/output/receipt-projection.js.map +1 -1
  76. package/dist/src/platforms/antigravity-permissions.d.ts +50 -0
  77. package/dist/src/platforms/antigravity-permissions.js +388 -0
  78. package/dist/src/platforms/antigravity-permissions.js.map +1 -0
  79. package/dist/src/platforms/contracts.d.ts +10 -1
  80. package/dist/src/platforms/discovery.d.ts +2 -0
  81. package/dist/src/platforms/discovery.js.map +1 -1
  82. package/dist/src/platforms/grok-permission-config.d.ts +22 -0
  83. package/dist/src/platforms/grok-permission-config.js +184 -0
  84. package/dist/src/platforms/grok-permission-config.js.map +1 -0
  85. package/dist/src/platforms/grok-permission-document.d.ts +4 -0
  86. package/dist/src/platforms/grok-permission-document.js +145 -0
  87. package/dist/src/platforms/grok-permission-document.js.map +1 -0
  88. package/dist/src/platforms/grok-permissions.d.ts +17 -0
  89. package/dist/src/platforms/grok-permissions.js +311 -0
  90. package/dist/src/platforms/grok-permissions.js.map +1 -0
  91. package/dist/src/platforms/host-permission-policy.d.ts +38 -0
  92. package/dist/src/platforms/host-permission-policy.js +86 -0
  93. package/dist/src/platforms/host-permission-policy.js.map +1 -0
  94. package/dist/src/platforms/inspection-grok.js +47 -5
  95. package/dist/src/platforms/inspection-grok.js.map +1 -1
  96. package/dist/src/platforms/layout.d.ts +7 -0
  97. package/dist/src/platforms/layout.js +46 -5
  98. package/dist/src/platforms/layout.js.map +1 -1
  99. package/dist/src/platforms/lifecycle.js +39 -17
  100. package/dist/src/platforms/lifecycle.js.map +1 -1
  101. package/dist/src/platforms/opencode-permission-config.d.ts +13 -0
  102. package/dist/src/platforms/opencode-permission-config.js +253 -0
  103. package/dist/src/platforms/opencode-permission-config.js.map +1 -0
  104. package/dist/src/platforms/opencode-permissions.d.ts +39 -0
  105. package/dist/src/platforms/opencode-permissions.js +212 -0
  106. package/dist/src/platforms/opencode-permissions.js.map +1 -0
  107. package/dist/src/platforms/opencode-related-permissions.d.ts +40 -0
  108. package/dist/src/platforms/opencode-related-permissions.js +177 -0
  109. package/dist/src/platforms/opencode-related-permissions.js.map +1 -0
  110. package/dist/src/platforms/permission-ownership.d.ts +89 -0
  111. package/dist/src/platforms/permission-ownership.js +543 -0
  112. package/dist/src/platforms/permission-ownership.js.map +1 -0
  113. package/dist/src/platforms/permission-sidecar.d.ts +70 -0
  114. package/dist/src/platforms/permission-sidecar.js +215 -0
  115. package/dist/src/platforms/permission-sidecar.js.map +1 -0
  116. package/dist/src/platforms/projection.js +58 -8
  117. package/dist/src/platforms/projection.js.map +1 -1
  118. package/dist/src/recovery/coordinator.d.ts +2 -0
  119. package/dist/src/recovery/coordinator.js +24 -27
  120. package/dist/src/recovery/coordinator.js.map +1 -1
  121. package/dist/src/recovery/joint-coordinator.js +103 -47
  122. package/dist/src/recovery/joint-coordinator.js.map +1 -1
  123. package/dist/src/recovery/joint-demand.js +1 -1
  124. package/dist/src/recovery/joint-demand.js.map +1 -1
  125. package/dist/src/recovery/joint-install-execution.js +2 -1
  126. package/dist/src/recovery/joint-install-execution.js.map +1 -1
  127. package/dist/src/recovery/retirement.js +11 -17
  128. package/dist/src/recovery/retirement.js.map +1 -1
  129. package/dist/src/recovery/status.js +32 -2
  130. package/dist/src/recovery/status.js.map +1 -1
  131. package/dist/src/review/eval-source-input.d.ts +1 -0
  132. package/dist/src/review/eval-source-input.js +7 -1
  133. package/dist/src/review/eval-source-input.js.map +1 -1
  134. package/dist/src/review/review-selection.js +12 -5
  135. package/dist/src/review/review-selection.js.map +1 -1
  136. package/dist/src/review/skill-materialization.d.ts +1 -1
  137. package/dist/src/review/skill-materialization.js +3 -7
  138. package/dist/src/review/skill-materialization.js.map +1 -1
  139. package/dist/src/tui/console-app-v4.js +37 -30
  140. package/dist/src/tui/console-app-v4.js.map +1 -1
  141. package/dist/src/tui/controller-runtime.js +71 -6
  142. package/dist/src/tui/controller-runtime.js.map +1 -1
  143. package/dist/src/tui/controller.d.ts +4 -1
  144. package/dist/src/tui/controller.js.map +1 -1
  145. package/dist/src/tui/deployment-view.d.ts +1 -1
  146. package/dist/src/tui/deployment-view.js +16 -3
  147. package/dist/src/tui/deployment-view.js.map +1 -1
  148. package/dist/src/tui/diagnostic-projection.js +11 -6
  149. package/dist/src/tui/diagnostic-projection.js.map +1 -1
  150. package/dist/src/tui/entity-cards.js +1 -1
  151. package/dist/src/tui/entity-cards.js.map +1 -1
  152. package/dist/src/tui/operation-review-planner.js +130 -70
  153. package/dist/src/tui/operation-review-planner.js.map +1 -1
  154. package/dist/src/types.d.ts +8 -20
  155. package/dist/src/types.js.map +1 -1
  156. package/dist/src/utils/artifact-plan.d.ts +3 -36
  157. package/dist/src/utils/artifact-plan.js +11 -77
  158. package/dist/src/utils/artifact-plan.js.map +1 -1
  159. package/dist/src/utils/artifact-renderer.d.ts +0 -59
  160. package/dist/src/utils/artifact-renderer.js +2 -49
  161. package/dist/src/utils/artifact-renderer.js.map +1 -1
  162. package/dist/src/utils/artifact-request.d.ts +3 -26
  163. package/dist/src/utils/artifact-request.js +13 -36
  164. package/dist/src/utils/artifact-request.js.map +1 -1
  165. package/dist/src/utils/artifact-sources.d.ts +0 -8
  166. package/dist/src/utils/artifact-sources.js +0 -8
  167. package/dist/src/utils/artifact-sources.js.map +1 -1
  168. package/dist/src/utils/bundle-layout.js +2 -7
  169. package/dist/src/utils/bundle-layout.js.map +1 -1
  170. package/dist/src/utils/catalog-source-references.js +10 -0
  171. package/dist/src/utils/catalog-source-references.js.map +1 -1
  172. package/dist/src/utils/component-command-preparation.d.ts +6 -11
  173. package/dist/src/utils/component-command-preparation.js +109 -228
  174. package/dist/src/utils/component-command-preparation.js.map +1 -1
  175. package/dist/src/utils/managed-command-cli-review.d.ts +43 -0
  176. package/dist/src/utils/managed-command-cli-review.js +389 -0
  177. package/dist/src/utils/managed-command-cli-review.js.map +1 -0
  178. package/dist/src/utils/managed-command-closure.d.ts +14 -3
  179. package/dist/src/utils/managed-command-closure.js +144 -23
  180. package/dist/src/utils/managed-command-closure.js.map +1 -1
  181. package/dist/src/utils/managed-command-errors.d.ts +5 -0
  182. package/dist/src/utils/managed-command-errors.js +10 -0
  183. package/dist/src/utils/managed-command-errors.js.map +1 -0
  184. package/dist/src/utils/managed-command-materialization.d.ts +77 -113
  185. package/dist/src/utils/managed-command-materialization.js +324 -323
  186. package/dist/src/utils/managed-command-materialization.js.map +1 -1
  187. package/dist/src/utils/managed-command-preparation.d.ts +28 -65
  188. package/dist/src/utils/managed-command-preparation.js +33 -140
  189. package/dist/src/utils/managed-command-preparation.js.map +1 -1
  190. package/dist/src/utils/managed-command-review.d.ts +11 -4
  191. package/dist/src/utils/managed-command-review.js +33 -21
  192. package/dist/src/utils/managed-command-review.js.map +1 -1
  193. package/dist/src/utils/managed-command-runtime.d.ts +1 -0
  194. package/dist/src/utils/managed-command-runtime.js +6 -3
  195. package/dist/src/utils/managed-command-runtime.js.map +1 -1
  196. package/dist/src/utils/managed-command-snapshots.d.ts +17 -0
  197. package/dist/src/utils/managed-command-snapshots.js +84 -0
  198. package/dist/src/utils/managed-command-snapshots.js.map +1 -0
  199. package/dist/src/utils/managed-command-store.d.ts +65 -78
  200. package/dist/src/utils/managed-command-store.js +446 -383
  201. package/dist/src/utils/managed-command-store.js.map +1 -1
  202. package/dist/src/utils/multi-source-catalog.d.ts +2 -0
  203. package/dist/src/utils/multi-source-catalog.js +3 -1
  204. package/dist/src/utils/multi-source-catalog.js.map +1 -1
  205. package/dist/src/utils/native-tool-context.d.ts +6 -3
  206. package/dist/src/utils/native-tool-context.js +3 -1
  207. package/dist/src/utils/native-tool-context.js.map +1 -1
  208. package/dist/src/utils/native-tool-review.d.ts +2 -12
  209. package/dist/src/utils/native-tool-review.js +6 -108
  210. package/dist/src/utils/native-tool-review.js.map +1 -1
  211. package/dist/src/utils/ownership.d.ts +7 -0
  212. package/dist/src/utils/ownership.js.map +1 -1
  213. package/dist/src/utils/platform-empty-state.d.ts +2 -1
  214. package/dist/src/utils/platform-empty-state.js +13 -12
  215. package/dist/src/utils/platform-empty-state.js.map +1 -1
  216. package/dist/src/utils/plugin-config-command-apply.d.ts +33 -0
  217. package/dist/src/utils/plugin-config-command-apply.js +134 -0
  218. package/dist/src/utils/plugin-config-command-apply.js.map +1 -0
  219. package/dist/src/utils/plugin-config-impact.d.ts +19 -9
  220. package/dist/src/utils/plugin-config-impact.js +56 -37
  221. package/dist/src/utils/plugin-config-impact.js.map +1 -1
  222. package/dist/src/utils/plugin-config-write.d.ts +19 -19
  223. package/dist/src/utils/plugin-config-write.js +194 -772
  224. package/dist/src/utils/plugin-config-write.js.map +1 -1
  225. package/dist/src/utils/rendered-contract.js +12 -6
  226. package/dist/src/utils/rendered-contract.js.map +1 -1
  227. package/package.json +4 -3
  228. package/dist/src/platforms/managed-command-placement.d.ts +0 -8
  229. package/dist/src/platforms/managed-command-placement.js +0 -79
  230. package/dist/src/platforms/managed-command-placement.js.map +0 -1
  231. package/dist/src/utils/managed-command-evidence.d.ts +0 -7
  232. package/dist/src/utils/managed-command-evidence.js +0 -10
  233. package/dist/src/utils/managed-command-evidence.js.map +0 -1
@@ -1,5 +1,6 @@
1
- import { getCommandPackageId } from '@lesliechan721/aw-plugin-core/manifest';
2
1
  import { finalizePreparedPlatformRebuildSession, recordPreparedGrokProjectRetirement } from '../commands/rebuild-integration.js';
2
+ import { commandPackageProviderSatisfied, preparePortableCommandWithdrawal, publishLifecycleCommandPackage } from '../commands/lifecycle-command-package.js';
3
+ import { operationPlanNativeToolChanges } from '../commands/operation-plan.js';
3
4
  import { addRequirements } from '../commands/intent-command.js';
4
5
  import { createEmptyIntent, calculateIntentDigest, removeIntentRoot } from '../intent/intent-codec.js';
5
6
  import { observeIntent, writeIntent, resolveIntentPath } from '../intent/intent-store.js';
@@ -162,6 +163,9 @@ function mergeReceipts(plan, receipts) {
162
163
  receipt.outputsMayHaveChanged = receipts.some((item) => item.outputsMayHaveChanged);
163
164
  receipt.commandResults = receipts.flatMap((item) => item.commandResults ?? []);
164
165
  receipt.nativeToolChanges = receipts.flatMap((item) => item.nativeToolChanges ?? []);
166
+ if (plan.portableCommandWithdrawals?.length) {
167
+ receipt.nativeToolChanges = operationPlanNativeToolChanges({ actions: plan.portableCommandWithdrawals, nativeToolChanges: receipt.nativeToolChanges });
168
+ }
165
169
  receipt.recoveryActions = [...new Set(actions)];
166
170
  receipt.ok = receipt.blockers.length === 0 && receipts.every((item) => item.ok);
167
171
  return receipt;
@@ -231,7 +235,7 @@ async function readJointPreparation(command, options, locked = false, suppliedRe
231
235
  /** Complete requirements determine placement before execution selectors are applied. */
232
236
  export async function prepareJointRecovery(command, selectors, options, runtime, preparation) {
233
237
  const originalRunner = runtime.nativeCliRunner ?? getDefaultNativeCliRunner();
234
- runtime = { ...runtime, ...(isInstallBatch(command) ? { nativeCliRunner: limitInstallNativeRunner(originalRunner) } : {}),
238
+ runtime = { ...runtime, invocationCwd: runtime.invocationCwd ?? options.cwd, ...(isInstallBatch(command) ? { nativeCliRunner: limitInstallNativeRunner(originalRunner) } : {}),
235
239
  preparedArtifactRenderResults: runtime.preparedArtifactRenderResults ?? new Map() };
236
240
  const { snapshot, catalogReadScope, manifestReads } = preparation ?? await readJointPreparation(command, options, false, runtime.catalogReadScope);
237
241
  const prepare = async (current) => {
@@ -700,37 +704,50 @@ async function prepareJointRecoveryInSession(command, selectors, { checkInstallC
700
704
  const batch = isInstallBatch(command);
701
705
  const hasSelectedScripts = selected.some((item) => item.plugin.manifest.scripts?.preApply);
702
706
  if (batch && nativeObservationBatch && [...demand.placements, ...selected].every(({ plugin }) => {
703
- const scripts = plugin.manifest.scripts;
704
- return !scripts?.artifacts?.render && !scripts?.preApply && !scripts?.node?.build;
707
+ const { command, scripts } = plugin.manifest;
708
+ return command?.mode !== 'dynamic' && !scripts?.artifacts?.render && !scripts?.preApply && !scripts?.node?.build;
705
709
  }))
706
710
  nativeObservationBatch.scriptFreePlacement = true;
707
711
  const portableGenerations = new Map();
708
712
  const targetGroups = batch ? [...nativeTargets, ...targets.filter((target) => target === 'generic')].map((target) => [target])
709
713
  : [...(nativeTargets.length ? [nativeTargets] : []), ...targets.filter((target) => target === 'generic').map((target) => [target])];
714
+ const inheritedScripts = command === 'sync' && !options.existingOnly ? new Set(selected.filter((item) => {
715
+ if (item.scope !== 'user' || !item.plugin.manifest.scripts?.preApply)
716
+ return false;
717
+ const contributions = selectedContributions.get(item);
718
+ return !contributions.some((entry) => entry.scope === 'user')
719
+ && contributions.some((entry) => entry.scope === 'project' && entry.root !== item.pluginId)
720
+ && !(requestedIds.has(item.pluginId) && (!options.exactTargets || options.exactTargets.some((exact) => exact.pluginId === item.pluginId && exact.agent === item.target && contributions.some((entry) => entry.scope === exact.scope))));
721
+ })) : new Set();
722
+ const preparedPlacements = selected.filter((item) => !(item.scope === 'user' && !canReuseProviderAcrossScopes(item.target)
723
+ && selectedContributions.get(item)?.every((entry) => entry.scope === 'project')
724
+ && currentStatus.observedTargets?.some((actual) => actual.pluginId === item.pluginId
725
+ && actual.agent === item.target && isInstalledSkillProvider(actual)))
726
+ && !(command === 'install' && scope === 'project' && item.scope === 'user'
727
+ && currentStatus.observedTargets?.some((observed) => observed.pluginId === item.pluginId
728
+ && observed.agent === item.target && observed.scope === 'user' && observed.content === 'satisfied'))
729
+ && !(hasSharedUserPackage(item.target) && inheritedScripts.has(item)
730
+ && currentStatus.observedTargets?.some((observed) => observed.pluginId === item.pluginId
731
+ && observed.agent === item.target && observed.scope === 'user' && observed.providerScope === 'user'
732
+ && observed.observation === 'verified' && observed.content === 'satisfied' && !observed.blockers.length)));
733
+ // Split provider and host groups must publish the same shared revision.
734
+ const commandPackagePlatforms = new Map();
735
+ for (const { pluginId, plugin, target, scope } of preparedPlacements) {
736
+ if (target === 'generic' || !plugin.manifest.command?.platforms.includes(target)
737
+ || activationOnlyTargets.some((entry) => entry.pluginId === pluginId && entry.platform === target && entry.scope === scope))
738
+ continue;
739
+ const platforms = commandPackagePlatforms.get(pluginId) ?? [];
740
+ if (!platforms.includes(target))
741
+ platforms.push(target);
742
+ commandPackagePlatforms.set(pluginId, platforms);
743
+ }
744
+ runtime = { ...runtime, commandPackagePlatforms, retainCommandPackages: command === 'uninstall' };
745
+ plan.runtime = runtime;
710
746
  for (const currentScope of snapshot.context.scopes) {
711
747
  const prepareGroup = async (groupTargets) => {
712
- const inheritedScripts = currentScope === 'user' && command === 'sync' && !options.existingOnly
713
- ? selected.filter((item) => {
714
- if (item.scope !== 'user' || !groupTargets.includes(item.target) || !item.plugin.manifest.scripts?.preApply)
715
- return false;
716
- const contributions = selectedContributions.get(item);
717
- return !contributions.some((entry) => entry.scope === 'user')
718
- && contributions.some((entry) => entry.scope === 'project' && entry.root !== item.pluginId)
719
- && !(requestedIds.has(item.pluginId) && (!options.exactTargets || options.exactTargets.some((exact) => exact.pluginId === item.pluginId && exact.agent === item.target && contributions.some((entry) => entry.scope === exact.scope))));
720
- }) : [];
721
- const inheritedPortableProviderIds = inheritedScripts.filter((item) => item.target === 'generic').map((item) => item.pluginId);
722
- const placements = selected.filter((item) => item.scope === currentScope && groupTargets.includes(item.target)
723
- && !(item.scope === 'user' && !canReuseProviderAcrossScopes(item.target)
724
- && selectedContributions.get(item)?.every((entry) => entry.scope === 'project')
725
- && currentStatus.observedTargets?.some((actual) => actual.pluginId === item.pluginId
726
- && actual.agent === item.target && isInstalledSkillProvider(actual)))
727
- && !(command === 'install' && scope === 'project' && currentScope === 'user'
728
- && currentStatus.observedTargets?.some((observed) => observed.pluginId === item.pluginId
729
- && observed.agent === item.target && observed.scope === 'user' && observed.content === 'satisfied'))
730
- && !(hasSharedUserPackage(item.target) && inheritedScripts.includes(item)
731
- && currentStatus.observedTargets?.some((observed) => observed.pluginId === item.pluginId
732
- && observed.agent === item.target && observed.scope === 'user' && observed.providerScope === 'user'
733
- && observed.observation === 'verified' && observed.content === 'satisfied' && !observed.blockers.length)));
748
+ const inheritedPortableProviderIds = currentScope === 'user' && groupTargets.includes('generic')
749
+ ? [...inheritedScripts].filter((item) => item.target === 'generic').map((item) => item.pluginId) : [];
750
+ const placements = preparedPlacements.filter((item) => item.scope === currentScope && groupTargets.includes(item.target));
734
751
  if (!placements.length)
735
752
  return;
736
753
  const sourceDemand = currentScope === 'project' ? snapshot.project : snapshot.user;
@@ -1046,6 +1063,28 @@ async function prepareJointRecoveryInSession(command, selectors, { checkInstallC
1046
1063
  }
1047
1064
  }
1048
1065
  }
1066
+ if ((batch || command === 'reinstall') && !options.existingOnly) {
1067
+ const eligible = children.filter((child) => child.command !== 'cleanup').flatMap((child) => child.receipt.targetResults.filter((target) => target.agent === 'generic' && target.delivery?.kind === 'agent-skills'
1068
+ && !target.blockers.length));
1069
+ const eligiblePositions = new Set(eligible.map(targetKey));
1070
+ const candidates = [...new Map(preparedPlacements.filter((item) => item.target === 'generic'
1071
+ && !item.plugin.manifest.command && eligiblePositions.has(targetKey({ ...item, agent: item.target })))
1072
+ .map((item) => [item.pluginId, item.plugin])).entries()];
1073
+ const reviewCwd = snapshot.context.projectRoot ?? context.executionCwd;
1074
+ const prepared = await mapInstallReads(candidates, async ([pluginId, plugin]) => {
1075
+ try {
1076
+ return await preparePortableCommandWithdrawal(plugin, reviewCwd, context.env);
1077
+ }
1078
+ catch (error) {
1079
+ if (recoveryInterruptionCode(error, options.signal))
1080
+ throw error;
1081
+ for (const target of eligible.filter((item) => item.pluginId === pluginId)) {
1082
+ target.blockers.push(diagnostic(errorCode(error, 'commandPackagePreparationFailed')));
1083
+ }
1084
+ }
1085
+ }, { signal: options.signal });
1086
+ plan.portableCommandWithdrawals = prepared.filter((entry) => entry !== undefined);
1087
+ }
1049
1088
  finalizePreparedPlatformRebuildSession(runtime.preparedArtifactRenderResults);
1050
1089
  plan.sourceRefreshes = [...new Map(children.flatMap((child) => child.sourceRefreshes).map((item) => [item.sourceId, item])).values()];
1051
1090
  plan.sourceRefreshFailures = [...new Map(children.flatMap((child) => child.sourceRefreshFailures).map((item) => [item.sourceId, item])).values()];
@@ -1086,6 +1125,9 @@ export async function executeJointRecovery(plan, execution) {
1086
1125
  let completedReceipt;
1087
1126
  let lockWaitStartedAt;
1088
1127
  try {
1128
+ if (plan.portableCommandWithdrawals?.length && (execution.yes ?? plan.options.yes) !== true) {
1129
+ return blockedBeforeDeployment(plan, diagnostic('confirmationRequired'));
1130
+ }
1089
1131
  if (plan.sourceRefreshes.length) {
1090
1132
  plan.receipt.blockers.push(diagnostic('sourceRefreshConfirmationRequired'));
1091
1133
  const receipt = mergeReceipts(plan, joint.children.map((child) => child.receipt));
@@ -1162,7 +1204,9 @@ export async function executeJointRecovery(plan, execution) {
1162
1204
  const failedPackages = new Set();
1163
1205
  const failedNodes = new Set();
1164
1206
  const packageResults = [];
1165
- const runtime = { ...performanceRuntime, awHomeMutationToken: token };
1207
+ const runtime = { ...performanceRuntime, awHomeMutationToken: token,
1208
+ commandPackagePlatforms: checked.runtime.commandPackagePlatforms,
1209
+ retainCommandPackages: checked.runtime.retainCommandPackages };
1166
1210
  runtime.preApplyExecutionCache ??= new Map();
1167
1211
  runtime.managedCommandProducerCache ??= new Map();
1168
1212
  let interrupted;
@@ -1173,9 +1217,6 @@ export async function executeJointRecovery(plan, execution) {
1173
1217
  results.push(...installed.receipts);
1174
1218
  packageResults.push(...installed.commands);
1175
1219
  plan.receipt.blockers.push(...installed.blockers);
1176
- for (const result of installed.commands)
1177
- if (result.state !== 'completed')
1178
- failedPackages.add(getCommandPackageId(result.producer));
1179
1220
  }
1180
1221
  else {
1181
1222
  const packages = runtime.configApplyPackages;
@@ -1373,11 +1414,11 @@ export async function executeJointRecovery(plan, execution) {
1373
1414
  for (const target of child.receipt.requestedTargets)
1374
1415
  nodeFor(target.pluginId, target.scope).targets.push({ child, agent: target.agent });
1375
1416
  }
1376
- const hasNative = (node) => node.targets.some(({ agent }) => agent !== 'generic');
1417
+ const consumesPackage = (node, target) => !target.blocker && node.targets.some(({ agent }) => agent !== 'generic' && target.platforms.includes(agent));
1377
1418
  for (const target of packages?.targets ?? []) {
1378
1419
  const sameScope = nodes.get(`${target.pluginId}\0${target.scope}`);
1379
- const native = sameScope && hasNative(sameScope) ? sameScope
1380
- : [...nodes.values()].find((node) => node.pluginId === target.pluginId && hasNative(node));
1420
+ const native = sameScope && consumesPackage(sameScope, target) ? sameScope
1421
+ : [...nodes.values()].find((node) => node.pluginId === target.pluginId && consumesPackage(node, target));
1381
1422
  const node = native ?? nodeFor(target.pluginId, target.scope);
1382
1423
  (node.packages ??= []).push(target);
1383
1424
  }
@@ -1404,7 +1445,7 @@ export async function executeJointRecovery(plan, execution) {
1404
1445
  const key = `${pluginId}\0${scope}`;
1405
1446
  completedPackages.set(key, produced);
1406
1447
  packageResults.push(...produced);
1407
- if (produced.some((result) => result.state !== 'completed')) {
1448
+ if (!produced.every(commandPackageProviderSatisfied)) {
1408
1449
  failedPackages.add(key);
1409
1450
  failedNodes.add(key);
1410
1451
  }
@@ -1419,17 +1460,19 @@ export async function executeJointRecovery(plan, execution) {
1419
1460
  };
1420
1461
  const blockPackages = (pluginId, scope, code) => completedPackages.get(`${pluginId}\0${scope}`)
1421
1462
  ?? recordPackages(pluginId, scope, packages?.blocked?.(pluginId, scope, code) ?? []);
1463
+ const nativePackages = (identity) => packages?.targets.filter((target) => target.pluginId === identity.pluginId
1464
+ && target.platforms.includes(identity.platform)
1465
+ && (target.scope === 'user' || target.scope === identity.scope)) ?? [];
1422
1466
  if (packages)
1423
1467
  runtime.nativeTargetExecution = {
1468
+ produces: (identity) => nativePackages(identity).length > 0,
1424
1469
  beforeApply: async (identity) => {
1425
1470
  const results = [];
1426
- for (const target of packages.targets.filter((target) => target.pluginId === identity.pluginId
1427
- && (target.scope === 'user' || target.scope === identity.scope)))
1471
+ for (const target of nativePackages(identity))
1428
1472
  results.push(...await applyPackages(target.pluginId, target.scope));
1429
1473
  return results;
1430
1474
  },
1431
- blocked: (identity, code) => packages.targets.filter((target) => target.pluginId === identity.pluginId
1432
- && (target.scope === 'user' || target.scope === identity.scope)).flatMap((target) => blockPackages(target.pluginId, target.scope, code === 'dependencyInstallFailed' ? 'dependencyApplyFailed' : code)),
1475
+ blocked: (identity, code) => nativePackages(identity).flatMap((target) => blockPackages(target.pluginId, target.scope, code === 'dependencyInstallFailed' ? 'dependencyApplyFailed' : code)),
1433
1476
  };
1434
1477
  while (pending.length) {
1435
1478
  const index = pending.findIndex((node) => {
@@ -1447,20 +1490,21 @@ export async function executeJointRecovery(plan, execution) {
1447
1490
  retiredProjectCopies = true;
1448
1491
  }
1449
1492
  const key = `${node.pluginId}\0${node.scope}`;
1450
- if (node.packages?.length && packages && !hasNative(node)) {
1493
+ const standalonePackages = node.packages?.filter((target) => !consumesPackage(node, target)) ?? [];
1494
+ if (standalonePackages.length && packages) {
1451
1495
  if (failedNodes.has(key) || [...node.dependencies].some((dependency) => failedNodes.has(dependency))) {
1452
1496
  failedPackages.add(key);
1453
1497
  failedNodes.add(key);
1454
- for (const target of node.packages)
1498
+ for (const target of standalonePackages)
1455
1499
  blockPackages(target.pluginId, target.scope, 'dependencyApplyFailed');
1456
1500
  plan.receipt.blockers.push(diagnostic('commandPackageProviderNotSatisfied', node.pluginId));
1457
1501
  }
1458
1502
  else {
1459
1503
  try {
1460
1504
  const produced = [];
1461
- for (const target of node.packages)
1505
+ for (const target of standalonePackages)
1462
1506
  produced.push(...await applyPackages(target.pluginId, target.scope));
1463
- if (produced.some((result) => result.state !== 'completed')) {
1507
+ if (!produced.every(commandPackageProviderSatisfied)) {
1464
1508
  failedPackages.add(key);
1465
1509
  failedNodes.add(key);
1466
1510
  }
@@ -1494,16 +1538,28 @@ export async function executeJointRecovery(plan, execution) {
1494
1538
  await retireVerified('user');
1495
1539
  }
1496
1540
  const receipt = mergeReceipts(plan, results);
1497
- receipt.commandResults = [...new Map([...packageResults, ...(receipt.commandResults ?? [])]
1498
- .map((result) => [getCommandPackageId(result.producer), result])).values()];
1541
+ completedReceipt = receipt;
1542
+ const commandResults = new Map([...packageResults, ...(receipt.commandResults ?? [])].map((result) => [result.packageId, result]));
1543
+ for (const action of plan.portableCommandWithdrawals ?? []) {
1544
+ if (interrupted || runtime.signal?.aborted)
1545
+ break;
1546
+ if (!receipt.targetResults.some((target) => target.pluginId === action.pluginId && target.agent === 'generic'
1547
+ && target.delivery?.kind === 'agent-skills' && !target.blockers.length && target.observation === 'verified'
1548
+ && ['applied', 'no-op'].includes(target.execution)))
1549
+ continue;
1550
+ const result = await runtime.managedCommandProducerCache.get(action.packageId)
1551
+ ?? await publishLifecycleCommandPackage(action, { cwd: joint.snapshot.context.projectRoot ?? plan.context.executionCwd }, { env: plan.context.env, reporter: runtime.reporter });
1552
+ commandResults.set(result.packageId, result);
1553
+ receipt.outputsMayHaveChanged ||= result.action === 'removed' || result.state === 'partial';
1554
+ }
1555
+ receipt.commandResults = [...commandResults.values()];
1499
1556
  receipt.recoveryActions = [...new Set([...receipt.recoveryActions,
1500
1557
  ...receipt.commandResults.flatMap((result) => result.recoveryActions)])];
1501
- receipt.ok &&= failedPackages.size === 0;
1502
- receipt.outputsMayHaveChanged ||= packageResults.some((result) => result.state === 'completed');
1558
+ receipt.ok &&= failedPackages.size === 0 && receipt.commandResults.every((result) => result.state === 'completed');
1559
+ receipt.outputsMayHaveChanged ||= packageResults.some(({ action, state }) => action !== 'unchanged' || state === 'partial');
1503
1560
  receipt.errors.push(...results.flatMap((result) => result.targetResults.flatMap((target) => target.blockers)));
1504
1561
  if (!receipt.ok && retriesFromRequestedRoots(receipt))
1505
1562
  useDeclaredRetryRoots(receipt);
1506
- completedReceipt = receipt;
1507
1563
  if (interrupted)
1508
1564
  throw interrupted;
1509
1565
  runtime.signal?.throwIfAborted();