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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (339) hide show
  1. package/dist/authoring/assets/command-runtime-config.d.mts +9 -0
  2. package/dist/authoring/assets/command-runtime-config.mjs +106 -0
  3. package/dist/authoring/assets/command-runtime-config.mjs.map +1 -0
  4. package/dist/authoring/scripts/validate-plugin.mjs +17 -22
  5. package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
  6. package/dist/index.js +2 -6
  7. package/dist/index.js.map +1 -1
  8. package/dist/scripts/aw-skill-eval-materializer.d.ts +4 -0
  9. package/dist/scripts/aw-skill-eval-materializer.js +27 -0
  10. package/dist/scripts/aw-skill-eval-materializer.js.map +1 -1
  11. package/dist/scripts/bundle-plugins.js +1 -1
  12. package/dist/scripts/bundle-plugins.js.map +1 -1
  13. package/dist/scripts/test-plugin-scripts.js +13 -2
  14. package/dist/scripts/test-plugin-scripts.js.map +1 -1
  15. package/dist/src/commands/aw-capabilities.d.ts +1 -1
  16. package/dist/src/commands/aw-capabilities.js +2 -2
  17. package/dist/src/commands/catalog-source.d.ts +2 -1
  18. package/dist/src/commands/catalog-source.js +8 -7
  19. package/dist/src/commands/catalog-source.js.map +1 -1
  20. package/dist/src/commands/deployment-confirmation.d.ts +8 -1
  21. package/dist/src/commands/deployment-confirmation.js +79 -11
  22. package/dist/src/commands/deployment-confirmation.js.map +1 -1
  23. package/dist/src/commands/lifecycle-command-package.d.ts +44 -0
  24. package/dist/src/commands/lifecycle-command-package.js +195 -0
  25. package/dist/src/commands/lifecycle-command-package.js.map +1 -0
  26. package/dist/src/commands/managed-commands.d.ts +6 -0
  27. package/dist/src/commands/managed-commands.js +203 -152
  28. package/dist/src/commands/managed-commands.js.map +1 -1
  29. package/dist/src/commands/operation-plan.d.ts +22 -21
  30. package/dist/src/commands/operation-plan.js +2 -5
  31. package/dist/src/commands/operation-plan.js.map +1 -1
  32. package/dist/src/commands/permission-batch.d.ts +5 -0
  33. package/dist/src/commands/permission-batch.js +80 -0
  34. package/dist/src/commands/permission-batch.js.map +1 -0
  35. package/dist/src/commands/plugin-capabilities.js +17 -13
  36. package/dist/src/commands/plugin-capabilities.js.map +1 -1
  37. package/dist/src/commands/public-config-confirmation.d.ts +8 -2
  38. package/dist/src/commands/public-config-confirmation.js +22 -5
  39. package/dist/src/commands/public-config-confirmation.js.map +1 -1
  40. package/dist/src/commands/public-lifecycle-result.d.ts +7 -12
  41. package/dist/src/commands/public-lifecycle-result.js +136 -40
  42. package/dist/src/commands/public-lifecycle-result.js.map +1 -1
  43. package/dist/src/commands/public-lifecycle.js +49 -8
  44. package/dist/src/commands/public-lifecycle.js.map +1 -1
  45. package/dist/src/commands/public-plugin-query.js +21 -5
  46. package/dist/src/commands/public-plugin-query.js.map +1 -1
  47. package/dist/src/commands/rebuild-command.d.ts +4 -0
  48. package/dist/src/commands/rebuild-command.js +150 -48
  49. package/dist/src/commands/rebuild-command.js.map +1 -1
  50. package/dist/src/commands/rebuild-integration.d.ts +12 -3
  51. package/dist/src/commands/rebuild-integration.js +52 -164
  52. package/dist/src/commands/rebuild-integration.js.map +1 -1
  53. package/dist/src/commands/rebuild-operations.d.ts +2 -1
  54. package/dist/src/commands/rebuild-operations.js +7 -2
  55. package/dist/src/commands/rebuild-operations.js.map +1 -1
  56. package/dist/src/commands/rebuild-platform-integration.d.ts +12 -5
  57. package/dist/src/commands/rebuild-platform-integration.js +691 -186
  58. package/dist/src/commands/rebuild-platform-integration.js.map +1 -1
  59. package/dist/src/commands/skill-eval.js +10 -1
  60. package/dist/src/commands/skill-eval.js.map +1 -1
  61. package/dist/src/generators/local-plugin.js +14 -15
  62. package/dist/src/generators/local-plugin.js.map +1 -1
  63. package/dist/src/generators/permissions.d.ts +18 -4
  64. package/dist/src/generators/permissions.js +76 -22
  65. package/dist/src/generators/permissions.js.map +1 -1
  66. package/dist/src/index.d.ts +1 -0
  67. package/dist/src/index.js +84 -44
  68. package/dist/src/index.js.map +1 -1
  69. package/dist/src/intent/scope-context.d.ts +4 -2
  70. package/dist/src/intent/scope-context.js +37 -7
  71. package/dist/src/intent/scope-context.js.map +1 -1
  72. package/dist/src/output/command-receipt.js +7 -8
  73. package/dist/src/output/command-receipt.js.map +1 -1
  74. package/dist/src/output/component-delivery.d.ts +28 -0
  75. package/dist/src/output/component-delivery.js +138 -0
  76. package/dist/src/output/component-delivery.js.map +1 -0
  77. package/dist/src/output/public-result.d.ts +17 -0
  78. package/dist/src/output/public-result.js +121 -25
  79. package/dist/src/output/public-result.js.map +1 -1
  80. package/dist/src/output/rebuild-progress.js +7 -4
  81. package/dist/src/output/rebuild-progress.js.map +1 -1
  82. package/dist/src/output/receipt-projection.js +51 -31
  83. package/dist/src/output/receipt-projection.js.map +1 -1
  84. package/dist/src/output/skill-invocation-notices.d.ts +2 -0
  85. package/dist/src/output/skill-invocation-notices.js +40 -4
  86. package/dist/src/output/skill-invocation-notices.js.map +1 -1
  87. package/dist/src/platforms/antigravity-permissions.d.ts +50 -0
  88. package/dist/src/platforms/antigravity-permissions.js +388 -0
  89. package/dist/src/platforms/antigravity-permissions.js.map +1 -0
  90. package/dist/src/platforms/capabilities.d.ts +4 -1
  91. package/dist/src/platforms/capabilities.js +93 -9
  92. package/dist/src/platforms/capabilities.js.map +1 -1
  93. package/dist/src/platforms/contracts.d.ts +46 -2
  94. package/dist/src/platforms/discovery.d.ts +13 -0
  95. package/dist/src/platforms/discovery.js +170 -30
  96. package/dist/src/platforms/discovery.js.map +1 -1
  97. package/dist/src/platforms/grok-permission-config.d.ts +22 -0
  98. package/dist/src/platforms/grok-permission-config.js +184 -0
  99. package/dist/src/platforms/grok-permission-config.js.map +1 -0
  100. package/dist/src/platforms/grok-permission-document.d.ts +4 -0
  101. package/dist/src/platforms/grok-permission-document.js +145 -0
  102. package/dist/src/platforms/grok-permission-document.js.map +1 -0
  103. package/dist/src/platforms/grok-permissions.d.ts +17 -0
  104. package/dist/src/platforms/grok-permissions.js +311 -0
  105. package/dist/src/platforms/grok-permissions.js.map +1 -0
  106. package/dist/src/platforms/host-permission-policy.d.ts +38 -0
  107. package/dist/src/platforms/host-permission-policy.js +86 -0
  108. package/dist/src/platforms/host-permission-policy.js.map +1 -0
  109. package/dist/src/platforms/inspection-grok.js +165 -11
  110. package/dist/src/platforms/inspection-grok.js.map +1 -1
  111. package/dist/src/platforms/inspection-native.js +53 -18
  112. package/dist/src/platforms/inspection-native.js.map +1 -1
  113. package/dist/src/platforms/inspection-pi.d.ts +7 -1
  114. package/dist/src/platforms/inspection-pi.js +295 -95
  115. package/dist/src/platforms/inspection-pi.js.map +1 -1
  116. package/dist/src/platforms/inspection-query.d.ts +4 -2
  117. package/dist/src/platforms/inspection-query.js +24 -8
  118. package/dist/src/platforms/inspection-query.js.map +1 -1
  119. package/dist/src/platforms/inspection.d.ts +4 -1
  120. package/dist/src/platforms/inspection.js +36 -4
  121. package/dist/src/platforms/inspection.js.map +1 -1
  122. package/dist/src/platforms/layout.d.ts +13 -0
  123. package/dist/src/platforms/layout.js +90 -12
  124. package/dist/src/platforms/layout.js.map +1 -1
  125. package/dist/src/platforms/lifecycle-native.d.ts +1 -0
  126. package/dist/src/platforms/lifecycle-native.js +25 -1
  127. package/dist/src/platforms/lifecycle-native.js.map +1 -1
  128. package/dist/src/platforms/lifecycle.d.ts +2 -0
  129. package/dist/src/platforms/lifecycle.js +98 -25
  130. package/dist/src/platforms/lifecycle.js.map +1 -1
  131. package/dist/src/platforms/opencode-permission-config.d.ts +13 -0
  132. package/dist/src/platforms/opencode-permission-config.js +253 -0
  133. package/dist/src/platforms/opencode-permission-config.js.map +1 -0
  134. package/dist/src/platforms/opencode-permissions.d.ts +39 -0
  135. package/dist/src/platforms/opencode-permissions.js +212 -0
  136. package/dist/src/platforms/opencode-permissions.js.map +1 -0
  137. package/dist/src/platforms/opencode-related-permissions.d.ts +40 -0
  138. package/dist/src/platforms/opencode-related-permissions.js +177 -0
  139. package/dist/src/platforms/opencode-related-permissions.js.map +1 -0
  140. package/dist/src/platforms/permission-ownership.d.ts +89 -0
  141. package/dist/src/platforms/permission-ownership.js +543 -0
  142. package/dist/src/platforms/permission-ownership.js.map +1 -0
  143. package/dist/src/platforms/permission-sidecar.d.ts +70 -0
  144. package/dist/src/platforms/permission-sidecar.js +215 -0
  145. package/dist/src/platforms/permission-sidecar.js.map +1 -0
  146. package/dist/src/platforms/projection-code-extension.js +2 -1
  147. package/dist/src/platforms/projection-code-extension.js.map +1 -1
  148. package/dist/src/platforms/projection.js +127 -29
  149. package/dist/src/platforms/projection.js.map +1 -1
  150. package/dist/src/platforms/supplement-layout.d.ts +5 -1
  151. package/dist/src/platforms/supplement-layout.js +23 -1
  152. package/dist/src/platforms/supplement-layout.js.map +1 -1
  153. package/dist/src/platforms/supplement-state.d.ts +1 -1
  154. package/dist/src/platforms/supplement-state.js +18 -7
  155. package/dist/src/platforms/supplement-state.js.map +1 -1
  156. package/dist/src/portable/commands.js +1 -1
  157. package/dist/src/portable/commands.js.map +1 -1
  158. package/dist/src/portable/materializer.d.ts +4 -0
  159. package/dist/src/portable/materializer.js +8 -1
  160. package/dist/src/portable/materializer.js.map +1 -1
  161. package/dist/src/portable/recovery.d.ts +2 -0
  162. package/dist/src/portable/recovery.js +45 -8
  163. package/dist/src/portable/recovery.js.map +1 -1
  164. package/dist/src/recovery/coordinator.d.ts +3 -1
  165. package/dist/src/recovery/coordinator.js +101 -37
  166. package/dist/src/recovery/coordinator.js.map +1 -1
  167. package/dist/src/recovery/install-concurrency.js +3 -2
  168. package/dist/src/recovery/install-concurrency.js.map +1 -1
  169. package/dist/src/recovery/joint-coordinator.d.ts +7 -0
  170. package/dist/src/recovery/joint-coordinator.js +270 -64
  171. package/dist/src/recovery/joint-coordinator.js.map +1 -1
  172. package/dist/src/recovery/joint-demand.d.ts +14 -2
  173. package/dist/src/recovery/joint-demand.js +54 -7
  174. package/dist/src/recovery/joint-demand.js.map +1 -1
  175. package/dist/src/recovery/joint-install-execution.js +2 -1
  176. package/dist/src/recovery/joint-install-execution.js.map +1 -1
  177. package/dist/src/recovery/receipt.d.ts +15 -4
  178. package/dist/src/recovery/receipt.js +23 -0
  179. package/dist/src/recovery/receipt.js.map +1 -1
  180. package/dist/src/recovery/retirement.js +11 -17
  181. package/dist/src/recovery/retirement.js.map +1 -1
  182. package/dist/src/recovery/status.d.ts +20 -8
  183. package/dist/src/recovery/status.js +411 -91
  184. package/dist/src/recovery/status.js.map +1 -1
  185. package/dist/src/review/eval-source-input.d.ts +1 -0
  186. package/dist/src/review/eval-source-input.js +7 -1
  187. package/dist/src/review/eval-source-input.js.map +1 -1
  188. package/dist/src/review/platform-profile.js +2 -1
  189. package/dist/src/review/platform-profile.js.map +1 -1
  190. package/dist/src/review/review-selection.js +12 -5
  191. package/dist/src/review/review-selection.js.map +1 -1
  192. package/dist/src/review/skill-materialization.d.ts +2 -1
  193. package/dist/src/review/skill-materialization.js +45 -43
  194. package/dist/src/review/skill-materialization.js.map +1 -1
  195. package/dist/src/review/source-binding.js +5 -1
  196. package/dist/src/review/source-binding.js.map +1 -1
  197. package/dist/src/tui/console-app-v4.js +101 -57
  198. package/dist/src/tui/console-app-v4.js.map +1 -1
  199. package/dist/src/tui/controller-runtime.js +72 -7
  200. package/dist/src/tui/controller-runtime.js.map +1 -1
  201. package/dist/src/tui/controller.d.ts +6 -2
  202. package/dist/src/tui/controller.js +17 -4
  203. package/dist/src/tui/controller.js.map +1 -1
  204. package/dist/src/tui/deployment-view.d.ts +6 -3
  205. package/dist/src/tui/deployment-view.js +52 -10
  206. package/dist/src/tui/deployment-view.js.map +1 -1
  207. package/dist/src/tui/diagnostic-projection.d.ts +7 -1
  208. package/dist/src/tui/diagnostic-projection.js +55 -5
  209. package/dist/src/tui/diagnostic-projection.js.map +1 -1
  210. package/dist/src/tui/entity-cards.d.ts +2 -1
  211. package/dist/src/tui/entity-cards.js +34 -11
  212. package/dist/src/tui/entity-cards.js.map +1 -1
  213. package/dist/src/tui/glossary.js +5 -0
  214. package/dist/src/tui/glossary.js.map +1 -1
  215. package/dist/src/tui/model.js +2 -1
  216. package/dist/src/tui/model.js.map +1 -1
  217. package/dist/src/tui/operation-diagnostic-screens.js +3 -1
  218. package/dist/src/tui/operation-diagnostic-screens.js.map +1 -1
  219. package/dist/src/tui/operation-history.d.ts +6 -0
  220. package/dist/src/tui/operation-history.js +20 -2
  221. package/dist/src/tui/operation-history.js.map +1 -1
  222. package/dist/src/tui/operation-review-planner.js +130 -70
  223. package/dist/src/tui/operation-review-planner.js.map +1 -1
  224. package/dist/src/tui/plugin-detail.d.ts +4 -1
  225. package/dist/src/tui/plugin-detail.js +9 -2
  226. package/dist/src/tui/plugin-detail.js.map +1 -1
  227. package/dist/src/tui/scoped-flow.js +34 -16
  228. package/dist/src/tui/scoped-flow.js.map +1 -1
  229. package/dist/src/tui/scoped-inventory.d.ts +6 -2
  230. package/dist/src/tui/scoped-inventory.js +29 -7
  231. package/dist/src/tui/scoped-inventory.js.map +1 -1
  232. package/dist/src/types.d.ts +10 -21
  233. package/dist/src/types.js.map +1 -1
  234. package/dist/src/utils/artifact-plan.d.ts +3 -36
  235. package/dist/src/utils/artifact-plan.js +16 -78
  236. package/dist/src/utils/artifact-plan.js.map +1 -1
  237. package/dist/src/utils/artifact-renderer.d.ts +1 -60
  238. package/dist/src/utils/artifact-renderer.js +31 -57
  239. package/dist/src/utils/artifact-renderer.js.map +1 -1
  240. package/dist/src/utils/artifact-request.d.ts +3 -26
  241. package/dist/src/utils/artifact-request.js +13 -36
  242. package/dist/src/utils/artifact-request.js.map +1 -1
  243. package/dist/src/utils/artifact-sources.d.ts +0 -8
  244. package/dist/src/utils/artifact-sources.js +0 -8
  245. package/dist/src/utils/artifact-sources.js.map +1 -1
  246. package/dist/src/utils/bundle-layout.js +2 -7
  247. package/dist/src/utils/bundle-layout.js.map +1 -1
  248. package/dist/src/utils/catalog-source-references.js +22 -3
  249. package/dist/src/utils/catalog-source-references.js.map +1 -1
  250. package/dist/src/utils/codex-native-observation.d.ts +6 -0
  251. package/dist/src/utils/codex-native-observation.js +32 -3
  252. package/dist/src/utils/codex-native-observation.js.map +1 -1
  253. package/dist/src/utils/component-command-preparation.d.ts +8 -11
  254. package/dist/src/utils/component-command-preparation.js +110 -210
  255. package/dist/src/utils/component-command-preparation.js.map +1 -1
  256. package/dist/src/utils/component-gap.d.ts +4 -0
  257. package/dist/src/utils/component-gap.js +20 -0
  258. package/dist/src/utils/component-gap.js.map +1 -0
  259. package/dist/src/utils/component-resources.js +2 -4
  260. package/dist/src/utils/component-resources.js.map +1 -1
  261. package/dist/src/utils/dynamic-skill-tree.js +2 -32
  262. package/dist/src/utils/dynamic-skill-tree.js.map +1 -1
  263. package/dist/src/utils/managed-command-cli-review.d.ts +43 -0
  264. package/dist/src/utils/managed-command-cli-review.js +389 -0
  265. package/dist/src/utils/managed-command-cli-review.js.map +1 -0
  266. package/dist/src/utils/managed-command-closure.d.ts +14 -3
  267. package/dist/src/utils/managed-command-closure.js +144 -23
  268. package/dist/src/utils/managed-command-closure.js.map +1 -1
  269. package/dist/src/utils/managed-command-errors.d.ts +5 -0
  270. package/dist/src/utils/managed-command-errors.js +10 -0
  271. package/dist/src/utils/managed-command-errors.js.map +1 -0
  272. package/dist/src/utils/managed-command-materialization.d.ts +77 -113
  273. package/dist/src/utils/managed-command-materialization.js +324 -323
  274. package/dist/src/utils/managed-command-materialization.js.map +1 -1
  275. package/dist/src/utils/managed-command-preparation.d.ts +28 -65
  276. package/dist/src/utils/managed-command-preparation.js +33 -140
  277. package/dist/src/utils/managed-command-preparation.js.map +1 -1
  278. package/dist/src/utils/managed-command-review.d.ts +11 -4
  279. package/dist/src/utils/managed-command-review.js +33 -21
  280. package/dist/src/utils/managed-command-review.js.map +1 -1
  281. package/dist/src/utils/managed-command-runtime.d.ts +1 -0
  282. package/dist/src/utils/managed-command-runtime.js +6 -3
  283. package/dist/src/utils/managed-command-runtime.js.map +1 -1
  284. package/dist/src/utils/managed-command-snapshots.d.ts +17 -0
  285. package/dist/src/utils/managed-command-snapshots.js +84 -0
  286. package/dist/src/utils/managed-command-snapshots.js.map +1 -0
  287. package/dist/src/utils/managed-command-store.d.ts +65 -78
  288. package/dist/src/utils/managed-command-store.js +446 -383
  289. package/dist/src/utils/managed-command-store.js.map +1 -1
  290. package/dist/src/utils/multi-source-catalog.d.ts +2 -0
  291. package/dist/src/utils/multi-source-catalog.js +3 -1
  292. package/dist/src/utils/multi-source-catalog.js.map +1 -1
  293. package/dist/src/utils/native-cli-interruption.d.ts +8 -0
  294. package/dist/src/utils/native-cli-interruption.js +65 -0
  295. package/dist/src/utils/native-cli-interruption.js.map +1 -0
  296. package/dist/src/utils/native-cli.d.ts +5 -0
  297. package/dist/src/utils/native-cli.js +166 -53
  298. package/dist/src/utils/native-cli.js.map +1 -1
  299. package/dist/src/utils/native-tool-context.d.ts +6 -3
  300. package/dist/src/utils/native-tool-context.js +3 -1
  301. package/dist/src/utils/native-tool-context.js.map +1 -1
  302. package/dist/src/utils/native-tool-review.d.ts +2 -12
  303. package/dist/src/utils/native-tool-review.js +6 -108
  304. package/dist/src/utils/native-tool-review.js.map +1 -1
  305. package/dist/src/utils/ownership.d.ts +8 -0
  306. package/dist/src/utils/ownership.js +17 -3
  307. package/dist/src/utils/ownership.js.map +1 -1
  308. package/dist/src/utils/package-content.d.ts +7 -0
  309. package/dist/src/utils/package-content.js +70 -0
  310. package/dist/src/utils/package-content.js.map +1 -0
  311. package/dist/src/utils/platform-empty-state.d.ts +32 -6
  312. package/dist/src/utils/platform-empty-state.js +146 -75
  313. package/dist/src/utils/platform-empty-state.js.map +1 -1
  314. package/dist/src/utils/plugin-config-command-apply.d.ts +33 -0
  315. package/dist/src/utils/plugin-config-command-apply.js +134 -0
  316. package/dist/src/utils/plugin-config-command-apply.js.map +1 -0
  317. package/dist/src/utils/plugin-config-impact.d.ts +19 -9
  318. package/dist/src/utils/plugin-config-impact.js +56 -37
  319. package/dist/src/utils/plugin-config-impact.js.map +1 -1
  320. package/dist/src/utils/plugin-config-write.d.ts +19 -19
  321. package/dist/src/utils/plugin-config-write.js +196 -770
  322. package/dist/src/utils/plugin-config-write.js.map +1 -1
  323. package/dist/src/utils/plugin-scripts.js +19 -8
  324. package/dist/src/utils/plugin-scripts.js.map +1 -1
  325. package/dist/src/utils/process-tree.d.ts +1 -1
  326. package/dist/src/utils/process-tree.js +1 -1
  327. package/dist/src/utils/process-tree.js.map +1 -1
  328. package/dist/src/utils/rendered-contract.js +12 -6
  329. package/dist/src/utils/rendered-contract.js.map +1 -1
  330. package/dist/src/utils/skill-invocation-warning.d.ts +8 -3
  331. package/dist/src/utils/skill-invocation-warning.js +27 -1
  332. package/dist/src/utils/skill-invocation-warning.js.map +1 -1
  333. package/package.json +4 -3
  334. package/dist/src/platforms/managed-command-placement.d.ts +0 -8
  335. package/dist/src/platforms/managed-command-placement.js +0 -79
  336. package/dist/src/platforms/managed-command-placement.js.map +0 -1
  337. package/dist/src/utils/managed-command-evidence.d.ts +0 -7
  338. package/dist/src/utils/managed-command-evidence.js +0 -10
  339. package/dist/src/utils/managed-command-evidence.js.map +0 -1
