@lesliechan721/aw 0.1.0-beta.5 → 0.1.0-beta.50

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 (566) hide show
  1. package/dist/authoring/assets/aw-config.mjs +100 -501
  2. package/dist/authoring/assets/aw-config.mjs.map +1 -1
  3. package/dist/authoring/assets/aw-runtime-config.d.mts +13 -0
  4. package/dist/authoring/assets/aw-runtime-config.mjs +199 -0
  5. package/dist/authoring/assets/aw-runtime-config.mjs.map +1 -0
  6. package/dist/authoring/scripts/add-skill.mjs +4 -4
  7. package/dist/authoring/scripts/add-skill.mjs.map +1 -1
  8. package/dist/authoring/scripts/init-plugin.mjs +67 -97
  9. package/dist/authoring/scripts/init-plugin.mjs.map +1 -1
  10. package/dist/authoring/scripts/lib/plugin-root.mjs +4 -4
  11. package/dist/authoring/scripts/lib/plugin-root.mjs.map +1 -1
  12. package/dist/authoring/scripts/lib/plugin-version-check.d.mts +1 -0
  13. package/dist/authoring/scripts/lib/plugin-version-check.mjs +229 -8
  14. package/dist/authoring/scripts/lib/plugin-version-check.mjs.map +1 -1
  15. package/dist/authoring/scripts/lib/skill-scaffold.d.mts +77 -90
  16. package/dist/authoring/scripts/lib/skill-scaffold.mjs +99 -120
  17. package/dist/authoring/scripts/lib/skill-scaffold.mjs.map +1 -1
  18. package/dist/authoring/scripts/plugin-status.mjs +8 -11
  19. package/dist/authoring/scripts/plugin-status.mjs.map +1 -1
  20. package/dist/authoring/scripts/remove-plugin.mjs +3 -2
  21. package/dist/authoring/scripts/remove-plugin.mjs.map +1 -1
  22. package/dist/authoring/scripts/validate-plugin.mjs +346 -1131
  23. package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
  24. package/dist/scripts/aw-skill-eval-materializer.d.ts +26 -0
  25. package/dist/scripts/aw-skill-eval-materializer.js +306 -0
  26. package/dist/scripts/aw-skill-eval-materializer.js.map +1 -0
  27. package/dist/scripts/bundle-plugins.d.ts +1 -0
  28. package/dist/scripts/bundle-plugins.js +20 -5
  29. package/dist/scripts/bundle-plugins.js.map +1 -1
  30. package/dist/scripts/plugin-staging.d.ts +7 -9
  31. package/dist/scripts/plugin-staging.js +18 -29
  32. package/dist/scripts/plugin-staging.js.map +1 -1
  33. package/dist/scripts/test-plugin-scripts.d.ts +2 -0
  34. package/dist/scripts/test-plugin-scripts.js +47 -76
  35. package/dist/scripts/test-plugin-scripts.js.map +1 -1
  36. package/dist/scripts/test-workers.d.mts +24 -0
  37. package/dist/scripts/test-workers.mjs +59 -0
  38. package/dist/scripts/test-workers.mjs.map +1 -0
  39. package/dist/src/adapters/helpers.js +2 -2
  40. package/dist/src/adapters/helpers.js.map +1 -1
  41. package/dist/src/authoring/workspace-commands.d.ts +17 -1
  42. package/dist/src/authoring/workspace-commands.js +21 -4
  43. package/dist/src/authoring/workspace-commands.js.map +1 -1
  44. package/dist/src/commands/aw-capabilities.d.ts +78 -0
  45. package/dist/src/commands/aw-capabilities.js +264 -0
  46. package/dist/src/commands/aw-capabilities.js.map +1 -0
  47. package/dist/src/commands/catalog-dev-source.d.ts +154 -0
  48. package/dist/src/commands/catalog-dev-source.js +655 -0
  49. package/dist/src/commands/catalog-dev-source.js.map +1 -0
  50. package/dist/src/commands/catalog-generation.d.ts +21 -0
  51. package/dist/src/commands/catalog-generation.js +9 -0
  52. package/dist/src/commands/catalog-generation.js.map +1 -0
  53. package/dist/src/commands/catalog-publication-inspection.d.ts +71 -30
  54. package/dist/src/commands/catalog-publication-inspection.js +475 -63
  55. package/dist/src/commands/catalog-publication-inspection.js.map +1 -1
  56. package/dist/src/commands/catalog-publication-journal.d.ts +68 -0
  57. package/dist/src/commands/catalog-publication-journal.js +292 -0
  58. package/dist/src/commands/catalog-publication-journal.js.map +1 -0
  59. package/dist/src/commands/catalog-publication-target.d.ts +18 -0
  60. package/dist/src/commands/catalog-publication-target.js +95 -0
  61. package/dist/src/commands/catalog-publication-target.js.map +1 -0
  62. package/dist/src/commands/catalog-publish.d.ts +73 -15
  63. package/dist/src/commands/catalog-publish.js +701 -212
  64. package/dist/src/commands/catalog-publish.js.map +1 -1
  65. package/dist/src/commands/catalog-source.d.ts +60 -22
  66. package/dist/src/commands/catalog-source.js +311 -91
  67. package/dist/src/commands/catalog-source.js.map +1 -1
  68. package/dist/src/commands/catalog-status.d.ts +18 -22
  69. package/dist/src/commands/catalog-status.js +81 -115
  70. package/dist/src/commands/catalog-status.js.map +1 -1
  71. package/dist/src/commands/catalog-store.d.ts +104 -0
  72. package/dist/src/commands/catalog-store.js +685 -0
  73. package/dist/src/commands/catalog-store.js.map +1 -0
  74. package/dist/src/commands/catalog-workspace-resolution.d.ts +13 -0
  75. package/dist/src/commands/catalog-workspace-resolution.js +42 -0
  76. package/dist/src/commands/catalog-workspace-resolution.js.map +1 -0
  77. package/dist/src/commands/console.js +28 -17
  78. package/dist/src/commands/console.js.map +1 -1
  79. package/dist/src/commands/dependency-operation-plan.d.ts +52 -15
  80. package/dist/src/commands/dependency-operation-plan.js +289 -7
  81. package/dist/src/commands/dependency-operation-plan.js.map +1 -1
  82. package/dist/src/commands/init.d.ts +5 -11
  83. package/dist/src/commands/init.js +30 -51
  84. package/dist/src/commands/init.js.map +1 -1
  85. package/dist/src/commands/offline-cleanup-evidence.d.ts +67 -0
  86. package/dist/src/commands/offline-cleanup-evidence.js +181 -0
  87. package/dist/src/commands/offline-cleanup-evidence.js.map +1 -0
  88. package/dist/src/commands/operation-plan.d.ts +146 -0
  89. package/dist/src/commands/operation-plan.js +71 -0
  90. package/dist/src/commands/operation-plan.js.map +1 -0
  91. package/dist/src/commands/operation-planner.d.ts +46 -0
  92. package/dist/src/commands/operation-planner.js +141 -0
  93. package/dist/src/commands/operation-planner.js.map +1 -0
  94. package/dist/src/commands/options.d.ts +9 -7
  95. package/dist/src/commands/options.js +83 -21
  96. package/dist/src/commands/options.js.map +1 -1
  97. package/dist/src/commands/plugin-capabilities.js +23 -3
  98. package/dist/src/commands/plugin-capabilities.js.map +1 -1
  99. package/dist/src/commands/rebuild-command.d.ts +77 -31
  100. package/dist/src/commands/rebuild-command.js +4862 -729
  101. package/dist/src/commands/rebuild-command.js.map +1 -1
  102. package/dist/src/commands/rebuild-integration.d.ts +131 -21
  103. package/dist/src/commands/rebuild-integration.js +2866 -1339
  104. package/dist/src/commands/rebuild-integration.js.map +1 -1
  105. package/dist/src/commands/rebuild-operations.d.ts +58 -30
  106. package/dist/src/commands/rebuild-operations.js +260 -319
  107. package/dist/src/commands/rebuild-operations.js.map +1 -1
  108. package/dist/src/commands/reconcile-operation-plan.d.ts +28 -0
  109. package/dist/src/commands/reconcile-operation-plan.js +47 -0
  110. package/dist/src/commands/reconcile-operation-plan.js.map +1 -0
  111. package/dist/src/commands/review-inspection.d.ts +228 -0
  112. package/dist/src/commands/review-inspection.js +1341 -0
  113. package/dist/src/commands/review-inspection.js.map +1 -0
  114. package/dist/src/commands/review-preparation.d.ts +49 -0
  115. package/dist/src/commands/review-preparation.js +427 -0
  116. package/dist/src/commands/review-preparation.js.map +1 -0
  117. package/dist/src/commands/runtime.d.ts +1 -5
  118. package/dist/src/commands/runtime.js +24 -50
  119. package/dist/src/commands/runtime.js.map +1 -1
  120. package/dist/src/commands/skill-eval.d.ts +39 -0
  121. package/dist/src/commands/skill-eval.js +400 -0
  122. package/dist/src/commands/skill-eval.js.map +1 -0
  123. package/dist/src/commands/status-v6.d.ts +279 -0
  124. package/dist/src/commands/status-v6.js +2787 -0
  125. package/dist/src/commands/status-v6.js.map +1 -0
  126. package/dist/src/commands/sync-command.d.ts +40 -0
  127. package/dist/src/commands/sync-command.js +250 -0
  128. package/dist/src/commands/sync-command.js.map +1 -0
  129. package/dist/src/commands/wizard.d.ts +8 -5
  130. package/dist/src/commands/wizard.js +6 -4
  131. package/dist/src/commands/wizard.js.map +1 -1
  132. package/dist/src/commands/write-commands.d.ts +9 -3
  133. package/dist/src/commands/write-commands.js +127 -31
  134. package/dist/src/commands/write-commands.js.map +1 -1
  135. package/dist/src/constants.d.ts +7 -1
  136. package/dist/src/constants.js +7 -1
  137. package/dist/src/constants.js.map +1 -1
  138. package/dist/src/eval/manifest-v1.d.ts +71 -0
  139. package/dist/src/eval/manifest-v1.js +370 -0
  140. package/dist/src/eval/manifest-v1.js.map +1 -0
  141. package/dist/src/generators/local-plugin.d.ts +5 -1
  142. package/dist/src/generators/local-plugin.js +236 -109
  143. package/dist/src/generators/local-plugin.js.map +1 -1
  144. package/dist/src/index.d.ts +10 -4
  145. package/dist/src/index.js +1793 -486
  146. package/dist/src/index.js.map +1 -1
  147. package/dist/src/output/command-receipt.d.ts +43 -46
  148. package/dist/src/output/command-receipt.js +256 -80
  149. package/dist/src/output/command-receipt.js.map +1 -1
  150. package/dist/src/output/model.d.ts +3 -44
  151. package/dist/src/output/model.js +1 -144
  152. package/dist/src/output/model.js.map +1 -1
  153. package/dist/src/output/rebuild-progress.js +1 -13
  154. package/dist/src/output/rebuild-progress.js.map +1 -1
  155. package/dist/src/portable/commands.d.ts +46 -7
  156. package/dist/src/portable/commands.js +349 -37
  157. package/dist/src/portable/commands.js.map +1 -1
  158. package/dist/src/portable/materializer.d.ts +17 -4
  159. package/dist/src/portable/materializer.js +179 -41
  160. package/dist/src/portable/materializer.js.map +1 -1
  161. package/dist/src/portable/skills-cli.d.ts +15 -7
  162. package/dist/src/portable/skills-cli.js +74 -20
  163. package/dist/src/portable/skills-cli.js.map +1 -1
  164. package/dist/src/review/eval-source-input.d.ts +43 -0
  165. package/dist/src/review/eval-source-input.js +207 -0
  166. package/dist/src/review/eval-source-input.js.map +1 -0
  167. package/dist/src/review/review-profile.d.ts +17 -0
  168. package/dist/src/review/review-profile.js +234 -0
  169. package/dist/src/review/review-profile.js.map +1 -0
  170. package/dist/src/review/review-selection.d.ts +30 -0
  171. package/dist/src/review/review-selection.js +527 -0
  172. package/dist/src/review/review-selection.js.map +1 -0
  173. package/dist/src/review/review-types.d.ts +68 -0
  174. package/dist/src/review/review-types.js +16 -0
  175. package/dist/src/review/review-types.js.map +1 -0
  176. package/dist/src/review/skill-materialization.d.ts +13 -0
  177. package/dist/src/review/skill-materialization.js +75 -0
  178. package/dist/src/review/skill-materialization.js.map +1 -0
  179. package/dist/src/review/source-binding.d.ts +183 -0
  180. package/dist/src/review/source-binding.js +708 -0
  181. package/dist/src/review/source-binding.js.map +1 -0
  182. package/dist/src/tui/catalog-freshness.d.ts +1 -0
  183. package/dist/src/tui/catalog-freshness.js +2 -0
  184. package/dist/src/tui/catalog-freshness.js.map +1 -0
  185. package/dist/src/tui/catalog-generation.d.ts +21 -0
  186. package/dist/src/tui/catalog-generation.js +156 -0
  187. package/dist/src/tui/catalog-generation.js.map +1 -0
  188. package/dist/src/tui/catalog-sources/projection.d.ts +4 -0
  189. package/dist/src/tui/catalog-sources/projection.js +17 -0
  190. package/dist/src/tui/catalog-sources/projection.js.map +1 -0
  191. package/dist/src/tui/catalog-sources/review.d.ts +3 -0
  192. package/dist/src/tui/catalog-sources/review.js +13 -0
  193. package/dist/src/tui/catalog-sources/review.js.map +1 -0
  194. package/dist/src/tui/catalog-sources/screens.d.ts +12 -0
  195. package/dist/src/tui/catalog-sources/screens.js +40 -0
  196. package/dist/src/tui/catalog-sources/screens.js.map +1 -0
  197. package/dist/src/tui/catalog-sources/session.d.ts +32 -0
  198. package/dist/src/tui/catalog-sources/session.js +300 -0
  199. package/dist/src/tui/catalog-sources/session.js.map +1 -0
  200. package/dist/src/tui/catalog-sources/types.d.ts +54 -0
  201. package/dist/src/tui/catalog-sources/types.js +2 -0
  202. package/dist/src/tui/catalog-sources/types.js.map +1 -0
  203. package/dist/src/tui/catalog-store-task.d.ts +16 -0
  204. package/dist/src/tui/catalog-store-task.js +19 -0
  205. package/dist/src/tui/catalog-store-task.js.map +1 -0
  206. package/dist/src/tui/clipboard.d.ts +13 -0
  207. package/dist/src/tui/clipboard.js +95 -0
  208. package/dist/src/tui/clipboard.js.map +1 -0
  209. package/dist/src/tui/components.d.ts +110 -3
  210. package/dist/src/tui/components.js +183 -36
  211. package/dist/src/tui/components.js.map +1 -1
  212. package/dist/src/tui/config-array-draft.d.ts +29 -0
  213. package/dist/src/tui/config-array-draft.js +48 -0
  214. package/dist/src/tui/config-array-draft.js.map +1 -0
  215. package/dist/src/tui/config-leaf-editor.d.ts +16 -0
  216. package/dist/src/tui/config-leaf-editor.js +206 -0
  217. package/dist/src/tui/config-leaf-editor.js.map +1 -0
  218. package/dist/src/tui/config-value-presentation.d.ts +20 -0
  219. package/dist/src/tui/config-value-presentation.js +104 -0
  220. package/dist/src/tui/config-value-presentation.js.map +1 -0
  221. package/dist/src/tui/console-app-v4.d.ts +14 -4
  222. package/dist/src/tui/console-app-v4.js +8941 -1872
  223. package/dist/src/tui/console-app-v4.js.map +1 -1
  224. package/dist/src/tui/content-item-card.d.ts +13 -0
  225. package/dist/src/tui/content-item-card.js +51 -0
  226. package/dist/src/tui/content-item-card.js.map +1 -0
  227. package/dist/src/tui/controller-runtime.d.ts +10 -2
  228. package/dist/src/tui/controller-runtime.js +3211 -388
  229. package/dist/src/tui/controller-runtime.js.map +1 -1
  230. package/dist/src/tui/controller.d.ts +615 -45
  231. package/dist/src/tui/controller.js +3558 -768
  232. package/dist/src/tui/controller.js.map +1 -1
  233. package/dist/src/tui/dependency-graph-view.d.ts +39 -0
  234. package/dist/src/tui/dependency-graph-view.js +121 -0
  235. package/dist/src/tui/dependency-graph-view.js.map +1 -0
  236. package/dist/src/tui/dependency-graph.d.ts +81 -0
  237. package/dist/src/tui/dependency-graph.js +452 -0
  238. package/dist/src/tui/dependency-graph.js.map +1 -0
  239. package/dist/src/tui/diagnostic-projection.d.ts +23 -0
  240. package/dist/src/tui/diagnostic-projection.js +567 -0
  241. package/dist/src/tui/diagnostic-projection.js.map +1 -0
  242. package/dist/src/tui/diagnostics.d.ts +3 -3
  243. package/dist/src/tui/diagnostics.js +14 -2
  244. package/dist/src/tui/diagnostics.js.map +1 -1
  245. package/dist/src/tui/entity-cards.d.ts +55 -0
  246. package/dist/src/tui/entity-cards.js +220 -0
  247. package/dist/src/tui/entity-cards.js.map +1 -0
  248. package/dist/src/tui/glossary.d.ts +23 -0
  249. package/dist/src/tui/glossary.js +42 -0
  250. package/dist/src/tui/glossary.js.map +1 -0
  251. package/dist/src/tui/index.d.ts +6 -1
  252. package/dist/src/tui/index.js +5 -1
  253. package/dist/src/tui/index.js.map +1 -1
  254. package/dist/src/tui/input-display.d.ts +9 -0
  255. package/dist/src/tui/input-display.js +58 -0
  256. package/dist/src/tui/input-display.js.map +1 -0
  257. package/dist/src/tui/keys.d.ts +44 -0
  258. package/dist/src/tui/keys.js +43 -15
  259. package/dist/src/tui/keys.js.map +1 -1
  260. package/dist/src/tui/lifecycle-action-view.d.ts +6 -0
  261. package/dist/src/tui/lifecycle-action-view.js +36 -0
  262. package/dist/src/tui/lifecycle-action-view.js.map +1 -0
  263. package/dist/src/tui/model.d.ts +223 -31
  264. package/dist/src/tui/model.js +1510 -397
  265. package/dist/src/tui/model.js.map +1 -1
  266. package/dist/src/tui/operation-diagnostic-screens.d.ts +8 -0
  267. package/dist/src/tui/operation-diagnostic-screens.js +71 -0
  268. package/dist/src/tui/operation-diagnostic-screens.js.map +1 -0
  269. package/dist/src/tui/operation-history.d.ts +81 -0
  270. package/dist/src/tui/operation-history.js +136 -0
  271. package/dist/src/tui/operation-history.js.map +1 -0
  272. package/dist/src/tui/operation-review-planner.d.ts +21 -0
  273. package/dist/src/tui/operation-review-planner.js +1295 -0
  274. package/dist/src/tui/operation-review-planner.js.map +1 -0
  275. package/dist/src/tui/plugin-content.d.ts +31 -0
  276. package/dist/src/tui/plugin-content.js +680 -0
  277. package/dist/src/tui/plugin-content.js.map +1 -0
  278. package/dist/src/tui/plugin-detail.d.ts +52 -0
  279. package/dist/src/tui/plugin-detail.js +165 -0
  280. package/dist/src/tui/plugin-detail.js.map +1 -0
  281. package/dist/src/tui/plugin-write-task.d.ts +69 -0
  282. package/dist/src/tui/plugin-write-task.js +286 -0
  283. package/dist/src/tui/plugin-write-task.js.map +1 -0
  284. package/dist/src/tui/project-inventory.d.ts +68 -0
  285. package/dist/src/tui/project-inventory.js +203 -0
  286. package/dist/src/tui/project-inventory.js.map +1 -0
  287. package/dist/src/tui/prompt.js +4 -15
  288. package/dist/src/tui/prompt.js.map +1 -1
  289. package/dist/src/tui/query-header.d.ts +30 -0
  290. package/dist/src/tui/query-header.js +40 -0
  291. package/dist/src/tui/query-header.js.map +1 -0
  292. package/dist/src/tui/reader.d.ts +37 -0
  293. package/dist/src/tui/reader.js +47 -0
  294. package/dist/src/tui/reader.js.map +1 -0
  295. package/dist/src/tui/router.d.ts +197 -10
  296. package/dist/src/tui/router.js +338 -50
  297. package/dist/src/tui/router.js.map +1 -1
  298. package/dist/src/tui/screen-registry.d.ts +701 -0
  299. package/dist/src/tui/screen-registry.js +230 -0
  300. package/dist/src/tui/screen-registry.js.map +1 -0
  301. package/dist/src/tui/session-console-app.d.ts +6 -0
  302. package/dist/src/tui/session-console-app.js +13 -0
  303. package/dist/src/tui/session-console-app.js.map +1 -0
  304. package/dist/src/tui/session-host.d.ts +45 -0
  305. package/dist/src/tui/session-host.js +209 -0
  306. package/dist/src/tui/session-host.js.map +1 -0
  307. package/dist/src/tui/source-detail-card.d.ts +29 -0
  308. package/dist/src/tui/source-detail-card.js +45 -0
  309. package/dist/src/tui/source-detail-card.js.map +1 -0
  310. package/dist/src/tui/source-ref-presets.d.ts +3 -0
  311. package/dist/src/tui/source-ref-presets.js +11 -0
  312. package/dist/src/tui/source-ref-presets.js.map +1 -0
  313. package/dist/src/tui/theme.d.ts +12 -0
  314. package/dist/src/tui/theme.js +12 -0
  315. package/dist/src/tui/theme.js.map +1 -1
  316. package/dist/src/tui/viewport.d.ts +1 -0
  317. package/dist/src/tui/viewport.js +23 -0
  318. package/dist/src/tui/viewport.js.map +1 -1
  319. package/dist/src/tui/views.js +31 -3
  320. package/dist/src/tui/views.js.map +1 -1
  321. package/dist/src/tui/wizard.js +37 -13
  322. package/dist/src/tui/wizard.js.map +1 -1
  323. package/dist/src/types.d.ts +244 -20
  324. package/dist/src/types.js +1 -0
  325. package/dist/src/types.js.map +1 -1
  326. package/dist/src/utils/agent-version.d.ts +7 -1
  327. package/dist/src/utils/agent-version.js +41 -8
  328. package/dist/src/utils/agent-version.js.map +1 -1
  329. package/dist/src/utils/artifact-plan.d.ts +5 -4
  330. package/dist/src/utils/artifact-plan.js +18 -7
  331. package/dist/src/utils/artifact-plan.js.map +1 -1
  332. package/dist/src/utils/artifact-renderer.d.ts +17 -7
  333. package/dist/src/utils/artifact-renderer.js +214 -216
  334. package/dist/src/utils/artifact-renderer.js.map +1 -1
  335. package/dist/src/utils/artifact-request.d.ts +21 -0
  336. package/dist/src/utils/artifact-request.js +78 -0
  337. package/dist/src/utils/artifact-request.js.map +1 -0
  338. package/dist/src/utils/aw-home-mutation-lock.d.ts +1 -0
  339. package/dist/src/utils/aw-home-mutation-lock.js +32 -4
  340. package/dist/src/utils/aw-home-mutation-lock.js.map +1 -1
  341. package/dist/src/utils/bundle-integrity.d.ts +0 -1
  342. package/dist/src/utils/bundle-integrity.js +0 -25
  343. package/dist/src/utils/bundle-integrity.js.map +1 -1
  344. package/dist/src/utils/bundle-layout.js +22 -29
  345. package/dist/src/utils/bundle-layout.js.map +1 -1
  346. package/dist/src/utils/catalog-capability-projection.d.ts +8 -0
  347. package/dist/src/utils/catalog-capability-projection.js +14 -0
  348. package/dist/src/utils/catalog-capability-projection.js.map +1 -0
  349. package/dist/src/utils/catalog-digests.d.ts +10 -0
  350. package/dist/src/utils/catalog-digests.js +57 -20
  351. package/dist/src/utils/catalog-digests.js.map +1 -1
  352. package/dist/src/utils/catalog-generation-control-snapshot.d.ts +11 -0
  353. package/dist/src/utils/catalog-generation-control-snapshot.js +45 -0
  354. package/dist/src/utils/catalog-generation-control-snapshot.js.map +1 -0
  355. package/dist/src/utils/catalog-generation-error.d.ts +16 -0
  356. package/dist/src/utils/catalog-generation-error.js +30 -0
  357. package/dist/src/utils/catalog-generation-error.js.map +1 -0
  358. package/dist/src/utils/catalog-generation-resolver.d.ts +44 -0
  359. package/dist/src/utils/catalog-generation-resolver.js +273 -0
  360. package/dist/src/utils/catalog-generation-resolver.js.map +1 -0
  361. package/dist/src/utils/catalog-generation-service.d.ts +172 -0
  362. package/dist/src/utils/catalog-generation-service.js +1271 -0
  363. package/dist/src/utils/catalog-generation-service.js.map +1 -0
  364. package/dist/src/utils/catalog-generation-state.d.ts +22 -0
  365. package/dist/src/utils/catalog-generation-state.js +192 -0
  366. package/dist/src/utils/catalog-generation-state.js.map +1 -0
  367. package/dist/src/utils/catalog-generation-store.d.ts +58 -0
  368. package/dist/src/utils/catalog-generation-store.js +452 -0
  369. package/dist/src/utils/catalog-generation-store.js.map +1 -0
  370. package/dist/src/utils/catalog-manifest-v7.d.ts +5 -0
  371. package/dist/src/utils/{catalog-manifest-v4.js → catalog-manifest-v7.js} +35 -43
  372. package/dist/src/utils/catalog-manifest-v7.js.map +1 -0
  373. package/dist/src/utils/catalog-operation-context.d.ts +20 -0
  374. package/dist/src/utils/catalog-operation-context.js +142 -0
  375. package/dist/src/utils/catalog-operation-context.js.map +1 -0
  376. package/dist/src/utils/catalog-public-error.d.ts +7 -3
  377. package/dist/src/utils/catalog-public-error.js +28 -8
  378. package/dist/src/utils/catalog-public-error.js.map +1 -1
  379. package/dist/src/utils/catalog-runtime-projection.d.ts +3 -0
  380. package/dist/src/utils/catalog-runtime-projection.js +5 -40
  381. package/dist/src/utils/catalog-runtime-projection.js.map +1 -1
  382. package/dist/src/utils/catalog-snapshot.d.ts +5 -3
  383. package/dist/src/utils/catalog-snapshot.js +11 -3
  384. package/dist/src/utils/catalog-snapshot.js.map +1 -1
  385. package/dist/src/utils/catalog-source-identity.d.ts +1 -0
  386. package/dist/src/utils/catalog-source-identity.js +21 -2
  387. package/dist/src/utils/catalog-source-identity.js.map +1 -1
  388. package/dist/src/utils/catalog-source-impact.d.ts +21 -0
  389. package/dist/src/utils/catalog-source-impact.js +344 -0
  390. package/dist/src/utils/catalog-source-impact.js.map +1 -0
  391. package/dist/src/utils/catalog-source-references.d.ts +3 -2
  392. package/dist/src/utils/catalog-source-references.js +195 -347
  393. package/dist/src/utils/catalog-source-references.js.map +1 -1
  394. package/dist/src/utils/catalog-sources.d.ts +15 -1
  395. package/dist/src/utils/catalog-sources.js +206 -27
  396. package/dist/src/utils/catalog-sources.js.map +1 -1
  397. package/dist/src/utils/codex-config.d.ts +2 -0
  398. package/dist/src/utils/codex-config.js +26 -5
  399. package/dist/src/utils/codex-config.js.map +1 -1
  400. package/dist/src/utils/codex-manager.d.ts +79 -0
  401. package/dist/src/utils/codex-manager.js +747 -0
  402. package/dist/src/utils/codex-manager.js.map +1 -0
  403. package/dist/src/utils/codex-marketplace-path.d.ts +5 -0
  404. package/dist/src/utils/codex-marketplace-path.js +45 -0
  405. package/dist/src/utils/codex-marketplace-path.js.map +1 -0
  406. package/dist/src/utils/codex-native-observation.d.ts +49 -0
  407. package/dist/src/utils/codex-native-observation.js +154 -0
  408. package/dist/src/utils/codex-native-observation.js.map +1 -0
  409. package/dist/src/utils/codex-native-render-receipt.d.ts +40 -0
  410. package/dist/src/utils/codex-native-render-receipt.js +205 -0
  411. package/dist/src/utils/codex-native-render-receipt.js.map +1 -0
  412. package/dist/src/utils/codex-reconciler.d.ts +126 -0
  413. package/dist/src/utils/codex-reconciler.js +298 -0
  414. package/dist/src/utils/codex-reconciler.js.map +1 -0
  415. package/dist/src/utils/codex-shared-native.d.ts +43 -0
  416. package/dist/src/utils/codex-shared-native.js +81 -0
  417. package/dist/src/utils/codex-shared-native.js.map +1 -0
  418. package/dist/src/utils/codex-skill-staging.d.ts +2 -0
  419. package/dist/src/utils/codex-skill-staging.js.map +1 -1
  420. package/dist/src/utils/codex-surface-analysis.d.ts +46 -0
  421. package/dist/src/utils/codex-surface-analysis.js +247 -0
  422. package/dist/src/utils/codex-surface-analysis.js.map +1 -0
  423. package/dist/src/utils/dynamic-skill-tree.d.ts +4 -0
  424. package/dist/src/utils/dynamic-skill-tree.js +35 -5
  425. package/dist/src/utils/dynamic-skill-tree.js.map +1 -1
  426. package/dist/src/utils/git-catalog-provider.d.ts +16 -0
  427. package/dist/src/utils/git-catalog-provider.js +177 -145
  428. package/dist/src/utils/git-catalog-provider.js.map +1 -1
  429. package/dist/src/utils/local-marketplace.d.ts +18 -1
  430. package/dist/src/utils/local-marketplace.js +354 -84
  431. package/dist/src/utils/local-marketplace.js.map +1 -1
  432. package/dist/src/utils/manifest.d.ts +1 -3
  433. package/dist/src/utils/manifest.js +1 -3
  434. package/dist/src/utils/manifest.js.map +1 -1
  435. package/dist/src/utils/multi-source-catalog.d.ts +3 -9
  436. package/dist/src/utils/multi-source-catalog.js +54 -110
  437. package/dist/src/utils/multi-source-catalog.js.map +1 -1
  438. package/dist/src/utils/native-cli.d.ts +55 -7
  439. package/dist/src/utils/native-cli.js +400 -58
  440. package/dist/src/utils/native-cli.js.map +1 -1
  441. package/dist/src/utils/orphan-marketplace-cleanup.js +0 -4
  442. package/dist/src/utils/orphan-marketplace-cleanup.js.map +1 -1
  443. package/dist/src/utils/ownership.d.ts +84 -20
  444. package/dist/src/utils/ownership.js +179 -222
  445. package/dist/src/utils/ownership.js.map +1 -1
  446. package/dist/src/utils/path-catalog-provider.d.ts +1 -1
  447. package/dist/src/utils/path-catalog-provider.js +54 -65
  448. package/dist/src/utils/path-catalog-provider.js.map +1 -1
  449. package/dist/src/utils/paths.d.ts +0 -1
  450. package/dist/src/utils/paths.js +0 -1
  451. package/dist/src/utils/paths.js.map +1 -1
  452. package/dist/src/utils/plugin-config-impact.d.ts +33 -0
  453. package/dist/src/utils/plugin-config-impact.js +298 -0
  454. package/dist/src/utils/plugin-config-impact.js.map +1 -0
  455. package/dist/src/utils/plugin-config-write.d.ts +52 -27
  456. package/dist/src/utils/plugin-config-write.js +1000 -296
  457. package/dist/src/utils/plugin-config-write.js.map +1 -1
  458. package/dist/src/utils/plugin-config.d.ts +153 -93
  459. package/dist/src/utils/plugin-config.js +1116 -968
  460. package/dist/src/utils/plugin-config.js.map +1 -1
  461. package/dist/src/utils/plugin-intent-state.d.ts +49 -0
  462. package/dist/src/utils/plugin-intent-state.js +320 -0
  463. package/dist/src/utils/plugin-intent-state.js.map +1 -0
  464. package/dist/src/utils/plugin-scripts.d.ts +65 -125
  465. package/dist/src/utils/plugin-scripts.js +484 -524
  466. package/dist/src/utils/plugin-scripts.js.map +1 -1
  467. package/dist/src/utils/process-tree.d.ts +2 -2
  468. package/dist/src/utils/process-tree.js +1 -1
  469. package/dist/src/utils/process-tree.js.map +1 -1
  470. package/dist/src/utils/project-boundary.d.ts +11 -13
  471. package/dist/src/utils/project-boundary.js +28 -34
  472. package/dist/src/utils/project-boundary.js.map +1 -1
  473. package/dist/src/utils/runtime-config.d.ts +20 -0
  474. package/dist/src/utils/runtime-config.js +75 -0
  475. package/dist/src/utils/runtime-config.js.map +1 -0
  476. package/dist/src/utils/safe-fs.d.ts +21 -0
  477. package/dist/src/utils/safe-fs.js +111 -0
  478. package/dist/src/utils/safe-fs.js.map +1 -0
  479. package/dist/src/utils/safe-operation-diagnostic.d.ts +15 -0
  480. package/dist/src/utils/safe-operation-diagnostic.js +33 -0
  481. package/dist/src/utils/safe-operation-diagnostic.js.map +1 -0
  482. package/dist/src/utils/sensitive-content.d.ts +4 -0
  483. package/dist/src/utils/sensitive-content.js +36 -0
  484. package/dist/src/utils/sensitive-content.js.map +1 -0
  485. package/dist/src/utils/state-paths.js +7 -2
  486. package/dist/src/utils/state-paths.js.map +1 -1
  487. package/dist/src/utils/target-eligibility.d.ts +8 -2
  488. package/dist/src/utils/target-eligibility.js +17 -8
  489. package/dist/src/utils/target-eligibility.js.map +1 -1
  490. package/dist/src/utils/windows-claude-shim.d.ts +7 -0
  491. package/dist/src/utils/windows-claude-shim.js +10 -0
  492. package/dist/src/utils/windows-claude-shim.js.map +1 -0
  493. package/dist/src/utils/windows-npm-shim.d.ts +14 -0
  494. package/dist/src/utils/windows-npm-shim.js +140 -0
  495. package/dist/src/utils/windows-npm-shim.js.map +1 -0
  496. package/dist/vitest.config.js +92 -10
  497. package/dist/vitest.config.js.map +1 -1
  498. package/package.json +27 -18
  499. package/dist/authoring/scripts/check-plugin-versions.d.mts +0 -2
  500. package/dist/authoring/scripts/check-plugin-versions.mjs +0 -5
  501. package/dist/authoring/scripts/check-plugin-versions.mjs.map +0 -1
  502. package/dist/scripts/aw-skill-eval-engine.d.ts +0 -13
  503. package/dist/scripts/aw-skill-eval-engine.js +0 -31
  504. package/dist/scripts/aw-skill-eval-engine.js.map +0 -1
  505. package/dist/scripts/codex-eval-app-server.d.ts +0 -89
  506. package/dist/scripts/codex-eval-app-server.js +0 -1228
  507. package/dist/scripts/codex-eval-app-server.js.map +0 -1
  508. package/dist/scripts/codex-eval-isolation.d.ts +0 -61
  509. package/dist/scripts/codex-eval-isolation.js +0 -318
  510. package/dist/scripts/codex-eval-isolation.js.map +0 -1
  511. package/dist/scripts/codex-eval-process-management.d.ts +0 -8
  512. package/dist/scripts/codex-eval-process-management.js +0 -69
  513. package/dist/scripts/codex-eval-process-management.js.map +0 -1
  514. package/dist/scripts/codex-eval-process-tree.d.ts +0 -38
  515. package/dist/scripts/codex-eval-process-tree.js +0 -803
  516. package/dist/scripts/codex-eval-process-tree.js.map +0 -1
  517. package/dist/scripts/codex-eval-runtime-config.d.ts +0 -62
  518. package/dist/scripts/codex-eval-runtime-config.js +0 -843
  519. package/dist/scripts/codex-eval-runtime-config.js.map +0 -1
  520. package/dist/scripts/codex-trigger-eval.d.ts +0 -84
  521. package/dist/scripts/codex-trigger-eval.js +0 -968
  522. package/dist/scripts/codex-trigger-eval.js.map +0 -1
  523. package/dist/scripts/eval-plugin-skills-audited.d.ts +0 -6
  524. package/dist/scripts/eval-plugin-skills-audited.js +0 -261
  525. package/dist/scripts/eval-plugin-skills-audited.js.map +0 -1
  526. package/dist/scripts/eval-plugin-skills.d.ts +0 -45
  527. package/dist/scripts/eval-plugin-skills.js +0 -1586
  528. package/dist/scripts/eval-plugin-skills.js.map +0 -1
  529. package/dist/scripts/eval-run-layout.d.ts +0 -17
  530. package/dist/scripts/eval-run-layout.js +0 -26
  531. package/dist/scripts/eval-run-layout.js.map +0 -1
  532. package/dist/scripts/plugin-eval-contract.d.ts +0 -185
  533. package/dist/scripts/plugin-eval-contract.js +0 -695
  534. package/dist/scripts/plugin-eval-contract.js.map +0 -1
  535. package/dist/scripts/plugin-eval-materializer.d.ts +0 -13
  536. package/dist/scripts/plugin-eval-materializer.js +0 -421
  537. package/dist/scripts/plugin-eval-materializer.js.map +0 -1
  538. package/dist/scripts/skill-reporting.d.ts +0 -212
  539. package/dist/scripts/skill-reporting.js +0 -922
  540. package/dist/scripts/skill-reporting.js.map +0 -1
  541. package/dist/src/commands/status-v4.d.ts +0 -123
  542. package/dist/src/commands/status-v4.js +0 -905
  543. package/dist/src/commands/status-v4.js.map +0 -1
  544. package/dist/src/commands/status.d.ts +0 -93
  545. package/dist/src/commands/status.js +0 -442
  546. package/dist/src/commands/status.js.map +0 -1
  547. package/dist/src/utils/active-marketplace-runtime-lock.d.ts +0 -12
  548. package/dist/src/utils/active-marketplace-runtime-lock.js +0 -133
  549. package/dist/src/utils/active-marketplace-runtime-lock.js.map +0 -1
  550. package/dist/src/utils/catalog-manifest-v3.d.ts +0 -2
  551. package/dist/src/utils/catalog-manifest-v3.js +0 -3
  552. package/dist/src/utils/catalog-manifest-v3.js.map +0 -1
  553. package/dist/src/utils/catalog-manifest-v4.d.ts +0 -5
  554. package/dist/src/utils/catalog-manifest-v4.js.map +0 -1
  555. package/dist/src/utils/catalog-source-cache.d.ts +0 -62
  556. package/dist/src/utils/catalog-source-cache.js +0 -296
  557. package/dist/src/utils/catalog-source-cache.js.map +0 -1
  558. package/dist/src/utils/codex-project-surface.d.ts +0 -3
  559. package/dist/src/utils/codex-project-surface.js +0 -49
  560. package/dist/src/utils/codex-project-surface.js.map +0 -1
  561. package/dist/src/utils/lifecycle-active-store.d.ts +0 -175
  562. package/dist/src/utils/lifecycle-active-store.js +0 -1276
  563. package/dist/src/utils/lifecycle-active-store.js.map +0 -1
  564. package/dist/src/utils/plugin-release.d.ts +0 -2
  565. package/dist/src/utils/plugin-release.js +0 -2
  566. package/dist/src/utils/plugin-release.js.map +0 -1
