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

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 (250) hide show
  1. package/dist/authoring/assets/aw-runtime-config.mjs +1 -1
  2. package/dist/authoring/assets/aw-runtime-config.mjs.map +1 -1
  3. package/dist/index.js +2 -6
  4. package/dist/index.js.map +1 -1
  5. package/dist/src/commands/console.js +1 -0
  6. package/dist/src/commands/console.js.map +1 -1
  7. package/dist/src/commands/intent-command.d.ts +1 -0
  8. package/dist/src/commands/intent-command.js +6 -2
  9. package/dist/src/commands/intent-command.js.map +1 -1
  10. package/dist/src/commands/plugin-capabilities.js +3 -3
  11. package/dist/src/commands/plugin-capabilities.js.map +1 -1
  12. package/dist/src/commands/public-lifecycle-result.d.ts +14 -13
  13. package/dist/src/commands/public-lifecycle-result.js +204 -64
  14. package/dist/src/commands/public-lifecycle-result.js.map +1 -1
  15. package/dist/src/commands/public-lifecycle.d.ts +1 -2
  16. package/dist/src/commands/public-lifecycle.js +56 -34
  17. package/dist/src/commands/public-lifecycle.js.map +1 -1
  18. package/dist/src/commands/public-plugin-query.js +44 -11
  19. package/dist/src/commands/public-plugin-query.js.map +1 -1
  20. package/dist/src/commands/rebuild-command.d.ts +13 -3
  21. package/dist/src/commands/rebuild-command.js +665 -288
  22. package/dist/src/commands/rebuild-command.js.map +1 -1
  23. package/dist/src/commands/rebuild-integration.d.ts +6 -2
  24. package/dist/src/commands/rebuild-integration.js +60 -29
  25. package/dist/src/commands/rebuild-integration.js.map +1 -1
  26. package/dist/src/commands/rebuild-operations.d.ts +1 -0
  27. package/dist/src/commands/rebuild-operations.js +28 -6
  28. package/dist/src/commands/rebuild-operations.js.map +1 -1
  29. package/dist/src/commands/rebuild-platform-integration.d.ts +20 -5
  30. package/dist/src/commands/rebuild-platform-integration.js +752 -182
  31. package/dist/src/commands/rebuild-platform-integration.js.map +1 -1
  32. package/dist/src/generators/permissions.d.ts +7 -1
  33. package/dist/src/generators/permissions.js +56 -0
  34. package/dist/src/generators/permissions.js.map +1 -1
  35. package/dist/src/index.d.ts +1 -0
  36. package/dist/src/index.js +112 -54
  37. package/dist/src/index.js.map +1 -1
  38. package/dist/src/intent/scope-context.d.ts +4 -2
  39. package/dist/src/intent/scope-context.js +37 -7
  40. package/dist/src/intent/scope-context.js.map +1 -1
  41. package/dist/src/output/component-delivery.d.ts +21 -0
  42. package/dist/src/output/component-delivery.js +82 -0
  43. package/dist/src/output/component-delivery.js.map +1 -0
  44. package/dist/src/output/public-result.d.ts +4 -0
  45. package/dist/src/output/public-result.js +85 -15
  46. package/dist/src/output/public-result.js.map +1 -1
  47. package/dist/src/output/rebuild-progress.d.ts +3 -0
  48. package/dist/src/output/rebuild-progress.js +12 -2
  49. package/dist/src/output/rebuild-progress.js.map +1 -1
  50. package/dist/src/output/receipt-projection.js +64 -19
  51. package/dist/src/output/receipt-projection.js.map +1 -1
  52. package/dist/src/output/skill-invocation-notices.d.ts +18 -0
  53. package/dist/src/output/skill-invocation-notices.js +84 -0
  54. package/dist/src/output/skill-invocation-notices.js.map +1 -0
  55. package/dist/src/platforms/capabilities.d.ts +6 -1
  56. package/dist/src/platforms/capabilities.js +161 -38
  57. package/dist/src/platforms/capabilities.js.map +1 -1
  58. package/dist/src/platforms/contracts.d.ts +45 -10
  59. package/dist/src/platforms/discovery.d.ts +11 -7
  60. package/dist/src/platforms/discovery.js +176 -76
  61. package/dist/src/platforms/discovery.js.map +1 -1
  62. package/dist/src/platforms/inspection-grok.js +121 -9
  63. package/dist/src/platforms/inspection-grok.js.map +1 -1
  64. package/dist/src/platforms/inspection-native.js +53 -97
  65. package/dist/src/platforms/inspection-native.js.map +1 -1
  66. package/dist/src/platforms/inspection-pi.d.ts +7 -1
  67. package/dist/src/platforms/inspection-pi.js +295 -95
  68. package/dist/src/platforms/inspection-pi.js.map +1 -1
  69. package/dist/src/platforms/inspection-query.d.ts +6 -5
  70. package/dist/src/platforms/inspection-query.js +30 -25
  71. package/dist/src/platforms/inspection-query.js.map +1 -1
  72. package/dist/src/platforms/inspection.d.ts +4 -1
  73. package/dist/src/platforms/inspection.js +38 -6
  74. package/dist/src/platforms/inspection.js.map +1 -1
  75. package/dist/src/platforms/layout.d.ts +6 -0
  76. package/dist/src/platforms/layout.js +45 -12
  77. package/dist/src/platforms/layout.js.map +1 -1
  78. package/dist/src/platforms/lifecycle-native-services.d.ts +1 -1
  79. package/dist/src/platforms/lifecycle-native-services.js +14 -14
  80. package/dist/src/platforms/lifecycle-native-services.js.map +1 -1
  81. package/dist/src/platforms/lifecycle-native.d.ts +1 -0
  82. package/dist/src/platforms/lifecycle-native.js +29 -89
  83. package/dist/src/platforms/lifecycle-native.js.map +1 -1
  84. package/dist/src/platforms/lifecycle.d.ts +2 -0
  85. package/dist/src/platforms/lifecycle.js +120 -69
  86. package/dist/src/platforms/lifecycle.js.map +1 -1
  87. package/dist/src/platforms/projection-code-extension.js +9 -4
  88. package/dist/src/platforms/projection-code-extension.js.map +1 -1
  89. package/dist/src/platforms/projection.d.ts +3 -0
  90. package/dist/src/platforms/projection.js +152 -72
  91. package/dist/src/platforms/projection.js.map +1 -1
  92. package/dist/src/platforms/supplement-layout.d.ts +5 -1
  93. package/dist/src/platforms/supplement-layout.js +23 -1
  94. package/dist/src/platforms/supplement-layout.js.map +1 -1
  95. package/dist/src/platforms/supplement-state.d.ts +1 -1
  96. package/dist/src/platforms/supplement-state.js +18 -7
  97. package/dist/src/platforms/supplement-state.js.map +1 -1
  98. package/dist/src/portable/commands.js +1 -1
  99. package/dist/src/portable/commands.js.map +1 -1
  100. package/dist/src/portable/materializer.d.ts +4 -0
  101. package/dist/src/portable/materializer.js +9 -2
  102. package/dist/src/portable/materializer.js.map +1 -1
  103. package/dist/src/portable/recovery.d.ts +31 -3
  104. package/dist/src/portable/recovery.js +261 -82
  105. package/dist/src/portable/recovery.js.map +1 -1
  106. package/dist/src/recovery/coordinator.d.ts +19 -5
  107. package/dist/src/recovery/coordinator.js +433 -174
  108. package/dist/src/recovery/coordinator.js.map +1 -1
  109. package/dist/src/recovery/install-concurrency.d.ts +48 -0
  110. package/dist/src/recovery/install-concurrency.js +196 -0
  111. package/dist/src/recovery/install-concurrency.js.map +1 -0
  112. package/dist/src/recovery/interruption.d.ts +19 -0
  113. package/dist/src/recovery/interruption.js +43 -0
  114. package/dist/src/recovery/interruption.js.map +1 -0
  115. package/dist/src/recovery/joint-coordinator.d.ts +18 -4
  116. package/dist/src/recovery/joint-coordinator.js +829 -341
  117. package/dist/src/recovery/joint-coordinator.js.map +1 -1
  118. package/dist/src/recovery/joint-demand.d.ts +22 -2
  119. package/dist/src/recovery/joint-demand.js +104 -6
  120. package/dist/src/recovery/joint-demand.js.map +1 -1
  121. package/dist/src/recovery/joint-install-execution.d.ts +19 -0
  122. package/dist/src/recovery/joint-install-execution.js +307 -0
  123. package/dist/src/recovery/joint-install-execution.js.map +1 -0
  124. package/dist/src/recovery/joint-install-native-rebase.d.ts +4 -0
  125. package/dist/src/recovery/joint-install-native-rebase.js +67 -0
  126. package/dist/src/recovery/joint-install-native-rebase.js.map +1 -0
  127. package/dist/src/recovery/receipt.d.ts +35 -4
  128. package/dist/src/recovery/receipt.js +90 -1
  129. package/dist/src/recovery/receipt.js.map +1 -1
  130. package/dist/src/recovery/retirement.js +1 -1
  131. package/dist/src/recovery/retirement.js.map +1 -1
  132. package/dist/src/recovery/status.d.ts +20 -8
  133. package/dist/src/recovery/status.js +405 -116
  134. package/dist/src/recovery/status.js.map +1 -1
  135. package/dist/src/review/platform-profile.d.ts +4 -1
  136. package/dist/src/review/platform-profile.js +14 -4
  137. package/dist/src/review/platform-profile.js.map +1 -1
  138. package/dist/src/review/skill-materialization.d.ts +2 -0
  139. package/dist/src/review/skill-materialization.js +68 -50
  140. package/dist/src/review/skill-materialization.js.map +1 -1
  141. package/dist/src/review/source-binding.js +11 -5
  142. package/dist/src/review/source-binding.js.map +1 -1
  143. package/dist/src/tui/console-app-v4.d.ts +1 -1
  144. package/dist/src/tui/console-app-v4.js +180 -63
  145. package/dist/src/tui/console-app-v4.js.map +1 -1
  146. package/dist/src/tui/controller-runtime.js +46 -10
  147. package/dist/src/tui/controller-runtime.js.map +1 -1
  148. package/dist/src/tui/controller.d.ts +15 -5
  149. package/dist/src/tui/controller.js +246 -102
  150. package/dist/src/tui/controller.js.map +1 -1
  151. package/dist/src/tui/deployment-view.d.ts +6 -3
  152. package/dist/src/tui/deployment-view.js +43 -9
  153. package/dist/src/tui/deployment-view.js.map +1 -1
  154. package/dist/src/tui/diagnostic-projection.d.ts +11 -3
  155. package/dist/src/tui/diagnostic-projection.js +85 -4
  156. package/dist/src/tui/diagnostic-projection.js.map +1 -1
  157. package/dist/src/tui/entity-cards.d.ts +2 -1
  158. package/dist/src/tui/entity-cards.js +34 -11
  159. package/dist/src/tui/entity-cards.js.map +1 -1
  160. package/dist/src/tui/glossary.js +5 -0
  161. package/dist/src/tui/glossary.js.map +1 -1
  162. package/dist/src/tui/model.js +2 -1
  163. package/dist/src/tui/model.js.map +1 -1
  164. package/dist/src/tui/operation-diagnostic-screens.d.ts +1 -1
  165. package/dist/src/tui/operation-diagnostic-screens.js +6 -2
  166. package/dist/src/tui/operation-diagnostic-screens.js.map +1 -1
  167. package/dist/src/tui/operation-history.d.ts +12 -3
  168. package/dist/src/tui/operation-history.js +34 -3
  169. package/dist/src/tui/operation-history.js.map +1 -1
  170. package/dist/src/tui/plugin-detail.d.ts +4 -1
  171. package/dist/src/tui/plugin-detail.js +9 -2
  172. package/dist/src/tui/plugin-detail.js.map +1 -1
  173. package/dist/src/tui/scoped-flow.d.ts +3 -1
  174. package/dist/src/tui/scoped-flow.js +117 -1
  175. package/dist/src/tui/scoped-flow.js.map +1 -1
  176. package/dist/src/tui/scoped-inventory.d.ts +6 -2
  177. package/dist/src/tui/scoped-inventory.js +29 -7
  178. package/dist/src/tui/scoped-inventory.js.map +1 -1
  179. package/dist/src/tui/session-console-app.d.ts +2 -0
  180. package/dist/src/tui/session-console-app.js +11 -0
  181. package/dist/src/tui/session-console-app.js.map +1 -1
  182. package/dist/src/types.d.ts +10 -2
  183. package/dist/src/types.js.map +1 -1
  184. package/dist/src/utils/artifact-plan.js +5 -1
  185. package/dist/src/utils/artifact-plan.js.map +1 -1
  186. package/dist/src/utils/artifact-renderer.d.ts +1 -1
  187. package/dist/src/utils/artifact-renderer.js +29 -8
  188. package/dist/src/utils/artifact-renderer.js.map +1 -1
  189. package/dist/src/utils/aw-home-mutation-lock.js +2 -1
  190. package/dist/src/utils/aw-home-mutation-lock.js.map +1 -1
  191. package/dist/src/utils/catalog-source-references.js +14 -17
  192. package/dist/src/utils/catalog-source-references.js.map +1 -1
  193. package/dist/src/utils/codex-native-observation.d.ts +6 -0
  194. package/dist/src/utils/codex-native-observation.js +32 -3
  195. package/dist/src/utils/codex-native-observation.js.map +1 -1
  196. package/dist/src/utils/component-command-preparation.d.ts +2 -0
  197. package/dist/src/utils/component-command-preparation.js +23 -4
  198. package/dist/src/utils/component-command-preparation.js.map +1 -1
  199. package/dist/src/utils/component-gap.d.ts +4 -0
  200. package/dist/src/utils/component-gap.js +20 -0
  201. package/dist/src/utils/component-gap.js.map +1 -0
  202. package/dist/src/utils/component-resources.js +2 -4
  203. package/dist/src/utils/component-resources.js.map +1 -1
  204. package/dist/src/utils/dynamic-skill-tree.js +2 -32
  205. package/dist/src/utils/dynamic-skill-tree.js.map +1 -1
  206. package/dist/src/utils/managed-command-materialization.d.ts +2 -1
  207. package/dist/src/utils/managed-command-materialization.js +3 -3
  208. package/dist/src/utils/managed-command-materialization.js.map +1 -1
  209. package/dist/src/utils/managed-command-store.d.ts +6 -0
  210. package/dist/src/utils/managed-command-store.js +90 -18
  211. package/dist/src/utils/managed-command-store.js.map +1 -1
  212. package/dist/src/utils/multi-source-catalog.d.ts +2 -0
  213. package/dist/src/utils/multi-source-catalog.js +3 -2
  214. package/dist/src/utils/multi-source-catalog.js.map +1 -1
  215. package/dist/src/utils/native-cli-interruption.d.ts +8 -0
  216. package/dist/src/utils/native-cli-interruption.js +65 -0
  217. package/dist/src/utils/native-cli-interruption.js.map +1 -0
  218. package/dist/src/utils/native-cli.d.ts +5 -19
  219. package/dist/src/utils/native-cli.js +168 -95
  220. package/dist/src/utils/native-cli.js.map +1 -1
  221. package/dist/src/utils/ownership.d.ts +1 -0
  222. package/dist/src/utils/ownership.js +18 -4
  223. package/dist/src/utils/ownership.js.map +1 -1
  224. package/dist/src/utils/package-content.d.ts +7 -0
  225. package/dist/src/utils/package-content.js +70 -0
  226. package/dist/src/utils/package-content.js.map +1 -0
  227. package/dist/src/utils/platform-empty-state.d.ts +32 -9
  228. package/dist/src/utils/platform-empty-state.js +135 -70
  229. package/dist/src/utils/platform-empty-state.js.map +1 -1
  230. package/dist/src/utils/plugin-config-write.d.ts +8 -0
  231. package/dist/src/utils/plugin-config-write.js +93 -25
  232. package/dist/src/utils/plugin-config-write.js.map +1 -1
  233. package/dist/src/utils/plugin-scripts.js +24 -8
  234. package/dist/src/utils/plugin-scripts.js.map +1 -1
  235. package/dist/src/utils/process-tree.d.ts +1 -1
  236. package/dist/src/utils/process-tree.js +1 -1
  237. package/dist/src/utils/process-tree.js.map +1 -1
  238. package/dist/src/utils/skill-invocation-warning.d.ts +20 -0
  239. package/dist/src/utils/skill-invocation-warning.js +68 -0
  240. package/dist/src/utils/skill-invocation-warning.js.map +1 -0
  241. package/package.json +3 -3
  242. package/dist/src/output/native-consent.d.ts +0 -2
  243. package/dist/src/output/native-consent.js +0 -5
  244. package/dist/src/output/native-consent.js.map +0 -1
  245. package/dist/src/platforms/gemini-activation.d.ts +0 -36
  246. package/dist/src/platforms/gemini-activation.js +0 -331
  247. package/dist/src/platforms/gemini-activation.js.map +0 -1
  248. package/dist/src/platforms/gemini-consent.d.ts +0 -8
  249. package/dist/src/platforms/gemini-consent.js +0 -81
  250. package/dist/src/platforms/gemini-consent.js.map +0 -1
