@lesliechan721/aw 0.1.0-beta.3 → 0.1.0-beta.31

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 (529) 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/scripts/add-skill.mjs +4 -4
  4. package/dist/authoring/scripts/add-skill.mjs.map +1 -1
  5. package/dist/authoring/scripts/init-plugin.mjs +67 -97
  6. package/dist/authoring/scripts/init-plugin.mjs.map +1 -1
  7. package/dist/authoring/scripts/lib/plugin-version-check.d.mts +15 -0
  8. package/dist/authoring/scripts/lib/plugin-version-check.mjs +239 -232
  9. package/dist/authoring/scripts/lib/plugin-version-check.mjs.map +1 -1
  10. package/dist/authoring/scripts/lib/skill-scaffold.d.mts +77 -90
  11. package/dist/authoring/scripts/lib/skill-scaffold.mjs +99 -120
  12. package/dist/authoring/scripts/lib/skill-scaffold.mjs.map +1 -1
  13. package/dist/authoring/scripts/plugin-status.mjs +8 -11
  14. package/dist/authoring/scripts/plugin-status.mjs.map +1 -1
  15. package/dist/authoring/scripts/remove-plugin.mjs +367 -0
  16. package/dist/authoring/scripts/remove-plugin.mjs.map +1 -0
  17. package/dist/authoring/scripts/validate-plugin.mjs +307 -1173
  18. package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
  19. package/dist/scripts/aw-skill-eval-materializer.d.ts +26 -0
  20. package/dist/scripts/aw-skill-eval-materializer.js +306 -0
  21. package/dist/scripts/aw-skill-eval-materializer.js.map +1 -0
  22. package/dist/scripts/bundle-plugins.d.ts +1 -2
  23. package/dist/scripts/bundle-plugins.js +24 -7
  24. package/dist/scripts/bundle-plugins.js.map +1 -1
  25. package/dist/scripts/plugin-staging.d.ts +7 -24
  26. package/dist/scripts/plugin-staging.js +22 -142
  27. package/dist/scripts/plugin-staging.js.map +1 -1
  28. package/dist/scripts/test-plugin-scripts.d.ts +2 -0
  29. package/dist/scripts/test-plugin-scripts.js +27 -75
  30. package/dist/scripts/test-plugin-scripts.js.map +1 -1
  31. package/dist/src/adapters/helpers.js +2 -2
  32. package/dist/src/adapters/helpers.js.map +1 -1
  33. package/dist/src/authoring/workspace-commands.d.ts +26 -2
  34. package/dist/src/authoring/workspace-commands.js +44 -19
  35. package/dist/src/authoring/workspace-commands.js.map +1 -1
  36. package/dist/src/commands/aw-capabilities.d.ts +78 -0
  37. package/dist/src/commands/aw-capabilities.js +256 -0
  38. package/dist/src/commands/aw-capabilities.js.map +1 -0
  39. package/dist/src/commands/catalog-dev-source.d.ts +154 -0
  40. package/dist/src/commands/catalog-dev-source.js +655 -0
  41. package/dist/src/commands/catalog-dev-source.js.map +1 -0
  42. package/dist/src/commands/catalog-generation.d.ts +21 -0
  43. package/dist/src/commands/catalog-generation.js +9 -0
  44. package/dist/src/commands/catalog-generation.js.map +1 -0
  45. package/dist/src/commands/catalog-publication-inspection.d.ts +138 -0
  46. package/dist/src/commands/catalog-publication-inspection.js +757 -0
  47. package/dist/src/commands/catalog-publication-inspection.js.map +1 -0
  48. package/dist/src/commands/catalog-publication-journal.d.ts +68 -0
  49. package/dist/src/commands/catalog-publication-journal.js +292 -0
  50. package/dist/src/commands/catalog-publication-journal.js.map +1 -0
  51. package/dist/src/commands/catalog-publication-target.d.ts +18 -0
  52. package/dist/src/commands/catalog-publication-target.js +95 -0
  53. package/dist/src/commands/catalog-publication-target.js.map +1 -0
  54. package/dist/src/commands/catalog-publish.d.ts +77 -7
  55. package/dist/src/commands/catalog-publish.js +746 -316
  56. package/dist/src/commands/catalog-publish.js.map +1 -1
  57. package/dist/src/commands/catalog-source.d.ts +60 -22
  58. package/dist/src/commands/catalog-source.js +311 -91
  59. package/dist/src/commands/catalog-source.js.map +1 -1
  60. package/dist/src/commands/catalog-status.d.ts +56 -0
  61. package/dist/src/commands/catalog-status.js +217 -0
  62. package/dist/src/commands/catalog-status.js.map +1 -0
  63. package/dist/src/commands/catalog-store.d.ts +104 -0
  64. package/dist/src/commands/catalog-store.js +685 -0
  65. package/dist/src/commands/catalog-store.js.map +1 -0
  66. package/dist/src/commands/catalog-workspace-resolution.d.ts +13 -0
  67. package/dist/src/commands/catalog-workspace-resolution.js +42 -0
  68. package/dist/src/commands/catalog-workspace-resolution.js.map +1 -0
  69. package/dist/src/commands/console.js +28 -17
  70. package/dist/src/commands/console.js.map +1 -1
  71. package/dist/src/commands/dependency-operation-plan.d.ts +52 -15
  72. package/dist/src/commands/dependency-operation-plan.js +289 -7
  73. package/dist/src/commands/dependency-operation-plan.js.map +1 -1
  74. package/dist/src/commands/init.d.ts +5 -11
  75. package/dist/src/commands/init.js +30 -51
  76. package/dist/src/commands/init.js.map +1 -1
  77. package/dist/src/commands/offline-cleanup-evidence.d.ts +67 -0
  78. package/dist/src/commands/offline-cleanup-evidence.js +181 -0
  79. package/dist/src/commands/offline-cleanup-evidence.js.map +1 -0
  80. package/dist/src/commands/operation-plan.d.ts +127 -0
  81. package/dist/src/commands/operation-plan.js +71 -0
  82. package/dist/src/commands/operation-plan.js.map +1 -0
  83. package/dist/src/commands/operation-planner.d.ts +46 -0
  84. package/dist/src/commands/operation-planner.js +141 -0
  85. package/dist/src/commands/operation-planner.js.map +1 -0
  86. package/dist/src/commands/options.d.ts +9 -7
  87. package/dist/src/commands/options.js +83 -21
  88. package/dist/src/commands/options.js.map +1 -1
  89. package/dist/src/commands/plugin-capabilities.d.ts +22 -0
  90. package/dist/src/commands/plugin-capabilities.js +159 -0
  91. package/dist/src/commands/plugin-capabilities.js.map +1 -0
  92. package/dist/src/commands/rebuild-command.d.ts +77 -30
  93. package/dist/src/commands/rebuild-command.js +3993 -711
  94. package/dist/src/commands/rebuild-command.js.map +1 -1
  95. package/dist/src/commands/rebuild-integration.d.ts +120 -21
  96. package/dist/src/commands/rebuild-integration.js +2765 -1326
  97. package/dist/src/commands/rebuild-integration.js.map +1 -1
  98. package/dist/src/commands/rebuild-operations.d.ts +58 -30
  99. package/dist/src/commands/rebuild-operations.js +260 -319
  100. package/dist/src/commands/rebuild-operations.js.map +1 -1
  101. package/dist/src/commands/reconcile-operation-plan.d.ts +28 -0
  102. package/dist/src/commands/reconcile-operation-plan.js +47 -0
  103. package/dist/src/commands/reconcile-operation-plan.js.map +1 -0
  104. package/dist/src/commands/review-inspection.d.ts +228 -0
  105. package/dist/src/commands/review-inspection.js +1341 -0
  106. package/dist/src/commands/review-inspection.js.map +1 -0
  107. package/dist/src/commands/review-preparation.d.ts +49 -0
  108. package/dist/src/commands/review-preparation.js +427 -0
  109. package/dist/src/commands/review-preparation.js.map +1 -0
  110. package/dist/src/commands/runtime.d.ts +1 -5
  111. package/dist/src/commands/runtime.js +24 -50
  112. package/dist/src/commands/runtime.js.map +1 -1
  113. package/dist/src/commands/skill-eval.d.ts +38 -0
  114. package/dist/src/commands/skill-eval.js +388 -0
  115. package/dist/src/commands/skill-eval.js.map +1 -0
  116. package/dist/src/commands/status-v6.d.ts +279 -0
  117. package/dist/src/commands/status-v6.js +2697 -0
  118. package/dist/src/commands/status-v6.js.map +1 -0
  119. package/dist/src/commands/sync-command.d.ts +40 -0
  120. package/dist/src/commands/sync-command.js +250 -0
  121. package/dist/src/commands/sync-command.js.map +1 -0
  122. package/dist/src/commands/wizard.d.ts +3 -4
  123. package/dist/src/commands/wizard.js +2 -2
  124. package/dist/src/commands/wizard.js.map +1 -1
  125. package/dist/src/commands/write-commands.d.ts +9 -3
  126. package/dist/src/commands/write-commands.js +124 -31
  127. package/dist/src/commands/write-commands.js.map +1 -1
  128. package/dist/src/constants.d.ts +7 -1
  129. package/dist/src/constants.js +7 -1
  130. package/dist/src/constants.js.map +1 -1
  131. package/dist/src/eval/manifest-v1.d.ts +71 -0
  132. package/dist/src/eval/manifest-v1.js +370 -0
  133. package/dist/src/eval/manifest-v1.js.map +1 -0
  134. package/dist/src/generators/local-plugin.d.ts +5 -1
  135. package/dist/src/generators/local-plugin.js +225 -104
  136. package/dist/src/generators/local-plugin.js.map +1 -1
  137. package/dist/src/index.d.ts +10 -4
  138. package/dist/src/index.js +1787 -476
  139. package/dist/src/index.js.map +1 -1
  140. package/dist/src/output/command-receipt.d.ts +43 -46
  141. package/dist/src/output/command-receipt.js +256 -80
  142. package/dist/src/output/command-receipt.js.map +1 -1
  143. package/dist/src/output/model.d.ts +3 -44
  144. package/dist/src/output/model.js +1 -144
  145. package/dist/src/output/model.js.map +1 -1
  146. package/dist/src/output/rebuild-progress.js +1 -13
  147. package/dist/src/output/rebuild-progress.js.map +1 -1
  148. package/dist/src/portable/commands.d.ts +46 -7
  149. package/dist/src/portable/commands.js +349 -37
  150. package/dist/src/portable/commands.js.map +1 -1
  151. package/dist/src/portable/materializer.d.ts +17 -4
  152. package/dist/src/portable/materializer.js +160 -38
  153. package/dist/src/portable/materializer.js.map +1 -1
  154. package/dist/src/portable/skills-cli.d.ts +15 -7
  155. package/dist/src/portable/skills-cli.js +66 -19
  156. package/dist/src/portable/skills-cli.js.map +1 -1
  157. package/dist/src/review/eval-source-input.d.ts +43 -0
  158. package/dist/src/review/eval-source-input.js +207 -0
  159. package/dist/src/review/eval-source-input.js.map +1 -0
  160. package/dist/src/review/review-profile.d.ts +17 -0
  161. package/dist/src/review/review-profile.js +177 -0
  162. package/dist/src/review/review-profile.js.map +1 -0
  163. package/dist/src/review/review-selection.d.ts +30 -0
  164. package/dist/src/review/review-selection.js +527 -0
  165. package/dist/src/review/review-selection.js.map +1 -0
  166. package/dist/src/review/review-types.d.ts +68 -0
  167. package/dist/src/review/review-types.js +16 -0
  168. package/dist/src/review/review-types.js.map +1 -0
  169. package/dist/src/review/skill-materialization.d.ts +13 -0
  170. package/dist/src/review/skill-materialization.js +75 -0
  171. package/dist/src/review/skill-materialization.js.map +1 -0
  172. package/dist/src/review/source-binding.d.ts +182 -0
  173. package/dist/src/review/source-binding.js +682 -0
  174. package/dist/src/review/source-binding.js.map +1 -0
  175. package/dist/src/tui/catalog-freshness.d.ts +1 -0
  176. package/dist/src/tui/catalog-freshness.js +2 -0
  177. package/dist/src/tui/catalog-freshness.js.map +1 -0
  178. package/dist/src/tui/catalog-generation.d.ts +21 -0
  179. package/dist/src/tui/catalog-generation.js +156 -0
  180. package/dist/src/tui/catalog-generation.js.map +1 -0
  181. package/dist/src/tui/catalog-sources/projection.d.ts +4 -0
  182. package/dist/src/tui/catalog-sources/projection.js +17 -0
  183. package/dist/src/tui/catalog-sources/projection.js.map +1 -0
  184. package/dist/src/tui/catalog-sources/review.d.ts +3 -0
  185. package/dist/src/tui/catalog-sources/review.js +13 -0
  186. package/dist/src/tui/catalog-sources/review.js.map +1 -0
  187. package/dist/src/tui/catalog-sources/screens.d.ts +12 -0
  188. package/dist/src/tui/catalog-sources/screens.js +40 -0
  189. package/dist/src/tui/catalog-sources/screens.js.map +1 -0
  190. package/dist/src/tui/catalog-sources/session.d.ts +28 -0
  191. package/dist/src/tui/catalog-sources/session.js +295 -0
  192. package/dist/src/tui/catalog-sources/session.js.map +1 -0
  193. package/dist/src/tui/catalog-sources/types.d.ts +53 -0
  194. package/dist/src/tui/catalog-sources/types.js +2 -0
  195. package/dist/src/tui/catalog-sources/types.js.map +1 -0
  196. package/dist/src/tui/catalog-store-task.d.ts +16 -0
  197. package/dist/src/tui/catalog-store-task.js +19 -0
  198. package/dist/src/tui/catalog-store-task.js.map +1 -0
  199. package/dist/src/tui/components.d.ts +128 -0
  200. package/dist/src/tui/components.js +251 -7
  201. package/dist/src/tui/components.js.map +1 -1
  202. package/dist/src/tui/console-app-v4.d.ts +14 -4
  203. package/dist/src/tui/console-app-v4.js +9248 -1461
  204. package/dist/src/tui/console-app-v4.js.map +1 -1
  205. package/dist/src/tui/controller-runtime.d.ts +13 -1
  206. package/dist/src/tui/controller-runtime.js +3338 -410
  207. package/dist/src/tui/controller-runtime.js.map +1 -1
  208. package/dist/src/tui/controller.d.ts +614 -40
  209. package/dist/src/tui/controller.js +3478 -708
  210. package/dist/src/tui/controller.js.map +1 -1
  211. package/dist/src/tui/dependency-graph.d.ts +81 -0
  212. package/dist/src/tui/dependency-graph.js +455 -0
  213. package/dist/src/tui/dependency-graph.js.map +1 -0
  214. package/dist/src/tui/diagnostic-projection.d.ts +23 -0
  215. package/dist/src/tui/diagnostic-projection.js +567 -0
  216. package/dist/src/tui/diagnostic-projection.js.map +1 -0
  217. package/dist/src/tui/diagnostics.d.ts +30 -0
  218. package/dist/src/tui/diagnostics.js +76 -0
  219. package/dist/src/tui/diagnostics.js.map +1 -0
  220. package/dist/src/tui/glossary.d.ts +23 -0
  221. package/dist/src/tui/glossary.js +42 -0
  222. package/dist/src/tui/glossary.js.map +1 -0
  223. package/dist/src/tui/index.d.ts +11 -4
  224. package/dist/src/tui/index.js +8 -2
  225. package/dist/src/tui/index.js.map +1 -1
  226. package/dist/src/tui/input-display.d.ts +8 -0
  227. package/dist/src/tui/input-display.js +36 -0
  228. package/dist/src/tui/input-display.js.map +1 -0
  229. package/dist/src/tui/keys.d.ts +44 -0
  230. package/dist/src/tui/keys.js +43 -15
  231. package/dist/src/tui/keys.js.map +1 -1
  232. package/dist/src/tui/lifecycle-action-view.d.ts +6 -0
  233. package/dist/src/tui/lifecycle-action-view.js +36 -0
  234. package/dist/src/tui/lifecycle-action-view.js.map +1 -0
  235. package/dist/src/tui/model.d.ts +235 -27
  236. package/dist/src/tui/model.js +1652 -304
  237. package/dist/src/tui/model.js.map +1 -1
  238. package/dist/src/tui/operation-diagnostic-screens.d.ts +21 -0
  239. package/dist/src/tui/operation-diagnostic-screens.js +102 -0
  240. package/dist/src/tui/operation-diagnostic-screens.js.map +1 -0
  241. package/dist/src/tui/operation-history.d.ts +81 -0
  242. package/dist/src/tui/operation-history.js +135 -0
  243. package/dist/src/tui/operation-history.js.map +1 -0
  244. package/dist/src/tui/operation-review-planner.d.ts +21 -0
  245. package/dist/src/tui/operation-review-planner.js +1254 -0
  246. package/dist/src/tui/operation-review-planner.js.map +1 -0
  247. package/dist/src/tui/plugin-content.d.ts +23 -0
  248. package/dist/src/tui/plugin-content.js +336 -0
  249. package/dist/src/tui/plugin-content.js.map +1 -0
  250. package/dist/src/tui/plugin-write-task.d.ts +69 -0
  251. package/dist/src/tui/plugin-write-task.js +286 -0
  252. package/dist/src/tui/plugin-write-task.js.map +1 -0
  253. package/dist/src/tui/prompt.js +4 -15
  254. package/dist/src/tui/prompt.js.map +1 -1
  255. package/dist/src/tui/router.d.ts +183 -11
  256. package/dist/src/tui/router.js +352 -29
  257. package/dist/src/tui/router.js.map +1 -1
  258. package/dist/src/tui/screen-registry.d.ts +702 -0
  259. package/dist/src/tui/screen-registry.js +231 -0
  260. package/dist/src/tui/screen-registry.js.map +1 -0
  261. package/dist/src/tui/session-console-app.d.ts +6 -0
  262. package/dist/src/tui/session-console-app.js +13 -0
  263. package/dist/src/tui/session-console-app.js.map +1 -0
  264. package/dist/src/tui/session-host.d.ts +45 -0
  265. package/dist/src/tui/session-host.js +209 -0
  266. package/dist/src/tui/session-host.js.map +1 -0
  267. package/dist/src/tui/source-ref-presets.d.ts +3 -0
  268. package/dist/src/tui/source-ref-presets.js +11 -0
  269. package/dist/src/tui/source-ref-presets.js.map +1 -0
  270. package/dist/src/tui/theme.d.ts +18 -10
  271. package/dist/src/tui/theme.js +18 -10
  272. package/dist/src/tui/theme.js.map +1 -1
  273. package/dist/src/tui/viewport.d.ts +20 -0
  274. package/dist/src/tui/viewport.js +29 -0
  275. package/dist/src/tui/viewport.js.map +1 -0
  276. package/dist/src/tui/views.js +31 -3
  277. package/dist/src/tui/views.js.map +1 -1
  278. package/dist/src/tui/wizard.js +11 -9
  279. package/dist/src/tui/wizard.js.map +1 -1
  280. package/dist/src/types.d.ts +242 -20
  281. package/dist/src/types.js +1 -0
  282. package/dist/src/types.js.map +1 -1
  283. package/dist/src/utils/agent-version.d.ts +7 -1
  284. package/dist/src/utils/agent-version.js +41 -8
  285. package/dist/src/utils/agent-version.js.map +1 -1
  286. package/dist/src/utils/artifact-plan.d.ts +5 -4
  287. package/dist/src/utils/artifact-plan.js +18 -7
  288. package/dist/src/utils/artifact-plan.js.map +1 -1
  289. package/dist/src/utils/artifact-renderer.d.ts +13 -7
  290. package/dist/src/utils/artifact-renderer.js +196 -219
  291. package/dist/src/utils/artifact-renderer.js.map +1 -1
  292. package/dist/src/utils/artifact-request.d.ts +21 -0
  293. package/dist/src/utils/artifact-request.js +82 -0
  294. package/dist/src/utils/artifact-request.js.map +1 -0
  295. package/dist/src/utils/aw-home-mutation-lock.d.ts +1 -0
  296. package/dist/src/utils/aw-home-mutation-lock.js +32 -4
  297. package/dist/src/utils/aw-home-mutation-lock.js.map +1 -1
  298. package/dist/src/utils/bundle-integrity.d.ts +0 -1
  299. package/dist/src/utils/bundle-integrity.js +0 -25
  300. package/dist/src/utils/bundle-integrity.js.map +1 -1
  301. package/dist/src/utils/bundle-layout.js +14 -29
  302. package/dist/src/utils/bundle-layout.js.map +1 -1
  303. package/dist/src/utils/catalog-capability-projection.d.ts +8 -0
  304. package/dist/src/utils/catalog-capability-projection.js +14 -0
  305. package/dist/src/utils/catalog-capability-projection.js.map +1 -0
  306. package/dist/src/utils/catalog-digests.d.ts +10 -0
  307. package/dist/src/utils/catalog-digests.js +50 -2
  308. package/dist/src/utils/catalog-digests.js.map +1 -1
  309. package/dist/src/utils/catalog-generation-control-snapshot.d.ts +11 -0
  310. package/dist/src/utils/catalog-generation-control-snapshot.js +45 -0
  311. package/dist/src/utils/catalog-generation-control-snapshot.js.map +1 -0
  312. package/dist/src/utils/catalog-generation-error.d.ts +16 -0
  313. package/dist/src/utils/catalog-generation-error.js +30 -0
  314. package/dist/src/utils/catalog-generation-error.js.map +1 -0
  315. package/dist/src/utils/catalog-generation-resolver.d.ts +44 -0
  316. package/dist/src/utils/catalog-generation-resolver.js +273 -0
  317. package/dist/src/utils/catalog-generation-resolver.js.map +1 -0
  318. package/dist/src/utils/catalog-generation-service.d.ts +172 -0
  319. package/dist/src/utils/catalog-generation-service.js +1271 -0
  320. package/dist/src/utils/catalog-generation-service.js.map +1 -0
  321. package/dist/src/utils/catalog-generation-state.d.ts +22 -0
  322. package/dist/src/utils/catalog-generation-state.js +192 -0
  323. package/dist/src/utils/catalog-generation-state.js.map +1 -0
  324. package/dist/src/utils/catalog-generation-store.d.ts +58 -0
  325. package/dist/src/utils/catalog-generation-store.js +452 -0
  326. package/dist/src/utils/catalog-generation-store.js.map +1 -0
  327. package/dist/src/utils/catalog-manifest-v7.d.ts +5 -0
  328. package/dist/src/utils/{catalog-manifest-v4.js → catalog-manifest-v7.js} +35 -43
  329. package/dist/src/utils/catalog-manifest-v7.js.map +1 -0
  330. package/dist/src/utils/catalog-operation-context.d.ts +20 -0
  331. package/dist/src/utils/catalog-operation-context.js +142 -0
  332. package/dist/src/utils/catalog-operation-context.js.map +1 -0
  333. package/dist/src/utils/catalog-public-error.d.ts +7 -3
  334. package/dist/src/utils/catalog-public-error.js +28 -8
  335. package/dist/src/utils/catalog-public-error.js.map +1 -1
  336. package/dist/src/utils/catalog-runtime-projection.d.ts +4 -7
  337. package/dist/src/utils/catalog-runtime-projection.js +7 -102
  338. package/dist/src/utils/catalog-runtime-projection.js.map +1 -1
  339. package/dist/src/utils/catalog-snapshot.d.ts +5 -3
  340. package/dist/src/utils/catalog-snapshot.js +11 -3
  341. package/dist/src/utils/catalog-snapshot.js.map +1 -1
  342. package/dist/src/utils/catalog-source-identity.d.ts +1 -0
  343. package/dist/src/utils/catalog-source-identity.js +21 -2
  344. package/dist/src/utils/catalog-source-identity.js.map +1 -1
  345. package/dist/src/utils/catalog-source-impact.d.ts +21 -0
  346. package/dist/src/utils/catalog-source-impact.js +344 -0
  347. package/dist/src/utils/catalog-source-impact.js.map +1 -0
  348. package/dist/src/utils/catalog-source-references.d.ts +3 -2
  349. package/dist/src/utils/catalog-source-references.js +195 -347
  350. package/dist/src/utils/catalog-source-references.js.map +1 -1
  351. package/dist/src/utils/catalog-sources.d.ts +15 -1
  352. package/dist/src/utils/catalog-sources.js +206 -27
  353. package/dist/src/utils/catalog-sources.js.map +1 -1
  354. package/dist/src/utils/codex-config.d.ts +2 -0
  355. package/dist/src/utils/codex-config.js +26 -5
  356. package/dist/src/utils/codex-config.js.map +1 -1
  357. package/dist/src/utils/codex-manager.d.ts +79 -0
  358. package/dist/src/utils/codex-manager.js +745 -0
  359. package/dist/src/utils/codex-manager.js.map +1 -0
  360. package/dist/src/utils/codex-marketplace-path.d.ts +5 -0
  361. package/dist/src/utils/codex-marketplace-path.js +45 -0
  362. package/dist/src/utils/codex-marketplace-path.js.map +1 -0
  363. package/dist/src/utils/codex-native-observation.d.ts +49 -0
  364. package/dist/src/utils/codex-native-observation.js +154 -0
  365. package/dist/src/utils/codex-native-observation.js.map +1 -0
  366. package/dist/src/utils/codex-native-render-receipt.d.ts +40 -0
  367. package/dist/src/utils/codex-native-render-receipt.js +205 -0
  368. package/dist/src/utils/codex-native-render-receipt.js.map +1 -0
  369. package/dist/src/utils/codex-reconciler.d.ts +126 -0
  370. package/dist/src/utils/codex-reconciler.js +298 -0
  371. package/dist/src/utils/codex-reconciler.js.map +1 -0
  372. package/dist/src/utils/codex-shared-native.d.ts +43 -0
  373. package/dist/src/utils/codex-shared-native.js +81 -0
  374. package/dist/src/utils/codex-shared-native.js.map +1 -0
  375. package/dist/src/utils/codex-skill-staging.d.ts +2 -0
  376. package/dist/src/utils/codex-skill-staging.js.map +1 -1
  377. package/dist/src/utils/codex-surface-analysis.d.ts +46 -0
  378. package/dist/src/utils/codex-surface-analysis.js +247 -0
  379. package/dist/src/utils/codex-surface-analysis.js.map +1 -0
  380. package/dist/src/utils/dynamic-skill-tree.d.ts +4 -0
  381. package/dist/src/utils/dynamic-skill-tree.js +36 -6
  382. package/dist/src/utils/dynamic-skill-tree.js.map +1 -1
  383. package/dist/src/utils/git-catalog-provider.d.ts +18 -0
  384. package/dist/src/utils/git-catalog-provider.js +170 -144
  385. package/dist/src/utils/git-catalog-provider.js.map +1 -1
  386. package/dist/src/utils/local-marketplace.d.ts +15 -1
  387. package/dist/src/utils/local-marketplace.js +307 -84
  388. package/dist/src/utils/local-marketplace.js.map +1 -1
  389. package/dist/src/utils/manifest.d.ts +1 -4
  390. package/dist/src/utils/manifest.js +1 -4
  391. package/dist/src/utils/manifest.js.map +1 -1
  392. package/dist/src/utils/multi-source-catalog.d.ts +3 -9
  393. package/dist/src/utils/multi-source-catalog.js +54 -110
  394. package/dist/src/utils/multi-source-catalog.js.map +1 -1
  395. package/dist/src/utils/native-cli.d.ts +55 -7
  396. package/dist/src/utils/native-cli.js +386 -57
  397. package/dist/src/utils/native-cli.js.map +1 -1
  398. package/dist/src/utils/orphan-marketplace-cleanup.js +0 -4
  399. package/dist/src/utils/orphan-marketplace-cleanup.js.map +1 -1
  400. package/dist/src/utils/ownership.d.ts +84 -20
  401. package/dist/src/utils/ownership.js +179 -222
  402. package/dist/src/utils/ownership.js.map +1 -1
  403. package/dist/src/utils/path-catalog-provider.d.ts +1 -1
  404. package/dist/src/utils/path-catalog-provider.js +54 -65
  405. package/dist/src/utils/path-catalog-provider.js.map +1 -1
  406. package/dist/src/utils/paths.d.ts +0 -1
  407. package/dist/src/utils/paths.js +0 -1
  408. package/dist/src/utils/paths.js.map +1 -1
  409. package/dist/src/utils/plugin-config-impact.d.ts +33 -0
  410. package/dist/src/utils/plugin-config-impact.js +298 -0
  411. package/dist/src/utils/plugin-config-impact.js.map +1 -0
  412. package/dist/src/utils/plugin-config-write.d.ts +52 -27
  413. package/dist/src/utils/plugin-config-write.js +990 -298
  414. package/dist/src/utils/plugin-config-write.js.map +1 -1
  415. package/dist/src/utils/plugin-config.d.ts +140 -93
  416. package/dist/src/utils/plugin-config.js +992 -980
  417. package/dist/src/utils/plugin-config.js.map +1 -1
  418. package/dist/src/utils/plugin-intent-state.d.ts +49 -0
  419. package/dist/src/utils/plugin-intent-state.js +320 -0
  420. package/dist/src/utils/plugin-intent-state.js.map +1 -0
  421. package/dist/src/utils/plugin-scripts.d.ts +62 -125
  422. package/dist/src/utils/plugin-scripts.js +468 -525
  423. package/dist/src/utils/plugin-scripts.js.map +1 -1
  424. package/dist/src/utils/process-tree.d.ts +2 -2
  425. package/dist/src/utils/process-tree.js +1 -1
  426. package/dist/src/utils/process-tree.js.map +1 -1
  427. package/dist/src/utils/project-boundary.d.ts +11 -13
  428. package/dist/src/utils/project-boundary.js +28 -34
  429. package/dist/src/utils/project-boundary.js.map +1 -1
  430. package/dist/src/utils/safe-fs.d.ts +21 -0
  431. package/dist/src/utils/safe-fs.js +111 -0
  432. package/dist/src/utils/safe-fs.js.map +1 -0
  433. package/dist/src/utils/safe-operation-diagnostic.d.ts +15 -0
  434. package/dist/src/utils/safe-operation-diagnostic.js +33 -0
  435. package/dist/src/utils/safe-operation-diagnostic.js.map +1 -0
  436. package/dist/src/utils/sensitive-content.d.ts +4 -0
  437. package/dist/src/utils/sensitive-content.js +36 -0
  438. package/dist/src/utils/sensitive-content.js.map +1 -0
  439. package/dist/src/utils/skill-validation.d.ts +1 -1
  440. package/dist/src/utils/skill-validation.js +1 -1
  441. package/dist/src/utils/skill-validation.js.map +1 -1
  442. package/dist/src/utils/state-paths.d.ts +1 -0
  443. package/dist/src/utils/state-paths.js +12 -2
  444. package/dist/src/utils/state-paths.js.map +1 -1
  445. package/dist/src/utils/target-eligibility.d.ts +8 -2
  446. package/dist/src/utils/target-eligibility.js +17 -8
  447. package/dist/src/utils/target-eligibility.js.map +1 -1
  448. package/dist/src/utils/windows-claude-shim.d.ts +9 -0
  449. package/dist/src/utils/windows-claude-shim.js +141 -0
  450. package/dist/src/utils/windows-claude-shim.js.map +1 -0
  451. package/dist/vitest.config.js +91 -10
  452. package/dist/vitest.config.js.map +1 -1
  453. package/package.json +22 -19
  454. package/dist/authoring/scripts/check-plugin-versions.mjs +0 -5
  455. package/dist/authoring/scripts/check-plugin-versions.mjs.map +0 -1
  456. package/dist/scripts/aw-skill-eval-engine.d.ts +0 -13
  457. package/dist/scripts/aw-skill-eval-engine.js +0 -31
  458. package/dist/scripts/aw-skill-eval-engine.js.map +0 -1
  459. package/dist/scripts/codex-eval-app-server.d.ts +0 -89
  460. package/dist/scripts/codex-eval-app-server.js +0 -1228
  461. package/dist/scripts/codex-eval-app-server.js.map +0 -1
  462. package/dist/scripts/codex-eval-isolation.d.ts +0 -61
  463. package/dist/scripts/codex-eval-isolation.js +0 -318
  464. package/dist/scripts/codex-eval-isolation.js.map +0 -1
  465. package/dist/scripts/codex-eval-process-management.d.ts +0 -8
  466. package/dist/scripts/codex-eval-process-management.js +0 -69
  467. package/dist/scripts/codex-eval-process-management.js.map +0 -1
  468. package/dist/scripts/codex-eval-process-tree.d.ts +0 -38
  469. package/dist/scripts/codex-eval-process-tree.js +0 -803
  470. package/dist/scripts/codex-eval-process-tree.js.map +0 -1
  471. package/dist/scripts/codex-eval-runtime-config.d.ts +0 -62
  472. package/dist/scripts/codex-eval-runtime-config.js +0 -843
  473. package/dist/scripts/codex-eval-runtime-config.js.map +0 -1
  474. package/dist/scripts/codex-trigger-eval.d.ts +0 -84
  475. package/dist/scripts/codex-trigger-eval.js +0 -968
  476. package/dist/scripts/codex-trigger-eval.js.map +0 -1
  477. package/dist/scripts/eval-plugin-skills-audited.d.ts +0 -6
  478. package/dist/scripts/eval-plugin-skills-audited.js +0 -261
  479. package/dist/scripts/eval-plugin-skills-audited.js.map +0 -1
  480. package/dist/scripts/eval-plugin-skills.d.ts +0 -45
  481. package/dist/scripts/eval-plugin-skills.js +0 -1586
  482. package/dist/scripts/eval-plugin-skills.js.map +0 -1
  483. package/dist/scripts/eval-run-layout.d.ts +0 -17
  484. package/dist/scripts/eval-run-layout.js +0 -26
  485. package/dist/scripts/eval-run-layout.js.map +0 -1
  486. package/dist/scripts/plugin-eval-contract.d.ts +0 -185
  487. package/dist/scripts/plugin-eval-contract.js +0 -695
  488. package/dist/scripts/plugin-eval-contract.js.map +0 -1
  489. package/dist/scripts/plugin-eval-materializer.d.ts +0 -13
  490. package/dist/scripts/plugin-eval-materializer.js +0 -421
  491. package/dist/scripts/plugin-eval-materializer.js.map +0 -1
  492. package/dist/scripts/skill-reporting.d.ts +0 -212
  493. package/dist/scripts/skill-reporting.js +0 -922
  494. package/dist/scripts/skill-reporting.js.map +0 -1
  495. package/dist/src/commands/status-v4.d.ts +0 -102
  496. package/dist/src/commands/status-v4.js +0 -844
  497. package/dist/src/commands/status-v4.js.map +0 -1
  498. package/dist/src/commands/status.d.ts +0 -93
  499. package/dist/src/commands/status.js +0 -442
  500. package/dist/src/commands/status.js.map +0 -1
  501. package/dist/src/utils/active-marketplace-runtime-lock.d.ts +0 -12
  502. package/dist/src/utils/active-marketplace-runtime-lock.js +0 -133
  503. package/dist/src/utils/active-marketplace-runtime-lock.js.map +0 -1
  504. package/dist/src/utils/catalog-manifest-v3.d.ts +0 -2
  505. package/dist/src/utils/catalog-manifest-v3.js +0 -3
  506. package/dist/src/utils/catalog-manifest-v3.js.map +0 -1
  507. package/dist/src/utils/catalog-manifest-v4.d.ts +0 -5
  508. package/dist/src/utils/catalog-manifest-v4.js.map +0 -1
  509. package/dist/src/utils/catalog-source-cache.d.ts +0 -61
  510. package/dist/src/utils/catalog-source-cache.js +0 -276
  511. package/dist/src/utils/catalog-source-cache.js.map +0 -1
  512. package/dist/src/utils/codex-project-surface.d.ts +0 -3
  513. package/dist/src/utils/codex-project-surface.js +0 -49
  514. package/dist/src/utils/codex-project-surface.js.map +0 -1
  515. package/dist/src/utils/lifecycle-active-store.d.ts +0 -175
  516. package/dist/src/utils/lifecycle-active-store.js +0 -1276
  517. package/dist/src/utils/lifecycle-active-store.js.map +0 -1
  518. package/dist/src/utils/plugin-authoring-capabilities.d.ts +0 -23
  519. package/dist/src/utils/plugin-authoring-capabilities.js +0 -37
  520. package/dist/src/utils/plugin-authoring-capabilities.js.map +0 -1
  521. package/dist/src/utils/plugin-authoring-capabilities.json +0 -92
  522. package/dist/src/utils/plugin-release.d.ts +0 -2
  523. package/dist/src/utils/plugin-release.js +0 -2
  524. package/dist/src/utils/plugin-release.js.map +0 -1
  525. package/dist/src/utils/skill-frontmatter-capabilities.d.ts +0 -201
  526. package/dist/src/utils/skill-frontmatter-capabilities.js +0 -5
  527. package/dist/src/utils/skill-frontmatter-capabilities.js.map +0 -1
  528. package/dist/src/utils/skill-frontmatter-capabilities.json +0 -200
  529. /package/dist/authoring/scripts/{check-plugin-versions.d.mts → remove-plugin.d.mts} +0 -0