@@ -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, assertPluginConfigMutationCandidate, 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,222 @@ 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({
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,
712
+ scope: options.scope,
713
+ cwd: options.cwd,
714
+ env: options.env,
715
+ visibleTargets: discovered?.targets ?? [],
716
+ mutation: {
717
+ kind: 'patch',
718
+ updates: requestedUpdates,
719
+ removeKeys: requestedRemoveKeys,
720
+ },
721
+ });
722
+ const updates = await coercePluginConfigUpdates({ schema, updates: requestedUpdates, cwd: options.cwd });
723
+ await assertPluginConfigMutationCandidate({
279
724
  ...configIdentity,
280
725
  pluginName,
726
+ manifest: schemaPlugin.manifest,
281
727
  scope: options.scope,
282
- projectLayer,
283
728
  cwd: options.cwd,
284
729
  env: options.env,
730
+ updates,
731
+ removeKeys: requestedRemoveKeys,
285
732
  });
286
733
  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(' '));
734
+ const { updatedKeys, removedKeys, staleRemovedKeys } = impact;
735
+ let preApplyUnavailableReason;
736
+ let preApplyUnavailableTargetResults = [];
737
+ let applyDiscovery = discovered
738
+ ? { targets: impact.affectedTargets, failures: discovered.failures }
739
+ : undefined;
740
+ const shouldApply = options.apply !== false && impact.storeChanged && !impact.noEffectiveChange;
741
+ if (shouldApply && pluginMayRunPreApply(schemaPlugin)) {
742
+ if (applyDiscovery) {
743
+ const preApplyAuthorization = await resolveConfigPreApplyAuthorization({
744
+ plugin: schemaPlugin,
745
+ scope: options.scope,
746
+ cwd: options.cwd,
747
+ env: options.env,
748
+ applyTargets: applyDiscovery.targets,
749
+ nativeCliRunner: options.nativeCliRunner,
750
+ rebuildRuntime: options.rebuildRuntime,
751
+ reinstallCommandImpl: options.reinstallCommandImpl,
752
+ });
753
+ if (preApplyAuthorization.targets.length > 0 && !preApplyAuthorizationIsConfirmed({
754
+ required: preApplyAuthorization.targets,
755
+ confirmed: options.preApplyConfirmed,
756
+ authorizedTargets: options.preApplyAuthorizedTargets,
757
+ })) {
758
+ throwPreApplyAuthorizationRequired(preApplyAuthorization.targets);
759
+ }
760
+ preApplyUnavailableTargetResults = preApplyAuthorization.unavailableTargetResults;
761
+ applyDiscovery = {
762
+ targets: preApplyAuthorization.availableApplyTargets,
763
+ failures: [...applyDiscovery.failures, ...preApplyUnavailableTargetResults],
764
+ };
765
+ if (applyDiscovery.targets.length === 0 && preApplyUnavailableTargetResults.length > 0) {
766
+ preApplyUnavailableReason = 'sourceUnavailable';
767
+ }
308
768
  }
309
769
  }
