@lesliechan721/aw 0.1.0-beta.7 → 0.1.0-beta.73

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 (726) hide show
  1. package/dist/authoring/assets/aw-config.mjs +100 -501
  2. package/dist/authoring/assets/aw-config.mjs.map +1 -1
  3. package/dist/authoring/assets/aw-runtime-config.d.mts +13 -0
  4. package/dist/authoring/assets/aw-runtime-config.mjs +199 -0
  5. package/dist/authoring/assets/aw-runtime-config.mjs.map +1 -0
  6. package/dist/authoring/scripts/add-skill.mjs +13 -27
  7. package/dist/authoring/scripts/add-skill.mjs.map +1 -1
  8. package/dist/authoring/scripts/init-plugin.mjs +74 -103
  9. package/dist/authoring/scripts/init-plugin.mjs.map +1 -1
  10. package/dist/authoring/scripts/lib/plugin-root.mjs +4 -4
  11. package/dist/authoring/scripts/lib/plugin-root.mjs.map +1 -1
  12. package/dist/authoring/scripts/lib/plugin-version-check.d.mts +1 -0
  13. package/dist/authoring/scripts/lib/plugin-version-check.mjs +229 -8
  14. package/dist/authoring/scripts/lib/plugin-version-check.mjs.map +1 -1
  15. package/dist/authoring/scripts/lib/skill-scaffold.d.mts +79 -92
  16. package/dist/authoring/scripts/lib/skill-scaffold.mjs +103 -126
  17. package/dist/authoring/scripts/lib/skill-scaffold.mjs.map +1 -1
  18. package/dist/authoring/scripts/plugin-status.mjs +8 -11
  19. package/dist/authoring/scripts/plugin-status.mjs.map +1 -1
  20. package/dist/authoring/scripts/remove-plugin.mjs +3 -2
  21. package/dist/authoring/scripts/remove-plugin.mjs.map +1 -1
  22. package/dist/authoring/scripts/validate-plugin.mjs +527 -1673
  23. package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
  24. package/dist/authoring/scripts/validate-skill.mjs +1 -1
  25. package/dist/native-runtime/reader-runtime.mjs +34 -0
  26. package/dist/native-runtime/reader.d.mts +6 -0
  27. package/dist/native-runtime/reader.mjs +11 -0
  28. package/dist/scripts/aw-skill-eval-materializer.d.ts +28 -0
  29. package/dist/scripts/aw-skill-eval-materializer.js +339 -0
  30. package/dist/scripts/aw-skill-eval-materializer.js.map +1 -0
  31. package/dist/scripts/bundle-plugins.d.ts +1 -0
  32. package/dist/scripts/bundle-plugins.js +27 -8
  33. package/dist/scripts/bundle-plugins.js.map +1 -1
  34. package/dist/scripts/plugin-staging.d.ts +8 -10
  35. package/dist/scripts/plugin-staging.js +19 -30
  36. package/dist/scripts/plugin-staging.js.map +1 -1
  37. package/dist/scripts/plugin-test-reporter.d.mts +2 -0
  38. package/dist/scripts/plugin-test-reporter.mjs +21 -0
  39. package/dist/scripts/plugin-test-reporter.mjs.map +1 -0
  40. package/dist/scripts/test-plugin-scripts.d.ts +5 -0
  41. package/dist/scripts/test-plugin-scripts.js +246 -108
  42. package/dist/scripts/test-plugin-scripts.js.map +1 -1
  43. package/dist/scripts/test-workers.d.mts +24 -0
  44. package/dist/scripts/test-workers.mjs +59 -0
  45. package/dist/scripts/test-workers.mjs.map +1 -0
  46. package/dist/src/adapters/helpers.d.ts +7 -0
  47. package/dist/src/adapters/helpers.js +2 -2
  48. package/dist/src/adapters/helpers.js.map +1 -1
  49. package/dist/src/authoring/workspace-commands.d.ts +20 -1
  50. package/dist/src/authoring/workspace-commands.js +28 -6
  51. package/dist/src/authoring/workspace-commands.js.map +1 -1
  52. package/dist/src/commands/aw-capabilities.d.ts +78 -0
  53. package/dist/src/commands/aw-capabilities.js +270 -0
  54. package/dist/src/commands/aw-capabilities.js.map +1 -0
  55. package/dist/src/commands/catalog-dev-source.d.ts +157 -0
  56. package/dist/src/commands/catalog-dev-source.js +725 -0
  57. package/dist/src/commands/catalog-dev-source.js.map +1 -0
  58. package/dist/src/commands/catalog-generation.d.ts +21 -0
  59. package/dist/src/commands/catalog-generation.js +9 -0
  60. package/dist/src/commands/catalog-generation.js.map +1 -0
  61. package/dist/src/commands/catalog-publication-inspection.d.ts +71 -30
  62. package/dist/src/commands/catalog-publication-inspection.js +475 -63
  63. package/dist/src/commands/catalog-publication-inspection.js.map +1 -1
  64. package/dist/src/commands/catalog-publication-journal.d.ts +68 -0
  65. package/dist/src/commands/catalog-publication-journal.js +292 -0
  66. package/dist/src/commands/catalog-publication-journal.js.map +1 -0
  67. package/dist/src/commands/catalog-publication-target.d.ts +18 -0
  68. package/dist/src/commands/catalog-publication-target.js +95 -0
  69. package/dist/src/commands/catalog-publication-target.js.map +1 -0
  70. package/dist/src/commands/catalog-publish.d.ts +89 -15
  71. package/dist/src/commands/catalog-publish.js +736 -210
  72. package/dist/src/commands/catalog-publish.js.map +1 -1
  73. package/dist/src/commands/catalog-source.d.ts +64 -22
  74. package/dist/src/commands/catalog-source.js +327 -91
  75. package/dist/src/commands/catalog-source.js.map +1 -1
  76. package/dist/src/commands/catalog-status.d.ts +18 -22
  77. package/dist/src/commands/catalog-status.js +82 -116
  78. package/dist/src/commands/catalog-status.js.map +1 -1
  79. package/dist/src/commands/catalog-store.d.ts +104 -0
  80. package/dist/src/commands/catalog-store.js +685 -0
  81. package/dist/src/commands/catalog-store.js.map +1 -0
  82. package/dist/src/commands/catalog-workspace-resolution.d.ts +17 -0
  83. package/dist/src/commands/catalog-workspace-resolution.js +57 -0
  84. package/dist/src/commands/catalog-workspace-resolution.js.map +1 -0
  85. package/dist/src/commands/console.js +32 -20
  86. package/dist/src/commands/console.js.map +1 -1
  87. package/dist/src/commands/dependency-operation-plan.d.ts +52 -15
  88. package/dist/src/commands/dependency-operation-plan.js +289 -7
  89. package/dist/src/commands/dependency-operation-plan.js.map +1 -1
  90. package/dist/src/commands/init.d.ts +5 -11
  91. package/dist/src/commands/init.js +30 -51
  92. package/dist/src/commands/init.js.map +1 -1
  93. package/dist/src/commands/intent-command.d.ts +32 -0
  94. package/dist/src/commands/intent-command.js +171 -0
  95. package/dist/src/commands/intent-command.js.map +1 -0
  96. package/dist/src/commands/managed-commands.d.ts +35 -0
  97. package/dist/src/commands/managed-commands.js +359 -0
  98. package/dist/src/commands/managed-commands.js.map +1 -0
  99. package/dist/src/commands/offline-cleanup-evidence.d.ts +67 -0
  100. package/dist/src/commands/offline-cleanup-evidence.js +181 -0
  101. package/dist/src/commands/offline-cleanup-evidence.js.map +1 -0
  102. package/dist/src/commands/operation-plan.d.ts +184 -0
  103. package/dist/src/commands/operation-plan.js +72 -0
  104. package/dist/src/commands/operation-plan.js.map +1 -0
  105. package/dist/src/commands/operation-planner.d.ts +47 -0
  106. package/dist/src/commands/operation-planner.js +142 -0
  107. package/dist/src/commands/operation-planner.js.map +1 -0
  108. package/dist/src/commands/options.d.ts +10 -17
  109. package/dist/src/commands/options.js +91 -38
  110. package/dist/src/commands/options.js.map +1 -1
  111. package/dist/src/commands/plugin-capabilities.js +85 -30
  112. package/dist/src/commands/plugin-capabilities.js.map +1 -1
  113. package/dist/src/commands/public-config-confirmation.d.ts +8 -0
  114. package/dist/src/commands/public-config-confirmation.js +56 -0
  115. package/dist/src/commands/public-config-confirmation.js.map +1 -0
  116. package/dist/src/commands/public-interruption.d.ts +9 -0
  117. package/dist/src/commands/public-interruption.js +23 -0
  118. package/dist/src/commands/public-interruption.js.map +1 -0
  119. package/dist/src/commands/public-lifecycle-result.d.ts +53 -0
  120. package/dist/src/commands/public-lifecycle-result.js +102 -0
  121. package/dist/src/commands/public-lifecycle-result.js.map +1 -0
  122. package/dist/src/commands/public-lifecycle.d.ts +27 -0
  123. package/dist/src/commands/public-lifecycle.js +479 -0
  124. package/dist/src/commands/public-lifecycle.js.map +1 -0
  125. package/dist/src/commands/public-plugin-query.d.ts +15 -0
  126. package/dist/src/commands/public-plugin-query.js +154 -0
  127. package/dist/src/commands/public-plugin-query.js.map +1 -0
  128. package/dist/src/commands/rebuild-command.d.ts +177 -29
  129. package/dist/src/commands/rebuild-command.js +4113 -745
  130. package/dist/src/commands/rebuild-command.js.map +1 -1
  131. package/dist/src/commands/rebuild-integration.d.ts +163 -22
  132. package/dist/src/commands/rebuild-integration.js +3553 -1456
  133. package/dist/src/commands/rebuild-integration.js.map +1 -1
  134. package/dist/src/commands/rebuild-operations.d.ts +60 -30
  135. package/dist/src/commands/rebuild-operations.js +266 -320
  136. package/dist/src/commands/rebuild-operations.js.map +1 -1
  137. package/dist/src/commands/reconcile-operation-plan.d.ts +28 -0
  138. package/dist/src/commands/reconcile-operation-plan.js +47 -0
  139. package/dist/src/commands/reconcile-operation-plan.js.map +1 -0
  140. package/dist/src/commands/review-inspection.d.ts +60 -0
  141. package/dist/src/commands/review-inspection.js +399 -0
  142. package/dist/src/commands/review-inspection.js.map +1 -0
  143. package/dist/src/commands/review-preparation.d.ts +49 -0
  144. package/dist/src/commands/review-preparation.js +437 -0
  145. package/dist/src/commands/review-preparation.js.map +1 -0
  146. package/dist/src/commands/runtime.d.ts +5 -5
  147. package/dist/src/commands/runtime.js +42 -54
  148. package/dist/src/commands/runtime.js.map +1 -1
  149. package/dist/src/commands/skill-eval.d.ts +41 -0
  150. package/dist/src/commands/skill-eval.js +406 -0
  151. package/dist/src/commands/skill-eval.js.map +1 -0
  152. package/dist/src/commands/status-v6.d.ts +317 -0
  153. package/dist/src/commands/status-v6.js +2970 -0
  154. package/dist/src/commands/status-v6.js.map +1 -0
  155. package/dist/src/commands/targets-command.d.ts +29 -0
  156. package/dist/src/commands/targets-command.js +131 -0
  157. package/dist/src/commands/targets-command.js.map +1 -0
  158. package/dist/src/commands/wizard.d.ts +8 -5
  159. package/dist/src/commands/wizard.js +6 -4
  160. package/dist/src/commands/wizard.js.map +1 -1
  161. package/dist/src/commands/write-commands.d.ts +9 -3
  162. package/dist/src/commands/write-commands.js +129 -30
  163. package/dist/src/commands/write-commands.js.map +1 -1
  164. package/dist/src/constants.d.ts +7 -2
  165. package/dist/src/constants.js +7 -2
  166. package/dist/src/constants.js.map +1 -1
  167. package/dist/src/eval/manifest-v1.d.ts +70 -0
  168. package/dist/src/eval/manifest-v1.js +358 -0
  169. package/dist/src/eval/manifest-v1.js.map +1 -0
  170. package/dist/src/generators/local-plugin.d.ts +7 -2
  171. package/dist/src/generators/local-plugin.js +377 -210
  172. package/dist/src/generators/local-plugin.js.map +1 -1
  173. package/dist/src/generators/permissions.d.ts +5 -2
  174. package/dist/src/generators/permissions.js +28 -15
  175. package/dist/src/generators/permissions.js.map +1 -1
  176. package/dist/src/index.d.ts +1 -27
  177. package/dist/src/index.js +1880 -1592
  178. package/dist/src/index.js.map +1 -1
  179. package/dist/src/intent/deployment-preferences.d.ts +63 -0
  180. package/dist/src/intent/deployment-preferences.js +170 -0
  181. package/dist/src/intent/deployment-preferences.js.map +1 -0
  182. package/dist/src/intent/diagnostics.d.ts +11 -0
  183. package/dist/src/intent/diagnostics.js +14 -0
  184. package/dist/src/intent/diagnostics.js.map +1 -0
  185. package/dist/src/intent/intent-codec.d.ts +19 -0
  186. package/dist/src/intent/intent-codec.js +117 -0
  187. package/dist/src/intent/intent-codec.js.map +1 -0
  188. package/dist/src/intent/intent-store.d.ts +43 -0
  189. package/dist/src/intent/intent-store.js +118 -0
  190. package/dist/src/intent/intent-store.js.map +1 -0
  191. package/dist/src/intent/scope-context.d.ts +33 -0
  192. package/dist/src/intent/scope-context.js +149 -0
  193. package/dist/src/intent/scope-context.js.map +1 -0
  194. package/dist/src/intent/work-context.d.ts +13 -0
  195. package/dist/src/intent/work-context.js +22 -0
  196. package/dist/src/intent/work-context.js.map +1 -0
  197. package/dist/src/output/command-receipt.d.ts +47 -46
  198. package/dist/src/output/command-receipt.js +284 -79
  199. package/dist/src/output/command-receipt.js.map +1 -1
  200. package/dist/src/output/model.d.ts +3 -44
  201. package/dist/src/output/model.js +1 -144
  202. package/dist/src/output/model.js.map +1 -1
  203. package/dist/src/output/public-result.d.ts +43 -0
  204. package/dist/src/output/public-result.js +139 -0
  205. package/dist/src/output/public-result.js.map +1 -0
  206. package/dist/src/output/rebuild-progress.js +15 -13
  207. package/dist/src/output/rebuild-progress.js.map +1 -1
  208. package/dist/src/output/receipt-projection.d.ts +7 -0
  209. package/dist/src/output/receipt-projection.js +575 -0
  210. package/dist/src/output/receipt-projection.js.map +1 -0
  211. package/dist/src/portable/commands.d.ts +59 -10
  212. package/dist/src/portable/commands.js +98 -302
  213. package/dist/src/portable/commands.js.map +1 -1
  214. package/dist/src/portable/historical-materialization.d.ts +22 -0
  215. package/dist/src/portable/historical-materialization.js +124 -0
  216. package/dist/src/portable/historical-materialization.js.map +1 -0
  217. package/dist/src/portable/materializer.d.ts +25 -4
  218. package/dist/src/portable/materializer.js +247 -68
  219. package/dist/src/portable/materializer.js.map +1 -1
  220. package/dist/src/portable/recovery-layout.d.ts +17 -0
  221. package/dist/src/portable/recovery-layout.js +55 -0
  222. package/dist/src/portable/recovery-layout.js.map +1 -0
  223. package/dist/src/portable/recovery.d.ts +143 -0
  224. package/dist/src/portable/recovery.js +339 -0
  225. package/dist/src/portable/recovery.js.map +1 -0
  226. package/dist/src/portable/writer.d.ts +64 -0
  227. package/dist/src/portable/writer.js +316 -0
  228. package/dist/src/portable/writer.js.map +1 -0
  229. package/dist/src/recovery/coordinator.d.ts +144 -0
  230. package/dist/src/recovery/coordinator.js +1201 -0
  231. package/dist/src/recovery/coordinator.js.map +1 -0
  232. package/dist/src/recovery/demand.d.ts +44 -0
  233. package/dist/src/recovery/demand.js +178 -0
  234. package/dist/src/recovery/demand.js.map +1 -0
  235. package/dist/src/recovery/joint-coordinator.d.ts +25 -0
  236. package/dist/src/recovery/joint-coordinator.js +931 -0
  237. package/dist/src/recovery/joint-coordinator.js.map +1 -0
  238. package/dist/src/recovery/joint-demand.d.ts +68 -0
  239. package/dist/src/recovery/joint-demand.js +166 -0
  240. package/dist/src/recovery/joint-demand.js.map +1 -0
  241. package/dist/src/recovery/performance.d.ts +4 -0
  242. package/dist/src/recovery/performance.js +26 -0
  243. package/dist/src/recovery/performance.js.map +1 -0
  244. package/dist/src/recovery/receipt.d.ts +81 -0
  245. package/dist/src/recovery/receipt.js +2 -0
  246. package/dist/src/recovery/receipt.js.map +1 -0
  247. package/dist/src/recovery/retirement.d.ts +47 -0
  248. package/dist/src/recovery/retirement.js +367 -0
  249. package/dist/src/recovery/retirement.js.map +1 -0
  250. package/dist/src/recovery/status.d.ts +109 -0
  251. package/dist/src/recovery/status.js +418 -0
  252. package/dist/src/recovery/status.js.map +1 -0
  253. package/dist/src/recovery/types.d.ts +86 -0
  254. package/dist/src/recovery/types.js +2 -0
  255. package/dist/src/recovery/types.js.map +1 -0
  256. package/dist/src/review/eval-source-input.d.ts +43 -0
  257. package/dist/src/review/eval-source-input.js +207 -0
  258. package/dist/src/review/eval-source-input.js.map +1 -0
  259. package/dist/src/review/review-profile.d.ts +19 -0
  260. package/dist/src/review/review-profile.js +270 -0
  261. package/dist/src/review/review-profile.js.map +1 -0
  262. package/dist/src/review/review-selection.d.ts +29 -0
  263. package/dist/src/review/review-selection.js +469 -0
  264. package/dist/src/review/review-selection.js.map +1 -0
  265. package/dist/src/review/review-types.d.ts +68 -0
  266. package/dist/src/review/review-types.js +16 -0
  267. package/dist/src/review/review-types.js.map +1 -0
  268. package/dist/src/review/skill-materialization.d.ts +27 -0
  269. package/dist/src/review/skill-materialization.js +228 -0
  270. package/dist/src/review/skill-materialization.js.map +1 -0
  271. package/dist/src/review/source-binding.d.ts +198 -0
  272. package/dist/src/review/source-binding.js +714 -0
  273. package/dist/src/review/source-binding.js.map +1 -0
  274. package/dist/src/tui/agent-management.d.ts +23 -0
  275. package/dist/src/tui/agent-management.js +217 -0
  276. package/dist/src/tui/agent-management.js.map +1 -0
  277. package/dist/src/tui/agent-settings.d.ts +44 -0
  278. package/dist/src/tui/agent-settings.js +98 -0
  279. package/dist/src/tui/agent-settings.js.map +1 -0
  280. package/dist/src/tui/catalog-freshness.d.ts +1 -0
  281. package/dist/src/tui/catalog-freshness.js +2 -0
  282. package/dist/src/tui/catalog-freshness.js.map +1 -0
  283. package/dist/src/tui/catalog-generation.d.ts +21 -0
  284. package/dist/src/tui/catalog-generation.js +156 -0
  285. package/dist/src/tui/catalog-generation.js.map +1 -0
  286. package/dist/src/tui/catalog-sources/projection.d.ts +4 -0
  287. package/dist/src/tui/catalog-sources/projection.js +17 -0
  288. package/dist/src/tui/catalog-sources/projection.js.map +1 -0
  289. package/dist/src/tui/catalog-sources/review.d.ts +3 -0
  290. package/dist/src/tui/catalog-sources/review.js +13 -0
  291. package/dist/src/tui/catalog-sources/review.js.map +1 -0
  292. package/dist/src/tui/catalog-sources/screens.d.ts +12 -0
  293. package/dist/src/tui/catalog-sources/screens.js +40 -0
  294. package/dist/src/tui/catalog-sources/screens.js.map +1 -0
  295. package/dist/src/tui/catalog-sources/session.d.ts +32 -0
  296. package/dist/src/tui/catalog-sources/session.js +300 -0
  297. package/dist/src/tui/catalog-sources/session.js.map +1 -0
  298. package/dist/src/tui/catalog-sources/types.d.ts +54 -0
  299. package/dist/src/tui/catalog-sources/types.js +2 -0
  300. package/dist/src/tui/catalog-sources/types.js.map +1 -0
  301. package/dist/src/tui/catalog-store-task.d.ts +16 -0
  302. package/dist/src/tui/catalog-store-task.js +19 -0
  303. package/dist/src/tui/catalog-store-task.js.map +1 -0
  304. package/dist/src/tui/clipboard.d.ts +13 -0
  305. package/dist/src/tui/clipboard.js +95 -0
  306. package/dist/src/tui/clipboard.js.map +1 -0
  307. package/dist/src/tui/components.d.ts +113 -3
  308. package/dist/src/tui/components.js +192 -36
  309. package/dist/src/tui/components.js.map +1 -1
  310. package/dist/src/tui/config-array-draft.d.ts +29 -0
  311. package/dist/src/tui/config-array-draft.js +48 -0
  312. package/dist/src/tui/config-array-draft.js.map +1 -0
  313. package/dist/src/tui/config-leaf-editor.d.ts +43 -0
  314. package/dist/src/tui/config-leaf-editor.js +224 -0
  315. package/dist/src/tui/config-leaf-editor.js.map +1 -0
  316. package/dist/src/tui/config-references.d.ts +38 -0
  317. package/dist/src/tui/config-references.js +82 -0
  318. package/dist/src/tui/config-references.js.map +1 -0
  319. package/dist/src/tui/config-value-presentation.d.ts +20 -0
  320. package/dist/src/tui/config-value-presentation.js +104 -0
  321. package/dist/src/tui/config-value-presentation.js.map +1 -0
  322. package/dist/src/tui/console-app-v4.d.ts +13 -4
  323. package/dist/src/tui/console-app-v4.js +9788 -1952
  324. package/dist/src/tui/console-app-v4.js.map +1 -1
  325. package/dist/src/tui/content-item-card.d.ts +13 -0
  326. package/dist/src/tui/content-item-card.js +51 -0
  327. package/dist/src/tui/content-item-card.js.map +1 -0
  328. package/dist/src/tui/controller-runtime.d.ts +11 -2
  329. package/dist/src/tui/controller-runtime.js +2224 -471
  330. package/dist/src/tui/controller-runtime.js.map +1 -1
  331. package/dist/src/tui/controller.d.ts +698 -66
  332. package/dist/src/tui/controller.js +3695 -778
  333. package/dist/src/tui/controller.js.map +1 -1
  334. package/dist/src/tui/dependency-graph-view.d.ts +39 -0
  335. package/dist/src/tui/dependency-graph-view.js +121 -0
  336. package/dist/src/tui/dependency-graph-view.js.map +1 -0
  337. package/dist/src/tui/dependency-graph.d.ts +81 -0
  338. package/dist/src/tui/dependency-graph.js +452 -0
  339. package/dist/src/tui/dependency-graph.js.map +1 -0
  340. package/dist/src/tui/diagnostic-projection.d.ts +23 -0
  341. package/dist/src/tui/diagnostic-projection.js +595 -0
  342. package/dist/src/tui/diagnostic-projection.js.map +1 -0
  343. package/dist/src/tui/diagnostics.d.ts +3 -3
  344. package/dist/src/tui/diagnostics.js +14 -2
  345. package/dist/src/tui/diagnostics.js.map +1 -1
  346. package/dist/src/tui/entity-cards.d.ts +55 -0
  347. package/dist/src/tui/entity-cards.js +298 -0
  348. package/dist/src/tui/entity-cards.js.map +1 -0
  349. package/dist/src/tui/glossary.d.ts +25 -0
  350. package/dist/src/tui/glossary.js +62 -0
  351. package/dist/src/tui/glossary.js.map +1 -0
  352. package/dist/src/tui/index.d.ts +6 -1
  353. package/dist/src/tui/index.js +5 -1
  354. package/dist/src/tui/index.js.map +1 -1
  355. package/dist/src/tui/input-display.d.ts +9 -0
  356. package/dist/src/tui/input-display.js +58 -0
  357. package/dist/src/tui/input-display.js.map +1 -0
  358. package/dist/src/tui/keys.d.ts +44 -0
  359. package/dist/src/tui/keys.js +43 -15
  360. package/dist/src/tui/keys.js.map +1 -1
  361. package/dist/src/tui/lifecycle-action-view.d.ts +6 -0
  362. package/dist/src/tui/lifecycle-action-view.js +36 -0
  363. package/dist/src/tui/lifecycle-action-view.js.map +1 -0
  364. package/dist/src/tui/model.d.ts +246 -35
  365. package/dist/src/tui/model.js +1514 -401
  366. package/dist/src/tui/model.js.map +1 -1
  367. package/dist/src/tui/operation-diagnostic-screens.d.ts +8 -0
  368. package/dist/src/tui/operation-diagnostic-screens.js +71 -0
  369. package/dist/src/tui/operation-diagnostic-screens.js.map +1 -0
  370. package/dist/src/tui/operation-history.d.ts +81 -0
  371. package/dist/src/tui/operation-history.js +136 -0
  372. package/dist/src/tui/operation-history.js.map +1 -0
  373. package/dist/src/tui/operation-review-planner.d.ts +23 -0
  374. package/dist/src/tui/operation-review-planner.js +1341 -0
  375. package/dist/src/tui/operation-review-planner.js.map +1 -0
  376. package/dist/src/tui/plugin-content.d.ts +31 -0
  377. package/dist/src/tui/plugin-content.js +683 -0
  378. package/dist/src/tui/plugin-content.js.map +1 -0
  379. package/dist/src/tui/plugin-detail.d.ts +71 -0
  380. package/dist/src/tui/plugin-detail.js +252 -0
  381. package/dist/src/tui/plugin-detail.js.map +1 -0
  382. package/dist/src/tui/plugin-write-task.d.ts +69 -0
  383. package/dist/src/tui/plugin-write-task.js +286 -0
  384. package/dist/src/tui/plugin-write-task.js.map +1 -0
  385. package/dist/src/tui/prompt.js +4 -15
  386. package/dist/src/tui/prompt.js.map +1 -1
  387. package/dist/src/tui/query-header.d.ts +30 -0
  388. package/dist/src/tui/query-header.js +40 -0
  389. package/dist/src/tui/query-header.js.map +1 -0
  390. package/dist/src/tui/reader.d.ts +38 -0
  391. package/dist/src/tui/reader.js +49 -0
  392. package/dist/src/tui/reader.js.map +1 -0
  393. package/dist/src/tui/router.d.ts +194 -17
  394. package/dist/src/tui/router.js +338 -50
  395. package/dist/src/tui/router.js.map +1 -1
  396. package/dist/src/tui/scoped-flow.d.ts +45 -0
  397. package/dist/src/tui/scoped-flow.js +96 -0
  398. package/dist/src/tui/scoped-flow.js.map +1 -0
  399. package/dist/src/tui/scoped-inventory.d.ts +122 -0
  400. package/dist/src/tui/scoped-inventory.js +225 -0
  401. package/dist/src/tui/scoped-inventory.js.map +1 -0
  402. package/dist/src/tui/screen-registry.d.ts +701 -0
  403. package/dist/src/tui/screen-registry.js +226 -0
  404. package/dist/src/tui/screen-registry.js.map +1 -0
  405. package/dist/src/tui/session-console-app.d.ts +6 -0
  406. package/dist/src/tui/session-console-app.js +13 -0
  407. package/dist/src/tui/session-console-app.js.map +1 -0
  408. package/dist/src/tui/session-host.d.ts +45 -0
  409. package/dist/src/tui/session-host.js +219 -0
  410. package/dist/src/tui/session-host.js.map +1 -0
  411. package/dist/src/tui/source-detail-card.d.ts +29 -0
  412. package/dist/src/tui/source-detail-card.js +45 -0
  413. package/dist/src/tui/source-detail-card.js.map +1 -0
  414. package/dist/src/tui/source-ref-presets.d.ts +3 -0
  415. package/dist/src/tui/source-ref-presets.js +11 -0
  416. package/dist/src/tui/source-ref-presets.js.map +1 -0
  417. package/dist/src/tui/theme.d.ts +12 -0
  418. package/dist/src/tui/theme.js +12 -0
  419. package/dist/src/tui/theme.js.map +1 -1
  420. package/dist/src/tui/viewport.d.ts +1 -0
  421. package/dist/src/tui/viewport.js +23 -0
  422. package/dist/src/tui/viewport.js.map +1 -1
  423. package/dist/src/tui/views.js +31 -3
  424. package/dist/src/tui/views.js.map +1 -1
  425. package/dist/src/tui/wizard.js +37 -13
  426. package/dist/src/tui/wizard.js.map +1 -1
  427. package/dist/src/types.d.ts +268 -23
  428. package/dist/src/types.js +1 -0
  429. package/dist/src/types.js.map +1 -1
  430. package/dist/src/utils/agent-version.d.ts +7 -1
  431. package/dist/src/utils/agent-version.js +38 -7
  432. package/dist/src/utils/agent-version.js.map +1 -1
  433. package/dist/src/utils/artifact-plan.d.ts +8 -6
  434. package/dist/src/utils/artifact-plan.js +80 -19
  435. package/dist/src/utils/artifact-plan.js.map +1 -1
  436. package/dist/src/utils/artifact-renderer.d.ts +35 -11
  437. package/dist/src/utils/artifact-renderer.js +250 -227
  438. package/dist/src/utils/artifact-renderer.js.map +1 -1
  439. package/dist/src/utils/artifact-request.d.ts +33 -0
  440. package/dist/src/utils/artifact-request.js +100 -0
  441. package/dist/src/utils/artifact-request.js.map +1 -0
  442. package/dist/src/utils/artifact-sources.d.ts +6 -2
  443. package/dist/src/utils/artifact-sources.js +17 -0
  444. package/dist/src/utils/artifact-sources.js.map +1 -1
  445. package/dist/src/utils/aw-home-mutation-lock.d.ts +1 -0
  446. package/dist/src/utils/aw-home-mutation-lock.js +32 -4
  447. package/dist/src/utils/aw-home-mutation-lock.js.map +1 -1
  448. package/dist/src/utils/bundle-integrity.d.ts +0 -1
  449. package/dist/src/utils/bundle-integrity.js +0 -25
  450. package/dist/src/utils/bundle-integrity.js.map +1 -1
  451. package/dist/src/utils/bundle-layout.js +47 -45
  452. package/dist/src/utils/bundle-layout.js.map +1 -1
  453. package/dist/src/utils/catalog-capability-projection.d.ts +8 -0
  454. package/dist/src/utils/catalog-capability-projection.js +14 -0
  455. package/dist/src/utils/catalog-capability-projection.js.map +1 -0
  456. package/dist/src/utils/catalog-digests.d.ts +10 -0
  457. package/dist/src/utils/catalog-digests.js +59 -20
  458. package/dist/src/utils/catalog-digests.js.map +1 -1
  459. package/dist/src/utils/catalog-generation-control-snapshot.d.ts +11 -0
  460. package/dist/src/utils/catalog-generation-control-snapshot.js +45 -0
  461. package/dist/src/utils/catalog-generation-control-snapshot.js.map +1 -0
  462. package/dist/src/utils/catalog-generation-error.d.ts +16 -0
  463. package/dist/src/utils/catalog-generation-error.js +30 -0
  464. package/dist/src/utils/catalog-generation-error.js.map +1 -0
  465. package/dist/src/utils/catalog-generation-resolver.d.ts +44 -0
  466. package/dist/src/utils/catalog-generation-resolver.js +273 -0
  467. package/dist/src/utils/catalog-generation-resolver.js.map +1 -0
  468. package/dist/src/utils/catalog-generation-service.d.ts +183 -0
  469. package/dist/src/utils/catalog-generation-service.js +1281 -0
  470. package/dist/src/utils/catalog-generation-service.js.map +1 -0
  471. package/dist/src/utils/catalog-generation-state.d.ts +22 -0
  472. package/dist/src/utils/catalog-generation-state.js +192 -0
  473. package/dist/src/utils/catalog-generation-state.js.map +1 -0
  474. package/dist/src/utils/catalog-generation-store.d.ts +58 -0
  475. package/dist/src/utils/catalog-generation-store.js +452 -0
  476. package/dist/src/utils/catalog-generation-store.js.map +1 -0
  477. package/dist/src/utils/catalog-manifest-v7.d.ts +5 -0
  478. package/dist/src/utils/{catalog-manifest-v4.js → catalog-manifest-v7.js} +35 -43
  479. package/dist/src/utils/catalog-manifest-v7.js.map +1 -0
  480. package/dist/src/utils/catalog-operation-context.d.ts +20 -0
  481. package/dist/src/utils/catalog-operation-context.js +142 -0
  482. package/dist/src/utils/catalog-operation-context.js.map +1 -0
  483. package/dist/src/utils/catalog-public-error.d.ts +7 -3
  484. package/dist/src/utils/catalog-public-error.js +28 -8
  485. package/dist/src/utils/catalog-public-error.js.map +1 -1
  486. package/dist/src/utils/catalog-runtime-projection.d.ts +7 -3
  487. package/dist/src/utils/catalog-runtime-projection.js +5 -40
  488. package/dist/src/utils/catalog-runtime-projection.js.map +1 -1
  489. package/dist/src/utils/catalog-snapshot.d.ts +5 -3
  490. package/dist/src/utils/catalog-snapshot.js +11 -3
  491. package/dist/src/utils/catalog-snapshot.js.map +1 -1
  492. package/dist/src/utils/catalog-source-identity.d.ts +1 -0
  493. package/dist/src/utils/catalog-source-identity.js +21 -2
  494. package/dist/src/utils/catalog-source-identity.js.map +1 -1
  495. package/dist/src/utils/catalog-source-impact.d.ts +21 -0
  496. package/dist/src/utils/catalog-source-impact.js +344 -0
  497. package/dist/src/utils/catalog-source-impact.js.map +1 -0
  498. package/dist/src/utils/catalog-source-references.d.ts +8 -2
  499. package/dist/src/utils/catalog-source-references.js +200 -367
  500. package/dist/src/utils/catalog-source-references.js.map +1 -1
  501. package/dist/src/utils/catalog-sources.d.ts +15 -1
  502. package/dist/src/utils/catalog-sources.js +206 -27
  503. package/dist/src/utils/catalog-sources.js.map +1 -1
  504. package/dist/src/utils/claude-native-render-receipt.d.ts +14 -0
  505. package/dist/src/utils/claude-native-render-receipt.js +26 -0
  506. package/dist/src/utils/claude-native-render-receipt.js.map +1 -0
  507. package/dist/src/utils/claude-skills-root.d.ts +8 -0
  508. package/dist/src/utils/claude-skills-root.js +87 -0
  509. package/dist/src/utils/claude-skills-root.js.map +1 -0
  510. package/dist/src/utils/codex-config.d.ts +2 -0
  511. package/dist/src/utils/codex-config.js +26 -5
  512. package/dist/src/utils/codex-config.js.map +1 -1
  513. package/dist/src/utils/codex-executable-discovery.d.ts +26 -0
  514. package/dist/src/utils/codex-executable-discovery.js +397 -0
  515. package/dist/src/utils/codex-executable-discovery.js.map +1 -0
  516. package/dist/src/utils/codex-manager.d.ts +62 -0
  517. package/dist/src/utils/codex-manager.js +122 -0
  518. package/dist/src/utils/codex-manager.js.map +1 -0
  519. package/dist/src/utils/codex-marketplace-path.d.ts +5 -0
  520. package/dist/src/utils/codex-marketplace-path.js +45 -0
  521. package/dist/src/utils/codex-marketplace-path.js.map +1 -0
  522. package/dist/src/utils/codex-native-observation.d.ts +49 -0
  523. package/dist/src/utils/codex-native-observation.js +169 -0
  524. package/dist/src/utils/codex-native-observation.js.map +1 -0
  525. package/dist/src/utils/codex-native-render-receipt.d.ts +40 -0
  526. package/dist/src/utils/codex-native-render-receipt.js +205 -0
  527. package/dist/src/utils/codex-native-render-receipt.js.map +1 -0
  528. package/dist/src/utils/codex-reconciler.d.ts +123 -0
  529. package/dist/src/utils/codex-reconciler.js +322 -0
  530. package/dist/src/utils/codex-reconciler.js.map +1 -0
  531. package/dist/src/utils/codex-shared-native.d.ts +43 -0
  532. package/dist/src/utils/codex-shared-native.js +81 -0
  533. package/dist/src/utils/codex-shared-native.js.map +1 -0
  534. package/dist/src/utils/codex-skill-staging.d.ts +2 -0
  535. package/dist/src/utils/codex-skill-staging.js.map +1 -1
  536. package/dist/src/utils/codex-skills-root.d.ts +4 -0
  537. package/dist/src/utils/codex-skills-root.js +25 -0
  538. package/dist/src/utils/codex-skills-root.js.map +1 -0
  539. package/dist/src/utils/codex-surface-analysis.d.ts +46 -0
  540. package/dist/src/utils/codex-surface-analysis.js +249 -0
  541. package/dist/src/utils/codex-surface-analysis.js.map +1 -0
  542. package/dist/src/utils/dynamic-skill-tree.d.ts +5 -0
  543. package/dist/src/utils/dynamic-skill-tree.js +56 -7
  544. package/dist/src/utils/dynamic-skill-tree.js.map +1 -1
  545. package/dist/src/utils/git-catalog-provider.d.ts +16 -0
  546. package/dist/src/utils/git-catalog-provider.js +177 -145
  547. package/dist/src/utils/git-catalog-provider.js.map +1 -1
  548. package/dist/src/utils/local-marketplace.d.ts +39 -1
  549. package/dist/src/utils/local-marketplace.js +601 -84
  550. package/dist/src/utils/local-marketplace.js.map +1 -1
  551. package/dist/src/utils/managed-command-closure.d.ts +3 -0
  552. package/dist/src/utils/managed-command-closure.js +35 -0
  553. package/dist/src/utils/managed-command-closure.js.map +1 -0
  554. package/dist/src/utils/managed-command-evidence.d.ts +7 -0
  555. package/dist/src/utils/managed-command-evidence.js +86 -0
  556. package/dist/src/utils/managed-command-evidence.js.map +1 -0
  557. package/dist/src/utils/managed-command-materialization.d.ts +121 -0
  558. package/dist/src/utils/managed-command-materialization.js +369 -0
  559. package/dist/src/utils/managed-command-materialization.js.map +1 -0
  560. package/dist/src/utils/managed-command-runtime.d.ts +33 -0
  561. package/dist/src/utils/managed-command-runtime.js +121 -0
  562. package/dist/src/utils/managed-command-runtime.js.map +1 -0
  563. package/dist/src/utils/managed-command-store.d.ts +143 -0
  564. package/dist/src/utils/managed-command-store.js +654 -0
  565. package/dist/src/utils/managed-command-store.js.map +1 -0
  566. package/dist/src/utils/manifest.d.ts +1 -3
  567. package/dist/src/utils/manifest.js +1 -3
  568. package/dist/src/utils/manifest.js.map +1 -1
  569. package/dist/src/utils/multi-source-catalog.d.ts +3 -9
  570. package/dist/src/utils/multi-source-catalog.js +54 -110
  571. package/dist/src/utils/multi-source-catalog.js.map +1 -1
  572. package/dist/src/utils/native-cli.d.ts +62 -7
  573. package/dist/src/utils/native-cli.js +449 -58
  574. package/dist/src/utils/native-cli.js.map +1 -1
  575. package/dist/src/utils/native-demand.d.ts +10 -0
  576. package/dist/src/utils/native-demand.js +4 -0
  577. package/dist/src/utils/native-demand.js.map +1 -0
  578. package/dist/src/utils/native-tool-context.d.ts +14 -0
  579. package/dist/src/utils/native-tool-context.js +38 -0
  580. package/dist/src/utils/native-tool-context.js.map +1 -0
  581. package/dist/src/utils/native-tool-review.d.ts +21 -0
  582. package/dist/src/utils/native-tool-review.js +102 -0
  583. package/dist/src/utils/native-tool-review.js.map +1 -0
  584. package/dist/src/utils/orphan-marketplace-cleanup.js +0 -4
  585. package/dist/src/utils/orphan-marketplace-cleanup.js.map +1 -1
  586. package/dist/src/utils/ownership.d.ts +88 -20
  587. package/dist/src/utils/ownership.js +187 -223
  588. package/dist/src/utils/ownership.js.map +1 -1
  589. package/dist/src/utils/path-catalog-provider.d.ts +1 -1
  590. package/dist/src/utils/path-catalog-provider.js +54 -65
  591. package/dist/src/utils/path-catalog-provider.js.map +1 -1
  592. package/dist/src/utils/paths.d.ts +0 -1
  593. package/dist/src/utils/paths.js +1 -2
  594. package/dist/src/utils/paths.js.map +1 -1
  595. package/dist/src/utils/platform-support.d.ts +1 -1
  596. package/dist/src/utils/platform-support.js +1 -1
  597. package/dist/src/utils/platform-support.js.map +1 -1
  598. package/dist/src/utils/plugin-config-impact.d.ts +58 -0
  599. package/dist/src/utils/plugin-config-impact.js +323 -0
  600. package/dist/src/utils/plugin-config-impact.js.map +1 -0
  601. package/dist/src/utils/plugin-config-references.d.ts +89 -0
  602. package/dist/src/utils/plugin-config-references.js +335 -0
  603. package/dist/src/utils/plugin-config-references.js.map +1 -0
  604. package/dist/src/utils/plugin-config-write.d.ts +109 -27
  605. package/dist/src/utils/plugin-config-write.js +1246 -368
  606. package/dist/src/utils/plugin-config-write.js.map +1 -1
  607. package/dist/src/utils/plugin-config.d.ts +189 -120
  608. package/dist/src/utils/plugin-config.js +926 -1270
  609. package/dist/src/utils/plugin-config.js.map +1 -1
  610. package/dist/src/utils/plugin-scripts.d.ts +75 -128
  611. package/dist/src/utils/plugin-scripts.js +556 -525
  612. package/dist/src/utils/plugin-scripts.js.map +1 -1
  613. package/dist/src/utils/process-lock.js +14 -5
  614. package/dist/src/utils/process-lock.js.map +1 -1
  615. package/dist/src/utils/process-tree.d.ts +2 -2
  616. package/dist/src/utils/process-tree.js +1 -1
  617. package/dist/src/utils/process-tree.js.map +1 -1
  618. package/dist/src/utils/project-boundary.d.ts +11 -13
  619. package/dist/src/utils/project-boundary.js +28 -34
  620. package/dist/src/utils/project-boundary.js.map +1 -1
  621. package/dist/src/utils/rendered-contract.js +18 -1
  622. package/dist/src/utils/rendered-contract.js.map +1 -1
  623. package/dist/src/utils/runtime-config.d.ts +20 -0
  624. package/dist/src/utils/runtime-config.js +77 -0
  625. package/dist/src/utils/runtime-config.js.map +1 -0
  626. package/dist/src/utils/runtime-skill-closure.d.ts +2 -2
  627. package/dist/src/utils/runtime-skill-closure.js +47 -6
  628. package/dist/src/utils/runtime-skill-closure.js.map +1 -1
  629. package/dist/src/utils/safe-fs.d.ts +21 -0
  630. package/dist/src/utils/safe-fs.js +111 -0
  631. package/dist/src/utils/safe-fs.js.map +1 -0
  632. package/dist/src/utils/safe-operation-diagnostic.d.ts +15 -0
  633. package/dist/src/utils/safe-operation-diagnostic.js +33 -0
  634. package/dist/src/utils/safe-operation-diagnostic.js.map +1 -0
  635. package/dist/src/utils/sensitive-content.d.ts +4 -0
  636. package/dist/src/utils/sensitive-content.js +36 -0
  637. package/dist/src/utils/sensitive-content.js.map +1 -0
  638. package/dist/src/utils/state-paths.d.ts +8 -3
  639. package/dist/src/utils/state-paths.js +51 -9
  640. package/dist/src/utils/state-paths.js.map +1 -1
  641. package/dist/src/utils/target-eligibility.d.ts +8 -2
  642. package/dist/src/utils/target-eligibility.js +17 -8
  643. package/dist/src/utils/target-eligibility.js.map +1 -1
  644. package/dist/src/utils/windows-claude-shim.d.ts +7 -0
  645. package/dist/src/utils/windows-claude-shim.js +10 -0
  646. package/dist/src/utils/windows-claude-shim.js.map +1 -0
  647. package/dist/src/utils/windows-npm-shim.d.ts +16 -0
  648. package/dist/src/utils/windows-npm-shim.js +138 -0
  649. package/dist/src/utils/windows-npm-shim.js.map +1 -0
  650. package/dist/vitest.config.js +101 -9
  651. package/dist/vitest.config.js.map +1 -1
  652. package/package.json +31 -21
  653. package/dist/authoring/scripts/check-plugin-versions.d.mts +0 -2
  654. package/dist/authoring/scripts/check-plugin-versions.mjs +0 -5
  655. package/dist/authoring/scripts/check-plugin-versions.mjs.map +0 -1
  656. package/dist/scripts/aw-skill-eval-engine.d.ts +0 -13
  657. package/dist/scripts/aw-skill-eval-engine.js +0 -31
  658. package/dist/scripts/aw-skill-eval-engine.js.map +0 -1
  659. package/dist/scripts/codex-eval-app-server.d.ts +0 -89
  660. package/dist/scripts/codex-eval-app-server.js +0 -1228
  661. package/dist/scripts/codex-eval-app-server.js.map +0 -1
  662. package/dist/scripts/codex-eval-isolation.d.ts +0 -61
  663. package/dist/scripts/codex-eval-isolation.js +0 -318
  664. package/dist/scripts/codex-eval-isolation.js.map +0 -1
  665. package/dist/scripts/codex-eval-process-management.d.ts +0 -8
  666. package/dist/scripts/codex-eval-process-management.js +0 -69
  667. package/dist/scripts/codex-eval-process-management.js.map +0 -1
  668. package/dist/scripts/codex-eval-process-tree.d.ts +0 -38
  669. package/dist/scripts/codex-eval-process-tree.js +0 -803
  670. package/dist/scripts/codex-eval-process-tree.js.map +0 -1
  671. package/dist/scripts/codex-eval-runtime-config.d.ts +0 -62
  672. package/dist/scripts/codex-eval-runtime-config.js +0 -843
  673. package/dist/scripts/codex-eval-runtime-config.js.map +0 -1
  674. package/dist/scripts/codex-trigger-eval.d.ts +0 -84
  675. package/dist/scripts/codex-trigger-eval.js +0 -968
  676. package/dist/scripts/codex-trigger-eval.js.map +0 -1
  677. package/dist/scripts/eval-plugin-skills-audited.d.ts +0 -6
  678. package/dist/scripts/eval-plugin-skills-audited.js +0 -261
  679. package/dist/scripts/eval-plugin-skills-audited.js.map +0 -1
  680. package/dist/scripts/eval-plugin-skills.d.ts +0 -45
  681. package/dist/scripts/eval-plugin-skills.js +0 -1586
  682. package/dist/scripts/eval-plugin-skills.js.map +0 -1
  683. package/dist/scripts/eval-run-layout.d.ts +0 -17
  684. package/dist/scripts/eval-run-layout.js +0 -26
  685. package/dist/scripts/eval-run-layout.js.map +0 -1
  686. package/dist/scripts/plugin-eval-contract.d.ts +0 -185
  687. package/dist/scripts/plugin-eval-contract.js +0 -695
  688. package/dist/scripts/plugin-eval-contract.js.map +0 -1
  689. package/dist/scripts/plugin-eval-materializer.d.ts +0 -13
  690. package/dist/scripts/plugin-eval-materializer.js +0 -421
  691. package/dist/scripts/plugin-eval-materializer.js.map +0 -1
  692. package/dist/scripts/skill-reporting.d.ts +0 -212
  693. package/dist/scripts/skill-reporting.js +0 -922
  694. package/dist/scripts/skill-reporting.js.map +0 -1
  695. package/dist/src/commands/review-publication.d.ts +0 -99
  696. package/dist/src/commands/review-publication.js +0 -904
  697. package/dist/src/commands/review-publication.js.map +0 -1
  698. package/dist/src/commands/status-v4.d.ts +0 -123
  699. package/dist/src/commands/status-v4.js +0 -905
  700. package/dist/src/commands/status-v4.js.map +0 -1
  701. package/dist/src/commands/status.d.ts +0 -93
  702. package/dist/src/commands/status.js +0 -442
  703. package/dist/src/commands/status.js.map +0 -1
  704. package/dist/src/portable/skills-cli.d.ts +0 -43
  705. package/dist/src/portable/skills-cli.js +0 -148
  706. package/dist/src/portable/skills-cli.js.map +0 -1
  707. package/dist/src/utils/active-marketplace-runtime-lock.d.ts +0 -12
  708. package/dist/src/utils/active-marketplace-runtime-lock.js +0 -133
  709. package/dist/src/utils/active-marketplace-runtime-lock.js.map +0 -1
  710. package/dist/src/utils/catalog-manifest-v3.d.ts +0 -2
  711. package/dist/src/utils/catalog-manifest-v3.js +0 -3
  712. package/dist/src/utils/catalog-manifest-v3.js.map +0 -1
  713. package/dist/src/utils/catalog-manifest-v4.d.ts +0 -5
  714. package/dist/src/utils/catalog-manifest-v4.js.map +0 -1
  715. package/dist/src/utils/catalog-source-cache.d.ts +0 -62
  716. package/dist/src/utils/catalog-source-cache.js +0 -296
  717. package/dist/src/utils/catalog-source-cache.js.map +0 -1
  718. package/dist/src/utils/codex-project-surface.d.ts +0 -3
  719. package/dist/src/utils/codex-project-surface.js +0 -49
  720. package/dist/src/utils/codex-project-surface.js.map +0 -1
  721. package/dist/src/utils/lifecycle-active-store.d.ts +0 -175
  722. package/dist/src/utils/lifecycle-active-store.js +0 -1276
  723. package/dist/src/utils/lifecycle-active-store.js.map +0 -1
  724. package/dist/src/utils/plugin-release.d.ts +0 -2
  725. package/dist/src/utils/plugin-release.js +0 -2
  726. package/dist/src/utils/plugin-release.js.map +0 -1