@@ -1,16 +1,74 @@
1
- import path from 'node:path';
2
- import { discoverRebuildTargetNames, inspectRebuildTarget, } from '../commands/rebuild-integration.js';
3
- import { reinstallWriteCommand } from '../commands/write-commands.js';
4
- import { createNoopDebugLogger } from '../output/debug-log.js';
5
- import { createNoopReporter } from '../output/reporter.js';
1
+ import { flattenStatusTargets, statusCommandV8, statusTargetIntent, } from '../commands/status-v6.js';
2
+ import { syncWriteCommand } from '../commands/write-commands.js';
3
+ import { CONFIG_MUTATION_RECEIPT_SCHEMA_VERSION, } from '../types.js';
6
4
  import { getDefaultNativeCliRunner } from './native-cli.js';
7
- import { resolveAwHome } from './paths.js';
8
- import { hasCodexProjectManagedArtifacts } from './codex-project-surface.js';
9
- import { assertSafePluginConfigSegment, coercePluginConfigUpdates, collectProjectArtifactConfigBoundaryIssues, patchPluginConfigStore, readPluginConfigStore, resetPluginConfigStore, resolveConfigRead, resolveEffectivePluginConfig, resolvePluginConfigSchemaAccess, summarizeEffectivePluginConfig, withPluginConfigTransactionLease, } from './plugin-config.js';
10
- import { assertProjectSharedConfigPathVisible, ensureProjectPrivateStateIgnore, } from './project-boundary.js';
5
+ import { assertReadyPluginConfigStore, assertSafePluginConfigSegment, codexNativeRefreshKeys, coercePluginConfigUpdates, patchPluginConfigStore, readPluginConfigStore, readNamespacedPluginConfigStoreIdentity, resetPluginConfigStore, resolveConfigRead, resolveEffectivePluginConfig, resolvePluginConfigStorePath, resolvePluginConfigSchemaAccess, summarizeEffectivePluginConfig, } from './plugin-config.js';
6
+ import { analyzePluginConfigMutationImpact } from './plugin-config-impact.js';
7
+ import { collectSensitivePluginConfigValues, redactPluginScriptOutput, } from './plugin-scripts.js';
11
8
  import { resolveClaudeProjectKey, resolveCodexProjectKey } from './paths.js';