310
- if (changedKeys.length > 0) {
311
- await patchPluginConfigStore({
770
+ if (options.apply !== false
771
+ && options.scope === 'user'
772
+ && options.sharedNativeApplyConfirmed !== true
773
+ && impact.sharedNativeRenderTargets.length > 0
774
+ && impact.affectedTargets.some((target) => target.platform === 'codex')) {
775
+ throwSharedNativeApplyConfirmationRequired();
776
+ }
777
+ if (impact.storeChanged) {
778
+ try {
779
+ const write = await patchPluginConfigStore({
780
+ ...configIdentity,
781
+ pluginName,
782
+ scope: options.scope,
783
+ cwd: options.cwd,
784
+ env: options.env,
785
+ updates: Object.fromEntries(updatedKeys.map((key) => [key, updates[key]])),
786
+ removeKeys: requestedRemoveKeys,
787
+ schema,
788
+ });
789
+ warnings.push(...write.warnings);
790
+ }
791
+ catch (error) {
792
+ throw markConfigWriteFailed(error);
793
+ }
794
+ }
795
+ let effective;
796
+ try {
797
+ effective = summarizeEffectivePluginConfig(await resolveEffectivePluginConfig({
312
798
  ...configIdentity,
313
799
  pluginName,
314
- scope: options.scope,
315
- projectLayer,
800
+ manifest: schemaPlugin.manifest,
801
+ targetScope: options.scope,
316
802
  cwd: options.cwd,
317
803
  env: options.env,
318
- updates,
319
- removeKeys: requestedRemoveKeys,
320
- });
804
+ }));
321
805
  }
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,
806
+ catch {
807
+ const apply = unavailableApply('effectiveConfigUnavailable', 'effectiveConfig');
808
+ const otherProjectsMayRequireSync = options.scope === 'user' && impact.storeChanged;
809
+ if (otherProjectsMayRequireSync)
810
+ warnings.push(...otherProjectsWarning(options.scope));
811
+ return {
812
+ plugin: pluginName,
337
813
  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)
814
+ ...(schemaAccess.schema ? { schema: schemaAccess.schema } : {}),
815
+ updatedKeys,
816
+ removedKeys,
817
+ staleRemovedKeys,
818
+ configWrite: 'succeeded',
819
+ overallState: 'partial',
820
+ apply: publicConfigApplyResult(apply),
821
+ otherProjectsMayRequireSync,
822
+ warnings,
823
+ };
824
+ }
825
+ let apply;
826
+ try {
827
+ apply = !impact.storeChanged
828
+ ? skippedApply('noConfigChange')
829
+ : options.apply === false
830
+ ? skippedApply('notRequested')
831
+ : targetDiscoveryFailed
832
+ ? unavailableApply('targetDiscoveryFailed', 'targetDiscovery')
833
+ : impact.noEffectiveChange
834
+ && ((discovered?.targets.length ?? 0) > 0
835
+ || staleRemovedKeys.length === impact.changedKeys.length)
836
+ ? skippedApply('noEffectiveConfigChange')
837
+ : preApplyUnavailableReason
838
+ ? unavailableApply(preApplyUnavailableReason, preApplyUnavailableReason === 'sourceUnavailable' ? 'source' : 'targetDiscovery', preApplyUnavailableTargetResults)
839
+ : await applyConfigToVisibleTargets({
840
+ plugin: schemaPlugin,
841
+ scope: options.scope,
842
+ cwd: options.cwd,
843
+ env: options.env ?? process.env,
844
+ applyTargets: applyDiscovery?.targets ?? impact.affectedTargets,
845
+ nativeCliRunner: options.nativeCliRunner,
846
+ reinstallCommandImpl: options.reinstallCommandImpl,
847
+ rebuildRuntime: options.rebuildRuntime,
848
+ noVisibleTargetHasInvalidConfig: (discovered?.targets.length ?? 0) > 0
849
+ && effective.issues.length > 0,
850
+ preApplyConfirmed: options.preApplyConfirmed,
851
+ discovered: applyDiscovery,
852
+ });
853
+ }
854
+ catch (error) {
855
+ const failure = error instanceof Error ? error : new Error(String(error));
856
+ throw Object.assign(failure, { configWrite: 'succeeded' });
857
+ }
858
+ const otherProjectsMayRequireSync = options.scope === 'user' && impact.storeChanged;
859
+ if (otherProjectsMayRequireSync)
348
860
  warnings.push(...otherProjectsWarning(options.scope));