@@ -5,31 +5,37 @@ import { createScopeContext } from '../intent/scope-context.js';
5
5
  import { resolveIntentPath } from '../intent/intent-store.js';
6
6
  import { parsePluginId } from '../utils/multi-source-catalog.js';
7
7
  import { inspectPortableExtraInstalled, inspectPortableRecovery, portablePreparationDiagnostic } from '../portable/recovery.js';
8
- import { readJointDemand, deriveJointDemand } from './joint-demand.js';
8
+ import { readJointDemand, deriveJointDemand, projectSkillCandidates, isInstalledSkillProvider, hasReadyProviderSkills } from './joint-demand.js';
9
9
  import { readDemand, resolveDelivery } from './demand.js';
10
- import { runNativeCli } from '../utils/native-cli.js';
10
+ import { retainedOutputDiagnostic, scopeNativeComponentGaps, uniqueRecoveryComponentGaps } from './receipt.js';
11
11
  import { rethrowFatalError } from '../utils/codex-executable-discovery.js';
12
12
  import { createCodexNativeObservationSession } from '../utils/codex-native-observation.js';
13
13
  import { getAgentPluginAdapter } from '../platforms/registry.js';
14
14
  import { getQualifiedPlatformProfile } from '../platforms/capabilities.js';
15
+ import { isDeliveryCapabilityGap } from '../utils/component-gap.js';
16
+ import { piAgentConsumerDiagnostic, piProjectListsUserSkills } from '../platforms/inspection-pi.js';
17
+ import { gapSupplementFiles } from '../platforms/supplement-layout.js';
15
18
  import { inspectPlatformSupplementState } from '../platforms/supplement-state.js';
16
19
  import { resolveArtifactRenderConfig } from '../utils/artifact-renderer.js';
17
- import { createPlatformInputEvidence, matchesPlatformEmptyState, platformPackageInputDigest, readPlatformPackageContentDigest } from '../utils/platform-empty-state.js';
20
+ import { createPlatformInputEvidence, matchesPlatformEmptyState, readPlatformDeliveryState, platformPackageInputDigest, readPlatformPackageContentDigest } from '../utils/platform-empty-state.js';
21
+ import { deliveryNoticeMessage, INVOCATION_POLICY_NOT_APPLIED } from '../output/component-delivery.js';
22
+ import { piProjectEmptyDeliveryObserved } from '../platforms/lifecycle-native.js';
18
23
  import { getDeploymentLayout, hasSharedUserPackage } from '../platforms/layout.js';
24
+ import { identityDigest } from '../platforms/identity.js';
19
25
  import { deploymentPackageComponent, inspectStaticSupplements, requiredDeploymentActivation } from '../platforms/inspection.js';
20
26
  import { resolveStaticPlatformResourceRoot } from '../utils/component-resources.js';
21
- import { readSkillOwnerMarker } from '../utils/ownership.js';
27
+ import { inspectOwnedComponents, readSkillOwnerMarker } from '../utils/ownership.js';
22
28
  import { inventoryCatalogSourceReferences } from '../utils/catalog-source-references.js';
23
29
  import { resolvePartialCatalogOperationContext } from '../utils/catalog-operation-context.js';
24
30
  import { checkAwCapabilitySupport, readPluginManifest } from '../utils/manifest.js';
25
31
  import { IMPLEMENTED_AW_CAPABILITIES } from '../commands/aw-capabilities.js';
26
- import { resolvePluginMetaDependencyClosure } from '../utils/plugin-dependencies.js';
32
+ import { resolvePluginDependencyClosure, resolvePluginMetaDependencyClosure } from '../utils/plugin-dependencies.js';
27
33
  import { installationInvocation, selectNativeProduct } from '../platforms/discovery.js';
28
- import { DEFAULT_AGENT_VERSION_PROBE_TIMEOUT_MS } from '../constants.js';
29
34
  import { inventoryRecoveryDiagnostic } from '../utils/inventory-recovery-diagnostic.js';
30
35
  import { measureRecoveryPerformanceStage } from './performance.js';
31
36
  import { withNativeObservationBatch } from '../platforms/inspection-query.js';
32
37
  import { readCatalogSourcesConfigSnapshot } from '../utils/catalog-sources.js';
38
+ import { mapInstallReads } from './install-concurrency.js';
33
39
  const NATIVE_READ_ERRORS = new Set(['nativeStateUnreadable', 'stateInventoryFailed', 'configReadFailed',
34
40
  'configInvalid', 'componentInspectionFailed', 'targetInspectionFailed', 'codexNativeObservationFailed',
35
41
  'nativeObservationFailed', 'nativeObservationUnavailable']);
