@lesliechan721/aw 0.1.0-beta.9 → 0.1.0-beta.91

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 (829) hide show
  1. package/dist/authoring/assets/aw-config.mjs +100 -501
  2. package/dist/authoring/assets/aw-config.mjs.map +1 -1
  3. package/dist/authoring/assets/aw-runtime-config.d.mts +13 -0
  4. package/dist/authoring/assets/aw-runtime-config.mjs +221 -0
  5. package/dist/authoring/assets/aw-runtime-config.mjs.map +1 -0
  6. package/dist/authoring/assets/command-runtime-config.d.mts +9 -0
  7. package/dist/authoring/assets/command-runtime-config.mjs +134 -0
  8. package/dist/authoring/assets/command-runtime-config.mjs.map +1 -0
  9. package/dist/authoring/scripts/add-skill.mjs +15 -38
  10. package/dist/authoring/scripts/add-skill.mjs.map +1 -1
  11. package/dist/authoring/scripts/init-plugin.mjs +72 -96
  12. package/dist/authoring/scripts/init-plugin.mjs.map +1 -1
  13. package/dist/authoring/scripts/lib/plugin-root.mjs +4 -4
  14. package/dist/authoring/scripts/lib/plugin-root.mjs.map +1 -1
  15. package/dist/authoring/scripts/lib/plugin-version-check.d.mts +1 -0
  16. package/dist/authoring/scripts/lib/plugin-version-check.mjs +230 -9
  17. package/dist/authoring/scripts/lib/plugin-version-check.mjs.map +1 -1
  18. package/dist/authoring/scripts/lib/skill-scaffold.d.mts +2 -2
  19. package/dist/authoring/scripts/lib/skill-scaffold.mjs +4 -7
  20. package/dist/authoring/scripts/lib/skill-scaffold.mjs.map +1 -1
  21. package/dist/authoring/scripts/remove-plugin.mjs +1 -1
  22. package/dist/authoring/scripts/remove-plugin.mjs.map +1 -1
  23. package/dist/authoring/scripts/validate-plugin.mjs +416 -1995
  24. package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
  25. package/dist/authoring/scripts/validate-skill.mjs +1 -1
  26. package/dist/index.js +2 -6
  27. package/dist/index.js.map +1 -1
  28. package/dist/native-runtime/reader-runtime.mjs +34 -0
  29. package/dist/native-runtime/reader.d.mts +6 -0
  30. package/dist/native-runtime/reader.mjs +11 -0
  31. package/dist/scripts/aw-skill-eval-materializer.d.ts +11 -1
  32. package/dist/scripts/aw-skill-eval-materializer.js +118 -115
  33. package/dist/scripts/aw-skill-eval-materializer.js.map +1 -1
  34. package/dist/scripts/bundle-plugins.js +25 -7
  35. package/dist/scripts/bundle-plugins.js.map +1 -1
  36. package/dist/scripts/plugin-staging.d.ts +7 -7
  37. package/dist/scripts/plugin-staging.js +10 -8
  38. package/dist/scripts/plugin-staging.js.map +1 -1
  39. package/dist/scripts/plugin-test-reporter.d.mts +2 -0
  40. package/dist/scripts/plugin-test-reporter.mjs +21 -0
  41. package/dist/scripts/plugin-test-reporter.mjs.map +1 -0
  42. package/dist/scripts/test-plugin-scripts.d.ts +5 -0
  43. package/dist/scripts/test-plugin-scripts.js +284 -78
  44. package/dist/scripts/test-plugin-scripts.js.map +1 -1
  45. package/dist/scripts/test-workers.d.mts +24 -0
  46. package/dist/scripts/test-workers.mjs +59 -0
  47. package/dist/scripts/test-workers.mjs.map +1 -0
  48. package/dist/src/adapters/helpers.d.ts +7 -0
  49. package/dist/src/adapters/helpers.js.map +1 -1
  50. package/dist/src/authoring/workspace-commands.d.ts +3 -0
  51. package/dist/src/authoring/workspace-commands.js +7 -2
  52. package/dist/src/authoring/workspace-commands.js.map +1 -1
  53. package/dist/src/commands/aw-capabilities.d.ts +1 -1
  54. package/dist/src/commands/aw-capabilities.js +42 -21
  55. package/dist/src/commands/aw-capabilities.js.map +1 -1
  56. package/dist/src/commands/catalog-dev-source.d.ts +42 -3
  57. package/dist/src/commands/catalog-dev-source.js +351 -43
  58. package/dist/src/commands/catalog-dev-source.js.map +1 -1
  59. package/dist/src/commands/catalog-generation.d.ts +8 -0
  60. package/dist/src/commands/catalog-generation.js +1 -5
  61. package/dist/src/commands/catalog-generation.js.map +1 -1
  62. package/dist/src/commands/catalog-publication-inspection.d.ts +42 -3
  63. package/dist/src/commands/catalog-publication-inspection.js +379 -48
  64. package/dist/src/commands/catalog-publication-inspection.js.map +1 -1
  65. package/dist/src/commands/catalog-publication-journal.d.ts +23 -4
  66. package/dist/src/commands/catalog-publication-journal.js +165 -20
  67. package/dist/src/commands/catalog-publication-journal.js.map +1 -1
  68. package/dist/src/commands/catalog-publish.d.ts +34 -3
  69. package/dist/src/commands/catalog-publish.js +311 -165
  70. package/dist/src/commands/catalog-publish.js.map +1 -1
  71. package/dist/src/commands/catalog-source.d.ts +54 -8
  72. package/dist/src/commands/catalog-source.js +277 -15
  73. package/dist/src/commands/catalog-source.js.map +1 -1
  74. package/dist/src/commands/catalog-status.js +2 -2
  75. package/dist/src/commands/catalog-status.js.map +1 -1
  76. package/dist/src/commands/catalog-store.d.ts +104 -0
  77. package/dist/src/commands/catalog-store.js +685 -0
  78. package/dist/src/commands/catalog-store.js.map +1 -0
  79. package/dist/src/commands/catalog-workspace-resolution.d.ts +4 -0
  80. package/dist/src/commands/catalog-workspace-resolution.js +18 -3
  81. package/dist/src/commands/catalog-workspace-resolution.js.map +1 -1
  82. package/dist/src/commands/console.js +33 -20
  83. package/dist/src/commands/console.js.map +1 -1
  84. package/dist/src/commands/dependency-operation-plan.d.ts +14 -56
  85. package/dist/src/commands/dependency-operation-plan.js +90 -133
  86. package/dist/src/commands/dependency-operation-plan.js.map +1 -1
  87. package/dist/src/commands/deployment-confirmation.d.ts +11 -0
  88. package/dist/src/commands/deployment-confirmation.js +88 -0
  89. package/dist/src/commands/deployment-confirmation.js.map +1 -0
  90. package/dist/src/commands/init.js +1 -1
  91. package/dist/src/commands/init.js.map +1 -1
  92. package/dist/src/commands/intent-command.d.ts +34 -0
  93. package/dist/src/commands/intent-command.js +174 -0
  94. package/dist/src/commands/intent-command.js.map +1 -0
  95. package/dist/src/commands/lifecycle-command-package.d.ts +45 -0
  96. package/dist/src/commands/lifecycle-command-package.js +199 -0
  97. package/dist/src/commands/lifecycle-command-package.js.map +1 -0
  98. package/dist/src/commands/managed-commands.d.ts +41 -0
  99. package/dist/src/commands/managed-commands.js +404 -0
  100. package/dist/src/commands/managed-commands.js.map +1 -0
  101. package/dist/src/commands/offline-cleanup-evidence.d.ts +29 -3
  102. package/dist/src/commands/offline-cleanup-evidence.js +80 -10
  103. package/dist/src/commands/offline-cleanup-evidence.js.map +1 -1
  104. package/dist/src/commands/operation-plan.d.ts +191 -0
  105. package/dist/src/commands/operation-plan.js +96 -0
  106. package/dist/src/commands/operation-plan.js.map +1 -0
  107. package/dist/src/commands/operation-planner.d.ts +47 -0
  108. package/dist/src/commands/operation-planner.js +142 -0
  109. package/dist/src/commands/operation-planner.js.map +1 -0
  110. package/dist/src/commands/options.d.ts +11 -20
  111. package/dist/src/commands/options.js +31 -36
  112. package/dist/src/commands/options.js.map +1 -1
  113. package/dist/src/commands/permission-batch.d.ts +5 -0
  114. package/dist/src/commands/permission-batch.js +80 -0
  115. package/dist/src/commands/permission-batch.js.map +1 -0
  116. package/dist/src/commands/plugin-capabilities.js +96 -46
  117. package/dist/src/commands/plugin-capabilities.js.map +1 -1
  118. package/dist/src/commands/public-config-confirmation.d.ts +14 -0
  119. package/dist/src/commands/public-config-confirmation.js +73 -0
  120. package/dist/src/commands/public-config-confirmation.js.map +1 -0
  121. package/dist/src/commands/public-interruption.d.ts +9 -0
  122. package/dist/src/commands/public-interruption.js +23 -0
  123. package/dist/src/commands/public-interruption.js.map +1 -0
  124. package/dist/src/commands/public-lifecycle-result.d.ts +106 -0
  125. package/dist/src/commands/public-lifecycle-result.js +518 -0
  126. package/dist/src/commands/public-lifecycle-result.js.map +1 -0
  127. package/dist/src/commands/public-lifecycle.d.ts +27 -0
  128. package/dist/src/commands/public-lifecycle.js +563 -0
  129. package/dist/src/commands/public-lifecycle.js.map +1 -0
  130. package/dist/src/commands/public-plugin-query.d.ts +16 -0
  131. package/dist/src/commands/public-plugin-query.js +230 -0
  132. package/dist/src/commands/public-plugin-query.js.map +1 -0
  133. package/dist/src/commands/rebuild-command.d.ts +176 -25
  134. package/dist/src/commands/rebuild-command.js +3989 -1392
  135. package/dist/src/commands/rebuild-command.js.map +1 -1
  136. package/dist/src/commands/rebuild-integration.d.ts +133 -52
  137. package/dist/src/commands/rebuild-integration.js +1097 -2692
  138. package/dist/src/commands/rebuild-integration.js.map +1 -1
  139. package/dist/src/commands/rebuild-operations.d.ts +74 -23
  140. package/dist/src/commands/rebuild-operations.js +334 -227
  141. package/dist/src/commands/rebuild-operations.js.map +1 -1
  142. package/dist/src/commands/rebuild-platform-integration.d.ts +81 -0
  143. package/dist/src/commands/rebuild-platform-integration.js +1992 -0
  144. package/dist/src/commands/rebuild-platform-integration.js.map +1 -0
  145. package/dist/src/commands/reconcile-operation-plan.d.ts +31 -0
  146. package/dist/src/commands/reconcile-operation-plan.js +48 -0
  147. package/dist/src/commands/reconcile-operation-plan.js.map +1 -0
  148. package/dist/src/commands/review-inspection.d.ts +60 -0
  149. package/dist/src/commands/review-inspection.js +436 -0
  150. package/dist/src/commands/review-inspection.js.map +1 -0
  151. package/dist/src/commands/review-preparation.d.ts +51 -0
  152. package/dist/src/commands/review-preparation.js +400 -0
  153. package/dist/src/commands/review-preparation.js.map +1 -0
  154. package/dist/src/commands/runtime.d.ts +6 -6
  155. package/dist/src/commands/runtime.js +44 -24
  156. package/dist/src/commands/runtime.js.map +1 -1
  157. package/dist/src/commands/skill-eval.d.ts +8 -0
  158. package/dist/src/commands/skill-eval.js +126 -73
  159. package/dist/src/commands/skill-eval.js.map +1 -1
  160. package/dist/src/commands/status-v6.d.ts +185 -68
  161. package/dist/src/commands/status-v6.js +1592 -499
  162. package/dist/src/commands/status-v6.js.map +1 -1
  163. package/dist/src/commands/targets-command.d.ts +38 -0
  164. package/dist/src/commands/targets-command.js +182 -0
  165. package/dist/src/commands/targets-command.js.map +1 -0
  166. package/dist/src/commands/wizard.d.ts +8 -5
  167. package/dist/src/commands/wizard.js +7 -4
  168. package/dist/src/commands/wizard.js.map +1 -1
  169. package/dist/src/commands/write-commands.d.ts +9 -3
  170. package/dist/src/commands/write-commands.js +144 -44
  171. package/dist/src/commands/write-commands.js.map +1 -1
  172. package/dist/src/constants.d.ts +2 -3
  173. package/dist/src/constants.js +2 -3
  174. package/dist/src/constants.js.map +1 -1
  175. package/dist/src/eval/manifest-v1.d.ts +6 -2
  176. package/dist/src/eval/manifest-v1.js +58 -26
  177. package/dist/src/eval/manifest-v1.js.map +1 -1
  178. package/dist/src/generators/local-plugin.d.ts +4 -2
  179. package/dist/src/generators/local-plugin.js +207 -346
  180. package/dist/src/generators/local-plugin.js.map +1 -1
  181. package/dist/src/generators/permissions.d.ts +20 -2
  182. package/dist/src/generators/permissions.js +82 -15
  183. package/dist/src/generators/permissions.js.map +1 -1
  184. package/dist/src/index.d.ts +3 -33
  185. package/dist/src/index.js +1786 -1945
  186. package/dist/src/index.js.map +1 -1
  187. package/dist/src/intent/deployment-preferences.d.ts +63 -0
  188. package/dist/src/intent/deployment-preferences.js +170 -0
  189. package/dist/src/intent/deployment-preferences.js.map +1 -0
  190. package/dist/src/intent/diagnostics.d.ts +11 -0
  191. package/dist/src/intent/diagnostics.js +14 -0
  192. package/dist/src/intent/diagnostics.js.map +1 -0
  193. package/dist/src/intent/intent-codec.d.ts +19 -0
  194. package/dist/src/intent/intent-codec.js +117 -0
  195. package/dist/src/intent/intent-codec.js.map +1 -0
  196. package/dist/src/intent/intent-store.d.ts +43 -0
  197. package/dist/src/intent/intent-store.js +118 -0
  198. package/dist/src/intent/intent-store.js.map +1 -0
  199. package/dist/src/intent/scope-context.d.ts +35 -0
  200. package/dist/src/intent/scope-context.js +179 -0
  201. package/dist/src/intent/scope-context.js.map +1 -0
  202. package/dist/src/intent/work-context.d.ts +13 -0
  203. package/dist/src/intent/work-context.js +22 -0
  204. package/dist/src/intent/work-context.js.map +1 -0
  205. package/dist/src/output/command-receipt.d.ts +37 -86
  206. package/dist/src/output/command-receipt.js +257 -179
  207. package/dist/src/output/command-receipt.js.map +1 -1
  208. package/dist/src/output/component-delivery.d.ts +28 -0
  209. package/dist/src/output/component-delivery.js +138 -0
  210. package/dist/src/output/component-delivery.js.map +1 -0
  211. package/dist/src/output/public-result.d.ts +69 -0
  212. package/dist/src/output/public-result.js +403 -0
  213. package/dist/src/output/public-result.js.map +1 -0
  214. package/dist/src/output/rebuild-progress.d.ts +3 -0
  215. package/dist/src/output/rebuild-progress.js +34 -16
  216. package/dist/src/output/rebuild-progress.js.map +1 -1
  217. package/dist/src/output/receipt-projection.d.ts +7 -0
  218. package/dist/src/output/receipt-projection.js +664 -0
  219. package/dist/src/output/receipt-projection.js.map +1 -0
  220. package/dist/src/output/skill-invocation-notices.d.ts +18 -0
  221. package/dist/src/output/skill-invocation-notices.js +84 -0
  222. package/dist/src/output/skill-invocation-notices.js.map +1 -0
  223. package/dist/src/platforms/antigravity-permissions.d.ts +50 -0
  224. package/dist/src/platforms/antigravity-permissions.js +388 -0
  225. package/dist/src/platforms/antigravity-permissions.js.map +1 -0
  226. package/dist/src/platforms/capabilities.d.ts +17 -0
  227. package/dist/src/platforms/capabilities.js +328 -0
  228. package/dist/src/platforms/capabilities.js.map +1 -0
  229. package/dist/src/platforms/contracts.d.ts +402 -0
  230. package/dist/src/platforms/contracts.js +2 -0
  231. package/dist/src/platforms/contracts.js.map +1 -0
  232. package/dist/src/platforms/cursor-workspace-hook.d.ts +28 -0
  233. package/dist/src/platforms/cursor-workspace-hook.js +198 -0
  234. package/dist/src/platforms/cursor-workspace-hook.js.map +1 -0
  235. package/dist/src/platforms/discovery.d.ts +98 -0
  236. package/dist/src/platforms/discovery.js +777 -0
  237. package/dist/src/platforms/discovery.js.map +1 -0
  238. package/dist/src/platforms/grok-permission-config.d.ts +23 -0
  239. package/dist/src/platforms/grok-permission-config.js +184 -0
  240. package/dist/src/platforms/grok-permission-config.js.map +1 -0
  241. package/dist/src/platforms/grok-permission-document.d.ts +4 -0
  242. package/dist/src/platforms/grok-permission-document.js +145 -0
  243. package/dist/src/platforms/grok-permission-document.js.map +1 -0
  244. package/dist/src/platforms/grok-permissions.d.ts +17 -0
  245. package/dist/src/platforms/grok-permissions.js +311 -0
  246. package/dist/src/platforms/grok-permissions.js.map +1 -0
  247. package/dist/src/platforms/host-permission-policy.d.ts +38 -0
  248. package/dist/src/platforms/host-permission-policy.js +86 -0
  249. package/dist/src/platforms/host-permission-policy.js.map +1 -0
  250. package/dist/src/platforms/identity.d.ts +4 -0
  251. package/dist/src/platforms/identity.js +22 -0
  252. package/dist/src/platforms/identity.js.map +1 -0
  253. package/dist/src/platforms/inspection-grok.d.ts +4 -0
  254. package/dist/src/platforms/inspection-grok.js +366 -0
  255. package/dist/src/platforms/inspection-grok.js.map +1 -0
  256. package/dist/src/platforms/inspection-native.d.ts +6 -0
  257. package/dist/src/platforms/inspection-native.js +373 -0
  258. package/dist/src/platforms/inspection-native.js.map +1 -0
  259. package/dist/src/platforms/inspection-opencode.d.ts +4 -0
  260. package/dist/src/platforms/inspection-opencode.js +98 -0
  261. package/dist/src/platforms/inspection-opencode.js.map +1 -0
  262. package/dist/src/platforms/inspection-pi.d.ts +9 -0
  263. package/dist/src/platforms/inspection-pi.js +482 -0
  264. package/dist/src/platforms/inspection-pi.js.map +1 -0
  265. package/dist/src/platforms/inspection-query.d.ts +24 -0
  266. package/dist/src/platforms/inspection-query.js +119 -0
  267. package/dist/src/platforms/inspection-query.js.map +1 -0
  268. package/dist/src/platforms/inspection.d.ts +20 -0
  269. package/dist/src/platforms/inspection.js +259 -0
  270. package/dist/src/platforms/inspection.js.map +1 -0
  271. package/dist/src/platforms/layout.d.ts +35 -0
  272. package/dist/src/platforms/layout.js +317 -0
  273. package/dist/src/platforms/layout.js.map +1 -0
  274. package/dist/src/platforms/lifecycle-native-services.d.ts +3 -0
  275. package/dist/src/platforms/lifecycle-native-services.js +147 -0
  276. package/dist/src/platforms/lifecycle-native-services.js.map +1 -0
  277. package/dist/src/platforms/lifecycle-native.d.ts +14 -0
  278. package/dist/src/platforms/lifecycle-native.js +223 -0
  279. package/dist/src/platforms/lifecycle-native.js.map +1 -0
  280. package/dist/src/platforms/lifecycle.d.ts +27 -0
  281. package/dist/src/platforms/lifecycle.js +567 -0
  282. package/dist/src/platforms/lifecycle.js.map +1 -0
  283. package/dist/src/platforms/opencode-permission-config.d.ts +13 -0
  284. package/dist/src/platforms/opencode-permission-config.js +253 -0
  285. package/dist/src/platforms/opencode-permission-config.js.map +1 -0
  286. package/dist/src/platforms/opencode-permissions.d.ts +39 -0
  287. package/dist/src/platforms/opencode-permissions.js +212 -0
  288. package/dist/src/platforms/opencode-permissions.js.map +1 -0
  289. package/dist/src/platforms/opencode-related-permissions.d.ts +40 -0
  290. package/dist/src/platforms/opencode-related-permissions.js +177 -0
  291. package/dist/src/platforms/opencode-related-permissions.js.map +1 -0
  292. package/dist/src/platforms/permission-ownership.d.ts +89 -0
  293. package/dist/src/platforms/permission-ownership.js +543 -0
  294. package/dist/src/platforms/permission-ownership.js.map +1 -0
  295. package/dist/src/platforms/permission-sidecar.d.ts +70 -0
  296. package/dist/src/platforms/permission-sidecar.js +215 -0
  297. package/dist/src/platforms/permission-sidecar.js.map +1 -0
  298. package/dist/src/platforms/projection-code-extension.d.ts +8 -0
  299. package/dist/src/platforms/projection-code-extension.js +126 -0
  300. package/dist/src/platforms/projection-code-extension.js.map +1 -0
  301. package/dist/src/platforms/projection-command-resources.d.ts +7 -0
  302. package/dist/src/platforms/projection-command-resources.js +74 -0
  303. package/dist/src/platforms/projection-command-resources.js.map +1 -0
  304. package/dist/src/platforms/projection-files.d.ts +27 -0
  305. package/dist/src/platforms/projection-files.js +111 -0
  306. package/dist/src/platforms/projection-files.js.map +1 -0
  307. package/dist/src/platforms/projection-marketplace.d.ts +19 -0
  308. package/dist/src/platforms/projection-marketplace.js +42 -0
  309. package/dist/src/platforms/projection-marketplace.js.map +1 -0
  310. package/dist/src/platforms/projection.d.ts +13 -0
  311. package/dist/src/platforms/projection.js +576 -0
  312. package/dist/src/platforms/projection.js.map +1 -0
  313. package/dist/src/platforms/registry.d.ts +4 -0
  314. package/dist/src/platforms/registry.js +30 -0
  315. package/dist/src/platforms/registry.js.map +1 -0
  316. package/dist/src/platforms/supplement-layout.d.ts +20 -0
  317. package/dist/src/platforms/supplement-layout.js +53 -0
  318. package/dist/src/platforms/supplement-layout.js.map +1 -0
  319. package/dist/src/platforms/supplement-state.d.ts +13 -0
  320. package/dist/src/platforms/supplement-state.js +93 -0
  321. package/dist/src/platforms/supplement-state.js.map +1 -0
  322. package/dist/src/portable/commands.d.ts +58 -11
  323. package/dist/src/portable/commands.js +99 -345
  324. package/dist/src/portable/commands.js.map +1 -1
  325. package/dist/src/portable/historical-materialization.d.ts +22 -0
  326. package/dist/src/portable/historical-materialization.js +124 -0
  327. package/dist/src/portable/historical-materialization.js.map +1 -0
  328. package/dist/src/portable/materializer.d.ts +29 -1
  329. package/dist/src/portable/materializer.js +197 -258
  330. package/dist/src/portable/materializer.js.map +1 -1
  331. package/dist/src/portable/recovery-layout.d.ts +17 -0
  332. package/dist/src/portable/recovery-layout.js +42 -0
  333. package/dist/src/portable/recovery-layout.js.map +1 -0
  334. package/dist/src/portable/recovery.d.ts +176 -0
  335. package/dist/src/portable/recovery.js +556 -0
  336. package/dist/src/portable/recovery.js.map +1 -0
  337. package/dist/src/portable/writer.d.ts +67 -0
  338. package/dist/src/portable/writer.js +321 -0
  339. package/dist/src/portable/writer.js.map +1 -0
  340. package/dist/src/recovery/coordinator.d.ts +168 -0
  341. package/dist/src/recovery/coordinator.js +1558 -0
  342. package/dist/src/recovery/coordinator.js.map +1 -0
  343. package/dist/src/recovery/demand.d.ts +53 -0
  344. package/dist/src/recovery/demand.js +189 -0
  345. package/dist/src/recovery/demand.js.map +1 -0
  346. package/dist/src/recovery/install-concurrency.d.ts +48 -0
  347. package/dist/src/recovery/install-concurrency.js +196 -0
  348. package/dist/src/recovery/install-concurrency.js.map +1 -0
  349. package/dist/src/recovery/interruption.d.ts +19 -0
  350. package/dist/src/recovery/interruption.js +43 -0
  351. package/dist/src/recovery/interruption.js.map +1 -0
  352. package/dist/src/recovery/joint-coordinator.d.ts +46 -0
  353. package/dist/src/recovery/joint-coordinator.js +1641 -0
  354. package/dist/src/recovery/joint-coordinator.js.map +1 -0
  355. package/dist/src/recovery/joint-demand.d.ts +72 -0
  356. package/dist/src/recovery/joint-demand.js +332 -0
  357. package/dist/src/recovery/joint-demand.js.map +1 -0
  358. package/dist/src/recovery/joint-install-execution.d.ts +19 -0
  359. package/dist/src/recovery/joint-install-execution.js +308 -0
  360. package/dist/src/recovery/joint-install-execution.js.map +1 -0
  361. package/dist/src/recovery/joint-install-native-rebase.d.ts +4 -0
  362. package/dist/src/recovery/joint-install-native-rebase.js +67 -0
  363. package/dist/src/recovery/joint-install-native-rebase.js.map +1 -0
  364. package/dist/src/recovery/performance.d.ts +4 -0
  365. package/dist/src/recovery/performance.js +26 -0
  366. package/dist/src/recovery/performance.js.map +1 -0
  367. package/dist/src/recovery/receipt.d.ts +129 -0
  368. package/dist/src/recovery/receipt.js +91 -0
  369. package/dist/src/recovery/receipt.js.map +1 -0
  370. package/dist/src/recovery/retirement.d.ts +47 -0
  371. package/dist/src/recovery/retirement.js +463 -0
  372. package/dist/src/recovery/retirement.js.map +1 -0
  373. package/dist/src/recovery/status.d.ts +143 -0
  374. package/dist/src/recovery/status.js +1517 -0
  375. package/dist/src/recovery/status.js.map +1 -0
  376. package/dist/src/recovery/types.d.ts +85 -0
  377. package/dist/src/recovery/types.js +2 -0
  378. package/dist/src/recovery/types.js.map +1 -0
  379. package/dist/src/review/eval-source-input.d.ts +44 -0
  380. package/dist/src/review/eval-source-input.js +213 -0
  381. package/dist/src/review/eval-source-input.js.map +1 -0
  382. package/dist/src/review/platform-profile.d.ts +6 -0
  383. package/dist/src/review/platform-profile.js +24 -0
  384. package/dist/src/review/platform-profile.js.map +1 -0
  385. package/dist/src/review/review-profile.d.ts +20 -0
  386. package/dist/src/review/review-profile.js +276 -0
  387. package/dist/src/review/review-profile.js.map +1 -0
  388. package/dist/src/review/review-selection.d.ts +20 -0
  389. package/dist/src/review/review-selection.js +502 -0
  390. package/dist/src/review/review-selection.js.map +1 -0
  391. package/dist/src/review/review-types.d.ts +71 -0
  392. package/dist/src/review/review-types.js +16 -0
  393. package/dist/src/review/review-types.js.map +1 -0
  394. package/dist/src/review/skill-materialization.d.ts +65 -0
  395. package/dist/src/review/skill-materialization.js +228 -0
  396. package/dist/src/review/skill-materialization.js.map +1 -0
  397. package/dist/src/review/source-binding.d.ts +201 -0
  398. package/dist/src/review/source-binding.js +782 -0
  399. package/dist/src/review/source-binding.js.map +1 -0
  400. package/dist/src/tui/agent-management.d.ts +23 -0
  401. package/dist/src/tui/agent-management.js +319 -0
  402. package/dist/src/tui/agent-management.js.map +1 -0
  403. package/dist/src/tui/agent-settings.d.ts +47 -0
  404. package/dist/src/tui/agent-settings.js +97 -0
  405. package/dist/src/tui/agent-settings.js.map +1 -0
  406. package/dist/src/tui/catalog-freshness.d.ts +1 -0
  407. package/dist/src/tui/catalog-freshness.js +2 -0
  408. package/dist/src/tui/catalog-freshness.js.map +1 -0
  409. package/dist/src/tui/catalog-generation.d.ts +8 -16
  410. package/dist/src/tui/catalog-generation.js +97 -10
  411. package/dist/src/tui/catalog-generation.js.map +1 -1
  412. package/dist/src/tui/catalog-sources/projection.d.ts +4 -0
  413. package/dist/src/tui/catalog-sources/projection.js +17 -0
  414. package/dist/src/tui/catalog-sources/projection.js.map +1 -0
  415. package/dist/src/tui/catalog-sources/review.d.ts +3 -0
  416. package/dist/src/tui/catalog-sources/review.js +13 -0
  417. package/dist/src/tui/catalog-sources/review.js.map +1 -0
  418. package/dist/src/tui/catalog-sources/screens.d.ts +12 -0
  419. package/dist/src/tui/catalog-sources/screens.js +40 -0
  420. package/dist/src/tui/catalog-sources/screens.js.map +1 -0
  421. package/dist/src/tui/catalog-sources/session.d.ts +32 -0
  422. package/dist/src/tui/catalog-sources/session.js +300 -0
  423. package/dist/src/tui/catalog-sources/session.js.map +1 -0
  424. package/dist/src/tui/catalog-sources/types.d.ts +54 -0
  425. package/dist/src/tui/catalog-sources/types.js +2 -0
  426. package/dist/src/tui/catalog-sources/types.js.map +1 -0
  427. package/dist/src/tui/catalog-store-task.d.ts +16 -0
  428. package/dist/src/tui/catalog-store-task.js +19 -0
  429. package/dist/src/tui/catalog-store-task.js.map +1 -0
  430. package/dist/src/tui/clipboard.d.ts +13 -0
  431. package/dist/src/tui/clipboard.js +95 -0
  432. package/dist/src/tui/clipboard.js.map +1 -0
  433. package/dist/src/tui/components.d.ts +113 -3
  434. package/dist/src/tui/components.js +201 -34
  435. package/dist/src/tui/components.js.map +1 -1
  436. package/dist/src/tui/config-array-draft.d.ts +30 -0
  437. package/dist/src/tui/config-array-draft.js +51 -0
  438. package/dist/src/tui/config-array-draft.js.map +1 -0
  439. package/dist/src/tui/config-leaf-editor.d.ts +44 -0
  440. package/dist/src/tui/config-leaf-editor.js +227 -0
  441. package/dist/src/tui/config-leaf-editor.js.map +1 -0
  442. package/dist/src/tui/config-object-suggestions.d.ts +15 -0
  443. package/dist/src/tui/config-object-suggestions.js +71 -0
  444. package/dist/src/tui/config-object-suggestions.js.map +1 -0
  445. package/dist/src/tui/config-references.d.ts +38 -0
  446. package/dist/src/tui/config-references.js +82 -0
  447. package/dist/src/tui/config-references.js.map +1 -0
  448. package/dist/src/tui/config-suggestions.d.ts +27 -0
  449. package/dist/src/tui/config-suggestions.js +62 -0
  450. package/dist/src/tui/config-suggestions.js.map +1 -0
  451. package/dist/src/tui/config-value-presentation.d.ts +21 -0
  452. package/dist/src/tui/config-value-presentation.js +129 -0
  453. package/dist/src/tui/config-value-presentation.js.map +1 -0
  454. package/dist/src/tui/console-app-v4.d.ts +14 -5
  455. package/dist/src/tui/console-app-v4.js +10344 -2133
  456. package/dist/src/tui/console-app-v4.js.map +1 -1
  457. package/dist/src/tui/content-item-card.d.ts +13 -0
  458. package/dist/src/tui/content-item-card.js +51 -0
  459. package/dist/src/tui/content-item-card.js.map +1 -0
  460. package/dist/src/tui/controller-runtime.d.ts +8 -3
  461. package/dist/src/tui/controller-runtime.js +2301 -842
  462. package/dist/src/tui/controller-runtime.js.map +1 -1
  463. package/dist/src/tui/controller.d.ts +664 -79
  464. package/dist/src/tui/controller.js +3670 -830
  465. package/dist/src/tui/controller.js.map +1 -1
  466. package/dist/src/tui/dependency-graph-view.d.ts +39 -0
  467. package/dist/src/tui/dependency-graph-view.js +121 -0
  468. package/dist/src/tui/dependency-graph-view.js.map +1 -0
  469. package/dist/src/tui/dependency-graph.d.ts +81 -0
  470. package/dist/src/tui/dependency-graph.js +452 -0
  471. package/dist/src/tui/dependency-graph.js.map +1 -0
  472. package/dist/src/tui/deployment-view.d.ts +13 -0
  473. package/dist/src/tui/deployment-view.js +155 -0
  474. package/dist/src/tui/deployment-view.js.map +1 -0
  475. package/dist/src/tui/diagnostic-projection.d.ts +31 -0
  476. package/dist/src/tui/diagnostic-projection.js +681 -0
  477. package/dist/src/tui/diagnostic-projection.js.map +1 -0
  478. package/dist/src/tui/diagnostics.d.ts +6 -2
  479. package/dist/src/tui/diagnostics.js +14 -2
  480. package/dist/src/tui/diagnostics.js.map +1 -1
  481. package/dist/src/tui/entity-cards.d.ts +56 -0
  482. package/dist/src/tui/entity-cards.js +321 -0
  483. package/dist/src/tui/entity-cards.js.map +1 -0
  484. package/dist/src/tui/glossary.d.ts +25 -0
  485. package/dist/src/tui/glossary.js +78 -0
  486. package/dist/src/tui/glossary.js.map +1 -0
  487. package/dist/src/tui/guided-setup.d.ts +25 -0
  488. package/dist/src/tui/guided-setup.js +101 -0
  489. package/dist/src/tui/guided-setup.js.map +1 -0
  490. package/dist/src/tui/index.d.ts +5 -1
  491. package/dist/src/tui/index.js +4 -1
  492. package/dist/src/tui/index.js.map +1 -1
  493. package/dist/src/tui/input-display.d.ts +1 -0
  494. package/dist/src/tui/input-display.js +23 -1
  495. package/dist/src/tui/input-display.js.map +1 -1
  496. package/dist/src/tui/keys.d.ts +44 -0
  497. package/dist/src/tui/keys.js +43 -15
  498. package/dist/src/tui/keys.js.map +1 -1
  499. package/dist/src/tui/lifecycle-action-view.d.ts +6 -0
  500. package/dist/src/tui/lifecycle-action-view.js +36 -0
  501. package/dist/src/tui/lifecycle-action-view.js.map +1 -0
  502. package/dist/src/tui/model.d.ts +187 -52
  503. package/dist/src/tui/model.js +1202 -426
  504. package/dist/src/tui/model.js.map +1 -1
  505. package/dist/src/tui/operation-diagnostic-screens.d.ts +8 -0
  506. package/dist/src/tui/operation-diagnostic-screens.js +76 -0
  507. package/dist/src/tui/operation-diagnostic-screens.js.map +1 -0
  508. package/dist/src/tui/operation-history.d.ts +91 -0
  509. package/dist/src/tui/operation-history.js +167 -0
  510. package/dist/src/tui/operation-history.js.map +1 -0
  511. package/dist/src/tui/operation-review-planner.d.ts +28 -0
  512. package/dist/src/tui/operation-review-planner.js +1456 -0
  513. package/dist/src/tui/operation-review-planner.js.map +1 -0
  514. package/dist/src/tui/plugin-content.d.ts +33 -0
  515. package/dist/src/tui/plugin-content.js +245 -0
  516. package/dist/src/tui/plugin-content.js.map +1 -0
  517. package/dist/src/tui/plugin-detail.d.ts +75 -0
  518. package/dist/src/tui/plugin-detail.js +267 -0
  519. package/dist/src/tui/plugin-detail.js.map +1 -0
  520. package/dist/src/tui/plugin-write-task.d.ts +69 -0
  521. package/dist/src/tui/plugin-write-task.js +286 -0
  522. package/dist/src/tui/plugin-write-task.js.map +1 -0
  523. package/dist/src/tui/prompt.js +4 -15
  524. package/dist/src/tui/prompt.js.map +1 -1
  525. package/dist/src/tui/query-header.d.ts +30 -0
  526. package/dist/src/tui/query-header.js +40 -0
  527. package/dist/src/tui/query-header.js.map +1 -0
  528. package/dist/src/tui/reader.d.ts +38 -0
  529. package/dist/src/tui/reader.js +49 -0
  530. package/dist/src/tui/reader.js.map +1 -0
  531. package/dist/src/tui/router.d.ts +182 -39
  532. package/dist/src/tui/router.js +338 -50
  533. package/dist/src/tui/router.js.map +1 -1
  534. package/dist/src/tui/scoped-flow.d.ts +49 -0
  535. package/dist/src/tui/scoped-flow.js +212 -0
  536. package/dist/src/tui/scoped-flow.js.map +1 -0
  537. package/dist/src/tui/scoped-inventory.d.ts +131 -0
  538. package/dist/src/tui/scoped-inventory.js +280 -0
  539. package/dist/src/tui/scoped-inventory.js.map +1 -0
  540. package/dist/src/tui/screen-registry.d.ts +696 -0
  541. package/dist/src/tui/screen-registry.js +226 -0
  542. package/dist/src/tui/screen-registry.js.map +1 -0
  543. package/dist/src/tui/session-console-app.d.ts +8 -0
  544. package/dist/src/tui/session-console-app.js +24 -0
  545. package/dist/src/tui/session-console-app.js.map +1 -0
  546. package/dist/src/tui/session-host.d.ts +45 -0
  547. package/dist/src/tui/session-host.js +219 -0
  548. package/dist/src/tui/session-host.js.map +1 -0
  549. package/dist/src/tui/source-detail-card.d.ts +29 -0
  550. package/dist/src/tui/source-detail-card.js +45 -0
  551. package/dist/src/tui/source-detail-card.js.map +1 -0
  552. package/dist/src/tui/theme.d.ts +12 -0
  553. package/dist/src/tui/theme.js +12 -0
  554. package/dist/src/tui/theme.js.map +1 -1
  555. package/dist/src/tui/viewport.d.ts +1 -0
  556. package/dist/src/tui/viewport.js +23 -0
  557. package/dist/src/tui/viewport.js.map +1 -1
  558. package/dist/src/tui/wizard.js +37 -13
  559. package/dist/src/tui/wizard.js.map +1 -1
  560. package/dist/src/types.d.ts +177 -85
  561. package/dist/src/types.js +1 -0
  562. package/dist/src/types.js.map +1 -1
  563. package/dist/src/utils/agent-version.d.ts +10 -4
  564. package/dist/src/utils/agent-version.js +6 -8
  565. package/dist/src/utils/agent-version.js.map +1 -1
  566. package/dist/src/utils/artifact-plan.d.ts +17 -24
  567. package/dist/src/utils/artifact-plan.js +59 -436
  568. package/dist/src/utils/artifact-plan.js.map +1 -1
  569. package/dist/src/utils/artifact-renderer.d.ts +61 -89
  570. package/dist/src/utils/artifact-renderer.js +187 -364
  571. package/dist/src/utils/artifact-renderer.js.map +1 -1
  572. package/dist/src/utils/artifact-request.d.ts +21 -0
  573. package/dist/src/utils/artifact-request.js +57 -0
  574. package/dist/src/utils/artifact-request.js.map +1 -0
  575. package/dist/src/utils/artifact-sources.d.ts +4 -8
  576. package/dist/src/utils/artifact-sources.js +15 -6
  577. package/dist/src/utils/artifact-sources.js.map +1 -1
  578. package/dist/src/utils/aw-home-mutation-lock.js +2 -1
  579. package/dist/src/utils/aw-home-mutation-lock.js.map +1 -1
  580. package/dist/src/utils/bundle-layout.js +59 -173
  581. package/dist/src/utils/bundle-layout.js.map +1 -1
  582. package/dist/src/utils/catalog-capability-projection.d.ts +8 -0
  583. package/dist/src/utils/catalog-capability-projection.js +14 -0
  584. package/dist/src/utils/catalog-capability-projection.js.map +1 -0
  585. package/dist/src/utils/catalog-digests.d.ts +2 -9
  586. package/dist/src/utils/catalog-digests.js +7 -45
  587. package/dist/src/utils/catalog-digests.js.map +1 -1
  588. package/dist/src/utils/catalog-generation-error.d.ts +4 -1
  589. package/dist/src/utils/catalog-generation-error.js +2 -0
  590. package/dist/src/utils/catalog-generation-error.js.map +1 -1
  591. package/dist/src/utils/catalog-generation-resolver.d.ts +32 -3
  592. package/dist/src/utils/catalog-generation-resolver.js +182 -40
  593. package/dist/src/utils/catalog-generation-resolver.js.map +1 -1
  594. package/dist/src/utils/catalog-generation-service.d.ts +142 -2
  595. package/dist/src/utils/catalog-generation-service.js +1146 -171
  596. package/dist/src/utils/catalog-generation-service.js.map +1 -1
  597. package/dist/src/utils/catalog-generation-state.d.ts +5 -0
  598. package/dist/src/utils/catalog-generation-state.js +25 -1
  599. package/dist/src/utils/catalog-generation-state.js.map +1 -1
  600. package/dist/src/utils/catalog-generation-store.d.ts +29 -2
  601. package/dist/src/utils/catalog-generation-store.js +240 -36
  602. package/dist/src/utils/catalog-generation-store.js.map +1 -1
  603. package/dist/src/utils/catalog-manifest-v7.d.ts +5 -0
  604. package/dist/src/utils/{catalog-manifest-v6.js → catalog-manifest-v7.js} +23 -23
  605. package/dist/src/utils/{catalog-manifest-v6.js.map → catalog-manifest-v7.js.map} +1 -1
  606. package/dist/src/utils/catalog-operation-context.d.ts +27 -3
  607. package/dist/src/utils/catalog-operation-context.js +75 -4
  608. package/dist/src/utils/catalog-operation-context.js.map +1 -1
  609. package/dist/src/utils/catalog-public-error.js +7 -0
  610. package/dist/src/utils/catalog-public-error.js.map +1 -1
  611. package/dist/src/utils/catalog-runtime-projection.d.ts +4 -3
  612. package/dist/src/utils/catalog-runtime-projection.js.map +1 -1
  613. package/dist/src/utils/catalog-snapshot.d.ts +5 -2
  614. package/dist/src/utils/catalog-snapshot.js +4 -1
  615. package/dist/src/utils/catalog-snapshot.js.map +1 -1
  616. package/dist/src/utils/catalog-source-impact.d.ts +21 -0
  617. package/dist/src/utils/catalog-source-impact.js +344 -0
  618. package/dist/src/utils/catalog-source-impact.js.map +1 -0
  619. package/dist/src/utils/catalog-source-references.d.ts +22 -8
  620. package/dist/src/utils/catalog-source-references.js +457 -365
  621. package/dist/src/utils/catalog-source-references.js.map +1 -1
  622. package/dist/src/utils/catalog-sources.d.ts +14 -1
  623. package/dist/src/utils/catalog-sources.js +155 -11
  624. package/dist/src/utils/catalog-sources.js.map +1 -1
  625. package/dist/src/utils/codex-executable-discovery.d.ts +28 -0
  626. package/dist/src/utils/codex-executable-discovery.js +431 -0
  627. package/dist/src/utils/codex-executable-discovery.js.map +1 -0
  628. package/dist/src/utils/codex-manager.d.ts +23 -42
  629. package/dist/src/utils/codex-manager.js +79 -767
  630. package/dist/src/utils/codex-manager.js.map +1 -1
  631. package/dist/src/utils/codex-marketplace-path.d.ts +5 -0
  632. package/dist/src/utils/codex-marketplace-path.js +45 -0
  633. package/dist/src/utils/codex-marketplace-path.js.map +1 -0
  634. package/dist/src/utils/codex-native-observation.d.ts +55 -0
  635. package/dist/src/utils/codex-native-observation.js +198 -0
  636. package/dist/src/utils/codex-native-observation.js.map +1 -0
  637. package/dist/src/utils/codex-reconciler.d.ts +6 -14
  638. package/dist/src/utils/codex-reconciler.js +45 -50
  639. package/dist/src/utils/codex-reconciler.js.map +1 -1
  640. package/dist/src/utils/codex-shared-native.d.ts +28 -39
  641. package/dist/src/utils/codex-shared-native.js +92 -57
  642. package/dist/src/utils/codex-shared-native.js.map +1 -1
  643. package/dist/src/utils/codex-skill-staging.d.ts +4 -3
  644. package/dist/src/utils/codex-skill-staging.js.map +1 -1
  645. package/dist/src/utils/codex-skills-root.d.ts +4 -0
  646. package/dist/src/utils/codex-skills-root.js +25 -0
  647. package/dist/src/utils/codex-skills-root.js.map +1 -0
  648. package/dist/src/utils/codex-surface-analysis.d.ts +8 -3
  649. package/dist/src/utils/codex-surface-analysis.js +35 -62
  650. package/dist/src/utils/codex-surface-analysis.js.map +1 -1
  651. package/dist/src/utils/component-command-preparation.d.ts +31 -0
  652. package/dist/src/utils/component-command-preparation.js +127 -0
  653. package/dist/src/utils/component-command-preparation.js.map +1 -0
  654. package/dist/src/utils/component-gap.d.ts +4 -0
  655. package/dist/src/utils/component-gap.js +20 -0
  656. package/dist/src/utils/component-gap.js.map +1 -0
  657. package/dist/src/utils/component-resources.d.ts +51 -0
  658. package/dist/src/utils/component-resources.js +320 -0
  659. package/dist/src/utils/component-resources.js.map +1 -0
  660. package/dist/src/utils/config-platforms.d.ts +21 -0
  661. package/dist/src/utils/config-platforms.js +51 -0
  662. package/dist/src/utils/config-platforms.js.map +1 -0
  663. package/dist/src/utils/dynamic-skill-tree.d.ts +18 -6
  664. package/dist/src/utils/dynamic-skill-tree.js +33 -40
  665. package/dist/src/utils/dynamic-skill-tree.js.map +1 -1
  666. package/dist/src/utils/git-catalog-provider.d.ts +16 -0
  667. package/dist/src/utils/git-catalog-provider.js +112 -6
  668. package/dist/src/utils/git-catalog-provider.js.map +1 -1
  669. package/dist/src/utils/inventory-recovery-diagnostic.d.ts +4 -0
  670. package/dist/src/utils/inventory-recovery-diagnostic.js +15 -0
  671. package/dist/src/utils/inventory-recovery-diagnostic.js.map +1 -0
  672. package/dist/src/utils/local-marketplace.d.ts +17 -12
  673. package/dist/src/utils/local-marketplace.js +85 -195
  674. package/dist/src/utils/local-marketplace.js.map +1 -1
  675. package/dist/src/utils/managed-command-cli-review.d.ts +53 -0
  676. package/dist/src/utils/managed-command-cli-review.js +431 -0
  677. package/dist/src/utils/managed-command-cli-review.js.map +1 -0
  678. package/dist/src/utils/managed-command-closure.d.ts +14 -0
  679. package/dist/src/utils/managed-command-closure.js +156 -0
  680. package/dist/src/utils/managed-command-closure.js.map +1 -0
  681. package/dist/src/utils/managed-command-errors.d.ts +5 -0
  682. package/dist/src/utils/managed-command-errors.js +10 -0
  683. package/dist/src/utils/managed-command-errors.js.map +1 -0
  684. package/dist/src/utils/managed-command-materialization.d.ts +90 -0
  685. package/dist/src/utils/managed-command-materialization.js +375 -0
  686. package/dist/src/utils/managed-command-materialization.js.map +1 -0
  687. package/dist/src/utils/managed-command-preparation.d.ts +30 -0
  688. package/dist/src/utils/managed-command-preparation.js +39 -0
  689. package/dist/src/utils/managed-command-preparation.js.map +1 -0
  690. package/dist/src/utils/managed-command-review.d.ts +33 -0
  691. package/dist/src/utils/managed-command-review.js +80 -0
  692. package/dist/src/utils/managed-command-review.js.map +1 -0
  693. package/dist/src/utils/managed-command-runtime.d.ts +36 -0
  694. package/dist/src/utils/managed-command-runtime.js +126 -0
  695. package/dist/src/utils/managed-command-runtime.js.map +1 -0
  696. package/dist/src/utils/managed-command-snapshots.d.ts +24 -0
  697. package/dist/src/utils/managed-command-snapshots.js +89 -0
  698. package/dist/src/utils/managed-command-snapshots.js.map +1 -0
  699. package/dist/src/utils/managed-command-store.d.ts +141 -0
  700. package/dist/src/utils/managed-command-store.js +839 -0
  701. package/dist/src/utils/managed-command-store.js.map +1 -0
  702. package/dist/src/utils/multi-source-catalog.d.ts +4 -0
  703. package/dist/src/utils/multi-source-catalog.js +7 -3
  704. package/dist/src/utils/multi-source-catalog.js.map +1 -1
  705. package/dist/src/utils/native-cli-interruption.d.ts +8 -0
  706. package/dist/src/utils/native-cli-interruption.js +65 -0
  707. package/dist/src/utils/native-cli-interruption.js.map +1 -0
  708. package/dist/src/utils/native-cli.d.ts +37 -6
  709. package/dist/src/utils/native-cli.js +523 -60
  710. package/dist/src/utils/native-cli.js.map +1 -1
  711. package/dist/src/utils/native-demand.d.ts +29 -0
  712. package/dist/src/utils/native-demand.js +4 -0
  713. package/dist/src/utils/native-demand.js.map +1 -0
  714. package/dist/src/utils/native-tool-context.d.ts +17 -0
  715. package/dist/src/utils/native-tool-context.js +40 -0
  716. package/dist/src/utils/native-tool-context.js.map +1 -0
  717. package/dist/src/utils/native-tool-review.d.ts +8 -0
  718. package/dist/src/utils/native-tool-review.js +14 -0
  719. package/dist/src/utils/native-tool-review.js.map +1 -0
  720. package/dist/src/utils/orphan-marketplace-cleanup.js +0 -2
  721. package/dist/src/utils/orphan-marketplace-cleanup.js.map +1 -1
  722. package/dist/src/utils/ownership.d.ts +111 -11
  723. package/dist/src/utils/ownership.js +247 -126
  724. package/dist/src/utils/ownership.js.map +1 -1
  725. package/dist/src/utils/package-content.d.ts +7 -0
  726. package/dist/src/utils/package-content.js +70 -0
  727. package/dist/src/utils/package-content.js.map +1 -0
  728. package/dist/src/utils/path-catalog-provider.js +2 -0
  729. package/dist/src/utils/path-catalog-provider.js.map +1 -1
  730. package/dist/src/utils/paths.d.ts +1 -1
  731. package/dist/src/utils/paths.js +5 -2
  732. package/dist/src/utils/paths.js.map +1 -1
  733. package/dist/src/utils/platform-empty-state.d.ts +69 -0
  734. package/dist/src/utils/platform-empty-state.js +226 -0
  735. package/dist/src/utils/platform-empty-state.js.map +1 -0
  736. package/dist/src/utils/platform-support.d.ts +1 -1
  737. package/dist/src/utils/platform-support.js +1 -1
  738. package/dist/src/utils/platform-support.js.map +1 -1
  739. package/dist/src/utils/plugin-config-command-apply.d.ts +33 -0
  740. package/dist/src/utils/plugin-config-command-apply.js +142 -0
  741. package/dist/src/utils/plugin-config-command-apply.js.map +1 -0
  742. package/dist/src/utils/plugin-config-diagnostics.d.ts +16 -0
  743. package/dist/src/utils/plugin-config-diagnostics.js +44 -0
  744. package/dist/src/utils/plugin-config-diagnostics.js.map +1 -0
  745. package/dist/src/utils/plugin-config-impact.d.ts +75 -0
  746. package/dist/src/utils/plugin-config-impact.js +355 -0
  747. package/dist/src/utils/plugin-config-impact.js.map +1 -0
  748. package/dist/src/utils/plugin-config-references.d.ts +96 -0
  749. package/dist/src/utils/plugin-config-references.js +357 -0
  750. package/dist/src/utils/plugin-config-references.js.map +1 -0
  751. package/dist/src/utils/plugin-config-suggestion-runner.d.ts +83 -0
  752. package/dist/src/utils/plugin-config-suggestion-runner.js +308 -0
  753. package/dist/src/utils/plugin-config-suggestion-runner.js.map +1 -0
  754. package/dist/src/utils/plugin-config-suggestions.d.ts +50 -0
  755. package/dist/src/utils/plugin-config-suggestions.js +302 -0
  756. package/dist/src/utils/plugin-config-suggestions.js.map +1 -0
  757. package/dist/src/utils/plugin-config-write.d.ts +123 -31
  758. package/dist/src/utils/plugin-config-write.js +828 -399
  759. package/dist/src/utils/plugin-config-write.js.map +1 -1
  760. package/dist/src/utils/plugin-config.d.ts +192 -109
  761. package/dist/src/utils/plugin-config.js +970 -1150
  762. package/dist/src/utils/plugin-config.js.map +1 -1
  763. package/dist/src/utils/plugin-dependencies.d.ts +1 -1
  764. package/dist/src/utils/plugin-dependencies.js.map +1 -1
  765. package/dist/src/utils/plugin-scripts.d.ts +80 -127
  766. package/dist/src/utils/plugin-scripts.js +655 -524
  767. package/dist/src/utils/plugin-scripts.js.map +1 -1
  768. package/dist/src/utils/process-lock.js +14 -5
  769. package/dist/src/utils/process-lock.js.map +1 -1
  770. package/dist/src/utils/process-tree.d.ts +2 -2
  771. package/dist/src/utils/process-tree.js +1 -1
  772. package/dist/src/utils/process-tree.js.map +1 -1
  773. package/dist/src/utils/project-boundary.d.ts +11 -13
  774. package/dist/src/utils/project-boundary.js +28 -34
  775. package/dist/src/utils/project-boundary.js.map +1 -1
  776. package/dist/src/utils/rendered-contract.js +24 -1
  777. package/dist/src/utils/rendered-contract.js.map +1 -1
  778. package/dist/src/utils/runtime-config.d.ts +18 -0
  779. package/dist/src/utils/runtime-config.js +64 -0
  780. package/dist/src/utils/runtime-config.js.map +1 -0
  781. package/dist/src/utils/runtime-skill-closure.d.ts +2 -2
  782. package/dist/src/utils/runtime-skill-closure.js +47 -6
  783. package/dist/src/utils/runtime-skill-closure.js.map +1 -1
  784. package/dist/src/utils/safe-fs.d.ts +21 -0
  785. package/dist/src/utils/safe-fs.js +111 -0
  786. package/dist/src/utils/safe-fs.js.map +1 -0
  787. package/dist/src/utils/safe-operation-diagnostic.d.ts +15 -0
  788. package/dist/src/utils/safe-operation-diagnostic.js +33 -0
  789. package/dist/src/utils/safe-operation-diagnostic.js.map +1 -0
  790. package/dist/src/utils/sensitive-content.d.ts +4 -0
  791. package/dist/src/utils/sensitive-content.js +36 -0
  792. package/dist/src/utils/sensitive-content.js.map +1 -0
  793. package/dist/src/utils/skill-invocation-warning.d.ts +20 -0
  794. package/dist/src/utils/skill-invocation-warning.js +68 -0
  795. package/dist/src/utils/skill-invocation-warning.js.map +1 -0
  796. package/dist/src/utils/state-paths.d.ts +8 -3
  797. package/dist/src/utils/state-paths.js +53 -16
  798. package/dist/src/utils/state-paths.js.map +1 -1
  799. package/dist/src/utils/target-eligibility.d.ts +3 -3
  800. package/dist/src/utils/target-eligibility.js +11 -6
  801. package/dist/src/utils/target-eligibility.js.map +1 -1
  802. package/dist/src/utils/windows-claude-shim.d.ts +7 -0
  803. package/dist/src/utils/windows-claude-shim.js +10 -0
  804. package/dist/src/utils/windows-claude-shim.js.map +1 -0
  805. package/dist/src/utils/windows-npm-shim.d.ts +16 -0
  806. package/dist/src/utils/windows-npm-shim.js +155 -0
  807. package/dist/src/utils/windows-npm-shim.js.map +1 -0
  808. package/dist/vitest.config.js +106 -9
  809. package/dist/vitest.config.js.map +1 -1
  810. package/package.json +30 -21
  811. package/dist/src/commands/review-publication.d.ts +0 -99
  812. package/dist/src/commands/review-publication.js +0 -904
  813. package/dist/src/commands/review-publication.js.map +0 -1
  814. package/dist/src/commands/sync-command.d.ts +0 -21
  815. package/dist/src/commands/sync-command.js +0 -206
  816. package/dist/src/commands/sync-command.js.map +0 -1
  817. package/dist/src/portable/skills-cli.d.ts +0 -43
  818. package/dist/src/portable/skills-cli.js +0 -148
  819. package/dist/src/portable/skills-cli.js.map +0 -1
  820. package/dist/src/utils/catalog-manifest-v6.d.ts +0 -5
  821. package/dist/src/utils/lifecycle-active-store.d.ts +0 -147
  822. package/dist/src/utils/lifecycle-active-store.js +0 -1064
  823. package/dist/src/utils/lifecycle-active-store.js.map +0 -1
  824. package/dist/src/utils/plugin-intent-state.d.ts +0 -39
  825. package/dist/src/utils/plugin-intent-state.js +0 -325
  826. package/dist/src/utils/plugin-intent-state.js.map +0 -1
  827. package/dist/src/utils/slash-commands.d.ts +0 -1
  828. package/dist/src/utils/slash-commands.js +0 -2
  829. package/dist/src/utils/slash-commands.js.map +0 -1
