@lesliechan721/aw 0.1.0-beta.101 → 0.1.0-beta.103

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 (199) hide show
  1. package/dist/src/commands/catalog-generation.d.ts +2 -5
  2. package/dist/src/commands/catalog-generation.js +2 -4
  3. package/dist/src/commands/catalog-generation.js.map +1 -1
  4. package/dist/src/commands/lifecycle-command-package.d.ts +1 -1
  5. package/dist/src/commands/lifecycle-command-package.js +40 -2
  6. package/dist/src/commands/lifecycle-command-package.js.map +1 -1
  7. package/dist/src/commands/managed-commands.d.ts +2 -1
  8. package/dist/src/commands/managed-commands.js +4 -2
  9. package/dist/src/commands/managed-commands.js.map +1 -1
  10. package/dist/src/commands/operation-plan.d.ts +2 -8
  11. package/dist/src/commands/operation-plan.js.map +1 -1
  12. package/dist/src/commands/public-config-confirmation.d.ts +16 -10
  13. package/dist/src/commands/public-config-confirmation.js +87 -52
  14. package/dist/src/commands/public-config-confirmation.js.map +1 -1
  15. package/dist/src/commands/public-lifecycle.d.ts +1 -1
  16. package/dist/src/commands/public-lifecycle.js +36 -8
  17. package/dist/src/commands/public-lifecycle.js.map +1 -1
  18. package/dist/src/commands/public-plugin-query.js +6 -4
  19. package/dist/src/commands/public-plugin-query.js.map +1 -1
  20. package/dist/src/commands/rebuild-command.d.ts +22 -6
  21. package/dist/src/commands/rebuild-command.js +273 -557
  22. package/dist/src/commands/rebuild-command.js.map +1 -1
  23. package/dist/src/commands/rebuild-integration.d.ts +12 -39
  24. package/dist/src/commands/rebuild-integration.js +67 -303
  25. package/dist/src/commands/rebuild-integration.js.map +1 -1
  26. package/dist/src/commands/rebuild-operations.d.ts +0 -4
  27. package/dist/src/commands/rebuild-operations.js +9 -8
  28. package/dist/src/commands/rebuild-operations.js.map +1 -1
  29. package/dist/src/commands/rebuild-platform-integration.d.ts +14 -6
  30. package/dist/src/commands/rebuild-platform-integration.js +310 -101
  31. package/dist/src/commands/rebuild-platform-integration.js.map +1 -1
  32. package/dist/src/commands/status-v6.d.ts +3 -117
  33. package/dist/src/commands/status-v6.js +0 -2886
  34. package/dist/src/commands/status-v6.js.map +1 -1
  35. package/dist/src/commands/write-commands.js +0 -3
  36. package/dist/src/commands/write-commands.js.map +1 -1
  37. package/dist/src/index.js +44 -36
  38. package/dist/src/index.js.map +1 -1
  39. package/dist/src/intent/deployment-preferences.js +4 -3
  40. package/dist/src/intent/deployment-preferences.js.map +1 -1
  41. package/dist/src/intent/intent-store.js +3 -2
  42. package/dist/src/intent/intent-store.js.map +1 -1
  43. package/dist/src/output/command-receipt.d.ts +0 -6
  44. package/dist/src/output/command-receipt.js +0 -15
  45. package/dist/src/output/command-receipt.js.map +1 -1
  46. package/dist/src/output/receipt-projection.js +2 -1
  47. package/dist/src/output/receipt-projection.js.map +1 -1
  48. package/dist/src/platforms/capabilities.js +8 -2
  49. package/dist/src/platforms/capabilities.js.map +1 -1
  50. package/dist/src/platforms/contracts.d.ts +2 -0
  51. package/dist/src/platforms/discovery.d.ts +2 -0
  52. package/dist/src/platforms/discovery.js +95 -49
  53. package/dist/src/platforms/discovery.js.map +1 -1
  54. package/dist/src/platforms/inspection-native.d.ts +7 -1
  55. package/dist/src/platforms/inspection-native.js +6 -3
  56. package/dist/src/platforms/inspection-native.js.map +1 -1
  57. package/dist/src/platforms/inspection-query.d.ts +28 -14
  58. package/dist/src/platforms/inspection-query.js +102 -8
  59. package/dist/src/platforms/inspection-query.js.map +1 -1
  60. package/dist/src/platforms/lifecycle-native-services.d.ts +1 -1
  61. package/dist/src/platforms/lifecycle-native-services.js +7 -2
  62. package/dist/src/platforms/lifecycle-native-services.js.map +1 -1
  63. package/dist/src/platforms/lifecycle-native.js +20 -3
  64. package/dist/src/platforms/lifecycle-native.js.map +1 -1
  65. package/dist/src/platforms/lifecycle.js +5 -0
  66. package/dist/src/platforms/lifecycle.js.map +1 -1
  67. package/dist/src/platforms/supplement-state.js +11 -2
  68. package/dist/src/platforms/supplement-state.js.map +1 -1
  69. package/dist/src/portable/commands.d.ts +1 -0
  70. package/dist/src/portable/commands.js.map +1 -1
  71. package/dist/src/portable/materializer.d.ts +2 -0
  72. package/dist/src/portable/materializer.js +4 -4
  73. package/dist/src/portable/materializer.js.map +1 -1
  74. package/dist/src/portable/recovery.d.ts +1 -0
  75. package/dist/src/portable/recovery.js +3 -2
  76. package/dist/src/portable/recovery.js.map +1 -1
  77. package/dist/src/recovery/coordinator.d.ts +6 -1
  78. package/dist/src/recovery/coordinator.js +113 -108
  79. package/dist/src/recovery/coordinator.js.map +1 -1
  80. package/dist/src/recovery/demand.d.ts +1 -2
  81. package/dist/src/recovery/demand.js +4 -11
  82. package/dist/src/recovery/demand.js.map +1 -1
  83. package/dist/src/recovery/install-concurrency.d.ts +12 -0
  84. package/dist/src/recovery/install-concurrency.js +39 -0
  85. package/dist/src/recovery/install-concurrency.js.map +1 -1
  86. package/dist/src/recovery/joint-coordinator.d.ts +3 -4
  87. package/dist/src/recovery/joint-coordinator.js +324 -188
  88. package/dist/src/recovery/joint-coordinator.js.map +1 -1
  89. package/dist/src/recovery/joint-demand.js +4 -3
  90. package/dist/src/recovery/joint-demand.js.map +1 -1
  91. package/dist/src/recovery/joint-install-execution.js +46 -2
  92. package/dist/src/recovery/joint-install-execution.js.map +1 -1
  93. package/dist/src/recovery/joint-install-native-rebase.js +5 -2
  94. package/dist/src/recovery/joint-install-native-rebase.js.map +1 -1
  95. package/dist/src/recovery/locked-prepared-execution.d.ts +32 -0
  96. package/dist/src/recovery/locked-prepared-execution.js +67 -0
  97. package/dist/src/recovery/locked-prepared-execution.js.map +1 -0
  98. package/dist/src/recovery/status.d.ts +20 -6
  99. package/dist/src/recovery/status.js +153 -98
  100. package/dist/src/recovery/status.js.map +1 -1
  101. package/dist/src/review/skill-materialization.d.ts +1 -0
  102. package/dist/src/review/skill-materialization.js.map +1 -1
  103. package/dist/src/tui/console-app-v4.js +4 -14
  104. package/dist/src/tui/console-app-v4.js.map +1 -1
  105. package/dist/src/tui/controller-runtime.js +201 -57
  106. package/dist/src/tui/controller-runtime.js.map +1 -1
  107. package/dist/src/tui/controller.d.ts +8 -9
  108. package/dist/src/tui/controller.js +5 -6
  109. package/dist/src/tui/controller.js.map +1 -1
  110. package/dist/src/tui/operation-review-planner.js +14 -103
  111. package/dist/src/tui/operation-review-planner.js.map +1 -1
  112. package/dist/src/types.d.ts +5 -1
  113. package/dist/src/types.js.map +1 -1
  114. package/dist/src/utils/agent-version.js +1 -0
  115. package/dist/src/utils/agent-version.js.map +1 -1
  116. package/dist/src/utils/artifact-renderer.d.ts +10 -0
  117. package/dist/src/utils/artifact-renderer.js +28 -2
  118. package/dist/src/utils/artifact-renderer.js.map +1 -1
  119. package/dist/src/utils/aw-home-mutation-lock.d.ts +8 -0
  120. package/dist/src/utils/aw-home-mutation-lock.js +44 -8
  121. package/dist/src/utils/aw-home-mutation-lock.js.map +1 -1
  122. package/dist/src/utils/bundle-integrity.js +126 -33
  123. package/dist/src/utils/bundle-integrity.js.map +1 -1
  124. package/dist/src/utils/catalog-generation-resolver.d.ts +4 -0
  125. package/dist/src/utils/catalog-generation-resolver.js +4 -0
  126. package/dist/src/utils/catalog-generation-resolver.js.map +1 -1
  127. package/dist/src/utils/catalog-generation-service.d.ts +50 -11
  128. package/dist/src/utils/catalog-generation-service.js +276 -130
  129. package/dist/src/utils/catalog-generation-service.js.map +1 -1
  130. package/dist/src/utils/catalog-generation-state.js +6 -1
  131. package/dist/src/utils/catalog-generation-state.js.map +1 -1
  132. package/dist/src/utils/catalog-generation-store.d.ts +5 -0
  133. package/dist/src/utils/catalog-generation-store.js +36 -13
  134. package/dist/src/utils/catalog-generation-store.js.map +1 -1
  135. package/dist/src/utils/catalog-operation-context.d.ts +17 -3
  136. package/dist/src/utils/catalog-operation-context.js +220 -22
  137. package/dist/src/utils/catalog-operation-context.js.map +1 -1
  138. package/dist/src/utils/catalog-performance.d.ts +3 -0
  139. package/dist/src/utils/catalog-performance.js +26 -0
  140. package/dist/src/utils/catalog-performance.js.map +1 -0
  141. package/dist/src/utils/catalog-snapshot.d.ts +5 -2
  142. package/dist/src/utils/catalog-snapshot.js +3 -2
  143. package/dist/src/utils/catalog-snapshot.js.map +1 -1
  144. package/dist/src/utils/catalog-source-impact.d.ts +2 -1
  145. package/dist/src/utils/catalog-source-impact.js +2 -2
  146. package/dist/src/utils/catalog-source-impact.js.map +1 -1
  147. package/dist/src/utils/catalog-source-references.d.ts +2 -0
  148. package/dist/src/utils/catalog-source-references.js +284 -148
  149. package/dist/src/utils/catalog-source-references.js.map +1 -1
  150. package/dist/src/utils/codex-executable-discovery.js +1 -0
  151. package/dist/src/utils/codex-executable-discovery.js.map +1 -1
  152. package/dist/src/utils/codex-manager.js +1 -0
  153. package/dist/src/utils/codex-manager.js.map +1 -1
  154. package/dist/src/utils/codex-native-observation.d.ts +5 -2
  155. package/dist/src/utils/codex-native-observation.js +8 -4
  156. package/dist/src/utils/codex-native-observation.js.map +1 -1
  157. package/dist/src/utils/component-command-preparation.d.ts +1 -0
  158. package/dist/src/utils/component-command-preparation.js.map +1 -1
  159. package/dist/src/utils/git-catalog-provider.d.ts +38 -5
  160. package/dist/src/utils/git-catalog-provider.js +365 -156
  161. package/dist/src/utils/git-catalog-provider.js.map +1 -1
  162. package/dist/src/utils/managed-command-closure.d.ts +3 -1
  163. package/dist/src/utils/managed-command-closure.js +10 -5
  164. package/dist/src/utils/managed-command-closure.js.map +1 -1
  165. package/dist/src/utils/managed-command-materialization.d.ts +2 -0
  166. package/dist/src/utils/managed-command-materialization.js +4 -3
  167. package/dist/src/utils/managed-command-materialization.js.map +1 -1
  168. package/dist/src/utils/managed-command-preparation.js +1 -1
  169. package/dist/src/utils/managed-command-preparation.js.map +1 -1
  170. package/dist/src/utils/multi-source-catalog.d.ts +1 -1
  171. package/dist/src/utils/multi-source-catalog.js +3 -3
  172. package/dist/src/utils/multi-source-catalog.js.map +1 -1
  173. package/dist/src/utils/native-cli.d.ts +6 -1
  174. package/dist/src/utils/native-cli.js +67 -32
  175. package/dist/src/utils/native-cli.js.map +1 -1
  176. package/dist/src/utils/platform-empty-state.d.ts +2 -0
  177. package/dist/src/utils/platform-empty-state.js +5 -5
  178. package/dist/src/utils/platform-empty-state.js.map +1 -1
  179. package/dist/src/utils/plugin-config-command-apply.d.ts +14 -4
  180. package/dist/src/utils/plugin-config-command-apply.js +49 -5
  181. package/dist/src/utils/plugin-config-command-apply.js.map +1 -1
  182. package/dist/src/utils/plugin-config-impact.d.ts +42 -0
  183. package/dist/src/utils/plugin-config-impact.js +170 -14
  184. package/dist/src/utils/plugin-config-impact.js.map +1 -1
  185. package/dist/src/utils/plugin-config-references.d.ts +3 -1
  186. package/dist/src/utils/plugin-config-references.js +3 -5
  187. package/dist/src/utils/plugin-config-references.js.map +1 -1
  188. package/dist/src/utils/plugin-config-write.d.ts +14 -5
  189. package/dist/src/utils/plugin-config-write.js +213 -117
  190. package/dist/src/utils/plugin-config-write.js.map +1 -1
  191. package/dist/src/utils/plugin-config.d.ts +2 -0
  192. package/dist/src/utils/plugin-config.js.map +1 -1
  193. package/dist/src/utils/plugin-scripts.d.ts +2 -0
  194. package/dist/src/utils/plugin-scripts.js +102 -3
  195. package/dist/src/utils/plugin-scripts.js.map +1 -1
  196. package/package.json +3 -5
  197. package/dist/src/utils/codex-reconciler.d.ts +0 -123
  198. package/dist/src/utils/codex-reconciler.js +0 -322
  199. package/dist/src/utils/codex-reconciler.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import path from 'node:path';