@@ -50,28 +56,29 @@ function withStatusNativeQueries(options, read) {
50
56
  discoveryCache: options.discoveryCache ?? batch.discoveryCache, nativeQuerySession: batch.nativeQuerySession,
51
57
  nativeCliRunner: batch.runner }));
52
58
  }
53
- async function readAdapterObservations(options, context, demand) {
54
- const observations = [];
55
- const existing = [];
56
- const owned = [];
59
+ async function readAdapterObservations(options, context, demand, inventory) {
57
60
  let selected;
58
61
  try {
59
62
  selected = selectAgents({ preferences: demand.preferences, targets: options.targets }).agents
60
63
  .filter((agent) => agent !== 'generic');
61
64
  }
62
65
  catch {
63
- return { observations, existing, owned };
66
+ return { observations: [], existing: [], owned: [] };
64
67
  }
65
- const ctx = { cwd: context.executionCwd, env: context.env, signal: options.signal, runner: options.nativeCliRunner,
66
- discoveryCache: options.discoveryCache, nativeQuerySession: options.nativeQuerySession,
67
- codexObservationSession: options.codexObservationSession, observeNative: options.observeNative };
68
- for (const platform of selected) {
68
+ const platforms = await mapInstallReads(selected, async (platform) => {
69
+ const observations = [];
70
+ const existing = [];
71
+ const owned = [];
72
+ const ctx = { cwd: context.executionCwd, env: context.env, signal: options.signal, runner: options.nativeCliRunner,
73
+ discoveryCache: options.discoveryCache, nativeQuerySession: options.nativeQuerySession,
74
+ codexObservationSession: platform === 'codex' ? options.codexObservationSession : undefined,
75
+ observeNative: options.observeNative };
69
76
  options.signal?.throwIfAborted();
70
77
  const roots = (demand.roots ?? []).filter((root) => root.plugin
71
78
  && resolveDelivery(root.plugin.manifest, platform, demand.scope)?.kind === 'native'
72
79
  && (!demand.targetRequirements || demand.targetRequirements.some((item) => item.pluginId === root.pluginId && item.target === platform)));
73
80
  if (!roots.length)
74
- continue;
81
+ return { observations, existing, owned };
75
82
  const adapter = getAgentPluginAdapter(platform);
76
83
  let ownedSession;
77
84
  try {
@@ -86,12 +93,7 @@ async function readAdapterObservations(options, context, demand) {
86
93
  ctx.codexObservationSession.setManager(manager);
87
94
  else {
88
95
  ownedSession = await createCodexNativeObservationSession({ exactCwd: context.executionCwd, env: context.env, manager,
89
- runner: async (request) => {
90
- const result = await runNativeCli({ ...request, signal: options.signal, timeoutMs: DEFAULT_AGENT_VERSION_PROBE_TIMEOUT_MS }, options.nativeCliRunner);
91
- if (Buffer.byteLength(result.stdout) + Buffer.byteLength(result.stderr) > 1024 * 1024)
92
- throw new Error('nativeObservationOutputLimit');
93
- return result;
94
- } });
96
+ runner: options.nativeCliRunner, probe: { platform: ctx.platform, signal: options.signal } });
95
97
  ctx.codexObservationSession = ownedSession;
96
98
  }
97
99
  }
@@ -99,6 +101,7 @@ async function readAdapterObservations(options, context, demand) {
99
101
  for (const root of roots) {
100
102
  options.signal?.throwIfAborted();
101
103
  const observation = { pluginId: root.pluginId, expectedVersion: root.plugin?.manifest.version, platform, content: 'unknown', blockers: [], reasons: [], deploymentObservations: [] };
104
+ let nativePackage;
102
105
  observations.push(observation);
103
106
  try {
104
107
  const plugin = root.plugin;
@@ -126,6 +129,7 @@ async function readAdapterObservations(options, context, demand) {
126
129
  const emptyMatches = [];
127
130
  const currentMatches = [];
128
131
  const versions = [];
132
+ const deliveredIds = new Set();
129
133
  const staticResourceRoot = await resolveStaticPlatformResourceRoot(plugin.rootDir, platform);
130
134
  for (const binding of resolution.bindings) {
131
135
  const subject = { pluginId: root.pluginId, target: platform, scope: binding.scope.kind };
@@ -135,36 +139,31 @@ async function readAdapterObservations(options, context, demand) {
135
139
  versions.push(live.packageVersion);
136
140
  options.signal?.throwIfAborted();
137
141
  observation.deploymentObservations.push({ bindingId: binding.id, products: binding.consumers, after: live });
138
- const shared = ['codex-marketplace', 'claude-marketplace', 'gemini-extension', 'copilot-marketplace'].includes(binding.route);
142
+ const shared = ['codex-marketplace', 'claude-marketplace', 'copilot-marketplace'].includes(binding.route);
139
143
  const scopedNativeConsumer = shared ? live.registration === 'present'
140
144
  && live.consumers.some((consumer) => consumer.activation === 'enabled')
141
145
  : live.package === 'present' && live.ownership === 'aw';
142
146
  if (scopedNativeConsumer && (live.ownership === 'aw' || live.ownership === 'shared')) {
143
147
  owned.push({ pluginId: root.pluginId, agent: platform, scope: demand.scope });
144
- existing.push({ pluginId: root.pluginId, agent: platform, scope: demand.scope });
148
+ if (!shared)
149
+ nativePackage ??= { sourceIdentity: binding.plugin.sourceIdentity, skillsReady: false };
150
+ existing.push({ pluginId: root.pluginId, agent: platform, scope: demand.scope,
151
+ ...(nativePackage ? { nativePackage } : {}) });
145
152
  }
146
153
  const unmet = [];
154
+ const staticPackageIds = new Set();
147
155
  const staticSupplements = [];
148
156
  const dynamicUnits = new Set();
149
157
  const inputUnits = [];
150
158
  const profile = getQualifiedPlatformProfile(platform);
151
- let expectedCount = 0;
152
- let packageExpectedCount = 0;
153
- for (const unit of resolution.renderUnits.filter((unit) => binding.renderUnitIds.includes(unit.id))) {
159
+ const renderUnits = resolution.renderUnits.filter((unit) => binding.renderUnitIds.includes(unit.id));
160
+ for (const unit of renderUnits) {
154
161
  const artifacts = plugin.manifest.artifacts;
155
162
  if (artifacts && unit.kinds.length && (!artifacts.scopes || artifacts.scopes.includes(unit.renderScope.kind))) {
156
163
  dynamicUnits.add(unit.output);
157
164
  }
158
165
  const capabilities = adapter.capabilities({ binding, renderUnit: unit, observation: live,
159
166
  profile });
160
- const expected = await normalizeStaticPluginComponents({ pluginRoot: plugin.rootDir, staticResourceRoot,
161
- manifest: plugin.manifest, platform, capabilities, allowedOutputKinds: unit.kinds });
162
- expectedCount += expected.components.length;
163
- if (unit.output === 'supplement')
164
- staticSupplements.push(...expected.components);
165
- else
166
- packageExpectedCount += expected.components.length;
167
- unmet.push(...expected.unmet);
168
167
  inputUnits.push({ renderUnit: unit, capabilities,
169
168
  config: await resolveArtifactRenderConfig({ pluginName: plugin.manifest.name, sourceId: binding.plugin.sourceId,
170
169
  sourceIdentity: binding.plugin.sourceIdentity, logicalIdentity: plugin.catalogLogicalIdentity,
@@ -172,17 +171,99 @@ async function readAdapterObservations(options, context, demand) {
172
171
  cwd: unit.renderScope.kind === 'project' ? unit.renderScope.projectRoot : context.executionCwd,
173
172
  env: context.env, referencePlugins: demand.plugins }) });
174
173
  }
175
- const supplements = await inspectStaticSupplements(ctx, binding, staticSupplements);
176
- const inputEvidence = await createPlatformInputEvidence({ plugin, binding, units: inputUnits });
174
+ const inputEvidence = await createPlatformInputEvidence({ plugin, binding, units: inputUnits }).catch((error) => {
175
+ rethrowFatalError(error);
176
+ options.signal?.throwIfAborted();
177
+ const systemCode = error?.code;
178
+ if (systemCode !== 'ENOENT' && systemCode !== 'ENOTDIR')
179
+ throw error;
180
+ observation.blockers.push({ code: 'componentResourceMissing', message: 'A required plugin source file or directory is missing.',
181
+ subject, detail: { reasonCode: systemCode } });
182
+ return undefined;
183
+ });
184
+ if (!inputEvidence) {
185
+ states.push('unknown');
186
+ continue;
187
+ }
188
+ const readPackageProjection = async () => {
189
+ const layout = await getDeploymentLayout(ctx, binding);
190
+ const marker = await readSkillOwnerMarker({ skillRoot: layout.packageRoot, allowedRoot: path.dirname(layout.packageRoot),
191
+ expectedIdentity: deploymentPackageComponent(binding, layout).identity });
192
+ return { layout, projection: marker?.nativeProjection };
193
+ };
194
+ const packageUnit = renderUnits.find((unit) => unit.output === 'package');
195
+ const rolePackage = (platform === 'copilot' || platform === 'grok') && packageUnit?.kinds.includes('agent')
196
+ && dynamicUnits.has('package') && plugin.manifest.extensions?.instructions?.length
197
+ && live.package === 'present' && live.ownership === 'aw' ? await readPackageProjection() : undefined;
198
+ // The current package projection identifies renderer-produced roles. File presence and bytes are checked below.
199
+ const roleProjection = rolePackage?.projection;
200
+ const projectedRole = rolePackage && roleProjection?.preparation === 'complete'
201
+ && roleProjection.inputDigest === platformPackageInputDigest(inputEvidence)
202
+ && identityDigest(roleProjection.physicalIdentity) === identityDigest(rolePackage.layout.physicalIdentity)
203
+ && roleProjection.components.some(({ nativeName, relativeOutputs }) => relativeOutputs.includes(platform === 'copilot'
204
+ ? `com.github.copilot/agents/${nativeName}.agent.md` : `agents/${nativeName}.md`));
205
+ let expectedCount = 0;
206
+ let grokAgentRecipientScope;
207
+ for (const { renderUnit: unit, capabilities } of inputUnits) {
208
+ const expected = await normalizeStaticPluginComponents({ pluginRoot: plugin.rootDir, staticResourceRoot,
209
+ manifest: plugin.manifest, platform, capabilities, allowedOutputKinds: unit.kinds,
210
+ hasInstructionAgentRecipients: platform === 'grok' && unit.output === 'supplement'
211
+ ? grokAgentRecipientScope === identityDigest(unit.renderScope) : projectedRole || undefined });
212
+ if (platform === 'grok' && unit.output === 'package'
213
+ && (projectedRole || expected.components.some(({ kind }) => kind === 'agent'))) {
214
+ grokAgentRecipientScope = identityDigest(unit.renderScope);
215
+ }
216
+ expectedCount += expected.components.length;
217
+ for (const component of expected.components) {
218
+ const grokRoleText = platform === 'grok' && component.kind === 'instruction' && !component.content.coverage.includes('main');
219
+ if (unit.output === 'supplement' && !grokRoleText)
220
+ staticSupplements.push(component);
221
+ else
222
+ staticPackageIds.add(component.id);
223
+ }
224
+ unmet.push(...expected.unmet);
225
+ }
226
+ const recordedDelivery = await readPlatformDeliveryState({ input: inputEvidence, env: context.env });
227
+ const recordedGaps = recordedDelivery?.result === 'capability-gaps' && recordedDelivery.gaps.length ? recordedDelivery : undefined;
228
+ for (const { field, ...detail } of recordedDelivery?.permissionNotices ?? []) {
229
+ observation.reasons.push({ code: INVOCATION_POLICY_NOT_APPLIED, subject: { ...subject, field }, detail,
230
+ message: deliveryNoticeMessage(INVOCATION_POLICY_NOT_APPLIED, detail, field) });
231
+ }
232
+ const currentIds = recordedGaps ? new Set(recordedGaps.installedComponentIds) : undefined;
233
+ if (currentIds && recordedGaps) {
234
+ // A renderer receipt can add dynamic expectations. A positive static
235
+ // expectation remains unless that specific component was skipped.
236
+ const skipped = new Set(recordedGaps.gaps.filter((gap) => !gap.componentId).map((gap) => gap.id));
237
+ for (const id of [...staticPackageIds, ...staticSupplements.map((component) => component.id)]) {
238
+ if (!skipped.has(id))
239
+ currentIds.add(id);
240
+ }
241
+ }
242
+ let packageExpectedCount = staticPackageIds.size;
243
+ const expectedSupplements = currentIds ? staticSupplements.filter(({ id }) => currentIds.has(id)) : staticSupplements;
244
+ const supplements = await inspectStaticSupplements(ctx, binding, expectedSupplements);
245
+ const gaps = recordedGaps?.gaps ?? unmet;
246
+ const blockingGaps = gaps.filter((gap) => !isDeliveryCapabilityGap(gap));
247
+ if (gaps.length) {
248
+ (observation.componentGaps ??= []).push(...scopeNativeComponentGaps(gaps, { pluginId: root.pluginId, agent: platform, scope: binding.scope.kind }, renderUnits));
249
+ }
177
250
  const supplementInput = inputEvidence.units.find((unit) => unit.output === 'supplement');
251
+ const emptyPackageIds = recordedDelivery?.result === 'intentional-empty-package' ? recordedDelivery.installedComponentIds : undefined;
178
252
  const recordedSupplements = dynamicUnits.has('supplement') && supplementInput
179
- ? await inspectPlatformSupplementState(ctx, binding, supplementInput.inputDigest) : null;
253
+ ? await inspectPlatformSupplementState(ctx, binding, supplementInput.inputDigest, emptyPackageIds) : null;
180
254
  if (recordedSupplements) {
181
255
  const staticIds = new Set(supplements.components.map((component) => component.id));
182
256
  const dynamicComponents = recordedSupplements.components.filter((component) => !staticIds.has(component.id));
183
257
  supplements.components.push(...dynamicComponents);
184
258
  expectedCount += dynamicComponents.length;
185
259
  }
260
+ const supplementIds = new Set(supplements.components.map(({ id }) => id));
261
+ if (currentIds) {
262
+ expectedCount = currentIds.size;
263
+ packageExpectedCount = [...currentIds].filter((id) => !supplementIds.has(id)).length;
264
+ }
265
+ const supplementSetUnconfirmed = emptyPackageIds
266
+ && (emptyPackageIds.length !== supplementIds.size || emptyPackageIds.some((id) => !supplementIds.has(id)));
186
267
  const supplementConflict = supplements.components.some((component) => component.reasonCodes.includes('supplementOwnershipConflict'));
187
268
  const supplementMissing = supplements.components.some((component) => component.presence === 'absent');
188
269
  const supplementDrift = supplements.components.some((component) => component.reasonCodes.includes('componentContentDrift'));
@@ -203,17 +284,20 @@ async function readAdapterObservations(options, context, demand) {
203
284
  owned.push({ pluginId: root.pluginId, agent: platform, scope: demand.scope });
204
285
  existing.push({ pluginId: root.pluginId, agent: platform, scope: demand.scope });
205
286
  }
206
- const confirmedEmpty = Boolean(plugin.manifest.artifacts && expectedCount === 0 && unmet.length === 0
207
- && await matchesPlatformEmptyState({ state: { ...inputEvidence, kind: 'aw-platform-empty-state', result: 'intentional-empty' }, env: context.env }));
208
- const confirmedEmptyPackage = binding.route === 'codex-marketplace' && recordedSupplements !== null
209
- && dynamicUnits.has('package') && packageExpectedCount === 0
210
- && await matchesPlatformEmptyState({ state: { ...inputEvidence, kind: 'aw-platform-empty-state', result: 'intentional-empty',
211
- units: inputEvidence.units.filter((unit) => unit.output === 'package') }, env: context.env });
287
+ const onlyCapabilityGaps = expectedCount === 0 && gaps.length > 0 && !blockingGaps.length;
288
+ const capabilityEmpty = onlyCapabilityGaps && recordedGaps !== undefined;
289
+ const confirmedEmpty = capabilityEmpty || Boolean(plugin.manifest.artifacts && expectedCount === 0 && gaps.length === 0
290
+ && recordedDelivery?.result === 'intentional-empty');
291
+ const confirmedEmptyPackage = packageExpectedCount === 0 && (Boolean(currentIds?.size)
292
+ || dynamicUnits.has('package') && (recordedDelivery?.result === 'intentional-empty-package'
293
+ || binding.route === 'codex-marketplace' && recordedSupplements !== null
294
+ && await matchesPlatformEmptyState({ state: { ...inputEvidence, kind: 'aw-platform-empty-state', result: 'intentional-empty',
295
+ units: inputEvidence.units.filter((unit) => unit.output === 'package') }, env: context.env })));
212
296
  const dynamicSupplementsUnconfirmed = dynamicUnits.has('supplement') && !confirmedEmpty
213
297
  && !recordedSupplements?.inputMatches && !supplementInputDrift;
214
- if (dynamicSupplementsUnconfirmed)
298
+ if (dynamicSupplementsUnconfirmed || supplementSetUnconfirmed)
215
299
  warn('dynamicExpectationUnconfirmed');
216
- const hasPackageExpectation = packageExpectedCount > 0 || dynamicUnits.has('package') && !confirmedEmpty && !confirmedEmptyPackage;
300
+ const hasPackageExpectation = packageExpectedCount > 0 || !currentIds && dynamicUnits.has('package') && !confirmedEmpty && !confirmedEmptyPackage;
217
301
  const inheritsUserNative = demand.targetRequirements?.find((item) => item.pluginId === root.pluginId
218
302
  && item.target === platform)?.inheritsUserNative;
219
303
  const requiredActivation = requiredDeploymentActivation(binding, live, !inheritsUserNative);
@@ -225,9 +309,18 @@ async function readAdapterObservations(options, context, demand) {
225
309
  ? observation.blockers : observation.reasons;
226
310
  destination.push({ code: entry.code, message: entry.message, subject: { ...subject, ...entry.subject }, detail: entry.detail });
227
311
  }
312
+ const legacyAntigravityPackage = live.antigravityLegacyProjectPackage;
313
+ if (legacyAntigravityPackage?.state === 'owned')
314
+ observation.reasons.push({
315
+ code: 'antigravityProjectPackageMigrationPending',
316
+ message: 'Sync this plugin to finish moving it to the short Antigravity project path.',
317
+ subject,
318
+ detail: { reasonCode: 'antigravityProjectPackageMigrationPending', path: legacyAntigravityPackage.path },
319
+ });
228
320
  const requiresScopeRegistration = binding.route === 'claude-marketplace' && !inheritsUserNative;
229
321
  const registration = requiresScopeRegistration ? live.scopeRegistration ?? 'unknown' : live.registration;
230
- const ownershipConflict = live.ownership === 'foreign' || live.ownership === 'shared';
322
+ const ownershipConflict = live.ownership === 'foreign' || live.ownership === 'shared'
323
+ || legacyAntigravityPackage?.state === 'unconfirmed';
231
324
  if (ownershipConflict)
232
325
  block('deploymentOwnershipConflict');
233
326
  const missing = hasPackageExpectation && (live.package === 'absent' && packageExpectedCount > 0
@@ -249,12 +342,9 @@ async function readAdapterObservations(options, context, demand) {
249
342
  let nativeContentDrift = false;
250
343
  let nativeContentUnconfirmed = false;
251
344
  if (hasPackageExpectation && live.package === 'present' && live.ownership === 'aw' && !missing) {
252
- const layout = await getDeploymentLayout(ctx, binding);
253
- const marker = await readSkillOwnerMarker({ skillRoot: layout.packageRoot, allowedRoot: path.dirname(layout.packageRoot),
254
- expectedIdentity: deploymentPackageComponent(binding, layout).identity });
255
- const projection = marker?.nativeProjection;
345
+ const { layout, projection } = rolePackage ?? await readPackageProjection();
256
346
  const contentDigest = projection ? await readPlatformPackageContentDigest(layout.packageRoot) : undefined;
257
- if (['grok-cli', 'gemini-extension', 'antigravity-cli'].includes(binding.route) && live.registration === 'present') {
347
+ if (['grok-cli', 'antigravity-cli'].includes(binding.route) && live.registration === 'present') {
258
348
  nativeContentUnconfirmed = !contentDigest || !live.nativePackageContentDigest;
259
349
  nativeContentDrift = Boolean(contentDigest && live.nativePackageContentDigest
260
350
  && contentDigest !== live.nativePackageContentDigest);
@@ -264,15 +354,18 @@ async function readAdapterObservations(options, context, demand) {
264
354
  warn('nativePackageContentDrift');
265
355
  }
266
356
  projectionUnconfirmed = !projection || projection.preparation !== 'complete' || !contentDigest;
267
- const packageInputDigest = platformPackageInputDigest(inputEvidence);
357
+ const packageInputDigest = platformPackageInputDigest(inputEvidence, projection?.components);
268
358
  inputDrift = Boolean(projection && (projection.inputDigest !== packageInputDigest
269
359
  || contentDigest && projection.contentDigest !== contentDigest));
270
360
  if (projectionUnconfirmed)
271
361
  warn(projection?.preparation === 'partial'
272
362
  ? 'platformPreparationPartial' : 'platformExpectationUnconfirmed');
273
- else if (inputDrift)
274
- warn(projection.inputDigest !== packageInputDigest
275
- ? 'platformInputDrift' : 'platformContentDrift');
363
+ else if (inputDrift) {
364
+ if (projection.inputDigest !== packageInputDigest)
365
+ warn('platformInputDrift');
366
+ if (projection.contentDigest !== contentDigest)
367
+ warn('platformContentDrift');
368
+ }
276
369
  componentMissing = live.components.some((component) => component.presence === 'absent');
277
370
  componentUnknown = live.components.some((component) => component.presence === 'unknown'
278
371
  && !component.reasonCodes.includes('nativePackageContentDrift'));
@@ -282,23 +375,82 @@ async function readAdapterObservations(options, context, demand) {
282
375
  warn('componentOutputUnconfirmed');
283
376
  packageExpectationConfirmed = Boolean(!projectionUnconfirmed && projection.inputDigest === packageInputDigest
284
377
  && projection.components.length > 0);
285
- if (packageExpectationConfirmed)
378
+ if (packageExpectationConfirmed) {
286
379
  expectedCount = Math.max(expectedCount, projection.components.length);
380
+ if (platform === 'pi' && !inputDrift) {
381
+ const roles = projection.components.filter((component) => component.relativeOutputs.some((output) => /^agents\/[^/]+\.md$/u.test(output))
382
+ && live.components.some((entry) => entry.id === component.id && entry.presence === 'present' && !entry.reasonCodes.length));
383
+ const warning = piAgentConsumerDiagnostic(binding, live, roles.map(({ id }) => id));
384
+ if (warning)
385
+ observation.reasons.push(warning);
386
+ }
387
+ }
388
+ }
389
+ const confirmedPackage = packageExpectationConfirmed && !inputDrift && !nativeContentDrift && !nativeContentUnconfirmed;
390
+ const confirmedComponents = [...(confirmedPackage ? live.components : []), ...supplements.components];
391
+ for (const component of confirmedComponents) {
392
+ if (component.presence === 'present' && !component.reasonCodes.length && (!currentIds || currentIds.has(component.id))) {
393
+ deliveredIds.add(component.id);
394
+ }
287
395
  }
288
396
  live.components.push(...supplements.components);
289
- currentMatches.push(!dynamicUnits.size || confirmedEmpty || packageExpectationConfirmed || missing
290
- || recordedSupplements !== null && !hasPackageExpectation);
291
- emptyMatches.push(confirmedEmpty);
292
- for (const entry of unmet)
397
+ currentMatches.push(Boolean(currentIds) || !dynamicUnits.size || confirmedEmpty || packageExpectationConfirmed || missing
398
+ || !dynamicSupplementsUnconfirmed && confirmedEmptyPackage || recordedSupplements !== null && !hasPackageExpectation);
399
+ emptyMatches.push(confirmedEmpty && !capabilityEmpty);
400
+ for (const entry of blockingGaps)
293
401
  block(entry.reasonCode);
402
+ if (legacyAntigravityPackage?.state === 'owned' && !ownershipConflict
403
+ && live.ownership !== 'unknown' && !blockingGaps.length) {
404
+ states.push('drifted');
405
+ continue;
406
+ }
294
407
  const inactiveScope = live.registration === 'absent'
295
408
  || live.package === 'absent' && live.registration === 'not-applicable'
296
409
  || live.scopeRegistration === 'absent'
297
410
  || binding.scope.kind === 'project' && shared && live.configuration?.activation === 'absent'
298
411
  || live.consumers.every((consumer) => ['disabled', 'not-applicable'].includes(consumer.activation));
412
+ const skippedFiles = gaps.filter((gap) => supplementInput?.kinds.includes(gap.kind) && gap.name
413
+ && !currentIds?.has(gap.componentId ?? gap.id)
414
+ && !expectedSupplements.some((component) => component.kind === gap.kind && component.name === gap.name));
415
+ if (skippedFiles.length) {
416
+ const slots = gapSupplementFiles(binding, await getDeploymentLayout(ctx, binding), skippedFiles);
417
+ const checked = await inspectOwnedComponents({ components: slots });
418
+ const retained = checked.components.filter((item) => item.state !== 'absent');
419
+ if (retained.length) {
420
+ for (const item of retained)
421
+ if ('path' in item.component) {
422
+ observation.blockers.push(retainedOutputDiagnostic(root.pluginId, platform, binding.scope.kind, item.component.path));
423
+ }
424
+ states.push(retained.some((item) => item.state === 'foreign') ? 'conflict'
425
+ : retained.some((item) => item.state === 'error') ? 'unknown' : 'drifted');
426
+ continue;
427
+ }
428
+ }
429
+ if (onlyCapabilityGaps) {
430
+ const supplementKey = supplementInput?.physicalKey;
431
+ const retained = supplementKey ? inventory.flatMap(({ ownedComponent }) => ownedComponent?.kind === 'owned-text-file' && ownedComponent.identity.physicalKey === supplementKey
432
+ && ownedComponent.identity.sourceIdentity === binding.plugin.sourceIdentity && ownedComponent.identity.pluginId === root.pluginId
433
+ ? [ownedComponent.path] : []) : [];
434
+ const piRegistrationRemaining = binding.route === 'pi-package'
435
+ && (live.registration === 'present' || live.configuration?.activation === 'enabled');
436
+ if ((live.package === 'present' && (!shared || !inactiveScope) || piRegistrationRemaining) && live.nativeIdentity) {
437
+ retained.push(live.nativeIdentity.sourceLocation);
438
+ }
439
+ if (binding.route === 'cursor-workspace-hook' && live.workspaceOpen === 'present') {
440
+ retained.push((await getDeploymentLayout(ctx, binding)).activationPath);
441
+ }
442
+ if (retained.length) {
443
+ observation.blockers.push(...retained.map((file) => retainedOutputDiagnostic(root.pluginId, platform, binding.scope.kind, file)));
444
+ states.push(ownershipConflict ? 'conflict' : 'drifted');
445
+ continue;
446
+ }
447
+ }
299
448
  if (confirmedEmpty) {
300
- states.push(ownershipConflict ? 'conflict' : live.package === 'unknown' || live.registration === 'unknown'
301
- || live.ownership === 'unknown' || observation.blockers.length || !inactiveScope ? 'unknown'
449
+ const hiddenEmptyPi = capabilityEmpty && piProjectEmptyDeliveryObserved(binding, live);
450
+ const cursorHookUnconfirmed = capabilityEmpty && binding.route === 'cursor-workspace-hook' && live.workspaceOpen !== 'absent';
451
+ const piConfigUnconfirmed = capabilityEmpty && binding.route === 'pi-package' && live.configuration?.activation !== 'absent';
452
+ states.push(ownershipConflict ? 'conflict' : live.package === 'unknown' || live.registration === 'unknown' && !hiddenEmptyPi
453
+ || live.ownership === 'unknown' || observation.blockers.length || cursorHookUnconfirmed || piConfigUnconfirmed || !inactiveScope && !hiddenEmptyPi ? 'unknown'
302
454
  : live.package === 'absent' || shared ? 'satisfied' : 'drifted');
303
455
  continue;
304
456
  }
@@ -323,11 +475,15 @@ async function readAdapterObservations(options, context, demand) {
323
475
  states.push('conflict');
324
476
  else if (confirmedEmptyPackage && (live.package === 'unknown' || live.registration === 'unknown' || live.ownership === 'unknown'))
325
477
  states.push('unknown');
326
- else if (confirmedEmptyPackage && !inactiveScope) {
478
+ else if (confirmedEmptyPackage && (!inactiveScope || !shared && live.package === 'present')) {
327
479
  warn('platformContentDrift');
328
480
  states.push('drifted');
329
481
  }
330
- else if (unmet.length || hasPackageExpectation && registration === 'unknown')
482
+ else if (onlyCapabilityGaps) {
483
+ warn('platformExpectationUnconfirmed');
484
+ states.push('unknown');
485
+ }
486
+ else if (blockingGaps.length || hasPackageExpectation && registration === 'unknown')
331
487
  states.push('unknown');
332
488
  else if (missing)
333
489
  states.push('absent');
@@ -340,7 +496,7 @@ async function readAdapterObservations(options, context, demand) {
340
496
  else if (hasPackageExpectation && ['disabled', 'blocked'].includes(requiredActivation)
341
497
  || live.workspaceOpen === 'absent' && live.package === 'present' || inputDrift || supplementDrift || supplementInputDrift || nativeContentDrift)
342
498
  states.push('drifted');
343
- else if (dynamicSupplementsUnconfirmed || hasPackageExpectation && !packageExpectationConfirmed)
499
+ else if (dynamicSupplementsUnconfirmed || supplementSetUnconfirmed || hasPackageExpectation && !packageExpectationConfirmed)
344
500
  states.push('unknown');
345
501
  else if (!expectedCount)
346
502
  states.push(live.package === 'absent' && ['absent', 'not-applicable'].includes(live.registration) ? 'satisfied' : 'drifted');
@@ -353,6 +509,11 @@ async function readAdapterObservations(options, context, demand) {
353
509
  observation.installedVersion = versions[0];
354
510
  observation.content = ['conflict', 'drifted', 'absent', 'unknown']
355
511
  .find((state) => states.includes(state)) ?? 'satisfied';
512
+ if (observation.content === 'satisfied' || observation.content === 'absent' || deliveredIds.size) {
513
+ observation.installedComponentIds = [...deliveredIds];
514
+ }
515
+ if (nativePackage)
516
+ nativePackage.skillsReady = hasReadyProviderSkills({ ...observation, installedComponentCount: deliveredIds.size });
356
517
  }
357
518
  catch (error) {
358
519
  rethrowFatalError(error);
@@ -369,17 +530,12 @@ async function readAdapterObservations(options, context, demand) {
369
530
  observations.push({ pluginId: root.pluginId, platform, content: 'unknown', blockers: [diagnostic('nativeObservationFailed')] });
370
531
  }
371
532
  finally {
372
- if (ownedSession) {
373
- try {
374
- await ownedSession.dispose();
375
- }
376
- finally {
377
- ctx.codexObservationSession = undefined;
378
- }
379
- }
533
+ await ownedSession?.dispose();
380
534
  }
381
- }
382
- return { observations, existing, owned };
535
+ return { observations, existing, owned };
536
+ }, { signal: options.signal });
537
+ return { observations: platforms.flatMap((result) => result.observations),
538
+ existing: platforms.flatMap((result) => result.existing), owned: platforms.flatMap((result) => result.owned) };
383
539
  }
384
540
  function safeNativePlacement(target) {
385
541
  const component = ({ kind, key, state, metadata }) => ({
@@ -456,6 +612,12 @@ export async function statusFromObservations(options) {
456
612
  && entry.platform === delivery.platform);
457
613
  if (native) {
458
614
  target.content = native.content;
615
+ if (native.componentGaps?.length)
616
+ target.componentGaps = native.componentGaps;
617
+ if (native.installedComponentIds) {
618
+ target.installedComponentIds = native.installedComponentIds;
619
+ target.installedComponentCount = native.installedComponentIds.length;
620
+ }
459
621
  if (native.installedVersion)
460
622
  target.installedVersion = native.installedVersion;
461
623
  if (native.deploymentObservations)
@@ -482,24 +644,38 @@ export async function statusFromObservations(options) {
482
644
  cliVersion: options.cliVersion ?? '0.0.0', catalogOperationContext: demand.catalogOperationContext,
483
645
  excludedPluginIds: demand.userProviders?.[agent] }, options.catalogReadScope);
484
646
  options.signal?.throwIfAborted();
485
- target.blockers.push(...portable.blockers.map((code) => portablePreparationDiagnostic(portable, diagnostic(code), agent)));
647
+ target.blockers.push(...portable.blockers.filter((code) => code !== 'previousDeploymentRetained').map((code) => portablePreparationDiagnostic(portable, diagnostic(code), agent)));
648
+ if (portable.policyNotices?.length)
649
+ target.reasons = [...target.reasons ?? [], ...portable.policyNotices];
486
650
  const gaps = (portable.unmet ?? []).filter((gap) => gap.agent === agent);
487
- if (gaps.length) {
651
+ const blockingGap = gaps.some((gap) => !isDeliveryCapabilityGap(gap));
652
+ if (gaps.length)
488
653
  target.componentGaps = gaps;
489
- if (!target.blockers.some((entry) => entry.code === 'portableComponentsUnmet'))
490
- target.blockers.push(diagnostic('portableComponentsUnmet'));
491
- }
654
+ if (blockingGap && !target.blockers.some((entry) => entry.code === 'portableComponentsUnmet'))
655
+ target.blockers.push(diagnostic('portableComponentsUnmet'));
492
656
  const observed = portable.targets.filter((entry) => entry.agent === agent);
493
- target.blockers.push(...observed.flatMap((entry) => entry.blocker ? [diagnostic(entry.blocker)] : []));
657
+ if (!portable.globalBlockers?.length) {
658
+ const installed = observed.filter((entry) => entry.providerPluginId === root.pluginId
659
+ && entry.disposition === 'write' && entry.observation === 'satisfied' && !entry.blocker);
660
+ if (installed.length || observed.every((entry) => entry.disposition === 'retain'
661
+ || entry.observation === 'satisfied' || entry.observation === 'absent')) {
662
+ target.installedComponentCount = installed.length;
663
+ if (installed.every((entry) => entry.componentId))
664
+ target.installedComponentIds = installed.map((entry) => entry.componentId);
665
+ }
666
+ }
667
+ target.blockers.push(...observed.flatMap((entry) => entry.disposition === 'retain'
668
+ ? [retainedOutputDiagnostic(entry.providerPluginId, agent, options.scope, entry.physicalPath, `skill.${entry.skill}`)]
669
+ : entry.blocker ? [diagnostic(entry.blocker)] : []));
494
670
  target.content = ['conflict', 'drifted', 'absent', 'unknown']
495
671
  .find((state) => observed.some((entry) => entry.observation === state))
496
- ?? (!portable.blockers.length && (observed.length || portable.intentionalEmpty && gaps.length === 0) ? 'satisfied' : 'unknown');
672
+ ?? (!portable.blockers.length && (observed.length || portable.intentionalEmpty || gaps.length && !blockingGap) ? 'satisfied' : 'unknown');
497
673
  if (observed.length === 0 && portable.blockers.includes('needs-preparation') && options.portableCoverage === true
498
674
  && options.portableInstalled && !options.portableInstalled.some((item) => item.pluginId === root.pluginId && item.agent === agent)) {
499
675
  target.content = 'absent';
500
676
  target.blockers = target.blockers.filter((item) => item.code !== 'needs-preparation');
501
677
  }
502
- if (gaps.length && target.content !== 'conflict')
678
+ if ((blockingGap || observed.some((entry) => entry.disposition === 'retain')) && target.content !== 'conflict')
503
679
  target.content = 'unknown';
504
680
  target.backend = observed.map((entry) => ({ skill: entry.skill, agent: entry.agent,
505
681
  ownership: entry.ownership, observation: entry.observation, associatedAgents: entry.associatedAgents }));
@@ -522,6 +698,10 @@ export async function statusFromObservations(options) {
522
698
  target.reasons = [...target.reasons ?? [], diagnostic('dynamicExpectationUnconfirmed')];
523
699
  }
524
700
  }
701
+ if (target.content === 'satisfied' && !target.blockers.length && target.installedComponentCount === 0
702
+ && target.componentGaps?.some((gap) => gap.providerPluginId === target.pluginId) && target.componentGaps.every(isDeliveryCapabilityGap)) {
703
+ target.satisfaction = 'not-applicable';
704
+ }
525
705
  target.observation = target.content === 'satisfied' ? 'verified'
526
706
  : target.content === 'absent' ? 'missing' : 'unknown';
527
707
  targetResults.push(target);
@@ -649,7 +829,7 @@ export async function readScopedRecoveryStatus(options) {
649
829
  targetRequirements: demand.targetRequirements ? [...demand.targetRequirements,
650
830
  ...candidates.map((entry) => ({ pluginId: `${entry.sourceId}/${entry.pluginName}`, target: entry.platform }))] : undefined };
651
831
  const adapters = options.nativeObservations ? { observations: [], existing: [], owned: [] }
652
- : await withStatusNativeQueries({ ...options, targets: [...new Set([...selectedAgents, ...candidates.map((entry) => entry.platform)])] }, (nativeOptions) => readAdapterObservations(nativeOptions, context, observationDemand));
832
+ : await withStatusNativeQueries({ ...options, targets: [...new Set([...selectedAgents, ...candidates.map((entry) => entry.platform)])] }, (nativeOptions) => readAdapterObservations(nativeOptions, context, observationDemand, candidates));
653
833
  const roots = new Set(demand.roots?.map((root) => root.pluginId) ?? []);
654
834
  const queue = [...(demand.roots ?? []).map((root) => root.plugin).filter((plugin) => plugin !== undefined)];
655
835
  const byId = new Map(demand.plugins.map((plugin) => [plugin.pluginId, plugin]));
@@ -682,7 +862,7 @@ export async function readScopedRecoveryStatus(options) {
682
862
  const nativeCopy = entry.platform === 'antigravity' && entry.scope === 'user'
683
863
  && entry.kind === 'namespacedMarketplace' && entry.recoveryCandidate?.evidence === 'verified'
684
864
  && entry.recoveryCandidate.binding.route === 'antigravity-cli';
685
- return nativeCopy || entry.ownedComponent && !['codex', 'claude', 'gemini', 'copilot'].includes(entry.platform)
865
+ return nativeCopy || entry.ownedComponent && !['codex', 'claude', 'copilot'].includes(entry.platform)
686
866
  ? [{ pluginId: `${entry.sourceId}/${entry.pluginName}`, agent: entry.platform, scope: options.scope }] : [];
687
867
  });
688
868
  for (const entry of inventoryOwned) {
@@ -690,19 +870,41 @@ export async function readScopedRecoveryStatus(options) {
690
870
  nativeExtraObserved.push({ ...entry, delivery: { kind: 'native', platform: entry.agent }, observation: 'unknown', content: 'unknown' });
691
871
  }
692
872
  }
873
+ const retainedProjectPackages = [];
693
874
  for (const entry of candidates) {
694
875
  const component = entry.ownedComponent;
695
- if (component?.kind !== 'owned-directory' || !['codex', 'claude', 'gemini', 'copilot'].includes(entry.platform)
696
- || component.identity.scope !== options.scope || entry.recoveryCandidate?.evidence !== 'verified'
876
+ const recovery = entry.recoveryCandidate;
877
+ if (component?.kind !== 'owned-directory' || recovery?.evidence !== 'verified' || component.identity.scope !== options.scope
697
878
  || component.identity.sourceId !== entry.sourceId || component.identity.sourceIdentity !== entry.sourceIdentity
698
879
  || component.identity.platform !== entry.platform || component.identity.pluginId !== `${entry.sourceId}/${entry.pluginName}`
699
- || component.identity.physicalKey !== entry.recoveryCandidate.binding.physicalKey)
880
+ || component.identity.physicalKey !== recovery.binding.physicalKey)
700
881
  continue;
701
882
  const pluginId = component.identity.pluginId;
883
+ const agent = entry.platform;
884
+ const sourceIdentity = recovery.binding.plugin.sourceIdentity;
885
+ if (!hasSharedUserPackage(agent)) {
886
+ const location = recovery.binding.scope;
887
+ if (location.kind !== 'project' || location.projectRoot !== context.projectRoot
888
+ || adapters.existing.some((target) => target.pluginId === pluginId && target.agent === agent
889
+ && target.nativePackage?.sourceIdentity === sourceIdentity))
890
+ continue;
891
+ const source = catalogSources.get(entry.sourceId)?.resolution;
892
+ let dependencies = null;
893
+ if (source?.sourceIdentity === sourceIdentity && source.manifest.entries.some((plugin) => plugin.name === entry.pluginName)) {
894
+ try {
895
+ dependencies = resolvePluginDependencyClosure(source.manifest.entries, [entry.pluginName])
896
+ .filter((plugin) => plugin.name !== entry.pluginName).map((plugin) => `${entry.sourceId}/${plugin.name}`);
897
+ }
898
+ catch { /* An unavailable closure retains only same-source candidates. */ }
899
+ }
900
+ retainedProjectPackages.push({ pluginId, agent, scope: 'project', dependencies,
901
+ nativePackage: { sourceIdentity, skillsReady: false } });
902
+ continue;
903
+ }
702
904
  if (observedPlugins.get(pluginId)?.sourceIdentity === component.identity.sourceIdentity)
703
905
  continue;
704
- nativeExtraObserved.push({ pluginId, agent: entry.platform, scope: component.identity.scope,
705
- delivery: { kind: 'native', platform: entry.platform }, observation: 'unknown', content: 'unknown',
906
+ nativeExtraObserved.push({ pluginId, agent, scope: component.identity.scope,
907
+ delivery: { kind: 'native', platform: agent }, observation: 'unknown', content: 'unknown',
706
908
  backend: { retainedPackage: true, ownedComponents: [{ ...component, state: 'present' }] } });
707
909
  }
708
910
  const portableExtra = options.targets && !options.targets.includes('generic') ? { targets: [], complete: true }
@@ -757,7 +959,7 @@ export async function readScopedRecoveryStatus(options) {
757
959
  if (!relevance.global && (relevance.platform && relevance.platform !== target.agent
758
960
  || relevance.sourceId && relevance.sourceId !== identity.sourceId
759
961
  || relevance.scope && relevance.scope !== target.scope
760
- && !(relevance.scope === 'user' && target.scope === 'project' && ['codex', 'claude', 'gemini', 'copilot'].includes(target.agent))
962
+ && !(relevance.scope === 'user' && target.scope === 'project' && ['codex', 'claude', 'copilot'].includes(target.agent))
761
963
  || relevance.projectLocationKey && relevance.projectLocationKey !== context.projectKey
762
964
  || relevance.pluginName && relevance.pluginName !== identity.pluginName
763
965
  && !(relevance.componentName && observedPlugins.get(target.pluginId)?.manifest.extensions?.agents?.some((agent) => agent.name === relevance.componentName))))
@@ -773,6 +975,7 @@ export async function readScopedRecoveryStatus(options) {
773
975
  ...adapters.existing,
774
976
  ...portableExtra.targets.map((target) => ({ pluginId: target.pluginId, agent: target.agent, scope: options.scope })),
775
977
  ];
978
+ result.retainedProjectPackages = retainedProjectPackages;
776
979
  result.ownedTargets = [
777
980
  ...adapters.owned, ...inventoryOwned,
778
981
  ...portableExtra.targets.map((target) => ({ pluginId: target.pluginId, agent: target.agent, scope: options.scope })),
@@ -824,6 +1027,15 @@ export async function checkRecovery(selectors, options) {
824
1027
  coverage: { scopes: status.coverage.scopes ?? [status.scope], ...(status.coverage.projectRoot ? { projectRoot: status.coverage.projectRoot } : {}) },
825
1028
  declarationChanged: false, preferencesChanged: false, configChanged: false, outputsMayHaveChanged: false };
826
1029
  }
1030
+ function observedSatisfaction(content, provider, inheritsUser) {
1031
+ if (!content || content === 'unknown')
1032
+ return 'unknown';
1033
+ if (content !== 'satisfied')
1034
+ return 'pending';
1035
+ if (provider?.satisfaction === 'not-applicable')
1036
+ return 'not-applicable';
1037
+ return inheritsUser ? 'inherited-user' : 'installed';
1038
+ }
827
1039
  export function aggregateConvergence(allSatisfied, residue) {
828
1040
  return allSatisfied === false || residue === 'present' ? false
829
1041
  : allSatisfied === null || residue === 'unknown' ? null : true;
@@ -834,7 +1046,7 @@ export async function readRecoveryStatus(options, preparedDemand) {
834
1046
  async function readRecoveryStatusWithQueries(options, preparedDemand) {
835
1047
  options = { ...options, discoveryCache: options.discoveryCache ?? new Map(), catalogSources: new Map() };
836
1048
  const snapshot = preparedDemand ?? await measureRecoveryPerformanceStage(options, 'status.demand', () => readJointDemand(options));
837
- if (options.codexObservationSession || options.nativeObservations) {
1049
+ if (options.codexObservationSession || options.nativeObservations || options.targets && !options.targets.includes('codex')) {
838
1050
  return readRecoveryStatusInSession(options, snapshot);
839
1051
  }
840
1052
  const context = await createScopeContext({ scope: snapshot.context.context,
@@ -843,13 +1055,7 @@ async function readRecoveryStatusWithQueries(options, preparedDemand) {
843
1055
  try {
844
1056
  options.signal?.throwIfAborted();
845
1057
  session = await createCodexNativeObservationSession({ exactCwd: context.executionCwd, env: context.env,
846
- runner: async (request) => {
847
- const result = await runNativeCli({ ...request, signal: options.signal,
848
- timeoutMs: DEFAULT_AGENT_VERSION_PROBE_TIMEOUT_MS }, options.nativeCliRunner);
849
- if (Buffer.byteLength(result.stdout) + Buffer.byteLength(result.stderr) > 1024 * 1024)
850
- throw new Error('nativeObservationOutputLimit');
851
- return result;
852
- } });
1058
+ runner: options.nativeCliRunner, probe: { signal: options.signal } });
853
1059
  // User reads use only this session's neutral cwd. Project reads add the
854
1060
  // exact project snapshot without repeating the same neutral observation.
855
1061
  return await readRecoveryStatusInSession({ ...options, codexObservationSession: session }, snapshot);
@@ -907,11 +1113,56 @@ async function checkUndeclaredSelection(options, snapshot) {
907
1113
  }
908
1114
  return errors;
909
1115
  }
1116
+ /** Decide whether a project location can consume the exact User Skills observed this round. */
1117
+ function projectSkillCopy(user, project, userAbsent) {
1118
+ const deployments = project.deploymentObservations;
1119
+ if (!deployments?.length || project.blockers.length)
1120
+ return 'blocked';
1121
+ const userDeployments = user.deploymentObservations ?? [];
1122
+ for (const { after, products } of deployments) {
1123
+ if (!products.every((product) => userDeployments.some((deployment) => deployment.products.some((item) => item.id === product.id))))
1124
+ return 'blocked';
1125
+ if (!userAbsent && project.agent === 'pi' && !userDeployments.some((deployment) => deployment.after.nativeIdentity
1126
+ && piProjectListsUserSkills(after, deployment.after.nativeIdentity.sourceLocation)))
1127
+ return 'blocked';
1128
+ if (after.configuration?.activation === 'disabled' || after.configuration?.activation === 'unknown'
1129
+ || after.antigravityLegacyProjectPackage?.state === 'unconfirmed' || after.grokScopeAuthorization === 'denied')
1130
+ return 'blocked';
1131
+ if (after.package === 'present' && after.ownership === 'aw') {
1132
+ // A previous input generation can retire if its own published bytes are still intact.
1133
+ const staleInput = project.content === 'drifted' && project.reasons?.some((reason) => reason.code === 'platformInputDrift' || reason.code === 'antigravityProjectPackageMigrationPending')
1134
+ && project.reasons.every((reason) => ['platformInputDrift', 'antigravityProjectPackageMigrationPending',
1135
+ 'opencodeNativeObservationRequired', INVOCATION_POLICY_NOT_APPLIED].includes(reason.code));
1136
+ if (project.content === 'satisfied' || staleInput)
1137
+ continue;
1138
+ }
1139
+ if (after.package !== 'absent' || after.ownership !== 'absent')
1140
+ return 'blocked';
1141
+ if (project.agent === 'pi') {
1142
+ const hiddenSection = after.registration === 'unknown' && after.diagnostics.some((entry) => entry.code === 'piProjectRegistrationNotVisible');
1143
+ if ((!hiddenSection && after.registration !== 'absent') || after.configuration?.activation !== 'absent')
1144
+ return 'blocked';
1145
+ }
1146
+ if (!userAbsent && project.agent === 'grok') {
1147
+ const name = after.nativeIdentity?.packageId;
1148
+ const native = after.prerequisites.nativeSources;
1149
+ const sources = native?.sources.filter((source) => source.name === name);
1150
+ const personal = user.deploymentObservations?.flatMap(({ after }) => after.prerequisites.nativeSources?.sources ?? [])
1151
+ .find((source) => source.name === name && source.scope === 'user' && source.enabled && source.origin === 'native');
1152
+ if (after.grokScopeAuthorization !== 'granted' || native?.observation !== 'complete' || !personal || sources?.length !== 1
1153
+ || sources[0].scope !== 'user' || !sources[0].enabled || sources[0].path !== personal.path
1154
+ || !user.installedComponentIds?.every((id) => sources[0].effectiveComponents.includes(id.replace(/^skill:/u, 'skills:'))))
1155
+ return 'blocked';
1156
+ }
1157
+ }
1158
+ return deployments.some(({ after }) => after.package === 'present' || after.antigravityLegacyProjectPackage?.state === 'owned') ? 'owned' : 'absent';
1159
+ }
910
1160
  async function readRecoveryStatusInSession(options, snapshot) {
911
1161
  const selectionErrors = await checkUndeclaredSelection(options, snapshot);
912
- const globalPlan = deriveJointDemand(snapshot);
913
- const plan = options.targets ? deriveJointDemand({ ...snapshot, preferences: snapshot.preferences
914
- ? { ...snapshot.preferences, targets: [...new Set([...snapshot.preferences.targets, ...options.targets])] } : null }) : globalPlan;
1162
+ const requestedDemand = options.targets ? { ...snapshot, preferences: snapshot.preferences
1163
+ ? { ...snapshot.preferences, targets: [...new Set([...snapshot.preferences.targets, ...options.targets])] } : null } : snapshot;
1164
+ let globalPlan = deriveJointDemand(snapshot);
1165
+ let plan = requestedDemand === snapshot ? globalPlan : deriveJointDemand(requestedDemand);
915
1166
  const matchesPlugin = (id) => !options.plugins?.length || options.plugins.some((selector) => selector === id || !selector.includes('/') && parsePluginId(id).pluginName === selector);
916
1167
  const selected = Boolean(options.plugins?.length || options.targets);
917
1168
  const observationPlugins = options.plugins?.length ? new Set(plan.placements.filter((item) => matchesPlugin(item.pluginId)
@@ -936,11 +1187,15 @@ async function readRecoveryStatusInSession(options, snapshot) {
936
1187
  for (const plugin of options.plugins ?? [])
937
1188
  observationPlugins.add(plugin);
938
1189
  const selectedPlacement = (item) => (!options.targets || options.targets.includes(item.target)) && (!observationPlugins || observationPlugins.has(item.pluginId));
1190
+ const candidates = [...new Map([...projectSkillCandidates(plan), ...(options.projectSkillProbes ?? [])]
1191
+ .filter(selectedPlacement).map((item) => [`${item.pluginId}\0${item.target}`, item])).values()];
939
1192
  const scopes = [snapshot.user, ...(snapshot.project ? [snapshot.project] : [])];
940
1193
  const observed = [];
1194
+ // Scope order gives User discovery the neutral cwd before equivalent Project
1195
+ // probes reuse it. Codex also shares a mutable manager and neutral inventory.
941
1196
  for (const demand of scopes) {
942
- const nodes = plan.placements.filter((item) => selectedPlacement(item) && (item.scope === demand.scope
943
- || demand.scope === 'project' && ['codex', 'claude', 'gemini', 'copilot'].includes(item.target)
1197
+ const nodes = [...plan.placements, ...(options.projectSkillProbes ?? [])].filter((item) => selectedPlacement(item) && (item.scope === demand.scope
1198
+ || demand.scope === 'project' && ['codex', 'claude', 'copilot'].includes(item.target)
944
1199
  && item.contributions.some((contribution) => contribution.scope === 'project')));
945
1200
  const expanded = { ...demand,
946
1201
  plugins: [...new Map([...demand.plugins, ...nodes.map((item) => item.plugin)]
@@ -959,11 +1214,28 @@ async function readRecoveryStatusInSession(options, snapshot) {
959
1214
  observed.push(await readScopedRecoveryStatus({ ...options, onNativeStatus: undefined, scope: demand.scope,
960
1215
  cwd: snapshot.context.projectRoot ?? options.cwd, observationPlugins, targets: options.targets, demandOverride: expanded }));
961
1216
  }
962
- const allTargets = observed.flatMap((status) => status.inventory?.flatMap((item) => item.targetResults) ?? []).map((target) => {
1217
+ const scopedTargets = observed.flatMap((status) => status.inventory?.flatMap((item) => item.targetResults) ?? []);
1218
+ const skillProviders = candidates.flatMap((candidate) => {
1219
+ const matches = (target) => target.pluginId === candidate.pluginId && target.agent === candidate.target;
1220
+ const user = scopedTargets.find((target) => matches(target) && target.scope === 'user');
1221
+ const project = scopedTargets.find((target) => matches(target) && target.scope === 'project');
1222
+ if (!user || !project)
1223
+ return [];
1224
+ const absent = user.deploymentObservations?.length && user.deploymentObservations.every(({ after }) => after.package === 'absent' && after.ownership === 'absent' && (after.registration === 'absent' || after.registration === 'not-applicable'));
1225
+ return [{ pluginId: candidate.pluginId, target: candidate.target, sourceIdentity: candidate.plugin.sourceIdentity,
1226
+ projectCopy: projectSkillCopy(user, project, !!absent), userAbsent: !!absent, userNeedsRepair: !absent && !isInstalledSkillProvider(user) }];
1227
+ });
1228
+ if (skillProviders.length) {
1229
+ globalPlan = deriveJointDemand(snapshot, skillProviders);
1230
+ plan = requestedDemand === snapshot ? globalPlan : deriveJointDemand(requestedDemand, skillProviders);
1231
+ }
1232
+ const allTargets = scopedTargets.flatMap((target) => {
963
1233
  const providers = plan.placements.filter((placement) => placement.pluginId === target.pluginId && placement.target === target.agent
964
1234
  && (placement.scope === target.scope || target.scope === 'project'
965
- && ['codex', 'claude', 'gemini', 'copilot'].includes(target.agent) && placement.scope === 'user'
1235
+ && ['codex', 'claude', 'copilot'].includes(target.agent) && placement.scope === 'user'
966
1236
  && placement.contributions.some((entry) => entry.scope === 'project')));
1237
+ if (!providers.length)
1238
+ return [];
967
1239
  const contributions = providers.flatMap((provider) => provider.contributions
968
1240
  .filter((entry) => provider.scope === target.scope || entry.scope === target.scope));
969
1241
  return { ...target, contributions: contributions.map((entry) => ({ root: entry.root, scope: entry.scope, path: [...entry.path] })),
@@ -971,6 +1243,14 @@ async function readRecoveryStatusInSession(options, snapshot) {
971
1243
  relation: contributions.some((entry) => entry.path.length === 1 && entry.scope === target.scope) ? 'root' : 'dependency' };
972
1244
  });
973
1245
  const inventory = scopes.some((demand) => demand.roots !== null) ? [] : null;
1246
+ const expected = new Set(plan.placements.map((item) => `${item.pluginId}\0${item.target}\0${item.scope}`));
1247
+ const surplusSkills = scopedTargets.filter((target) => target.scope === 'project'
1248
+ && !expected.has(`${target.pluginId}\0${target.agent}\0project`)
1249
+ && skillProviders.some((provider) => provider.projectCopy === 'owned' && !provider.userAbsent && !provider.userNeedsRepair
1250
+ && provider.pluginId === target.pluginId && provider.target === target.agent))
1251
+ .map((target) => ({ ...target, reasons: [{ code: 'projectSkillDuplicatePending', pluginId: target.pluginId,
1252
+ subject: { pluginId: target.pluginId, target: target.agent, scope: target.scope },
1253
+ message: 'Sync the Project plugin to remove the previous copy of its User Skill dependency.' }] }));
974
1254
  const visibleInventory = [];
975
1255
  for (const demand of scopes)
976
1256
  for (const root of demand.roots ?? []) {
@@ -1001,15 +1281,26 @@ async function readRecoveryStatusInSession(options, snapshot) {
1001
1281
  return allTargets.find((item) => item.pluginId === id && item.agent === requirement.target && item.scope === scope);
1002
1282
  });
1003
1283
  const ownProvider = providers.find((provider) => provider?.pluginId === root.pluginId);
1284
+ if (ownProvider?.installedComponentIds)
1285
+ target.installedComponentIds = ownProvider.installedComponentIds;
1286
+ if (ownProvider?.installedComponentCount !== undefined)
1287
+ target.installedComponentCount = ownProvider.installedComponentCount;
1004
1288
  if (ownProvider?.installedVersion)
1005
1289
  target.installedVersion = ownProvider.installedVersion;
1006
1290
  target.blockers.push(...providers.flatMap((item) => item?.blockers ?? []));
1007
1291
  const reasons = providers.flatMap((item) => item?.reasons ?? []);
1292
+ if (demand.scope === 'project') {
1293
+ for (const copy of surplusSkills) {
1294
+ if (copy.agent !== requirement.target || !requirement.dependencies.includes(copy.pluginId))
1295
+ continue;
1296
+ reasons.push(...copy.reasons);
1297
+ }
1298
+ }
1008
1299
  if (reasons.length)
1009
1300
  target.reasons = reasons;
1010
1301
  const componentGaps = providers.flatMap((item) => item?.componentGaps ?? []);
1011
1302
  if (componentGaps.length)
1012
- target.componentGaps = [...new Map(componentGaps.map((gap) => [JSON.stringify([gap.providerPluginId, gap.agent, gap.renderScope, gap.id]), gap])).values()];
1303
+ target.componentGaps = uniqueRecoveryComponentGaps(componentGaps);
1013
1304
  const exclusions = providers.flatMap((item) => item?.deploymentExclusions ?? []);
1014
1305
  if (exclusions.length)
1015
1306
  target.deploymentExclusions = [...new Map(exclusions.map((exclusion) => [JSON.stringify([exclusion.pluginId, exclusion.platform, exclusion.scope, exclusion.productId, exclusion.reasonCode]), exclusion])).values()];
@@ -1018,8 +1309,7 @@ async function readRecoveryStatusInSession(options, snapshot) {
1018
1309
  target.deploymentObservations = [...new Map(deployments.map((item) => [item.bindingId, item])).values()];
1019
1310
  target.content = ['conflict', 'drifted', 'absent', 'unknown'].find((state) => providers.some((item) => (item?.content ?? 'unknown') === state)) ?? 'satisfied';
1020
1311
  target.observation = target.content === 'satisfied' ? 'verified' : target.content === 'absent' ? 'missing' : 'unknown';
1021
- target.satisfaction = target.content === 'satisfied' ? demand.scope === 'project' && placement?.scope === 'user' ? 'inherited-user' : 'installed'
1022
- : target.content === 'unknown' ? 'unknown' : 'pending';
1312
+ target.satisfaction = observedSatisfaction(target.content, ownProvider, demand.scope === 'project' && placement?.scope === 'user');
1023
1313
  target.backend = providers.map((provider) => ({ pluginId: provider?.pluginId, scope: provider?.scope, content: provider?.content, live: provider?.backend }));
1024
1314
  }
1025
1315
  targetResults.push(target);
@@ -1027,13 +1317,12 @@ async function readRecoveryStatusInSession(options, snapshot) {
1027
1317
  visibleInventory.push({ pluginId: root.pluginId, source: root.sourceId, sourceState: root.sourceState,
1028
1318
  blockers: root.blockers.map(diagnostic), targetResults });
1029
1319
  }
1030
- const expected = new Set(plan.placements.map((item) => `${item.pluginId}\0${item.target}\0${item.scope}`));
1031
- const extraObserved = observed.flatMap((status) => status.extraObserved)
1320
+ const extraObserved = [...observed.flatMap((status) => status.extraObserved), ...surplusSkills]
1032
1321
  .filter((item) => !expected.has(`${item.pluginId}\0${item.agent}\0${item.scope}`));
1033
1322
  const targets = visibleInventory.flatMap((item) => item.targetResults);
1034
1323
  const globalTargets = targets.filter((target) => globalPlan.roots.some((root) => root.pluginId === target.pluginId && root.target === target.agent && root.scope === target.scope));
1035
1324
  const fullObservation = !selected || globalPlan.placements.every(selectedPlacement);
1036
- const knownFailure = globalPlan.errors.some((error) => ['targetsNotConfigured', 'dependencyExcluded', 'dependencyContractInvalid', 'targetPlacementConflict'].includes(error.code))
1325
+ const knownFailure = globalPlan.errors.some((error) => ['targetsNotConfigured', 'dependencyExcluded', 'dependencyContractInvalid', 'targetPlacementConflict', 'projectSkillProviderConflict', 'userSkillProviderNotReady'].includes(error.code))
1037
1326
  || globalTargets.some((target) => ['absent', 'drifted', 'conflict'].includes(target.content ?? 'unknown')
1038
1327
  || target.blockers.some((entry) => entry.code === 'awCapabilityUnsupported'));
1039
1328
  const uncertain = !fullObservation || !globalPlan.complete || globalTargets.some((target) => target.content === 'unknown' || target.blockers.length > 0);
@@ -1049,8 +1338,9 @@ async function readRecoveryStatusInSession(options, snapshot) {
1049
1338
  : scopes.some((demand) => demand.intent.state === 'unsupported-version') ? 'unsupported-version'
1050
1339
  : scopes.some((demand) => demand.intent.state === 'valid') ? 'valid' : 'absent' },
1051
1340
  selection: { agents: snapshot.preferences?.targets ?? [], origin: snapshot.preferences?.targets.length ? 'preference' : 'none', preferences: snapshot.user.preferences.state },
1052
- inventory: inventory === null ? null : visibleInventory, extraObserved, observedTargets: allTargets,
1341
+ inventory: inventory === null ? null : visibleInventory, extraObserved, observedTargets: allTargets, projectSkillProviders: skillProviders,
1053
1342
  existingTargets: observed.flatMap((status) => status.existingTargets ?? []), ownedTargets: observed.flatMap((status) => status.ownedTargets ?? []),
1343
+ retainedProjectPackages: observed.flatMap((status) => status.retainedProjectPackages ?? []),
1054
1344
  coverage: { native: nativeCoverage, portable: portableCoverage, scopes: snapshot.context.scopes,
1055
1345
  ...(snapshot.context.projectRoot ? { projectRoot: snapshot.context.projectRoot } : {}) },
1056
1346
  counts: { blocked: targets.filter((target) => target.blockers.length).length,
@@ -1065,8 +1355,7 @@ async function readRecoveryStatusInSession(options, snapshot) {
1065
1355
  visibleInventory.push({ pluginId: target.pluginId, source: parsePluginId(target.pluginId).sourceId, sourceState: 'ready', blockers: [],
1066
1356
  targetResults: allTargets.filter((entry) => entry.pluginId === target.pluginId).map((entry) => ({ ...entry,
1067
1357
  requirementScope: entry.contributions?.[0]?.scope,
1068
- satisfaction: entry.content === 'satisfied' ? entry.scope === 'user' && entry.contributions?.some((contribution) => contribution.scope === 'project')
1069
- ? 'inherited-user' : 'installed' : entry.content === 'unknown' ? 'unknown' : 'pending' })) });
1358
+ satisfaction: observedSatisfaction(entry.content, entry, entry.scope === 'user' && entry.contributions.some((contribution) => contribution.scope === 'project')) })) });
1070
1359
  }
1071
1360
  }
1072
1361
  if (selected) {