@@ -1,15 +1,88 @@
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';
6
- import { getDefaultNativeCliRunner } from './native-cli.js';
7
- import { resolveAwHome } from './paths.js';
8
- import { assertSafePluginConfigSegment, coercePluginConfigUpdates, collectProjectArtifactConfigBoundaryIssues, patchPluginConfigStore, readPluginConfigStore, resetPluginConfigStore, resolveConfigRead, resolveEffectivePluginConfig, resolvePluginConfigSchemaAccess, summarizeEffectivePluginConfig, } from './plugin-config.js';
9
- import { assertProjectSharedConfigPathVisible, ensureProjectPrivateStateIgnore, } from './project-boundary.js';
10
- import { resolveClaudeProjectKey, resolveCodexProjectKey } from './paths.js';
11
- import { supportsPlatform } from './platform-support.js';
1
+ import { catalogGenerationErrorCode } from './catalog-generation-error.js';
2
+ import { CatalogPluginNotFoundError } from './multi-source-catalog.js';
3
+ import { resolveWorkContext } from '../intent/work-context.js';
4
+ import { observePreferences } from '../intent/deployment-preferences.js';
5
+ import { assertConfigLayerWritable, ConfigLayerError, resolveActiveConfigPlatforms } from './config-platforms.js';
6
+ import { RecoveryInterruptedError, recoveryInterruptionCode } from '../recovery/interruption.js';
7
+ import { readDemand, demandNativeProjection } from '../recovery/demand.js';
8
+ import { createScopeContext } from '../intent/scope-context.js';
9
+ import { nativeDeploymentHasVerifiedComponentWrite } from '../commands/rebuild-platform-integration.js';
10
+ import { projectDeploymentNotices, projectRelatedProjectPermissionFailures } from '../commands/public-lifecycle-result.js';
11
+ import { recoveryHostPermissionEffects } from '../commands/deployment-confirmation.js';
12
+ import { projectComponentDelivery } from '../output/component-delivery.js';
13
+ import { canonicalizeIdentityValue, selectPluginConfigProfile } from '@lesliechan721/aw-plugin-core/manifest';
14
+ import { syncWriteCommand } from '../commands/write-commands.js';
15
+ import { skillInvocationDiagnostics } from '../output/skill-invocation-notices.js';
16
+ import { CONFIG_MUTATION_RECEIPT_SCHEMA_VERSION, } from '../types.js';
17
+ import { assertPluginConfigMutationCandidate, assertSafePluginConfigSegment, coercePluginConfigUpdates, patchPluginConfigStore, PluginConfigSchemaResolutionError, readPluginConfigStore, readNamespacedPluginConfigStoreIdentity, resetPluginConfigStore, resolveConfigRead, resolveEffectivePluginConfig, resolvePluginConfigStorePath, resolvePluginConfigSchemaAccess, summarizeEffectivePluginConfig, } from './plugin-config.js';
18
+ import { analyzePluginConfigMutationImpact, discoverPluginConfigManagedCommandPackages, pluginSharedNativeConfigRenderUnits } from './plugin-config-impact.js';
19
+ import { collectPluginConfigReferenceEvidence, resolvePluginConfigReferencePlugins, resolvePluginConfigReferenceConsumers } from './plugin-config-references.js';
20
+ import { resolvePluginMetaDependencyClosure } from './plugin-dependencies.js';
21
+ import { publishPreparedManagedCommandPackage } from './managed-command-materialization.js';
22
+ import { ManagedCommandError, managedCommandDiagnostic } from './managed-command-store.js';
23
+ import { configPackageResult, inspectConfigCommandPackageReview, prepareConfigCommandPackages } from './plugin-config-command-apply.js';
24
+ import { collectSensitivePluginConfigValues, redactPluginScriptOutput, } from './plugin-scripts.js';
25
+ import { resolveCliPackageRoot } from './paths.js';
26
+ import { readSafeOperationError } from './safe-operation-diagnostic.js';
12
27
  import { withAwHomeMutationLock, } from './aw-home-mutation-lock.js';