12
- import { supportsPlatform } from './platform-support.js';
13
9
  import { withAwHomeMutationLock, } from './aw-home-mutation-lock.js';
10
+ import { assertProjectSharedConfigPathVisible, } from './project-boundary.js';
11
+ export function buildConfigMutationReceipt(command, receipt) {
12
+ return {
13
+ ...receipt,
14
+ receiptSchemaVersion: CONFIG_MUTATION_RECEIPT_SCHEMA_VERSION,
15
+ command,
16
+ };
17
+ }
18
+ function publicConfigApplyTargetResult(result) {
19
+ return {
20
+ target: {
21
+ pluginName: result.target.pluginName,
22
+ ...(result.target.pluginId ? { pluginId: result.target.pluginId } : {}),
23
+ platform: result.target.platform,
24
+ scope: result.target.scope,
25
+ },
26
+ action: result.action,
27
+ state: result.state,
28
+ ...(result.message ? { message: result.message } : {}),
29
+ ...(result.errorCode ? { errorCode: result.errorCode } : {}),
30
+ ...(result.relation ? { relation: result.relation } : {}),
31
+ ...(result.requiredBy ? { requiredBy: result.requiredBy } : {}),
32
+ };
33
+ }
34
+ function publicConfigApplyResult(apply) {
35
+ if (apply.state === 'skipped')
36
+ return apply;
37
+ return {
38
+ ...apply,
39
+ targetResults: apply.targetResults.map(publicConfigApplyTargetResult),
40
+ };
41
+ }
42
+ export function configWriteStateForError(error) {
43
+ return error?.configWrite === 'failed'
44
+ ? 'failed'
45
+ : 'notStarted';
46
+ }
47
+ function markConfigWriteFailed(error) {
48
+ const failure = error instanceof Error ? error : new Error(String(error));
49
+ return Object.assign(failure, { configWrite: 'failed' });
50
+ }
51
+ function skippedApply(reason) {
52
+ return { state: 'skipped', reason, targetResults: [] };
53
+ }
54
+ function unavailableApply(reason, stage, targetResults = []) {
55
+ const messages = {
56
+ invalidConfig: 'The effective config is invalid for every visible target.',
57
+ schemaUnavailable: 'The config schema is unavailable after the config commit.',
58
+ sourceUnavailable: 'The plugin source is unavailable after the config commit.',
59
+ effectiveConfigUnavailable: 'The effective config cannot be read after the config commit.',
60
+ targetDiscoveryFailed: 'Visible config apply targets cannot be discovered after the config commit.',
61
+ };
62
+ return {
63
+ state: 'unavailable',
64
+ reason,
65
+ targetResults,
66
+ error: { stage, code: reason, message: messages[reason] },
67
+ };
68
+ }
69
+ function overallStateForApply(apply) {
70
+ return apply.state === 'succeeded' || apply.state === 'skipped' ? 'succeeded' : 'partial';
71
+ }
14
72
  function uniqueInOrder(values) {
15
73
  return [...new Set(values)];
16
74
  }