349
861
  return {
350
862
  plugin: pluginName,
351
863
  scope: options.scope,
352
- projectLayer,
353
864
  ...(schemaAccess.schema ? { schema: schemaAccess.schema } : {}),
354
865
  updatedKeys,
355
866
  removedKeys,
867
+ staleRemovedKeys,
356
868
  effective,
357
869
  configWrite: 'succeeded',
358
- overallState: applied.overallState,
359
- targetResults: applied.targetResults,
360
- ...(applied.applySkippedReason ? { applySkippedReason: applied.applySkippedReason } : {}),
361
- otherProjectsRequireReinstall,
870
+ overallState: overallStateForApply(apply),
871
+ apply: publicConfigApplyResult(apply),
872
+ otherProjectsMayRequireSync,
362
873
  warnings,
363
874
  };
364
875
  }
@@ -366,162 +877,356 @@ export async function applyPluginConfigWrite(options) {
366
877
  const requestedPluginName = options.pluginName ?? options.plugin?.manifest.name;
367
878
  if (!requestedPluginName)
368
879
  throw new Error('Plugin name is required for config write.');
369
- const pluginName = assertSafePluginConfigSegment(requestedPluginName);
880
+ assertSafePluginConfigSegment(requestedPluginName);
881
+ if (options.scope === 'project') {
882
+ const targetPath = resolvePluginConfigStorePath({
883
+ sourceId: options.plugin?.sourceId,
884
+ pluginName: requestedPluginName,
885
+ scope: 'project',
886
+ cwd: options.cwd,
887
+ env: options.env,
888
+ });
889
+ await assertProjectSharedConfigPathVisible({
890
+ cwd: options.cwd,
891
+ targetPath,
892
+ env: options.env,
893
+ });
894
+ }
370
895
  return withAwHomeMutationLock({
371
896
  env: options.env,
372
897
  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({
898
+ action: async (awHomeMutationToken) => {
899
+ await options.reviewPreflight?.();
900
+ try {
901
+ return await applyPluginConfigWriteUnlocked({
383
902
  ...options,
384
903
  awHomeMutationToken,
385
904
  rebuildRuntime: { ...options.rebuildRuntime, awHomeMutationToken },
386
905
  });
387
- },
388
- }),
906
+ }
907
+ catch (error) {
908
+ let sensitiveValues = options.plugin
909
+ ? collectSensitivePluginConfigValues(options.plugin.manifest, (options.request.updates ?? {}))
910
+ : [];
911
+ if (options.plugin) {
912
+ try {
913
+ const effective = await resolveEffectivePluginConfig({
914
+ ...(options.plugin.sourceId ? {
915
+ sourceId: options.plugin.sourceId,
916
+ sourceIdentity: options.plugin.sourceIdentity,
917
+ logicalIdentity: options.plugin.catalogLogicalIdentity,
918
+ } : {}),
919
+ pluginName: options.plugin.manifest.name,
920
+ manifest: options.plugin.manifest,
921
+ targetScope: options.scope,
922
+ cwd: options.cwd,
923
+ env: options.env,
924
+ });
925
+ sensitiveValues = [
926
+ ...sensitiveValues,
927
+ ...collectSensitivePluginConfigValues(options.plugin.manifest, effective.values),
928
+ ];
929
+ }
930
+ catch {
931
+ // Requested sensitive values and generic credential redaction remain available.
932
+ }
933
+ }
934
+ let message = redactPluginScriptOutput(error instanceof Error ? error.message : String(error), sensitiveValues);
935
+ message = message.split(options.cwd).join('<project>');
936
+ for (const scope of ['user', 'project']) {
937
+ const configPath = resolvePluginConfigStorePath({
938
+ sourceId: options.plugin?.sourceId,
939
+ pluginName: requestedPluginName,
940
+ scope,
941
+ cwd: options.cwd,
942
+ env: options.env,
943
+ });
944
+ message = message.split(configPath).join(`${scope}/plugin-config/${[
945
+ options.plugin?.sourceId,
946
+ requestedPluginName,
947
+ 'config.json',
948
+ ].filter(Boolean).join('/')}`);
949
+ }
950
+ const safeError = new Error(message);
951
+ const code = error.code;
952
+ safeError.code = typeof code === 'string' ? code
953
+ : message.startsWith('schemaVersionUnsupported:') ? 'schemaVersionUnsupported'
954
+ : 'configApplyFailed';
955
+ const configWrite = error.configWrite;
956
+ if (configWrite === 'succeeded' || configWriteStateForError(error) === 'failed') {
957
+ safeError.configWrite = configWrite === 'succeeded' ? 'succeeded' : 'failed';
958
+ }
959
+ if (error && typeof error === 'object' && 'operationDiagnostic' in error) {
960
+ safeError.operationDiagnostic = error.operationDiagnostic;
961
+ }
962
+ throw safeError;
963
+ }
964
+ },
389
965
  });