@@ -0,0 +1,2970 @@
1
+ import { selectAgents } from '../intent/deployment-preferences.js';
2
+ import { readDemand, demandNativeProjection } from '../recovery/demand.js';
3
+ import fs from 'node:fs';
4
+ import path from 'node:path';
5
+ import { analyzeCodexSurface } from '../utils/codex-surface-analysis.js';
6
+ import { catalogSourceErrorCode, sanitizeCatalogSourceError, } from '../utils/catalog-public-error.js';
7
+ import { calculateCatalogSourceIdentity } from '../utils/catalog-source-identity.js';
8
+ import { canonicalMarketplaceRegistrationNames, inventoryCatalogSourceReferences, inventoryLegacyOwnerReferences, } from '../utils/catalog-source-references.js';
9
+ import { readStrictNamespacedMarketplaceRoot } from '../utils/local-marketplace.js';
10
+ import { readCatalogSourcesConfigSnapshot, resolveCatalogSourceRef } from '../utils/catalog-sources.js';
11
+ import { formatPluginId, parsePluginId, planPluginSelectorSourceIds, withResolvedMultiSourceCatalog, } from '../utils/multi-source-catalog.js';
12
+ import { assertStrictSemVer, checkAwCapabilitySupport, compareStrictSemVer, readPluginManifest, tryParseStrictSemVer, } from '../utils/manifest.js';
13
+ import { resolveCliPackageRoot, resolveCodexPaths } from '../utils/paths.js';
14
+ import { resolveSupportedPlatforms, supportsPlatform } from '../utils/platform-support.js';
15
+ import { parsePlatformValue, parseScopeValue } from './options.js';
16
+ import { inspectCodexPluginRegistrationLive, inspectCodexSharedNativeLive, inspectRebuildTarget, } from './rebuild-integration.js';
17
+ import { createNoopReporter } from '../output/reporter.js';
18
+ import { createNoopDebugLogger } from '../output/debug-log.js';
19
+ import { bindNativeCliRunnerSignal, getDefaultNativeCliRunner } from '../utils/native-cli.js';
20
+ import { createCodexNativeObservationSession, } from '../utils/codex-native-observation.js';
21
+ import { resolveAwHome } from '../utils/paths.js';
22
+ import { codexProjectConfigAliasesUserHome, createProjectLocationKey, getClaudeHome, getCodexHome, resolveRequiredCanonicalRepoRoot, } from '../utils/state-paths.js';
23
+ import { resolveEffectivePluginConfig, resolveProjectArtifactRenderConfig, } from '../utils/plugin-config.js';
24
+ import { readCodexConfigFile } from '../utils/codex-config.js';
25
+ import { createEmptyNativeDemandView } from '../utils/native-demand.js';
26
+ import { IMPLEMENTED_AW_CAPABILITIES } from './aw-capabilities.js';
27
+ import { createDependencyPlacementPlan } from './dependency-operation-plan.js';
28
+ import { getCodexOperationRequirement } from '../utils/agent-version.js';
29
+ import { inspectSystemCodex, } from '../utils/codex-manager.js';
30
+ export function statusTargetPlacements(target) {
31
+ if (target.platform === 'claude')
32
+ return [target];
33
+ return target.placements.map((placement) => ({
34
+ pluginName: target.pluginName,
35
+ sourceId: target.sourceId,
36
+ sourceIdentity: target.sourceIdentity,
37
+ pluginId: target.pluginId,
38
+ ...(target.version ? { version: target.version } : {}),
39
+ platform: target.platform,
40
+ cwd: target.cwd,
41
+ ...placement,
42
+ sharedComponents: target.components.filter((component) => component.kind !== 'systemConsumer' || component.key === `codex:${placement.scope}`),
43
+ sharedReasons: target.reasons.filter((reason) => reason.code.startsWith('codexSharedNative') || reason.code === 'staleCacheObserved'
44
+ || reason.code === 'codexCandidateExcluded'),
45
+ }));
46
+ }
47
+ export function flattenStatusTargets(targets) {
48
+ return targets.flatMap(statusTargetPlacements);
49
+ }
50
+ /** Existing output evidence is required before config apply can refresh a target. */
51
+ export function statusTargetHasLiveConfigConsumer(target) {
52
+ return target.components.some((component) => component.kind === 'ownership'
53
+ && (target.platform !== 'codex' || (component.key !== 'native'
54
+ && !component.key.startsWith('activation-') && !component.key.startsWith('marketplace-')))
55
+ && ['present', 'partial'].includes(component.state))
56
+ || (target.sharedComponents?.some((component) => component.kind === 'sharedNative' && ['usable', 'replaceable'].includes(component.state)) === true
57
+ && target.components.some((component) => component.kind === 'activation'
58
+ && component.key === target.scope && component.state === 'enabled'));
59
+ }
60
+ export function projectStatusSharedNativeReasons(sharedNative, existingReasonCodes = [], desiredEnabled = false) {
61
+ if (!sharedNative)
62
+ return [];
63
+ const warning = (code, message) => ({
64
+ code,
65
+ message: `${code}: ${message}`,
66
+ severity: 'warning',
67
+ });
68
+ const blocking = (code, message) => ({
69
+ code,
70
+ message: `${code}: ${message}`,
71
+ severity: 'blocking',
72
+ });
73
+ return [
74
+ ...(sharedNative.state === 'blocked' && sharedNative.reason === 'foreign'
75
+ && !existingReasonCodes.includes('codexSharedNativeForeign')
76
+ ? [blocking('codexSharedNativeForeign', `${sharedNative.pluginId} is foreign and was preserved.`)]
77
+ : []),
78
+ ...(sharedNative.state === 'blocked' && sharedNative.reason === 'unreadable'
79
+ && !existingReasonCodes.includes('codexSharedNativeCorrupt')
80
+ ? [blocking('codexSharedNativeCorrupt', `${sharedNative.pluginId} is unreadable.`)]
81
+ : []),
82
+ ...(sharedNative.state === 'replaceable' && sharedNative.reason === 'damaged'
83
+ ? [warning('codexSharedNativeCorrupt', `${sharedNative.pluginId} shared generated content is missing or damaged and can be replaced.`)]
84
+ : []),
85
+ ...(sharedNative.state === 'replaceable' && sharedNative.reason === 'outdated'
86
+ ? [warning('codexSharedNativeUpdateRequired', `${sharedNative.pluginId} requires a shared update.`)]
87
+ : []),
88
+ ...(sharedNative.state === 'replaceable' && sharedNative.reason === 'renderDrift'
89
+ ? [warning('codexSharedNativeRenderDrift', `${sharedNative.pluginId} shared generated content does not match the current render inputs and can be replaced.`)]
90
+ : []),
91
+ ...(sharedNative.staleCacheObserved
92
+ ? [warning('staleCacheObserved', `${sharedNative.pluginId} has non-blocking stale Codex cache residue.`)]
93
+ : []),
94
+ ...(sharedNative.state === 'unobserved' && desiredEnabled
95
+ ? [warning('codexSharedNativeUnobserved', `${sharedNative.pluginId} was not observed by a compatible Codex consumer.`)]
96
+ : []),
97
+ ];
98
+ }
99
+ function statusComponent(target, kind, key) {
100
+ return [...target.components, ...(target.sharedComponents ?? [])].find((component) => component.kind === kind && (key === undefined || component.key === key));
101
+ }
102
+ export function statusTargetIntent(target) {
103
+ const metadata = statusComponent(target, 'intent', 'desired')?.metadata;
104
+ return {
105
+ enabled: metadata?.enabled === true,
106
+ scopes: Array.isArray(metadata?.scopes)
107
+ ? metadata.scopes.filter((scope) => scope === 'user' || scope === 'project')
108
+ : [],
109
+ relation: metadata?.relation === 'root'
110
+ || metadata?.relation === 'dependency'
111
+ || metadata?.relation === 'managed'
112
+ ? metadata.relation
113
+ : 'none',
114
+ };
115
+ }
116
+ export function statusTargetOwnershipState(target) {
117
+ const components = target.components.filter((component) => component.kind === 'ownership');
118
+ if (components.some((component) => component.state === 'error'))
119
+ return 'error';
120
+ if (components.some((component) => component.state === 'partial'))
121
+ return 'partial';
122
+ if (components.some((component) => component.state === 'present'))
123
+ return 'present';
124
+ return 'absent';
125
+ }
126
+ export function statusTargetSharedNative(target) {
127
+ const component = statusComponent(target, 'sharedNative');
128
+ if (!component || (component.state !== 'missing'
129
+ && component.state !== 'usable'
130
+ && component.state !== 'replaceable'
131
+ && component.state !== 'blocked'
132
+ && component.state !== 'unobserved'))
133
+ return undefined;
134
+ const reason = component.metadata?.reason;
135
+ return {
136
+ pluginId: component.key,
137
+ state: component.state,
138
+ ...(reason === 'outdated' || reason === 'damaged' || reason === 'renderDrift'
139
+ || reason === 'foreign' || reason === 'unreadable'
140
+ ? { reason }
141
+ : {}),
142
+ ...(typeof component.metadata?.version === 'string'
143
+ ? { version: component.metadata.version }
144
+ : {}),
145
+ ...(typeof component.metadata?.desiredVersion === 'string'
146
+ ? { desiredVersion: component.metadata.desiredVersion }
147
+ : {}),
148
+ ...(typeof component.metadata?.diagnostic === 'string'
149
+ ? { diagnostic: component.metadata.diagnostic }
150
+ : {}),
151
+ ...(component.metadata?.staleCacheObserved === true ? { staleCacheObserved: true } : {}),
152
+ };
153
+ }
154
+ export function statusTargetActivation(target) {
155
+ const user = statusComponent(target, 'activation', 'user');
156
+ const project = statusComponent(target, 'activation', 'project');
157
+ const consumer = statusComponent(target, 'systemConsumer');
158
+ if (!user && !project && !consumer)
159
+ return undefined;
160
+ const activation = user ?? project ?? consumer;
161
+ const evidence = activation?.metadata?.evidence;
162
+ const requiredMinVersion = consumer?.metadata?.requiredMinVersion;
163
+ let systemConsumer;
164
+ if (consumer && typeof requiredMinVersion === 'string') {
165
+ const detectedVersion = consumer.metadata?.detectedVersion;
166
+ const code = consumer.metadata?.code;
167
+ const diagnostic = consumer.metadata?.diagnostic;
168
+ systemConsumer = consumer.state === 'missing' || consumer.state === 'unobserved'
169
+ ? { state: consumer.state, requiredMinVersion }
170
+ : consumer.state === 'compatible' && typeof detectedVersion === 'string'
171
+ ? { state: 'compatible', detectedVersion, requiredMinVersion }
172
+ : consumer.state === 'incompatible'
173
+ && code === 'codexSystemCliUnsupported'
174
+ && typeof detectedVersion === 'string'
175
+ && typeof diagnostic === 'string'
176
+ ? { state: 'incompatible', code, detectedVersion, diagnostic, requiredMinVersion }
177
+ : consumer.state === 'unresolved'
178
+ && code === 'codexSystemCliUnsupported'
179
+ && typeof diagnostic === 'string'
180
+ ? { state: 'unresolved', code, diagnostic, requiredMinVersion }
181
+ : undefined;
182
+ const diagnostics = consumer.metadata?.diagnostics;
183
+ if (systemConsumer && Array.isArray(diagnostics) && diagnostics.length > 0) {
184
+ systemConsumer = { ...systemConsumer, diagnostics: diagnostics.filter((value) => typeof value === 'string') };
185
+ }
186
+ }
187
+ return {
188
+ ...(user ? { user: user.state === 'enabled' } : {}),
189
+ ...(project ? { project: project.state === 'enabled' } : {}),
190
+ ...(typeof activation?.metadata?.effective === 'boolean'
191
+ ? { effective: activation.metadata.effective }
192
+ : {}),
193
+ evidence: evidence === 'observed' || evidence === 'unobserved' ? evidence : 'assumed',
194
+ ...(systemConsumer ? { systemConsumer } : {}),
195
+ };
196
+ }
197
+ export function statusTargetExtensions(target) {
198
+ const component = statusComponent(target, 'extension', 'aw');
199
+ if (!component || (component.state !== 'ready'
200
+ && component.state !== 'missing'
201
+ && component.state !== 'drifted'
202
+ && component.state !== 'conflict'))
203
+ return undefined;
204
+ const kinds = Array.isArray(component.metadata?.kinds)
205
+ ? component.metadata.kinds.filter((kind) => kind === 'skill'
206
+ || kind === 'instruction'
207
+ || kind === 'permission'
208
+ || kind === 'agent'
209
+ || kind === 'config')
210
+ : [];
211
+ return { state: component.state, kinds };
212
+ }
213
+ function resolveCatalogEntrySupportedPlatforms(policy) {
214
+ return resolveSupportedPlatforms({ marketplace: { policy } });
215
+ }
216
+ let dependencyInspectionHookForTests;
217
+ export function setStatusDependencyInspectionHookForTests(hook) {
218
+ dependencyInspectionHookForTests = hook;
219
+ }
220
+ export async function loadConsoleItemsResult(options = {}, runtime = {}) {
221
+ const result = await statusCommandV8({
222
+ cwd: options.cwd ?? process.cwd(),
223
+ env: runtime.env,
224
+ platform: options.platform,
225
+ scope: options.scope,
226
+ verbose: options.verbose,
227
+ });
228
+ const groups = new Map();
229
+ const summaries = new Map(result.pluginSummaries.map((summary) => [summary.pluginId, summary]));
230
+ for (const target of result.payload.targets) {
231
+ const summary = summaries.get(target.pluginId);
232
+ let pluginSummary;
233
+ if (summary !== undefined) {
234
+ const { pluginName: _pluginName, pluginId: _pluginId, ...projected } = summary;
235
+ pluginSummary = projected;
236
+ }
237
+ const current = groups.get(target.pluginId) ?? {
238
+ pluginName: target.pluginId,
239
+ ...(target.version ? { version: target.version } : {}),
240
+ ...(pluginSummary ? { pluginSummary } : {}),
241
+ targets: [],
242
+ };
243
+ current.targets.push(...statusTargetPlacements(target));
244
+ groups.set(target.pluginId, current);
245
+ }
246
+ const allSourcesFailed = result.payload.catalog.sources.length > 0
247
+ && result.payload.catalog.sources.every((source) => source.error !== undefined);
248
+ return {
249
+ items: [...groups.values()].sort((left, right) => left.pluginName.localeCompare(right.pluginName)),
250
+ catalogUnavailable: allSourcesFailed,
251
+ status: result.payload,
252
+ };
253
+ }
254
+ export async function loadConsoleItems(options = {}, runtime = {}) {
255
+ return (await loadConsoleItemsResult(options, runtime)).items;
256
+ }
257
+ function projectStateInventoryError(error, env, cwd) {
258
+ const sanitized = sanitizeCatalogSourceError(error, env, [
259
+ getCodexHome(env),
260
+ getClaudeHome(env),
261
+ path.resolve(cwd),
262
+ ]);
263
+ const native = /(?:Codex|Claude|config\.toml|settings|installed_plugins)/iu.test(sanitized.message);
264
+ const code = native ? 'nativeStateUnreadable' : 'stateInventoryFailed';
265
+ return { code, message: `${code}: ${sanitized.message}`, relevance: { global: true } };
266
+ }
267
+ function inventoryErrorMatchesSelection(options) {
268
+ const relevance = options.error.relevance;
269
+ if (relevance.global)
270
+ return true;
271
+ if (relevance.projectLocationKey
272
+ && (!options.currentProjectLocationKey
273
+ || relevance.projectLocationKey !== options.currentProjectLocationKey))
274
+ return false;
275
+ if (options.platformExplicit && relevance.platform
276
+ && !options.platforms.includes(relevance.platform))
277
+ return false;
278
+ if (options.scopeExplicit && relevance.scope
279
+ && !options.scopes.includes(relevance.scope))
280
+ return false;
281
+ if (options.selectors.length === 0 || (!relevance.sourceId && !relevance.pluginName))
282
+ return true;
283
+ return options.selectors.some((selector) => (!relevance.pluginName || selector.parsed.pluginName === relevance.pluginName)
284
+ && (!relevance.sourceId
285
+ || selector.parsed.sourceId === undefined
286
+ || selector.parsed.sourceId === relevance.sourceId));
287
+ }
288
+ function finalizeTargetError(error, targetState) {
289
+ return {
290
+ ...error,
291
+ severity: error.code === 'artifactCollision'
292
+ || error.code === 'dependencyGraphInvalid'
293
+ || (targetState === 'error'
294
+ && error.dependencyPluginId === undefined)
295
+ ? 'blocking'
296
+ : 'warning',
297
+ };
298
+ }
299
+ function projectTargetError(error, env, cwd, targetState) {
300
+ const sanitized = sanitizeCatalogSourceError(new Error(error.message), env, [
301
+ getCodexHome(env),
302
+ getClaudeHome(env),
303
+ path.resolve(cwd),
304
+ ]);
305
+ return finalizeTargetError({ ...error, message: sanitized.message }, targetState);
306
+ }
307
+ function sourceRequestedRef(source, cliVersion) {
308
+ return source.type === 'git' ? resolveCatalogSourceRef(source.refPolicy, cliVersion) : 'path';
309
+ }
310
+ function selectedPlatforms(value) {
311
+ const selection = value === undefined ? 'both' : parsePlatformValue(value);
312
+ return selection === 'both' ? ['codex', 'claude'] : [selection];
313
+ }
314
+ function selectedScopes(value) {
315
+ return value === undefined ? ['user', 'project'] : [parseScopeValue(value)];
316
+ }
317
+ const emptyIntent = createEmptyNativeDemandView;
318
+ function desiredTargetKey(pluginId, platform) {
319
+ return `${pluginId}\0${platform}`;
320
+ }
321
+ function calculateDesiredTargetStates(options) {
322
+ const desired = new Map();
323
+ const add = (pluginId, platform, scope, relation) => {
324
+ const key = desiredTargetKey(pluginId, platform);
325
+ const current = desired.get(key) ?? { scopes: new Set(), relation: 'none' };
326
+ current.scopes.add(scope);
327
+ if (relation === 'root' || (relation === 'dependency' && current.relation !== 'root')) {
328
+ current.relation = relation;
329
+ }
330
+ desired.set(key, current);
331
+ };
332
+ const byId = new Map(options.available.map((entry) => [
333
+ formatPluginId({ sourceId: entry.source.id, pluginName: entry.name }),
334
+ entry,
335
+ ]));
336
+ for (const [scope, intent] of [
337
+ ['user', options.userIntent],
338
+ ['project', options.projectIntent],
339
+ ]) {
340
+ for (const root of intent.roots) {
341
+ for (const platform of root.platforms)
342
+ add(root.pluginId, platform, scope, 'root');
343
+ }
344
+ for (const platform of ['codex', 'claude']) {
345
+ const platformRoots = intent.roots.filter((root) => root.platforms.includes(platform) && byId.has(root.pluginId));
346
+ const closure = new Set();
347
+ const visit = (pluginId) => {
348
+ if (closure.has(pluginId))
349
+ return;
350
+ closure.add(pluginId);
351
+ const entry = byId.get(pluginId);
352
+ if (!entry)
353
+ return;
354
+ for (const dependency of entry.dependencies) {
355
+ visit(formatPluginId({ sourceId: entry.source.id, pluginName: dependency }));
356
+ }
357
+ };
358
+ for (const root of platformRoots)
359
+ visit(root.pluginId);
360
+ const nodes = [...closure].flatMap((pluginId) => {
361
+ const entry = byId.get(pluginId);
362
+ if (!entry || !entry.targets[platform].user && !entry.targets[platform].project)
363
+ return [];
364
+ const allowedScopes = [
365
+ ...(entry.targets[platform].project
366
+ && (platform !== 'codex' || options.codexProjectAllowed) ? ['project'] : []),
367
+ ...(entry.targets[platform].user ? ['user'] : []),
368
+ ];
369
+ return allowedScopes.length === 0 ? [] : [{
370
+ pluginId,
371
+ pluginName: entry.name,
372
+ platform,
373
+ relation: platformRoots.some((root) => root.pluginId === pluginId)
374
+ ? 'requested'
375
+ : 'dependency',
376
+ depth: platformRoots.some((root) => root.pluginId === pluginId) ? 0 : 1,
377
+ allowedScopes,
378
+ ...(scope === 'project'
379
+ && !platformRoots.some((root) => root.pluginId === pluginId)
380
+ && entry.states?.[platform]?.user?.state === 'present'
381
+ && !entry.states[platform]?.user?.errors.some((error) => error.severity === 'blocking')
382
+ ? { preferredScope: 'user', preferredScopeReason: 'existingWiderTarget' }
383
+ : {}),
384
+ }];
385
+ });
386
+ const nodeIds = new Set(nodes.map((node) => node.pluginId));
387
+ const roots = platformRoots.flatMap((root) => nodeIds.has(root.pluginId)
388
+ ? [{ pluginId: root.pluginId, platform, scope }]
389
+ : []);
390
+ if (roots.length === 0)
391
+ continue;
392
+ const edges = nodes.flatMap((node) => {
393
+ const entry = byId.get(node.pluginId);
394
+ return entry.dependencies.flatMap((dependency) => {
395
+ const dependencyId = formatPluginId({
396
+ sourceId: entry.source.id,
397
+ pluginName: dependency,
398
+ });
399
+ return nodeIds.has(dependencyId)
400
+ ? [{ from: node.pluginId, to: dependencyId, platform }]
401
+ : [];
402
+ });
403
+ });
404
+ const plan = createDependencyPlacementPlan({
405
+ requestedPluginIds: roots.map((root) => root.pluginId),
406
+ nodes,
407
+ roots,
408
+ dependencyEdges: edges,
409
+ scopeOverrides: (intent.dependencyScopeOverrides ?? []).filter((override) => nodeIds.has(override.pluginId)
410
+ && (override.platform === undefined || override.platform === platform)),
411
+ });
412
+ for (const target of plan.targets) {
413
+ add(target.pluginId, target.platform, target.resolvedScope, target.relation === 'requested' ? 'root' : 'dependency');
414
+ }
415
+ }
416
+ }
417
+ return new Map([...desired].map(([key, value]) => [key, {
418
+ scopes: [...value.scopes].sort(),
419
+ relation: value.relation,
420
+ }]));
421
+ }
422
+ function projectDependencyClosureForTarget(options) {
423
+ const byId = new Map(options.available.map((entry) => [
424
+ formatPluginId({ sourceId: entry.source.id, pluginName: entry.name }),
425
+ entry,
426
+ ]));
427
+ const closure = new Set();
428
+ const visit = (pluginId) => {
429
+ const entry = byId.get(pluginId);
430
+ if (!entry)
431
+ return;
432
+ for (const dependency of entry.dependencies) {
433
+ const dependencyId = formatPluginId({
434
+ sourceId: entry.source.id,
435
+ pluginName: dependency,
436
+ });
437
+ const dependencyEntry = byId.get(dependencyId);
438
+ if (!dependencyEntry
439
+ || (!dependencyEntry.targets[options.platform].user
440
+ && !dependencyEntry.targets[options.platform].project)
441
+ || closure.has(dependencyId)) {
442
+ continue;
443
+ }
444
+ closure.add(dependencyId);
445
+ visit(dependencyId);
446
+ }
447
+ };
448
+ visit(options.pluginId);
449
+ return closure;
450
+ }
451
+ export function statusRecovery(options) {
452
+ if (options.errorCodes?.includes('removedPluginCleanupRequired')) {
453
+ return [{
454
+ command: 'cleanup',
455
+ description: '整体清理已删除插件在两个平台、用户与当前项目中的安装、设置和遗留记录。',
456
+ }];
457
+ }
458
+ if (options.errorCodes?.some((code) => code === 'codexProjectPluginUnsupported' || code === 'codexSystemCliUnsupported')) {
459
+ return [{
460
+ command: 'manual',
461
+ description: '升级或修复官方 system Codex CLI 后重试原操作。',
462
+ }];
463
+ }
464
+ if (options.errorCodes?.includes('awCapabilityUnsupported')) {
465
+ return [{
466
+ command: 'manual',
467
+ description: '升级 AW CLI 到支持插件所需 capability 的版本后重试。',
468
+ }];
469
+ }
470
+ if (options.errorCodes?.includes('dependencyGraphInvalid')) {
471
+ return [{
472
+ command: 'manual',
473
+ description: '修复 Catalog 中的插件依赖循环后重试。',
474
+ }];
475
+ }
476
+ if (options.state === 'ready' || options.state === 'absent')
477
+ return [];
478
+ if (options.desired.scopes.length === 0
479
+ && options.sharedNative?.state === 'replaceable'
480
+ && options.sharedNative.reason === 'damaged') {
481
+ return [
482
+ ...(options.actualEnabled ? [{
483
+ command: 'cleanup',
484
+ ...(options.scope ? { scope: options.scope } : {}),
485
+ description: `仅清理 ${options.scope ?? '当前'} scope 的激活;不会修复或删除损坏的共享内容。`,
486
+ }] : []),
487
+ {
488
+ command: 'manual',
489
+ description: `共享内容已损坏。先确认本机 Agent 选择,明确 user 或 project 使用范围,再运行 aw plugin install ${options.pluginId} --scope <user|project> 重建。`,
490
+ },
491
+ ];
492
+ }
493
+ if (options.state === 'orphaned') {
494
+ return [{ command: 'cleanup', description: '清理可证明属于 AW 的遗留输出。' }];
495
+ }
496
+ if (options.state === 'blocked' && options.errorCodes?.some((code) => code === 'sourceMissing'
497
+ || code === 'catalogSourceUnavailable'
498
+ || code === 'bundleUnavailable'
499
+ || code === 'codexIntentSourceUnavailable')) {
500
+ return [
501
+ { command: 'sync', description: '来源恢复后同步 desired intent。' },
502
+ { command: 'cleanup', description: '来源无法恢复时清理可证明属于 AW 的输出。' },
503
+ ];
504
+ }
505
+ if (options.state === 'blocked') {
506
+ if (options.desired.scopes.includes('user') && options.desired.scopes.includes('project')) {
507
+ return ['user', 'project'].flatMap((scope) => {
508
+ const retainedScope = scope === 'user' ? 'project' : 'user';
509
+ const retainedRoot = options.conflictRoots?.[retainedScope]?.[0];
510
+ if (!retainedRoot)
511
+ return [];
512
+ return (options.conflictRoots?.[scope] ?? []).map((rootPluginId) => ({
513
+ command: 'uninstall',
514
+ scope,
515
+ description: `运行 aw plugin remove ${rootPluginId} --only requirements --scope ${scope},再运行 aw plugin remove --only outputs ${rootPluginId} --target ${options.platform} --scope ${scope},最后运行 aw plugin sync ${retainedRoot} --target ${options.platform} --context ${retainedScope}。`,
516
+ }));
517
+ });
518
+ }
519
+ const collision = options.sharedNative?.state === 'blocked'
520
+ ? `Codex shared native ${options.sharedNative.pluginId}`
521
+ : `${options.pluginId} 的 foreign extension`;
522
+ return [
523
+ {
524
+ command: 'sync',
525
+ description: `先移除或重命名 ${collision},再运行 aw plugin sync ${options.pluginId} --target ${options.platform} --context ${options.scope ?? 'user'}。cleanup 会保留 foreign 内容,不会删除该冲突。`,
526
+ },
527
+ ];
528
+ }
529
+ if (options.dependencyMoves?.length) {
530
+ const rootScope = options.desired.scopes[0] ?? 'project';
531
+ const removeDependencies = options.dependencyMoves.map((move) => `aw plugin remove --only outputs ${move.pluginId} --target ${options.platform} --scope ${move.fromScope}`);
532
+ return [{
533
+ command: 'manual',
534
+ description: `先按依赖保护提示依次移除 ${options.dependencyMoves.map((move) => move.pluginId).join('、')} 的所有直接和间接依赖者;若命令报告 dependencyStillRequired,继续处理提示的其他依赖者。再运行 ${removeDependencies.join(',再运行 ')} 移除依赖旧位置。最后确认本机 Agent 选择,逐个按原 scope 重新添加全部已移除 root,由联合需求重新确定提供位置;当前 root 的示例命令是 aw plugin install ${options.pluginId} --scope ${rootScope}。`,
535
+ }];
536
+ }
537
+ return [{
538
+ command: options.errorCodes?.some((code) => code === 'codexSharedNativeCorrupt'
539
+ || code === 'codexActivationDrift'
540
+ || code === 'codexExtensionDrift') ? 'reinstall' : 'sync',
541
+ ...(options.desired.scopes.length === 1 ? { scope: options.desired.scopes[0] } : {}),
542
+ description: '同步 desired intent 和当前现场;现场损坏时使用重新安装修复。',
543
+ }];
544
+ }
545
+ function rootIntentsForTarget(options) {
546
+ const byId = new Map(options.available.map((entry) => [
547
+ formatPluginId({ sourceId: entry.source.id, pluginName: entry.name }),
548
+ entry,
549
+ ]));
550
+ const result = {};
551
+ for (const [scope, intent] of [
552
+ ['user', options.userIntent],
553
+ ['project', options.projectIntent],
554
+ ]) {
555
+ const roots = intent.roots.filter((root) => {
556
+ if (!root.platforms.includes(options.platform))
557
+ return false;
558
+ const seen = new Set();
559
+ const reaches = (pluginId) => {
560
+ if (pluginId === options.pluginId)
561
+ return true;
562
+ if (seen.has(pluginId))
563
+ return false;
564
+ seen.add(pluginId);
565
+ const entry = byId.get(pluginId);
566
+ return entry?.dependencies.some((dependency) => reaches(formatPluginId({
567
+ sourceId: entry.source.id,
568
+ pluginName: dependency,
569
+ }))) === true;
570
+ };
571
+ return reaches(root.pluginId);
572
+ }).map((root) => root.pluginId).sort();
573
+ if (roots.length > 0)
574
+ result[scope] = roots;
575
+ }
576
+ return result;
577
+ }
578
+ function projectedLiveState(options) {
579
+ if (options.inspection.state === 'error'
580
+ || options.inspection.components.some((entry) => entry.state === 'error'))
581
+ return 'error';
582
+ const owned = options.inspection.components.filter((entry) => (entry.state === 'present' || entry.state === 'partial'));
583
+ if (owned.length === 0)
584
+ return 'absent';
585
+ if (owned.some((entry) => entry.state === 'partial'))
586
+ return 'partial';
587
+ const required = new Set(options.required);
588
+ const optional = new Set(options.optional);
589
+ if (options.inspection.components.some((entry) => entry.state === 'present' && !required.has(entry.component) && !optional.has(entry.component))) {
590
+ return 'partial';
591
+ }
592
+ if (!options.required.every((component) => options.inspection.components.some((entry) => entry.component === component && entry.state === 'present')))
593
+ return 'partial';
594
+ if (options.required.length > 0)
595
+ return 'present';
596
+ return options.optional.some((component) => options.inspection.components.some((entry) => entry.component === component && entry.state === 'present')) ? 'present' : 'absent';
597
+ }
598
+ export function projectTargetRevision(availableVersion, installedVersion) {
599
+ if (!availableVersion || !installedVersion
600
+ || !tryParseStrictSemVer(availableVersion)
601
+ || !tryParseStrictSemVer(installedVersion)) {
602
+ return {
603
+ state: 'unknown',
604
+ ...(availableVersion ? { availableVersion } : {}),
605
+ ...(installedVersion ? { installedVersion } : {}),
606
+ };
607
+ }
608
+ const relation = compareStrictSemVer(installedVersion, availableVersion);
609
+ if (relation === 0)
610
+ return { state: 'current', availableVersion, installedVersion };
611
+ if (relation < 0)
612
+ return { state: 'upgradeAvailable', availableVersion, installedVersion };
613
+ return { state: 'unknown', availableVersion, installedVersion };
614
+ }
615
+ function renderStatusV8(payload, verbose) {
616
+ const lines = [`Catalog sources: ${payload.catalog.sources.length}`];
617
+ for (const source of payload.catalog.sources) {
618
+ lines.push(`${source.primary ? '*' : '-'} ${source.id}: ${source.error ?? source.freshness ?? 'unavailable'}`);
619
+ }
620
+ for (const target of payload.targets) {
621
+ const reasons = target.reasons.length > 0
622
+ ? ` [${target.reasons.map((reason) => reason.message.startsWith(`${reason.code}:`)
623
+ ? reason.message : `${reason.code}: ${reason.message}`).join('; ')}]`
624
+ : '';
625
+ if (target.platform === 'claude') {
626
+ lines.push(`${target.pluginId} ${target.platform} (${target.scope}): ${target.state}${reasons}`);
627
+ }
628
+ else {
629
+ lines.push(`${target.pluginId} ${target.platform}: ${target.state}${reasons}`);
630
+ const desiredScopes = target.placements.filter((placement) => placement.components.some((component) => component.kind === 'intent' && component.metadata?.enabled === true))
631
+ .map((placement) => placement.scope);
632
+ const actualScopes = target.placements.filter((placement) => placement.components.some((component) => component.kind === 'activation'
633
+ && component.key === placement.scope
634
+ && component.state === 'enabled'))
635
+ .map((placement) => placement.scope);
636
+ const usage = (scopes) => scopes.length === 0
637
+ ? 'disabled'
638
+ : scopes.length === 2 ? 'user+project' : scopes[0];
639
+ lines.push(` desired use: ${usage(desiredScopes)}`);
640
+ lines.push(` actual use: ${usage(actualScopes)}`);
641
+ const shared = target.components.find((component) => component.kind === 'sharedNative');
642
+ if (shared)
643
+ lines.push(` shared content: ${shared.state} (${shared.key})`);
644
+ for (const placement of target.placements) {
645
+ lines.push(` ${placement.scope}: ${placement.state}`);
646
+ }
647
+ }
648
+ if (verbose) {
649
+ for (const component of target.components) {
650
+ lines.push(` component ${component.kind}/${component.key}: ${component.state}`);
651
+ }
652
+ if (target.platform === 'codex') {
653
+ for (const placement of target.placements) {
654
+ lines.push(` placement ${placement.scope}: ${placement.state}`);
655
+ for (const component of placement.components) {
656
+ lines.push(` component ${component.kind}/${component.key}: ${component.state}`);
657
+ }
658
+ }
659
+ }
660
+ for (const action of target.recoveryActions) {
661
+ lines.push(` recovery ${action.command}: ${action.description}`);
662
+ }
663
+ }
664
+ }
665
+ for (const issue of payload.configIssues ?? []) {
666
+ lines.push(`Warning: ${issue.pluginId} config ${issue.key} has an unsupported project override; user/default is effective. Unset the project value.`);
667
+ }
668
+ for (const error of payload.errors)
669
+ lines.push(`Error: ${error.message}`);
670
+ return lines.join('\n');
671
+ }
672
+ function collisionMessage(collision) {
673
+ const reason = {
674
+ ownerMismatch: '已有内容属于其他 owner',
675
+ unownedContent: '已有内容没有 AW owner 标记',
676
+ typeMismatch: '已有内容类型与目标不匹配',
677
+ }[collision.reason];
678
+ return `artifactCollision: ${collision.artifactKind} ${collision.artifactKey}: ${reason}。请移除或迁移冲突内容后重试。`;
679
+ }
680
+ function collisionRootIssueId(options) {
681
+ return [
682
+ 'artifactCollision',
683
+ options.pluginId,
684
+ options.platform,
685
+ options.scope,
686
+ options.collision.artifactKind,
687
+ options.collision.artifactKey,
688
+ ].join(':');
689
+ }
690
+ async function statusCommandV8InSession(options) {
691
+ const throwIfCancelled = (error) => {
692
+ if (error instanceof Error && error.name === 'AbortError')
693
+ throw error;
694
+ options.signal?.throwIfAborted();
695
+ };
696
+ throwIfCancelled();
697
+ const env = options.env ?? process.env;
698
+ const dependencyPluginCache = new Map();
699
+ const dependencyInspectionCache = new Map();
700
+ const cliVersion = options.cliVersion ?? assertStrictSemVer(JSON.parse(fs.readFileSync(path.join(resolveCliPackageRoot(), 'package.json'), 'utf8')).version, 'packages/cli/package.json version');
701
+ const snapshot = await readCatalogSourcesConfigSnapshot(env);
702
+ throwIfCancelled();
703
+ const scope = options.scope === 'project' ? 'project' : 'user';
704
+ const demand = options.recoveryDemand ?? await readDemand({
705
+ scope, cwd: options.cwd, env, catalogOperationContext: options.catalogOperationContext, signal: options.signal,
706
+ });
707
+ throwIfCancelled();
708
+ const observedDemands = new Map([[scope, demand]]);
709
+ if (options.scope !== 'user') {
710
+ const otherScope = scope === 'user' ? 'project' : 'user';
711
+ try {
712
+ observedDemands.set(otherScope, await readDemand({ scope: otherScope, cwd: options.cwd,
713
+ env, catalogOperationContext: options.catalogOperationContext, signal: options.signal }));
714
+ }
715
+ catch (error) {
716
+ throwIfCancelled(error); /* The other scope remains unknown; current scope stays readable. */
717
+ }
718
+ }
719
+ const selectedPlatformsByScope = new Map();
720
+ for (const [demandScope, scopedDemand] of observedDemands) {
721
+ try {
722
+ selectedPlatformsByScope.set(demandScope, selectAgents({
723
+ preferences: scopedDemand.preferences,
724
+ ...(demandScope === scope ? options.recoverySelection : {}),
725
+ }).agents.flatMap((agent) => agent === 'codex' ? ['codex']
726
+ : agent === 'claude' ? ['claude'] : []));
727
+ }
728
+ catch {
729
+ selectedPlatformsByScope.set(demandScope, []);
730
+ }
731
+ }
732
+ const projectObservationPlatforms = selectedPlatformsByScope.get('project') ?? [];
733
+ const intentErrors = [];
734
+ const readIntent = async (scope) => {
735
+ let observation;
736
+ const scopedDemand = observedDemands.get(scope);
737
+ if (scopedDemand) {
738
+ try {
739
+ const protective = demandNativeProjection(scopedDemand);
740
+ // A protective execution view includes every supported Native platform. Status
741
+ // demand is limited to selected Agents; live residue is observed separately.
742
+ const value = { ...protective, roots: protective.roots.flatMap((root) => {
743
+ const platforms = root.platforms.filter((platform) => selectedPlatformsByScope.get(scope)?.includes(platform));
744
+ return platforms.length ? [{ ...root, platforms }] : [];
745
+ }) };
746
+ observation = scopedDemand.intent.state === 'absent' ? { state: 'absent' }
747
+ : { state: 'ready', value };
748
+ }
749
+ catch {
750
+ observation = { state: 'invalid', code: 'pluginIntentStateInvalid', message: '声明或偏好无效。' };
751
+ }
752
+ }
753
+ else
754
+ observation = options.scope === 'user' ? { state: 'absent' }
755
+ : { state: 'unavailable', code: 'pluginIntentStateUnavailable', message: '另一范围需求不可读。' };
756
+ if (observation.state === 'invalid') {
757
+ intentErrors.push({
758
+ code: 'pluginIntentStateInvalid',
759
+ message: `pluginIntentStateInvalid: ${scope} plugin intent state is invalid.`,
760
+ });
761
+ }
762
+ return observation;
763
+ };
764
+ const [userIntentObservation, initialProjectIntentObservation] = await Promise.all([
765
+ readIntent('user'),
766
+ readIntent('project'),
767
+ ]);
768
+ const userIntent = userIntentObservation.state === 'ready'
769
+ ? userIntentObservation.value : emptyIntent();
770
+ let projectIntentObservation = initialProjectIntentObservation;
771
+ let projectIntent = projectIntentObservation.state === 'ready'
772
+ ? projectIntentObservation.value : emptyIntent();
773
+ const codexConfigErrors = [];
774
+ const readActivationConfig = async (scope) => {
775
+ try {
776
+ return await readCodexConfigFile(resolveCodexPaths(options.cwd, scope, env).configTomlPath);
777
+ }
778
+ catch {
779
+ codexConfigErrors.push({
780
+ scope,
781
+ code: 'codexActivationDrift',
782
+ message: `codexActivationDrift: ${scope} Codex activation config is unreadable.`,
783
+ });
784
+ return undefined;
785
+ }
786
+ };
787
+ const codexScopePathsAlias = codexProjectConfigAliasesUserHome(options.cwd, env);
788
+ const [userCodexConfig, projectCodexConfig] = await Promise.all([
789
+ readActivationConfig('user'),
790
+ options.scope === 'user' || codexScopePathsAlias ? undefined : readActivationConfig('project'),
791
+ ]);
792
+ let projectRoot;
793
+ try {
794
+ projectRoot = await resolveRequiredCanonicalRepoRoot(options.cwd);
795
+ }
796
+ catch (error) {
797
+ if (error instanceof Error && error.name === 'AbortError')
798
+ throw error;
799
+ if (options.scope === 'project') {
800
+ projectIntentObservation = {
801
+ state: 'unavailable', code: 'pluginIntentStateUnavailable',
802
+ message: '无法确定当前项目位置,不能读取插件声明。',
803
+ };
804
+ projectIntent = emptyIntent();
805
+ if (!intentErrors.some((error) => error.message.includes('project plugin intent'))) {
806
+ intentErrors.push({ code: 'pluginIntentStateInvalid',
807
+ message: 'pluginIntentStateInvalid: project plugin intent state is unavailable.' });
808
+ }
809
+ }
810
+ }
811
+ const currentProjectKey = projectRoot;
812
+ const currentProjectLocationKey = currentProjectKey
813
+ ? createProjectLocationKey(currentProjectKey) : undefined;
814
+ const inventoryErrors = [];
815
+ const readInventory = options.inventoryCatalogSourceReferences
816
+ ?? inventoryCatalogSourceReferences;
817
+ const ownerInventory = await readInventory({ cwd: options.cwd, env,
818
+ ...(options.scope === 'user' ? { scope: 'user' } : { includeProjectAgentSkills: true }) }).catch(async (error) => {
819
+ throwIfCancelled(error);
820
+ inventoryErrors.push(projectStateInventoryError(error, env, options.cwd));
821
+ return inventoryLegacyOwnerReferences({ cwd: options.cwd, env,
822
+ ...(options.scope === 'user' ? { scope: 'user' } : { includeProjectAgentSkills: true }) }).catch((fallbackError) => {
823
+ throwIfCancelled(fallbackError);
824
+ inventoryErrors.push(projectStateInventoryError(fallbackError, env, options.cwd));
825
+ return { inventorySchemaVersion: 1, references: [], errors: [] };
826
+ });
827
+ });
828
+ throwIfCancelled();
829
+ for (const error of ownerInventory.errors ?? []) {
830
+ const code = error.kind === 'nativeStateRead' ? 'nativeStateUnreadable' : 'stateInventoryFailed';
831
+ inventoryErrors.push({
832
+ code,
833
+ message: `${code}: ${error.kind}@${error.location}: ${error.message}`,
834
+ relevance: error.relevance,
835
+ });
836
+ }
837
+ const nativeCliRunner = options.nativeCliRunner ?? getDefaultNativeCliRunner();
838
+ let codexSystemConsumerInspection;
839
+ const inspectCodexSystemConsumer = (scope) => {
840
+ throwIfCancelled();
841
+ let inspection = codexSystemConsumerInspection;
842
+ if (!inspection) {
843
+ inspection = inspectSystemCodex({
844
+ runner: nativeCliRunner,
845
+ cwd: options.cwd,
846
+ env,
847
+ signal: options.signal,
848
+ operationRequirement: getCodexOperationRequirement(scope),
849
+ }).then((result) => {
850
+ throwIfCancelled();
851
+ if (result.state === 'compatible') {
852
+ options.codexObservationSession.setManager(result.manager);
853
+ }
854
+ return result;
855
+ });
856
+ codexSystemConsumerInspection = inspection;
857
+ }
858
+ return inspection;
859
+ };
860
+ const codexRegistrationCache = new Map();
861
+ const inspectCodexRegistration = async (pluginId, scope) => {
862
+ const consumer = await inspectCodexSystemConsumer(scope);
863
+ throwIfCancelled();
864
+ if (consumer.state !== 'compatible') {
865
+ return {
866
+ observation: { state: 'unobserved' },
867
+ observations: { user: false, project: false },
868
+ activations: {},
869
+ };
870
+ }
871
+ let inspection = codexRegistrationCache.get(pluginId);
872
+ if (!inspection) {
873
+ inspection = inspectCodexPluginRegistrationLive({
874
+ pluginId,
875
+ cwd: options.cwd,
876
+ env,
877
+ nativeCliRunner,
878
+ manager: consumer.manager,
879
+ scope: options.scope === 'user' ? 'user' : 'both',
880
+ observationSession: options.codexObservationSession,
881
+ });
882
+ codexRegistrationCache.set(pluginId, inspection);
883
+ }
884
+ return inspection;
885
+ };
886
+ const nativeProbeCache = new Map();
887
+ const codexDesiredUserActivationIds = new Set();
888
+ const readOnlyNativeProbe = (probe) => async () => {
889
+ const key = [
890
+ probe.sourceIdentity,
891
+ probe.pluginName,
892
+ probe.platform,
893
+ probe.scope,
894
+ probe.marketplaceName,
895
+ String(probe.desired),
896
+ ].join('\0');
897
+ let value = nativeProbeCache.get(key);
898
+ if (!value) {
899
+ const hasLocalResidue = ownerInventory.references.some((reference) => (reference.kind === 'namespacedOwner' || reference.kind === 'namespacedMarketplace')
900
+ && reference.sourceId === probe.sourceId
901
+ && reference.pluginName === probe.pluginName
902
+ && reference.platform === probe.platform);
903
+ value = probe.platform === 'codex'
904
+ ? inspectCodexRegistration(`${probe.pluginName}@${probe.marketplaceName}`, options.scope === undefined ? probe.scope : scopes[0]).then((registration) => {
905
+ if (registration.observation.state === 'failed') {
906
+ throw new Error('codexNativeObservationFailed: status requires Codex plugin list evidence.');
907
+ }
908
+ if (registration.observation.state === 'unobserved') {
909
+ return probe.desired || hasLocalResidue ? 'partial' : 'absent';
910
+ }
911
+ if (registration.observation.value === 'absent')
912
+ return 'absent';
913
+ if (!userCodexConfig || (probe.scope === 'project' && !projectCodexConfig)) {
914
+ return 'partial';
915
+ }
916
+ const configEnabled = (probe.scope === 'user'
917
+ ? userCodexConfig
918
+ : projectCodexConfig)?.snapshot.plugins[`${probe.pluginName}@${probe.marketplaceName}`]?.enabled === true;
919
+ return configEnabled
920
+ ? 'present'
921
+ : 'partial';
922
+ })
923
+ : Promise.resolve(ownerInventory.references.some((reference) => (reference.kind === 'namespacedOwner' || reference.kind === 'namespacedMarketplace')
924
+ && reference.sourceId === probe.sourceId
925
+ && reference.sourceIdentity === probe.sourceIdentity
926
+ && reference.pluginName === probe.pluginName
927
+ && reference.platform === probe.platform
928
+ && reference.scope === probe.scope
929
+ && (probe.scope === 'user' || reference.projectKey === currentProjectKey))
930
+ ? 'present'
931
+ : 'absent');
932
+ nativeProbeCache.set(key, value);
933
+ }
934
+ return value;
935
+ };
936
+ const hasCurrentCodexProjectOwner = (sourceId, pluginName) => ownerInventory.references.some((reference) => reference.kind === 'namespacedOwner'
937
+ && reference.sourceId === sourceId
938
+ && reference.pluginName === pluginName
939
+ && reference.platform === 'codex'
940
+ && reference.scope === 'project'
941
+ && reference.projectKey === currentProjectKey);
942
+ const configured = new Map(snapshot.config.sources.map((source) => [source.id, source]));
943
+ const requested = options.plugins ?? [];
944
+ const platforms = selectedPlatforms(options.platform);
945
+ const scopes = selectedScopes(options.scope);
946
+ const selectorErrors = [];
947
+ const parsedSelectors = [];
948
+ const plannedSelectors = [];
949
+ const liveOnlySelectors = [];
950
+ for (const selector of requested) {
951
+ let parsed;
952
+ try {
953
+ parsed = parsePluginId(selector);
954
+ }
955
+ catch (error) {
956
+ selectorErrors.push({
957
+ code: 'invalidPluginSelector',
958
+ message: error instanceof Error ? error.message : String(error),
959
+ });
960
+ continue;
961
+ }
962
+ parsedSelectors.push({ raw: selector, parsed });
963
+ if (parsed.sourceId !== undefined && !configured.has(parsed.sourceId)) {
964
+ const hasLiveReference = ownerInventory.references.some((reference) => (reference.kind === 'namespacedOwner' || reference.kind === 'namespacedMarketplace')
965
+ && reference.sourceId === parsed.sourceId
966
+ && reference.pluginName === parsed.pluginName
967
+ && platforms.includes(reference.platform)
968
+ && scopes.includes(reference.scope)
969
+ && (reference.scope !== 'project' || reference.projectKey === currentProjectKey));
970
+ if (hasLiveReference) {
971
+ liveOnlySelectors.push({ raw: selector, parsed });
972
+ }
973
+ else if (!inventoryErrors.some((error) => inventoryErrorMatchesSelection({
974
+ error,
975
+ selectors: [{ raw: selector, parsed }],
976
+ platformExplicit: options.platform !== undefined,
977
+ scopeExplicit: options.scope !== undefined,
978
+ platforms,
979
+ scopes,
980
+ currentProjectLocationKey,
981
+ }))) {
982
+ selectorErrors.push({
983
+ code: 'pluginNotFound',
984
+ message: `Plugin "${selector}" was not found because catalog source "${parsed.sourceId}" is not configured.`,
985
+ });
986
+ }
987
+ continue;
988
+ }
989
+ plannedSelectors.push({ raw: selector, parsed });
990
+ }
991
+ const selectedInventoryErrors = inventoryErrors.filter((error) => inventoryErrorMatchesSelection({
992
+ error,
993
+ selectors: parsedSelectors,
994
+ platformExplicit: options.platform !== undefined,
995
+ scopeExplicit: options.scope !== undefined,
996
+ platforms,
997
+ scopes,
998
+ currentProjectLocationKey,
999
+ }));
1000
+ const selectorSourceIds = requested.length === 0
1001
+ ? undefined
1002
+ : planPluginSelectorSourceIds(plannedSelectors.map((selector) => selector.parsed));
1003
+ const plannedSourceIds = selectorSourceIds === undefined ? undefined : [...new Set([
1004
+ ...selectorSourceIds,
1005
+ ...(options.catalogOperationContext ? [] : [...observedDemands.values()].flatMap((entry) => entry.roots ?? []))
1006
+ .map((root) => root.sourceId).filter((id) => configured.has(id)),
1007
+ ])];
1008
+ const selectedConfiguredSources = plannedSourceIds === undefined
1009
+ ? snapshot.config.sources
1010
+ : plannedSourceIds.map((sourceId) => configured.get(sourceId));
1011
+ const identityEntries = await Promise.all(selectedConfiguredSources.map(async (source) => {
1012
+ try {
1013
+ return [source.id, { identity: await calculateCatalogSourceIdentity(source) }];
1014
+ }
1015
+ catch (error) {
1016
+ const sanitized = sanitizeCatalogSourceError(error, env);
1017
+ return [source.id, {
1018
+ error: sanitized.message,
1019
+ }];
1020
+ }
1021
+ }));
1022
+ const identities = new Map(identityEntries);
1023
+ const catalog = await withResolvedMultiSourceCatalog({
1024
+ cliVersion,
1025
+ configSnapshot: snapshot,
1026
+ ...(plannedSourceIds === undefined ? {} : { sourceIds: plannedSourceIds }),
1027
+ ...(options.catalogOperationContext
1028
+ ? { operationContext: options.catalogOperationContext }
1029
+ : {}),
1030
+ env,
1031
+ signal: options.signal,
1032
+ consume: async (resolution) => ({
1033
+ primarySourceId: resolution.primarySourceId,
1034
+ configDigest: resolution.configDigest,
1035
+ compositeDigest: resolution.compositeDigest,
1036
+ sources: await Promise.all(resolution.sources.map(async (item) => {
1037
+ throwIfCancelled();
1038
+ const source = configured.get(item.sourceId);
1039
+ const identity = identities.get(item.sourceId);
1040
+ const base = {
1041
+ id: item.sourceId,
1042
+ identity: identity.identity ?? 'unavailable',
1043
+ type: source.type,
1044
+ primary: source.primary,
1045
+ requestedRef: item.resolution?.requestedRef ?? sourceRequestedRef(source, cliVersion),
1046
+ };
1047
+ if (identity.error || item.error) {
1048
+ const error = item.error ?? new Error(identity.error);
1049
+ return {
1050
+ ...base,
1051
+ error: [identity.error, item.error?.message].filter(Boolean).join('; '),
1052
+ errorCode: catalogSourceErrorCode(error),
1053
+ };
1054
+ }
1055
+ try {
1056
+ const catalogEntriesByName = new Map(item.resolution.manifest.entries.map((entry) => [
1057
+ entry.name,
1058
+ entry,
1059
+ ]));
1060
+ const cyclicDependencyPluginNames = new Set();
1061
+ const dependencyVisitState = new Map();
1062
+ const dependencyVisitStack = [];
1063
+ const visitDependencyGraph = (pluginName) => {
1064
+ const state = dependencyVisitState.get(pluginName);
1065
+ if (state === 'visited')
1066
+ return;
1067
+ if (state === 'visiting') {
1068
+ const cycleStart = dependencyVisitStack.lastIndexOf(pluginName);
1069
+ for (const name of dependencyVisitStack.slice(cycleStart)) {
1070
+ cyclicDependencyPluginNames.add(name);
1071
+ }
1072
+ return;
1073
+ }
1074
+ dependencyVisitState.set(pluginName, 'visiting');
1075
+ dependencyVisitStack.push(pluginName);
1076
+ for (const dependencyName of catalogEntriesByName.get(pluginName)?.dependencies ?? []) {
1077
+ if (catalogEntriesByName.has(dependencyName))
1078
+ visitDependencyGraph(dependencyName);
1079
+ }
1080
+ dependencyVisitStack.pop();
1081
+ dependencyVisitState.set(pluginName, 'visited');
1082
+ };
1083
+ for (const pluginName of catalogEntriesByName.keys())
1084
+ visitDependencyGraph(pluginName);
1085
+ const placementEntries = item.resolution.manifest.entries.map((entry) => {
1086
+ const supportedPlatforms = resolveCatalogEntrySupportedPlatforms(entry.policy);
1087
+ return {
1088
+ name: entry.name,
1089
+ dependencies: entry.dependencies,
1090
+ source: { id: item.resolution.sourceId },
1091
+ targets: {
1092
+ codex: {
1093
+ user: supportedPlatforms.has('codex'),
1094
+ project: supportedPlatforms.has('codex'),
1095
+ },
1096
+ claude: {
1097
+ user: supportedPlatforms.has('claude'),
1098
+ project: supportedPlatforms.has('claude'),
1099
+ },
1100
+ },
1101
+ };
1102
+ });
1103
+ const sourceDesired = calculateDesiredTargetStates({
1104
+ userIntent,
1105
+ projectIntent,
1106
+ available: placementEntries,
1107
+ codexProjectAllowed: !codexScopePathsAlias,
1108
+ });
1109
+ const registeredNames = canonicalMarketplaceRegistrationNames(ownerInventory.references, item.resolution.sourceId);
1110
+ if (registeredNames.length > 1) {
1111
+ throw new Error('marketplaceIdentityUnavailable: Multiple canonical native marketplace registrations match the source.');
1112
+ }
1113
+ const desiredMarketplaceName = registeredNames[0]
1114
+ ?? (item.resolution.sourceId === resolution.primarySourceId
1115
+ ? 'aw'
1116
+ : `aw-${item.resolution.sourceId}`);
1117
+ for (const entry of placementEntries) {
1118
+ const pluginId = formatPluginId({
1119
+ sourceId: item.resolution.sourceId,
1120
+ pluginName: entry.name,
1121
+ });
1122
+ if (options.scope === 'project'
1123
+ ? userCodexConfig?.snapshot.plugins[`${entry.name}@${desiredMarketplaceName}`]?.enabled === true
1124
+ : sourceDesired.get(desiredTargetKey(pluginId, 'codex'))?.scopes.includes('user')) {
1125
+ codexDesiredUserActivationIds.add(`${entry.name}@${desiredMarketplaceName}`);
1126
+ }
1127
+ }
1128
+ const plugins = await Promise.all(item.resolution.manifest.entries.map(async (entry) => {
1129
+ throwIfCancelled();
1130
+ const capabilitySupport = checkAwCapabilitySupport(entry.requires.aw.capabilities ?? [], IMPLEMENTED_AW_CAPABILITIES);
1131
+ if (!capabilitySupport.supported) {
1132
+ const supportedPlatforms = resolveCatalogEntrySupportedPlatforms(entry.policy);
1133
+ const states = {};
1134
+ const message = `awCapabilityUnsupported: ${item.resolution.sourceId}/${entry.name} requires unsupported AW capabilities: ${capabilitySupport.missing.join(', ')}.`;
1135
+ for (const platform of ['codex', 'claude']) {
1136
+ if (!supportedPlatforms.has(platform))
1137
+ continue;
1138
+ states[platform] = {};
1139
+ for (const scope of ['user', 'project']) {
1140
+ states[platform][scope] = {
1141
+ state: 'error',
1142
+ components: [],
1143
+ errors: [finalizeTargetError({ code: 'awCapabilityUnsupported', message }, 'error')],
1144
+ };
1145
+ }
1146
+ }
1147
+ return {
1148
+ name: entry.name,
1149
+ version: entry.version,
1150
+ displayName: entry.interface?.displayName ?? entry.name,
1151
+ shortDescription: entry.interface?.shortDescription ?? entry.description,
1152
+ description: entry.description,
1153
+ targets: {
1154
+ claude: {
1155
+ user: supportedPlatforms.has('claude'),
1156
+ project: supportedPlatforms.has('claude'),
1157
+ },
1158
+ codex: {
1159
+ user: supportedPlatforms.has('codex'),
1160
+ project: supportedPlatforms.has('codex'),
1161
+ },
1162
+ },
1163
+ states,
1164
+ dependencies: entry.dependencies,
1165
+ missingCapabilities: capabilitySupport.missing,
1166
+ };
1167
+ }
1168
+ const plugin = await readPluginManifest(path.join(item.resolution.rootDir, 'plugins', entry.name), { mode: 'bundle' });
1169
+ const claude = supportsPlatform(plugin.manifest, 'claude');
1170
+ const codex = supportsPlatform(plugin.manifest, 'codex');
1171
+ const codexSurface = analyzeCodexSurface(plugin.manifest);
1172
+ plugin.sourceId = item.resolution.sourceId;
1173
+ plugin.sourceIdentity = item.resolution.sourceIdentity;
1174
+ plugin.catalogLogicalIdentity = item.resolution.logicalIdentity;
1175
+ plugin.pluginId = formatPluginId({ sourceId: item.resolution.sourceId, pluginName: entry.name });
1176
+ let configIssues;
1177
+ let configDiagnostic;
1178
+ if (plugin.manifest.config?.fields) {
1179
+ const issues = new Map();
1180
+ for (const platform of ['codex', 'claude']) {
1181
+ if (!supportsPlatform(plugin.manifest, platform))
1182
+ continue;
1183
+ for (const scope of scopes) {
1184
+ try {
1185
+ const resolved = scope === 'project'
1186
+ ? await resolveProjectArtifactRenderConfig({
1187
+ sourceId: plugin.sourceId,
1188
+ sourceIdentity: plugin.sourceIdentity,
1189
+ logicalIdentity: plugin.catalogLogicalIdentity,
1190
+ pluginName: plugin.manifest.name,
1191
+ manifest: plugin.manifest,
1192
+ platform,
1193
+ cwd: options.cwd,
1194
+ env,
1195
+ })
1196
+ : await resolveEffectivePluginConfig({
1197
+ sourceId: plugin.sourceId,
1198
+ sourceIdentity: plugin.sourceIdentity,
1199
+ logicalIdentity: plugin.catalogLogicalIdentity,
1200
+ pluginName: plugin.manifest.name,
1201
+ manifest: plugin.manifest,
1202
+ platform,
1203
+ targetScope: 'user',
1204
+ cwd: options.cwd,
1205
+ env,
1206
+ });
1207
+ for (const issue of resolved.issues) {
1208
+ const source = issue.source ?? 'missing';
1209
+ const configIssue = {
1210
+ scope,
1211
+ platform,
1212
+ type: issue.type,
1213
+ key: issue.key,
1214
+ title: resolved.schema[issue.key]?.title ?? issue.key,
1215
+ source,
1216
+ };
1217
+ issues.set(`${platform}\0${scope}\0${configIssue.type}\0${configIssue.key}\0${configIssue.source}`, configIssue);
1218
+ }
1219
+ for (const override of resolved.unsupportedLayerOverrides) {
1220
+ const configIssue = {
1221
+ scope,
1222
+ platform,
1223
+ type: override.type,
1224
+ key: override.key,
1225
+ title: resolved.schema[override.key]?.title ?? override.key,
1226
+ source: override.source,
1227
+ };
1228
+ issues.set(`${platform}\0${scope}\0${configIssue.type}\0${configIssue.key}\0${configIssue.source}`, configIssue);
1229
+ }
1230
+ }
1231
+ catch {
1232
+ configDiagnostic ??= {
1233
+ scope,
1234
+ code: 'configReadFailed',
1235
+ message: '插件设置当前不可读。未读取或显示设置值。',
1236
+ };
1237
+ }
1238
+ }
1239
+ }
1240
+ configIssues = [...issues.values()];
1241
+ }
1242
+ const states = {};
1243
+ const defaultMarketplaceName = item.resolution.sourceId === resolution.primarySourceId
1244
+ ? 'aw'
1245
+ : `aw-${item.resolution.sourceId}`;
1246
+ const marketplaceNameFor = (pluginName, platform, scope) => {
1247
+ const liveName = ownerInventory.references.find((reference) => (reference.kind === 'namespacedOwner' || reference.kind === 'namespacedMarketplace')
1248
+ && reference.sourceId === item.resolution.sourceId
1249
+ && reference.sourceIdentity === item.resolution.sourceIdentity
1250
+ && reference.pluginName === pluginName
1251
+ && reference.platform === platform
1252
+ && reference.scope === scope
1253
+ && (scope === 'user' || reference.projectKey === currentProjectKey)
1254
+ && reference.marketplaceName)?.marketplaceName;
1255
+ if (liveName)
1256
+ return liveName;
1257
+ const registeredNames = canonicalMarketplaceRegistrationNames(ownerInventory.references, item.resolution.sourceId);
1258
+ if (registeredNames.length > 1) {
1259
+ throw new Error('marketplaceIdentityUnavailable: Multiple canonical native marketplace registrations match the source.');
1260
+ }
1261
+ return registeredNames[0] ?? defaultMarketplaceName;
1262
+ };
1263
+ const marketplaceRoot = path.join(resolveAwHome(env), 'marketplaces', item.resolution.sourceId);
1264
+ for (const platform of ['codex', 'claude']) {
1265
+ states[platform] = {};
1266
+ for (const scope of ['user', 'project']) {
1267
+ throwIfCancelled();
1268
+ if (platform === 'codex'
1269
+ && scope === 'project'
1270
+ && codexScopePathsAlias
1271
+ && !hasCurrentCodexProjectOwner(item.resolution.sourceId, entry.name))
1272
+ continue;
1273
+ const supported = platform === 'claude'
1274
+ ? claude
1275
+ : codex && codexSurface.ok;
1276
+ if (!supported)
1277
+ continue;
1278
+ const changedOwner = ownerInventory.references.find((reference) => (reference.kind === 'namespacedOwner' || reference.kind === 'namespacedMarketplace')
1279
+ && reference.sourceId === item.resolution.sourceId
1280
+ && reference.pluginName === entry.name
1281
+ && reference.platform === platform
1282
+ && reference.scope === scope
1283
+ && (scope === 'user' || reference.projectKey === currentProjectKey)
1284
+ && reference.sourceIdentity
1285
+ && reference.sourceIdentity !== item.resolution.sourceIdentity);
1286
+ if (changedOwner) {
1287
+ states[platform][scope] = {
1288
+ state: 'error',
1289
+ components: [],
1290
+ errors: [finalizeTargetError({
1291
+ code: 'sourceChanged',
1292
+ message: `sourceChanged: owner at ${changedOwner.location} has a different source identity.`,
1293
+ }, 'error')],
1294
+ };
1295
+ continue;
1296
+ }
1297
+ try {
1298
+ const marketplaceName = marketplaceNameFor(entry.name, platform, scope);
1299
+ const inspected = await inspectRebuildTarget({
1300
+ sourceId: item.resolution.sourceId,
1301
+ sourceIdentity: item.resolution.sourceIdentity,
1302
+ pluginId: plugin.pluginId,
1303
+ marketplaceName,
1304
+ marketplaceRoot,
1305
+ plugin,
1306
+ platform,
1307
+ scope,
1308
+ cwd: options.cwd,
1309
+ catalog: {
1310
+ rootDir: item.resolution.rootDir,
1311
+ source: 'local',
1312
+ },
1313
+ context: {
1314
+ env,
1315
+ nativeCliRunner,
1316
+ reporter: createNoopReporter(),
1317
+ debugLogger: createNoopDebugLogger(),
1318
+ codexObservationSession: options.codexObservationSession,
1319
+ },
1320
+ userActivationDesired: codexDesiredUserActivationIds,
1321
+ nativeProbe: readOnlyNativeProbe({
1322
+ pluginName: entry.name,
1323
+ sourceId: item.resolution.sourceId,
1324
+ sourceIdentity: item.resolution.sourceIdentity,
1325
+ platform,
1326
+ scope,
1327
+ marketplaceName,
1328
+ marketplaceRoot,
1329
+ desired: sourceDesired.get(desiredTargetKey(plugin.pluginId, platform))
1330
+ ?.scopes.includes(scope) === true,
1331
+ }),
1332
+ shallow: true,
1333
+ });
1334
+ const liveState = projectedLiveState({
1335
+ inspection: inspected.inspection,
1336
+ required: inspected.target.desiredOwnedComponents ?? inspected.target.ownedComponents,
1337
+ optional: inspected.target.optionalOwnedComponents ?? [],
1338
+ });
1339
+ const collisionErrors = inspected.inspection.components.flatMap((component) => component.collision ? [finalizeTargetError({
1340
+ code: 'artifactCollision',
1341
+ message: collisionMessage(component.collision),
1342
+ collision: component.collision,
1343
+ rootIssueId: collisionRootIssueId({
1344
+ pluginId: formatPluginId({
1345
+ sourceId: item.resolution.sourceId,
1346
+ pluginName: entry.name,
1347
+ }),
1348
+ platform,
1349
+ scope,
1350
+ collision: component.collision,
1351
+ }),
1352
+ rootIssueCode: 'artifactCollision',
1353
+ }, liveState)] : []);
1354
+ const dependencyErrors = [];
1355
+ const dependencyReadiness = [];
1356
+ const directDependencies = plugin.manifest.dependencies ?? [];
1357
+ const desiredInScope = sourceDesired.get(desiredTargetKey(plugin.pluginId, platform))?.scopes.includes(scope) === true;
1358
+ const codexPluginId = `${entry.name}@${marketplaceName}`;
1359
+ const actualCodexActivation = platform === 'codex'
1360
+ && (scope === 'user' ? userCodexConfig : projectCodexConfig)
1361
+ ?.snapshot.plugins[codexPluginId]?.enabled === true;
1362
+ const hasScopedExtensionResidue = platform === 'codex'
1363
+ && inspected.inspection.components.some((component) => component.component.kind !== 'native-plugin'
1364
+ && !component.component.identity.artifactKey.startsWith('activation-')
1365
+ && !component.component.identity.artifactKey.startsWith('marketplace-')
1366
+ && (component.state !== 'absent' || component.collision !== undefined));
1367
+ const dependencyPriority = {
1368
+ ready: 5,
1369
+ blockedByCollision: 4,
1370
+ incomplete: 3,
1371
+ error: 2,
1372
+ absent: 1,
1373
+ };
1374
+ function dependencyPlacementsFor(dependencyId, consumerScope) {
1375
+ const dependencyOverride = (consumerScope === 'project'
1376
+ ? projectIntent
1377
+ : userIntent).dependencyScopeOverrides.find((override) => override.pluginId === dependencyId
1378
+ && (override.platform === undefined || override.platform === platform));
1379
+ return dependencyOverride
1380
+ ? [dependencyOverride.scope]
1381
+ : consumerScope === 'project' ? ['project', 'user'] : ['user'];
1382
+ }
1383
+ async function inspectDependencyAtScope(dependencyName, dependencyScope) {
1384
+ const dependencyId = formatPluginId({
1385
+ sourceId: item.resolution.sourceId,
1386
+ pluginName: dependencyName,
1387
+ });
1388
+ const inspectionCacheKey = [
1389
+ item.resolution.sourceIdentity,
1390
+ dependencyId,
1391
+ platform,
1392
+ dependencyScope,
1393
+ dependencyScope === 'project' ? currentProjectKey : '',
1394
+ ].join('\0');
1395
+ if (cyclicDependencyPluginNames.has(dependencyName)) {
1396
+ return {
1397
+ state: 'error',
1398
+ dependencyScope,
1399
+ rootIssueId: `dependencyGraphInvalid:${dependencyId}`,
1400
+ rootIssueCode: 'dependencyGraphInvalid',
1401
+ issuePluginId: dependencyId,
1402
+ issueScope: dependencyScope,
1403
+ };
1404
+ }
1405
+ const cached = dependencyInspectionCache.get(inspectionCacheKey);
1406
+ if (cached)
1407
+ return cached;
1408
+ const inspection = (async () => {
1409
+ const dependencyEntry = item.resolution.manifest.entries.find((candidate) => candidate.name === dependencyName);
1410
+ if (!dependencyEntry) {
1411
+ return {
1412
+ state: 'absent',
1413
+ dependencyScope,
1414
+ rootIssueId: `dependencyMissing:${dependencyId}:${platform}:${dependencyScope}`,
1415
+ rootIssueCode: 'dependencyMissing',
1416
+ issuePluginId: dependencyId,
1417
+ issueScope: dependencyScope,
1418
+ };
1419
+ }
1420
+ const dependencySupport = checkAwCapabilitySupport(dependencyEntry.requires.aw.capabilities ?? [], IMPLEMENTED_AW_CAPABILITIES);
1421
+ if (!dependencySupport.supported) {
1422
+ return {
1423
+ state: 'error',
1424
+ dependencyScope,
1425
+ rootIssueId: `awCapabilityUnsupported:${dependencyId}`,
1426
+ rootIssueCode: 'awCapabilityUnsupported',
1427
+ issuePluginId: dependencyId,
1428
+ issueScope: dependencyScope,
1429
+ missingCapabilities: dependencySupport.missing,
1430
+ };
1431
+ }
1432
+ const pluginCacheKey = [item.resolution.sourceIdentity, dependencyId].join('\0');
1433
+ let dependencyPluginPromise = dependencyPluginCache.get(pluginCacheKey);
1434
+ if (!dependencyPluginPromise) {
1435
+ dependencyPluginPromise = readPluginManifest(path.join(item.resolution.rootDir, 'plugins', dependencyName), { mode: 'bundle' }).then((dependencyPlugin) => {
1436
+ dependencyPlugin.sourceId = item.resolution.sourceId;
1437
+ dependencyPlugin.sourceIdentity = item.resolution.sourceIdentity;
1438
+ dependencyPlugin.catalogLogicalIdentity = item.resolution.logicalIdentity;
1439
+ dependencyPlugin.pluginId = dependencyId;
1440
+ return dependencyPlugin;
1441
+ });
1442
+ dependencyPluginCache.set(pluginCacheKey, dependencyPluginPromise);
1443
+ }
1444
+ const dependencyPlugin = await dependencyPluginPromise;
1445
+ dependencyInspectionHookForTests?.();
1446
+ const dependencyMarketplaceName = marketplaceNameFor(dependencyName, platform, dependencyScope);
1447
+ const dependencyInspected = await inspectRebuildTarget({
1448
+ sourceId: item.resolution.sourceId,
1449
+ sourceIdentity: item.resolution.sourceIdentity,
1450
+ pluginId: dependencyId,
1451
+ marketplaceName: dependencyMarketplaceName,
1452
+ marketplaceRoot,
1453
+ plugin: dependencyPlugin,
1454
+ platform,
1455
+ scope: dependencyScope,
1456
+ cwd: options.cwd,
1457
+ catalog: { rootDir: item.resolution.rootDir, source: 'local' },
1458
+ context: {
1459
+ env,
1460
+ nativeCliRunner,
1461
+ reporter: createNoopReporter(),
1462
+ debugLogger: createNoopDebugLogger(),
1463
+ codexObservationSession: options.codexObservationSession,
1464
+ },
1465
+ userActivationDesired: codexDesiredUserActivationIds,
1466
+ nativeProbe: readOnlyNativeProbe({
1467
+ pluginName: dependencyName,
1468
+ sourceId: item.resolution.sourceId,
1469
+ sourceIdentity: item.resolution.sourceIdentity,
1470
+ platform,
1471
+ scope: dependencyScope,
1472
+ marketplaceName: dependencyMarketplaceName,
1473
+ marketplaceRoot,
1474
+ desired: sourceDesired.get(desiredTargetKey(dependencyId, platform))
1475
+ ?.scopes.includes(dependencyScope) === true,
1476
+ }),
1477
+ shallow: true,
1478
+ });
1479
+ const dependencyLiveState = projectedLiveState({
1480
+ inspection: dependencyInspected.inspection,
1481
+ required: dependencyInspected.target.desiredOwnedComponents
1482
+ ?? dependencyInspected.target.ownedComponents,
1483
+ optional: dependencyInspected.target.optionalOwnedComponents ?? [],
1484
+ });
1485
+ const collision = dependencyInspected.inspection.components.find((component) => component.collision)?.collision;
1486
+ if (collision) {
1487
+ return {
1488
+ state: 'blockedByCollision',
1489
+ dependencyScope,
1490
+ rootIssueId: collisionRootIssueId({
1491
+ pluginId: dependencyId,
1492
+ platform,
1493
+ scope: dependencyScope,
1494
+ collision,
1495
+ }),
1496
+ rootIssueCode: 'artifactCollision',
1497
+ issuePluginId: dependencyId,
1498
+ issueScope: dependencyScope,
1499
+ };
1500
+ }
1501
+ const requiredDependencyComponents = dependencyInspected.target
1502
+ .desiredOwnedComponents ?? dependencyInspected.target.ownedComponents;
1503
+ const desiredDependency = sourceDesired.get(desiredTargetKey(dependencyId, platform));
1504
+ const projectMigrationPending = dependencyScope === 'project'
1505
+ && projectIntent.dependencyScopeOverrides.some((override) => override.pluginId === dependencyId
1506
+ && override.scope === 'project'
1507
+ && (override.platform === undefined || override.platform === platform))
1508
+ && desiredDependency?.scopes.includes('project') === true
1509
+ && desiredDependency.scopes.includes('user') === false
1510
+ && ownerInventory.references.some((reference) => reference.kind === 'namespacedOwner'
1511
+ && reference.sourceId === item.resolution.sourceId
1512
+ && reference.pluginName === dependencyName
1513
+ && reference.platform === platform
1514
+ && reference.scope === 'user');
1515
+ const migrationOnlyPartial = dependencyLiveState === 'partial'
1516
+ && projectMigrationPending
1517
+ && dependencyInspected.inspection.components.every((component) => component.state === 'present' || component.state === 'absent')
1518
+ && requiredDependencyComponents.every((required) => dependencyInspected.inspection.components.some((component) => component.component === required
1519
+ && (component.state === 'present'
1520
+ || component.state === 'absent'
1521
+ && component.component.kind !== 'native-plugin'
1522
+ && 'locator' in component.component
1523
+ && component.component.locator.kind === 'codex-activation'
1524
+ && component.component.locator.desired === false)));
1525
+ const effectiveDependencyLiveState = migrationOnlyPartial
1526
+ ? 'present'
1527
+ : dependencyLiveState;
1528
+ if (effectiveDependencyLiveState !== 'present') {
1529
+ const state = effectiveDependencyLiveState === 'absent' ? 'absent'
1530
+ : effectiveDependencyLiveState === 'partial' ? 'incomplete'
1531
+ : 'error';
1532
+ return {
1533
+ state,
1534
+ dependencyScope,
1535
+ rootIssueId: state === 'absent'
1536
+ ? `dependencyMissing:${dependencyId}:${platform}:${dependencyScope}`
1537
+ : state === 'incomplete'
1538
+ ? `incompleteInstallation:${dependencyId}:${platform}:${dependencyScope}`
1539
+ : `diagnostic:${dependencyId}:${platform}:${dependencyScope}`,
1540
+ rootIssueCode: state === 'absent' ? 'dependencyMissing'
1541
+ : state === 'incomplete' ? 'incompleteInstallation' : 'diagnostic',
1542
+ issuePluginId: dependencyId,
1543
+ issueScope: dependencyScope,
1544
+ };
1545
+ }
1546
+ for (const childName of dependencyPlugin.manifest.dependencies ?? []) {
1547
+ const childId = formatPluginId({
1548
+ sourceId: item.resolution.sourceId,
1549
+ pluginName: childName,
1550
+ });
1551
+ let childResult;
1552
+ for (const childScope of dependencyPlacementsFor(childId, dependencyScope)) {
1553
+ const candidate = await inspectDependencyAtScope(childName, childScope);
1554
+ if (candidate.state === 'ready') {
1555
+ childResult = candidate;
1556
+ break;
1557
+ }
1558
+ if (!childResult
1559
+ || dependencyPriority[candidate.state]
1560
+ > dependencyPriority[childResult.state]) {
1561
+ childResult = candidate;
1562
+ }
1563
+ }
1564
+ if (childResult?.state !== 'ready') {
1565
+ return {
1566
+ ...childResult,
1567
+ dependencyScope,
1568
+ };
1569
+ }
1570
+ }
1571
+ return { state: 'ready', dependencyScope };
1572
+ })().catch((error) => {
1573
+ throwIfCancelled(error);
1574
+ return {
1575
+ state: 'error',
1576
+ dependencyScope,
1577
+ rootIssueId: `diagnostic:${dependencyId}:${platform}:${dependencyScope}`,
1578
+ rootIssueCode: 'diagnostic',
1579
+ issuePluginId: dependencyId,
1580
+ issueScope: dependencyScope,
1581
+ };
1582
+ });
1583
+ dependencyInspectionCache.set(inspectionCacheKey, inspection);
1584
+ return inspection;
1585
+ }
1586
+ // Inspect dependencies for returned live placements and selected project Agents.
1587
+ const dependencyObservationRequested = platforms.includes(platform) && scopes.includes(scope)
1588
+ || scope === 'project' && projectObservationPlatforms.includes(platform);
1589
+ if (dependencyObservationRequested && directDependencies.length > 0
1590
+ && (desiredInScope
1591
+ || actualCodexActivation
1592
+ || hasScopedExtensionResidue
1593
+ || (platform !== 'codex'
1594
+ && (liveState === 'present' || liveState === 'partial')))) {
1595
+ for (const dependencyName of directDependencies) {
1596
+ const dependencyId = formatPluginId({
1597
+ sourceId: item.resolution.sourceId,
1598
+ pluginName: dependencyName,
1599
+ });
1600
+ const dependencyEntry = item.resolution.manifest.entries.find((candidate) => candidate.name === dependencyName);
1601
+ if (!dependencyEntry) {
1602
+ const rootIssueId = `dependencyMissing:${dependencyId}:${platform}:${scope}`;
1603
+ dependencyReadiness.push({
1604
+ dependencyPluginId: dependencyId,
1605
+ dependencyPlatform: platform,
1606
+ dependencyScope: scope,
1607
+ dependencyProject: scope === 'project' ? 'current' : null,
1608
+ state: 'absent',
1609
+ rootIssueId,
1610
+ rootIssueCode: 'dependencyMissing',
1611
+ });
1612
+ dependencyErrors.push(finalizeTargetError({
1613
+ code: 'dependencyMissing',
1614
+ message: `dependencyMissing: ${dependencyId} is not available in the current source snapshot.`,
1615
+ dependencyPluginId: dependencyId,
1616
+ dependencyPlatform: platform,
1617
+ dependencyScope: scope,
1618
+ dependencyProject: scope === 'project' ? 'current' : null,
1619
+ rootIssueId,
1620
+ rootIssueCode: 'dependencyMissing',
1621
+ }, 'partial'));
1622
+ continue;
1623
+ }
1624
+ const dependencySupport = checkAwCapabilitySupport(dependencyEntry.requires.aw.capabilities ?? [], IMPLEMENTED_AW_CAPABILITIES);
1625
+ if (!dependencySupport.supported) {
1626
+ const rootIssueId = `awCapabilityUnsupported:${dependencyId}`;
1627
+ dependencyReadiness.push({
1628
+ dependencyPluginId: dependencyId,
1629
+ dependencyPlatform: platform,
1630
+ dependencyScope: scope,
1631
+ dependencyProject: scope === 'project' ? 'current' : null,
1632
+ state: 'error',
1633
+ rootIssueId,
1634
+ rootIssueCode: 'awCapabilityUnsupported',
1635
+ });
1636
+ dependencyErrors.push(finalizeTargetError({
1637
+ code: 'awCapabilityUnsupported',
1638
+ message: `awCapabilityUnsupported: ${dependencyId} requires unsupported AW capabilities: ${dependencySupport.missing.join(', ')}.`,
1639
+ dependencyPluginId: dependencyId,
1640
+ dependencyPlatform: platform,
1641
+ dependencyScope: scope,
1642
+ dependencyProject: scope === 'project' ? 'current' : null,
1643
+ rootIssueId,
1644
+ rootIssueCode: 'awCapabilityUnsupported',
1645
+ }, 'partial'));
1646
+ continue;
1647
+ }
1648
+ const placements = dependencyPlacementsFor(dependencyId, scope);
1649
+ let dependencyResult = {
1650
+ state: 'absent',
1651
+ };
1652
+ for (const dependencyScope of placements) {
1653
+ const candidate = await inspectDependencyAtScope(dependencyName, dependencyScope);
1654
+ if (candidate.state === 'ready') {
1655
+ dependencyResult = candidate;
1656
+ break;
1657
+ }
1658
+ const priority = {
1659
+ ready: 5,
1660
+ blockedByCollision: 4,
1661
+ incomplete: 3,
1662
+ error: 2,
1663
+ absent: 1,
1664
+ };
1665
+ if (priority[candidate.state] > priority[dependencyResult.state]) {
1666
+ dependencyResult = candidate;
1667
+ }
1668
+ }
1669
+ if (dependencyResult.state === 'absent' && !dependencyResult.rootIssueId) {
1670
+ const dependencyScope = dependencyResult.dependencyScope ?? placements[0];
1671
+ dependencyResult = {
1672
+ state: 'absent',
1673
+ dependencyScope,
1674
+ rootIssueId: `dependencyMissing:${dependencyId}:${platform}:${dependencyScope}`,
1675
+ rootIssueCode: 'dependencyMissing',
1676
+ };
1677
+ }
1678
+ const dependencyScope = dependencyResult.dependencyScope ?? placements[0];
1679
+ dependencyReadiness.push({
1680
+ dependencyPluginId: dependencyId,
1681
+ dependencyPlatform: platform,
1682
+ dependencyScope,
1683
+ dependencyProject: dependencyScope === 'project' ? 'current' : null,
1684
+ state: dependencyResult.state,
1685
+ ...(dependencyResult.rootIssueId
1686
+ ? { rootIssueId: dependencyResult.rootIssueId }
1687
+ : {}),
1688
+ ...(dependencyResult.rootIssueCode
1689
+ ? { rootIssueCode: dependencyResult.rootIssueCode }
1690
+ : {}),
1691
+ });
1692
+ const issuePluginId = dependencyResult.issuePluginId ?? dependencyId;
1693
+ const issueScope = dependencyResult.issueScope ?? dependencyScope;
1694
+ if (dependencyResult.state === 'absent') {
1695
+ dependencyErrors.push(finalizeTargetError({
1696
+ code: 'dependencyMissing',
1697
+ message: `dependencyMissing: ${issuePluginId} is absent from its required live placement.`,
1698
+ dependencyPluginId: issuePluginId,
1699
+ dependencyPlatform: platform,
1700
+ dependencyScope: issueScope,
1701
+ dependencyProject: issueScope === 'project' ? 'current' : null,
1702
+ rootIssueId: dependencyResult.rootIssueId,
1703
+ rootIssueCode: dependencyResult.rootIssueCode,
1704
+ }, 'partial'));
1705
+ }
1706
+ else if (dependencyResult.state !== 'ready') {
1707
+ const code = dependencyResult.rootIssueCode === 'awCapabilityUnsupported'
1708
+ ? 'awCapabilityUnsupported'
1709
+ : dependencyResult.rootIssueCode === 'dependencyGraphInvalid'
1710
+ ? 'dependencyGraphInvalid'
1711
+ : 'dependencyNotReady';
1712
+ const message = code === 'awCapabilityUnsupported'
1713
+ ? `${code}: ${issuePluginId} requires unsupported AW capabilities: ${(dependencyResult.missingCapabilities ?? []).join(', ')}.`
1714
+ : code === 'dependencyGraphInvalid'
1715
+ ? `${code}: dependency cycle includes ${issuePluginId}.`
1716
+ : `${code}: ${issuePluginId} is not ready at its required live placement.`;
1717
+ dependencyErrors.push(finalizeTargetError({
1718
+ code,
1719
+ message,
1720
+ dependencyPluginId: issuePluginId,
1721
+ dependencyPlatform: platform,
1722
+ dependencyScope: issueScope,
1723
+ dependencyProject: issueScope === 'project' ? 'current' : null,
1724
+ ...(dependencyResult.rootIssueId
1725
+ ? { rootIssueId: dependencyResult.rootIssueId }
1726
+ : {}),
1727
+ ...(dependencyResult.rootIssueCode
1728
+ ? { rootIssueCode: dependencyResult.rootIssueCode }
1729
+ : {}),
1730
+ }, 'partial'));
1731
+ }
1732
+ }
1733
+ }
1734
+ states[platform][scope] = {
1735
+ state: liveState,
1736
+ errors: [...inspected.inspection.errors.map((error) => projectTargetError({
1737
+ code: 'componentInspectionFailed',
1738
+ message: `${error.label}: ${error.message}`,
1739
+ }, env, options.cwd, liveState)), ...collisionErrors, ...dependencyErrors],
1740
+ ...(dependencyReadiness.length > 0 ? { dependencyReadiness } : {}),
1741
+ components: inspected.inspection.components.map((component) => {
1742
+ const projectedError = component.collision
1743
+ ? projectTargetError({
1744
+ code: 'artifactCollision',
1745
+ message: collisionMessage(component.collision),
1746
+ collision: component.collision,
1747
+ }, env, options.cwd, liveState)
1748
+ : component.diagnostic
1749
+ ? projectTargetError({
1750
+ code: 'componentInspectionFailed',
1751
+ message: component.diagnostic,
1752
+ }, env, options.cwd, liveState)
1753
+ : undefined;
1754
+ return {
1755
+ key: component.component.identity.artifactKey,
1756
+ state: component.state,
1757
+ ...(projectedError ? { error: projectedError } : {}),
1758
+ };
1759
+ }),
1760
+ ...(inspected.installedVersion
1761
+ ? { installedVersion: inspected.installedVersion }
1762
+ : {}),
1763
+ };
1764
+ }
1765
+ catch (error) {
1766
+ throwIfCancelled(error);
1767
+ const message = error instanceof Error ? error.message : String(error);
1768
+ const configErrorCode = platform === 'codex' && codexConfigErrors.length > 0
1769
+ ? codexSurface.nativeKinds.length > 0
1770
+ ? 'codexSharedNativeCorrupt'
1771
+ : 'codexActivationDrift'
1772
+ : undefined;
1773
+ const code = configErrorCode
1774
+ ?? /^([A-Za-z][A-Za-z0-9]*):/u.exec(message)?.[1]
1775
+ ?? 'targetInspectionFailed';
1776
+ states[platform][scope] = {
1777
+ state: 'error',
1778
+ components: [],
1779
+ errors: [projectTargetError({
1780
+ code,
1781
+ message: configErrorCode
1782
+ ? `${configErrorCode}: Codex activation state is unreadable.`
1783
+ : message,
1784
+ }, env, options.cwd, 'error')],
1785
+ };
1786
+ }
1787
+ }
1788
+ }
1789
+ let codexStatus;
1790
+ if (codex && codexSurface.ok) {
1791
+ const marketplaceName = marketplaceNameFor(entry.name, 'codex', 'user');
1792
+ const codexPluginId = `${entry.name}@${marketplaceName}`;
1793
+ const desiredCodexScopes = sourceDesired.get(desiredTargetKey(formatPluginId({ sourceId: item.resolution.sourceId, pluginName: entry.name }), 'codex'))?.scopes ?? [];
1794
+ const registrationScope = options.scope !== undefined
1795
+ ? scopes[0]
1796
+ : desiredCodexScopes.includes('project')
1797
+ ? 'project'
1798
+ : desiredCodexScopes.includes('user') ? 'user' : 'project';
1799
+ const pluginRegistration = codexSurface.nativeKinds.length > 0
1800
+ ? await inspectCodexRegistration(codexPluginId, registrationScope)
1801
+ : {
1802
+ observation: { state: 'unobserved' },
1803
+ observations: { user: false, project: false },
1804
+ activations: {},
1805
+ };
1806
+ let residueFailed = false;
1807
+ const hasNativeRenderTargets = (plugin.manifest.artifacts?.targets ?? []).some((target) => target.platform === 'codex'
1808
+ && target.target === 'codex.skill');
1809
+ const sharedInspection = codexSurface.nativeKinds.length > 0
1810
+ ? await inspectCodexSharedNativeLive({
1811
+ pluginName: entry.name,
1812
+ sourceId: item.resolution.sourceId,
1813
+ desiredVersion: entry.version,
1814
+ inspectionMode: hasNativeRenderTargets ? 'payload' : 'shallow',
1815
+ cwd: options.cwd,
1816
+ env,
1817
+ marketplaceName,
1818
+ marketplaceRoot,
1819
+ nativeCliRunner,
1820
+ pluginRegistration,
1821
+ ...(hasNativeRenderTargets ? { nativeRenderPlugin: plugin } : {}),
1822
+ }).catch((error) => {
1823
+ throwIfCancelled(error);
1824
+ residueFailed = true;
1825
+ return undefined;
1826
+ })
1827
+ : undefined;
1828
+ const nativeState = sharedInspection?.sharedNative;
1829
+ const sharedNative = residueFailed
1830
+ ? { pluginId: codexPluginId, state: 'blocked', reason: 'unreadable' }
1831
+ : !nativeState
1832
+ ? undefined
1833
+ : nativeState.state === 'unobserved'
1834
+ ? {
1835
+ pluginId: codexPluginId,
1836
+ state: 'unobserved',
1837
+ ...(nativeState.staleCacheObserved ? { staleCacheObserved: true } : {}),
1838
+ }
1839
+ : nativeState.state === 'missing'
1840
+ ? {
1841
+ pluginId: codexPluginId,
1842
+ state: 'missing',
1843
+ ...(nativeState.staleCacheObserved ? { staleCacheObserved: true } : {}),
1844
+ }
1845
+ : nativeState.state === 'usable'
1846
+ ? {
1847
+ pluginId: codexPluginId,
1848
+ state: 'usable',
1849
+ version: nativeState.version,
1850
+ }
1851
+ : nativeState.state === 'replaceable'
1852
+ ? {
1853
+ pluginId: codexPluginId,
1854
+ state: 'replaceable',
1855
+ reason: nativeState.reason,
1856
+ ...(nativeState.version ? { version: nativeState.version } : {}),
1857
+ ...(nativeState.desiredVersion
1858
+ ? { desiredVersion: nativeState.desiredVersion }
1859
+ : {}),
1860
+ ...(nativeState.diagnostic ? { diagnostic: nativeState.diagnostic } : {}),
1861
+ }
1862
+ : {
1863
+ pluginId: codexPluginId,
1864
+ state: 'blocked',
1865
+ reason: nativeState.reason,
1866
+ diagnostic: nativeState.diagnostic,
1867
+ };
1868
+ const configuredUserActivation = userCodexConfig
1869
+ ?.snapshot.plugins[codexPluginId]?.enabled;
1870
+ const configuredProjectActivation = projectCodexConfig
1871
+ ?.snapshot.plugins[codexPluginId]?.enabled;
1872
+ const userActivation = configuredUserActivation;
1873
+ const projectActivation = configuredProjectActivation;
1874
+ const activationObserved = registrationScope === 'project'
1875
+ ? userCodexConfig !== undefined && projectCodexConfig !== undefined
1876
+ : userCodexConfig !== undefined;
1877
+ codexStatus = {
1878
+ pluginId: codexPluginId,
1879
+ nativeKinds: codexSurface.nativeKinds,
1880
+ extensionKinds: codexSurface.extensionKinds,
1881
+ ...(sharedNative ? { sharedNative } : {}),
1882
+ activation: {
1883
+ ...(userActivation !== undefined ? { user: userActivation } : {}),
1884
+ ...(projectActivation !== undefined ? { project: projectActivation } : {}),
1885
+ ...((userActivation !== undefined || projectActivation !== undefined)
1886
+ ? { effective: (projectActivation ?? userActivation) === true }
1887
+ : {}),
1888
+ evidence: activationObserved ? 'observed' : 'assumed',
1889
+ },
1890
+ };
1891
+ }
1892
+ return {
1893
+ name: entry.name,
1894
+ version: entry.version,
1895
+ displayName: plugin.manifest.interface?.displayName ?? entry.name,
1896
+ shortDescription: plugin.manifest.interface?.shortDescription
1897
+ ?? plugin.manifest.description,
1898
+ description: plugin.manifest.description,
1899
+ platforms: [...resolveSupportedPlatforms(plugin.manifest)],
1900
+ ...(plugin.manifest.config?.fields
1901
+ ? { configSchema: plugin.manifest.config.fields }
1902
+ : {}),
1903
+ ...(configIssues?.length ? { configIssues } : {}),
1904
+ ...(configDiagnostic ? { configDiagnostic } : {}),
1905
+ targets: {
1906
+ claude: { user: claude, project: claude },
1907
+ codex: {
1908
+ user: codex,
1909
+ project: codex
1910
+ && codexSurface.ok
1911
+ && codexSurface.classification !== 'empty',
1912
+ },
1913
+ },
1914
+ states,
1915
+ dependencies: plugin.manifest.dependencies ?? [],
1916
+ ...(codexStatus ? { codex: codexStatus } : {}),
1917
+ };
1918
+ }));
1919
+ return {
1920
+ ...base,
1921
+ resolvedCommit: item.resolution.resolvedCommit,
1922
+ catalogVersion: item.resolution.manifest.catalogVersion,
1923
+ channel: item.resolution.manifest.channel,
1924
+ freshness: 'active',
1925
+ plugins,
1926
+ };
1927
+ }
1928
+ catch (error) {
1929
+ throwIfCancelled(error);
1930
+ const sanitized = sanitizeCatalogSourceError(error, env);
1931
+ return {
1932
+ ...base,
1933
+ error: sanitized.message,
1934
+ errorCode: catalogSourceErrorCode(sanitized),
1935
+ };
1936
+ }
1937
+ })),
1938
+ }),
1939
+ });
1940
+ const available = catalog.sources.flatMap((source) => 'plugins' in source
1941
+ ? source.plugins.map((plugin) => ({ ...plugin, source }))
1942
+ : []);
1943
+ const removedProjectionReferences = [];
1944
+ for (const source of catalog.sources) {
1945
+ throwIfCancelled();
1946
+ if (!('plugins' in source))
1947
+ continue;
1948
+ const marketplaceRoot = path.join(resolveAwHome(env), 'marketplaces', source.id);
1949
+ try {
1950
+ const root = await readStrictNamespacedMarketplaceRoot({
1951
+ rootDir: marketplaceRoot, sourceId: source.id, sourceIdentity: source.identity,
1952
+ });
1953
+ if (!root)
1954
+ continue;
1955
+ const currentNames = new Set(source.plugins.map((plugin) => plugin.name));
1956
+ const candidates = new Map();
1957
+ const add = (name, platform) => {
1958
+ if (typeof name !== 'string' || currentNames.has(name))
1959
+ return;
1960
+ try {
1961
+ if (parsePluginId(name).sourceId !== undefined)
1962
+ return;
1963
+ }
1964
+ catch {
1965
+ return;
1966
+ }
1967
+ const supported = candidates.get(name) ?? new Set();
1968
+ supported.add(platform);
1969
+ candidates.set(name, supported);
1970
+ };
1971
+ for (const [platform, manifest] of [
1972
+ ['codex', root.agentsManifest], ['claude', root.claudeManifest],
1973
+ ]) {
1974
+ if (!Array.isArray(manifest?.plugins))
1975
+ continue;
1976
+ for (const plugin of manifest.plugins) {
1977
+ if (plugin && typeof plugin === 'object')
1978
+ add(plugin.name, platform);
1979
+ }
1980
+ }
1981
+ const pluginsRoot = path.join(root.rootDir, 'plugins');
1982
+ const pluginsStats = await fs.promises.lstat(pluginsRoot).catch((error) => {
1983
+ if (error.code === 'ENOENT')
1984
+ return undefined;
1985
+ throw error;
1986
+ });
1987
+ if (pluginsStats && (!pluginsStats.isDirectory() || pluginsStats.isSymbolicLink())) {
1988
+ throw new Error('marketplaceRootInvalid: plugin projection directory is unsafe.');
1989
+ }
1990
+ if (pluginsStats) {
1991
+ for (const entry of await fs.promises.readdir(pluginsRoot, { withFileTypes: true })) {
1992
+ if (!candidates.has(entry.name))
1993
+ add(entry.name, 'codex');
1994
+ }
1995
+ }
1996
+ const registration = userCodexConfig?.snapshot.marketplaces[root.config.marketplaceName];
1997
+ if (platforms.includes('codex')
1998
+ && registration?.sourceType === 'local'
1999
+ && !registration.sourcePointsToManifest
2000
+ && path.resolve(registration.source ?? '') === path.resolve(root.rootDir)
2001
+ && (await inspectCodexSystemConsumer(options.scope === 'project' ? 'project' : 'user')).state === 'compatible') {
2002
+ const observed = await options.codexObservationSession.snapshot(root.config.marketplaceName, options.scope === 'user' ? 'user' : 'both');
2003
+ const suffix = `@${root.config.marketplaceName}`;
2004
+ for (const pluginId of [...(observed.exact?.keys() ?? []), ...(observed.neutral?.keys() ?? [])]) {
2005
+ if (pluginId.endsWith(suffix))
2006
+ add(pluginId.slice(0, -suffix.length), 'codex');
2007
+ }
2008
+ }
2009
+ for (const [pluginName, supported] of candidates) {
2010
+ for (const platform of supported)
2011
+ removedProjectionReferences.push({
2012
+ kind: 'namespacedMarketplace', location: path.join(root.rootDir, 'config.json'),
2013
+ sourceId: source.id, sourceIdentity: source.identity,
2014
+ marketplaceName: root.config.marketplaceName, pluginName, platform, scope: 'user',
2015
+ });
2016
+ }
2017
+ }
2018
+ catch (error) {
2019
+ throwIfCancelled(error);
2020
+ const projected = projectStateInventoryError(error, env, options.cwd);
2021
+ selectedInventoryErrors.push({ ...projected, relevance: { sourceId: source.id, global: false } });
2022
+ }
2023
+ }
2024
+ const statusReferences = [...ownerInventory.references, ...removedProjectionReferences];
2025
+ const desiredTargetStates = calculateDesiredTargetStates({
2026
+ userIntent,
2027
+ projectIntent,
2028
+ available,
2029
+ codexProjectAllowed: !codexScopePathsAlias,
2030
+ });
2031
+ const failedSourceIds = new Set(catalog.sources.filter((source) => 'error' in source).map((source) => source.id));
2032
+ const selectedById = new Map();
2033
+ if (requested.length === 0) {
2034
+ for (const entry of available) {
2035
+ selectedById.set(formatPluginId({ sourceId: entry.source.id, pluginName: entry.name }), entry);
2036
+ }
2037
+ }
2038
+ else {
2039
+ for (const selector of plannedSelectors) {
2040
+ if (selector.parsed.sourceId === undefined && failedSourceIds.size > 0) {
2041
+ selectorErrors.push({
2042
+ code: 'catalogSourceUnavailable',
2043
+ message: `Cannot resolve bare plugin selector "${selector.raw}" while catalog sources are unavailable: ${[...failedSourceIds].join(', ')}.`,
2044
+ });
2045
+ continue;
2046
+ }
2047
+ if (selector.parsed.sourceId !== undefined && failedSourceIds.has(selector.parsed.sourceId)) {
2048
+ selectorErrors.push({
2049
+ code: 'catalogSourceUnavailable',
2050
+ message: `Cannot resolve plugin selector "${selector.raw}" because catalog source "${selector.parsed.sourceId}" is unavailable.`,
2051
+ });
2052
+ continue;
2053
+ }
2054
+ const matches = available.filter((entry) => entry.name === selector.parsed.pluginName
2055
+ && (selector.parsed.sourceId === undefined || entry.source.id === selector.parsed.sourceId));
2056
+ if (matches.length === 0) {
2057
+ const selectorHasInventoryError = selectedInventoryErrors.some((error) => inventoryErrorMatchesSelection({
2058
+ error,
2059
+ selectors: [selector],
2060
+ platformExplicit: options.platform !== undefined,
2061
+ scopeExplicit: options.scope !== undefined,
2062
+ platforms,
2063
+ scopes,
2064
+ currentProjectLocationKey,
2065
+ }));
2066
+ const selectorHasLiveOrIntent = statusReferences.some((reference) => (reference.kind === 'namespacedOwner' || reference.kind === 'namespacedMarketplace')
2067
+ && reference.pluginName === selector.parsed.pluginName
2068
+ && reference.sourceId !== undefined
2069
+ && (selector.parsed.sourceId === undefined || reference.sourceId === selector.parsed.sourceId)
2070
+ && platforms.some((platform) => platform === reference.platform)
2071
+ && scopes.some((scope) => scope === reference.scope)
2072
+ && (reference.scope !== 'project' || reference.projectKey === currentProjectKey))
2073
+ || [userIntent, projectIntent].some((intent, index) => scopes.includes(index === 0 ? 'user' : 'project')
2074
+ && intent.roots.some((root) => {
2075
+ const parsed = parsePluginId(root.pluginId);
2076
+ return parsed.pluginName === selector.parsed.pluginName
2077
+ && (selector.parsed.sourceId === undefined || parsed.sourceId === selector.parsed.sourceId)
2078
+ && root.platforms.some((platform) => platforms.includes(platform));
2079
+ }));
2080
+ if (!selectorHasInventoryError && !selectorHasLiveOrIntent) {
2081
+ selectorErrors.push({
2082
+ code: 'pluginNotFound',
2083
+ message: `Plugin "${selector.raw}" was not found in the selected catalog source set.`,
2084
+ });
2085
+ }
2086
+ continue;
2087
+ }
2088
+ if (selector.parsed.sourceId === undefined && matches.length > 1) {
2089
+ selectorErrors.push({
2090
+ code: 'ambiguousPlugin',
2091
+ message: `Plugin "${selector.raw}" is ambiguous across sources: ${matches.map((entry) => entry.source.id).join(', ')}.`,
2092
+ });
2093
+ continue;
2094
+ }
2095
+ for (const entry of matches) {
2096
+ selectedById.set(formatPluginId({ sourceId: entry.source.id, pluginName: entry.name }), entry);
2097
+ }
2098
+ }
2099
+ }
2100
+ const selected = [...selectedById.values()];
2101
+ const explicitTargetFilter = requested.length > 0
2102
+ && (options.platform !== undefined || options.scope !== undefined);
2103
+ const targets = selected.flatMap((entry) => platforms.flatMap((platform) => scopes.flatMap((scope) => {
2104
+ const target = {
2105
+ pluginName: entry.name,
2106
+ sourceId: entry.source.id,
2107
+ sourceIdentity: entry.source.identity,
2108
+ pluginId: formatPluginId({ sourceId: entry.source.id, pluginName: entry.name }),
2109
+ version: entry.version,
2110
+ platform,
2111
+ scope,
2112
+ cwd: path.resolve(options.cwd),
2113
+ components: [],
2114
+ };
2115
+ if (platform === 'codex'
2116
+ && scope === 'project'
2117
+ && codexScopePathsAlias
2118
+ && !hasCurrentCodexProjectOwner(entry.source.id, entry.name)) {
2119
+ if (options.scope !== 'project')
2120
+ return [];
2121
+ return [{
2122
+ ...target,
2123
+ state: 'error',
2124
+ errors: [finalizeTargetError({
2125
+ code: 'codexScopePathAlias',
2126
+ message: 'codexScopePathAlias: Codex project config resolves to the user config directory. Run this command from an actual project directory.',
2127
+ }, 'error')],
2128
+ }];
2129
+ }
2130
+ if (entry.targets[platform][scope]) {
2131
+ const live = entry.states[platform]?.[scope];
2132
+ const dependencyIssueCount = (live?.errors ?? []).filter((error) => error.code.startsWith('dependency')
2133
+ || error.code === 'awCapabilityUnsupported'
2134
+ || error.code === 'sourceChanged').length;
2135
+ return [{
2136
+ ...target,
2137
+ state: live?.state ?? 'error',
2138
+ components: live?.components ?? [],
2139
+ errors: live?.errors ?? [finalizeTargetError({
2140
+ code: 'targetInspectionFailed',
2141
+ message: `No live inspection result exists for ${entry.source.id}/${entry.name}.`,
2142
+ }, 'error')],
2143
+ ...(live?.dependencyReadiness
2144
+ ? { dependencyReadiness: live.dependencyReadiness }
2145
+ : {}),
2146
+ ...(entry.dependencies.length > 0 || dependencyIssueCount > 0 ? {
2147
+ dependency: {
2148
+ directCount: entry.dependencies.length,
2149
+ issueCount: dependencyIssueCount,
2150
+ },
2151
+ } : {}),
2152
+ }];
2153
+ }
2154
+ const unsupportedLiveReference = ownerInventory.references.find((reference) => (reference.kind === 'namespacedOwner' || reference.kind === 'namespacedMarketplace')
2155
+ && reference.sourceId === entry.source.id
2156
+ && reference.pluginName === entry.name
2157
+ && reference.platform === platform
2158
+ && reference.scope === scope
2159
+ && (scope === 'user' || reference.projectKey === currentProjectKey));
2160
+ if (unsupportedLiveReference) {
2161
+ const sourceChanged = Boolean(unsupportedLiveReference.sourceIdentity
2162
+ && unsupportedLiveReference.sourceIdentity !== entry.source.identity);
2163
+ return [{
2164
+ ...target,
2165
+ state: 'error',
2166
+ errors: [finalizeTargetError({
2167
+ code: sourceChanged ? 'sourceChanged' : 'noLongerSupported',
2168
+ message: sourceChanged
2169
+ ? `sourceChanged: live state for ${target.pluginId} has a different source identity.`
2170
+ : `noLongerSupported: ${target.pluginId} has live state for ${platform}/${scope}, but the current bundle no longer supports that target.`,
2171
+ }, 'error')],
2172
+ }];
2173
+ }
2174
+ if (!explicitTargetFilter)
2175
+ return [];
2176
+ return [{
2177
+ ...target,
2178
+ state: 'error',
2179
+ errors: [finalizeTargetError({
2180
+ code: platform === 'codex' && scope === 'project'
2181
+ ? 'codexProjectPluginUnsupported'
2182
+ : 'unsupportedTarget',
2183
+ message: platform === 'codex' && scope === 'project'
2184
+ ? `codexProjectPluginUnsupported: ${entry.source.id}/${entry.name} cannot use the current Codex project plugin contract.`
2185
+ : `${entry.source.id}/${entry.name} does not support ${platform}/${scope}.`,
2186
+ }, 'error')],
2187
+ }];
2188
+ })));
2189
+ const referenceSelectors = [...plannedSelectors, ...liveOnlySelectors];
2190
+ const referenceSelected = (reference) => (reference.pluginName !== undefined
2191
+ && reference.platform !== undefined
2192
+ && reference.scope !== undefined
2193
+ && platforms.includes(reference.platform)
2194
+ && scopes.includes(reference.scope)
2195
+ && (reference.scope !== 'project' || reference.projectKey === currentProjectKey)
2196
+ && (requested.length === 0 || referenceSelectors.some((selector) => selector.parsed.pluginName === reference.pluginName
2197
+ && (selector.parsed.sourceId === undefined || selector.parsed.sourceId === reference.sourceId))));
2198
+ const legacyOwners = ownerInventory.references.filter((reference) => (reference.kind === 'legacyOwner' || reference.kind === 'legacyMarketplace')
2199
+ && reference.pluginName !== undefined
2200
+ && reference.platform !== undefined
2201
+ && reference.scope !== undefined
2202
+ && platforms.includes(reference.platform)
2203
+ && scopes.includes(reference.scope)
2204
+ && (requested.length === 0 || plannedSelectors.some((selector) => selector.parsed.pluginName === reference.pluginName)));
2205
+ const missingSourceOwners = ownerInventory.references.filter((reference) => (reference.kind === 'namespacedOwner' || reference.kind === 'namespacedMarketplace')
2206
+ && reference.sourceId
2207
+ && !configured.has(reference.sourceId)
2208
+ && referenceSelected(reference));
2209
+ const missingTargets = [...new Map(missingSourceOwners.flatMap((reference) => {
2210
+ if (!reference.sourceId || !reference.pluginName
2211
+ || (reference.platform !== 'codex' && reference.platform !== 'claude')
2212
+ || (reference.scope !== 'user' && reference.scope !== 'project'))
2213
+ return [];
2214
+ const pluginId = formatPluginId({ sourceId: reference.sourceId, pluginName: reference.pluginName });
2215
+ const target = {
2216
+ pluginName: reference.pluginName,
2217
+ sourceId: reference.sourceId,
2218
+ sourceIdentity: reference.sourceIdentity ?? 'unavailable',
2219
+ pluginId,
2220
+ platform: reference.platform,
2221
+ scope: reference.scope,
2222
+ cwd: path.resolve(options.cwd),
2223
+ state: 'error',
2224
+ components: [],
2225
+ errors: [finalizeTargetError({
2226
+ code: 'sourceMissing',
2227
+ message: `sourceMissing: catalog source "${reference.sourceId}" is not configured for ${pluginId}.`,
2228
+ }, 'error')],
2229
+ };
2230
+ return [[`${pluginId}\0${reference.platform}\0${reference.scope}`, target]];
2231
+ })).values()];
2232
+ targets.push(...missingTargets);
2233
+ const unavailableSourceReferences = ownerInventory.references.filter((reference) => (reference.kind === 'namespacedOwner' || reference.kind === 'namespacedMarketplace')
2234
+ && reference.sourceId
2235
+ && configured.has(reference.sourceId)
2236
+ && failedSourceIds.has(reference.sourceId)
2237
+ && referenceSelected(reference));
2238
+ const unavailableSourceTargets = [...new Map(unavailableSourceReferences.flatMap((reference) => {
2239
+ if (!reference.sourceId || !reference.pluginName
2240
+ || (reference.platform !== 'codex' && reference.platform !== 'claude')
2241
+ || (reference.scope !== 'user' && reference.scope !== 'project'))
2242
+ return [];
2243
+ const pluginId = formatPluginId({ sourceId: reference.sourceId, pluginName: reference.pluginName });
2244
+ const target = {
2245
+ pluginName: reference.pluginName,
2246
+ sourceId: reference.sourceId,
2247
+ sourceIdentity: reference.sourceIdentity ?? 'unavailable',
2248
+ pluginId,
2249
+ platform: reference.platform,
2250
+ scope: reference.scope,
2251
+ cwd: path.resolve(options.cwd),
2252
+ state: 'error',
2253
+ components: [],
2254
+ errors: [finalizeTargetError({
2255
+ code: 'catalogSourceUnavailable',
2256
+ message: `catalogSourceUnavailable: catalog source "${reference.sourceId}" is unavailable for ${pluginId}.`,
2257
+ }, 'error')],
2258
+ };
2259
+ return [[`${pluginId}\0${reference.platform}\0${reference.scope}`, target]];
2260
+ })).values()];
2261
+ targets.push(...unavailableSourceTargets);
2262
+ const availablePluginIds = new Set(available.map((entry) => formatPluginId({ sourceId: entry.source.id, pluginName: entry.name })));
2263
+ const resolvedSourceIds = new Set(catalog.sources.flatMap((source) => 'plugins' in source ? [source.id] : []));
2264
+ const unavailableBundleReferences = statusReferences.filter((reference) => (reference.kind === 'namespacedOwner' || reference.kind === 'namespacedMarketplace')
2265
+ && reference.sourceId
2266
+ && configured.has(reference.sourceId)
2267
+ && resolvedSourceIds.has(reference.sourceId)
2268
+ && reference.pluginName
2269
+ && referenceSelected(reference)
2270
+ && !availablePluginIds.has(formatPluginId({
2271
+ sourceId: reference.sourceId,
2272
+ pluginName: reference.pluginName,
2273
+ })));
2274
+ const unavailableBundleTargets = [...new Map((await Promise.all(unavailableBundleReferences.map(async (reference) => {
2275
+ if (!reference.sourceId || !reference.pluginName
2276
+ || (reference.platform !== 'codex' && reference.platform !== 'claude')
2277
+ || (reference.scope !== 'user' && reference.scope !== 'project'))
2278
+ return [];
2279
+ const pluginId = formatPluginId({ sourceId: reference.sourceId, pluginName: reference.pluginName });
2280
+ if (requested.length > 0 && !plannedSelectors.some((selector) => selector.parsed.pluginName === reference.pluginName
2281
+ && (selector.parsed.sourceId === undefined || selector.parsed.sourceId === reference.sourceId)))
2282
+ return [];
2283
+ const registration = reference.platform === 'codex' && reference.marketplaceName
2284
+ ? await inspectCodexRegistration(`${reference.pluginName}@${reference.marketplaceName}`, reference.scope)
2285
+ : undefined;
2286
+ const nativeUnknown = registration && registration.observation.state !== 'observed';
2287
+ const target = {
2288
+ pluginName: reference.pluginName,
2289
+ sourceId: reference.sourceId,
2290
+ sourceIdentity: reference.sourceIdentity ?? 'unavailable',
2291
+ pluginId,
2292
+ platform: reference.platform,
2293
+ scope: reference.scope,
2294
+ cwd: path.resolve(options.cwd),
2295
+ state: 'error',
2296
+ components: registration ? [{
2297
+ key: 'native',
2298
+ state: registration.observation.state !== 'observed' ? 'error'
2299
+ : registration.observation.value === 'installed' ? 'present' : 'absent',
2300
+ }] : [],
2301
+ errors: [finalizeTargetError({
2302
+ code: 'bundleUnavailable',
2303
+ message: `bundleUnavailable: ${pluginId} has live state but is not present in the current source snapshot.`,
2304
+ }, 'error'), finalizeTargetError({
2305
+ code: 'removedPluginCleanupRequired',
2306
+ message: `removedPluginCleanupRequired: ${pluginId} was removed from the current Catalog and has remaining local state.`,
2307
+ }, 'error'), ...(nativeUnknown ? [finalizeTargetError({
2308
+ code: 'codexNativeObservationFailed',
2309
+ message: 'codexNativeObservationFailed: the remaining native installation could not be observed.',
2310
+ }, 'error')] : [])],
2311
+ };
2312
+ return [[`${pluginId}\0${reference.platform}\0${reference.scope}`, target]];
2313
+ }))).flat()).values()];
2314
+ targets.push(...unavailableBundleTargets);
2315
+ const targetKeys = new Set(targets.map((target) => `${target.pluginId}\0${target.platform}\0${target.scope}`));
2316
+ for (const [scope, intent] of [
2317
+ ['user', userIntent],
2318
+ ['project', projectIntent],
2319
+ ]) {
2320
+ for (const root of intent.roots) {
2321
+ const parsed = parsePluginId(root.pluginId);
2322
+ if (!parsed.sourceId)
2323
+ continue;
2324
+ if (requested.length > 0 && !parsedSelectors.some((selector) => selector.parsed.pluginName === parsed.pluginName
2325
+ && (selector.parsed.sourceId === undefined || selector.parsed.sourceId === parsed.sourceId))) {
2326
+ continue;
2327
+ }
2328
+ for (const platform of root.platforms.filter((candidate) => platforms.includes(candidate))) {
2329
+ if (!scopes.includes(scope))
2330
+ continue;
2331
+ const key = `${root.pluginId}\0${platform}\0${scope}`;
2332
+ if (targetKeys.has(key))
2333
+ continue;
2334
+ targets.push({
2335
+ pluginName: parsed.pluginName,
2336
+ sourceId: parsed.sourceId,
2337
+ sourceIdentity: identities.get(parsed.sourceId)?.identity ?? 'unavailable',
2338
+ pluginId: root.pluginId,
2339
+ platform,
2340
+ scope,
2341
+ cwd: path.resolve(options.cwd),
2342
+ state: 'error',
2343
+ components: [],
2344
+ errors: [finalizeTargetError({
2345
+ code: 'codexIntentSourceUnavailable',
2346
+ message: `codexIntentSourceUnavailable: desired intent for ${root.pluginId} cannot be resolved from the current Catalog.`,
2347
+ }, 'partial')],
2348
+ });
2349
+ targetKeys.add(key);
2350
+ }
2351
+ }
2352
+ }
2353
+ const projectedInventoryErrors = [...new Map(selectedInventoryErrors.map((error) => [
2354
+ `${error.code}\0${error.message}`,
2355
+ { code: error.code, message: error.message },
2356
+ ])).values()];
2357
+ const errors = [
2358
+ ...projectedInventoryErrors,
2359
+ ...selectorErrors,
2360
+ ...intentErrors,
2361
+ ...legacyOwners.map((reference) => projectTargetError({
2362
+ code: 'legacyStateUnsupported',
2363
+ message: `legacyStateUnsupported: legacy live ${reference.kind} at ${reference.location}`,
2364
+ }, env, options.cwd, 'error')),
2365
+ ];
2366
+ const draftTargets = targets.map((target) => ({
2367
+ ...target,
2368
+ errors: target.errors.map((error) => projectTargetError(error, env, options.cwd, target.state)),
2369
+ }));
2370
+ const selectedByPluginId = new Map(selected.map((entry) => [
2371
+ formatPluginId({ sourceId: entry.source.id, pluginName: entry.name }),
2372
+ entry,
2373
+ ]));
2374
+ const explicitScope = options.scope === undefined ? undefined : scopes[0];
2375
+ const warning = (code, message) => ({
2376
+ code,
2377
+ message: `${code}: ${message}`,
2378
+ severity: 'warning',
2379
+ });
2380
+ const blocking = (code, message) => ({
2381
+ code,
2382
+ message: `${code}: ${message}`,
2383
+ severity: 'blocking',
2384
+ });
2385
+ const decorateTarget = async (target, groupedScopes, groupedTargets) => {
2386
+ const entry = selectedByPluginId.get(target.pluginId);
2387
+ const codex = target.platform === 'codex' ? entry?.codex : undefined;
2388
+ const desiredAll = desiredTargetStates.get(desiredTargetKey(target.pluginId, target.platform))
2389
+ ?? { scopes: [], relation: 'none' };
2390
+ const desired = {
2391
+ scopes: desiredAll.scopes.includes(target.scope) ? [target.scope] : [],
2392
+ relation: desiredAll.relation,
2393
+ };
2394
+ const sharedNative = codex?.sharedNative ?? target.sharedNative;
2395
+ const baseActivation = codex?.activation ?? target.activation;
2396
+ const consumerScope = desired.scopes.includes('project')
2397
+ ? 'project'
2398
+ : desired.scopes.includes('user')
2399
+ ? 'user'
2400
+ : explicitScope ?? (groupedScopes.includes('project') ? 'project' : 'user');
2401
+ const inspectSystemConsumer = target.platform === 'codex'
2402
+ && baseActivation !== undefined
2403
+ && ((codex?.nativeKinds.length ?? 0) > 0 || target.sharedNative !== undefined);
2404
+ const systemConsumer = inspectSystemConsumer
2405
+ ? await inspectCodexSystemConsumer(consumerScope)
2406
+ : undefined;
2407
+ const activation = baseActivation && systemConsumer
2408
+ ? {
2409
+ ...baseActivation,
2410
+ evidence: systemConsumer.state === 'compatible'
2411
+ ? 'observed'
2412
+ : systemConsumer.state === 'missing' ? 'assumed' : 'unobserved',
2413
+ systemConsumer,
2414
+ }
2415
+ : baseActivation;
2416
+ const observationScopes = [target.scope];
2417
+ const scopedTargets = groupedTargets.filter((candidate) => observationScopes.includes(candidate.scope));
2418
+ const observedTargets = scopedTargets.length > 0 ? scopedTargets : groupedTargets;
2419
+ const ownershipState = observedTargets.some((candidate) => candidate.state === 'error')
2420
+ ? 'error'
2421
+ : observedTargets.some((candidate) => candidate.state === 'partial')
2422
+ ? 'partial'
2423
+ : observedTargets.some((candidate) => candidate.state === 'present')
2424
+ ? 'present'
2425
+ : sharedNative?.staleCacheObserved
2426
+ ? 'partial'
2427
+ : 'absent';
2428
+ const actualScopeEnabled = target.platform === 'codex'
2429
+ && baseActivation?.[target.scope] === true;
2430
+ const hasSourceError = observedTargets.some((candidate) => candidate.errors.some((error) => error.code === 'sourceMissing'
2431
+ || error.code === 'catalogSourceUnavailable'
2432
+ || error.code === 'bundleUnavailable'
2433
+ || error.code === 'codexIntentSourceUnavailable'));
2434
+ const desiredOverlapConflict = target.platform === 'codex'
2435
+ && (codex?.extensionKinds.length ?? 0) > 0
2436
+ && desired.scopes.includes('user')
2437
+ && desired.scopes.includes('project');
2438
+ const expectedEnabled = desired.scopes.includes(target.scope);
2439
+ const inheritedUserActivation = target.platform === 'codex'
2440
+ && target.scope === 'project'
2441
+ && !expectedEnabled
2442
+ && desiredAll.scopes.includes('user')
2443
+ && activation?.user === true
2444
+ && (codex?.nativeKinds.length ?? 0) > 0;
2445
+ const projectDisablesUserActivation = inheritedUserActivation && activation?.project === false;
2446
+ const redundantProjectActivation = inheritedUserActivation && activation?.project === true
2447
+ && (codex?.extensionKinds.length ?? 0) === 0;
2448
+ const activationDrift = target.platform === 'codex'
2449
+ && (codexConfigErrors.some((error) => error.scope === 'user' || observationScopes.includes(error.scope))
2450
+ || ((codex?.nativeKinds.length ?? 0) > 0
2451
+ && (expectedEnabled && activation?.[target.scope] !== true
2452
+ || !expectedEnabled && activation?.[target.scope] === true && !redundantProjectActivation
2453
+ || projectDisablesUserActivation)));
2454
+ const extensionComponents = observedTargets.flatMap((candidate) => candidate.components).filter((component) => component.key !== 'native'
2455
+ && !component.key.startsWith('activation-')
2456
+ && !component.key.startsWith('marketplace-'));
2457
+ const hasScopedExtensionResidue = extensionComponents.some((component) => component.state !== 'absent' || component.error !== undefined);
2458
+ const extensions = target.platform !== 'codex'
2459
+ || (codex?.extensionKinds.length ?? 0) === 0
2460
+ ? undefined
2461
+ : {
2462
+ state: desiredOverlapConflict
2463
+ ? 'conflict'
2464
+ : extensionComponents.some((component) => component.error?.code === 'artifactCollision')
2465
+ ? 'conflict'
2466
+ : extensionComponents.some((component) => component.state === 'partial' || component.state === 'error')
2467
+ ? 'drifted'
2468
+ : desired.scopes.length > 0 && (extensionComponents.length === 0
2469
+ || extensionComponents.every((component) => component.state === 'absent'))
2470
+ ? 'missing'
2471
+ : 'ready',
2472
+ kinds: codex.extensionKinds,
2473
+ };
2474
+ const desiredEnabled = desired.scopes.length > 0;
2475
+ const projectDependencyIds = projectIntent.roots.some((root) => root.pluginId === target.pluginId && root.platforms.includes(target.platform))
2476
+ ? projectDependencyClosureForTarget({
2477
+ pluginId: target.pluginId,
2478
+ platform: target.platform,
2479
+ available,
2480
+ })
2481
+ : new Set();
2482
+ const dependencyMoves = projectIntent.dependencyScopeOverrides.flatMap((override) => {
2483
+ if (override.scope !== 'project'
2484
+ || (override.platform !== undefined && override.platform !== target.platform)
2485
+ || !projectDependencyIds.has(override.pluginId)) {
2486
+ return [];
2487
+ }
2488
+ const dependencyDesired = desiredTargetStates.get(desiredTargetKey(override.pluginId, target.platform));
2489
+ if (!dependencyDesired?.scopes.includes('project')
2490
+ || dependencyDesired.scopes.includes('user')) {
2491
+ return [];
2492
+ }
2493
+ const parsed = parsePluginId(override.pluginId);
2494
+ const hasPreservedUserActual = ownerInventory.references.some((reference) => reference.kind === 'namespacedOwner'
2495
+ && reference.sourceId === parsed.sourceId
2496
+ && reference.pluginName === parsed.pluginName
2497
+ && reference.platform === target.platform
2498
+ && reference.scope === 'user');
2499
+ return hasPreservedUserActual
2500
+ ? [{ pluginId: override.pluginId, fromScope: 'user', toScope: 'project' }]
2501
+ : [];
2502
+ }).sort((left, right) => left.pluginId.localeCompare(right.pluginId, 'en'));
2503
+ const consumerIssue = activation?.systemConsumer?.state === 'incompatible'
2504
+ || activation?.systemConsumer?.state === 'unresolved'
2505
+ ? activation.systemConsumer
2506
+ : undefined;
2507
+ const consumerBlocking = consumerIssue !== undefined;
2508
+ const baseTargetErrors = observedTargets.flatMap((candidate) => candidate.errors);
2509
+ const hasBlockingBaseReason = baseTargetErrors.some((reason) => reason.severity === 'blocking');
2510
+ const capabilityUnsupported = baseTargetErrors.some((reason) => reason.code === 'awCapabilityUnsupported');
2511
+ const dependencyNotReady = (target.dependencyReadiness ?? []).some((dependency) => dependency.state !== 'ready');
2512
+ const state = hasSourceError && desiredEnabled
2513
+ ? 'blocked'
2514
+ : consumerBlocking && desiredEnabled
2515
+ ? 'blocked'
2516
+ : desiredOverlapConflict
2517
+ ? 'blocked'
2518
+ : sharedNative?.state === 'blocked' || hasBlockingBaseReason || capabilityUnsupported
2519
+ ? 'blocked'
2520
+ : sharedNative?.state === 'replaceable' && sharedNative.reason === 'damaged'
2521
+ ? 'needsSync'
2522
+ : projectDisablesUserActivation
2523
+ ? 'needsSync'
2524
+ : redundantProjectActivation && sharedNative?.state === 'usable' && !hasScopedExtensionResidue
2525
+ ? 'ready'
2526
+ : !desiredEnabled
2527
+ ? (target.platform === 'codex'
2528
+ ? actualScopeEnabled || hasScopedExtensionResidue
2529
+ : ownershipState !== 'absent')
2530
+ || desired.relation === 'managed'
2531
+ ? 'orphaned'
2532
+ : 'absent'
2533
+ : dependencyMoves.length > 0
2534
+ ? 'needsSync'
2535
+ : dependencyNotReady
2536
+ ? 'needsSync'
2537
+ : sharedNative?.state === 'missing'
2538
+ || sharedNative?.state === 'replaceable'
2539
+ || sharedNative?.state === 'unobserved'
2540
+ ? 'needsSync'
2541
+ : activationDrift || extensions?.state === 'drifted'
2542
+ ? 'needsSync'
2543
+ : extensions?.state === 'missing'
2544
+ || (target.platform !== 'codex' && ownershipState === 'absent')
2545
+ ? 'needsSync'
2546
+ : ownershipState === 'partial' || ownershipState === 'error'
2547
+ ? 'needsSync'
2548
+ : 'ready';
2549
+ const stableErrors = [
2550
+ ...projectStatusSharedNativeReasons(sharedNative, baseTargetErrors.map((error) => error.code), desiredEnabled),
2551
+ ...(desiredOverlapConflict
2552
+ ? [blocking('codexExtensionScopeConflict', `${target.pluginId} has AW extensions desired at user and project scope.`)]
2553
+ : []),
2554
+ ...(activationDrift && sharedNative?.state !== 'missing' && sharedNative?.state !== 'unobserved'
2555
+ ? [warning('codexActivationDrift', projectDisablesUserActivation
2556
+ ? `${target.pluginId} is enabled for the user but disabled by the current project.`
2557
+ : `${target.pluginId} activation differs from desired intent: `
2558
+ + `${target.scope} expected=${expectedEnabled}, `
2559
+ + `actual=${activation?.[target.scope] ?? 'unset'}.`)]
2560
+ : []),
2561
+ ...(extensions?.state === 'drifted'
2562
+ ? [warning('codexExtensionDrift', `${target.pluginId} extension projection has drifted.`)]
2563
+ : []),
2564
+ ...dependencyMoves.map((move) => ({
2565
+ ...warning('dependencyScopeMigrationCleanupRequired', `${move.pluginId} has preserved user-scope output after moving to project scope.`),
2566
+ dependencyPluginId: move.pluginId,
2567
+ dependencyPlatform: target.platform,
2568
+ dependencyScope: move.toScope,
2569
+ dependencyProject: 'current',
2570
+ })),
2571
+ ...(target.platform === 'codex' && hasSourceError && desiredEnabled
2572
+ ? [warning('codexIntentSourceUnavailable', `${target.pluginId} desired intent cannot be resolved from the current Catalog.`)]
2573
+ : []),
2574
+ ...(target.platform === 'codex' && consumerBlocking && desiredEnabled
2575
+ ? [blocking(consumerIssue.code, consumerIssue.diagnostic)]
2576
+ : []),
2577
+ ...(activation?.systemConsumer?.diagnostics ?? []).map((diagnostic) => warning('codexCandidateExcluded', diagnostic)),
2578
+ ];
2579
+ const targetErrors = [...baseTargetErrors, ...stableErrors];
2580
+ const dedupedErrors = [...new Map(targetErrors.map((error) => [
2581
+ `${error.code}\0${error.message}`,
2582
+ error,
2583
+ ])).values()];
2584
+ const ownershipComponents = [...new Map(observedTargets.flatMap((candidate) => candidate.components)
2585
+ .map((component) => [component.key, component])).values()];
2586
+ const representativeScope = target.scope;
2587
+ const representativeTarget = observedTargets.find((candidate) => candidate.scope === representativeScope) ?? target;
2588
+ const components = [
2589
+ {
2590
+ kind: 'intent',
2591
+ key: 'desired',
2592
+ state: desiredEnabled ? 'desired' : 'absent',
2593
+ metadata: {
2594
+ enabled: desiredEnabled,
2595
+ scopes: desired.scopes,
2596
+ relation: desired.relation,
2597
+ },
2598
+ },
2599
+ ...ownershipComponents.map((component) => ({
2600
+ kind: 'ownership',
2601
+ key: component.key,
2602
+ state: component.key === 'native'
2603
+ && component.state === 'absent'
2604
+ && sharedNative?.staleCacheObserved
2605
+ ? 'partial'
2606
+ : component.state,
2607
+ ...(component.error ? { metadata: { errorCode: component.error.code } } : {}),
2608
+ })),
2609
+ ...(sharedNative ? [{
2610
+ kind: 'sharedNative',
2611
+ key: sharedNative.pluginId,
2612
+ state: sharedNative.state,
2613
+ metadata: {
2614
+ shared: true,
2615
+ ...(sharedNative.reason ? { reason: sharedNative.reason } : {}),
2616
+ ...(sharedNative.version ? { version: sharedNative.version } : {}),
2617
+ ...(sharedNative.desiredVersion ? { desiredVersion: sharedNative.desiredVersion } : {}),
2618
+ ...(sharedNative.diagnostic ? { diagnostic: sharedNative.diagnostic } : {}),
2619
+ ...(sharedNative.staleCacheObserved ? { staleCacheObserved: true } : {}),
2620
+ },
2621
+ }] : []),
2622
+ ...['user', 'project'].flatMap((scope) => activation?.[scope] === undefined ? [] : [{
2623
+ kind: 'activation',
2624
+ key: scope,
2625
+ state: activation[scope] ? 'enabled' : 'disabled',
2626
+ metadata: {
2627
+ evidence: activation.evidence,
2628
+ ...(activation.effective !== undefined ? { effective: activation.effective } : {}),
2629
+ },
2630
+ }]),
2631
+ ...(activation?.systemConsumer ? [{
2632
+ kind: 'systemConsumer',
2633
+ key: `codex:${representativeScope}`,
2634
+ state: activation.systemConsumer.state,
2635
+ metadata: {
2636
+ evidence: activation.evidence,
2637
+ requiredMinVersion: activation.systemConsumer.requiredMinVersion,
2638
+ ...('detectedVersion' in activation.systemConsumer
2639
+ ? { detectedVersion: activation.systemConsumer.detectedVersion }
2640
+ : {}),
2641
+ ...('code' in activation.systemConsumer ? { code: activation.systemConsumer.code } : {}),
2642
+ ...('diagnostic' in activation.systemConsumer
2643
+ ? { diagnostic: activation.systemConsumer.diagnostic }
2644
+ : {}),
2645
+ ...(activation.systemConsumer.diagnostics?.length
2646
+ ? { diagnostics: activation.systemConsumer.diagnostics }
2647
+ : {}),
2648
+ },
2649
+ }] : []),
2650
+ ...(extensions ? [{
2651
+ kind: 'extension',
2652
+ key: 'aw',
2653
+ state: extensions.state,
2654
+ metadata: { kinds: extensions.kinds },
2655
+ }] : []),
2656
+ ...(representativeTarget.dependencyReadiness ?? []).map((dependency) => ({
2657
+ kind: 'dependency',
2658
+ key: dependency.dependencyPluginId,
2659
+ state: dependency.state,
2660
+ metadata: {
2661
+ platform: dependency.dependencyPlatform,
2662
+ scope: dependency.dependencyScope,
2663
+ project: dependency.dependencyProject ?? 'none',
2664
+ ...(dependency.rootIssueId ? { rootIssueId: dependency.rootIssueId } : {}),
2665
+ ...(dependency.rootIssueCode ? { rootIssueCode: dependency.rootIssueCode } : {}),
2666
+ },
2667
+ })),
2668
+ ];
2669
+ const { state: _ownershipState, components: _ownershipComponents, errors: _errors, sharedNative: _sharedNative, activation: _activation, extensions: _extensions, dependency: _dependency, dependencyReadiness: _dependencyReadiness, ...identity } = target;
2670
+ return {
2671
+ ...identity,
2672
+ scope: representativeScope,
2673
+ state,
2674
+ components,
2675
+ reasons: dedupedErrors,
2676
+ recoveryActions: projectDisablesUserActivation && state === 'needsSync' ? [{
2677
+ command: 'sync', scope: 'user',
2678
+ description: '移除当前项目的关闭设置,恢复使用所有项目已启用的插件。',
2679
+ }] : statusRecovery({
2680
+ state,
2681
+ desired,
2682
+ platform: target.platform,
2683
+ pluginId: target.pluginId,
2684
+ ...(dependencyMoves.length > 0 ? { dependencyMoves } : {}),
2685
+ ...(sharedNative ? { sharedNative } : {}),
2686
+ scope: target.scope,
2687
+ actualEnabled: actualScopeEnabled,
2688
+ conflictRoots: rootIntentsForTarget({
2689
+ pluginId: target.pluginId,
2690
+ platform: target.platform,
2691
+ userIntent,
2692
+ projectIntent,
2693
+ available,
2694
+ }),
2695
+ errorCodes: dedupedErrors.map((error) => error.code),
2696
+ }).map((action) => action.command === 'manual' || action.scope
2697
+ ? action
2698
+ : { ...action, scope: representativeScope }),
2699
+ };
2700
+ };
2701
+ const codexGroups = new Map();
2702
+ const projectedTargets = [];
2703
+ for (const target of draftTargets) {
2704
+ if (target.platform !== 'codex') {
2705
+ projectedTargets.push(await decorateTarget(target, [target.scope], [target]));
2706
+ continue;
2707
+ }
2708
+ const group = codexGroups.get(target.pluginId) ?? [];
2709
+ group.push(target);
2710
+ codexGroups.set(target.pluginId, group);
2711
+ }
2712
+ for (const group of codexGroups.values()) {
2713
+ const decorated = await Promise.all(group.map((target) => decorateTarget(target, [target.scope], [target])));
2714
+ const first = decorated[0];
2715
+ const entry = selectedByPluginId.get(first.pluginId);
2716
+ const desired = desiredTargetStates.get(desiredTargetKey(first.pluginId, 'codex'))
2717
+ ?? { scopes: [], relation: 'none' };
2718
+ const returnedScopes = new Set(decorated.map((target) => target.scope));
2719
+ const desiredOverlapConflict = (entry?.codex?.extensionKinds.length ?? 0) > 0
2720
+ && desired.scopes.includes('user')
2721
+ && desired.scopes.includes('project')
2722
+ && returnedScopes.has('user')
2723
+ && returnedScopes.has('project');
2724
+ const sharedComponents = [...new Map(decorated.flatMap((target) => target.components)
2725
+ .filter((component) => component.kind === 'sharedNative' || component.kind === 'systemConsumer')
2726
+ .map((component) => [`${component.kind}\0${component.key}`, component])).values()];
2727
+ const sharedReason = (reason) => reason.code.startsWith('codexSharedNative') || reason.code === 'staleCacheObserved'
2728
+ || reason.code === 'codexCandidateExcluded';
2729
+ const sharedReasons = decorated.flatMap((target) => target.reasons.filter(sharedReason));
2730
+ const placements = decorated.map((target) => ({
2731
+ scope: target.scope,
2732
+ state: target.state,
2733
+ components: target.components.filter((component) => component.kind !== 'sharedNative' && component.kind !== 'systemConsumer'),
2734
+ reasons: target.reasons.filter((reason) => !sharedReason(reason)),
2735
+ recoveryActions: target.recoveryActions,
2736
+ })).sort((left, right) => left.scope.localeCompare(right.scope, 'en'));
2737
+ const reasons = [...new Map([
2738
+ ...placements.flatMap((placement) => placement.reasons),
2739
+ ...sharedReasons,
2740
+ ...(desiredOverlapConflict ? [blocking('codexExtensionScopeConflict', `${first.pluginId} has AW extensions desired at user and project scope.`)] : []),
2741
+ ]
2742
+ .map((reason) => [`${reason.code}\0${reason.message}`, reason])).values()];
2743
+ const conflictRecovery = desiredOverlapConflict ? statusRecovery({
2744
+ state: 'blocked',
2745
+ desired,
2746
+ platform: 'codex',
2747
+ pluginId: first.pluginId,
2748
+ conflictRoots: rootIntentsForTarget({
2749
+ pluginId: first.pluginId,
2750
+ platform: 'codex',
2751
+ userIntent,
2752
+ projectIntent,
2753
+ available,
2754
+ }),
2755
+ errorCodes: ['codexExtensionScopeConflict'],
2756
+ }) : [];
2757
+ const recoveryActions = [...new Map((desiredOverlapConflict
2758
+ ? conflictRecovery
2759
+ : placements.flatMap((placement) => placement.recoveryActions))
2760
+ .map((action) => [
2761
+ `${action.command}\0${action.scope ?? ''}\0${action.description}`,
2762
+ action,
2763
+ ])).values()];
2764
+ const state = desiredOverlapConflict ? 'blocked'
2765
+ : ['blocked', 'needsSync', 'orphaned', 'ready', 'absent']
2766
+ .find((candidate) => placements.some((placement) => placement.state === candidate));
2767
+ projectedTargets.push({
2768
+ pluginName: first.pluginName,
2769
+ sourceId: first.sourceId,
2770
+ sourceIdentity: first.sourceIdentity,
2771
+ pluginId: first.pluginId,
2772
+ ...(first.version ? { version: first.version } : {}),
2773
+ platform: 'codex',
2774
+ cwd: first.cwd,
2775
+ state,
2776
+ components: sharedComponents,
2777
+ reasons,
2778
+ recoveryActions,
2779
+ placements,
2780
+ });
2781
+ }
2782
+ projectedTargets.sort((left, right) => `${left.pluginId}\0${left.platform}`.localeCompare(`${right.pluginId}\0${right.platform}`, 'en'));
2783
+ const targetRevisions = projectedTargets.flatMap((target) => {
2784
+ const entry = selectedByPluginId.get(target.pluginId);
2785
+ const placements = target.platform === 'codex' ? target.placements : [target];
2786
+ return placements.map((placement) => ({
2787
+ pluginId: target.pluginId,
2788
+ platform: target.platform,
2789
+ scope: placement.scope,
2790
+ revision: projectTargetRevision(entry?.version, entry?.states[target.platform]?.[placement.scope]?.installedVersion),
2791
+ }));
2792
+ });
2793
+ const publicConfigIssues = available.flatMap((entry) => (entry.configIssues ?? [])
2794
+ .filter((issue) => issue.type === 'configLayerUnsupported')
2795
+ .map((issue) => ({
2796
+ pluginId: formatPluginId({ sourceId: entry.source.id, pluginName: entry.name }),
2797
+ pluginName: entry.name,
2798
+ ...issue,
2799
+ })));
2800
+ const nativeObservations = available.flatMap((entry) => ['codex', 'claude'].map((platform) => {
2801
+ const observed = entry.states[platform]?.[scope];
2802
+ const blockers = (observed?.errors ?? []).map((error) => ({
2803
+ code: error.code, message: `${error.code}: 项目 Native 目标尚未满足。`,
2804
+ }));
2805
+ const nativeInventoryErrors = inventoryErrors.filter((error) => inventoryErrorMatchesSelection({
2806
+ error,
2807
+ selectors: [{ raw: `${entry.source.id}/${entry.name}`, parsed: {
2808
+ sourceId: entry.source.id, pluginName: entry.name,
2809
+ } }],
2810
+ platformExplicit: true, scopeExplicit: true, platforms: [platform], scopes: [scope],
2811
+ currentProjectLocationKey,
2812
+ }));
2813
+ blockers.push(...nativeInventoryErrors.map((error) => ({
2814
+ code: error.code, message: `${error.code}: 无法读取项目 Native 现场。`,
2815
+ })));
2816
+ if (platform === 'codex' && codexConfigErrors.some((error) => error.scope === scope
2817
+ || scope === 'project' && error.scope === 'user')) {
2818
+ blockers.push({ code: 'nativeStateUnreadable', message: '无法读取 Codex 激活配置。' });
2819
+ }
2820
+ if (entry.configDiagnostic)
2821
+ blockers.push({ code: 'configReadFailed', message: '无法读取插件配置。' });
2822
+ if (entry.configIssues?.some((issue) => issue.scope === scope)) {
2823
+ blockers.push({ code: 'configInvalid', message: '项目配置需要处理。' });
2824
+ }
2825
+ if (observed?.state === 'error' && !blockers.some((error) => /Unsupported$|collision|conflict|foreign/iu.test(error.code))) {
2826
+ blockers.push({ code: 'nativeObservationFailed', message: '无法完成项目 Native 现场观察。' });
2827
+ }
2828
+ let content = !observed ? 'unknown'
2829
+ : observed.state === 'absent' ? 'absent'
2830
+ : observed.state === 'present' ? 'satisfied'
2831
+ : observed.state === 'partial' ? 'drifted' : 'unknown';
2832
+ if (blockers.some((blocker) => /collision|conflict|foreign/iu.test(blocker.code)))
2833
+ content = 'conflict';
2834
+ if (platform === 'codex' && entry.codex?.nativeKinds.length) {
2835
+ const shared = entry.codex.sharedNative;
2836
+ if (shared?.state === 'missing')
2837
+ content = 'absent';
2838
+ else if (shared?.state === 'replaceable')
2839
+ content = 'drifted';
2840
+ else if (shared?.state === 'blocked')
2841
+ content = shared.reason === 'foreign' ? 'conflict' : 'unknown';
2842
+ else if (!shared || shared.state === 'unobserved')
2843
+ content = 'unknown';
2844
+ if (content === 'satisfied' && entry.codex.activation.effective !== true)
2845
+ content = 'absent';
2846
+ }
2847
+ return {
2848
+ pluginId: `${entry.source.id}/${entry.name}`, platform, content, blockers,
2849
+ backend: flattenStatusTargets(projectedTargets).find((target) => target.pluginId === `${entry.source.id}/${entry.name}`
2850
+ && target.platform === platform && target.scope === scope),
2851
+ ...(platform === 'codex' && entry.codex?.activation.evidence === 'assumed'
2852
+ ? { assumedActivation: true } : {}),
2853
+ };
2854
+ }));
2855
+ const payload = {
2856
+ schemaVersion: 8,
2857
+ catalog: {
2858
+ primarySourceId: catalog.primarySourceId,
2859
+ configDigest: catalog.configDigest,
2860
+ compositeDigest: catalog.compositeDigest,
2861
+ ...(options.catalogOperationContext
2862
+ ? { generationSetDigest: options.catalogOperationContext.generationSetDigest }
2863
+ : {}),
2864
+ sources: catalog.sources.map((source) => {
2865
+ if (!('plugins' in source))
2866
+ return source;
2867
+ const { plugins: _plugins, ...projected } = source;
2868
+ return projected;
2869
+ }),
2870
+ },
2871
+ filters: {
2872
+ plugins: requested,
2873
+ platform: options.platform === undefined ? 'both' : parsePlatformValue(options.platform),
2874
+ ...(options.scope === undefined ? {} : { scope: parseScopeValue(options.scope) }),
2875
+ cwd: path.resolve(options.cwd),
2876
+ },
2877
+ targets: projectedTargets,
2878
+ ...(publicConfigIssues.length > 0 ? { configIssues: publicConfigIssues } : {}),
2879
+ errors,
2880
+ };
2881
+ const hasErrors = payload.catalog.sources.some((source) => source.error !== undefined)
2882
+ || payload.errors.length > 0
2883
+ || payload.targets.some((target) => target.reasons.some((reason) => reason.severity === 'blocking'));
2884
+ return {
2885
+ payload,
2886
+ output: options.json ? JSON.stringify(payload) : renderStatusV8(payload, options.verbose === true),
2887
+ hasErrors,
2888
+ targetRevisions,
2889
+ nativeObservations,
2890
+ nativeExtraObserved: ownerInventory.references.flatMap((reference) => {
2891
+ if (!reference.sourceId || !reference.pluginName || reference.scope !== scope
2892
+ || !['namespacedOwner', 'namespacedConfig', 'namespacedMarketplace'].includes(reference.kind))
2893
+ return [];
2894
+ return [{ pluginId: `${reference.sourceId}/${reference.pluginName}`,
2895
+ ...(reference.platform === 'codex' || reference.platform === 'claude'
2896
+ ? { platform: reference.platform } : {}), scope, reference }];
2897
+ }),
2898
+ ...(projectRoot ? { projectRoot } : {}),
2899
+ projectIntentObservation,
2900
+ pluginSummaries: available.map((entry) => {
2901
+ const sourceEntries = available.filter((candidate) => candidate.source.id === entry.source.id);
2902
+ const byName = new Map(sourceEntries.map((candidate) => [candidate.name, candidate]));
2903
+ const transitive = new Set();
2904
+ const visit = (name) => {
2905
+ const candidate = byName.get(name);
2906
+ for (const dependency of candidate?.dependencies ?? []) {
2907
+ if (transitive.has(dependency))
2908
+ continue;
2909
+ transitive.add(dependency);
2910
+ visit(dependency);
2911
+ }
2912
+ };
2913
+ visit(entry.name);
2914
+ const dependencyIssueCount = targets.filter((target) => target.pluginId === formatPluginId({
2915
+ sourceId: entry.source.id,
2916
+ pluginName: entry.name,
2917
+ })).reduce((count, target) => count + target.errors.filter((error) => error.code.startsWith('dependency')
2918
+ || error.code === 'awCapabilityUnsupported'
2919
+ || error.code === 'sourceChanged').length, 0);
2920
+ return {
2921
+ pluginName: entry.name,
2922
+ pluginId: formatPluginId({ sourceId: entry.source.id, pluginName: entry.name }),
2923
+ displayName: entry.displayName,
2924
+ description: entry.shortDescription,
2925
+ version: entry.version,
2926
+ supportedTargets: {
2927
+ codex: ['user', 'project'].filter((scope) => entry.targets.codex[scope]),
2928
+ claude: ['user', 'project'].filter((scope) => entry.targets.claude[scope]),
2929
+ },
2930
+ ...(entry.platforms ? { platforms: entry.platforms } : {}),
2931
+ configFieldCount: Object.keys(entry.configSchema ?? {}).length,
2932
+ ...(entry.configSchema ? { configSchema: entry.configSchema } : {}),
2933
+ ...(entry.configIssues ? { configIssues: entry.configIssues } : {}),
2934
+ ...(entry.configDiagnostic ? { configDiagnostic: entry.configDiagnostic } : {}),
2935
+ dependencyDirectCount: entry.dependencies.length,
2936
+ dependencyTotalCount: transitive.size,
2937
+ dependencyIssueCount,
2938
+ ...(entry.missingCapabilities
2939
+ ? { missingCapabilities: entry.missingCapabilities }
2940
+ : {}),
2941
+ };
2942
+ }),
2943
+ };
2944
+ }
2945
+ export async function statusCommandV8(options) {
2946
+ options.signal?.throwIfAborted();
2947
+ options = { ...options, nativeCliRunner: bindNativeCliRunnerSignal(options.nativeCliRunner ?? getDefaultNativeCliRunner(), options.signal) };
2948
+ if (options.codexObservationSession) {
2949
+ return statusCommandV8InSession({
2950
+ ...options,
2951
+ codexObservationSession: options.codexObservationSession,
2952
+ });
2953
+ }
2954
+ const env = options.env ?? process.env;
2955
+ const session = await createCodexNativeObservationSession({
2956
+ exactCwd: options.cwd,
2957
+ env,
2958
+ runner: options.nativeCliRunner ?? getDefaultNativeCliRunner(),
2959
+ });
2960
+ try {
2961
+ options.signal?.throwIfAborted();
2962
+ const result = await statusCommandV8InSession({ ...options, codexObservationSession: session });
2963
+ options.signal?.throwIfAborted();
2964
+ return result;
2965
+ }
2966
+ finally {
2967
+ await session.dispose();
2968
+ }
2969
+ }
2970
+ //# sourceMappingURL=status-v6.js.map