@@ -44,97 +102,38 @@ async function createCandidateTarget(options) {
44
102
  async function discoverVisibleTargets(options) {
45
103
  const targets = [];
46
104
  const failures = [];
47
- const namedTargets = [];
48
- const scopes = options.scope === 'user' ? ['user', 'project'] : ['project'];
49
- for (const platform of ['codex', 'claude']) {
50
- for (const scope of scopes) {
51
- if (!supportsPlatform(options.plugin.manifest, platform))
52
- continue;
53
- if (platform === 'codex'
54
- && scope === 'project'
55
- && !hasCodexProjectManagedArtifacts(options.plugin))
105
+ const selector = options.plugin.pluginId ?? options.pluginName;
106
+ const status = await statusCommandV8({
107
+ plugins: [selector],
108
+ cwd: options.cwd,
109
+ env: options.env,
110
+ nativeCliRunner: options.nativeCliRunner,
111
+ ...(options.scope === 'project' ? { scope: 'project' } : {}),
112
+ ...(options.rebuildRuntime?.catalogOperationContext
113
+ ? { catalogOperationContext: options.rebuildRuntime.catalogOperationContext }
114
+ : {}),
115
+ });
116
+ for (const statusTarget of flattenStatusTargets(status.payload.targets)) {
117
+ const intent = statusTargetIntent(statusTarget);
118
+ if ((statusTarget.pluginId !== selector && statusTarget.pluginName !== options.pluginName)
119
+ || !intent.enabled)
120
+ continue;
121
+ for (const scope of intent.scopes) {
122
+ if (options.scope === 'project' && scope !== 'project')
56
123
  continue;
57
- const target = await createCandidateTarget({
124
+ targets.push(await createCandidateTarget({
58
125
  pluginName: options.pluginName,
59
- platform,
126
+ platform: statusTarget.platform,
60
127
  scope,
61
128
  cwd: options.cwd,
62
- });
63
- try {
64
- const names = await discoverRebuildTargetNames({
65
- cwd: options.cwd,
66
- env: options.env,
67
- platform,
68
- scope,
69
- nativeCliRunner: options.nativeCliRunner,
70
- nativeFailureMode: 'ignore',
71
- marketplaceName: options.plugin.marketplaceName,
72
- marketplaceRoot: options.plugin.sourceId
73
- ? path.join(resolveAwHome(options.env), 'marketplaces', options.plugin.sourceId)
74
- : undefined,
75
- });
76
- if (!names.includes(options.pluginName))
77
- continue;
78
- namedTargets.push(target);
79
- }
80
- catch (error) {
81
- failures.push({
82
- target,
83
- action: 'reinstall',
84
- state: 'failed',
85
- message: error instanceof Error ? error.message : String(error),
86
- });
87
- }
88
- }
89
- }
90
- if (namedTargets.length === 0)
91
- return { targets, failures };
92
- const catalog = options.rebuildRuntime?.catalogResolution ?? {
93
- rootDir: options.plugin.sourceId
94
- ? path.resolve(options.plugin.rootDir, '..', '..')
95
- : options.plugin.rootDir,
96
- source: 'local',
97
- };
98
- for (const target of namedTargets) {
99
- try {
100
- const inspected = await inspectRebuildTarget({
101
- sourceId: options.plugin.sourceId,
102
- sourceIdentity: options.plugin.sourceIdentity,
103
- pluginId: options.plugin.pluginId,
104
- marketplaceName: options.plugin.marketplaceName,
105
- marketplaceRoot: options.plugin.sourceId
106
- ? path.join(resolveAwHome(options.env), 'marketplaces', options.plugin.sourceId)
107
- : undefined,
108
- plugin: options.plugin,
109
- platform: target.platform,
110
- scope: target.scope,
111
- cwd: options.cwd,
112
- catalog,
113
- context: {
114
- env: options.env,
115
- nativeCliRunner: options.nativeCliRunner,
116
- reporter: options.rebuildRuntime?.reporter ?? createNoopReporter(),
117
- debugLogger: options.rebuildRuntime?.debugLogger ?? createNoopDebugLogger(),
118
- },
119
- });
120
- if (inspected.inspection.state === 'present' || inspected.inspection.state === 'partial') {
121
- targets.push(target);
122
- }
123
- }
124
- catch (error) {
125
- failures.push({
126
- target,
127
- action: 'reinstall',
128
- state: 'failed',
129
- message: error instanceof Error ? error.message : String(error),
130
- });
129
+ }));
131
130
  }
132
131
  }
133
132
  return { targets: dedupeTargets(targets), failures };
134
133
  }
135
134
  async function reinstallVisibleTargets(options) {
136
135
  const nativeCliRunner = options.nativeCliRunner ?? getDefaultNativeCliRunner();
137
- const discovered = options.applyTargets === undefined
136
+ const discovered = options.discovered ?? (options.applyTargets === undefined
138
137
  ? await discoverVisibleTargets({
139
138
  pluginName: options.plugin.manifest.name,
140
139
  plugin: options.plugin,
@@ -144,54 +143,361 @@ async function reinstallVisibleTargets(options) {
144
143
  nativeCliRunner,
145
144
  rebuildRuntime: options.rebuildRuntime,
146
145
  })
147
- : { targets: dedupeTargets(options.applyTargets), failures: [] };
146
+ : { targets: dedupeTargets(options.applyTargets), failures: [] });
148
147
  const targetResults = [...discovered.failures];
149
148
  let runtimeFailed = discovered.failures.length > 0;
150
- const reinstall = options.reinstallCommandImpl ?? reinstallWriteCommand;
149
+ let invalidTargets = 0;
150
+ let unavailableTargets = 0;
151
+ const errors = [];
152
+ const reinstall = options.reinstallCommandImpl ?? syncWriteCommand;
151
153
  if (options.plugin.sourceId && !options.plugin.pluginId) {
152
154
  throw new Error(`Plugin "${options.plugin.manifest.name}" is missing its namespaced plugin ID.`);
153
155
  }
154
156
  const selector = options.plugin.sourceId
155
157
  ? options.plugin.pluginId
156
158
  : options.plugin.manifest.name;
159
+ const sanitizeFailure = async (message, target) => {
160
+ let sensitiveValues = [];
161
+ try {
162
+ const effective = await resolveEffectivePluginConfig({
163
+ ...(options.plugin.sourceId ? {
164
+ sourceId: options.plugin.sourceId,
165
+ sourceIdentity: options.plugin.sourceIdentity,
166
+ logicalIdentity: options.plugin.catalogLogicalIdentity,
167
+ } : {}),
168
+ pluginName: options.plugin.manifest.name,
169
+ manifest: options.plugin.manifest,
170
+ targetScope: target.scope,
171
+ cwd: options.cwd,
172
+ env: options.env,
173
+ });
174
+ sensitiveValues = collectSensitivePluginConfigValues(options.plugin.manifest, effective.values);
175
+ }
176
+ catch {
177
+ // Generic credential redaction and known config paths still apply.
178
+ }
179
+ let sanitized = redactPluginScriptOutput(message, sensitiveValues);
180
+ for (const privatePath of [target.projectKey, options.cwd]) {
181
+ if (privatePath)
182
+ sanitized = sanitized.split(privatePath).join('<project>');
183
+ }
184
+ for (const scope of ['user', 'project']) {
185
+ const configPath = resolvePluginConfigStorePath({
186
+ sourceId: options.plugin.sourceId,
187
+ pluginName: options.plugin.manifest.name,
188
+ scope,
189
+ cwd: options.cwd,
190
+ env: options.env,
191
+ });
192
+ const safeTarget = `${scope}/plugin-config/${[
193
+ options.plugin.sourceId,
194
+ options.plugin.manifest.name,
195
+ 'config.json',
196
+ ].filter(Boolean).join('/')}`;
197
+ sanitized = sanitized.split(configPath).join(safeTarget);
198
+ }
199
+ return sanitized;
200
+ };
201
+ const sanitizeProjection = async (value, target, freeText = false) => {
202
+ if (typeof value === 'string')
203
+ return freeText ? sanitizeFailure(value, target) : value;
204
+ if (value === null || typeof value !== 'object')
205
+ return value;
206
+ if (Array.isArray(value)) {
207
+ return Promise.all(value.map((entry) => sanitizeProjection(entry, target, freeText)));
208
+ }
209
+ return Object.fromEntries(await Promise.all(Object.entries(value).map(async ([key, entry]) => [
210
+ key,
211
+ await sanitizeProjection(entry, target, typeof entry === 'string'
212
+ ? /^(?:message|error|stack|stdout|stderr|output|warning)$/u.test(key)
213
+ : Array.isArray(entry) && /^(?:messages|warnings)$/u.test(key)),
214
+ ])));
215
+ };
216
+ const preApplyExecutionCache = new Map();
157
217
  for (const target of discovered.targets) {
158
218
  try {
219
+ const effective = await resolveEffectivePluginConfig({
220
+ ...(options.plugin.sourceId ? {
221
+ sourceId: options.plugin.sourceId,
222
+ sourceIdentity: options.plugin.sourceIdentity,
223
+ logicalIdentity: options.plugin.catalogLogicalIdentity,
224
+ } : {}),
225
+ pluginName: options.plugin.manifest.name,
226
+ manifest: options.plugin.manifest,
227
+ targetScope: target.scope,
228
+ cwd: options.cwd,
229
+ env: options.env,
230
+ });
231
+ if (effective.issues.length > 0) {
232
+ invalidTargets += 1;
233
+ targetResults.push({
234
+ target,
235
+ action: 'reinstall',
236
+ state: 'skipped',
237
+ errorCode: 'invalidConfig',
238
+ message: 'The effective config is invalid for this target.',
239
+ });
240
+ continue;
241
+ }
242
+ }
243
+ catch {
244
+ runtimeFailed = true;
245
+ unavailableTargets += 1;
246
+ targetResults.push({
247
+ target,
248
+ action: 'reinstall',
249
+ state: 'failed',
250
+ errorCode: 'effectiveConfigUnavailable',
251
+ message: 'The effective config cannot be read for this target.',
252
+ });
253
+ errors.push({
254
+ stage: 'targetValidation',
255
+ code: 'effectiveConfigUnavailable',
256
+ message: 'The effective config cannot be read for a visible target.',
257
+ });
258
+ continue;
259
+ }
260
+ try {
261
+ const debugLogger = options.rebuildRuntime?.debugLogger;
262
+ const reporter = options.rebuildRuntime?.reporter;
159
263
  const result = await reinstall([selector], {
160
264
  cwd: options.cwd,
161
265
  platform: target.platform,
162
266
  scope: target.scope,
267
+ ...(options.rebuildRuntime?.scriptTimeoutMs === undefined
268
+ ? {}
269
+ : { scriptTimeoutMs: options.rebuildRuntime.scriptTimeoutMs }),
163
270
  }, {
164
271
  ...options.rebuildRuntime,
165
272
  env: options.env,
166
273
  nativeCliRunner,
274
+ preApplyConfirmed: options.preApplyConfirmed === true,
275
+ preApplyExecutionCache,
276
+ ...(debugLogger ? {
277
+ debugLogger: {
278
+ ...debugLogger,
279
+ log: async (value) => debugLogger.log(await sanitizeProjection(value, target)),
280
+ },
281
+ } : {}),
282
+ ...(reporter ? {
283
+ reporter: {
284
+ event: async (value) => reporter.event(await sanitizeProjection(value, target)),
285
+ notice: async (value) => reporter.notice(await sanitizeProjection(value, target)),
286
+ },
287
+ } : {}),
167
288
  });
168
- if (result.overallState === 'failed')
289
+ options.rebuildRuntime?.operationDiagnosticSink?.(result.rebuildResults);
290
+ if (result.overallState !== 'succeeded')
169
291
  runtimeFailed = true;
170
- targetResults.push(...result.targetResults);
292
+ targetResults.push(...await Promise.all(result.targetResults.map(async (entry) => ({
293
+ ...entry,
294
+ state: entry.action === 'skipped' ? 'skipped' : entry.state,
295
+ ...(entry.message ? { message: await sanitizeFailure(entry.message, entry.target) } : {}),
296
+ }))));
171
297
  }
172
298
  catch (error) {
173
299
  runtimeFailed = true;
300
+ const message = await sanitizeFailure(error instanceof Error ? error.message : String(error), target);
174
301
  targetResults.push({
175
302
  target,
176
303
  action: 'reinstall',
177
304
  state: 'failed',
178
- message: error instanceof Error ? error.message : String(error),
305
+ message,
306
+ });
307
+ errors.push({
308
+ stage: 'apply',
309
+ code: 'targetApplyFailed',
310
+ message: 'A visible config apply target failed.',
311
+ });
312
+ }
313
+ }
314
+ if (discovered.targets.length === 0 && discovered.failures.length === 0) {
315
+ return skippedApply('noVisibleTarget');
316
+ }
317
+ if (discovered.targets.length > 0 && invalidTargets === discovered.targets.length) {
318
+ return unavailableApply('invalidConfig', 'targetValidation', targetResults);
319
+ }
320
+ if (discovered.targets.length > 0 && unavailableTargets === discovered.targets.length) {
321
+ return unavailableApply('effectiveConfigUnavailable', 'targetValidation', targetResults);
322
+ }
323
+ if (runtimeFailed
324
+ || invalidTargets > 0
325
+ || unavailableTargets > 0
326
+ || targetResults.some((entry) => entry.state === 'failed' || entry.state === 'skipped')) {
327
+ return {
328
+ state: 'partial',
329
+ targetResults,
330
+ ...(errors.length > 0 ? { errors } : {}),
331
+ };
332
+ }
333
+ return { state: 'succeeded', targetResults };
334
+ }
335
+ async function resolveConfigApplyTargets(options) {
336
+ if (options.applyTargets !== undefined) {
337
+ return { targets: dedupeTargets(options.applyTargets), failures: [] };
338
+ }
339
+ return discoverVisibleTargets({
340
+ pluginName: options.plugin.manifest.name,
341
+ plugin: options.plugin,
342
+ scope: options.scope,
343
+ cwd: options.cwd,
344
+ env: options.env,
345
+ nativeCliRunner: options.nativeCliRunner ?? getDefaultNativeCliRunner(),
346
+ rebuildRuntime: options.rebuildRuntime,
347
+ });
348
+ }
349
+ async function configApplyHasValidCodexTarget(options) {
350
+ const codexScopes = new Set(options.targets
351
+ .filter((target) => target.platform === 'codex')
352
+ .map((target) => target.scope));
353
+ for (const scope of codexScopes) {
354
+ const effective = await resolveEffectivePluginConfig({
355
+ ...(options.plugin.sourceId ? {
356
+ sourceId: options.plugin.sourceId,
357
+ sourceIdentity: options.plugin.sourceIdentity,
358
+ logicalIdentity: options.plugin.catalogLogicalIdentity,
359
+ } : {}),
360
+ pluginName: options.plugin.manifest.name,
361
+ manifest: options.plugin.manifest,
362
+ targetScope: scope,
363
+ cwd: options.cwd,
364
+ env: options.env,
365
+ });
366
+ if (effective.issues.length === 0)
367
+ return true;
368
+ }
369
+ return false;
370
+ }
371
+ async function applyConfigToVisibleTargets(options) {
372
+ let discovered;
373
+ if (options.discovered) {
374
+ discovered = options.discovered;
375
+ }
376
+ else {
377
+ try {
378
+ discovered = await resolveConfigApplyTargets(options);
379
+ }
380
+ catch {
381
+ return unavailableApply('targetDiscoveryFailed', 'targetDiscovery');
382
+ }
383
+ }
384
+ if (discovered.targets.length === 0
385
+ && discovered.failures.length === 0
386
+ && options.noVisibleTargetHasInvalidConfig) {
387
+ return unavailableApply('invalidConfig', 'targetValidation');
388
+ }
389
+ return reinstallVisibleTargets({ ...options, discovered });
390
+ }
391
+ export async function resolveConfigPreApplyAuthorization(options) {
392
+ const applyTargets = dedupeTargets(options.applyTargets);
393
+ if (applyTargets.length === 0 || !pluginMayRunPreApply(options.plugin)) {
394
+ return { targets: [], availableApplyTargets: applyTargets, unavailableTargetResults: [] };
395
+ }
396
+ if (options.plugin.sourceId && !options.plugin.pluginId) {
397
+ return {
398
+ targets: [],
399
+ availableApplyTargets: [],
400
+ unavailableTargetResults: applyTargets.map((target) => ({
401
+ target,
402
+ action: 'reinstall',
403
+ state: 'failed',
404
+ errorCode: 'sourceUnavailable',
405
+ message: 'The preApply authorization scope cannot be resolved for this target.',
406
+ })),
407
+ };
408
+ }
409
+ const selector = options.plugin.sourceId
410
+ ? options.plugin.pluginId
411
+ : options.plugin.manifest.name;
412
+ const groups = new Map();
413
+ for (const target of applyTargets) {
414
+ const targets = groups.get(target.scope) ?? [];
415
+ targets.push(target);
416
+ groups.set(target.scope, targets);
417
+ }
418
+ const authorization = [];
419
+ const availableApplyTargets = [];
420
+ const unavailableTargetResults = [];
421
+ const resolveGroup = async (targets) => {
422
+ const platforms = new Set(targets.map((target) => target.platform));
423
+ const platform = platforms.size === 2 ? 'both' : [...platforms][0];
424
+ try {
425
+ const preview = await (options.reinstallCommandImpl ?? syncWriteCommand)([selector], {
426
+ cwd: options.cwd,
427
+ platform,
428
+ scope: targets[0].scope,
429
+ }, {
430
+ ...options.rebuildRuntime,
431
+ env: options.env ?? process.env,
432
+ nativeCliRunner: options.nativeCliRunner,
433
+ resolvePreApplyAuthorization: true,
434
+ });
435
+ if (preview.overallState !== 'succeeded' || !preview.preApplyAuthorization)
436
+ return false;
437
+ authorization.push(...preview.preApplyAuthorization);
438
+ availableApplyTargets.push(...targets);
439
+ return true;
440
+ }
441
+ catch {
442
+ return false;
443
+ }
444
+ };
445
+ for (const targets of groups.values()) {
446
+ if (await resolveGroup(targets))
447
+ continue;
448
+ for (const target of targets) {
449
+ if (targets.length > 1 && await resolveGroup([target]))
450
+ continue;
451
+ unavailableTargetResults.push({
452
+ target,
453
+ action: 'reinstall',
454
+ state: 'failed',
455
+ errorCode: 'sourceUnavailable',
456
+ message: 'The preApply authorization scope cannot be resolved for this target.',
179
457
  });
180
458
  }
181
459
  }
182
- const overallState = runtimeFailed || targetResults.some((entry) => entry.state === 'failed')
183
- ? 'failed' : 'succeeded';
184
460
  return {
185
- overallState,
186
- targetResults,
187
- ...(discovered.targets.length === 0 && discovered.failures.length === 0
188
- ? { applySkippedReason: 'noVisibleTarget' }
189
- : {}),
461
+ targets: [...new Map(authorization.map((target) => [[
462
+ target.pluginId,
463
+ target.platform,
464
+ target.scope,
465
+ ].join('\0'), target])).values()],
466
+ availableApplyTargets: dedupeTargets(availableApplyTargets),
467
+ unavailableTargetResults,
190
468
  };
191
469
  }
470
+ function pluginMayRunPreApply(plugin) {
471
+ return plugin.manifest.scripts?.preApply !== undefined
472
+ || (plugin.manifest.dependencies?.length ?? 0) > 0;
473
+ }
474
+ function throwPreApplyAuthorizationRequired(targets) {
475
+ const plugins = [...new Set(targets.map((target) => target.pluginId))].join(', ');
476
+ const error = new Error(`preApplyAuthorizationRequired: Applying this config runs plugin preApply for ${plugins}. Re-run with --yes.`);
477
+ error.code = 'preApplyAuthorizationRequired';
478
+ throw error;
479
+ }
480
+ function preApplyAuthorizationIsConfirmed(options) {
481
+ if (options.confirmed !== true)
482
+ return false;
483
+ if (options.authorizedTargets === undefined)
484
+ return true;
485
+ const authorized = new Set(options.authorizedTargets.map((target) => [
486
+ target.pluginId,
487
+ target.sourceIdentity,
488
+ target.platform,
489
+ target.scope,
490
+ ].join('\0')));
491
+ return options.required.every((target) => authorized.has([
492
+ target.pluginId,
493
+ target.sourceIdentity,
494
+ target.platform,
495
+ target.scope,
496
+ ].join('\0')));
497
+ }
192
498
  function otherProjectsWarning(scope) {
193
499
  return scope === 'user'
194
- ? ['其它项目不会由本次命令扫描或更新。请在每个项目目录中运行对应的 aw reinstall 命令。']
500
+ ? ['其它项目不会由本次命令扫描或更新,可能需要在对应项目目录中运行 aw sync。']
195
501
  : [];
196
502
  }
197
503
  function buildReceiptFieldEntry(options) {
@@ -202,7 +508,6 @@ function buildReceiptFieldEntry(options) {
202
508
  reserved: options.reserved,
203
509
  action: options.action,
204
510
  scope: options.scope,
205
- ...(options.scope === 'project' ? { projectLayer: options.projectLayer } : {}),
206
511
  ...(options.valueState ? { valueState: options.valueState } : {}),
207
512
  };
208
513
  }
@@ -211,26 +516,123 @@ export async function replayConfigRuntimeWrites(options) {
211
516
  env: options.env,
212
517
  token: options.awHomeMutationToken,
213
518
  action: async (awHomeMutationToken) => {
214
- const applied = await reinstallVisibleTargets({
519
+ const env = options.env ?? process.env;
520
+ const rebuildRuntime = { ...options.rebuildRuntime, awHomeMutationToken };
521
+ let discovered;
522
+ try {
523
+ discovered = await resolveConfigApplyTargets({
524
+ plugin: options.plugin,
525
+ scope: options.scope,
526
+ cwd: options.cwd,
527
+ env,
528
+ applyTargets: options.applyTargets,
529
+ nativeCliRunner: options.nativeCliRunner,
530
+ rebuildRuntime,
531
+ });
532
+ }
533
+ catch {
534
+ const apply = unavailableApply('targetDiscoveryFailed', 'targetDiscovery');
535
+ return {
536
+ configWrite: 'succeeded',
537
+ overallState: 'partial',
538
+ apply: publicConfigApplyResult(apply),
539
+ otherProjectsMayRequireSync: false,
540
+ };
541
+ }
542
+ const preApplyAuthorization = await resolveConfigPreApplyAuthorization({
215
543
  plugin: options.plugin,
216
544
  scope: options.scope,
217
545
  cwd: options.cwd,
218
- env: options.env ?? process.env,
546
+ env,
547
+ applyTargets: discovered.targets,
548
+ nativeCliRunner: options.nativeCliRunner,
549
+ rebuildRuntime,
550
+ reinstallCommandImpl: options.reinstallCommandImpl,
551
+ });
552
+ if (preApplyAuthorization.targets.length > 0 && !preApplyAuthorizationIsConfirmed({
553
+ required: preApplyAuthorization.targets,
554
+ confirmed: options.preApplyConfirmed,
555
+ authorizedTargets: options.preApplyAuthorizedTargets,
556
+ })) {
557
+ const apply = {
558
+ state: 'partial',
559
+ targetResults: preApplyAuthorization.targets.map((target) => ({
560
+ target: {
561
+ pluginName: target.pluginName,
562
+ pluginId: target.pluginId,
563
+ platform: target.platform,
564
+ scope: target.scope,
565
+ },
566
+ action: 'reinstall',
567
+ state: 'failed',
568
+ errorCode: 'preApplyAuthorizationRequired',
569
+ message: 'Running plugin preApply requires explicit authorization.',
570
+ })),
571
+ };
572
+ return {
573
+ configWrite: 'succeeded',
574
+ overallState: 'partial',
575
+ apply: publicConfigApplyResult(apply),
576
+ otherProjectsMayRequireSync: false,
577
+ };
578
+ }
579
+ discovered = {
580
+ targets: preApplyAuthorization.availableApplyTargets,
581
+ failures: [...discovered.failures, ...preApplyAuthorization.unavailableTargetResults],
582
+ };
583
+ if (discovered.targets.length === 0
584
+ && preApplyAuthorization.unavailableTargetResults.length > 0) {
585
+ const apply = unavailableApply('sourceUnavailable', 'source', preApplyAuthorization.unavailableTargetResults);
586
+ return {
587
+ configWrite: 'succeeded',
588
+ overallState: 'partial',
589
+ apply: publicConfigApplyResult(apply),
590
+ otherProjectsMayRequireSync: false,
591
+ };
592
+ }
593
+ if (options.scope === 'user'
594
+ && options.sharedNativeApplyConfirmed !== true
595
+ && pluginHasSharedNativeRefreshKeys(options.plugin)
596
+ && await configApplyHasValidCodexTarget({
597
+ plugin: options.plugin,
598
+ targets: discovered.targets,
599
+ cwd: options.cwd,
600
+ env,
601
+ })) {
602
+ throwSharedNativeApplyConfirmationRequired();
603
+ }
604
+ const apply = await reinstallVisibleTargets({
605
+ plugin: options.plugin,
606
+ scope: options.scope,
607
+ cwd: options.cwd,
608
+ env,
219
609
  applyTargets: options.applyTargets,
220
610
  nativeCliRunner: options.nativeCliRunner,
221
611
  reinstallCommandImpl: options.reinstallCommandImpl,
222
- rebuildRuntime: { ...options.rebuildRuntime, awHomeMutationToken },
612
+ rebuildRuntime,
613
+ discovered,
614
+ preApplyConfirmed: options.preApplyConfirmed,
223
615
  });
224
616
  return {
225
617
  configWrite: 'succeeded',
226
- overallState: applied.overallState,
227
- targetResults: applied.targetResults,
228
- ...(applied.applySkippedReason ? { applySkippedReason: applied.applySkippedReason } : {}),
229
- otherProjectsRequireReinstall: options.scope === 'user',
618
+ overallState: overallStateForApply(apply),
619
+ apply: publicConfigApplyResult(apply),
620
+ otherProjectsMayRequireSync: false,
230
621
  };
231
622
  },
232
623
  });
233
624
  }
625
+ function pluginHasSharedNativeRefreshKeys(plugin) {
626
+ return (plugin.manifest.artifacts?.targets ?? []).some((target) => target.platform === 'codex'
627
+ && target.target === 'codex.skill'
628
+ && target.delivery?.mode === 'codex-native'
629
+ && target.refreshKeys.length > 0);
630
+ }
631
+ function throwSharedNativeApplyConfirmationRequired() {
632
+ const error = new Error('sharedNativeConfigApplyConfirmationRequired: Applying this user config changes a shared Codex native artifact. Re-run with --yes.');
633
+ error.code = 'sharedNativeConfigApplyConfirmationRequired';
634
+ throw error;
635
+ }
234
636
  async function applyPluginConfigWriteUnlocked(options) {
235
637
  const requestedPluginName = options.pluginName ?? options.plugin?.manifest.name;
236
638
  if (!requestedPluginName)
@@ -239,8 +641,8 @@ async function applyPluginConfigWriteUnlocked(options) {
239
641
  const configIdentity = options.plugin?.sourceId ? {
240
642
  sourceId: options.plugin.sourceId,
241
643
  sourceIdentity: options.plugin.sourceIdentity,
644
+ logicalIdentity: options.plugin.catalogLogicalIdentity,
242
645
  } : {};
243
- const projectLayer = options.scope === 'project' ? (options.projectLayer ?? 'shared') : 'shared';
244
646
  const requestedUpdates = options.request.updates ?? {};
245
647
  const requestedRemoveKeys = uniqueInOrder(options.request.removeKeys ?? []);
246
648
  const duplicateKeys = requestedRemoveKeys.filter((key) => Object.hasOwn(requestedUpdates, key));
@@ -252,113 +654,212 @@ async function applyPluginConfigWriteUnlocked(options) {
252
654
  currentPlugin: options.plugin,
253
655
  currentPluginError: options.pluginError,
254
656
  scope: options.scope,
255
- projectLayer,
256
657
  cwd: options.cwd,
257
658
  env: options.env,
258
659
  });
259
660
  const schemaPlugin = schemaAccess.plugin;
260
- const schema = schemaPlugin?.manifest.config?.schema;
661
+ const schema = schemaPlugin?.manifest.config?.fields;
261
662
  if (!schema || !schemaPlugin) {
262
663
  throw new Error(`configSchemaUnavailable: Plugin "${pluginName}" does not declare an AW config schema.`);
263
664
  }
264
- for (const key of requestedRemoveKeys) {
265
- if (!schema[key])
266
- throw new Error(`Unknown config key "${key}".`);
665
+ if (options.scope === 'project') {
666
+ const userStore = await readPluginConfigStore({
667
+ ...configIdentity,
668
+ pluginName,
669
+ scope: 'user',
670
+ cwd: options.cwd,
671
+ env: options.env,
672
+ schema,
673
+ });
674
+ assertReadyPluginConfigStore(userStore);
267
675
  }
268
- const updates = await coercePluginConfigUpdates({ schema, updates: requestedUpdates, cwd: options.cwd });
269
- if (options.scope === 'project' && projectLayer === 'shared') {
270
- for (const key of Object.keys(updates)) {
271
- const field = schema[key];
272
- if (field.type === 'file' || field.type === 'directory') {
273
- throw new Error(`Config "${key}" is a ${field.type} value and cannot be written into project shared config. `
274
- + 'Use `--scope project --local` or user config instead.');
275
- }
676
+ if (options.scope === 'project') {
677
+ const rejectedSensitiveKeys = Object.keys(requestedUpdates)
678
+ .filter((key) => schema[key]?.sensitive === true);
679
+ if (rejectedSensitiveKeys.length > 0) {
680
+ const error = new Error('sensitiveProjectConfigUnsupported: Sensitive config can only be set in user scope.');
681
+ error.code = 'sensitiveProjectConfigUnsupported';
682
+ throw error;
683
+ }
684
+ const userOnlyKeys = codexNativeRefreshKeys(schemaPlugin.manifest);
685
+ const rejectedKeys = Object.keys(requestedUpdates).filter((key) => userOnlyKeys.has(key));
686
+ if (rejectedKeys.length > 0) {
687
+ const error = new Error(`sharedNativeConfigUserScopeRequired: Codex native Skill refresh keys can only be set in user scope: ${rejectedKeys.join(', ')}.`);
688
+ error.code = 'sharedNativeConfigUserScopeRequired';
689
+ throw error;
276
690
  }
277
691
  }
278
- const store = await readPluginConfigStore({
279
- ...configIdentity,
280
- pluginName,
692
+ let discovered;
693
+ let targetDiscoveryFailed = false;
694
+ if (options.apply !== false) {
695
+ try {
696
+ discovered = await resolveConfigApplyTargets({
697
+ plugin: schemaPlugin,
698
+ scope: options.scope,
699
+ cwd: options.cwd,
700
+ env: options.env ?? process.env,
701
+ applyTargets: options.applyTargets,
702
+ nativeCliRunner: options.nativeCliRunner,
703
+ rebuildRuntime: options.rebuildRuntime,
704
+ });
705
+ }
706
+ catch {
707
+ targetDiscoveryFailed = true;
708
+ }
709
+ }
710
+ const impact = await analyzePluginConfigMutationImpact({
711
+ plugin: schemaPlugin,
281
712
  scope: options.scope,
282
- projectLayer,
283
713
  cwd: options.cwd,
284
714
  env: options.env,
715
+ visibleTargets: discovered?.targets ?? [],
716
+ mutation: {
717
+ kind: 'patch',
718
+ updates: requestedUpdates,
719
+ removeKeys: requestedRemoveKeys,
720
+ },
285
721
  });
722
+ const updates = await coercePluginConfigUpdates({ schema, updates: requestedUpdates, cwd: options.cwd });
286
723
  const warnings = [];
287
- if (options.scope === 'project' && projectLayer === 'shared') {
288
- await assertProjectSharedConfigPathVisible({ cwd: options.cwd, targetPath: store.path });
289
- }
290
- if (options.scope === 'project' && projectLayer === 'local') {
291
- const ignore = await ensureProjectPrivateStateIgnore({ cwd: options.cwd, targetPath: store.path });
292
- if (ignore.warning)
293
- warnings.push(ignore.warning);
294
- }
295
- const removedKeys = requestedRemoveKeys.filter((key) => Object.hasOwn(store.values, key));
296
- const updatedKeys = Object.keys(updates);
297
- const changedKeys = [...updatedKeys, ...removedKeys];
298
- if (options.scope === 'project' && projectLayer === 'shared' && changedKeys.length > 0) {
299
- const nextValues = { ...store.values, ...updates };
300
- for (const key of requestedRemoveKeys)
301
- delete nextValues[key];
302
- const boundaryIssues = collectProjectArtifactConfigBoundaryIssues({
303
- schema,
304
- sharedEntries: nextValues,
305
- });
306
- if (boundaryIssues.length > 0) {
307
- throw new Error([...new Set(boundaryIssues.map((issue) => issue.message))].join(' '));
724
+ const { updatedKeys, removedKeys, staleRemovedKeys } = impact;
725
+ let preApplyUnavailableReason;
726
+ let preApplyUnavailableTargetResults = [];
727
+ let applyDiscovery = discovered
728
+ ? { targets: impact.affectedTargets, failures: discovered.failures }
729
+ : undefined;
730
+ const shouldApply = options.apply !== false && impact.storeChanged && !impact.noEffectiveChange;
731
+ if (shouldApply && pluginMayRunPreApply(schemaPlugin)) {
732
+ if (applyDiscovery) {
733
+ const preApplyAuthorization = await resolveConfigPreApplyAuthorization({
734
+ plugin: schemaPlugin,
735
+ scope: options.scope,
736
+ cwd: options.cwd,
737
+ env: options.env,
738
+ applyTargets: applyDiscovery.targets,
739
+ nativeCliRunner: options.nativeCliRunner,
740
+ rebuildRuntime: options.rebuildRuntime,
741
+ reinstallCommandImpl: options.reinstallCommandImpl,
742
+ });
743
+ if (preApplyAuthorization.targets.length > 0 && !preApplyAuthorizationIsConfirmed({
744
+ required: preApplyAuthorization.targets,
745
+ confirmed: options.preApplyConfirmed,
746
+ authorizedTargets: options.preApplyAuthorizedTargets,
747
+ })) {
748
+ throwPreApplyAuthorizationRequired(preApplyAuthorization.targets);
749
+ }
750
+ preApplyUnavailableTargetResults = preApplyAuthorization.unavailableTargetResults;
751
+ applyDiscovery = {
752
+ targets: preApplyAuthorization.availableApplyTargets,
753
+ failures: [...applyDiscovery.failures, ...preApplyUnavailableTargetResults],
754
+ };
755
+ if (applyDiscovery.targets.length === 0 && preApplyUnavailableTargetResults.length > 0) {
756
+ preApplyUnavailableReason = 'sourceUnavailable';
757
+ }
758
+ }
759
+ }
760
+ if (options.apply !== false
761
+ && options.scope === 'user'
762
+ && options.sharedNativeApplyConfirmed !== true
763
+ && impact.sharedNativeRenderTargets.length > 0
764
+ && impact.affectedTargets.some((target) => target.platform === 'codex')) {
765
+ throwSharedNativeApplyConfirmationRequired();
766
+ }
767
+ if (impact.storeChanged) {
768
+ try {
769
+ const write = await patchPluginConfigStore({
770
+ ...configIdentity,
771
+ pluginName,
772
+ scope: options.scope,
773
+ cwd: options.cwd,
774
+ env: options.env,
775
+ updates: Object.fromEntries(updatedKeys.map((key) => [key, updates[key]])),
776
+ removeKeys: requestedRemoveKeys,
777
+ schema,
778
+ });
779
+ warnings.push(...write.warnings);
780
+ }
781
+ catch (error) {
782
+ throw markConfigWriteFailed(error);
308
783
  }
309
784
  }
310
- if (changedKeys.length > 0) {
311
- await patchPluginConfigStore({
785
+ let effective;
786
+ try {
787
+ effective = summarizeEffectivePluginConfig(await resolveEffectivePluginConfig({
312
788
  ...configIdentity,
313
789
  pluginName,
314
- scope: options.scope,
315
- projectLayer,
790
+ manifest: schemaPlugin.manifest,
791
+ targetScope: options.scope,
316
792
  cwd: options.cwd,
317
793
  env: options.env,
318
- updates,
319
- removeKeys: requestedRemoveKeys,
320
- });
794
+ }));
321
795
  }
322
- const effective = summarizeEffectivePluginConfig(await resolveEffectivePluginConfig({
323
- ...configIdentity,
324
- pluginName,
325
- manifest: schemaPlugin.manifest,
326
- cwd: options.cwd,
327
- env: options.env,
328
- }));
329
- const applied = changedKeys.length === 0
330
- ? {
331
- overallState: 'succeeded',
332
- targetResults: [],
333
- applySkippedReason: 'noConfigChange',
334
- }
335
- : await reinstallVisibleTargets({
336
- plugin: schemaPlugin,
796
+ catch {
797
+ const apply = unavailableApply('effectiveConfigUnavailable', 'effectiveConfig');
798
+ const otherProjectsMayRequireSync = options.scope === 'user' && impact.storeChanged;
799
+ if (otherProjectsMayRequireSync)
800
+ warnings.push(...otherProjectsWarning(options.scope));
801
+ return {
802
+ plugin: pluginName,
337
803
  scope: options.scope,
338
- cwd: options.cwd,
339
- env: options.env ?? process.env,
340
- applyTargets: options.applyTargets,
341
- nativeCliRunner: options.nativeCliRunner,
342
- reinstallCommandImpl: options.reinstallCommandImpl,
343
- rebuildRuntime: options.rebuildRuntime,
344
- });
345
- const otherProjectsRequireReinstall = options.scope === 'user'
346
- && changedKeys.length > 0;
347
- if (otherProjectsRequireReinstall)
804
+ ...(schemaAccess.schema ? { schema: schemaAccess.schema } : {}),
805
+ updatedKeys,
806
+ removedKeys,
807
+ staleRemovedKeys,
808
+ configWrite: 'succeeded',
809
+ overallState: 'partial',
810
+ apply: publicConfigApplyResult(apply),
811
+ otherProjectsMayRequireSync,
812
+ warnings,
813
+ };
814
+ }
815
+ let apply;
816
+ try {
817
+ apply = !impact.storeChanged
818
+ ? skippedApply('noConfigChange')
819
+ : options.apply === false
820
+ ? skippedApply('notRequested')
821
+ : targetDiscoveryFailed
822
+ ? unavailableApply('targetDiscoveryFailed', 'targetDiscovery')
823
+ : impact.noEffectiveChange
824
+ && ((discovered?.targets.length ?? 0) > 0
825
+ || staleRemovedKeys.length === impact.changedKeys.length)
826
+ ? skippedApply('noEffectiveConfigChange')
827
+ : preApplyUnavailableReason
828
+ ? unavailableApply(preApplyUnavailableReason, preApplyUnavailableReason === 'sourceUnavailable' ? 'source' : 'targetDiscovery', preApplyUnavailableTargetResults)
829
+ : await applyConfigToVisibleTargets({
830
+ plugin: schemaPlugin,
831
+ scope: options.scope,
832
+ cwd: options.cwd,
833
+ env: options.env ?? process.env,
834
+ applyTargets: applyDiscovery?.targets ?? impact.affectedTargets,
835
+ nativeCliRunner: options.nativeCliRunner,
836
+ reinstallCommandImpl: options.reinstallCommandImpl,
837
+ rebuildRuntime: options.rebuildRuntime,
838
+ noVisibleTargetHasInvalidConfig: (discovered?.targets.length ?? 0) > 0
839
+ && effective.issues.length > 0,
840
+ preApplyConfirmed: options.preApplyConfirmed,
841
+ discovered: applyDiscovery,
842
+ });
843
+ }
844
+ catch (error) {
845
+ const failure = error instanceof Error ? error : new Error(String(error));
846
+ throw Object.assign(failure, { configWrite: 'succeeded' });
847
+ }
848
+ const otherProjectsMayRequireSync = options.scope === 'user' && impact.storeChanged;
849
+ if (otherProjectsMayRequireSync)
348
850
  warnings.push(...otherProjectsWarning(options.scope));
349
851
  return {
350
852
  plugin: pluginName,
351
853
  scope: options.scope,
352
- projectLayer,
353
854
  ...(schemaAccess.schema ? { schema: schemaAccess.schema } : {}),
354
855
  updatedKeys,
355
856
  removedKeys,
857
+ staleRemovedKeys,
356
858
  effective,
357
859
  configWrite: 'succeeded',
358
- overallState: applied.overallState,
359
- targetResults: applied.targetResults,
360
- ...(applied.applySkippedReason ? { applySkippedReason: applied.applySkippedReason } : {}),
361
- otherProjectsRequireReinstall,
860
+ overallState: overallStateForApply(apply),
861
+ apply: publicConfigApplyResult(apply),
862
+ otherProjectsMayRequireSync,
362
863
  warnings,
363
864
  };
364
865
  }
@@ -366,162 +867,354 @@ export async function applyPluginConfigWrite(options) {
366
867
  const requestedPluginName = options.pluginName ?? options.plugin?.manifest.name;
367
868
  if (!requestedPluginName)
368
869
  throw new Error('Plugin name is required for config write.');
369
- const pluginName = assertSafePluginConfigSegment(requestedPluginName);
870
+ assertSafePluginConfigSegment(requestedPluginName);
871
+ if (options.scope === 'project') {
872
+ const targetPath = resolvePluginConfigStorePath({
873
+ sourceId: options.plugin?.sourceId,
874
+ pluginName: requestedPluginName,
875
+ scope: 'project',
876
+ cwd: options.cwd,
877
+ env: options.env,
878
+ });
879
+ await assertProjectSharedConfigPathVisible({
880
+ cwd: options.cwd,
881
+ targetPath,
882
+ env: options.env,
883
+ });
884
+ }
370
885
  return withAwHomeMutationLock({
371
886
  env: options.env,
372
887
  token: options.awHomeMutationToken,
373
- action: (awHomeMutationToken) => withPluginConfigTransactionLease({
374
- ...(options.plugin?.sourceId ? { sourceId: options.plugin.sourceId } : {}),
375
- pluginName,
376
- scope: options.scope,
377
- projectLayer: options.scope === 'project' ? (options.projectLayer ?? 'shared') : 'shared',
378
- cwd: options.cwd,
379
- env: options.env,
380
- action: async () => {
381
- await options.reviewPreflight?.();
382
- return applyPluginConfigWriteUnlocked({
888
+ action: async (awHomeMutationToken) => {
889
+ await options.reviewPreflight?.();
890
+ try {
891
+ return await applyPluginConfigWriteUnlocked({
383
892
  ...options,
384
893
  awHomeMutationToken,
385
894
  rebuildRuntime: { ...options.rebuildRuntime, awHomeMutationToken },
386
895
  });
387
- },
388
- }),
896
+ }
897
+ catch (error) {
898
+ let sensitiveValues = options.plugin
899
+ ? collectSensitivePluginConfigValues(options.plugin.manifest, (options.request.updates ?? {}))
900
+ : [];
901
+ if (options.plugin) {
902
+ try {
903
+ const effective = await resolveEffectivePluginConfig({
904
+ ...(options.plugin.sourceId ? {
905
+ sourceId: options.plugin.sourceId,
906
+ sourceIdentity: options.plugin.sourceIdentity,
907
+ logicalIdentity: options.plugin.catalogLogicalIdentity,
908
+ } : {}),
909
+ pluginName: options.plugin.manifest.name,
910
+ manifest: options.plugin.manifest,
911
+ targetScope: options.scope,
912
+ cwd: options.cwd,
913
+ env: options.env,
914
+ });
915
+ sensitiveValues = [
916
+ ...sensitiveValues,
917
+ ...collectSensitivePluginConfigValues(options.plugin.manifest, effective.values),
918
+ ];
919
+ }
920
+ catch {
921
+ // Requested sensitive values and generic credential redaction remain available.
922
+ }
923
+ }
924
+ let message = redactPluginScriptOutput(error instanceof Error ? error.message : String(error), sensitiveValues);
925
+ message = message.split(options.cwd).join('<project>');
926
+ for (const scope of ['user', 'project']) {
927
+ const configPath = resolvePluginConfigStorePath({
928
+ sourceId: options.plugin?.sourceId,
929
+ pluginName: requestedPluginName,
930
+ scope,
931
+ cwd: options.cwd,
932
+ env: options.env,
933
+ });
934
+ message = message.split(configPath).join(`${scope}/plugin-config/${[
935
+ options.plugin?.sourceId,
936
+ requestedPluginName,
937
+ 'config.json',
938
+ ].filter(Boolean).join('/')}`);
939
+ }
940
+ const safeError = new Error(message);
941
+ const code = error.code;
942
+ safeError.code = typeof code === 'string' ? code : 'configApplyFailed';
943
+ const configWrite = error.configWrite;
944
+ if (configWrite === 'succeeded' || configWriteStateForError(error) === 'failed') {
945
+ safeError.configWrite = configWrite === 'succeeded' ? 'succeeded' : 'failed';
946
+ }
947
+ if (error && typeof error === 'object' && 'operationDiagnostic' in error) {
948
+ safeError.operationDiagnostic = error.operationDiagnostic;
949
+ }
950
+ throw safeError;
951
+ }
952
+ },
389
953
  });
390
954
  }
391
955
  async function resetPluginConfigWithHelperUnlocked(options) {
392
956
  const pluginName = assertSafePluginConfigSegment(options.pluginName);
393
- const projectLayer = options.scope === 'project' ? (options.projectLayer ?? 'shared') : 'shared';
394
- if (!options.plugin) {
395
- throw new Error(`sourceMissing: Plugin "${pluginName}" is unavailable; config reset was not applied.`);
396
- }
397
- const schemaAccess = await resolvePluginConfigSchemaAccess({
398
- pluginName,
399
- currentPlugin: options.plugin,
400
- scope: options.scope,
401
- projectLayer,
402
- cwd: options.cwd,
403
- env: options.env,
404
- });
405
- if (!schemaAccess.plugin?.manifest.config?.schema) {
406
- throw new Error(`configSchemaUnavailable: Plugin "${pluginName}" does not declare an AW config schema.`);
407
- }
408
- const configIdentity = options.plugin.sourceId ? {
957
+ let configIdentity = options.plugin?.sourceId ? {
409
958
  sourceId: options.plugin.sourceId,
410
959
  sourceIdentity: options.plugin.sourceIdentity,
960
+ logicalIdentity: options.plugin.catalogLogicalIdentity,
961
+ } : options.sourceId ? {
962
+ sourceId: options.sourceId,
963
+ sourceIdentity: options.sourceIdentity,
964
+ logicalIdentity: options.logicalIdentity,
411
965
  } : {};
412
- const store = await readPluginConfigStore({
413
- ...configIdentity,
414
- pluginName,
415
- scope: options.scope,
416
- projectLayer,
417
- cwd: options.cwd,
418
- env: options.env,
419
- });
420
- const removedKeys = collectRemovedConfigKeys(store.values);
421
- const warnings = [];
422
- if (options.scope === 'project' && projectLayer === 'shared' && store.exists) {
423
- await assertProjectSharedConfigPathVisible({ cwd: options.cwd, targetPath: store.path });
424
- }
425
- if (options.scope === 'project' && projectLayer === 'local') {
426
- const ignore = await ensureProjectPrivateStateIgnore({ cwd: options.cwd, targetPath: store.path });
427
- if (ignore.warning)
428
- warnings.push(ignore.warning);
429
- }
430
- const reset = await resetPluginConfigStore({
431
- ...configIdentity,
432
- pluginName,
433
- scope: options.scope,
434
- projectLayer,
435
- cwd: options.cwd,
436
- env: options.env,
437
- });
438
- let applied = {
439
- overallState: 'succeeded',
440
- targetResults: [],
441
- applySkippedReason: 'noConfigChange',
442
- };
443
- let effective;
444
- if (schemaAccess.plugin) {
445
- if (schemaAccess.plugin.manifest.config?.schema) {
446
- effective = summarizeEffectivePluginConfig(await resolveEffectivePluginConfig({
447
- ...configIdentity,
966
+ if (options.sourceId && !options.sourceIdentity) {
967
+ try {
968
+ const identity = await readNamespacedPluginConfigStoreIdentity({
969
+ sourceId: options.sourceId,
448
970
  pluginName,
449
- manifest: schemaAccess.plugin.manifest,
971
+ scope: options.scope,
450
972
  cwd: options.cwd,
451
973
  env: options.env,
452
- }));
974
+ });
975
+ if (identity?.binding.kind === 'source')
976
+ configIdentity = {
977
+ sourceId: options.sourceId,
978
+ sourceIdentity: identity.binding.sourceIdentity,
979
+ };
980
+ if (identity?.binding.kind === 'catalog')
981
+ configIdentity = {
982
+ sourceId: options.sourceId,
983
+ logicalIdentity: identity.binding.logicalIdentity,
984
+ };
985
+ }
986
+ catch {
987
+ // Reset does not require a readable or valid envelope.
453
988
  }
454
- if (reset.deleted) {
455
- applied = await reinstallVisibleTargets({
456
- plugin: schemaAccess.plugin,
989
+ }
990
+ let removedKeys = [];
991
+ try {
992
+ const store = await readPluginConfigStore({
993
+ ...configIdentity,
994
+ pluginName,
995
+ scope: options.scope,
996
+ cwd: options.cwd,
997
+ env: options.env,
998
+ });
999
+ removedKeys = collectRemovedConfigKeys(store.values);
1000
+ }
1001
+ catch {
1002
+ // Reset is the final recovery boundary and does not require a readable store.
1003
+ }
1004
+ const warnings = [];
1005
+ let impact;
1006
+ let targetDiscoveryFailed = false;
1007
+ let visibleTargets = [];
1008
+ if (options.plugin) {
1009
+ if (options.apply !== false) {
1010
+ try {
1011
+ visibleTargets = (await resolveConfigApplyTargets({
1012
+ plugin: options.plugin,
1013
+ scope: options.scope,
1014
+ cwd: options.cwd,
1015
+ env: options.env ?? process.env,
1016
+ applyTargets: options.applyTargets,
1017
+ nativeCliRunner: options.nativeCliRunner,
1018
+ rebuildRuntime: options.rebuildRuntime,
1019
+ })).targets;
1020
+ }
1021
+ catch {
1022
+ targetDiscoveryFailed = true;
1023
+ }
1024
+ }
1025
+ try {
1026
+ impact = await analyzePluginConfigMutationImpact({
1027
+ plugin: options.plugin,
457
1028
  scope: options.scope,
458
1029
  cwd: options.cwd,
459
- env: options.env ?? process.env,
460
- applyTargets: options.applyTargets,
461
- nativeCliRunner: options.nativeCliRunner,
462
- reinstallCommandImpl: options.reinstallCommandImpl,
463
- rebuildRuntime: options.rebuildRuntime,
1030
+ env: options.env,
1031
+ visibleTargets,
1032
+ mutation: { kind: 'reset' },
464
1033
  });
1034
+ removedKeys = impact.removedKeys;
1035
+ }
1036
+ catch {
1037
+ // Reset remains available when its before state cannot be read.
1038
+ }
1039
+ }
1040
+ let preApplyUnavailableReason;
1041
+ let preApplyUnavailableTargetResults = [];
1042
+ let applyDiscovery = options.plugin && !targetDiscoveryFailed
1043
+ ? { targets: impact?.affectedTargets ?? visibleTargets, failures: [] }
1044
+ : undefined;
1045
+ if (options.plugin
1046
+ && options.apply !== false
1047
+ && impact?.storeChanged
1048
+ && !impact.noEffectiveChange
1049
+ && applyDiscovery
1050
+ && pluginMayRunPreApply(options.plugin)) {
1051
+ const preApplyAuthorization = await resolveConfigPreApplyAuthorization({
1052
+ plugin: options.plugin,
1053
+ scope: options.scope,
1054
+ cwd: options.cwd,
1055
+ env: options.env,
1056
+ applyTargets: applyDiscovery.targets,
1057
+ nativeCliRunner: options.nativeCliRunner,
1058
+ rebuildRuntime: options.rebuildRuntime,
1059
+ reinstallCommandImpl: options.reinstallCommandImpl,
1060
+ });
1061
+ if (preApplyAuthorization.targets.length > 0 && !preApplyAuthorizationIsConfirmed({
1062
+ required: preApplyAuthorization.targets,
1063
+ confirmed: options.preApplyConfirmed,
1064
+ authorizedTargets: options.preApplyAuthorizedTargets,
1065
+ })) {
1066
+ throwPreApplyAuthorizationRequired(preApplyAuthorization.targets);
1067
+ }
1068
+ preApplyUnavailableTargetResults = preApplyAuthorization.unavailableTargetResults;
1069
+ applyDiscovery = {
1070
+ targets: preApplyAuthorization.availableApplyTargets,
1071
+ failures: preApplyUnavailableTargetResults,
1072
+ };
1073
+ if (applyDiscovery.targets.length === 0 && preApplyUnavailableTargetResults.length > 0) {
1074
+ preApplyUnavailableReason = 'sourceUnavailable';
465
1075
  }
466
1076
  }
467
- const otherProjectsRequireReinstall = Boolean(schemaAccess.plugin)
1077
+ if (options.plugin
1078
+ && options.apply !== false
468
1079
  && options.scope === 'user'
469
- && reset.deleted;
470
- if (otherProjectsRequireReinstall)
1080
+ && options.sharedNativeApplyConfirmed !== true
1081
+ && (impact
1082
+ ? impact.sharedNativeRenderTargets.length > 0
1083
+ && impact.affectedTargets.some((target) => target.platform === 'codex')
1084
+ : pluginHasSharedNativeRefreshKeys(options.plugin))
1085
+ && visibleTargets.some((target) => target.platform === 'codex')) {
1086
+ throwSharedNativeApplyConfirmationRequired();
1087
+ }
1088
+ let reset;
1089
+ try {
1090
+ reset = await resetPluginConfigStore({
1091
+ ...configIdentity,
1092
+ pluginName,
1093
+ scope: options.scope,
1094
+ cwd: options.cwd,
1095
+ env: options.env,
1096
+ });
1097
+ }
1098
+ catch (error) {
1099
+ throw markConfigWriteFailed(error);
1100
+ }
1101
+ let schemaAccess;
1102
+ let apply = reset.deleted ? skippedApply('notRequested') : skippedApply('noConfigChange');
1103
+ let effective;
1104
+ if (options.plugin) {
1105
+ try {
1106
+ schemaAccess = await resolvePluginConfigSchemaAccess({
1107
+ pluginName,
1108
+ currentPlugin: options.plugin,
1109
+ scope: options.scope,
1110
+ cwd: options.cwd,
1111
+ env: options.env,
1112
+ });
1113
+ }
1114
+ catch {
1115
+ if (reset.deleted && options.apply !== false) {
1116
+ apply = unavailableApply('sourceUnavailable', 'source');
1117
+ }
1118
+ }
1119
+ const schemaPlugin = schemaAccess?.plugin;
1120
+ if (schemaPlugin?.manifest.config?.fields) {
1121
+ try {
1122
+ effective = summarizeEffectivePluginConfig(await resolveEffectivePluginConfig({
1123
+ ...configIdentity,
1124
+ pluginName,
1125
+ manifest: schemaPlugin.manifest,
1126
+ targetScope: options.scope,
1127
+ cwd: options.cwd,
1128
+ env: options.env,
1129
+ }));
1130
+ }
1131
+ catch {
1132
+ if (reset.deleted && options.apply !== false) {
1133
+ apply = unavailableApply('effectiveConfigUnavailable', 'effectiveConfig');
1134
+ }
1135
+ }
1136
+ if (reset.deleted
1137
+ && options.apply !== false
1138
+ && apply.state === 'skipped'
1139
+ && impact?.noEffectiveChange
1140
+ && visibleTargets.length > 0) {
1141
+ apply = skippedApply('noEffectiveConfigChange');
1142
+ }
1143
+ else if (reset.deleted
1144
+ && options.apply !== false
1145
+ && apply.state === 'skipped'
1146
+ && targetDiscoveryFailed) {
1147
+ apply = unavailableApply('targetDiscoveryFailed', 'targetDiscovery');
1148
+ }
1149
+ else if (reset.deleted && options.apply !== false && apply.state === 'skipped') {
1150
+ apply = preApplyUnavailableReason
1151
+ ? unavailableApply(preApplyUnavailableReason, 'source', preApplyUnavailableTargetResults)
1152
+ : await applyConfigToVisibleTargets({
1153
+ plugin: schemaPlugin,
1154
+ scope: options.scope,
1155
+ cwd: options.cwd,
1156
+ env: options.env ?? process.env,
1157
+ applyTargets: applyDiscovery?.targets ?? impact?.affectedTargets ?? options.applyTargets,
1158
+ nativeCliRunner: options.nativeCliRunner,
1159
+ reinstallCommandImpl: options.reinstallCommandImpl,
1160
+ rebuildRuntime: options.rebuildRuntime,
1161
+ noVisibleTargetHasInvalidConfig: (effective?.issues.length ?? 0) > 0,
1162
+ preApplyConfirmed: options.preApplyConfirmed,
1163
+ discovered: applyDiscovery,
1164
+ });
1165
+ }
1166
+ }
1167
+ else if (reset.deleted && options.apply !== false && apply.state === 'skipped') {
1168
+ apply = unavailableApply('schemaUnavailable', 'schema');
1169
+ }
1170
+ }
1171
+ else if (reset.deleted && options.apply !== false) {
1172
+ apply = options.pluginError
1173
+ ? unavailableApply('sourceUnavailable', 'source')
1174
+ : unavailableApply('schemaUnavailable', 'schema');
1175
+ }
1176
+ const otherProjectsMayRequireSync = options.scope === 'user' && reset.deleted;
1177
+ if (otherProjectsMayRequireSync)
471
1178
  warnings.push(...otherProjectsWarning(options.scope));
472
1179
  return {
473
1180
  plugin: pluginName,
474
1181
  scope: options.scope,
475
- projectLayer,
476
- ...(schemaAccess.schema ? { schema: schemaAccess.schema } : {}),
1182
+ ...(schemaAccess?.schema ? { schema: schemaAccess.schema } : {}),
477
1183
  existed: reset.existed,
478
1184
  deleted: reset.deleted,
1185
+ resetDisposition: reset.resetDisposition,
1186
+ ...(reset.quarantineBasename ? { quarantineBasename: reset.quarantineBasename } : {}),
479
1187
  removedKeys,
480
1188
  ...(effective ? { effective } : {}),
481
1189
  configWrite: 'succeeded',
482
- overallState: applied.overallState,
483
- targetResults: applied.targetResults,
484
- ...(applied.applySkippedReason ? { applySkippedReason: applied.applySkippedReason } : {}),
485
- otherProjectsRequireReinstall,
1190
+ overallState: overallStateForApply(apply),
1191
+ apply: publicConfigApplyResult(apply),
1192
+ otherProjectsMayRequireSync,
486
1193
  warnings,
487
1194
  };
488
1195
  }
489
1196
  export async function resetPluginConfigWithHelper(options) {
490
- const pluginName = assertSafePluginConfigSegment(options.pluginName);
491
- if (!options.plugin) {
492
- throw new Error(`sourceMissing: Plugin "${pluginName}" is unavailable; config reset was not applied.`);
493
- }
494
- const sourceId = options.plugin.sourceId;
1197
+ assertSafePluginConfigSegment(options.pluginName);
495
1198
  return withAwHomeMutationLock({
496
1199
  env: options.env,
497
1200
  token: options.awHomeMutationToken,
498
- action: (awHomeMutationToken) => withPluginConfigTransactionLease({
499
- ...(sourceId ? { sourceId } : {}),
500
- pluginName,
501
- scope: options.scope,
502
- projectLayer: options.scope === 'project' ? (options.projectLayer ?? 'shared') : 'shared',
503
- cwd: options.cwd,
504
- env: options.env,
505
- action: async () => {
506
- await options.reviewPreflight?.();
507
- return resetPluginConfigWithHelperUnlocked({
508
- ...options,
509
- awHomeMutationToken,
510
- rebuildRuntime: { ...options.rebuildRuntime, awHomeMutationToken },
511
- });
512
- },
513
- }),
1201
+ action: async (awHomeMutationToken) => {
1202
+ await options.reviewPreflight?.();
1203
+ return resetPluginConfigWithHelperUnlocked({
1204
+ ...options,
1205
+ awHomeMutationToken,
1206
+ rebuildRuntime: { ...options.rebuildRuntime, awHomeMutationToken },
1207
+ });
1208
+ },
514
1209
  });
515
1210
  }
516
1211
  export async function describeResetAffectedFields(options) {
517
- const projectLayer = options.scope === 'project' ? (options.projectLayer ?? 'shared') : 'shared';
518
1212
  try {
519
1213
  const resolved = await resolveConfigRead({
520
1214
  pluginName: options.pluginName,
521
1215
  plugin: options.plugin,
522
1216
  ...(options.pluginError ? { pluginError: options.pluginError } : {}),
523
1217
  scope: options.scope,
524
- projectLayer,
525
1218
  cwd: options.cwd,
526
1219
  env: options.env,
527
1220
  });
@@ -532,7 +1225,6 @@ export async function describeResetAffectedFields(options) {
532
1225
  reserved: field.reserved,
533
1226
  action: 'reset',
534
1227
  scope: options.scope,
535
- projectLayer,
536
1228
  valueState: field.valueState,
537
1229
  }));
538
1230
  }
@@ -541,13 +1233,14 @@ export async function describeResetAffectedFields(options) {
541
1233
  ...(options.plugin?.sourceId ? {
542
1234
  sourceId: options.plugin.sourceId,
543
1235
  sourceIdentity: options.plugin.sourceIdentity,
1236
+ logicalIdentity: options.plugin.catalogLogicalIdentity,
544
1237
  } : options.sourceId ? {
545
1238
  sourceId: options.sourceId,
546
1239
  sourceIdentity: options.sourceIdentity,
1240
+ logicalIdentity: options.logicalIdentity,
547
1241
  } : {}),
548
1242
  pluginName: options.pluginName,
549
1243
  scope: options.scope,
550
- projectLayer,
551
1244
  cwd: options.cwd,
552
1245
  env: options.env,
553
1246
  });
@@ -558,7 +1251,6 @@ export async function describeResetAffectedFields(options) {
558
1251
  reserved: false,
559
1252
  action: 'reset',
560
1253
  scope: options.scope,
561
- projectLayer,
562
1254
  }));
563
1255
  }
564
1256
  }