2
- import { isPlatformTarget, normalizeStaticPluginComponents, resolveInvocationPolicy } from '@lesliechan721/aw-plugin-core/manifest';
2
+ import { isPlatformTarget, NATIVE_PLATFORM_TARGETS, resolveInvocationPolicy } from '@lesliechan721/aw-plugin-core/manifest';
3
3
  import { selectAgents } from '../intent/deployment-preferences.js';
4
4
  import { createScopeContext } from '../intent/scope-context.js';
5
5
  import { resolveIntentPath } from '../intent/intent-store.js';
@@ -9,7 +9,6 @@ import { readJointDemand, deriveJointDemand, projectSkillCandidates, isInstalled
9
9
  import { readDemand, resolveDelivery } from './demand.js';
10
10
  import { retainedOutputDiagnostic, scopeNativeComponentGaps, uniqueRecoveryComponentGaps } from './receipt.js';
11
11
  import { rethrowFatalError } from '../utils/codex-executable-discovery.js';
12
- import { createCodexNativeObservationSession } from '../utils/codex-native-observation.js';
13
12
  import { getAgentPluginAdapter } from '../platforms/registry.js';
14
13
  import { getQualifiedPlatformProfile } from '../platforms/capabilities.js';
15
14
  import { isDeliveryCapabilityGap } from '../utils/component-gap.js';
@@ -28,20 +27,25 @@ import { deploymentPackageComponent, inspectStaticSupplements, requiredDeploymen
28
27
  import { resolveStaticPlatformResourceRoot } from '../utils/component-resources.js';
29
28
  import { inspectOwnedComponents, readSkillOwnerMarker } from '../utils/ownership.js';
30
29
  import { inventoryCatalogSourceReferences } from '../utils/catalog-source-references.js';
31
- import { resolvePartialCatalogOperationContext } from '../utils/catalog-operation-context.js';
32
- import { checkAwCapabilitySupport, readPluginManifest } from '../utils/manifest.js';
30
+ import { resolvePartialCatalogOperationContext, CatalogPreparationReadScope } from '../utils/catalog-operation-context.js';
31
+ import { checkAwCapabilitySupport } from '../utils/manifest.js';
33
32
  import { IMPLEMENTED_AW_CAPABILITIES } from '../commands/aw-capabilities.js';
34
33
  import { resolvePluginDependencyClosure, resolvePluginMetaDependencyClosure } from '../utils/plugin-dependencies.js';
35
- import { installationInvocation, selectNativeProduct } from '../platforms/discovery.js';
34
+ import { resolvePlatformConfigRoot } from '../platforms/discovery.js';
36
35
  import { inventoryRecoveryDiagnostic } from '../utils/inventory-recovery-diagnostic.js';
37
36
  import { measureRecoveryPerformanceStage } from './performance.js';
38
37
  import { withNativeObservationBatch } from '../platforms/inspection-query.js';
39
38
  import { readCatalogSourcesConfigSnapshot } from '../utils/catalog-sources.js';
40
- import { mapInstallReads } from './install-concurrency.js';
39
+ import { installConcurrencyLimits, mapInstallReads } from './install-concurrency.js';
41
40
  import { selectPlatformInvocationPolicy, hostPermissionClaims } from '../generators/permissions.js';
42
41
  import { isPermissionHost } from '../platforms/host-permission-policy.js';
43
42
  import { inspectHostPermissionDelivery } from '../platforms/permission-ownership.js';
44
43
  import { readManagedCommandPackage } from '../utils/managed-command-store.js';
44
+ function createStatusDispatchGate() {
45
+ let release;
46
+ const promise = new Promise((resolve) => { release = resolve; });
47
+ return { promise, resolve: release };
48
+ }
45
49
  const NATIVE_READ_ERRORS = new Set(['nativeStateUnreadable', 'stateInventoryFailed', 'configReadFailed', 'componentInspectionFailed', 'targetInspectionFailed', 'codexNativeObservationFailed',
46
50
  'nativeObservationFailed', 'nativeObservationUnavailable']);
47
51
  function isNativeReadError({ code, detail }, needsOwnership = true) {
@@ -56,11 +60,9 @@ export function isTargetObservationReadError(entry) {
56
60
  }
57
61
  function diagnostic(code) { return { code, message: `目标尚未满足:${code}。` }; }
58
62
  function withStatusNativeQueries(options, read) {
59
- if (options.nativeQuerySession)
63
+ if (options.nativeObservationBatch)
60
64
  return read(options);
61
- return withNativeObservationBatch({ runner: options.nativeCliRunner, signal: options.signal }, (batch) => read({ ...options,
62
- discoveryCache: options.discoveryCache ?? batch.discoveryCache, nativeQuerySession: batch.nativeQuerySession,
63
- nativeCliRunner: batch.runner }));
65
+ return withNativeObservationBatch({ phase: 'read-only-status', runner: options.nativeCliRunner, signal: options.signal }, (batch) => read({ ...options, nativeObservationBatch: batch, nativeCliRunner: batch.runner }));
64
66
  }
65
67
  async function readAdapterObservations(options, context, demand, inventory) {
66
68
  let selected;
@@ -72,25 +74,43 @@ async function readAdapterObservations(options, context, demand, inventory) {
72
74
  return { observations: [], existing: [], owned: [] };
73
75
  }
74
76
  const commandPackages = new Map();
77
+ // Joint scopes can run together, but one host still has at most four root readers.
78
+ const rootReadLimit = Math.max(1, Math.floor(installConcurrencyLimits().reads / (options.statusUserDispatch ? 2 : 1)));
75
79
  const platforms = await mapInstallReads(selected, async (platform) => {
76
80
  const observations = [];
77
81
  const existing = [];
78
82
  const owned = [];
79
- const ctx = { cwd: context.executionCwd, env: context.env, signal: options.signal, runner: options.nativeCliRunner,
80
- discoveryCache: options.discoveryCache, nativeQuerySession: options.nativeQuerySession,
81
- codexObservationSession: platform === 'codex' ? options.codexObservationSession : undefined,
83
+ const base = { cwd: options.nativeObservationExactCwd ?? context.executionCwd, env: context.env, signal: options.signal, runner: options.nativeCliRunner,
82
84
  observeNative: options.observeNative };
85
+ const ctx = { ...options.nativeObservationBatch.readContextFor(platform, options.nativeObservationWindow ?? 'ordinary', base), cwd: context.executionCwd };
86
+ // Both scopes may resolve bindings and inspect files concurrently. Preserve
87
+ // the User-first native inventory dispatch contract without serializing reads.
88
+ const dispatch = options.statusUserDispatch?.get(platform);
89
+ const queries = ctx.nativeQuerySession;
90
+ if (dispatch && queries)
91
+ ctx.nativeQuerySession = { ...queries, async read(key, readContext, action) {
92
+ if (demand.scope === 'project')
93
+ await dispatch.promise;
94
+ else {
95
+ const result = queries.read(key, readContext, action);
96
+ dispatch.resolve();
97
+ return result;
98
+ }
99
+ return queries.read(key, readContext, action);
100
+ } };
83
101
  options.signal?.throwIfAborted();
84
102
  const roots = (demand.roots ?? []).filter((root) => root.plugin
85
103
  && resolveDelivery(root.plugin.manifest, platform, demand.scope)?.kind === 'native'
86
104
  && (!demand.targetRequirements || demand.targetRequirements.some((item) => item.pluginId === root.pluginId && item.target === platform)));
87
- if (!roots.length)
105
+ if (!roots.length) {
106
+ if (demand.scope === 'user')
107
+ dispatch?.resolve();
88
108
  return { observations, existing, owned };
109
+ }
89
110
  // Configuration is independent of the host's availability. Preserve these blockers if discovery fails.
90
111
  const configuredRoots = await mapInstallReads(roots, async (root) => {
91
112
  options.signal?.throwIfAborted();
92
113
  const observation = { pluginId: root.pluginId, expectedVersion: root.plugin?.manifest.version, platform, content: 'unknown', blockers: [], reasons: [], deploymentObservations: [] };
93
- observations.push(observation);
94
114
  const plugin = root.plugin;
95
115
  const active = demand.preferences.state === 'valid'
96
116
  && resolveActiveConfigPlatforms(root.pluginId, plugin.manifest, demand.preferences).includes(platform);
@@ -114,29 +134,22 @@ async function readAdapterObservations(options, context, demand, inventory) {
114
134
  }
115
135
  };
116
136
  // Missing clients/bindings cannot hide a known configuration problem. Keep inspecting live ownership.
117
- const scopedConfig = await configForScope(demand.scope, context.executionCwd);
118
- return { root, observation, configForScope, scopedConfig };
119
- }, { signal: options.signal, limit: 1 });
137
+ const detailed = !options.planningDetails || options.planningDetails.has(root.pluginId);
138
+ const scopedConfig = detailed ? await configForScope(demand.scope, context.executionCwd) : undefined;
139
+ return { root, observation, configForScope, scopedConfig, detailed,
140
+ existing: [], owned: [] };
141
+ }, { signal: options.signal, limit: rootReadLimit });
142
+ observations.push(...configuredRoots.map(({ observation }) => observation));
120
143
  const adapter = getAgentPluginAdapter(platform);
121
- let ownedSession;
122
144
  try {
123
- const discovery = await measureRecoveryPerformanceStage(options, 'status.discovery', () => adapter.discover(ctx));
124
- if (platform === 'codex') {
125
- const product = selectNativeProduct(discovery.installations);
126
- if (product) {
127
- const invocation = await installationInvocation(product, ctx, []);
128
- const manager = { kind: product.product === 'app' ? 'app' : 'system', version: product.version ?? 'unknown',
129
- command: invocation.command, argsPrefix: invocation.args };
130
- if (ctx.codexObservationSession)
131
- ctx.codexObservationSession.setManager(manager);
132
- else {
133
- ownedSession = await createCodexNativeObservationSession({ exactCwd: context.executionCwd, env: context.env, manager,
134
- runner: options.nativeCliRunner, probe: { platform: ctx.platform, signal: options.signal } });
135
- ctx.codexObservationSession = ownedSession;
136
- }
137
- }
138
- }
139
- for (const { root, observation, configForScope, scopedConfig } of configuredRoots) {
145
+ const neutralCwd = await ctx.nativeQuerySession.userCwd(context.env, platform === 'grok');
146
+ // Pi resolves its agent directory relative to the actual inventory cwd.
147
+ // Share neutral discovery only when it describes the same config root.
148
+ const discoveryCwd = platform === 'pi' && demand.scope === 'project'
149
+ && resolvePlatformConfigRoot(platform, ctx) !== resolvePlatformConfigRoot(platform, { ...ctx, cwd: neutralCwd })
150
+ ? ctx.cwd : neutralCwd;
151
+ const discovery = await measureRecoveryPerformanceStage(options, 'status.discovery', () => adapter.discover({ ...ctx, cwd: discoveryCwd }));
152
+ await mapInstallReads(configuredRoots, async ({ root, observation, configForScope, scopedConfig, detailed, existing, owned }) => {
140
153
  options.signal?.throwIfAborted();
141
154
  let nativePackage;
142
155
  try {
@@ -159,16 +172,16 @@ async function readAdapterObservations(options, context, demand, inventory) {
159
172
  observation.blockers.push(...discovery.diagnostics.map((entry) => ({ code: entry.code, message: entry.message })));
160
173
  if (!observation.blockers.some((blocker) => !isConfigDiagnostic(blocker)))
161
174
  observation.blockers.push(diagnostic(discovery.availability === 'missing' ? 'client-missing' : 'nativeObservationUnavailable'));
162
- continue;
175
+ return;
163
176
  }
164
177
  const states = [];
165
178
  const emptyMatches = [];
166
179
  const currentMatches = [];
167
180
  const versions = [];
168
181
  const deliveredIds = new Set();
169
- const staticResourceRoot = await resolveStaticPlatformResourceRoot(plugin.rootDir, platform);
182
+ const staticResourceRoot = detailed ? await resolveStaticPlatformResourceRoot(plugin.rootDir, platform) : undefined;
170
183
  let commandRoutes;
171
- if (plugin.sourceIdentity && plugin.manifest.command?.platforms.includes(platform)) {
184
+ if (detailed && plugin.sourceIdentity && plugin.manifest.command?.platforms.includes(platform)) {
172
185
  let commandPackage = commandPackages.get(root.pluginId);
173
186
  if (!commandPackage) {
174
187
  commandPackage = readManagedCommandPackage({ sourceId: root.sourceId,
@@ -185,7 +198,7 @@ async function readAdapterObservations(options, context, demand, inventory) {
185
198
  versions.push(live.packageVersion);
186
199
  options.signal?.throwIfAborted();
187
200
  observation.deploymentObservations.push({ bindingId: binding.id, products: binding.consumers, after: live });
188
- if (isPermissionHost(platform)) {
201
+ if (detailed && isPermissionHost(platform)) {
189
202
  const { policy } = selectPlatformInvocationPolicy(resolveInvocationPolicy(plugin.manifest, platform, root.pluginId), subject, commandRoutes ?? null);
190
203
  const claims = hostPermissionClaims(policy.permissions, policy.invocationSelector);
191
204
  const previous = inventory.some(({ ownedComponent }) => ownedComponent?.kind === 'shared-config'
@@ -211,6 +224,11 @@ async function readAdapterObservations(options, context, demand, inventory) {
211
224
  existing.push({ pluginId: root.pluginId, agent: platform, scope: demand.scope,
212
225
  ...(nativePackage ? { nativePackage } : {}) });
213
226
  }
227
+ if (!detailed) {
228
+ observation.blockers.push(...live.diagnostics.filter((entry) => isNativeReadError(entry)));
229
+ states.push('unknown');
230
+ continue;
231
+ }
214
232
  if (!scopedConfig) {
215
233
  states.push('unknown');
216
234
  continue;
@@ -239,7 +257,7 @@ async function readAdapterObservations(options, context, demand, inventory) {
239
257
  states.push('unknown');
240
258
  continue;
241
259
  }
242
- const inputEvidence = await createPlatformInputEvidence({ plugin, binding, units: inputUnits, commandRoutes }).catch((error) => {
260
+ const inputEvidence = await createPlatformInputEvidence({ plugin, binding, units: inputUnits, commandRoutes, catalogReadScope: options.catalogReadScope }).catch((error) => {
243
261
  rethrowFatalError(error);
244
262
  options.signal?.throwIfAborted();
245
263
  const systemCode = error?.code;
@@ -274,8 +292,8 @@ async function readAdapterObservations(options, context, demand, inventory) {
274
292
  let grokAgentRecipientScope;
275
293
  for (const { renderUnit: unit, capabilities } of inputUnits) {
276
294
  // Static Agent references are resolved by Core; dynamic references stay deferred to current delivery evidence.
277
- const expected = await normalizeStaticPluginComponents({ pluginRoot: plugin.rootDir, staticResourceRoot,
278
- manifest: plugin.manifest, platform, capabilities, allowedOutputKinds: unit.kinds,
295
+ const expected = await CatalogPreparationReadScope.normalizeStaticDeclarations(options.catalogReadScope, plugin, { staticResourceRoot,
296
+ platform, capabilities, allowedOutputKinds: unit.kinds,
279
297
  hasInstructionAgentRecipients: platform === 'grok' && unit.output === 'supplement'
280
298
  ? grokAgentRecipientScope === identityDigest(unit.renderScope) : projectedRole || undefined });
281
299
  if (platform === 'grok' && unit.output === 'package'
@@ -590,7 +608,7 @@ async function readAdapterObservations(options, context, demand, inventory) {
590
608
  observation.content = 'unknown';
591
609
  observation.blockers.push(diagnostic('nativeObservationFailed'));
592
610
  }
593
- }
611
+ }, { signal: options.signal, limit: rootReadLimit });
594
612
  }
595
613
  catch (error) {
596
614
  rethrowFatalError(error);
@@ -601,9 +619,10 @@ async function readAdapterObservations(options, context, demand, inventory) {
601
619
  }
602
620
  }
603
621
  finally {
604
- await ownedSession?.dispose();
622
+ if (demand.scope === 'user')
623
+ dispatch?.resolve();
605
624
  }
606
- return { observations, existing, owned };
625
+ return { observations, existing: configuredRoots.flatMap((result) => result.existing), owned: configuredRoots.flatMap((result) => result.owned) };
607
626
  }, { signal: options.signal });
608
627
  return { observations: platforms.flatMap((result) => result.observations),
609
628
  existing: platforms.flatMap((result) => result.existing), owned: platforms.flatMap((result) => result.owned) };
@@ -708,7 +727,7 @@ export async function statusFromObservations(options) {
708
727
  errors.push({ ...diagnostic('nativeObservationUnavailable'), pluginId: root.pluginId });
709
728
  }
710
729
  }
711
- else {
730
+ else if (!options.planningDetails || options.planningDetails.has(root.pluginId)) {
712
731
  try {
713
732
  const portable = await inspectPortableRecovery({ scope: options.scope, context: options.context,
714
733
  selector: root.pluginId, agents: [agent], env: options.env, signal: options.signal,
@@ -827,6 +846,7 @@ export async function statusFromObservations(options) {
827
846
  }
828
847
  export async function readScopedRecoveryStatus(options) {
829
848
  options.signal?.throwIfAborted();
849
+ options = { ...options, catalogReadScope: options.catalogReadScope ?? new CatalogPreparationReadScope(options) };
830
850
  const context = await createScopeContext({ scope: options.scope, cwd: options.cwd, env: options.env, readOnly: true });
831
851
  try {
832
852
  options.signal?.throwIfAborted();
@@ -836,7 +856,7 @@ export async function readScopedRecoveryStatus(options) {
836
856
  options.onDemand?.(demand);
837
857
  options.signal?.throwIfAborted();
838
858
  const ownerInventory = options.nativeObservations ? { references: [], errors: [] }
839
- : await measureRecoveryPerformanceStage(options, 'status.inventory', () => inventoryCatalogSourceReferences({ cwd: context.executionCwd, env: context.env, scope: options.scope,
859
+ : options.ownerInventoryOverride ?? await measureRecoveryPerformanceStage(options, 'status.inventory', () => inventoryCatalogSourceReferences({ cwd: context.executionCwd, env: context.env, scope: options.scope,
840
860
  knownPluginNames: demand.plugins.map((plugin) => plugin.manifest.name), collectPathEvidence: false,
841
861
  observationPlugins: options.observationPlugins }));
842
862
  options.signal?.throwIfAborted();
@@ -847,7 +867,7 @@ export async function readScopedRecoveryStatus(options) {
847
867
  && (!options.targets || options.targets.includes(entry.platform)));
848
868
  const portableExtra = options.targets && !options.targets.includes('generic') ? { targets: [], complete: true }
849
869
  : await inspectPortableExtraInstalled({
850
- scope: options.scope, context, env: context.env, signal: options.signal, plugins: options.observationPlugins,
870
+ scope: options.scope, context, env: context.env, signal: options.signal, plugins: options.observationPlugins ?? options.planningDetails,
851
871
  });
852
872
  options.signal?.throwIfAborted();
853
873
  const sourceCandidates = [...candidates, ...portableExtra.targets.flatMap((target) => {
@@ -904,7 +924,7 @@ export async function readScopedRecoveryStatus(options) {
904
924
  if (observedPlugins.has(id))
905
925
  continue;
906
926
  try {
907
- const plugin = await readPluginManifest(path.join(source.rootDir, 'plugins', name), { mode: 'bundle' });
927
+ const plugin = await CatalogPreparationReadScope.readManifest(options.catalogReadScope, source, name);
908
928
  Object.assign(plugin, { pluginId: id, sourceId: source.sourceId, sourceIdentity: source.sourceIdentity,
909
929
  catalogLogicalIdentity: source.logicalIdentity });
910
930
  observedPlugins.set(id, plugin);
@@ -1035,7 +1055,8 @@ export async function readScopedRecoveryStatus(options) {
1035
1055
  const plugin = observedPlugins.get(entry.pluginId);
1036
1056
  const key = `${entry.pluginId}\0${entry.agent}`;
1037
1057
  const current = plugin?.catalogLogicalIdentity !== undefined && plugin.catalogLogicalIdentity === entry.logicalIdentity;
1038
- if (current && !portableConfigBlockers.has(key) && demand.preferences.state === 'valid'
1058
+ if (current && (!options.planningDetails || options.planningDetails.has(entry.pluginId))
1059
+ && !portableConfigBlockers.has(key) && demand.preferences.state === 'valid'
1039
1060
  && (!options.observationPlugins || options.observationPlugins.has(entry.pluginId)
1040
1061
  || options.observationPlugins.has(parsePluginId(entry.pluginId).pluginName))
1041
1062
  && resolveActiveConfigPlatforms(entry.pluginId, plugin.manifest, demand.preferences).includes(entry.agent)) {
@@ -1191,31 +1212,22 @@ export function aggregateConvergence(allSatisfied, residue) {
1191
1212
  export async function readRecoveryStatus(options, preparedDemand) {
1192
1213
  return withStatusNativeQueries(options, (nativeOptions) => readRecoveryStatusWithQueries(nativeOptions, preparedDemand));
1193
1214
  }
1215
+ /** Direct single-root sync needs whole ownership/reference coverage, not a
1216
+ * full content report for unrelated roots. Public/final status stays full. */
1217
+ export function readRecoveryPlanningStatus(options, snapshot, selector) {
1218
+ const plan = deriveJointDemand(snapshot);
1219
+ const details = expandStatusPluginSelection(snapshot, plan, [selector]);
1220
+ // Other candidates can move a provider between scopes and therefore still
1221
+ // contribute to the same global desired/actual shared-reference fingerprint.
1222
+ for (const candidate of [...projectSkillCandidates(plan), ...(options.projectSkillProbes ?? [])])
1223
+ details.add(candidate.pluginId);
1224
+ return readRecoveryStatus({ ...options, planningDetails: details }, snapshot);
1225
+ }
1194
1226
  async function readRecoveryStatusWithQueries(options, preparedDemand) {
1195
- options = { ...options, discoveryCache: options.discoveryCache ?? new Map(), catalogSources: new Map() };
1227
+ options = { ...options, catalogSources: new Map(),
1228
+ catalogReadScope: options.catalogReadScope ?? new CatalogPreparationReadScope(options) };
1196
1229
  const snapshot = preparedDemand ?? await measureRecoveryPerformanceStage(options, 'status.demand', () => readJointDemand(options));
1197
- if (options.codexObservationSession || options.nativeObservations || options.targets && !options.targets.includes('codex')) {
1198
- return readRecoveryStatusInSession(options, snapshot);
1199
- }
1200
- const context = await createScopeContext({ scope: snapshot.context.context,
1201
- cwd: snapshot.context.projectRoot ?? options.cwd, env: options.env, readOnly: true });
1202
- let session;
1203
- try {
1204
- options.signal?.throwIfAborted();
1205
- session = await createCodexNativeObservationSession({ exactCwd: context.executionCwd, env: context.env,
1206
- runner: options.nativeCliRunner, probe: { signal: options.signal } });
1207
- // User reads use only this session's neutral cwd. Project reads add the
1208
- // exact project snapshot without repeating the same neutral observation.
1209
- return await readRecoveryStatusInSession({ ...options, codexObservationSession: session }, snapshot);
1210
- }
1211
- finally {
1212
- try {
1213
- await session?.dispose();
1214
- }
1215
- finally {
1216
- await context.dispose();
1217
- }
1218
- }
1230
+ return readRecoveryStatusInSession({ ...options, nativeObservationExactCwd: snapshot.context.projectRoot ?? options.cwd }, snapshot);
1219
1231
  }
1220
1232
  /** An empty demand or inventory does not establish that the selected Catalog is readable. */
1221
1233
  async function checkUndeclaredSelection(options, snapshot) {
@@ -1305,43 +1317,68 @@ function projectSkillCopy(user, project, userAbsent) {
1305
1317
  }
1306
1318
  return deployments.some(({ after }) => after.package === 'present' || after.antigravityLegacyProjectPackage?.state === 'owned') ? 'owned' : 'absent';
1307
1319
  }
1308
- async function readRecoveryStatusInSession(options, snapshot) {
1309
- const selectionErrors = await checkUndeclaredSelection(options, snapshot);
1310
- const requestedDemand = options.targets ? { ...snapshot, preferences: snapshot.preferences
1311
- ? { ...snapshot.preferences, targets: [...new Set([...snapshot.preferences.targets, ...options.targets])] } : null } : snapshot;
1312
- let globalPlan = deriveJointDemand(snapshot);
1313
- let plan = requestedDemand === snapshot ? globalPlan : deriveJointDemand(requestedDemand);
1314
- const matchesPlugin = (id) => !options.plugins?.length || options.plugins.some((selector) => selector === id || !selector.includes('/') && parsePluginId(id).pluginName === selector);
1315
- const selected = Boolean(options.plugins?.length || options.targets);
1316
- const observationPlugins = options.plugins?.length ? new Set(plan.placements.filter((item) => matchesPlugin(item.pluginId)
1317
- || item.contributions.some((contribution) => matchesPlugin(contribution.root))).map((item) => item.pluginId)) : undefined;
1318
- if (observationPlugins) {
1320
+ function expandStatusPluginSelection(snapshot, plan, selectors) {
1321
+ const matches = (id) => selectors.some((selector) => selector === id
1322
+ || !selector.includes('/') && parsePluginId(id).pluginName === selector);
1323
+ const pluginsForObservation = new Set(plan.placements.filter((item) => matches(item.pluginId)
1324
+ || item.contributions.some((contribution) => matches(contribution.root))).map((item) => item.pluginId));
1325
+ {
1319
1326
  const plugins = [...new Map([snapshot.user, ...(snapshot.project ? [snapshot.project] : [])]
1320
1327
  .flatMap((demand) => demand.plugins).map((plugin) => [plugin.pluginId, plugin])).values()];
1321
- for (const id of observationPlugins) {
1328
+ for (const id of pluginsForObservation) {
1322
1329
  const plugin = plugins.find((entry) => entry.pluginId === id);
1323
1330
  if (!plugin)
1324
1331
  continue;
1325
1332
  for (const dependency of plugin.manifest.dependencies ?? [])
1326
- observationPlugins.add(`${plugin.sourceId}/${dependency}`);
1333
+ pluginsForObservation.add(`${plugin.sourceId}/${dependency}`);
1327
1334
  const slots = new Set(plugin.manifest.extensions?.agents?.map((agent) => agent.name) ?? []);
1328
1335
  for (const candidate of plugins)
1329
1336
  if (candidate.manifest.extensions?.agents?.some((agent) => slots.has(agent.name))) {
1330
- observationPlugins.add(candidate.pluginId);
1337
+ pluginsForObservation.add(candidate.pluginId);
1331
1338
  }
1332
1339
  }
1333
1340
  }
1334
- if (observationPlugins)
1335
- for (const plugin of options.plugins ?? [])
1336
- observationPlugins.add(plugin);
1341
+ for (const selector of selectors)
1342
+ pluginsForObservation.add(selector);
1343
+ return pluginsForObservation;
1344
+ }
1345
+ async function readRecoveryStatusInSession(options, snapshot) {
1346
+ const selectionErrors = await checkUndeclaredSelection(options, snapshot);
1347
+ const requestedDemand = options.targets ? { ...snapshot, preferences: snapshot.preferences
1348
+ ? { ...snapshot.preferences, targets: [...new Set([...snapshot.preferences.targets, ...options.targets])] } : null } : snapshot;
1349
+ let globalPlan = deriveJointDemand(snapshot);
1350
+ let plan = requestedDemand === snapshot ? globalPlan : deriveJointDemand(requestedDemand);
1351
+ const matchesPlugin = (id) => !options.plugins?.length || options.plugins.some((selector) => selector === id || !selector.includes('/') && parsePluginId(id).pluginName === selector);
1352
+ const selected = Boolean(options.plugins?.length || options.targets);
1353
+ const observationPlugins = options.plugins?.length ? expandStatusPluginSelection(snapshot, plan, options.plugins) : undefined;
1337
1354
  const selectedPlacement = (item) => (!options.targets || options.targets.includes(item.target)) && (!observationPlugins || observationPlugins.has(item.pluginId));
1338
1355
  const candidates = [...new Map([...projectSkillCandidates(plan), ...(options.projectSkillProbes ?? [])]
1339
1356
  .filter(selectedPlacement).map((item) => [`${item.pluginId}\0${item.target}`, item])).values()];
1340
1357
  const scopes = [snapshot.user, ...(snapshot.project ? [snapshot.project] : [])];
1341
- const observed = [];
1342
- // Scope order gives User discovery the neutral cwd before equivalent Project
1343
- // probes reuse it. Codex also shares a mutable manager and neutral inventory.
1344
- for (const demand of scopes) {
1358
+ // Both scopes use one neutral discovery context; the Project binding keeps
1359
+ // its own exact inspection context. Merge in original scope order.
1360
+ const statusUserDispatch = scopes.length > 1 ? new Map(NATIVE_PLATFORM_TARGETS
1361
+ .map((platform) => [platform, createStatusDispatchGate()])) : undefined;
1362
+ // A project-scoped inventory already covers both user and project scopes.
1363
+ // Share one filesystem walk across both scopes in the same joint status read.
1364
+ let sharedInventoryPromise;
1365
+ if (scopes.length > 1 && !options.nativeObservations) {
1366
+ const knownPluginNames = [...new Set([
1367
+ ...scopes.flatMap((demand) => demand.plugins.map((plugin) => plugin.manifest.name)),
1368
+ ...plan.placements.map((item) => item.plugin.manifest.name),
1369
+ ...(options.projectSkillProbes ?? []).map((item) => item.plugin.manifest.name),
1370
+ ])];
1371
+ sharedInventoryPromise = measureRecoveryPerformanceStage(options, 'status.inventory', () => inventoryCatalogSourceReferences({
1372
+ cwd: snapshot.context.projectRoot ?? options.cwd,
1373
+ env: options.env ?? process.env,
1374
+ scope: 'project',
1375
+ knownPluginNames,
1376
+ collectPathEvidence: false,
1377
+ observationPlugins,
1378
+ }));
1379
+ sharedInventoryPromise.catch(() => undefined);
1380
+ }
1381
+ const observed = await mapInstallReads(scopes, async (demand) => {
1345
1382
  const nodes = [...plan.placements, ...(options.projectSkillProbes ?? [])].filter((item) => selectedPlacement(item) && (item.scope === demand.scope
1346
1383
  || demand.scope === 'project' && ['codex', 'claude', 'copilot'].includes(item.target)
1347
1384
  && item.contributions.some((contribution) => contribution.scope === 'project')));
@@ -1359,9 +1396,27 @@ async function readRecoveryStatusInSession(options, snapshot) {
1359
1396
  pluginId: item.pluginId, sourceId: item.plugin.sourceId, sourceState: 'ready',
1360
1397
  blockers: [], plugin: item.plugin,
1361
1398
  }])).values()] };
1362
- observed.push(await readScopedRecoveryStatus({ ...options, onNativeStatus: undefined, scope: demand.scope,
1363
- cwd: snapshot.context.projectRoot ?? options.cwd, observationPlugins, targets: options.targets, demandOverride: expanded }));
1364
- }
1399
+ try {
1400
+ const shared = sharedInventoryPromise ? await sharedInventoryPromise : undefined;
1401
+ const ownerInventoryOverride = shared
1402
+ ? demand.scope === 'user'
1403
+ ? {
1404
+ inventorySchemaVersion: shared.inventorySchemaVersion,
1405
+ references: shared.references.filter((reference) => reference.scope !== 'project'),
1406
+ errors: shared.errors.filter((error) => !('scope' in error.relevance) || error.relevance.scope !== 'project'),
1407
+ }
1408
+ : shared
1409
+ : undefined;
1410
+ return await readScopedRecoveryStatus({ ...options, onNativeStatus: undefined, scope: demand.scope, statusUserDispatch,
1411
+ cwd: snapshot.context.projectRoot ?? options.cwd, observationPlugins, targets: options.targets, demandOverride: expanded,
1412
+ ownerInventoryOverride });
1413
+ }
1414
+ finally {
1415
+ if (demand.scope === 'user')
1416
+ for (const dispatch of statusUserDispatch?.values() ?? [])
1417
+ dispatch.resolve();
1418
+ }
1419
+ }, { signal: options.signal });
1365
1420
  const scopedTargets = observed.flatMap((status) => status.inventory?.flatMap((item) => item.targetResults) ?? []);
1366
1421
  const skillProviders = candidates.flatMap((candidate) => {
1367
1422
  const matches = (target) => target.pluginId === candidate.pluginId && target.agent === candidate.target;