@@ -1,36 +1,45 @@
1
1
  import path from 'node:path';
2
- import { isPlatformTarget, normalizeStaticPluginComponents } from '@lesliechan721/aw-plugin-core/manifest';
2
+ import { isPlatformTarget, normalizeStaticPluginComponents, 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';
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';
33
38
  import { mapInstallReads } from './install-concurrency.js';
39
+ import { selectPlatformInvocationPolicy, hostPermissionClaims } from '../generators/permissions.js';
40
+ import { isPermissionHost } from '../platforms/host-permission-policy.js';
41
+ import { inspectHostPermissionDelivery } from '../platforms/permission-ownership.js';
42
+ import { readManagedCommandPackage } from '../utils/managed-command-store.js';
34
43
  const NATIVE_READ_ERRORS = new Set(['nativeStateUnreadable', 'stateInventoryFailed', 'configReadFailed',
35
44
  'configInvalid', 'componentInspectionFailed', 'targetInspectionFailed', 'codexNativeObservationFailed',
36
45
  'nativeObservationFailed', 'nativeObservationUnavailable']);
@@ -51,7 +60,7 @@ function withStatusNativeQueries(options, read) {
51
60
  discoveryCache: options.discoveryCache ?? batch.discoveryCache, nativeQuerySession: batch.nativeQuerySession,
52
61
  nativeCliRunner: batch.runner }));