390
966
  }
391
967
  async function resetPluginConfigWithHelperUnlocked(options) {
392
968
  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 ? {
969
+ let configIdentity = options.plugin?.sourceId ? {
409
970
  sourceId: options.plugin.sourceId,
410
971
  sourceIdentity: options.plugin.sourceIdentity,
972
+ logicalIdentity: options.plugin.catalogLogicalIdentity,
973
+ } : options.sourceId ? {
974
+ sourceId: options.sourceId,
975
+ sourceIdentity: options.sourceIdentity,
976
+ logicalIdentity: options.logicalIdentity,
411
977
  } : {};
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,
978
+ if (options.sourceId && !options.sourceIdentity) {
979
+ try {
980
+ const identity = await readNamespacedPluginConfigStoreIdentity({
981
+ sourceId: options.sourceId,
448
982
  pluginName,
449
- manifest: schemaAccess.plugin.manifest,
983
+ scope: options.scope,
450
984
  cwd: options.cwd,
451
985
  env: options.env,
452
- }));
986
+ });
987
+ if (identity?.binding.kind === 'source')
988
+ configIdentity = {
989
+ sourceId: options.sourceId,
990
+ sourceIdentity: identity.binding.sourceIdentity,
991
+ };
992
+ if (identity?.binding.kind === 'catalog')
993
+ configIdentity = {
994
+ sourceId: options.sourceId,
995
+ logicalIdentity: identity.binding.logicalIdentity,
996
+ };
997
+ }
998
+ catch {
999
+ // Reset does not require a readable or valid envelope.
1000
+ }
1001
+ }
1002
+ let removedKeys = [];
1003
+ try {
1004
+ const store = await readPluginConfigStore({
1005
+ ...configIdentity,
1006
+ pluginName,
1007
+ scope: options.scope,
1008
+ cwd: options.cwd,
1009
+ env: options.env,
1010
+ });
1011
+ removedKeys = collectRemovedConfigKeys(store.values);
1012
+ }
1013
+ catch {
1014
+ // Reset is the final recovery boundary and does not require a readable store.
1015
+ }
1016
+ const warnings = [];
1017
+ let impact;
1018
+ let targetDiscoveryFailed = false;
1019
+ let visibleTargets = [];
1020
+ if (options.plugin) {
1021
+ if (options.apply !== false) {
1022
+ try {
1023
+ visibleTargets = (await resolveConfigApplyTargets({
1024
+ plugin: options.plugin,
1025
+ scope: options.scope,
1026
+ cwd: options.cwd,
1027
+ env: options.env ?? process.env,
1028
+ applyTargets: options.applyTargets,
1029
+ nativeCliRunner: options.nativeCliRunner,
1030
+ rebuildRuntime: options.rebuildRuntime,
1031
+ })).targets;
1032
+ }
1033
+ catch {
1034
+ targetDiscoveryFailed = true;
1035
+ }
453
1036
  }
454
- if (reset.deleted) {
455
- applied = await reinstallVisibleTargets({
456
- plugin: schemaAccess.plugin,
1037
+ try {
1038
+ impact = await analyzePluginConfigMutationImpact({
1039
+ plugin: options.plugin,
457
1040
  scope: options.scope,
458
1041
  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,
1042
+ env: options.env,
1043
+ visibleTargets,
1044
+ mutation: { kind: 'reset' },
464
1045
  });
1046
+ removedKeys = impact.removedKeys;
1047
+ }
1048
+ catch {
1049
+ // Reset remains available when its before state cannot be read.
1050
+ }
1051
+ }
1052
+ let preApplyUnavailableReason;
1053
+ let preApplyUnavailableTargetResults = [];
1054
+ let applyDiscovery = options.plugin && !targetDiscoveryFailed
1055
+ ? { targets: impact?.affectedTargets ?? visibleTargets, failures: [] }
1056
+ : undefined;
1057
+ if (options.plugin
1058
+ && options.apply !== false
1059
+ && impact?.storeChanged
1060
+ && !impact.noEffectiveChange
1061
+ && applyDiscovery
1062
+ && pluginMayRunPreApply(options.plugin)) {
1063
+ const preApplyAuthorization = await resolveConfigPreApplyAuthorization({
1064
+ plugin: options.plugin,
1065
+ scope: options.scope,
1066
+ cwd: options.cwd,
1067
+ env: options.env,
1068
+ applyTargets: applyDiscovery.targets,
1069
+ nativeCliRunner: options.nativeCliRunner,
1070
+ rebuildRuntime: options.rebuildRuntime,
1071
+ reinstallCommandImpl: options.reinstallCommandImpl,
1072
+ });
1073
+ if (preApplyAuthorization.targets.length > 0 && !preApplyAuthorizationIsConfirmed({
1074
+ required: preApplyAuthorization.targets,
1075
+ confirmed: options.preApplyConfirmed,
1076
+ authorizedTargets: options.preApplyAuthorizedTargets,
1077
+ })) {
1078
+ throwPreApplyAuthorizationRequired(preApplyAuthorization.targets);
1079
+ }
1080
+ preApplyUnavailableTargetResults = preApplyAuthorization.unavailableTargetResults;
1081
+ applyDiscovery = {
1082
+ targets: preApplyAuthorization.availableApplyTargets,
1083
+ failures: preApplyUnavailableTargetResults,
1084
+ };
1085
+ if (applyDiscovery.targets.length === 0 && preApplyUnavailableTargetResults.length > 0) {
1086
+ preApplyUnavailableReason = 'sourceUnavailable';
465
1087
  }
466
1088
  }
467
- const otherProjectsRequireReinstall = Boolean(schemaAccess.plugin)
1089
+ if (options.plugin
1090
+ && options.apply !== false
468
1091
  && options.scope === 'user'
469
- && reset.deleted;
470
- if (otherProjectsRequireReinstall)
1092
+ && options.sharedNativeApplyConfirmed !== true
1093
+ && (impact
1094
+ ? impact.sharedNativeRenderTargets.length > 0
1095
+ && impact.affectedTargets.some((target) => target.platform === 'codex')
1096
+ : pluginHasSharedNativeRefreshKeys(options.plugin))
1097
+ && visibleTargets.some((target) => target.platform === 'codex')) {
1098
+ throwSharedNativeApplyConfirmationRequired();
1099
+ }
1100
+ let reset;
1101
+ try {
1102
+ reset = await resetPluginConfigStore({
1103
+ ...configIdentity,
1104
+ pluginName,
1105
+ scope: options.scope,
1106
+ cwd: options.cwd,
1107
+ env: options.env,
1108
+ });
1109
+ }
1110
+ catch (error) {
1111
+ throw markConfigWriteFailed(error);
1112
+ }
1113
+ let schemaAccess;
1114
+ let apply = reset.deleted ? skippedApply('notRequested') : skippedApply('noConfigChange');
1115
+ let effective;
1116
+ if (options.plugin) {
1117
+ try {
1118
+ schemaAccess = await resolvePluginConfigSchemaAccess({
1119
+ pluginName,
1120
+ currentPlugin: options.plugin,
1121
+ scope: options.scope,
1122
+ cwd: options.cwd,
1123
+ env: options.env,
1124
+ });
1125
+ }
1126
+ catch {
1127
+ if (reset.deleted && options.apply !== false) {
1128
+ apply = unavailableApply('sourceUnavailable', 'source');
1129
+ }
1130
+ }
1131
+ const schemaPlugin = schemaAccess?.plugin;
1132
+ if (schemaPlugin?.manifest.config?.fields) {
1133
+ try {
1134
+ effective = summarizeEffectivePluginConfig(await resolveEffectivePluginConfig({
1135
+ ...configIdentity,
1136
+ pluginName,
1137
+ manifest: schemaPlugin.manifest,
1138
+ targetScope: options.scope,
1139
+ cwd: options.cwd,
1140
+ env: options.env,
1141
+ }));
1142
+ }
1143
+ catch {
1144
+ if (reset.deleted && options.apply !== false) {
1145
+ apply = unavailableApply('effectiveConfigUnavailable', 'effectiveConfig');
1146
+ }
1147
+ }
1148
+ if (reset.deleted
1149
+ && options.apply !== false
1150
+ && apply.state === 'skipped'
1151
+ && impact?.noEffectiveChange
1152
+ && visibleTargets.length > 0) {
1153
+ apply = skippedApply('noEffectiveConfigChange');
1154
+ }
1155
+ else if (reset.deleted
1156
+ && options.apply !== false
1157
+ && apply.state === 'skipped'
1158
+ && targetDiscoveryFailed) {
1159
+ apply = unavailableApply('targetDiscoveryFailed', 'targetDiscovery');
1160
+ }
1161
+ else if (reset.deleted && options.apply !== false && apply.state === 'skipped') {
1162
+ apply = preApplyUnavailableReason
1163
+ ? unavailableApply(preApplyUnavailableReason, 'source', preApplyUnavailableTargetResults)
1164
+ : await applyConfigToVisibleTargets({
1165
+ plugin: schemaPlugin,
1166
+ scope: options.scope,
1167
+ cwd: options.cwd,
1168
+ env: options.env ?? process.env,
1169
+ applyTargets: applyDiscovery?.targets ?? impact?.affectedTargets ?? options.applyTargets,
1170
+ nativeCliRunner: options.nativeCliRunner,
1171
+ reinstallCommandImpl: options.reinstallCommandImpl,
1172
+ rebuildRuntime: options.rebuildRuntime,
1173
+ noVisibleTargetHasInvalidConfig: (effective?.issues.length ?? 0) > 0,
1174
+ preApplyConfirmed: options.preApplyConfirmed,
1175
+ discovered: applyDiscovery,
1176
+ });
1177
+ }
1178
+ }
1179
+ else if (reset.deleted && options.apply !== false && apply.state === 'skipped') {
1180
+ apply = unavailableApply('schemaUnavailable', 'schema');
1181
+ }
1182
+ }
1183
+ else if (reset.deleted && options.apply !== false) {
1184
+ apply = options.pluginError
1185
+ ? unavailableApply('sourceUnavailable', 'source')
1186
+ : unavailableApply('schemaUnavailable', 'schema');
1187
+ }
1188
+ const otherProjectsMayRequireSync = options.scope === 'user' && reset.deleted;
1189
+ if (otherProjectsMayRequireSync)
471
1190
  warnings.push(...otherProjectsWarning(options.scope));
472
1191
  return {
473
1192
  plugin: pluginName,
474
1193
  scope: options.scope,
475
- projectLayer,
476
- ...(schemaAccess.schema ? { schema: schemaAccess.schema } : {}),
1194
+ ...(schemaAccess?.schema ? { schema: schemaAccess.schema } : {}),
477
1195
  existed: reset.existed,
478
1196
  deleted: reset.deleted,
1197
+ resetDisposition: reset.resetDisposition,
1198
+ ...(reset.quarantineBasename ? { quarantineBasename: reset.quarantineBasename } : {}),
479
1199
  removedKeys,
480
1200
  ...(effective ? { effective } : {}),
481
1201
  configWrite: 'succeeded',
482
- overallState: applied.overallState,
483
- targetResults: applied.targetResults,
484
- ...(applied.applySkippedReason ? { applySkippedReason: applied.applySkippedReason } : {}),
485
- otherProjectsRequireReinstall,
1202
+ overallState: overallStateForApply(apply),
1203
+ apply: publicConfigApplyResult(apply),
1204
+ otherProjectsMayRequireSync,
486
1205
  warnings,
487
1206
  };
488
1207
  }
489
1208
  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;
1209
+ assertSafePluginConfigSegment(options.pluginName);
495
1210
  return withAwHomeMutationLock({
496
1211
  env: options.env,
497
1212
  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
- }),
1213
+ action: async (awHomeMutationToken) => {
1214
+ await options.reviewPreflight?.();
1215
+ return resetPluginConfigWithHelperUnlocked({
1216
+ ...options,
1217
+ awHomeMutationToken,
1218
+ rebuildRuntime: { ...options.rebuildRuntime, awHomeMutationToken },
1219
+ });
1220
+ },
514
1221
  });
