@lesliechan721/aw 0.1.0-beta.8 → 0.1.0-beta.81

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