28
+ import fs from 'fs-extra';
29
+ import path from 'node:path';
30
+ export function buildConfigMutationReceipt(command, receipt) {
31
+ return {
32
+ ...receipt,
33
+ receiptSchemaVersion: CONFIG_MUTATION_RECEIPT_SCHEMA_VERSION,
34
+ command,
35
+ };
36
+ }
37
+ export function configWriteStateForError(error) {
38
+ return error?.configWrite === 'failed'
39
+ ? 'failed'
40
+ : 'notStarted';
41
+ }
42
+ function markConfigWriteFailed(error) {
43
+ const failure = error instanceof Error ? error : new Error(String(error));
44
+ return Object.assign(failure, { configWrite: 'failed' });
45
+ }
46
+ function skippedApply(reason) {
47
+ return { state: 'skipped', reason, targetResults: [] };
48
+ }
49
+ async function observeConfigLayerError(options) {
50
+ const { plugin } = options;
51
+ try {
52
+ assertConfigLayerWritable(plugin.pluginId ?? (plugin.sourceId ? `${plugin.sourceId}/${plugin.manifest.name}` : plugin.manifest.name), plugin.manifest, await observePreferences(options), options.platform);
53
+ }
54
+ catch (error) {
55
+ if (!(error instanceof ConfigLayerError))
56
+ throw error;
57
+ return error;
58
+ }
59
+ return undefined;
60
+ }
61
+ export function configApplyLayerFailure(error) {
62
+ return { state: 'unavailable', reason: 'targetDiscoveryFailed', targetResults: [],
63
+ error: { stage: 'targetValidation', code: error.code, message: error.message } };
64
+ }
65
+ export function configActiveAvailabilityError(error) {
66
+ if (error instanceof CatalogPluginNotFoundError)
67
+ return { code: 'pluginUnavailable',
68
+ message: 'The plugin is absent from the active catalog. Run aw source sync and check the selector.' };
69
+ if (['catalogGenerationUnavailable', 'catalogGenerationSourceMissing', 'catalogGenerationIdentityMismatch',
70
+ 'catalogGenerationStateInvalid', 'catalogGenerationMetadataInvalid'].includes(catalogGenerationErrorCode(error))) {
71
+ return { code: 'sourceActiveUnavailable',
72
+ message: 'The active catalog is unavailable. Run aw source sync, then retry configuration apply.' };
73
+ }
74
+ return undefined;
75
+ }
76
+ function unavailableApply(reason, stage) {
77
+ const messages = {
78
+ invalidConfig: 'The effective config is invalid for every visible target.',
79
+ schemaUnavailable: 'The config schema is unavailable after the config commit.',
80
+ sourceUnavailable: 'The plugin source is unavailable after the config commit.',
81
+ effectiveConfigUnavailable: 'The effective config cannot be read after the config commit.',
82
+ targetDiscoveryFailed: 'Visible config apply targets cannot be discovered after the config commit.',
83
+ };
84
+ return { state: 'unavailable', reason, targetResults: [], error: { stage, code: reason, message: messages[reason] } };
85
+ }
13
86
  function uniqueInOrder(values) {
14
87
  return [...new Set(values)];
15
88
  }