53
62
  }
54
- async function readAdapterObservations(options, context, demand) {
63
+ async function readAdapterObservations(options, context, demand, inventory) {
55
64
  let selected;
56
65
  try {
57
66
  selected = selectAgents({ preferences: demand.preferences, targets: options.targets }).agents
@@ -60,6 +69,7 @@ async function readAdapterObservations(options, context, demand) {
60
69
  catch {
61
70
  return { observations: [], existing: [], owned: [] };
62
71
  }
72
+ const commandPackages = new Map();
63
73
  const platforms = await mapInstallReads(selected, async (platform) => {
64
74
  const observations = [];
65
75
  const existing = [];
@@ -88,12 +98,7 @@ async function readAdapterObservations(options, context, demand) {
88
98
  ctx.codexObservationSession.setManager(manager);
89
99
  else {
90
100
  ownedSession = await createCodexNativeObservationSession({ exactCwd: context.executionCwd, env: context.env, manager,
91
- runner: async (request) => {
92
- const result = await runNativeCli({ ...request, signal: options.signal, timeoutMs: DEFAULT_AGENT_VERSION_PROBE_TIMEOUT_MS }, options.nativeCliRunner);
93
- if (Buffer.byteLength(result.stdout) + Buffer.byteLength(result.stderr) > 1024 * 1024)
94
- throw new Error('nativeObservationOutputLimit');
95
- return result;
96
- } });
101
+ runner: options.nativeCliRunner, probe: { platform: ctx.platform, signal: options.signal } });
97
102
  ctx.codexObservationSession = ownedSession;
98
103
  }
99
104
  }
@@ -101,6 +106,7 @@ async function readAdapterObservations(options, context, demand) {
101
106
  for (const root of roots) {
102
107
  options.signal?.throwIfAborted();
103
108
  const observation = { pluginId: root.pluginId, expectedVersion: root.plugin?.manifest.version, platform, content: 'unknown', blockers: [], reasons: [], deploymentObservations: [] };
109
+ let nativePackage;
104
110
  observations.push(observation);
105
111
  try {
106
112
  const plugin = root.plugin;
@@ -128,7 +134,18 @@ async function readAdapterObservations(options, context, demand) {
128
134
  const emptyMatches = [];
129
135
  const currentMatches = [];
130
136
  const versions = [];
137
+ const deliveredIds = new Set();
131
138
  const staticResourceRoot = await resolveStaticPlatformResourceRoot(plugin.rootDir, platform);
139
+ let commandRoutes;
140
+ if (plugin.sourceIdentity && plugin.manifest.command?.platforms.includes(platform)) {
141
+ let commandPackage = commandPackages.get(root.pluginId);
142
+ if (!commandPackage) {
143
+ commandPackage = readManagedCommandPackage({ sourceId: root.sourceId,
144
+ sourceIdentity: plugin.sourceIdentity, pluginName: plugin.manifest.name }, context.env).catch(() => undefined);
145
+ commandPackages.set(root.pluginId, commandPackage);
146
+ }
147
+ commandRoutes = (await commandPackage)?.record.routes;
148
+ }
132
149
  for (const binding of resolution.bindings) {
133
150
  const subject = { pluginId: root.pluginId, target: platform, scope: binding.scope.kind };
134
151
  const warn = (code) => observation.reasons.push({ ...diagnostic(code), subject });
@@ -137,36 +154,46 @@ async function readAdapterObservations(options, context, demand) {
137
154
  versions.push(live.packageVersion);
138
155
  options.signal?.throwIfAborted();
139
156
  observation.deploymentObservations.push({ bindingId: binding.id, products: binding.consumers, after: live });
157
+ if (isPermissionHost(platform)) {
158
+ const { policy } = selectPlatformInvocationPolicy(resolveInvocationPolicy(plugin.manifest, platform), subject, commandRoutes ?? null);
159
+ const claims = hostPermissionClaims(policy.permissions, binding.plugin.pluginId);
160
+ const previous = inventory.some(({ ownedComponent }) => ownedComponent?.kind === 'shared-config'
161
+ && ownedComponent.locator.kind === 'host-permissions' && ownedComponent.identity.pluginId === root.pluginId
162
+ && ownedComponent.identity.sourceIdentity === binding.plugin.sourceIdentity && ownedComponent.identity.platform === platform
163
+ && ownedComponent.identity.scope === binding.scope.kind);
164
+ if (claims.length || previous) {
165
+ const permissions = await inspectHostPermissionDelivery(ctx, binding, claims, live.grokScopeAuthorization);
166
+ if (permissions) {
167
+ states.push(permissions.content);
168
+ observation.reasons.push(permissions.diagnostic);
169
+ }
170
+ }
171
+ }
140
172
  const shared = ['codex-marketplace', 'claude-marketplace', 'copilot-marketplace'].includes(binding.route);
141
173
  const scopedNativeConsumer = shared ? live.registration === 'present'
142
174
  && live.consumers.some((consumer) => consumer.activation === 'enabled')
143
175
  : live.package === 'present' && live.ownership === 'aw';
144
176
  if (scopedNativeConsumer && (live.ownership === 'aw' || live.ownership === 'shared')) {
145
177
  owned.push({ pluginId: root.pluginId, agent: platform, scope: demand.scope });
146
- existing.push({ pluginId: root.pluginId, agent: platform, scope: demand.scope });
178
+ if (!shared)
179
+ nativePackage ??= { sourceIdentity: binding.plugin.sourceIdentity, skillsReady: false };
180
+ existing.push({ pluginId: root.pluginId, agent: platform, scope: demand.scope,
181
+ ...(nativePackage ? { nativePackage } : {}) });
147
182
  }
148
183
  const unmet = [];
184
+ const staticPackageIds = new Set();
149
185
  const staticSupplements = [];
150
186
  const dynamicUnits = new Set();
151
187
  const inputUnits = [];
152
188
  const profile = getQualifiedPlatformProfile(platform);
153
- let expectedCount = 0;
154
- let packageExpectedCount = 0;
155
- for (const unit of resolution.renderUnits.filter((unit) => binding.renderUnitIds.includes(unit.id))) {
189
+ const renderUnits = resolution.renderUnits.filter((unit) => binding.renderUnitIds.includes(unit.id));
190
+ for (const unit of renderUnits) {
156
191
  const artifacts = plugin.manifest.artifacts;
157
192
  if (artifacts && unit.kinds.length && (!artifacts.scopes || artifacts.scopes.includes(unit.renderScope.kind))) {
158
193
  dynamicUnits.add(unit.output);
159
194
  }
160
195
  const capabilities = adapter.capabilities({ binding, renderUnit: unit, observation: live,
161
196
  profile });
162
- const expected = await normalizeStaticPluginComponents({ pluginRoot: plugin.rootDir, staticResourceRoot,
163
- manifest: plugin.manifest, platform, capabilities, allowedOutputKinds: unit.kinds });
164
- expectedCount += expected.components.length;
165
- if (unit.output === 'supplement')
166
- staticSupplements.push(...expected.components);
167
- else
168
- packageExpectedCount += expected.components.length;
169
- unmet.push(...expected.unmet);
170
197
  inputUnits.push({ renderUnit: unit, capabilities,
171
198
  config: await resolveArtifactRenderConfig({ pluginName: plugin.manifest.name, sourceId: binding.plugin.sourceId,
172
199
  sourceIdentity: binding.plugin.sourceIdentity, logicalIdentity: plugin.catalogLogicalIdentity,
@@ -174,17 +201,99 @@ async function readAdapterObservations(options, context, demand) {
174
201
  cwd: unit.renderScope.kind === 'project' ? unit.renderScope.projectRoot : context.executionCwd,
175
202
  env: context.env, referencePlugins: demand.plugins }) });
176
203
  }
177
- const supplements = await inspectStaticSupplements(ctx, binding, staticSupplements);
178
- const inputEvidence = await createPlatformInputEvidence({ plugin, binding, units: inputUnits });
204
+ const inputEvidence = await createPlatformInputEvidence({ plugin, binding, units: inputUnits, commandRoutes }).catch((error) => {
205
+ rethrowFatalError(error);
206
+ options.signal?.throwIfAborted();
207
+ const systemCode = error?.code;
208
+ if (systemCode !== 'ENOENT' && systemCode !== 'ENOTDIR')
209
+ throw error;
210
+ observation.blockers.push({ code: 'componentResourceMissing', message: 'A required plugin source file or directory is missing.',
211
+ subject, detail: { reasonCode: systemCode } });
212
+ return undefined;
213
+ });
214
+ if (!inputEvidence) {
215
+ states.push('unknown');
216
+ continue;
217
+ }
218
+ const readPackageProjection = async () => {
219
+ const layout = await getDeploymentLayout(ctx, binding);
220
+ const marker = await readSkillOwnerMarker({ skillRoot: layout.packageRoot, allowedRoot: path.dirname(layout.packageRoot),
221
+ expectedIdentity: deploymentPackageComponent(binding, layout).identity });
222
+ return { layout, projection: marker?.nativeProjection };
223
+ };
224
+ const packageUnit = renderUnits.find((unit) => unit.output === 'package');
225
+ const rolePackage = (platform === 'copilot' || platform === 'grok') && packageUnit?.kinds.includes('agent')
226
+ && dynamicUnits.has('package') && plugin.manifest.extensions?.instructions?.length
227
+ && live.package === 'present' && live.ownership === 'aw' ? await readPackageProjection() : undefined;
228
+ // The current package projection identifies renderer-produced roles. File presence and bytes are checked below.
229
+ const roleProjection = rolePackage?.projection;
230
+ const projectedRole = rolePackage && roleProjection?.preparation === 'complete'
231
+ && roleProjection.inputDigest === platformPackageInputDigest(inputEvidence)
232
+ && identityDigest(roleProjection.physicalIdentity) === identityDigest(rolePackage.layout.physicalIdentity)
233
+ && roleProjection.components.some(({ nativeName, relativeOutputs }) => relativeOutputs.includes(platform === 'copilot'
234
+ ? `com.github.copilot/agents/${nativeName}.agent.md` : `agents/${nativeName}.md`));
235
+ let expectedCount = 0;
236
+ let grokAgentRecipientScope;
237
+ for (const { renderUnit: unit, capabilities } of inputUnits) {
238
+ const expected = await normalizeStaticPluginComponents({ pluginRoot: plugin.rootDir, staticResourceRoot,
239
+ manifest: plugin.manifest, platform, capabilities, allowedOutputKinds: unit.kinds,
240
+ hasInstructionAgentRecipients: platform === 'grok' && unit.output === 'supplement'
241
+ ? grokAgentRecipientScope === identityDigest(unit.renderScope) : projectedRole || undefined });
242
+ if (platform === 'grok' && unit.output === 'package'
243
+ && (projectedRole || expected.components.some(({ kind }) => kind === 'agent'))) {
244
+ grokAgentRecipientScope = identityDigest(unit.renderScope);
245
+ }
246
+ expectedCount += expected.components.length;
247
+ for (const component of expected.components) {
248
+ const grokRoleText = platform === 'grok' && component.kind === 'instruction' && !component.content.coverage.includes('main');
249
+ if (unit.output === 'supplement' && !grokRoleText)
250
+ staticSupplements.push(component);
251
+ else
252
+ staticPackageIds.add(component.id);
253
+ }
254
+ unmet.push(...expected.unmet);
255
+ }
256
+ const recordedDelivery = await readPlatformDeliveryState({ input: inputEvidence, env: context.env });
257
+ const recordedGaps = recordedDelivery?.result === 'capability-gaps' && recordedDelivery.gaps.length ? recordedDelivery : undefined;
258
+ for (const { field, ...detail } of recordedDelivery?.permissionNotices ?? []) {
259
+ observation.reasons.push({ code: INVOCATION_POLICY_NOT_APPLIED, subject: { ...subject, field }, detail,
260
+ message: deliveryNoticeMessage(INVOCATION_POLICY_NOT_APPLIED, detail, field) });
261
+ }
262
+ const currentIds = recordedGaps ? new Set(recordedGaps.installedComponentIds) : undefined;
263
+ if (currentIds && recordedGaps) {
264
+ // A renderer receipt can add dynamic expectations. A positive static
265
+ // expectation remains unless that specific component was skipped.
266
+ const skipped = new Set(recordedGaps.gaps.filter((gap) => !gap.componentId).map((gap) => gap.id));
267
+ for (const id of [...staticPackageIds, ...staticSupplements.map((component) => component.id)]) {
268
+ if (!skipped.has(id))
269
+ currentIds.add(id);
270
+ }
271
+ }
272
+ let packageExpectedCount = staticPackageIds.size;
273
+ const expectedSupplements = currentIds ? staticSupplements.filter(({ id }) => currentIds.has(id)) : staticSupplements;
274
+ const supplements = await inspectStaticSupplements(ctx, binding, expectedSupplements);
275
+ const gaps = recordedGaps?.gaps ?? unmet;
276
+ const blockingGaps = gaps.filter((gap) => !isDeliveryCapabilityGap(gap));
277
+ if (gaps.length) {
278
+ (observation.componentGaps ??= []).push(...scopeNativeComponentGaps(gaps, { pluginId: root.pluginId, agent: platform, scope: binding.scope.kind }, renderUnits));
279
+ }
179
280
  const supplementInput = inputEvidence.units.find((unit) => unit.output === 'supplement');
281
+ const emptyPackageIds = recordedDelivery?.result === 'intentional-empty-package' ? recordedDelivery.installedComponentIds : undefined;
180
282
  const recordedSupplements = dynamicUnits.has('supplement') && supplementInput
181
- ? await inspectPlatformSupplementState(ctx, binding, supplementInput.inputDigest) : null;
283
+ ? await inspectPlatformSupplementState(ctx, binding, supplementInput.inputDigest, emptyPackageIds) : null;
182
284
  if (recordedSupplements) {
183
285
  const staticIds = new Set(supplements.components.map((component) => component.id));
184
286
  const dynamicComponents = recordedSupplements.components.filter((component) => !staticIds.has(component.id));
185
287
  supplements.components.push(...dynamicComponents);
186
288
  expectedCount += dynamicComponents.length;
187
289
  }
290
+ const supplementIds = new Set(supplements.components.map(({ id }) => id));
291
+ if (currentIds) {
292
+ expectedCount = currentIds.size;
293
+ packageExpectedCount = [...currentIds].filter((id) => !supplementIds.has(id)).length;
294
+ }
295
+ const supplementSetUnconfirmed = emptyPackageIds
296
+ && (emptyPackageIds.length !== supplementIds.size || emptyPackageIds.some((id) => !supplementIds.has(id)));
188
297
  const supplementConflict = supplements.components.some((component) => component.reasonCodes.includes('supplementOwnershipConflict'));
189
298
  const supplementMissing = supplements.components.some((component) => component.presence === 'absent');
190
299
  const supplementDrift = supplements.components.some((component) => component.reasonCodes.includes('componentContentDrift'));
@@ -205,17 +314,20 @@ async function readAdapterObservations(options, context, demand) {
205
314
  owned.push({ pluginId: root.pluginId, agent: platform, scope: demand.scope });
206
315
  existing.push({ pluginId: root.pluginId, agent: platform, scope: demand.scope });
207
316
  }
208
- const confirmedEmpty = Boolean(plugin.manifest.artifacts && expectedCount === 0 && unmet.length === 0
209
- && await matchesPlatformEmptyState({ state: { ...inputEvidence, kind: 'aw-platform-empty-state', result: 'intentional-empty' }, env: context.env }));
210
- const confirmedEmptyPackage = binding.route === 'codex-marketplace' && recordedSupplements !== null
211
- && dynamicUnits.has('package') && packageExpectedCount === 0
212
- && await matchesPlatformEmptyState({ state: { ...inputEvidence, kind: 'aw-platform-empty-state', result: 'intentional-empty',
213
- units: inputEvidence.units.filter((unit) => unit.output === 'package') }, env: context.env });
317
+ const onlyCapabilityGaps = expectedCount === 0 && gaps.length > 0 && !blockingGaps.length;
318
+ const capabilityEmpty = onlyCapabilityGaps && recordedGaps !== undefined;
319
+ const confirmedEmpty = capabilityEmpty || Boolean(plugin.manifest.artifacts && expectedCount === 0 && gaps.length === 0
320
+ && recordedDelivery?.result === 'intentional-empty');
321
+ const confirmedEmptyPackage = packageExpectedCount === 0 && (Boolean(currentIds?.size)
322
+ || dynamicUnits.has('package') && (recordedDelivery?.result === 'intentional-empty-package'
323
+ || binding.route === 'codex-marketplace' && recordedSupplements !== null
324
+ && await matchesPlatformEmptyState({ state: { ...inputEvidence, kind: 'aw-platform-empty-state', result: 'intentional-empty',
325
+ units: inputEvidence.units.filter((unit) => unit.output === 'package') }, env: context.env })));
214
326
  const dynamicSupplementsUnconfirmed = dynamicUnits.has('supplement') && !confirmedEmpty
215
327
  && !recordedSupplements?.inputMatches && !supplementInputDrift;
216
- if (dynamicSupplementsUnconfirmed)
328
+ if (dynamicSupplementsUnconfirmed || supplementSetUnconfirmed)
217
329
  warn('dynamicExpectationUnconfirmed');
218
- const hasPackageExpectation = packageExpectedCount > 0 || dynamicUnits.has('package') && !confirmedEmpty && !confirmedEmptyPackage;
330
+ const hasPackageExpectation = packageExpectedCount > 0 || !currentIds && dynamicUnits.has('package') && !confirmedEmpty && !confirmedEmptyPackage;
219
331
  const inheritsUserNative = demand.targetRequirements?.find((item) => item.pluginId === root.pluginId
220
332
  && item.target === platform)?.inheritsUserNative;
221
333
  const requiredActivation = requiredDeploymentActivation(binding, live, !inheritsUserNative);
@@ -227,9 +339,18 @@ async function readAdapterObservations(options, context, demand) {
227
339
  ? observation.blockers : observation.reasons;
228
340
  destination.push({ code: entry.code, message: entry.message, subject: { ...subject, ...entry.subject }, detail: entry.detail });
229
341
  }
342
+ const legacyAntigravityPackage = live.antigravityLegacyProjectPackage;
343
+ if (legacyAntigravityPackage?.state === 'owned')
344
+ observation.reasons.push({
345
+ code: 'antigravityProjectPackageMigrationPending',
346
+ message: 'Sync this plugin to finish moving it to the short Antigravity project path.',
347
+ subject,
348
+ detail: { reasonCode: 'antigravityProjectPackageMigrationPending', path: legacyAntigravityPackage.path },
349
+ });
230
350
  const requiresScopeRegistration = binding.route === 'claude-marketplace' && !inheritsUserNative;
231
351
  const registration = requiresScopeRegistration ? live.scopeRegistration ?? 'unknown' : live.registration;
232
- const ownershipConflict = live.ownership === 'foreign' || live.ownership === 'shared';
352
+ const ownershipConflict = live.ownership === 'foreign' || live.ownership === 'shared'
353
+ || legacyAntigravityPackage?.state === 'unconfirmed';
233
354
  if (ownershipConflict)
234
355
  block('deploymentOwnershipConflict');
235
356
  const missing = hasPackageExpectation && (live.package === 'absent' && packageExpectedCount > 0
@@ -251,10 +372,7 @@ async function readAdapterObservations(options, context, demand) {
251
372
  let nativeContentDrift = false;
252
373
  let nativeContentUnconfirmed = false;
253
374
  if (hasPackageExpectation && live.package === 'present' && live.ownership === 'aw' && !missing) {
254
- const layout = await getDeploymentLayout(ctx, binding);
255
- const marker = await readSkillOwnerMarker({ skillRoot: layout.packageRoot, allowedRoot: path.dirname(layout.packageRoot),
256
- expectedIdentity: deploymentPackageComponent(binding, layout).identity });
257
- const projection = marker?.nativeProjection;
375
+ const { layout, projection } = rolePackage ?? await readPackageProjection();
258
376
  const contentDigest = projection ? await readPlatformPackageContentDigest(layout.packageRoot) : undefined;
259
377
  if (['grok-cli', 'antigravity-cli'].includes(binding.route) && live.registration === 'present') {
260
378
  nativeContentUnconfirmed = !contentDigest || !live.nativePackageContentDigest;
@@ -266,15 +384,18 @@ async function readAdapterObservations(options, context, demand) {
266
384
  warn('nativePackageContentDrift');
267
385
  }
268
386
  projectionUnconfirmed = !projection || projection.preparation !== 'complete' || !contentDigest;
269
- const packageInputDigest = platformPackageInputDigest(inputEvidence);
387
+ const packageInputDigest = platformPackageInputDigest(inputEvidence, projection?.components);
270
388
  inputDrift = Boolean(projection && (projection.inputDigest !== packageInputDigest
271
389
  || contentDigest && projection.contentDigest !== contentDigest));
272
390
  if (projectionUnconfirmed)
273
391
  warn(projection?.preparation === 'partial'
274
392
  ? 'platformPreparationPartial' : 'platformExpectationUnconfirmed');
275
- else if (inputDrift)
276
- warn(projection.inputDigest !== packageInputDigest
277
- ? 'platformInputDrift' : 'platformContentDrift');
393
+ else if (inputDrift) {
394
+ if (projection.inputDigest !== packageInputDigest)
395
+ warn('platformInputDrift');
396
+ if (projection.contentDigest !== contentDigest)
397
+ warn('platformContentDrift');
398
+ }
278
399
  componentMissing = live.components.some((component) => component.presence === 'absent');
279
400
  componentUnknown = live.components.some((component) => component.presence === 'unknown'
280
401
  && !component.reasonCodes.includes('nativePackageContentDrift'));
@@ -284,23 +405,82 @@ async function readAdapterObservations(options, context, demand) {
284
405
  warn('componentOutputUnconfirmed');
285
406
  packageExpectationConfirmed = Boolean(!projectionUnconfirmed && projection.inputDigest === packageInputDigest
286
407
  && projection.components.length > 0);
287
- if (packageExpectationConfirmed)
408
+ if (packageExpectationConfirmed) {
288
409
  expectedCount = Math.max(expectedCount, projection.components.length);
410
+ if (platform === 'pi' && !inputDrift) {
411
+ const roles = projection.components.filter((component) => component.relativeOutputs.some((output) => /^agents\/[^/]+\.md$/u.test(output))
412
+ && live.components.some((entry) => entry.id === component.id && entry.presence === 'present' && !entry.reasonCodes.length));
413
+ const warning = piAgentConsumerDiagnostic(binding, live, roles.map(({ id }) => id));
414
+ if (warning)
415
+ observation.reasons.push(warning);
416
+ }
417
+ }
418
+ }
419
+ const confirmedPackage = packageExpectationConfirmed && !inputDrift && !nativeContentDrift && !nativeContentUnconfirmed;
420
+ const confirmedComponents = [...(confirmedPackage ? live.components : []), ...supplements.components];
421
+ for (const component of confirmedComponents) {
422
+ if (component.presence === 'present' && !component.reasonCodes.length && (!currentIds || currentIds.has(component.id))) {
423
+ deliveredIds.add(component.id);
424
+ }
289
425
  }
290
426
  live.components.push(...supplements.components);
291
- currentMatches.push(!dynamicUnits.size || confirmedEmpty || packageExpectationConfirmed || missing
292
- || recordedSupplements !== null && !hasPackageExpectation);
293
- emptyMatches.push(confirmedEmpty);
294
- for (const entry of unmet)
427
+ currentMatches.push(Boolean(currentIds) || !dynamicUnits.size || confirmedEmpty || packageExpectationConfirmed || missing
428
+ || !dynamicSupplementsUnconfirmed && confirmedEmptyPackage || recordedSupplements !== null && !hasPackageExpectation);
429
+ emptyMatches.push(confirmedEmpty && !capabilityEmpty);
430
+ for (const entry of blockingGaps)
295
431
  block(entry.reasonCode);
432
+ if (legacyAntigravityPackage?.state === 'owned' && !ownershipConflict
433
+ && live.ownership !== 'unknown' && !blockingGaps.length) {
434
+ states.push('drifted');
435
+ continue;
436
+ }
296
437
  const inactiveScope = live.registration === 'absent'
297
438
  || live.package === 'absent' && live.registration === 'not-applicable'
298
439
  || live.scopeRegistration === 'absent'
299
440
  || binding.scope.kind === 'project' && shared && live.configuration?.activation === 'absent'
300
441
  || live.consumers.every((consumer) => ['disabled', 'not-applicable'].includes(consumer.activation));
442
+ const skippedFiles = gaps.filter((gap) => supplementInput?.kinds.includes(gap.kind) && gap.name
443
+ && !currentIds?.has(gap.componentId ?? gap.id)
444
+ && !expectedSupplements.some((component) => component.kind === gap.kind && component.name === gap.name));
445
+ if (skippedFiles.length) {
446
+ const slots = gapSupplementFiles(binding, await getDeploymentLayout(ctx, binding), skippedFiles);
447
+ const checked = await inspectOwnedComponents({ components: slots });
448
+ const retained = checked.components.filter((item) => item.state !== 'absent');
449
+ if (retained.length) {
450
+ for (const item of retained)
451
+ if ('path' in item.component) {
452
+ observation.blockers.push(retainedOutputDiagnostic(root.pluginId, platform, binding.scope.kind, item.component.path));
453
+ }
454
+ states.push(retained.some((item) => item.state === 'foreign') ? 'conflict'
455
+ : retained.some((item) => item.state === 'error') ? 'unknown' : 'drifted');
456
+ continue;
457
+ }
458
+ }
459
+ if (onlyCapabilityGaps) {
460
+ const supplementKey = supplementInput?.physicalKey;
461
+ const retained = supplementKey ? inventory.flatMap(({ ownedComponent }) => ownedComponent?.kind === 'owned-text-file' && ownedComponent.identity.physicalKey === supplementKey
462
+ && ownedComponent.identity.sourceIdentity === binding.plugin.sourceIdentity && ownedComponent.identity.pluginId === root.pluginId
463
+ ? [ownedComponent.path] : []) : [];
464
+ const piRegistrationRemaining = binding.route === 'pi-package'
465
+ && (live.registration === 'present' || live.configuration?.activation === 'enabled');
466
+ if ((live.package === 'present' && (!shared || !inactiveScope) || piRegistrationRemaining) && live.nativeIdentity) {
467
+ retained.push(live.nativeIdentity.sourceLocation);
468
+ }
469
+ if (binding.route === 'cursor-workspace-hook' && live.workspaceOpen === 'present') {
470
+ retained.push((await getDeploymentLayout(ctx, binding)).activationPath);
471
+ }
472
+ if (retained.length) {
473
+ observation.blockers.push(...retained.map((file) => retainedOutputDiagnostic(root.pluginId, platform, binding.scope.kind, file)));
474
+ states.push(ownershipConflict ? 'conflict' : 'drifted');
475
+ continue;
476
+ }
477
+ }
301
478
  if (confirmedEmpty) {
302
- states.push(ownershipConflict ? 'conflict' : live.package === 'unknown' || live.registration === 'unknown'
303
- || live.ownership === 'unknown' || observation.blockers.length || !inactiveScope ? 'unknown'
479
+ const hiddenEmptyPi = capabilityEmpty && piProjectEmptyDeliveryObserved(binding, live);
480
+ const cursorHookUnconfirmed = capabilityEmpty && binding.route === 'cursor-workspace-hook' && live.workspaceOpen !== 'absent';
481
+ const piConfigUnconfirmed = capabilityEmpty && binding.route === 'pi-package' && live.configuration?.activation !== 'absent';
482
+ states.push(ownershipConflict ? 'conflict' : live.package === 'unknown' || live.registration === 'unknown' && !hiddenEmptyPi
483
+ || live.ownership === 'unknown' || observation.blockers.length || cursorHookUnconfirmed || piConfigUnconfirmed || !inactiveScope && !hiddenEmptyPi ? 'unknown'
304
484
  : live.package === 'absent' || shared ? 'satisfied' : 'drifted');
305
485
  continue;
306
486
  }
@@ -325,11 +505,15 @@ async function readAdapterObservations(options, context, demand) {
325
505
  states.push('conflict');
326
506
  else if (confirmedEmptyPackage && (live.package === 'unknown' || live.registration === 'unknown' || live.ownership === 'unknown'))
327
507
  states.push('unknown');
328
- else if (confirmedEmptyPackage && !inactiveScope) {
508
+ else if (confirmedEmptyPackage && (!inactiveScope || !shared && live.package === 'present')) {
329
509
  warn('platformContentDrift');
330
510
  states.push('drifted');
331
511
  }
332
- else if (unmet.length || hasPackageExpectation && registration === 'unknown')
512
+ else if (onlyCapabilityGaps) {
513
+ warn('platformExpectationUnconfirmed');
514
+ states.push('unknown');
515
+ }
516
+ else if (blockingGaps.length || hasPackageExpectation && registration === 'unknown')
333
517
  states.push('unknown');
334
518
  else if (missing)
335
519
  states.push('absent');
@@ -342,7 +526,7 @@ async function readAdapterObservations(options, context, demand) {
342
526
  else if (hasPackageExpectation && ['disabled', 'blocked'].includes(requiredActivation)
343
527
  || live.workspaceOpen === 'absent' && live.package === 'present' || inputDrift || supplementDrift || supplementInputDrift || nativeContentDrift)
344
528
  states.push('drifted');
345
- else if (dynamicSupplementsUnconfirmed || hasPackageExpectation && !packageExpectationConfirmed)
529
+ else if (dynamicSupplementsUnconfirmed || supplementSetUnconfirmed || hasPackageExpectation && !packageExpectationConfirmed)
346
530
  states.push('unknown');
347
531
  else if (!expectedCount)
348
532
  states.push(live.package === 'absent' && ['absent', 'not-applicable'].includes(live.registration) ? 'satisfied' : 'drifted');
@@ -355,6 +539,11 @@ async function readAdapterObservations(options, context, demand) {
355
539
  observation.installedVersion = versions[0];
356
540
  observation.content = ['conflict', 'drifted', 'absent', 'unknown']
357
541
  .find((state) => states.includes(state)) ?? 'satisfied';
542
+ if (observation.content === 'satisfied' || observation.content === 'absent' || deliveredIds.size) {
543
+ observation.installedComponentIds = [...deliveredIds];
544
+ }
545
+ if (nativePackage)
546
+ nativePackage.skillsReady = hasReadyProviderSkills({ ...observation, installedComponentCount: deliveredIds.size });
358
547
  }
359
548
  catch (error) {
360
549
  rethrowFatalError(error);
@@ -453,6 +642,12 @@ export async function statusFromObservations(options) {
453
642
  && entry.platform === delivery.platform);
454
643
  if (native) {
455
644
  target.content = native.content;
645
+ if (native.componentGaps?.length)
646
+ target.componentGaps = native.componentGaps;
647
+ if (native.installedComponentIds) {
648
+ target.installedComponentIds = native.installedComponentIds;
649
+ target.installedComponentCount = native.installedComponentIds.length;
650
+ }
456
651
  if (native.installedVersion)
457
652
  target.installedVersion = native.installedVersion;
458
653
  if (native.deploymentObservations)
@@ -479,24 +674,38 @@ export async function statusFromObservations(options) {
479
674
  cliVersion: options.cliVersion ?? '0.0.0', catalogOperationContext: demand.catalogOperationContext,
480
675
  excludedPluginIds: demand.userProviders?.[agent] }, options.catalogReadScope);
481
676
  options.signal?.throwIfAborted();
482
- target.blockers.push(...portable.blockers.map((code) => portablePreparationDiagnostic(portable, diagnostic(code), agent)));
677
+ target.blockers.push(...portable.blockers.filter((code) => code !== 'previousDeploymentRetained').map((code) => portablePreparationDiagnostic(portable, diagnostic(code), agent)));
678
+ if (portable.policyNotices?.length)
679
+ target.reasons = [...target.reasons ?? [], ...portable.policyNotices];
483
680
  const gaps = (portable.unmet ?? []).filter((gap) => gap.agent === agent);
484
- if (gaps.length) {
681
+ const blockingGap = gaps.some((gap) => !isDeliveryCapabilityGap(gap));
682
+ if (gaps.length)
485
683
  target.componentGaps = gaps;
486
- if (!target.blockers.some((entry) => entry.code === 'portableComponentsUnmet'))
487
- target.blockers.push(diagnostic('portableComponentsUnmet'));
488
- }
684
+ if (blockingGap && !target.blockers.some((entry) => entry.code === 'portableComponentsUnmet'))
685
+ target.blockers.push(diagnostic('portableComponentsUnmet'));
489
686
  const observed = portable.targets.filter((entry) => entry.agent === agent);
490
- target.blockers.push(...observed.flatMap((entry) => entry.blocker ? [diagnostic(entry.blocker)] : []));
687
+ if (!portable.globalBlockers?.length) {
688
+ const installed = observed.filter((entry) => entry.providerPluginId === root.pluginId
689
+ && entry.disposition === 'write' && entry.observation === 'satisfied' && !entry.blocker);
690
+ if (installed.length || observed.every((entry) => entry.disposition === 'retain'
691
+ || entry.observation === 'satisfied' || entry.observation === 'absent')) {
692
+ target.installedComponentCount = installed.length;
693
+ if (installed.every((entry) => entry.componentId))
694
+ target.installedComponentIds = installed.map((entry) => entry.componentId);
695
+ }
696
+ }
697
+ target.blockers.push(...observed.flatMap((entry) => entry.disposition === 'retain'
698
+ ? [retainedOutputDiagnostic(entry.providerPluginId, agent, options.scope, entry.physicalPath, `skill.${entry.skill}`)]
699
+ : entry.blocker ? [diagnostic(entry.blocker)] : []));
491
700
  target.content = ['conflict', 'drifted', 'absent', 'unknown']
492
701
  .find((state) => observed.some((entry) => entry.observation === state))
493
- ?? (!portable.blockers.length && (observed.length || portable.intentionalEmpty && gaps.length === 0) ? 'satisfied' : 'unknown');
702
+ ?? (!portable.blockers.length && (observed.length || portable.intentionalEmpty || gaps.length && !blockingGap) ? 'satisfied' : 'unknown');
494
703
  if (observed.length === 0 && portable.blockers.includes('needs-preparation') && options.portableCoverage === true
495
704
  && options.portableInstalled && !options.portableInstalled.some((item) => item.pluginId === root.pluginId && item.agent === agent)) {
496
705
  target.content = 'absent';
497
706
  target.blockers = target.blockers.filter((item) => item.code !== 'needs-preparation');
498
707
  }
499
- if (gaps.length && target.content !== 'conflict')
708
+ if ((blockingGap || observed.some((entry) => entry.disposition === 'retain')) && target.content !== 'conflict')
500
709
  target.content = 'unknown';
501
710
  target.backend = observed.map((entry) => ({ skill: entry.skill, agent: entry.agent,
502
711
  ownership: entry.ownership, observation: entry.observation, associatedAgents: entry.associatedAgents }));
@@ -519,6 +728,10 @@ export async function statusFromObservations(options) {
519
728
  target.reasons = [...target.reasons ?? [], diagnostic('dynamicExpectationUnconfirmed')];
520
729
  }
521
730
  }
731
+ if (target.content === 'satisfied' && !target.blockers.length && target.installedComponentCount === 0
732
+ && target.componentGaps?.some((gap) => gap.providerPluginId === target.pluginId) && target.componentGaps.every(isDeliveryCapabilityGap)) {
733
+ target.satisfaction = 'not-applicable';
734
+ }
522
735
  target.observation = target.content === 'satisfied' ? 'verified'
523
736
  : target.content === 'absent' ? 'missing' : 'unknown';
524
737
  targetResults.push(target);
@@ -646,7 +859,7 @@ export async function readScopedRecoveryStatus(options) {
646
859
  targetRequirements: demand.targetRequirements ? [...demand.targetRequirements,
647
860
  ...candidates.map((entry) => ({ pluginId: `${entry.sourceId}/${entry.pluginName}`, target: entry.platform }))] : undefined };
648
861
  const adapters = options.nativeObservations ? { observations: [], existing: [], owned: [] }
649
- : await withStatusNativeQueries({ ...options, targets: [...new Set([...selectedAgents, ...candidates.map((entry) => entry.platform)])] }, (nativeOptions) => readAdapterObservations(nativeOptions, context, observationDemand));
862
+ : await withStatusNativeQueries({ ...options, targets: [...new Set([...selectedAgents, ...candidates.map((entry) => entry.platform)])] }, (nativeOptions) => readAdapterObservations(nativeOptions, context, observationDemand, candidates));
650
863
  const roots = new Set(demand.roots?.map((root) => root.pluginId) ?? []);
651
864
  const queue = [...(demand.roots ?? []).map((root) => root.plugin).filter((plugin) => plugin !== undefined)];
652
865
  const byId = new Map(demand.plugins.map((plugin) => [plugin.pluginId, plugin]));
@@ -687,19 +900,41 @@ export async function readScopedRecoveryStatus(options) {
687
900
  nativeExtraObserved.push({ ...entry, delivery: { kind: 'native', platform: entry.agent }, observation: 'unknown', content: 'unknown' });
688
901
  }
689
902
  }
903
+ const retainedProjectPackages = [];
690
904
  for (const entry of candidates) {
691
905
  const component = entry.ownedComponent;
692
- if (component?.kind !== 'owned-directory' || !['codex', 'claude', 'copilot'].includes(entry.platform)
693
- || component.identity.scope !== options.scope || entry.recoveryCandidate?.evidence !== 'verified'
906
+ const recovery = entry.recoveryCandidate;
907
+ if (component?.kind !== 'owned-directory' || recovery?.evidence !== 'verified' || component.identity.scope !== options.scope
694
908
  || component.identity.sourceId !== entry.sourceId || component.identity.sourceIdentity !== entry.sourceIdentity
695
909
  || component.identity.platform !== entry.platform || component.identity.pluginId !== `${entry.sourceId}/${entry.pluginName}`
696
- || component.identity.physicalKey !== entry.recoveryCandidate.binding.physicalKey)
910
+ || component.identity.physicalKey !== recovery.binding.physicalKey)
697
911
  continue;
698
912
  const pluginId = component.identity.pluginId;
913
+ const agent = entry.platform;
914
+ const sourceIdentity = recovery.binding.plugin.sourceIdentity;
915
+ if (!hasSharedUserPackage(agent)) {
916
+ const location = recovery.binding.scope;
917
+ if (location.kind !== 'project' || location.projectRoot !== context.projectRoot
918
+ || adapters.existing.some((target) => target.pluginId === pluginId && target.agent === agent
919
+ && target.nativePackage?.sourceIdentity === sourceIdentity))
920
+ continue;
921
+ const source = catalogSources.get(entry.sourceId)?.resolution;
922
+ let dependencies = null;
923
+ if (source?.sourceIdentity === sourceIdentity && source.manifest.entries.some((plugin) => plugin.name === entry.pluginName)) {
924
+ try {
925
+ dependencies = resolvePluginDependencyClosure(source.manifest.entries, [entry.pluginName])
926
+ .filter((plugin) => plugin.name !== entry.pluginName).map((plugin) => `${entry.sourceId}/${plugin.name}`);
927
+ }
928
+ catch { /* An unavailable closure retains only same-source candidates. */ }
929
+ }
930
+ retainedProjectPackages.push({ pluginId, agent, scope: 'project', dependencies,
931
+ nativePackage: { sourceIdentity, skillsReady: false } });
932
+ continue;
933
+ }
699
934
  if (observedPlugins.get(pluginId)?.sourceIdentity === component.identity.sourceIdentity)
700
935
  continue;
701
- nativeExtraObserved.push({ pluginId, agent: entry.platform, scope: component.identity.scope,
702
- delivery: { kind: 'native', platform: entry.platform }, observation: 'unknown', content: 'unknown',
936
+ nativeExtraObserved.push({ pluginId, agent, scope: component.identity.scope,
937
+ delivery: { kind: 'native', platform: agent }, observation: 'unknown', content: 'unknown',
703
938
  backend: { retainedPackage: true, ownedComponents: [{ ...component, state: 'present' }] } });
704
939
  }
705
940
  const portableExtra = options.targets && !options.targets.includes('generic') ? { targets: [], complete: true }
@@ -770,6 +1005,7 @@ export async function readScopedRecoveryStatus(options) {
770
1005
  ...adapters.existing,
771
1006
  ...portableExtra.targets.map((target) => ({ pluginId: target.pluginId, agent: target.agent, scope: options.scope })),
772
1007
  ];
1008
+ result.retainedProjectPackages = retainedProjectPackages;
773
1009
  result.ownedTargets = [
774
1010
  ...adapters.owned, ...inventoryOwned,
775
1011
  ...portableExtra.targets.map((target) => ({ pluginId: target.pluginId, agent: target.agent, scope: options.scope })),
@@ -821,6 +1057,15 @@ export async function checkRecovery(selectors, options) {
821
1057
  coverage: { scopes: status.coverage.scopes ?? [status.scope], ...(status.coverage.projectRoot ? { projectRoot: status.coverage.projectRoot } : {}) },
822
1058
  declarationChanged: false, preferencesChanged: false, configChanged: false, outputsMayHaveChanged: false };
823
1059
  }
1060
+ function observedSatisfaction(content, provider, inheritsUser) {
1061
+ if (!content || content === 'unknown')
1062
+ return 'unknown';
1063
+ if (content !== 'satisfied')
1064
+ return 'pending';
1065
+ if (provider?.satisfaction === 'not-applicable')
1066
+ return 'not-applicable';
1067
+ return inheritsUser ? 'inherited-user' : 'installed';
1068
+ }
824
1069
  export function aggregateConvergence(allSatisfied, residue) {
825
1070
  return allSatisfied === false || residue === 'present' ? false
826
1071
  : allSatisfied === null || residue === 'unknown' ? null : true;
@@ -840,13 +1085,7 @@ async function readRecoveryStatusWithQueries(options, preparedDemand) {
840
1085
  try {
841
1086
  options.signal?.throwIfAborted();
842
1087
  session = await createCodexNativeObservationSession({ exactCwd: context.executionCwd, env: context.env,
843
- runner: async (request) => {
844
- const result = await runNativeCli({ ...request, signal: options.signal,
845
- timeoutMs: DEFAULT_AGENT_VERSION_PROBE_TIMEOUT_MS }, options.nativeCliRunner);
846
- if (Buffer.byteLength(result.stdout) + Buffer.byteLength(result.stderr) > 1024 * 1024)
847
- throw new Error('nativeObservationOutputLimit');
848
- return result;
849
- } });
1088
+ runner: options.nativeCliRunner, probe: { signal: options.signal } });
850
1089
  // User reads use only this session's neutral cwd. Project reads add the
851
1090
  // exact project snapshot without repeating the same neutral observation.
852
1091
  return await readRecoveryStatusInSession({ ...options, codexObservationSession: session }, snapshot);
@@ -904,11 +1143,56 @@ async function checkUndeclaredSelection(options, snapshot) {
904
1143
  }
905
1144
  return errors;
906
1145
  }
1146
+ /** Decide whether a project location can consume the exact User Skills observed this round. */
1147
+ function projectSkillCopy(user, project, userAbsent) {
1148
+ const deployments = project.deploymentObservations;
1149
+ if (!deployments?.length || project.blockers.length)
1150
+ return 'blocked';
1151
+ const userDeployments = user.deploymentObservations ?? [];
1152
+ for (const { after, products } of deployments) {
1153
+ if (!products.every((product) => userDeployments.some((deployment) => deployment.products.some((item) => item.id === product.id))))
1154
+ return 'blocked';
1155
+ if (!userAbsent && project.agent === 'pi' && !userDeployments.some((deployment) => deployment.after.nativeIdentity
1156
+ && piProjectListsUserSkills(after, deployment.after.nativeIdentity.sourceLocation)))
1157
+ return 'blocked';
1158
+ if (after.configuration?.activation === 'disabled' || after.configuration?.activation === 'unknown'
1159
+ || after.antigravityLegacyProjectPackage?.state === 'unconfirmed' || after.grokScopeAuthorization === 'denied')
1160
+ return 'blocked';
1161
+ if (after.package === 'present' && after.ownership === 'aw') {
1162
+ // A previous input generation can retire if its own published bytes are still intact.
1163
+ const staleInput = project.content === 'drifted' && project.reasons?.some((reason) => reason.code === 'platformInputDrift' || reason.code === 'antigravityProjectPackageMigrationPending')
1164
+ && project.reasons.every((reason) => ['platformInputDrift', 'antigravityProjectPackageMigrationPending',
1165
+ 'opencodeNativeObservationRequired', INVOCATION_POLICY_NOT_APPLIED].includes(reason.code));
1166
+ if (project.content === 'satisfied' || staleInput)
1167
+ continue;
1168
+ }
1169
+ if (after.package !== 'absent' || after.ownership !== 'absent')
1170
+ return 'blocked';
1171
+ if (project.agent === 'pi') {
1172
+ const hiddenSection = after.registration === 'unknown' && after.diagnostics.some((entry) => entry.code === 'piProjectRegistrationNotVisible');
1173
+ if ((!hiddenSection && after.registration !== 'absent') || after.configuration?.activation !== 'absent')
1174
+ return 'blocked';
1175
+ }
1176
+ if (!userAbsent && project.agent === 'grok') {
1177
+ const name = after.nativeIdentity?.packageId;
1178
+ const native = after.prerequisites.nativeSources;
1179
+ const sources = native?.sources.filter((source) => source.name === name);
1180
+ const personal = user.deploymentObservations?.flatMap(({ after }) => after.prerequisites.nativeSources?.sources ?? [])
1181
+ .find((source) => source.name === name && source.scope === 'user' && source.enabled && source.origin === 'native');
1182
+ if (after.grokScopeAuthorization !== 'granted' || native?.observation !== 'complete' || !personal || sources?.length !== 1
1183
+ || sources[0].scope !== 'user' || !sources[0].enabled || sources[0].path !== personal.path
1184
+ || !user.installedComponentIds?.every((id) => sources[0].effectiveComponents.includes(id.replace(/^skill:/u, 'skills:'))))
1185
+ return 'blocked';
1186
+ }
1187
+ }
1188
+ return deployments.some(({ after }) => after.package === 'present' || after.antigravityLegacyProjectPackage?.state === 'owned') ? 'owned' : 'absent';
1189
+ }
907
1190
  async function readRecoveryStatusInSession(options, snapshot) {
908
1191
  const selectionErrors = await checkUndeclaredSelection(options, snapshot);
909
- const globalPlan = deriveJointDemand(snapshot);
910
- const plan = options.targets ? deriveJointDemand({ ...snapshot, preferences: snapshot.preferences
911
- ? { ...snapshot.preferences, targets: [...new Set([...snapshot.preferences.targets, ...options.targets])] } : null }) : globalPlan;
1192
+ const requestedDemand = options.targets ? { ...snapshot, preferences: snapshot.preferences
1193
+ ? { ...snapshot.preferences, targets: [...new Set([...snapshot.preferences.targets, ...options.targets])] } : null } : snapshot;
1194
+ let globalPlan = deriveJointDemand(snapshot);
1195
+ let plan = requestedDemand === snapshot ? globalPlan : deriveJointDemand(requestedDemand);
912
1196
  const matchesPlugin = (id) => !options.plugins?.length || options.plugins.some((selector) => selector === id || !selector.includes('/') && parsePluginId(id).pluginName === selector);
913
1197
  const selected = Boolean(options.plugins?.length || options.targets);
914
1198
  const observationPlugins = options.plugins?.length ? new Set(plan.placements.filter((item) => matchesPlugin(item.pluginId)
@@ -933,12 +1217,14 @@ async function readRecoveryStatusInSession(options, snapshot) {
933
1217
  for (const plugin of options.plugins ?? [])
934
1218
  observationPlugins.add(plugin);
935
1219
  const selectedPlacement = (item) => (!options.targets || options.targets.includes(item.target)) && (!observationPlugins || observationPlugins.has(item.pluginId));
1220
+ const candidates = [...new Map([...projectSkillCandidates(plan), ...(options.projectSkillProbes ?? [])]
1221
+ .filter(selectedPlacement).map((item) => [`${item.pluginId}\0${item.target}`, item])).values()];
936
1222
  const scopes = [snapshot.user, ...(snapshot.project ? [snapshot.project] : [])];
937
1223
  const observed = [];
938
1224
  // Scope order gives User discovery the neutral cwd before equivalent Project
939
1225
  // probes reuse it. Codex also shares a mutable manager and neutral inventory.
940
1226
  for (const demand of scopes) {
941
- const nodes = plan.placements.filter((item) => selectedPlacement(item) && (item.scope === demand.scope
1227
+ const nodes = [...plan.placements, ...(options.projectSkillProbes ?? [])].filter((item) => selectedPlacement(item) && (item.scope === demand.scope
942
1228
  || demand.scope === 'project' && ['codex', 'claude', 'copilot'].includes(item.target)
943
1229
  && item.contributions.some((contribution) => contribution.scope === 'project')));
944
1230
  const expanded = { ...demand,
@@ -958,11 +1244,28 @@ async function readRecoveryStatusInSession(options, snapshot) {
958
1244
  observed.push(await readScopedRecoveryStatus({ ...options, onNativeStatus: undefined, scope: demand.scope,
959
1245
  cwd: snapshot.context.projectRoot ?? options.cwd, observationPlugins, targets: options.targets, demandOverride: expanded }));
960
1246
  }
961
- const allTargets = observed.flatMap((status) => status.inventory?.flatMap((item) => item.targetResults) ?? []).map((target) => {
1247
+ const scopedTargets = observed.flatMap((status) => status.inventory?.flatMap((item) => item.targetResults) ?? []);
1248
+ const skillProviders = candidates.flatMap((candidate) => {
1249
+ const matches = (target) => target.pluginId === candidate.pluginId && target.agent === candidate.target;
1250
+ const user = scopedTargets.find((target) => matches(target) && target.scope === 'user');
1251
+ const project = scopedTargets.find((target) => matches(target) && target.scope === 'project');
1252
+ if (!user || !project)
1253
+ return [];
1254
+ const absent = user.deploymentObservations?.length && user.deploymentObservations.every(({ after }) => after.package === 'absent' && after.ownership === 'absent' && (after.registration === 'absent' || after.registration === 'not-applicable'));
1255
+ return [{ pluginId: candidate.pluginId, target: candidate.target, sourceIdentity: candidate.plugin.sourceIdentity,
1256
+ projectCopy: projectSkillCopy(user, project, !!absent), userAbsent: !!absent, userNeedsRepair: !absent && !isInstalledSkillProvider(user) }];
1257
+ });
1258
+ if (skillProviders.length) {
1259
+ globalPlan = deriveJointDemand(snapshot, skillProviders);
1260
+ plan = requestedDemand === snapshot ? globalPlan : deriveJointDemand(requestedDemand, skillProviders);
1261
+ }
1262
+ const allTargets = scopedTargets.flatMap((target) => {
962
1263
  const providers = plan.placements.filter((placement) => placement.pluginId === target.pluginId && placement.target === target.agent
963
1264
  && (placement.scope === target.scope || target.scope === 'project'
964
1265
  && ['codex', 'claude', 'copilot'].includes(target.agent) && placement.scope === 'user'
965
1266
  && placement.contributions.some((entry) => entry.scope === 'project')));
1267
+ if (!providers.length)
1268
+ return [];
966
1269
  const contributions = providers.flatMap((provider) => provider.contributions
967
1270
  .filter((entry) => provider.scope === target.scope || entry.scope === target.scope));
968
1271
  return { ...target, contributions: contributions.map((entry) => ({ root: entry.root, scope: entry.scope, path: [...entry.path] })),
@@ -970,6 +1273,14 @@ async function readRecoveryStatusInSession(options, snapshot) {
970
1273
  relation: contributions.some((entry) => entry.path.length === 1 && entry.scope === target.scope) ? 'root' : 'dependency' };
971
1274
  });
972
1275
  const inventory = scopes.some((demand) => demand.roots !== null) ? [] : null;
1276
+ const expected = new Set(plan.placements.map((item) => `${item.pluginId}\0${item.target}\0${item.scope}`));
1277
+ const surplusSkills = scopedTargets.filter((target) => target.scope === 'project'
1278
+ && !expected.has(`${target.pluginId}\0${target.agent}\0project`)
1279
+ && skillProviders.some((provider) => provider.projectCopy === 'owned' && !provider.userAbsent && !provider.userNeedsRepair
1280
+ && provider.pluginId === target.pluginId && provider.target === target.agent))
1281
+ .map((target) => ({ ...target, reasons: [{ code: 'projectSkillDuplicatePending', pluginId: target.pluginId,
1282
+ subject: { pluginId: target.pluginId, target: target.agent, scope: target.scope },
1283
+ message: 'Sync the Project plugin to remove the previous copy of its User Skill dependency.' }] }));
973
1284
  const visibleInventory = [];
974
1285
  for (const demand of scopes)
975
1286
  for (const root of demand.roots ?? []) {
@@ -1000,15 +1311,26 @@ async function readRecoveryStatusInSession(options, snapshot) {
1000
1311
  return allTargets.find((item) => item.pluginId === id && item.agent === requirement.target && item.scope === scope);
1001
1312
  });
1002
1313
  const ownProvider = providers.find((provider) => provider?.pluginId === root.pluginId);
1314
+ if (ownProvider?.installedComponentIds)
1315
+ target.installedComponentIds = ownProvider.installedComponentIds;
1316
+ if (ownProvider?.installedComponentCount !== undefined)
1317
+ target.installedComponentCount = ownProvider.installedComponentCount;
1003
1318
  if (ownProvider?.installedVersion)
1004
1319
  target.installedVersion = ownProvider.installedVersion;
1005
1320
  target.blockers.push(...providers.flatMap((item) => item?.blockers ?? []));
1006
1321
  const reasons = providers.flatMap((item) => item?.reasons ?? []);
1322
+ if (demand.scope === 'project') {
1323
+ for (const copy of surplusSkills) {
1324
+ if (copy.agent !== requirement.target || !requirement.dependencies.includes(copy.pluginId))
1325
+ continue;
1326
+ reasons.push(...copy.reasons);
1327
+ }
1328
+ }
1007
1329
  if (reasons.length)
1008
1330
  target.reasons = reasons;
1009
1331
  const componentGaps = providers.flatMap((item) => item?.componentGaps ?? []);
1010
1332
  if (componentGaps.length)
1011
- target.componentGaps = [...new Map(componentGaps.map((gap) => [JSON.stringify([gap.providerPluginId, gap.agent, gap.renderScope, gap.id]), gap])).values()];
1333
+ target.componentGaps = uniqueRecoveryComponentGaps(componentGaps);
1012
1334
  const exclusions = providers.flatMap((item) => item?.deploymentExclusions ?? []);
1013
1335
  if (exclusions.length)
1014
1336
  target.deploymentExclusions = [...new Map(exclusions.map((exclusion) => [JSON.stringify([exclusion.pluginId, exclusion.platform, exclusion.scope, exclusion.productId, exclusion.reasonCode]), exclusion])).values()];
@@ -1017,8 +1339,7 @@ async function readRecoveryStatusInSession(options, snapshot) {
1017
1339
  target.deploymentObservations = [...new Map(deployments.map((item) => [item.bindingId, item])).values()];
1018
1340
  target.content = ['conflict', 'drifted', 'absent', 'unknown'].find((state) => providers.some((item) => (item?.content ?? 'unknown') === state)) ?? 'satisfied';
1019
1341
  target.observation = target.content === 'satisfied' ? 'verified' : target.content === 'absent' ? 'missing' : 'unknown';
1020
- target.satisfaction = target.content === 'satisfied' ? demand.scope === 'project' && placement?.scope === 'user' ? 'inherited-user' : 'installed'
1021
- : target.content === 'unknown' ? 'unknown' : 'pending';
1342
+ target.satisfaction = observedSatisfaction(target.content, ownProvider, demand.scope === 'project' && placement?.scope === 'user');
1022
1343
  target.backend = providers.map((provider) => ({ pluginId: provider?.pluginId, scope: provider?.scope, content: provider?.content, live: provider?.backend }));
1023
1344
  }
1024
1345
  targetResults.push(target);
@@ -1026,13 +1347,12 @@ async function readRecoveryStatusInSession(options, snapshot) {
1026
1347
  visibleInventory.push({ pluginId: root.pluginId, source: root.sourceId, sourceState: root.sourceState,
1027
1348
  blockers: root.blockers.map(diagnostic), targetResults });
1028
1349
  }
1029
- const expected = new Set(plan.placements.map((item) => `${item.pluginId}\0${item.target}\0${item.scope}`));
1030
- const extraObserved = observed.flatMap((status) => status.extraObserved)
1350
+ const extraObserved = [...observed.flatMap((status) => status.extraObserved), ...surplusSkills]
1031
1351
  .filter((item) => !expected.has(`${item.pluginId}\0${item.agent}\0${item.scope}`));
1032
1352
  const targets = visibleInventory.flatMap((item) => item.targetResults);
1033
1353
  const globalTargets = targets.filter((target) => globalPlan.roots.some((root) => root.pluginId === target.pluginId && root.target === target.agent && root.scope === target.scope));
1034
1354
  const fullObservation = !selected || globalPlan.placements.every(selectedPlacement);
1035
- const knownFailure = globalPlan.errors.some((error) => ['targetsNotConfigured', 'dependencyExcluded', 'dependencyContractInvalid', 'targetPlacementConflict'].includes(error.code))
1355
+ const knownFailure = globalPlan.errors.some((error) => ['targetsNotConfigured', 'dependencyExcluded', 'dependencyContractInvalid', 'targetPlacementConflict', 'projectSkillProviderConflict', 'userSkillProviderNotReady'].includes(error.code))
1036
1356
  || globalTargets.some((target) => ['absent', 'drifted', 'conflict'].includes(target.content ?? 'unknown')
1037
1357
  || target.blockers.some((entry) => entry.code === 'awCapabilityUnsupported'));
1038
1358
  const uncertain = !fullObservation || !globalPlan.complete || globalTargets.some((target) => target.content === 'unknown' || target.blockers.length > 0);
@@ -1048,8 +1368,9 @@ async function readRecoveryStatusInSession(options, snapshot) {
1048
1368
  : scopes.some((demand) => demand.intent.state === 'unsupported-version') ? 'unsupported-version'
1049
1369
  : scopes.some((demand) => demand.intent.state === 'valid') ? 'valid' : 'absent' },
1050
1370
  selection: { agents: snapshot.preferences?.targets ?? [], origin: snapshot.preferences?.targets.length ? 'preference' : 'none', preferences: snapshot.user.preferences.state },
1051
- inventory: inventory === null ? null : visibleInventory, extraObserved, observedTargets: allTargets,
1371
+ inventory: inventory === null ? null : visibleInventory, extraObserved, observedTargets: allTargets, projectSkillProviders: skillProviders,
1052
1372
  existingTargets: observed.flatMap((status) => status.existingTargets ?? []), ownedTargets: observed.flatMap((status) => status.ownedTargets ?? []),
1373
+ retainedProjectPackages: observed.flatMap((status) => status.retainedProjectPackages ?? []),
1053
1374
  coverage: { native: nativeCoverage, portable: portableCoverage, scopes: snapshot.context.scopes,
1054
1375
  ...(snapshot.context.projectRoot ? { projectRoot: snapshot.context.projectRoot } : {}) },
1055
1376
  counts: { blocked: targets.filter((target) => target.blockers.length).length,
@@ -1064,8 +1385,7 @@ async function readRecoveryStatusInSession(options, snapshot) {
1064
1385
  visibleInventory.push({ pluginId: target.pluginId, source: parsePluginId(target.pluginId).sourceId, sourceState: 'ready', blockers: [],
1065
1386
  targetResults: allTargets.filter((entry) => entry.pluginId === target.pluginId).map((entry) => ({ ...entry,
1066
1387
  requirementScope: entry.contributions?.[0]?.scope,
1067
- satisfaction: entry.content === 'satisfied' ? entry.scope === 'user' && entry.contributions?.some((contribution) => contribution.scope === 'project')
1068
- ? 'inherited-user' : 'installed' : entry.content === 'unknown' ? 'unknown' : 'pending' })) });
1388
+ satisfaction: observedSatisfaction(entry.content, entry, entry.scope === 'user' && entry.contributions.some((contribution) => contribution.scope === 'project')) })) });
1069
1389
  }
1070
1390
  }
1071
1391
  if (selected) {