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

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 +160 -101
  45. package/dist/src/commands/rebuild-command.js.map +1 -1
  46. package/dist/src/commands/rebuild-integration.d.ts +17 -6
  47. package/dist/src/commands/rebuild-integration.js +76 -183
  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 +8 -0
  97. package/dist/src/platforms/layout.js +53 -8
  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,4 +1,6 @@
1
- import { type ManagedCommandCandidate, type PreparedManagedCommandPackage } from '../utils/managed-command-materialization.js';
1
+ import type { InstalledCommandProducer } from '@lesliechan721/aw-plugin-core/manifest';
2
+ import type { PreparedManagedCommandPackage } from '../utils/managed-command-materialization.js';
3
+ import { type ClaudePermissions } from '../generators/permissions.js';
2
4
  import type { CommandReporter, DebugLogger } from '../output/model.js';
3
5
  import type { CatalogResolution, CommandProducerResult, PlatformName, PluginMeta, Scope } from '../types.js';
4
6
  import { type CodexNativeObservationSession, type CodexNativePluginObservation } from '../utils/codex-native-observation.js';
@@ -9,6 +11,7 @@ import { type NativeOwnershipProbe, type OwnedComponent, type OwnershipInspectio
9
11
  import type { PluginProcessResult } from '../utils/plugin-scripts.js';
10
12
  import type { OperationAction } from './operation-plan.js';
11
13
  import type { DesiredTarget, RebuildTargetDriver, RebuildTargetIdentity } from './rebuild-operations.js';
14
+ import type { NativeIdentity } from '../platforms/contracts.js';
12
15
  import { PlatformRebuildSession } from './rebuild-platform-integration.js';
13
16
  export declare function finalizePreparedPlatformRebuildSession(results: Map<string, PluginProcessResult>): void;
14
17
  export declare function recordPreparedGrokProjectRetirement(results: Map<string, PluginProcessResult>, ...retirement: Parameters<PlatformRebuildSession['recordGrokProjectRetirement']>): void;
@@ -16,6 +19,7 @@ export declare function disposePreparedPlatformRebuildSession(results: Map<strin
16
19
  export interface RebuildIntegration {
17
20
  resolvePlatformTargets(inputs: readonly Parameters<RebuildIntegration['buildTarget']>[0][]): Promise<void>;
18
21
  sealMarketplaceGenerations(targets: readonly DesiredTarget[]): Promise<void>;
22
+ pendingOpenCodeProjectNotices(interrupted: boolean): import('../platforms/contracts.js').Diagnostic[];
19
23
  driver: RebuildTargetDriver;
20
24
  setNativeMarketplaceEligibleTargets(targets: readonly DesiredTarget[]): void;
21
25
  prepareNativeMarketplaceGroup(target: DesiredTarget): Promise<void>;
@@ -33,6 +37,7 @@ export interface RebuildIntegration {
33
37
  cwd: string;
34
38
  command: 'install' | 'sync' | 'reinstall' | 'cleanup' | 'uninstall';
35
39
  catalog: CatalogResolution;
40
+ commandRecord?: InstalledCommandProducer | null;
36
41
  readOnlyInspectionPlan?: boolean;
37
42
  /** Fresh read window for peers undergoing the same placement check or plan verification. */
38
43
  observationBatch?: import('../platforms/inspection-query.js').NativeObservationBatch;
@@ -54,11 +59,16 @@ export declare class CodexActivationPostcheckError extends Error {
54
59
  constructor(codexPluginIds: string | readonly string[], detail: string);
55
60
  }
56
61
  export interface RebuildExecutionContext {
62
+ removeHostPermissions?: (locator: import('../platforms/permission-ownership.js').PermissionLocator) => Promise<void>;
63
+ invocationCwd?: string;
57
64
  recoveryCandidates?: readonly import('../platforms/contracts.js').RecoveryCandidate[];
58
65
  sharedReferenceView?: import('../utils/native-demand.js').NativeSharedReferenceView;
59
66
  platformRebuildSession?: PlatformRebuildSession;
60
67
  /** Concurrent native groups share a session across scopes of the same platform. */
61
68
  batchInstallPlatform?: PlatformName;
69
+ configApply?: boolean;
70
+ retainCommandPackages?: boolean;
71
+ commandPackagePlatforms?: ReadonlyMap<string, readonly PlatformName[]>;
62
72
  packagePreparationCache?: Map<string, Promise<PreparedManagedCommandPackage>>;
63
73
  interruption?: import('./public-interruption.js').PublicCommandInterruption;
64
74
  /** Validated renderer process output shared only by preparations of this operation. */
@@ -86,7 +96,6 @@ export interface RebuildExecutionContext {
86
96
  scope: Scope;
87
97
  }[];
88
98
  commandResults?: CommandProducerResult[];
89
- managedCommandCandidates?: Map<string, ManagedCommandCandidate[]>;
90
99
  }
91
100
  export declare function executeCodexReconcileActivations(options: {
92
101
  plans: readonly CodexReconcilePlan[];
@@ -174,13 +183,15 @@ export declare function assertNoClaudeUnboundNativeNameCollision(options: {
174
183
  cwd: string;
175
184
  env: NodeJS.ProcessEnv;
176
185
  }): Promise<void>;
177
- export declare function inspectNativeMarketplaceRegistrations(options: {
186
+ export declare function inspectNativeMarketplaceRegistration(options: {
187
+ platform: 'codex' | 'claude';
178
188
  marketplaceName: string;
179
- marketplaceRoot: string;
189
+ sourceId: string;
180
190
  cwd: string;
181
191
  env: NodeJS.ProcessEnv;
182
- }): Promise<Record<'codex' | 'claude', 'absent' | 'canonical' | 'foreign'>>;
183
- export declare function applyPlannedOperationAction(action: OperationAction): Promise<void>;
192
+ codexPackages: readonly NativeIdentity[];
193
+ }): Promise<'absent' | 'canonical' | 'foreign'>;
194
+ export declare function applyPlannedOperationAction(action: OperationAction): Promise<ClaudePermissions>;
184
195
  export declare function isNativeActivationOnlyTarget(context: Pick<RebuildExecutionContext, 'nativeActivationOnlyTargets'>, identity: Pick<RebuildTargetIdentity, 'pluginId' | 'platform' | 'scope'>): boolean;
185
196
  export declare function createRebuildIntegration(options: {
186
197
  context: RebuildExecutionContext;
@@ -1,12 +1,9 @@
1
1
  import crypto from 'node:crypto';
2
2
  import path from 'node:path';
3
- import { captureNativeToolChanges } from '../utils/native-tool-review.js';
4
3
  import { catalogFileMode } from '@lesliechan721/aw-plugin-core';
5
- import { getCommandPackageId } from '@lesliechan721/aw-plugin-core/manifest';
6
4
  import fs from 'fs-extra';
7
- import os from 'node:os';
8
- import { discoverRetainedManagedCommandPackages, managedCommandProducerIdentity, prepareManagedCommandPackage, retainedManagedCommandPackageResult } from '../utils/managed-command-materialization.js';
9
- import { assertManagedCommandBindingIdentities, listManagedCommands, managedCommandDiagnostic, ManagedCommandError, revokeManagedCommandBindings, syncManagedCommandPackage } from '../utils/managed-command-store.js';
5
+ import { ManagedCommandError } from '../utils/managed-command-store.js';
6
+ import { prepareLifecycleCommandPackage, publishLifecycleCommandPackages, retainedManagedCommandPackageResult } from './lifecycle-command-package.js';
10
7
  import { readClaudeSettings, writeClaudeSettings } from '../adapters/helpers.js';
11
8
  import { buildGeneratedName } from '../generators/shared.js';
12
9
  import { readCatalogSourcesConfigSnapshot } from '../utils/catalog-sources.js';
@@ -25,10 +22,13 @@ import { runPreApplyScript } from '../utils/plugin-scripts.js';
25
22
  import { assertCanonicalProjectManagedRoots } from '../utils/project-boundary.js';
26
23
  import { attachSafeOperationError, readSafeOperationError } from '../utils/safe-operation-diagnostic.js';
27
24
  import { createProjectLocationKey, resolveRequiredCanonicalRepoRoot, resolveClaudeProjectKey, resolveCodexProjectKey } from '../utils/state-paths.js';
25
+ import { hasPermissionOwner, updateHostPermissions } from '../platforms/permission-ownership.js';
26
+ import { resolvePlatformConfigRoot } from '../platforms/discovery.js';
27
+ import { canonicalNamespaceRoot } from '../platforms/identity.js';
28
+ import { getManagedPlatformRoot } from '../platforms/layout.js';
28
29
  import { platformOwnership, PlatformRebuildSession } from './rebuild-platform-integration.js';
29
30
  const MARKETPLACE_NAME = 'aw';
30
31
  const LEGACY_MCP_OWNER_ENV = 'AW_AGENT_WORKFLOWS_OWNER';
31
- const commandPackagePreparationCaches = new WeakMap();
32
32
  const platformRebuildSessions = new WeakMap();
33
33
  const commandPackageCandidates = new WeakMap();
34
34
  export function finalizePreparedPlatformRebuildSession(results) {
@@ -56,65 +56,6 @@ export async function disposePreparedPlatformRebuildSession(results) {
56
56
  }));
57
57
  }
58
58
  }
59
- async function commandPackageActions(options) {
60
- const actions = [];
61
- const candidates = [];
62
- const packageCache = options.context.packagePreparationCache ??= new Map();
63
- let cache = commandPackagePreparationCaches.get(options.context);
64
- if (!cache) {
65
- cache = new Map();
66
- commandPackagePreparationCaches.set(options.context, cache);
67
- }
68
- for (const declaration of options.plugin.manifest.managedCommands?.packages ?? []) {
69
- if (!declaration.platforms.includes(options.platform) || options.scope === 'user' && declaration.scope === 'project')
70
- continue;
71
- const producer = await managedCommandProducerIdentity({ ...options, scope: declaration.scope,
72
- producer: { kind: 'package', packageKey: declaration.key } });
73
- const key = getCommandPackageId(producer);
74
- let preparation = cache.get(key);
75
- if (!preparation) {
76
- preparation = (async () => {
77
- let candidate = packageCache.get(key);
78
- if (!candidate) {
79
- candidate = prepareManagedCommandPackage({ ...options, referencePlugins: options.context.referencePlugins,
80
- packageKey: declaration.key, scope: declaration.scope, signal: options.context.signal,
81
- scriptTimeoutMs: options.context.scriptTimeoutMs });
82
- packageCache.set(key, candidate);
83
- }
84
- const prepared = await candidate;
85
- const files = [];
86
- async function visit(directory, prefix) {
87
- for (const entry of await fs.readdir(directory, { withFileTypes: true })) {
88
- const relativePath = prefix ? `${prefix}/${entry.name}` : entry.name;
89
- const absolute = path.join(directory, entry.name);
90
- if (entry.isDirectory()) {
91
- await visit(absolute, relativePath);
92
- }
93
- else if (entry.isFile()) {
94
- const content = await fs.readFile(absolute);
95
- files.push({ relativePath, contentBase64: content.toString('base64'),
96
- contentDigest: `sha256:${crypto.createHash('sha256').update(content).digest('hex')}`,
97
- mode: (await fs.stat(absolute)).mode & 0o777 });
98
- }
99
- else
100
- throw new ManagedCommandError('commandResourceInvalid', 'The prepared package contains an unsafe resource.');
101
- }
102
- }
103
- await visit(prepared.resourceRoot, '');
104
- files.sort((left, right) => left.relativePath.localeCompare(right.relativePath));
105
- return { action: { kind: 'syncManagedCommandPackage', pluginId: pluginActionId(options.plugin),
106
- scope: declaration.scope, producer: prepared.producer, sets: prepared.sets, nativeTools: prepared.nativeTools,
107
- files, contentDigest: `sha256:${crypto.createHash('sha256').update(JSON.stringify(files)).digest('hex')}` },
108
- candidate: { producer: prepared.producer, sets: prepared.sets, nativeTools: prepared.nativeTools } };
109
- })();
110
- cache.set(key, preparation);
111
- }
112
- const prepared = await preparation;
113
- actions.push(prepared.action);
114
- candidates.push(prepared.candidate);
115
- }
116
- return { actions, candidates };
117
- }
118
59
  export class CodexActivationPostcheckError extends Error {
119
60
  code = 'codexActivationPostcheckFailed';
120
61
  codexPluginIds;
@@ -994,32 +935,39 @@ export async function assertNoClaudeUnboundNativeNameCollision(options) {
994
935
  throw new Error(`externalOwnershipPresent: Claude has an unbound installed plugin named ${options.pluginName}; native install would overwrite it.`);
995
936
  }
996
937
  }
997
- export async function inspectNativeMarketplaceRegistrations(options) {
998
- const codexConfig = await readCodexConfigFile(resolveCodexPaths(options.cwd, 'user', options.env).configTomlPath);
999
- const codexMarketplace = codexConfig.snapshot.marketplaces[options.marketplaceName];
1000
- const codexRegistration = codexMarketplace === undefined
1001
- ? 'absent'
1002
- : isCanonicalCodexMarketplaceRegistration(codexMarketplace, options.marketplaceRoot)
1003
- ? 'canonical'
1004
- : 'foreign';
1005
- const codexConsumerSuffix = `@${options.marketplaceName}`;
1006
- const codex = codexRegistration === 'absent'
1007
- && Object.keys(codexConfig.snapshot.plugins).some((pluginId) => pluginId.length > codexConsumerSuffix.length && pluginId.endsWith(codexConsumerSuffix))
1008
- ? 'foreign'
1009
- : codexRegistration;
938
+ export async function inspectNativeMarketplaceRegistration(options) {
939
+ const { sourceId, platform, marketplaceName, cwd, env } = options;
940
+ const [awRoot, configRoot] = await Promise.all([
941
+ canonicalNamespaceRoot(resolveAwHome(env)),
942
+ canonicalNamespaceRoot(resolvePlatformConfigRoot(platform, { cwd, env })),
943
+ ]);
944
+ const marketplaceRoot = path.join(getManagedPlatformRoot(awRoot, platform, `${platform}-marketplace`, configRoot), 'marketplaces', sourceId);
945
+ if (platform === 'codex') {
946
+ const config = await readCodexConfigFile(resolveCodexPaths(cwd, 'user', env).configTomlPath);
947
+ const marketplace = config.snapshot.marketplaces[marketplaceName];
948
+ if (marketplace !== undefined) {
949
+ return isCanonicalCodexMarketplaceRegistration(marketplace, marketplaceRoot) ? 'canonical' : 'foreign';
950
+ }
951
+ const suffix = `@${marketplaceName}`;
952
+ // A repair can restore activation before the marketplace has been registered again.
953
+ const ownedActivations = new Set(options.codexPackages
954
+ .filter(({ packageId, sourceLocation }) => sourceLocation === path.join(marketplaceRoot, 'plugins', packageId))
955
+ .map(({ registrationId }) => registrationId));
956
+ return Object.keys(config.snapshot.plugins).some((id) => id.length > suffix.length && id.endsWith(suffix) && !ownedActivations.has(id))
957
+ ? 'foreign' : 'absent';
958
+ }
1010
959
  const claudeState = await readClaudeNativeState({
1011
960
  pluginName: '__marketplace_preflight__',
1012
961
  scope: 'user',
1013
- cwd: options.cwd,
1014
- env: options.env,
1015
- marketplaceName: options.marketplaceName,
1016
- marketplaceRoot: options.marketplaceRoot,
962
+ cwd,
963
+ env,
964
+ marketplaceName,
965
+ marketplaceRoot,
1017
966
  });
1018
- const claude = claudeState.marketplaceState === 'absent'
967
+ return claudeState.marketplaceState === 'absent'
1019
968
  && claudeState.marketplaceConsumerEvidence
1020
969
  ? 'foreign'
1021
970
  : claudeState.marketplaceState;
1022
- return { codex, claude };
1023
971
  }
1024
972
  export async function applyPlannedOperationAction(action) {
1025
973
  if (action.kind !== 'updateSharedConfig' || action.mutation.kind !== 'claude-permissions'
@@ -1027,77 +975,17 @@ export async function applyPlannedOperationAction(action) {
1027
975
  throw new Error('platformContributionUnsupported: expected a Claude permissions contribution.');
1028
976
  }
1029
977
  const settings = await readClaudeSettings(action.locator.settingsPath);
978
+ const before = settings.permissions;
1030
979
  rebuildClaudePermissions(settings, action.locator.ownerKey, action.mutation.permissions);
1031
980
  await writeClaudeSettings(action.locator.settingsPath, settings);
981
+ return {
982
+ allow: (settings.permissions?.allow ?? []).filter((rule) => !before?.allow?.includes(rule)),
983
+ ask: (settings.permissions?.ask ?? []).filter((rule) => !before?.ask?.includes(rule)),
984
+ deny: (settings.permissions?.deny ?? []).filter((rule) => !before?.deny?.includes(rule)),
985
+ };
1032
986
  }
1033
987
  function createNativeDriver(options) {
1034
988
  const runner = options.context.nativeCliRunner;
1035
- const revokeAtRoot = async (root, recursive = false, platform) => {
1036
- const listed = await listManagedCommands(options.context.env);
1037
- const producers = new Map();
1038
- for (const command of listed.commands) {
1039
- if (command.owner.kind !== 'plugin' || !command.resourceRoot)
1040
- continue;
1041
- if (platform && command.owner.producer.platform !== platform)
1042
- continue;
1043
- const relative = path.relative(path.resolve(root), path.resolve(command.resourceRoot));
1044
- if (relative !== '' && (!recursive || relative === '..' || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)))
1045
- continue;
1046
- producers.set(getCommandPackageId(command.owner.producer), command.owner.producer);
1047
- }
1048
- for (const producer of producers.values()) {
1049
- const removedCommandIds = await revokeManagedCommandBindings(producer, options.context.env);
1050
- options.context.commandResults ??= [];
1051
- options.context.commandResults.push({ producer, state: 'completed', commandIds: [], removedCommandIds, errors: [], recoveryActions: [] });
1052
- }
1053
- };
1054
- const publishPackages = async (target) => {
1055
- const cache = options.context.managedCommandProducerCache ??= new Map();
1056
- for (const action of target.operationActions ?? []) {
1057
- if (action.kind !== 'syncManagedCommandPackage')
1058
- continue;
1059
- const key = getCommandPackageId(action.producer);
1060
- let publication = cache.get(key);
1061
- if (!publication) {
1062
- publication = (async () => {
1063
- await options.context.reporter.event({ type: 'managed-command:producer', source: { plugin: action.producer.pluginName, scope: action.producer.scope }, data: { packageKey: action.producer.key, phase: 'start' } });
1064
- const temporary = await fs.mkdtemp(path.join(os.tmpdir(), 'aw-command-publish-'));
1065
- try {
1066
- const digest = `sha256:${crypto.createHash('sha256').update(JSON.stringify(action.files)).digest('hex')}`;
1067
- if (digest !== action.contentDigest)
1068
- throw new ManagedCommandError('commandResourceInvalid', 'The prepared command package digest changed.');
1069
- const resourceRoot = path.join(temporary, 'resource');
1070
- await fs.ensureDir(resourceRoot);
1071
- for (const file of action.files) {
1072
- const content = Buffer.from(file.contentBase64, 'base64');
1073
- if (`sha256:${crypto.createHash('sha256').update(content).digest('hex')}` !== file.contentDigest)
1074
- throw new ManagedCommandError('commandResourceInvalid', 'The prepared command package file digest changed.');
1075
- const destination = path.join(resourceRoot, ...file.relativePath.split('/'));
1076
- await fs.outputFile(destination, content);
1077
- await fs.chmod(destination, file.mode);
1078
- }
1079
- const result = await syncManagedCommandPackage({ producer: action.producer, sourceDirectory: resourceRoot, sets: action.sets, nativeTools: action.nativeTools, env: options.context.env });
1080
- await options.context.reporter.event({ type: 'managed-command:producer', source: { plugin: action.producer.pluginName, scope: action.producer.scope }, data: { packageKey: action.producer.key, phase: 'success' } });
1081
- return { producer: action.producer, state: 'completed', commandIds: result.commandIds, removedCommandIds: result.removedCommandIds, errors: [], recoveryActions: [] };
1082
- }
1083
- catch (error) {
1084
- await options.context.reporter.event({ type: 'managed-command:producer', source: { plugin: action.producer.pluginName, scope: action.producer.scope }, data: { packageKey: action.producer.key, phase: 'failure' } });
1085
- return { producer: action.producer, state: 'failed', commandIds: [], removedCommandIds: [], errors: [managedCommandDiagnostic(error)], recoveryActions: [`aw command package sync ${action.producer.sourceId}/${action.producer.pluginName} ${action.producer.key} --scope ${action.producer.scope} --yes`] };
1086
- }
1087
- finally {
1088
- await fs.remove(temporary);
1089
- }
1090
- })();
1091
- cache.set(key, publication);
1092
- }
1093
- const result = await publication;
1094
- options.context.commandResults ??= [];
1095
- if (!options.context.commandResults.some((entry) => getCommandPackageId(entry.producer) === key))
1096
- options.context.commandResults.push(result);
1097
- if (result.state !== 'completed')
1098
- throw new Error('commandPackagePublishFailed: sync the command package and retry the plugin operation.');
1099
- }
1100
- };
1101
989
  const currentCodexManager = () => options.context.codexManager;
1102
990
  const codexNativeStates = new Map();
1103
991
  const pendingCodexNativeStates = new Map();
@@ -1264,6 +1152,8 @@ function createNativeDriver(options) {
1264
1152
  inspectShared: async (component) => {
1265
1153
  const locator = component.locator;
1266
1154
  switch (locator.kind) {
1155
+ case 'host-permissions':
1156
+ return await hasPermissionOwner(options.context.env, locator) ? 'present' : 'absent';
1267
1157
  case 'cursor-workspace-hook':
1268
1158
  return platformOwnership.inspectShared(component);
1269
1159
  case 'claude-permissions':
@@ -1316,6 +1206,11 @@ function createNativeDriver(options) {
1316
1206
  removeShared: async (component) => {
1317
1207
  const locator = component.locator;
1318
1208
  switch (locator.kind) {
1209
+ case 'host-permissions':
1210
+ if (options.context.removeHostPermissions)
1211
+ return options.context.removeHostPermissions(locator);
1212
+ await updateHostPermissions({ env: options.context.env, cwd: locator.projectRoot ?? locator.hostConfigRoot, invocationCwd: options.context.invocationCwd }, locator);
1213
+ return;
1319
1214
  case 'cursor-workspace-hook':
1320
1215
  return platformOwnership.removeShared(component);
1321
1216
  case 'claude-permissions': {
@@ -1439,10 +1334,6 @@ function createNativeDriver(options) {
1439
1334
  };
1440
1335
  return {
1441
1336
  ownership,
1442
- beforeCleanupMutation: async (component) => {
1443
- if (component.kind === 'skill-directory')
1444
- await revokeAtRoot(component.path);
1445
- },
1446
1337
  setNativeMarketplaceEligibleTargets: (eligibleTargets) => {
1447
1338
  nativeMarketplaceEligibleTargets = new Set(eligibleTargets);
1448
1339
  },
@@ -1523,10 +1414,6 @@ function createNativeDriver(options) {
1523
1414
  ? 'both'
1524
1415
  : 'user'))));
1525
1416
  },
1526
- preflightMutation: async (target) => {
1527
- await assertManagedCommandBindingIdentities({ producers: (target.operationActions ?? []).flatMap((action) => action.kind === 'syncManagedCommandPackage' ? [{ producer: action.producer, sets: action.sets, nativeTools: action.nativeTools }] : []),
1528
- env: options.context.env });
1529
- },
1530
1417
  preflightMaterialize: async (target) => {
1531
1418
  if (target.identity.sourceId && options.context.expectedCatalogConfigDigest) {
1532
1419
  const current = await readCatalogSourcesConfigSnapshot(options.context.env);
@@ -1544,7 +1431,7 @@ function createNativeDriver(options) {
1544
1431
  if (action.kind !== 'retainManagedCommandPackage')
1545
1432
  continue;
1546
1433
  options.context.commandResults ??= [];
1547
- if (!options.context.commandResults.some((result) => getCommandPackageId(result.producer) === action.packageId))
1434
+ if (!options.context.commandResults.some((result) => result.packageId === action.packageId))
1548
1435
  options.context.commandResults.push(retainedManagedCommandPackageResult(action));
1549
1436
  }
1550
1437
  },
@@ -1637,10 +1524,8 @@ function createNativeDriver(options) {
1637
1524
  throw new Error('codexNativeObservationUnavailable: native group precheck is missing.');
1638
1525
  }
1639
1526
  const removalRequired = before === 'present';
1640
- if (!removalRequired) {
1641
- await revokeAtRoot(path.join(target.identity.marketplaceRoot ?? resolveAwHome(options.context.env), 'plugins', target.identity.pluginName), true, 'codex');
1527
+ if (!removalRequired)
1642
1528
  return;
1643
- }
1644
1529
  try {
1645
1530
  codexMutationMarketplaces.add(marketplaceName);
1646
1531
  await runObservedCodexMutation({
@@ -1677,8 +1562,6 @@ function createNativeDriver(options) {
1677
1562
  ? `codexNativeRemoveIncomplete: ${CODEX_REMOVE_RECOVERY}`
1678
1563
  : `codexNativeInstallIncomplete: ${component.pluginId} is absent from Codex plugin list.`);
1679
1564
  }
1680
- if (expected === 'absent')
1681
- await revokeAtRoot(path.join(target.identity.marketplaceRoot ?? resolveAwHome(options.context.env), 'plugins', target.identity.pluginName), true, 'codex');
1682
1565
  };
1683
1566
  if (options.operationScopedNativePhases) {
1684
1567
  deferredPostchecks.push({ target, postcheck });
@@ -1713,7 +1596,7 @@ function createNativeDriver(options) {
1713
1596
  }
1714
1597
  }
1715
1598
  },
1716
- applyManagedCommands: publishPackages,
1599
+ applyManagedCommands: (target) => publishLifecycleCommandPackages(target, options.context),
1717
1600
  writeNative: async () => { throw new Error('platformDeploymentRequired: native writes require a frozen platform deployment.'); },
1718
1601
  writeArtifacts: async (target) => {
1719
1602
  if (target.artifacts.length > 0)
@@ -1790,39 +1673,49 @@ export function createRebuildIntegration(options) {
1790
1673
  options.context.platformRebuildSession = platformSession;
1791
1674
  platformSession.updateContext(options.context);
1792
1675
  platformSession.setOwnershipExecutor(driver.ownership);
1676
+ const targetPlatforms = new Map();
1793
1677
  return {
1794
- resolvePlatformTargets: (inputs) => platformSession.resolveAll(inputs),
1678
+ resolvePlatformTargets: async (inputs) => {
1679
+ await platformSession.resolveAll(inputs);
1680
+ for (const input of inputs) {
1681
+ const id = input.pluginId ?? pluginActionId(input.plugin);
1682
+ const platforms = targetPlatforms.get(id) ?? [];
1683
+ if (!platforms.includes(input.platform))
1684
+ platforms.push(input.platform);
1685
+ targetPlatforms.set(id, platforms);
1686
+ }
1687
+ },
1795
1688
  sealMarketplaceGenerations: (eligible) => platformSession.sealMarketplaceGenerations(eligible),
1689
+ pendingOpenCodeProjectNotices: (interrupted) => platformSession.pendingOpenCodeProjectNotices(interrupted),
1796
1690
  driver,
1797
1691
  setNativeMarketplaceEligibleTargets: driver.setNativeMarketplaceEligibleTargets,
1798
1692
  prepareNativeMarketplaceGroup: driver.prepareNativeMarketplaceGroup,
1799
1693
  postcheckCodexProvider: driver.postcheckCodexProvider,
1800
1694
  captureCodexPostMutationSnapshots: driver.captureCodexPostMutationSnapshots,
1801
1695
  buildTarget: async (input) => {
1802
- const target = await platformSession.buildTarget(input);
1696
+ const removed = input.command === 'cleanup' || input.command === 'uninstall';
1697
+ const id = input.pluginId ?? pluginActionId(input.plugin);
1698
+ const platforms = options.context.commandPackagePlatforms?.get(id) ?? targetPlatforms.get(id) ?? [input.platform];
1699
+ let commands;
1803
1700
  if (!input.readOnlyInspectionPlan) {
1804
- const removed = input.command === 'cleanup' || input.command === 'uninstall';
1805
- const commands = removed ? { actions: [], candidates: [] }
1806
- : await commandPackageActions({ ...input, env: options.context.env, context: options.context });
1807
- const retained = removed ? await discoverRetainedManagedCommandPackages({
1808
- selectors: [{ sourceId: input.sourceId ?? input.plugin.sourceId, pluginName: input.plugin.manifest.name }],
1809
- scope: input.scope, cwd: input.cwd, env: options.context.env
1810
- }) : [];
1811
- const operationActions = [...commands.actions, ...retained.map((entry) => ({ ...entry,
1812
- kind: 'retainManagedCommandPackage', pluginId: `${entry.producer.sourceId}/${entry.producer.pluginName}`,
1813
- scope: entry.producer.scope }))];
1814
- options.context.managedCommandCandidates ??= new Map();
1815
- options.context.managedCommandCandidates.set(pluginActionId(input.plugin), commands.candidates);
1701
+ try {
1702
+ commands = await prepareLifecycleCommandPackage({ ...input, removing: removed, platforms, context: options.context });
1703
+ }
1704
+ catch (error) {
1705
+ if (error instanceof ManagedCommandError)
1706
+ throw new Error(`${error.code}: ${error.message}`, { cause: error });
1707
+ throw error;
1708
+ }
1709
+ }
1710
+ const target = await platformSession.buildTarget({ ...input, commandRecord: commands?.record });
1711
+ if (commands) {
1712
+ const operationActions = commands.actions;
1816
1713
  const preApply = input.plugin.manifest.scripts?.preApply;
1817
1714
  if (preApply && !removed && !isNativeActivationOnlyTarget(options.context, target.identity))
1818
1715
  operationActions.push({ kind: 'runPreApply',
1819
1716
  pluginId: input.pluginId ?? pluginActionId(input.plugin), platform: input.platform, scope: input.scope,
1820
1717
  script: preApply.path, scriptDigest: `sha256:${crypto.createHash('sha256')
1821
1718
  .update(await fs.readFile(path.resolve(input.plugin.rootDir, preApply.path.replace(/^\.\//u, '')))).digest('hex')}` });
1822
- const nativeToolChanges = await captureNativeToolChanges({ actions: operationActions,
1823
- producers: commands.candidates.map((candidate) => candidate.producer), removed, env: options.context.env });
1824
- if (nativeToolChanges.length)
1825
- operationActions[0].nativeToolChanges = nativeToolChanges;
1826
1719
  target.operationActions = operationActions;
1827
1720
  }
1828
1721
  targets.push(target);