@@ -17,7 +90,7 @@ function collectRemovedConfigKeys(values) {
17
90
  return uniqueInOrder(Object.keys(values));
18
91
  }
19
92
  function targetKey(target) {
20
- return `${target.platform}:${target.scope}:${target.projectKey ?? '-'}`;
93
+ return `${target.pluginName}:${target.platform}:${target.scope}:${target.projectKey ?? '-'}`;
21
94
  }
22
95
  function dedupeTargets(targets) {
23
96
  const deduped = new Map();
@@ -25,168 +98,158 @@ function dedupeTargets(targets) {
25
98
  deduped.set(targetKey(target), target);
26
99
  return [...deduped.values()];
27
100
  }
28
- async function resolveProjectKey(platform, cwd) {
29
- return platform === 'codex'
30
- ? resolveCodexProjectKey(cwd)
31
- : resolveClaudeProjectKey(cwd);
32
- }
33
- async function createCandidateTarget(options) {
34
- return {
35
- pluginName: options.pluginName,
36
- platform: options.platform,
37
- scope: options.scope,
38
- ...(options.scope === 'project'
39
- ? { projectKey: await resolveProjectKey(options.platform, options.cwd) }
40
- : {}),
41
- };
42
- }
43
- async function discoverVisibleTargets(options) {
44
- const targets = [];
45
- const failures = [];
46
- const namedTargets = [];
47
- const scopes = options.scope === 'user' ? ['user', 'project'] : ['project'];
48
- for (const platform of ['codex', 'claude']) {
49
- for (const scope of scopes) {
50
- if (!supportsPlatform(options.plugin.manifest, platform))
101
+ async function configApplyHasValidSharedNativeTarget(options) {
102
+ const plugins = await resolvePluginConfigReferenceConsumers({ plugin: options.plugin, env: options.env, plugins: options.plugins });
103
+ for (const plugin of plugins) {
104
+ for (const target of options.targets.filter((target) => target.pluginName === plugin.manifest.name)) {
105
+ const shared = pluginSharedNativeConfigRenderUnits(plugin);
106
+ if (!shared.some((entry) => entry.platform === target.platform))
51
107
  continue;
52
- const target = await createCandidateTarget({
53
- pluginName: options.pluginName,
54
- platform,
55
- scope,
56
- cwd: options.cwd,
57
- });
58
- try {
59
- const names = await discoverRebuildTargetNames({
60
- cwd: options.cwd,
61
- env: options.env,
62
- platform,
63
- scope,
64
- nativeCliRunner: options.nativeCliRunner,
65
- nativeFailureMode: 'ignore',
66
- marketplaceName: options.plugin.marketplaceName,
67
- marketplaceRoot: options.plugin.sourceId
68
- ? path.join(resolveAwHome(options.env), 'marketplaces', options.plugin.sourceId)
69
- : undefined,
70
- });
71
- if (!names.includes(options.pluginName))
72
- continue;
73
- namedTargets.push(target);
74
- }
75
- catch (error) {
76
- failures.push({
77
- target,
78
- action: 'reinstall',
79
- state: 'failed',
80
- message: error instanceof Error ? error.message : String(error),
81
- });
82
- }
108
+ const effective = await resolveEffectivePluginConfig({ sourceId: plugin.sourceId,
109
+ sourceIdentity: plugin.sourceIdentity, logicalIdentity: plugin.catalogLogicalIdentity,
110
+ manifest: plugin.manifest, platform: target.platform, targetScope: 'user',
111
+ cwd: options.cwd, env: options.env, referencePlugins: options.plugins });
112
+ if (!effective.issues.length)
113
+ return true;
83
114
  }
84
115
  }
85
- if (namedTargets.length === 0)
86
- return { targets, failures };
87
- const catalog = options.rebuildRuntime?.catalogResolution ?? {
88
- rootDir: options.plugin.sourceId
89
- ? path.resolve(options.plugin.rootDir, '..', '..')
90
- : options.plugin.rootDir,
91
- source: 'local',
92
- };
93
- for (const target of namedTargets) {
94
- try {
95
- const inspected = await inspectRebuildTarget({
96
- sourceId: options.plugin.sourceId,
97
- sourceIdentity: options.plugin.sourceIdentity,
98
- pluginId: options.plugin.pluginId,
99
- marketplaceName: options.plugin.marketplaceName,
100
- marketplaceRoot: options.plugin.sourceId
101
- ? path.join(resolveAwHome(options.env), 'marketplaces', options.plugin.sourceId)
102
- : undefined,
103
- plugin: options.plugin,
104
- platform: target.platform,
105
- scope: target.scope,
106
- cwd: options.cwd,
107
- catalog,
108
- context: {
109
- env: options.env,
110
- nativeCliRunner: options.nativeCliRunner,
111
- reporter: options.rebuildRuntime?.reporter ?? createNoopReporter(),
112
- debugLogger: options.rebuildRuntime?.debugLogger ?? createNoopDebugLogger(),
113
- },
114
- });
115
- if (inspected.inspection.state === 'present' || inspected.inspection.state === 'partial') {
116
- targets.push(target);
117
- }
118
- }
119
- catch (error) {
120
- failures.push({
116
+ return false;
117
+ }
118
+ export async function resolveConfigPreApplyAuthorization(options) {
119
+ const applyTargets = dedupeTargets(options.applyTargets).filter((target) => !options.rebuildRuntime?.configApplyPackages?.targets.some((entry) => entry.blocker
120
+ && entry.pluginId === (target.pluginId ?? options.plugin.pluginId) && entry.platforms.includes(target.platform)));
121
+ if (applyTargets.some((target) => target.pluginName !== options.plugin.manifest.name)) {
122
+ const plugins = await resolvePluginConfigReferencePlugins({ sourceId: options.plugin.sourceId,
123
+ sourceIdentity: options.plugin.sourceIdentity, logicalIdentity: options.plugin.catalogLogicalIdentity,
124
+ env: options.env, plugins: options.rebuildRuntime?.referencePlugins });
125
+ const results = await Promise.all(plugins.map((plugin) => resolveConfigPreApplyAuthorization({ ...options, plugin,
126
+ applyTargets: applyTargets.filter((target) => target.pluginName === plugin.manifest.name) })));
127
+ return { targets: results.flatMap((result) => result.targets),
128
+ availableApplyTargets: results.flatMap((result) => result.availableApplyTargets),
129
+ unavailableTargetResults: results.flatMap((result) => result.unavailableTargetResults) };
130
+ }
131
+ if (applyTargets.length === 0 || !pluginMayRunPreApply(options.plugin)) {
132
+ return { targets: [], availableApplyTargets: applyTargets, unavailableTargetResults: [] };
133
+ }
134
+ if (options.plugin.sourceId && !options.plugin.pluginId) {
135
+ return {
136
+ targets: [],
137
+ availableApplyTargets: [],
138
+ unavailableTargetResults: applyTargets.map((target) => ({
121
139
  target,
122
140
  action: 'reinstall',
123
141
  state: 'failed',
124
- message: error instanceof Error ? error.message : String(error),
125
- });
126
- }
127
- }
128
- return { targets: dedupeTargets(targets), failures };
129
- }
130
- async function reinstallVisibleTargets(options) {
131
- const nativeCliRunner = options.nativeCliRunner ?? getDefaultNativeCliRunner();
132
- const discovered = options.applyTargets === undefined
133
- ? await discoverVisibleTargets({
134
- pluginName: options.plugin.manifest.name,
135
- plugin: options.plugin,
136
- scope: options.scope,
137
- cwd: options.cwd,
138
- env: options.env,
139
- nativeCliRunner,
140
- rebuildRuntime: options.rebuildRuntime,
141
- })
142
- : { targets: dedupeTargets(options.applyTargets), failures: [] };
143
- const targetResults = [...discovered.failures];
144
- let runtimeFailed = discovered.failures.length > 0;
145
- const reinstall = options.reinstallCommandImpl ?? reinstallWriteCommand;
146
- if (options.plugin.sourceId && !options.plugin.pluginId) {
147
- throw new Error(`Plugin "${options.plugin.manifest.name}" is missing its namespaced plugin ID.`);
142
+ errorCode: 'sourceUnavailable',
143
+ message: 'The preApply authorization scope cannot be resolved for this target.',
144
+ })),
145
+ };
148
146
  }
149
147
  const selector = options.plugin.sourceId
150
148
  ? options.plugin.pluginId
151
149
  : options.plugin.manifest.name;
152
- for (const target of discovered.targets) {
150
+ const groups = new Map();
151
+ for (const target of applyTargets) {
152
+ const key = `${target.scope}\0${target.platform}`;
153
+ const targets = groups.get(key) ?? [];
154
+ targets.push(target);
155
+ groups.set(key, targets);
156
+ }
157
+ const authorization = [];
158
+ const availableApplyTargets = [];
159
+ const unavailableTargetResults = [];
160
+ const resolveGroup = async (targets) => {
161
+ const platform = targets[0].platform;
162
+ let context;
153
163
  try {
154
- const result = await reinstall([selector], {
155
- cwd: options.cwd,
156
- platform: target.platform,
157
- scope: target.scope,
164
+ context = await createScopeContext({ scope: targets[0].scope, cwd: options.cwd, env: options.env });
165
+ const demand = await readDemand({ scope: targets[0].scope,
166
+ cwd: context.executionCwd, env: context.env });
167
+ const preview = await (options.reinstallCommandImpl ?? syncWriteCommand)([selector], {
168
+ cwd: context.executionCwd,
169
+ platform,
170
+ scope: targets[0].scope,
158
171
  }, {
159
172
  ...options.rebuildRuntime,
160
- env: options.env,
161
- nativeCliRunner,
173
+ env: context.env,
174
+ nativeCliRunner: options.nativeCliRunner ?? options.rebuildRuntime?.nativeCliRunner,
175
+ previewOperationPlan: true,
176
+ resolvePreApplyAuthorization: true,
177
+ executionInput: {
178
+ context, requirements: demandNativeProjection(demand),
179
+ selectedTargets: targets.map((target) => ({ pluginId: selector,
180
+ platform: target.platform, scope: target.scope })),
181
+ preserveOtherObservedTargets: true,
182
+ },
162
183
  });
163
- if (result.overallState === 'failed')
164
- runtimeFailed = true;
165
- targetResults.push(...result.targetResults);
184
+ if (preview.overallState !== 'succeeded' || !preview.preApplyAuthorization)
185
+ return false;
186
+ authorization.push(...preview.preApplyAuthorization);
187
+ availableApplyTargets.push(...targets);
188
+ return true;
166
189
  }
167
- catch (error) {
168
- runtimeFailed = true;
169
- targetResults.push({
190
+ catch {
191
+ return false;
192
+ }
193
+ finally {
194
+ await context?.dispose();
195
+ }
196
+ };
197
+ for (const targets of groups.values()) {
198
+ if (await resolveGroup(targets))
199
+ continue;
200
+ for (const target of targets) {
201
+ if (targets.length > 1 && await resolveGroup([target]))
202
+ continue;
203
+ unavailableTargetResults.push({
170
204
  target,
171
205
  action: 'reinstall',
172
206
  state: 'failed',
173
- message: error instanceof Error ? error.message : String(error),
207
+ errorCode: 'sourceUnavailable',
208
+ message: 'The preApply authorization scope cannot be resolved for this target.',
174
209
  });
175
210
  }
176
211
  }
177
- const overallState = runtimeFailed || targetResults.some((entry) => entry.state === 'failed')
178
- ? 'failed' : 'succeeded';
179
212
  return {
180
- overallState,
181
- targetResults,
182
- ...(discovered.targets.length === 0 && discovered.failures.length === 0
183
- ? { applySkippedReason: 'noVisibleTarget' }
184
- : {}),
213
+ targets: [...new Map(authorization.map((target) => [[
214
+ target.pluginId,
215
+ target.platform,
216
+ target.scope,
217
+ ].join('\0'), target])).values()],
218
+ availableApplyTargets: dedupeTargets(availableApplyTargets),
219
+ unavailableTargetResults,
185
220
  };
186
221
  }
222
+ function pluginMayRunPreApply(plugin) {
223
+ return plugin.manifest.scripts?.preApply !== undefined
224
+ || (plugin.manifest.dependencies?.length ?? 0) > 0;
225
+ }
226
+ function throwPreApplyAuthorizationRequired(targets) {
227
+ const plugins = [...new Set(targets.map((target) => target.pluginId))].join(', ');
228
+ const error = new Error(`preApplyAuthorizationRequired: Applying this config runs plugin preApply for ${plugins}. Re-run with --yes.`);
229
+ error.code = 'preApplyAuthorizationRequired';
230
+ throw error;
231
+ }
232
+ function preApplyAuthorizationIsConfirmed(options) {
233
+ if (options.confirmed !== true)
234
+ return false;
235
+ if (options.authorizedTargets === undefined)
236
+ return true;
237
+ const authorized = new Set(options.authorizedTargets.map((target) => [
238
+ target.pluginId,
239
+ target.sourceIdentity,
240
+ target.platform,
241
+ target.scope,
242
+ ].join('\0')));
243
+ return options.required.every((target) => authorized.has([
244
+ target.pluginId,
245
+ target.sourceIdentity,
246
+ target.platform,
247
+ target.scope,
248
+ ].join('\0')));
249
+ }
187
250
  function otherProjectsWarning(scope) {
188
251
  return scope === 'user'
189
- ? ['其它项目不会由本次命令扫描或更新。请在每个项目目录中运行对应的 aw reinstall 命令。']
252
+ ? ['其它项目不会由本次命令扫描或更新,可能需要在对应项目目录中运行 aw plugin sync --context project。']
190
253
  : [];
191
254
  }
192
255
  function buildReceiptFieldEntry(options) {
@@ -197,167 +260,464 @@ function buildReceiptFieldEntry(options) {
197
260
  reserved: options.reserved,
198
261
  action: options.action,
199
262
  scope: options.scope,
200
- ...(options.scope === 'project' ? { projectLayer: options.projectLayer } : {}),
201
263
  ...(options.valueState ? { valueState: options.valueState } : {}),
202
264
  };
203
265
  }
204
266
  export async function replayConfigRuntimeWrites(options) {
205
- return withAwHomeMutationLock({
206
- env: options.env,
207
- token: options.awHomeMutationToken,
208
- action: async (awHomeMutationToken) => {
209
- const applied = await reinstallVisibleTargets({
210
- plugin: options.plugin,
211
- scope: options.scope,
212
- cwd: options.cwd,
213
- env: options.env ?? process.env,
214
- applyTargets: options.applyTargets,
215
- nativeCliRunner: options.nativeCliRunner,
216
- reinstallCommandImpl: options.reinstallCommandImpl,
217
- rebuildRuntime: { ...options.rebuildRuntime, awHomeMutationToken },
218
- });
219
- return {
220
- configWrite: 'succeeded',
221
- overallState: applied.overallState,
222
- targetResults: applied.targetResults,
223
- ...(applied.applySkippedReason ? { applySkippedReason: applied.applySkippedReason } : {}),
224
- otherProjectsRequireReinstall: options.scope === 'user',
225
- };
267
+ if (options.scope === 'user' && options.sharedNativeApplyConfirmed !== true && await configApplyHasValidSharedNativeTarget({
268
+ ...options, plugins: options.rebuildRuntime?.referencePlugins, targets: options.applyTargets ?? [],
269
+ }))
270
+ throwSharedNativeApplyConfirmationRequired();
271
+ const result = await applyPluginConfig(options);
272
+ return { ...result, configWrite: 'succeeded', otherProjectsMayRequireSync: false };
273
+ }
274
+ const commandCandidateCleanup = new WeakMap();
275
+ function configApplyRequestedTargets(plan) {
276
+ const targets = plan.joint
277
+ ? plan.joint.children.filter((child) => child.command !== 'cleanup' && child.command !== 'uninstall')
278
+ .flatMap((child) => configApplyRequestedTargets(child))
279
+ : plan.receipt.requestedTargets;
280
+ return targets.filter((target) => !plan.receipt.targetResults.some((result) => result.pluginId === target.pluginId && result.agent === target.agent && result.scope === target.scope
281
+ && (result.satisfaction === 'unsupported' || result.satisfaction === 'excluded')));
282
+ }
283
+ function configApplyPackageHook(options, entries, referencePlugins) {
284
+ const env = options.env ?? process.env;
285
+ const targets = entries.map(({ target, plugin, evidence }) => ({
286
+ pluginId: plugin.pluginId ?? plugin.manifest.name,
287
+ scope: 'user',
288
+ packageId: target.packageId,
289
+ platforms: evidence.review?.routeChanges.length || evidence.blocker
290
+ ? [...plugin.manifest.command?.platforms ?? target.runtimeConfigPlatforms] : [],
291
+ ...(evidence.blocker && ['nativeToolSyncRequired', 'configApplyVersionMismatch'].includes(evidence.blocker.code)
292
+ ? { blocker: evidence.blocker } : {}),
293
+ dependencies: resolvePluginMetaDependencyClosure(referencePlugins, [plugin.manifest.name])
294
+ .filter((entry) => entry.manifest.name !== plugin.manifest.name).map((entry) => entry.pluginId ?? entry.manifest.name),
295
+ }));
296
+ const selected = (pluginId, packageId) => entries.filter(({ target, plugin }) => (plugin.pluginId ?? plugin.manifest.name) === pluginId && (!packageId || target.packageId === packageId));
297
+ return { targets, evidence: entries.map(({ evidence }) => evidence),
298
+ blocked: (pluginId, _scope, code, packageId) => selected(pluginId, packageId).map(({ target, candidate, evidence }) => configPackageResult(target, [evidence.blocker ?? { code, message: 'The command package refresh did not complete.' }], candidate)),
299
+ execute: async (pluginId, _scope, _token, packageId) => {
300
+ const results = [];
301
+ for (const { target, plugin, candidate, evidence } of selected(pluginId, packageId)) {
302
+ if (evidence.blocker || !candidate) {
303
+ results.push(configPackageResult(target, [evidence.blocker ?? {
304
+ code: 'commandPackageApplyFailed', message: 'The command package could not be prepared.',
305
+ }]));
306
+ continue;
307
+ }
308
+ try {
309
+ options.rebuildRuntime?.signal?.throwIfAborted();
310
+ if (canonicalizeIdentityValue(evidence.review) !== canonicalizeIdentityValue(await inspectConfigCommandPackageReview(options, target, candidate))) {
311
+ throw new ManagedCommandError('operationReviewStale', 'Permissions affecting the reviewed routes changed. Prepare a new Review.');
312
+ }
313
+ const published = await publishPreparedManagedCommandPackage({ plugin, candidate, cwd: options.cwd, env, referencePlugins });
314
+ results.push(configPackageResult(target, [], candidate, published));
315
+ }
316
+ catch (error) {
317
+ if (recoveryInterruptionCode(error, options.rebuildRuntime?.signal) || readSafeOperationError(error))
318
+ throw error;
319
+ results.push(configPackageResult(target, [managedCommandDiagnostic(error)], candidate));
320
+ }
321
+ }
322
+ return results;
226
323
  },
227
- });
324
+ };
228
325
  }
229
- async function applyPluginConfigWriteUnlocked(options) {
230
- const requestedPluginName = options.pluginName ?? options.plugin?.manifest.name;
231
- if (!requestedPluginName)
232
- throw new Error('Plugin name is required for config write.');
233
- const pluginName = assertSafePluginConfigSegment(requestedPluginName);
234
- const configIdentity = options.plugin?.sourceId ? {
235
- sourceId: options.plugin.sourceId,
236
- sourceIdentity: options.plugin.sourceIdentity,
237
- } : {};
238
- const projectLayer = options.scope === 'project' ? (options.projectLayer ?? 'shared') : 'shared';
239
- const requestedUpdates = options.request.updates ?? {};
240
- const requestedRemoveKeys = uniqueInOrder(options.request.removeKeys ?? []);
241
- const duplicateKeys = requestedRemoveKeys.filter((key) => Object.hasOwn(requestedUpdates, key));
242
- if (duplicateKeys.length > 0) {
243
- throw new Error(`Config write cannot update and remove the same key: ${duplicateKeys.join(', ')}.`);
244
- }
245
- const schemaAccess = await resolvePluginConfigSchemaAccess({
246
- pluginName,
247
- currentPlugin: options.plugin,
248
- currentPluginError: options.pluginError,
249
- scope: options.scope,
250
- projectLayer,
251
- cwd: options.cwd,
252
- env: options.env,
326
+ /** Prepare the same existing-output plan used by apply, without saving config or output. */
327
+ export async function preparePluginConfigApply(options, { inspectOnly = false } = {}) {
328
+ const { prepareRecovery, describeRecoveryPlan } = await import('../recovery/coordinator.js');
329
+ const context = options.context ?? options.scope;
330
+ const referencePlugins = await resolvePluginConfigReferencePlugins({ sourceId: options.plugin.sourceId,
331
+ sourceIdentity: options.plugin.sourceIdentity, logicalIdentity: options.plugin.catalogLogicalIdentity,
332
+ env: options.env, plugins: options.rebuildRuntime?.referencePlugins,
333
+ operationContext: options.rebuildRuntime?.catalogOperationContext }).catch((error) => {
334
+ if (recoveryInterruptionCode(error, options.rebuildRuntime?.signal))
335
+ throw error;
336
+ throw Object.assign(new Error('The selected source has no usable Active Catalog.'), { code: 'sourceActiveUnavailable' });
253
337
  });
254
- const schemaPlugin = schemaAccess.plugin;
255
- const schema = schemaPlugin?.manifest.config?.schema;
256
- if (!schema || !schemaPlugin) {
257
- throw new Error(`configSchemaUnavailable: Plugin "${pluginName}" does not declare an AW config schema.`);
258
- }
259
- for (const key of requestedRemoveKeys) {
260
- if (!schema[key])
261
- throw new Error(`Unknown config key "${key}".`);
262
- }
263
- const updates = await coercePluginConfigUpdates({ schema, updates: requestedUpdates, cwd: options.cwd });
264
- if (options.scope === 'project' && projectLayer === 'shared') {
265
- for (const key of Object.keys(updates)) {
266
- const field = schema[key];
267
- if (field.type === 'file' || field.type === 'directory') {
268
- throw new Error(`Config "${key}" is a ${field.type} value and cannot be written into project shared config. `
269
- + 'Use `--scope project --local` or user config instead.');
270
- }
338
+ if (options.plugin.sourceId) {
339
+ const activePlugin = referencePlugins.find((entry) => entry.manifest.name === options.plugin.manifest.name);
340
+ if (activePlugin)
341
+ options = { ...options, plugin: activePlugin };
342
+ else if (options.plugin.manifest.command) {
343
+ throw Object.assign(new Error('The plugin is unavailable in Active Catalog.'), { code: 'pluginUnavailable' });
271
344
  }
272
345
  }
273
- const store = await readPluginConfigStore({
274
- ...configIdentity,
275
- pluginName,
276
- scope: options.scope,
277
- projectLayer,
278
- cwd: options.cwd,
279
- env: options.env,
280
- });
281
- const warnings = [];
282
- if (options.scope === 'project' && projectLayer === 'shared') {
283
- await assertProjectSharedConfigPathVisible({ cwd: options.cwd, targetPath: store.path });
284
- }
285
- if (options.scope === 'project' && projectLayer === 'local') {
286
- const ignore = await ensureProjectPrivateStateIgnore({ cwd: options.cwd, targetPath: store.path });
287
- if (ignore.warning)
288
- warnings.push(ignore.warning);
289
- }
290
- const removedKeys = requestedRemoveKeys.filter((key) => Object.hasOwn(store.values, key));
291
- const updatedKeys = Object.keys(updates);
292
- const changedKeys = [...updatedKeys, ...removedKeys];
293
- if (options.scope === 'project' && projectLayer === 'shared' && changedKeys.length > 0) {
294
- const nextValues = { ...store.values, ...updates };
295
- for (const key of requestedRemoveKeys)
296
- delete nextValues[key];
297
- const boundaryIssues = collectProjectArtifactConfigBoundaryIssues({
298
- schema,
299
- sharedEntries: nextValues,
346
+ const pluginId = options.plugin.pluginId ?? (options.plugin.sourceId
347
+ ? `${options.plugin.sourceId}/${options.plugin.manifest.name}` : options.plugin.manifest.name);
348
+ const preferences = await observePreferences(options);
349
+ resolveActiveConfigPlatforms(pluginId, options.plugin.manifest, preferences);
350
+ for (const selected of [...(options.platform ? [options.platform] : []), ...(options.targets ?? [])]) {
351
+ assertConfigLayerWritable(pluginId, options.plugin.manifest, preferences, selected);
352
+ }
353
+ const plugins = await resolvePluginConfigReferenceConsumers({ plugin: options.plugin, env: options.env,
354
+ plugins: referencePlugins });
355
+ const selectors = plugins.map((plugin) => plugin.pluginId ?? plugin.manifest.name);
356
+ const version = options.cliVersion
357
+ ?? (await fs.readJson(path.join(resolveCliPackageRoot(), 'package.json'))).version;
358
+ let exactTargets = options.applyTargets?.map((target) => ({
359
+ pluginId: target.pluginId ?? plugins.find((plugin) => plugin.manifest.name === target.pluginName)?.pluginId ?? target.pluginName,
360
+ agent: target.platform,
361
+ scope: target.scope,
362
+ }));
363
+ const retainedLegacyTargets = [];
364
+ if (exactTargets?.length) {
365
+ const { readRecoveryStatus } = await import('../recovery/status.js');
366
+ const observed = await readRecoveryStatus({ context, cwd: options.cwd, env: options.env, cliVersion: version,
367
+ nativeCliRunner: options.nativeCliRunner ?? options.rebuildRuntime?.nativeCliRunner,
368
+ codexObservationSession: options.rebuildRuntime?.codexObservationSession });
369
+ const key = (target) => `${target.pluginId}\0${target.agent}\0${target.scope}`;
370
+ const live = new Set(observed.existingTargets?.map(key));
371
+ const owned = new Set(observed.ownedTargets?.map(key));
372
+ exactTargets = exactTargets.filter((target, index) => {
373
+ if (owned.has(key(target)) && !live.has(key(target))) {
374
+ retainedLegacyTargets.push(options.applyTargets[index]);
375
+ return false;
376
+ }
377
+ return true;
300
378
  });
301
- if (boundaryIssues.length > 0) {
302
- throw new Error([...new Set(boundaryIssues.map((issue) => issue.message))].join(' '));
303
- }
304
379
  }
305
- if (changedKeys.length > 0) {
306
- await patchPluginConfigStore({
307
- ...configIdentity,
308
- pluginName,
309
- scope: options.scope,
310
- projectLayer,
380
+ const env = options.env ?? process.env;
381
+ const commands = await discoverPluginConfigManagedCommandPackages({ plugin: options.plugin, scope: context,
382
+ cwd: options.cwd, env, referencePlugins });
383
+ let selectedPackages = commands.packages.filter((target) => {
384
+ if (options.applyCommandPackages && !options.applyCommandPackages.includes(target.packageId))
385
+ return false;
386
+ const plugin = plugins.find((entry) => entry.manifest.name === target.producer.pluginName);
387
+ const platforms = plugin?.manifest.command?.platforms ?? target.runtimeConfigPlatforms;
388
+ if (options.platform)
389
+ return options.platform !== 'generic' && platforms.includes(options.platform) && target.runtimeConfigKeys.length > 0;
390
+ return (target.refreshKeys.length > 0 || target.runtimeConfigKeys.length > 0)
391
+ && (!options.targets || platforms.some((platform) => options.targets.includes(platform)));
392
+ });
393
+ if (options.mutation) {
394
+ const impact = await analyzePluginConfigMutationImpact({ ...options, scope: context, visibleTargets: [],
395
+ mutation: options.mutation, commandDiscovery: { ...commands, packages: selectedPackages }, referencePlugins });
396
+ selectedPackages = impact.affectedCommandPackages;
397
+ }
398
+ const entries = await prepareConfigCommandPackages(options, selectedPackages, plugins, referencePlugins, { inspectOnly });
399
+ const cleanup = () => Promise.all(entries.map(({ candidate }) => candidate?.cleanup()));
400
+ const packagePreparationCache = new Map();
401
+ for (const { target, candidate } of entries) {
402
+ if (candidate)
403
+ packagePreparationCache.set(target.packageId, Promise.resolve(candidate));
404
+ }
405
+ let plan;
406
+ try {
407
+ plan = await prepareRecovery('sync', selectors, {
408
+ scope: context,
409
+ context,
311
410
  cwd: options.cwd,
312
411
  env: options.env,
313
- updates,
314
- removeKeys: requestedRemoveKeys,
412
+ signal: options.rebuildRuntime?.signal,
413
+ cliVersion: version,
414
+ existingOnly: true,
415
+ ...(exactTargets ? { exactTargets } : {}),
416
+ ...(options.platform ? { targets: [options.platform] } : options.targets ? { targets: options.targets } : {}),
417
+ }, {
418
+ ...options.rebuildRuntime,
419
+ configApply: true,
420
+ packagePreparationCache,
421
+ configApplyPackages: configApplyPackageHook(options, entries, referencePlugins),
422
+ referencePlugins,
423
+ nativeCliRunner: options.nativeCliRunner ?? options.rebuildRuntime?.nativeCliRunner,
424
+ awHomeMutationToken: options.awHomeMutationToken,
425
+ preApplyConfirmed: options.preApplyConfirmed,
315
426
  });
316
- }
317
- const effective = summarizeEffectivePluginConfig(await resolveEffectivePluginConfig({
318
- ...configIdentity,
319
- pluginName,
320
- manifest: schemaPlugin.manifest,
321
- cwd: options.cwd,
322
- env: options.env,
323
- }));
324
- const applied = changedKeys.length === 0
325
- ? {
326
- overallState: 'succeeded',
327
- targetResults: [],
328
- applySkippedReason: 'noConfigChange',
427
+ commandCandidateCleanup.set(plan, cleanup);
428
+ plan.warnings.push(...retainedLegacyTargets.map((target) => `${target.pluginId ?? target.pluginName}/${target.platform}/${target.scope}:保留已停用的历史输出;配置 apply 不创建激活。`));
429
+ const profiles = configApplyRequestedTargets(plan).map((target) => ({
430
+ pluginName: target.pluginId.split('/').at(-1), scope: target.scope, platform: target.agent,
431
+ }));
432
+ for (const { target, candidate } of entries) {
433
+ for (const platform of candidate?.runtimeConfigEvidence.keys() ?? []) {
434
+ profiles.push({ pluginName: target.producer.pluginName, scope: 'user', platform });
435
+ }
436
+ if (candidate?.routeConfigEvidence)
437
+ profiles.push({ pluginName: target.producer.pluginName, scope: 'user' });
329
438
  }
330
- : await reinstallVisibleTargets({
331
- plugin: schemaPlugin,
332
- scope: options.scope,
333
- cwd: options.cwd,
334
- env: options.env ?? process.env,
335
- applyTargets: options.applyTargets,
336
- nativeCliRunner: options.nativeCliRunner,
337
- reinstallCommandImpl: options.reinstallCommandImpl,
338
- rebuildRuntime: options.rebuildRuntime,
439
+ const references = await collectPluginConfigReferenceEvidence({ plugin: options.plugin, plugins: referencePlugins,
440
+ profiles, cwd: options.cwd, env: options.env });
441
+ const authorization = await resolveConfigPreApplyAuthorization({
442
+ plugin: options.plugin, scope: context, cwd: options.cwd, env: options.env,
443
+ applyTargets: configApplyRequestedTargets(plan).flatMap((target) => target.agent !== 'generic'
444
+ ? [{ pluginName: target.pluginId.split('/').at(-1), pluginId: target.pluginId, platform: target.agent, scope: target.scope }] : []),
445
+ nativeCliRunner: options.nativeCliRunner ?? options.rebuildRuntime?.nativeCliRunner,
446
+ rebuildRuntime: { ...plan.runtime, referencePlugins },
339
447
  });
340
- const otherProjectsRequireReinstall = options.scope === 'user'
341
- && changedKeys.length > 0;
342
- if (otherProjectsRequireReinstall)
343
- warnings.push(...otherProjectsWarning(options.scope));
344
- return {
345
- plugin: pluginName,
346
- scope: options.scope,
347
- projectLayer,
348
- ...(schemaAccess.schema ? { schema: schemaAccess.schema } : {}),
349
- updatedKeys,
350
- removedKeys,
351
- effective,
352
- configWrite: 'succeeded',
353
- overallState: applied.overallState,
354
- targetResults: applied.targetResults,
355
- ...(applied.applySkippedReason ? { applySkippedReason: applied.applySkippedReason } : {}),
356
- otherProjectsRequireReinstall,
357
- warnings,
358
- };
448
+ const portableAuthorization = (current) => [
449
+ ...current.preApplyAuthorization ?? [],
450
+ ...(current.joint?.children ?? []).flatMap(portableAuthorization),
451
+ ];
452
+ const preApplyAuthorization = [...new Map([...authorization.targets, ...portableAuthorization(plan)]
453
+ .map((target) => [[target.pluginId, target.platform, target.scope].join('\0'), target])).values()];
454
+ const commandPackageEvidence = entries.map(({ evidence }) => evidence);
455
+ return { plan, retainedLegacyTargets, commandPackages: commands.packages, commandDiscoveryErrors: commands.errors,
456
+ commandPackageEvidence, commandPackageReviews: commandPackageEvidence.flatMap(({ review }) => review ? [review] : []),
457
+ preApplyAuthorization,
458
+ evidence: { recovery: describeRecoveryPlan(plan), references, commandPackageEvidence,
459
+ preApplyAuthorization, retainedLegacyTargets } };
460
+ }
461
+ catch (error) {
462
+ if (plan)
463
+ await disposePluginConfigApply(plan);
464
+ else
465
+ await cleanup();
466
+ throw error;
467
+ }
468
+ }
469
+ export async function disposePluginConfigApply(plan) {
470
+ const cleanup = commandCandidateCleanup.get(plan);
471
+ commandCandidateCleanup.delete(plan);
472
+ await cleanup?.();
473
+ for (const child of plan.joint?.children ?? [])
474
+ await disposePluginConfigApply(child);
475
+ await plan.context.dispose();
476
+ }
477
+ export class ConfigApplyInterruptedError extends Error {
478
+ apply;
479
+ code;
480
+ operationDiagnostic;
481
+ configWrite = 'notStarted';
482
+ constructor(error, apply, signal) {
483
+ super(error.code === 'operationInterrupted' && signal?.reason instanceof Error ? signal.reason.message : error.message);
484
+ this.apply = apply;
485
+ this.code = error.code;
486
+ this.operationDiagnostic = readSafeOperationError(error.cause) ?? error.operationDiagnostic;
487
+ }
488
+ }
489
+ function configApplyHasPartialDelivery(target) {
490
+ if (target.execution !== 'partial')
491
+ return false;
492
+ if (skillInvocationDiagnostics([target]).some(({ subject }) => subject?.pluginId === target.pluginId
493
+ && subject.target === target.agent && subject.scope === target.scope))
494
+ return true;
495
+ if (target.delivery?.kind === 'native') {
496
+ return target.deploymentReceipts?.some((receipt) => {
497
+ const plan = target.deploymentPlans?.find(({ binding }) => binding.id === receipt.bindingId);
498
+ return plan && nativeDeploymentHasVerifiedComponentWrite(plan, receipt);
499
+ }) ?? false;
500
+ }
501
+ if (target.delivery?.kind !== 'agent-skills' || !Array.isArray(target.backend))
502
+ return false;
503
+ return target.backend.some((entry) => {
504
+ if (!entry || typeof entry !== 'object')
505
+ return false;
506
+ const outcome = entry;
507
+ return typeof outcome.skill === 'string' && outcome.observation === 'satisfied'
508
+ && (outcome.execution === 'applied' || outcome.execution === 'no-op')
509
+ && Array.isArray(outcome.blockers) && outcome.blockers.length === 0;
510
+ });
511
+ }
512
+ export async function applyPluginConfig(options) {
513
+ return withAwHomeMutationLock({ env: options.env, token: options.awHomeMutationToken, action: async (token) => {
514
+ await options.reviewPreflight?.();
515
+ let prepared;
516
+ try {
517
+ const { executeRecovery } = await import('../recovery/coordinator.js');
518
+ const expectedCommands = options.expectedCommandPackageEvidence
519
+ ?? options.expectedEvidence?.commandPackageEvidence;
520
+ prepared = await preparePluginConfigApply({ ...options, awHomeMutationToken: token,
521
+ expectedCommandPackageEvidence: expectedCommands });
522
+ if (options.expectedEvidence !== undefined
523
+ && JSON.stringify(options.expectedEvidence) !== JSON.stringify(prepared.evidence)) {
524
+ throw Object.assign(new Error('Configuration apply inputs changed. Prepare a new Review.'), { code: 'operationReviewStale' });
525
+ }
526
+ const authorizedEffects = new Set(options.expectedHostPermissionEffects?.map((effect) => JSON.stringify(effect)));
527
+ if (recoveryHostPermissionEffects(prepared.plan).some((effect) => !authorizedEffects.has(JSON.stringify(effect)))) {
528
+ throw Object.assign(new Error('Host permission effects changed after Review. Prepare a new Review.'), { code: 'operationReviewStale' });
529
+ }
530
+ const authorization = prepared.preApplyAuthorization;
531
+ if (authorization.length && !preApplyAuthorizationIsConfirmed({ required: authorization,
532
+ confirmed: options.preApplyConfirmed, authorizedTargets: options.preApplyAuthorizedTargets })) {
533
+ throwPreApplyAuthorizationRequired(authorization);
534
+ }
535
+ if (options.sharedNativeApplyConfirmed !== true && await configApplyHasValidSharedNativeTarget({
536
+ plugin: options.plugin, cwd: options.cwd, env: options.env, plugins: options.rebuildRuntime?.referencePlugins,
537
+ targets: configApplyRequestedTargets(prepared.plan).flatMap((target) => target.agent !== 'generic'
538
+ ? [{ pluginName: target.pluginId.split('/').at(-1), pluginId: target.pluginId, platform: target.agent, scope: target.scope }] : []),
539
+ }))
540
+ throwSharedNativeApplyConfirmationRequired();
541
+ const discoveryErrors = prepared.commandDiscoveryErrors.map((error) => ({
542
+ stage: 'targetDiscovery', code: error.code, message: error.message,
543
+ }));
544
+ let interruption;
545
+ const receipt = await executeRecovery(prepared.plan, {
546
+ yes: options.sharedNativeApplyConfirmed === true || options.preApplyConfirmed === true,
547
+ runtime: { ...options.rebuildRuntime, awHomeMutationToken: token, preApplyConfirmed: options.preApplyConfirmed },
548
+ }).catch((error) => {
549
+ if (!(error instanceof RecoveryInterruptedError))
550
+ throw error;
551
+ interruption = error;
552
+ return error.receipt;
553
+ });
554
+ const retainedLegacyTargets = prepared.retainedLegacyTargets.filter((target) => !receipt.targetResults.some((result) => (target.pluginId ? result.pluginId === target.pluginId : result.pluginId.split('/').at(-1) === target.pluginName)
555
+ && result.agent === target.platform && result.scope === target.scope));
556
+ const ok = receipt.ok && discoveryErrors.length === 0;
557
+ const errors = [...discoveryErrors, ...receipt.blockers, ...receipt.errors].map((error) => ({
558
+ stage: 'stage' in error ? error.stage : 'apply', code: error.code, message: error.message,
559
+ }));
560
+ const diagnostics = [...projectDeploymentNotices(receipt.targetResults), ...projectRelatedProjectPermissionFailures(receipt.targetResults)];
561
+ const apply = {
562
+ state: ok ? 'succeeded' : 'partial',
563
+ targetResults: [...receipt.targetResults.filter((target) => target.satisfaction !== 'unsupported' && target.satisfaction !== 'excluded').map((target) => ({
564
+ target: { pluginName: target.pluginId.split('/').at(-1), pluginId: target.pluginId,
565
+ platform: target.agent, scope: target.scope },
566
+ action: 'refresh',
567
+ state: target.execution === 'applied' || target.execution === 'no-op' ? 'completed'
568
+ : target.execution === 'not-run' ? 'skipped' : 'failed',
569
+ ...projectComponentDelivery(target),
570
+ ...(target.relation === 'root' ? { relation: 'requested' } : target.relation === 'dependency' ? { relation: 'dependency' } : {}),
571
+ ...(target.requiredBy.length ? { requiredBy: target.requiredBy } : {}),
572
+ ...(configApplyHasPartialDelivery(target) ? { partialDelivery: true } : {}),
573
+ ...(target.blockers.length ? { errorCode: target.blockers[0].code,
574
+ message: target.blockers.map((item) => item.message).join(' ') } : {}),
575
+ })), ...retainedLegacyTargets.map((target) => ({
576
+ target, action: 'refresh', state: 'skipped',
577
+ message: 'The inactive legacy output was preserved. Configuration apply does not create an activation.',
578
+ }))],
579
+ commandResults: receipt.commandResults,
580
+ ...(receipt.reviewedUserRoots !== undefined ? { reviewedUserRoots: receipt.reviewedUserRoots } : {}),
581
+ ...(errors.length ? { errors } : {}),
582
+ ...(diagnostics.length ? { diagnostics } : {}),
583
+ };
584
+ if (interruption)
585
+ throw new ConfigApplyInterruptedError(interruption, apply, options.rebuildRuntime?.signal);
586
+ return { configWrite: 'notStarted', overallState: ok ? 'succeeded' : 'partial', apply,
587
+ otherProjectsMayRequireSync: true };
588
+ }
589
+ catch (error) {
590
+ if (recoveryInterruptionCode(error, options.rebuildRuntime?.signal)
591
+ || readSafeOperationError(error))
592
+ throw error;
593
+ if (error instanceof ConfigLayerError)
594
+ return { configWrite: 'notStarted', overallState: 'failed',
595
+ apply: configApplyLayerFailure(error), otherProjectsMayRequireSync: false };
596
+ const apply = unavailableApply('targetDiscoveryFailed', 'targetDiscovery');
597
+ const code = error?.code;
598
+ if (code === 'sourceActiveUnavailable' || code === 'pluginUnavailable') {
599
+ return { configWrite: 'notStarted', overallState: 'partial', apply: {
600
+ ...unavailableApply('sourceUnavailable', 'source'),
601
+ error: { stage: 'source', code, message: error instanceof Error ? error.message : 'The Active Catalog plugin is unavailable.' },
602
+ }, otherProjectsMayRequireSync: true };
603
+ }
604
+ if (typeof code === 'string')
605
+ apply.error = { stage: 'apply', code,
606
+ message: code === 'operationReviewStale' ? 'Configuration apply inputs changed. Prepare a new Review.'
607
+ : 'The existing outputs cannot be refreshed with the current authorization.' };
608
+ return { configWrite: 'notStarted', overallState: 'partial', apply, otherProjectsMayRequireSync: true };
609
+ }
610
+ finally {
611
+ if (prepared)
612
+ await disposePluginConfigApply(prepared.plan);
613
+ }
614
+ } });
615
+ }
616
+ function throwSharedNativeApplyConfirmationRequired() {
617
+ const error = new Error('sharedNativeConfigApplyConfirmationRequired: Applying this user config changes a shared native artifact. Re-run with --yes.');
618
+ error.code = 'sharedNativeConfigApplyConfirmationRequired';
619
+ throw error;
620
+ }
621
+ async function applyPluginConfigWriteUnlocked(options) {
622
+ const pluginName = assertSafePluginConfigSegment(options.pluginName ?? options.plugin?.manifest.name ?? '');
623
+ const identity = options.plugin?.sourceId ? { sourceId: options.plugin.sourceId,
624
+ sourceIdentity: options.plugin.sourceIdentity, logicalIdentity: options.plugin.catalogLogicalIdentity } : {};
625
+ const requestedUpdates = options.request.updates ?? {};
626
+ const removeKeys = uniqueInOrder(options.request.removeKeys ?? []);
627
+ const duplicateKeys = removeKeys.filter((key) => Object.hasOwn(requestedUpdates, key));
628
+ if (duplicateKeys.length)
629
+ throw new Error(`Config write cannot update and remove the same key: ${duplicateKeys.join(', ')}.`);
630
+ const schemaAccess = await resolvePluginConfigSchemaAccess({ pluginName, currentPlugin: options.plugin,
631
+ currentPluginError: options.pluginError, scope: options.scope, platform: options.platform, cwd: options.cwd, env: options.env });
632
+ const plugin = schemaAccess.plugin;
633
+ const definition = plugin?.manifest.config ? selectPluginConfigProfile(plugin.manifest.config, options.platform) : undefined;
634
+ if (!plugin || !definition && (Object.keys(requestedUpdates).length > 0 || removeKeys.length === 0)) {
635
+ throw new PluginConfigSchemaResolutionError('configSchemaUnavailable', `Plugin "${pluginName}" does not declare an AW config schema.`);
636
+ }
637
+ const updates = await coercePluginConfigUpdates({ schema: definition?.fields ?? {}, updates: requestedUpdates, cwd: options.cwd });
638
+ const impact = await analyzePluginConfigMutationImpact({ plugin, scope: options.scope, platform: options.platform,
639
+ cwd: options.cwd, env: options.env, visibleTargets: [], commandDiscovery: { packages: [], errors: [] },
640
+ referencePlugins: options.rebuildRuntime?.referencePlugins, mutation: { kind: 'patch', updates, removeKeys } });
641
+ await assertPluginConfigMutationCandidate({ ...identity, pluginName, manifest: plugin.manifest,
642
+ scope: options.scope, platform: options.platform, cwd: options.cwd, env: options.env, updates, removeKeys,
643
+ referencePlugins: options.rebuildRuntime?.referencePlugins });
644
+ if (impact.referenceBlockers?.length)
645
+ throw Object.assign(new Error(`configReferenceInUse: ${impact.referenceBlockers.join(' ')}`), { code: 'configReferenceInUse' });
646
+ if (impact.storeChanged) {
647
+ try {
648
+ await patchPluginConfigStore({ ...identity, pluginName, scope: 'user', platform: options.platform,
649
+ cwd: options.cwd, env: options.env, updates: Object.fromEntries(impact.updatedKeys.map((key) => [key, updates[key]])), removeKeys });
650
+ }
651
+ catch (error) {
652
+ throw markConfigWriteFailed(error);
653
+ }
654
+ }
655
+ const warnings = [...impact.referenceWarnings ?? []];
656
+ let effective;
657
+ try {
658
+ effective = summarizeEffectivePluginConfig(await resolveEffectivePluginConfig({ ...identity, pluginName,
659
+ manifest: plugin.manifest, platform: options.platform, targetScope: options.scope, cwd: options.cwd, env: options.env,
660
+ referencePlugins: options.rebuildRuntime?.referencePlugins }));
661
+ }
662
+ catch {
663
+ warnings.push('The saved configuration cannot be previewed. Check its schema and reference sources before applying it.');
664
+ }
665
+ if (impact.storeChanged)
666
+ warnings.push(...otherProjectsWarning('user'));
667
+ return { plugin: pluginName, scope: 'user', context: options.scope, platform: options.platform,
668
+ ...(schemaAccess.schema ? { schema: schemaAccess.schema } : {}), updatedKeys: impact.updatedKeys,
669
+ removedKeys: impact.removedKeys, staleRemovedKeys: impact.staleRemovedKeys, effective,
670
+ configWrite: 'succeeded', overallState: 'succeeded',
671
+ apply: skippedApply(impact.storeChanged ? 'notRequested' : 'noConfigChange'),
672
+ otherProjectsMayRequireSync: impact.storeChanged, warnings };
673
+ }
674
+ async function prepareConfigMutationApplySelection(options) {
675
+ if (options.apply !== true || !options.plugin)
676
+ return undefined;
677
+ let prepared;
678
+ try {
679
+ prepared = await preparePluginConfigApply({ ...options, plugin: options.plugin }, { inspectOnly: true });
680
+ const requestedTargets = configApplyRequestedTargets(prepared.plan);
681
+ const hasGeneric = requestedTargets.some((target) => target.agent === 'generic');
682
+ const visibleTargets = requestedTargets.flatMap((target) => target.agent === 'generic' ? [] : [{
683
+ pluginName: target.pluginId.split('/').at(-1), pluginId: target.pluginId,
684
+ platform: target.agent, scope: target.scope,
685
+ }]);
686
+ const impact = await analyzePluginConfigMutationImpact({ plugin: options.plugin, scope: options.context ?? options.scope,
687
+ platform: options.platform, cwd: options.cwd, env: options.env, visibleTargets,
688
+ commandDiscovery: { packages: prepared.commandPackages, errors: prepared.commandDiscoveryErrors },
689
+ referencePlugins: options.rebuildRuntime?.referencePlugins,
690
+ mutation: 'request' in options ? { kind: 'patch', ...options.request } : { kind: 'reset' } });
691
+ if (options.expectedCommandPackageEvidence) {
692
+ const referencePlugins = prepared.plan.runtime.referencePlugins ?? [];
693
+ const plugins = await resolvePluginConfigReferenceConsumers({ plugin: options.plugin, env: options.env, plugins: referencePlugins });
694
+ const entries = await prepareConfigCommandPackages({ ...options, plugin: options.plugin,
695
+ mutation: 'request' in options ? { kind: 'patch', ...options.request } : { kind: 'reset' } }, impact.affectedCommandPackages, plugins, referencePlugins);
696
+ await Promise.all(entries.map(({ candidate }) => candidate?.cleanup()));
697
+ }
698
+ if (!hasGeneric && !visibleTargets.length && !prepared.commandPackages.length && !prepared.commandDiscoveryErrors.length) {
699
+ if (prepared.plan.blockExecution || prepared.plan.receipt.blockers.length || prepared.plan.receipt.errors.length)
700
+ return undefined;
701
+ return { skipReason: 'noVisibleTarget' };
702
+ }
703
+ return { applyTargets: hasGeneric ? undefined : impact.affectedTargets,
704
+ applyCommandPackages: impact.affectedCommandPackages.map((target) => target.packageId),
705
+ ...(!hasGeneric && impact.noEffectiveChange ? { skipReason: 'noEffectiveConfigChange' } : {}) };
706
+ }
707
+ catch (error) {
708
+ if (error?.code === 'operationReviewStale' || recoveryInterruptionCode(error, options.rebuildRuntime?.signal))
709
+ throw error;
710
+ // A failed output discovery must not prevent a valid configuration save.
711
+ return undefined;
712
+ }
713
+ finally {
714
+ if (prepared)
715
+ await disposePluginConfigApply(prepared.plan);
716
+ }
359
717
  }
360
718
  export async function applyPluginConfigWrite(options) {
719
+ if (options.context)
720
+ await resolveWorkContext({ cwd: options.cwd, context: options.context });
361
721
  const requestedPluginName = options.pluginName ?? options.plugin?.manifest.name;
362
722
  if (!requestedPluginName)
363
723
  throw new Error('Plugin name is required for config write.');
@@ -367,139 +727,206 @@ export async function applyPluginConfigWrite(options) {
367
727
  token: options.awHomeMutationToken,
368
728
  action: async (awHomeMutationToken) => {
369
729
  await options.reviewPreflight?.();
370
- return applyPluginConfigWriteUnlocked({
371
- ...options,
372
- awHomeMutationToken,
373
- rebuildRuntime: { ...options.rebuildRuntime, awHomeMutationToken },
374
- });
730
+ const hasUpdates = Object.keys(options.request.updates ?? {}).length > 0;
731
+ const layerError = options.plugin && (hasUpdates || options.apply)
732
+ ? await observeConfigLayerError({ ...options, plugin: options.plugin }) : undefined;
733
+ if (layerError && hasUpdates)
734
+ throw layerError;
735
+ let configCommitted = false;
736
+ try {
737
+ const selection = layerError ? undefined : await prepareConfigMutationApplySelection({ ...options, awHomeMutationToken });
738
+ const saved = await applyPluginConfigWriteUnlocked({ ...options, scope: options.context ?? options.scope,
739
+ apply: false, awHomeMutationToken, rebuildRuntime: { ...options.rebuildRuntime, awHomeMutationToken } });
740
+ configCommitted = true;
741
+ if (options.apply !== true || !options.plugin)
742
+ return saved;
743
+ if (layerError)
744
+ return { ...saved, overallState: 'partial', apply: configApplyLayerFailure(layerError) };
745
+ if (saved.apply.state === 'skipped' && saved.apply.reason === 'noConfigChange')
746
+ return saved;
747
+ if (selection?.skipReason)
748
+ return { ...saved, apply: skippedApply(selection.skipReason) };
749
+ const applied = await applyPluginConfig({ ...options, ...selection, plugin: options.plugin, awHomeMutationToken });
750
+ return { ...saved, overallState: applied.overallState, apply: applied.apply };
751
+ }
752
+ catch (error) {
753
+ let sensitiveValues = options.plugin
754
+ ? collectSensitivePluginConfigValues(options.plugin.manifest, (options.request.updates ?? {}), options.platform)
755
+ : [];
756
+ if (options.plugin) {
757
+ try {
758
+ const effective = await resolveEffectivePluginConfig({
759
+ ...(options.plugin.sourceId ? {
760
+ sourceId: options.plugin.sourceId,
761
+ sourceIdentity: options.plugin.sourceIdentity,
762
+ logicalIdentity: options.plugin.catalogLogicalIdentity,
763
+ } : {}),
764
+ pluginName: options.plugin.manifest.name,
765
+ manifest: options.plugin.manifest,
766
+ referencePlugins: options.rebuildRuntime?.referencePlugins,
767
+ targetScope: options.scope,
768
+ platform: options.platform,
769
+ cwd: options.cwd,
770
+ env: options.env,
771
+ });
772
+ sensitiveValues = [
773
+ ...sensitiveValues,
774
+ ...collectSensitivePluginConfigValues(options.plugin.manifest, effective.values, options.platform),
775
+ ];
776
+ }
777
+ catch {
778
+ // Requested sensitive values and generic credential redaction remain available.
779
+ }
780
+ }
781
+ let message = redactPluginScriptOutput(error instanceof Error ? error.message : String(error), sensitiveValues);
782
+ message = message.split(options.cwd).join('<project>');
783
+ for (const scope of ['user', 'project']) {
784
+ const configPath = resolvePluginConfigStorePath({
785
+ sourceId: options.plugin?.sourceId,
786
+ pluginName: requestedPluginName,
787
+ scope,
788
+ cwd: options.cwd,
789
+ env: options.env,
790
+ });
791
+ message = message.split(configPath).join(`${scope}/plugin-config/${[
792
+ options.plugin?.sourceId,
793
+ requestedPluginName,
794
+ 'config.json',
795
+ ].filter(Boolean).join('/')}`);
796
+ }
797
+ if (error instanceof ConfigApplyInterruptedError) {
798
+ error.message = message;
799
+ if (configCommitted)
800
+ error.configWrite = 'succeeded';
801
+ throw error;
802
+ }
803
+ const safeError = new Error(message);
804
+ const code = error.code;
805
+ safeError.code = typeof code === 'string' ? code
806
+ : message.startsWith('schemaVersionUnsupported:') ? 'schemaVersionUnsupported'
807
+ : 'configApplyFailed';
808
+ const configWrite = error.configWrite;
809
+ if (configCommitted || configWrite === 'succeeded' || configWriteStateForError(error) === 'failed') {
810
+ safeError.configWrite = configCommitted || configWrite === 'succeeded' ? 'succeeded' : 'failed';
811
+ }
812
+ if (error && typeof error === 'object' && 'operationDiagnostic' in error) {
813
+ safeError.operationDiagnostic = error.operationDiagnostic;
814
+ }
815
+ throw safeError;
816
+ }
375
817
  },
376
818
  });
377
819
  }
378
820
  async function resetPluginConfigWithHelperUnlocked(options) {
379
821
  const pluginName = assertSafePluginConfigSegment(options.pluginName);
380
- const projectLayer = options.scope === 'project' ? (options.projectLayer ?? 'shared') : 'shared';
381
- if (!options.plugin) {
382
- throw new Error(`sourceMissing: Plugin "${pluginName}" is unavailable; config reset was not applied.`);
822
+ let identity = options.plugin?.sourceId ? { sourceId: options.plugin.sourceId,
823
+ sourceIdentity: options.plugin.sourceIdentity, logicalIdentity: options.plugin.catalogLogicalIdentity }
824
+ : { sourceId: options.sourceId, sourceIdentity: options.sourceIdentity, logicalIdentity: options.logicalIdentity };
825
+ if (identity.sourceId && !identity.sourceIdentity) {
826
+ try {
827
+ const stored = await readNamespacedPluginConfigStoreIdentity({ sourceId: identity.sourceId, pluginName,
828
+ scope: 'user', platform: options.platform, cwd: options.cwd, env: options.env });
829
+ if (stored)
830
+ identity = { ...identity, sourceIdentity: stored.binding.sourceIdentity };
831
+ }
832
+ catch { /* Reset remains available for unreadable identity metadata. */ }
383
833
  }
384
- const schemaAccess = await resolvePluginConfigSchemaAccess({
385
- pluginName,
386
- currentPlugin: options.plugin,
387
- scope: options.scope,
388
- projectLayer,
389
- cwd: options.cwd,
390
- env: options.env,
391
- });
392
- if (!schemaAccess.plugin?.manifest.config?.schema) {
393
- throw new Error(`configSchemaUnavailable: Plugin "${pluginName}" does not declare an AW config schema.`);
394
- }
395
- const configIdentity = options.plugin.sourceId ? {
396
- sourceId: options.plugin.sourceId,
397
- sourceIdentity: options.plugin.sourceIdentity,
398
- } : {};
399
- const store = await readPluginConfigStore({
400
- ...configIdentity,
401
- pluginName,
402
- scope: options.scope,
403
- projectLayer,
404
- cwd: options.cwd,
405
- env: options.env,
406
- });
407
- const removedKeys = collectRemovedConfigKeys(store.values);
834
+ let removedKeys = [];
835
+ try {
836
+ const store = await readPluginConfigStore({ ...identity, pluginName, scope: 'user', platform: options.platform,
837
+ cwd: options.cwd, env: options.env });
838
+ removedKeys = collectRemovedConfigKeys(store.values);
839
+ }
840
+ catch { /* Broken stores still have the path-based reset boundary. */ }
408
841
  const warnings = [];
409
- if (options.scope === 'project' && projectLayer === 'shared' && store.exists) {
410
- await assertProjectSharedConfigPathVisible({ cwd: options.cwd, targetPath: store.path });
842
+ if (options.plugin) {
843
+ try {
844
+ const impact = await analyzePluginConfigMutationImpact({ plugin: options.plugin, scope: options.scope,
845
+ platform: options.platform, cwd: options.cwd, env: options.env, visibleTargets: [],
846
+ commandDiscovery: { packages: [], errors: [] }, referencePlugins: options.rebuildRuntime?.referencePlugins,
847
+ mutation: { kind: 'reset' } });
848
+ warnings.push(...impact.referenceWarnings ?? [], ...impact.referenceBlockers ?? []);
849
+ }
850
+ catch {
851
+ warnings.push('Configuration references could not be checked. Reset will still clear the selected layer.');
852
+ }
411
853
  }
412
- if (options.scope === 'project' && projectLayer === 'local') {
413
- const ignore = await ensureProjectPrivateStateIgnore({ cwd: options.cwd, targetPath: store.path });
414
- if (ignore.warning)
415
- warnings.push(ignore.warning);
854
+ let reset;
855
+ try {
856
+ reset = await resetPluginConfigStore({ ...identity, pluginName, scope: 'user', platform: options.platform,
857
+ cwd: options.cwd, env: options.env });
858
+ }
859
+ catch (error) {
860
+ throw markConfigWriteFailed(error);
416
861
  }
417
- const reset = await resetPluginConfigStore({
418
- ...configIdentity,
419
- pluginName,
420
- scope: options.scope,
421
- projectLayer,
422
- cwd: options.cwd,
423
- env: options.env,
424
- });
425
- let applied = {
426
- overallState: 'succeeded',
427
- targetResults: [],
428
- applySkippedReason: 'noConfigChange',
429
- };
430
862
  let effective;
431
- if (schemaAccess.plugin) {
432
- if (schemaAccess.plugin.manifest.config?.schema) {
433
- effective = summarizeEffectivePluginConfig(await resolveEffectivePluginConfig({
434
- ...configIdentity,
435
- pluginName,
436
- manifest: schemaAccess.plugin.manifest,
437
- cwd: options.cwd,
438
- env: options.env,
439
- }));
863
+ let schema;
864
+ if (options.plugin) {
865
+ try {
866
+ schema = (await resolvePluginConfigSchemaAccess({ pluginName, currentPlugin: options.plugin,
867
+ scope: options.scope, platform: options.platform, cwd: options.cwd, env: options.env })).schema;
868
+ effective = summarizeEffectivePluginConfig(await resolveEffectivePluginConfig({ ...identity, pluginName,
869
+ manifest: options.plugin.manifest, platform: options.platform, targetScope: options.scope, cwd: options.cwd,
870
+ env: options.env, referencePlugins: options.rebuildRuntime?.referencePlugins }));
440
871
  }
441
- if (reset.deleted) {
442
- applied = await reinstallVisibleTargets({
443
- plugin: schemaAccess.plugin,
444
- scope: options.scope,
445
- cwd: options.cwd,
446
- env: options.env ?? process.env,
447
- applyTargets: options.applyTargets,
448
- nativeCliRunner: options.nativeCliRunner,
449
- reinstallCommandImpl: options.reinstallCommandImpl,
450
- rebuildRuntime: options.rebuildRuntime,
451
- });
872
+ catch {
873
+ warnings.push('The cleared configuration cannot be previewed. Check its schema and references before applying it.');
452
874
  }
453
875
  }
454
- const otherProjectsRequireReinstall = Boolean(schemaAccess.plugin)
455
- && options.scope === 'user'
456
- && reset.deleted;
457
- if (otherProjectsRequireReinstall)
458
- warnings.push(...otherProjectsWarning(options.scope));
459
- return {
460
- plugin: pluginName,
461
- scope: options.scope,
462
- projectLayer,
463
- ...(schemaAccess.schema ? { schema: schemaAccess.schema } : {}),
464
- existed: reset.existed,
465
- deleted: reset.deleted,
466
- removedKeys,
467
- ...(effective ? { effective } : {}),
468
- configWrite: 'succeeded',
469
- overallState: applied.overallState,
470
- targetResults: applied.targetResults,
471
- ...(applied.applySkippedReason ? { applySkippedReason: applied.applySkippedReason } : {}),
472
- otherProjectsRequireReinstall,
473
- warnings,
474
- };
876
+ if (reset.existed)
877
+ warnings.push(...otherProjectsWarning('user'));
878
+ return { plugin: pluginName, scope: 'user', context: options.scope, platform: options.platform, schema,
879
+ existed: reset.existed, deleted: reset.deleted, resetDisposition: reset.resetDisposition,
880
+ ...(reset.quarantineBasename ? { quarantineBasename: reset.quarantineBasename } : {}), removedKeys, effective,
881
+ configWrite: 'succeeded', overallState: 'succeeded', apply: skippedApply(reset.existed ? 'notRequested' : 'noConfigChange'),
882
+ otherProjectsMayRequireSync: reset.existed, warnings };
475
883
  }
476
884
  export async function resetPluginConfigWithHelper(options) {
477
- const pluginName = assertSafePluginConfigSegment(options.pluginName);
478
- if (!options.plugin) {
479
- throw new Error(`sourceMissing: Plugin "${pluginName}" is unavailable; config reset was not applied.`);
480
- }
885
+ if (options.context)
886
+ await resolveWorkContext({ cwd: options.cwd, context: options.context });
887
+ assertSafePluginConfigSegment(options.pluginName);
481
888
  return withAwHomeMutationLock({
482
889
  env: options.env,
483
890
  token: options.awHomeMutationToken,
484
891
  action: async (awHomeMutationToken) => {
485
892
  await options.reviewPreflight?.();
486
- return resetPluginConfigWithHelperUnlocked({
487
- ...options,
488
- awHomeMutationToken,
489
- rebuildRuntime: { ...options.rebuildRuntime, awHomeMutationToken },
893
+ const layerError = options.plugin && options.apply
894
+ ? await observeConfigLayerError({ ...options, plugin: options.plugin }) : undefined;
895
+ const selection = layerError ? undefined : await prepareConfigMutationApplySelection({ ...options, awHomeMutationToken });
896
+ const saved = await resetPluginConfigWithHelperUnlocked({ ...options, scope: options.context ?? options.scope,
897
+ apply: false, awHomeMutationToken, rebuildRuntime: { ...options.rebuildRuntime, awHomeMutationToken } });
898
+ if (options.apply !== true)
899
+ return saved;
900
+ if (layerError)
901
+ return { ...saved, overallState: 'partial', apply: configApplyLayerFailure(layerError) };
902
+ if (!options.plugin) {
903
+ const apply = unavailableApply('sourceUnavailable', 'source');
904
+ const cause = configActiveAvailabilityError(options.pluginError);
905
+ return { ...saved, overallState: 'partial', apply: cause ? { ...apply, error: { stage: 'source', ...cause } } : apply };
906
+ }
907
+ if (saved.apply.state === 'skipped' && saved.apply.reason === 'noConfigChange')
908
+ return saved;
909
+ if (selection?.skipReason)
910
+ return { ...saved, apply: skippedApply(selection.skipReason) };
911
+ const applied = await applyPluginConfig({ ...options, ...selection, plugin: options.plugin, awHomeMutationToken })
912
+ .catch((error) => {
913
+ if (error instanceof ConfigApplyInterruptedError)
914
+ error.configWrite = 'succeeded';
915
+ throw error;
490
916
  });
917
+ return { ...saved, overallState: applied.overallState, apply: applied.apply };
491
918
  },
492
919
  });
493
920
  }
494
921
  export async function describeResetAffectedFields(options) {
495
- const projectLayer = options.scope === 'project' ? (options.projectLayer ?? 'shared') : 'shared';
496
922
  try {
497
923
  const resolved = await resolveConfigRead({
498
924
  pluginName: options.pluginName,
499
925
  plugin: options.plugin,
500
926
  ...(options.pluginError ? { pluginError: options.pluginError } : {}),
501
927
  scope: options.scope,
502
- projectLayer,
928
+ context: options.context,
929
+ platform: options.platform,
503
930
  cwd: options.cwd,
504
931
  env: options.env,
505
932
  });
@@ -509,8 +936,8 @@ export async function describeResetAffectedFields(options) {
509
936
  kind: field.kind,
510
937
  reserved: field.reserved,
511
938
  action: 'reset',
512
- scope: options.scope,
513
- projectLayer,
939
+ scope: 'user',
940
+ platform: options.platform,
514
941
  valueState: field.valueState,
515
942
  }));
516
943
  }
@@ -519,13 +946,15 @@ export async function describeResetAffectedFields(options) {
519
946
  ...(options.plugin?.sourceId ? {
520
947
  sourceId: options.plugin.sourceId,
521
948
  sourceIdentity: options.plugin.sourceIdentity,
949
+ logicalIdentity: options.plugin.catalogLogicalIdentity,
522
950
  } : options.sourceId ? {
523
951
  sourceId: options.sourceId,
524
952
  sourceIdentity: options.sourceIdentity,
953
+ logicalIdentity: options.logicalIdentity,
525
954
  } : {}),
526
955
  pluginName: options.pluginName,
527
- scope: options.scope,
528
- projectLayer,
956
+ scope: 'user',
957
+ platform: options.platform,
529
958
  cwd: options.cwd,
530
959
  env: options.env,
531
960
  });
@@ -535,8 +964,8 @@ export async function describeResetAffectedFields(options) {
535
964
  kind: 'manifest',
536
965
  reserved: false,
537
966
  action: 'reset',
538
- scope: options.scope,
539
- projectLayer,
967
+ scope: 'user',
968
+ platform: options.platform,
540
969
  }));
541
970
  }
542
971
  }