515
1222
  }
516
1223
  export async function describeResetAffectedFields(options) {
517
- const projectLayer = options.scope === 'project' ? (options.projectLayer ?? 'shared') : 'shared';
518
1224
  try {
519
1225
  const resolved = await resolveConfigRead({
520
1226
  pluginName: options.pluginName,
521
1227
  plugin: options.plugin,
522
1228
  ...(options.pluginError ? { pluginError: options.pluginError } : {}),
523
1229
  scope: options.scope,
524
- projectLayer,
525
1230
  cwd: options.cwd,
526
1231
  env: options.env,
527
1232
  });
@@ -532,7 +1237,6 @@ export async function describeResetAffectedFields(options) {
532
1237
  reserved: field.reserved,
533
1238
  action: 'reset',
534
1239
  scope: options.scope,
535
- projectLayer,
536
1240
  valueState: field.valueState,
537
1241
  }));
538
1242
  }
@@ -541,13 +1245,14 @@ export async function describeResetAffectedFields(options) {
541
1245
  ...(options.plugin?.sourceId ? {
542
1246
  sourceId: options.plugin.sourceId,
543
1247
  sourceIdentity: options.plugin.sourceIdentity,
1248
+ logicalIdentity: options.plugin.catalogLogicalIdentity,
544
1249
  } : options.sourceId ? {
545
1250
  sourceId: options.sourceId,
546
1251
  sourceIdentity: options.sourceIdentity,
1252
+ logicalIdentity: options.logicalIdentity,
547
1253
  } : {}),
548
1254
  pluginName: options.pluginName,
549
1255
  scope: options.scope,
550
- projectLayer,
551
1256
  cwd: options.cwd,
552
1257
  env: options.env,
553
1258
  });
@@ -558,7 +1263,6 @@ export async function describeResetAffectedFields(options) {
558
1263
  reserved: false,
559
1264
  action: 'reset',
560
1265
  scope: options.scope,
561
- projectLayer,
562
1266
  }));
563
1267
  }
564
1268
  }