@lesliechan721/aw 0.1.0-beta.10 → 0.1.0-beta.101

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 (864) hide show
  1. package/dist/authoring/assets/aw-config.d.mts +1 -50
  2. package/dist/authoring/assets/aw-config.mjs +58 -928
  3. package/dist/authoring/assets/aw-config.mjs.map +1 -1
  4. package/dist/authoring/assets/aw-runtime-config.d.mts +13 -0
  5. package/dist/authoring/assets/aw-runtime-config.mjs +221 -0
  6. package/dist/authoring/assets/aw-runtime-config.mjs.map +1 -0
  7. package/dist/authoring/assets/command-runtime-config.d.mts +9 -0
  8. package/dist/authoring/assets/command-runtime-config.mjs +134 -0
  9. package/dist/authoring/assets/command-runtime-config.mjs.map +1 -0
  10. package/dist/authoring/scripts/add-skill.mjs +16 -39
  11. package/dist/authoring/scripts/add-skill.mjs.map +1 -1
  12. package/dist/authoring/scripts/init-plugin.mjs +43 -71
  13. package/dist/authoring/scripts/init-plugin.mjs.map +1 -1
  14. package/dist/authoring/scripts/lib/plugin-root.mjs +4 -4
  15. package/dist/authoring/scripts/lib/plugin-root.mjs.map +1 -1
  16. package/dist/authoring/scripts/lib/plugin-version-check.d.mts +1 -0
  17. package/dist/authoring/scripts/lib/plugin-version-check.mjs +230 -9
  18. package/dist/authoring/scripts/lib/plugin-version-check.mjs.map +1 -1
  19. package/dist/authoring/scripts/lib/skill-scaffold.d.mts +3 -3
  20. package/dist/authoring/scripts/lib/skill-scaffold.mjs +5 -8
  21. package/dist/authoring/scripts/lib/skill-scaffold.mjs.map +1 -1
  22. package/dist/authoring/scripts/remove-plugin.mjs +1 -1
  23. package/dist/authoring/scripts/remove-plugin.mjs.map +1 -1
  24. package/dist/authoring/scripts/validate-plugin.mjs +408 -1748
  25. package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
  26. package/dist/authoring/scripts/validate-skill.mjs +1 -1
  27. package/dist/index.js +2 -6
  28. package/dist/index.js.map +1 -1
  29. package/dist/native-runtime/reader-runtime.mjs +34 -0
  30. package/dist/native-runtime/reader.d.mts +6 -0
  31. package/dist/native-runtime/reader.mjs +11 -0
  32. package/dist/scripts/aw-skill-eval-materializer.d.ts +11 -1
  33. package/dist/scripts/aw-skill-eval-materializer.js +119 -114
  34. package/dist/scripts/aw-skill-eval-materializer.js.map +1 -1
  35. package/dist/scripts/bundle-plugins.js +32 -7
  36. package/dist/scripts/bundle-plugins.js.map +1 -1
  37. package/dist/scripts/plugin-staging.d.ts +1 -1
  38. package/dist/scripts/plugin-staging.js +5 -2
  39. package/dist/scripts/plugin-staging.js.map +1 -1
  40. package/dist/scripts/plugin-test-context-guard.d.mts +1 -0
  41. package/dist/scripts/plugin-test-context-guard.mjs +59 -0
  42. package/dist/scripts/plugin-test-context-guard.mjs.map +1 -0
  43. package/dist/scripts/plugin-test-reporter.d.mts +2 -0
  44. package/dist/scripts/plugin-test-reporter.mjs +21 -0
  45. package/dist/scripts/plugin-test-reporter.mjs.map +1 -0
  46. package/dist/scripts/test-plugin-scripts.d.ts +5 -0
  47. package/dist/scripts/test-plugin-scripts.js +343 -58
  48. package/dist/scripts/test-plugin-scripts.js.map +1 -1
  49. package/dist/scripts/test-workers.d.mts +24 -0
  50. package/dist/scripts/test-workers.mjs +59 -0
  51. package/dist/scripts/test-workers.mjs.map +1 -0
  52. package/dist/src/adapters/helpers.d.ts +7 -0
  53. package/dist/src/adapters/helpers.js.map +1 -1
  54. package/dist/src/authoring/workspace-commands.d.ts +3 -0
  55. package/dist/src/authoring/workspace-commands.js +7 -2
  56. package/dist/src/authoring/workspace-commands.js.map +1 -1
  57. package/dist/src/commands/aw-capabilities.d.ts +1 -1
  58. package/dist/src/commands/aw-capabilities.js +48 -19
  59. package/dist/src/commands/aw-capabilities.js.map +1 -1
  60. package/dist/src/commands/catalog-dev-source.d.ts +40 -3
  61. package/dist/src/commands/catalog-dev-source.js +333 -42
  62. package/dist/src/commands/catalog-dev-source.js.map +1 -1
  63. package/dist/src/commands/catalog-generation.d.ts +5 -0
  64. package/dist/src/commands/catalog-generation.js.map +1 -1
  65. package/dist/src/commands/catalog-publication-inspection.d.ts +11 -3
  66. package/dist/src/commands/catalog-publication-inspection.js +211 -59
  67. package/dist/src/commands/catalog-publication-inspection.js.map +1 -1
  68. package/dist/src/commands/catalog-publication-journal.d.ts +12 -0
  69. package/dist/src/commands/catalog-publication-journal.js +78 -1
  70. package/dist/src/commands/catalog-publication-journal.js.map +1 -1
  71. package/dist/src/commands/catalog-publish.d.ts +21 -1
  72. package/dist/src/commands/catalog-publish.js +133 -92
  73. package/dist/src/commands/catalog-publish.js.map +1 -1
  74. package/dist/src/commands/catalog-source.d.ts +26 -5
  75. package/dist/src/commands/catalog-source.js +154 -27
  76. package/dist/src/commands/catalog-source.js.map +1 -1
  77. package/dist/src/commands/catalog-status.js +2 -2
  78. package/dist/src/commands/catalog-status.js.map +1 -1
  79. package/dist/src/commands/catalog-store.d.ts +35 -7
  80. package/dist/src/commands/catalog-store.js +469 -79
  81. package/dist/src/commands/catalog-store.js.map +1 -1
  82. package/dist/src/commands/catalog-workspace-resolution.d.ts +4 -0
  83. package/dist/src/commands/catalog-workspace-resolution.js +18 -3
  84. package/dist/src/commands/catalog-workspace-resolution.js.map +1 -1
  85. package/dist/src/commands/console.js +33 -20
  86. package/dist/src/commands/console.js.map +1 -1
  87. package/dist/src/commands/dependency-operation-plan.d.ts +7 -0
  88. package/dist/src/commands/dependency-operation-plan.js +66 -30
  89. package/dist/src/commands/dependency-operation-plan.js.map +1 -1
  90. package/dist/src/commands/deployment-confirmation.d.ts +11 -0
  91. package/dist/src/commands/deployment-confirmation.js +101 -0
  92. package/dist/src/commands/deployment-confirmation.js.map +1 -0
  93. package/dist/src/commands/init.js +1 -1
  94. package/dist/src/commands/init.js.map +1 -1
  95. package/dist/src/commands/intent-command.d.ts +35 -0
  96. package/dist/src/commands/intent-command.js +174 -0
  97. package/dist/src/commands/intent-command.js.map +1 -0
  98. package/dist/src/commands/lifecycle-command-package.d.ts +45 -0
  99. package/dist/src/commands/lifecycle-command-package.js +199 -0
  100. package/dist/src/commands/lifecycle-command-package.js.map +1 -0
  101. package/dist/src/commands/managed-commands.d.ts +41 -0
  102. package/dist/src/commands/managed-commands.js +408 -0
  103. package/dist/src/commands/managed-commands.js.map +1 -0
  104. package/dist/src/commands/offline-cleanup-evidence.d.ts +12 -2
  105. package/dist/src/commands/offline-cleanup-evidence.js +57 -35
  106. package/dist/src/commands/offline-cleanup-evidence.js.map +1 -1
  107. package/dist/src/commands/operation-plan.d.ts +72 -2
  108. package/dist/src/commands/operation-plan.js +54 -3
  109. package/dist/src/commands/operation-plan.js.map +1 -1
  110. package/dist/src/commands/operation-planner.d.ts +6 -5
  111. package/dist/src/commands/operation-planner.js +23 -20
  112. package/dist/src/commands/operation-planner.js.map +1 -1
  113. package/dist/src/commands/options.d.ts +11 -16
  114. package/dist/src/commands/options.js +31 -25
  115. package/dist/src/commands/options.js.map +1 -1
  116. package/dist/src/commands/permission-batch.d.ts +5 -0
  117. package/dist/src/commands/permission-batch.js +83 -0
  118. package/dist/src/commands/permission-batch.js.map +1 -0
  119. package/dist/src/commands/plugin-capabilities.js +128 -58
  120. package/dist/src/commands/plugin-capabilities.js.map +1 -1
  121. package/dist/src/commands/public-config-confirmation.d.ts +14 -0
  122. package/dist/src/commands/public-config-confirmation.js +73 -0
  123. package/dist/src/commands/public-config-confirmation.js.map +1 -0
  124. package/dist/src/commands/public-interruption.d.ts +9 -0
  125. package/dist/src/commands/public-interruption.js +23 -0
  126. package/dist/src/commands/public-interruption.js.map +1 -0
  127. package/dist/src/commands/public-lifecycle-result.d.ts +107 -0
  128. package/dist/src/commands/public-lifecycle-result.js +536 -0
  129. package/dist/src/commands/public-lifecycle-result.js.map +1 -0
  130. package/dist/src/commands/public-lifecycle.d.ts +28 -0
  131. package/dist/src/commands/public-lifecycle.js +633 -0
  132. package/dist/src/commands/public-lifecycle.js.map +1 -0
  133. package/dist/src/commands/public-plugin-query.d.ts +16 -0
  134. package/dist/src/commands/public-plugin-query.js +235 -0
  135. package/dist/src/commands/public-plugin-query.js.map +1 -0
  136. package/dist/src/commands/rebuild-command.d.ts +177 -16
  137. package/dist/src/commands/rebuild-command.js +3374 -1558
  138. package/dist/src/commands/rebuild-command.js.map +1 -1
  139. package/dist/src/commands/rebuild-integration.d.ts +100 -55
  140. package/dist/src/commands/rebuild-integration.js +866 -3275
  141. package/dist/src/commands/rebuild-integration.js.map +1 -1
  142. package/dist/src/commands/rebuild-operations.d.ts +68 -13
  143. package/dist/src/commands/rebuild-operations.js +309 -120
  144. package/dist/src/commands/rebuild-operations.js.map +1 -1
  145. package/dist/src/commands/rebuild-platform-integration.d.ts +99 -0
  146. package/dist/src/commands/rebuild-platform-integration.js +2329 -0
  147. package/dist/src/commands/rebuild-platform-integration.js.map +1 -0
  148. package/dist/src/commands/reconcile-operation-plan.d.ts +14 -9
  149. package/dist/src/commands/reconcile-operation-plan.js +26 -6
  150. package/dist/src/commands/reconcile-operation-plan.js.map +1 -1
  151. package/dist/src/commands/review-inspection.d.ts +60 -0
  152. package/dist/src/commands/review-inspection.js +437 -0
  153. package/dist/src/commands/review-inspection.js.map +1 -0
  154. package/dist/src/commands/review-preparation.d.ts +51 -0
  155. package/dist/src/commands/review-preparation.js +400 -0
  156. package/dist/src/commands/review-preparation.js.map +1 -0
  157. package/dist/src/commands/runtime.d.ts +7 -1
  158. package/dist/src/commands/runtime.js +41 -8
  159. package/dist/src/commands/runtime.js.map +1 -1
  160. package/dist/src/commands/skill-eval.d.ts +8 -0
  161. package/dist/src/commands/skill-eval.js +126 -73
  162. package/dist/src/commands/skill-eval.js.map +1 -1
  163. package/dist/src/commands/status-v6.d.ts +148 -35
  164. package/dist/src/commands/status-v6.js +1166 -307
  165. package/dist/src/commands/status-v6.js.map +1 -1
  166. package/dist/src/commands/targets-command.d.ts +38 -0
  167. package/dist/src/commands/targets-command.js +210 -0
  168. package/dist/src/commands/targets-command.js.map +1 -0
  169. package/dist/src/commands/wizard.d.ts +7 -3
  170. package/dist/src/commands/wizard.js +7 -4
  171. package/dist/src/commands/wizard.js.map +1 -1
  172. package/dist/src/commands/write-commands.d.ts +7 -1
  173. package/dist/src/commands/write-commands.js +129 -38
  174. package/dist/src/commands/write-commands.js.map +1 -1
  175. package/dist/src/constants.d.ts +2 -3
  176. package/dist/src/constants.js +2 -3
  177. package/dist/src/constants.js.map +1 -1
  178. package/dist/src/eval/manifest-v1.d.ts +6 -3
  179. package/dist/src/eval/manifest-v1.js +44 -33
  180. package/dist/src/eval/manifest-v1.js.map +1 -1
  181. package/dist/src/generators/local-plugin.d.ts +4 -2
  182. package/dist/src/generators/local-plugin.js +319 -353
  183. package/dist/src/generators/local-plugin.js.map +1 -1
  184. package/dist/src/generators/permissions.d.ts +20 -2
  185. package/dist/src/generators/permissions.js +82 -15
  186. package/dist/src/generators/permissions.js.map +1 -1
  187. package/dist/src/index.d.ts +3 -34
  188. package/dist/src/index.js +1711 -1935
  189. package/dist/src/index.js.map +1 -1
  190. package/dist/src/intent/deployment-preferences.d.ts +63 -0
  191. package/dist/src/intent/deployment-preferences.js +170 -0
  192. package/dist/src/intent/deployment-preferences.js.map +1 -0
  193. package/dist/src/intent/diagnostics.d.ts +11 -0
  194. package/dist/src/intent/diagnostics.js +14 -0
  195. package/dist/src/intent/diagnostics.js.map +1 -0
  196. package/dist/src/intent/intent-codec.d.ts +19 -0
  197. package/dist/src/intent/intent-codec.js +117 -0
  198. package/dist/src/intent/intent-codec.js.map +1 -0
  199. package/dist/src/intent/intent-store.d.ts +43 -0
  200. package/dist/src/intent/intent-store.js +118 -0
  201. package/dist/src/intent/intent-store.js.map +1 -0
  202. package/dist/src/intent/scope-context.d.ts +35 -0
  203. package/dist/src/intent/scope-context.js +179 -0
  204. package/dist/src/intent/scope-context.js.map +1 -0
  205. package/dist/src/intent/work-context.d.ts +13 -0
  206. package/dist/src/intent/work-context.js +22 -0
  207. package/dist/src/intent/work-context.js.map +1 -0
  208. package/dist/src/output/cli-progress.d.ts +30 -0
  209. package/dist/src/output/cli-progress.js +424 -0
  210. package/dist/src/output/cli-progress.js.map +1 -0
  211. package/dist/src/output/command-receipt.d.ts +6 -2
  212. package/dist/src/output/command-receipt.js +67 -32
  213. package/dist/src/output/command-receipt.js.map +1 -1
  214. package/dist/src/output/component-delivery.d.ts +28 -0
  215. package/dist/src/output/component-delivery.js +141 -0
  216. package/dist/src/output/component-delivery.js.map +1 -0
  217. package/dist/src/output/model.d.ts +123 -1
  218. package/dist/src/output/model.js +45 -1
  219. package/dist/src/output/model.js.map +1 -1
  220. package/dist/src/output/public-command-ids.d.ts +8 -0
  221. package/dist/src/output/public-command-ids.js +38 -0
  222. package/dist/src/output/public-command-ids.js.map +1 -0
  223. package/dist/src/output/public-result.d.ts +71 -0
  224. package/dist/src/output/public-result.js +40 -0
  225. package/dist/src/output/public-result.js.map +1 -0
  226. package/dist/src/output/rebuild-progress.d.ts +3 -0
  227. package/dist/src/output/rebuild-progress.js +34 -9
  228. package/dist/src/output/rebuild-progress.js.map +1 -1
  229. package/dist/src/output/receipt-projection.d.ts +7 -0
  230. package/dist/src/output/receipt-projection.js +670 -0
  231. package/dist/src/output/receipt-projection.js.map +1 -0
  232. package/dist/src/output/render/document.d.ts +55 -0
  233. package/dist/src/output/render/document.js +176 -0
  234. package/dist/src/output/render/document.js.map +1 -0
  235. package/dist/src/output/render/shared.d.ts +18 -0
  236. package/dist/src/output/render/shared.js +245 -0
  237. package/dist/src/output/render/shared.js.map +1 -0
  238. package/dist/src/output/render/style.d.ts +45 -0
  239. package/dist/src/output/render/style.js +155 -0
  240. package/dist/src/output/render/style.js.map +1 -0
  241. package/dist/src/output/render/views/commands-self.d.ts +6 -0
  242. package/dist/src/output/render/views/commands-self.js +210 -0
  243. package/dist/src/output/render/views/commands-self.js.map +1 -0
  244. package/dist/src/output/render/views/config.d.ts +2 -0
  245. package/dist/src/output/render/views/config.js +203 -0
  246. package/dist/src/output/render/views/config.js.map +1 -0
  247. package/dist/src/output/render/views/dev.d.ts +2 -0
  248. package/dist/src/output/render/views/dev.js +278 -0
  249. package/dist/src/output/render/views/dev.js.map +1 -0
  250. package/dist/src/output/render/views/fallback.d.ts +2 -0
  251. package/dist/src/output/render/views/fallback.js +6 -0
  252. package/dist/src/output/render/views/fallback.js.map +1 -0
  253. package/dist/src/output/render/views/index.d.ts +3 -0
  254. package/dist/src/output/render/views/index.js +79 -0
  255. package/dist/src/output/render/views/index.js.map +1 -0
  256. package/dist/src/output/render/views/lifecycle.d.ts +5 -0
  257. package/dist/src/output/render/views/lifecycle.js +170 -0
  258. package/dist/src/output/render/views/lifecycle.js.map +1 -0
  259. package/dist/src/output/render/views/sources-cache.d.ts +3 -0
  260. package/dist/src/output/render/views/sources-cache.js +322 -0
  261. package/dist/src/output/render/views/sources-cache.js.map +1 -0
  262. package/dist/src/output/render/views/targets.d.ts +2 -0
  263. package/dist/src/output/render/views/targets.js +82 -0
  264. package/dist/src/output/render/views/targets.js.map +1 -0
  265. package/dist/src/output/skill-invocation-notices.d.ts +18 -0
  266. package/dist/src/output/skill-invocation-notices.js +84 -0
  267. package/dist/src/output/skill-invocation-notices.js.map +1 -0
  268. package/dist/src/platforms/antigravity-permissions.d.ts +50 -0
  269. package/dist/src/platforms/antigravity-permissions.js +388 -0
  270. package/dist/src/platforms/antigravity-permissions.js.map +1 -0
  271. package/dist/src/platforms/capabilities.d.ts +9 -0
  272. package/dist/src/platforms/capabilities.js +125 -0
  273. package/dist/src/platforms/capabilities.js.map +1 -0
  274. package/dist/src/platforms/contracts.d.ts +394 -0
  275. package/dist/src/platforms/contracts.js +2 -0
  276. package/dist/src/platforms/contracts.js.map +1 -0
  277. package/dist/src/platforms/cursor-workspace-hook.d.ts +28 -0
  278. package/dist/src/platforms/cursor-workspace-hook.js +198 -0
  279. package/dist/src/platforms/cursor-workspace-hook.js.map +1 -0
  280. package/dist/src/platforms/discovery.d.ts +100 -0
  281. package/dist/src/platforms/discovery.js +796 -0
  282. package/dist/src/platforms/discovery.js.map +1 -0
  283. package/dist/src/platforms/grok-permission-config.d.ts +23 -0
  284. package/dist/src/platforms/grok-permission-config.js +184 -0
  285. package/dist/src/platforms/grok-permission-config.js.map +1 -0
  286. package/dist/src/platforms/grok-permission-document.d.ts +4 -0
  287. package/dist/src/platforms/grok-permission-document.js +145 -0
  288. package/dist/src/platforms/grok-permission-document.js.map +1 -0
  289. package/dist/src/platforms/grok-permissions.d.ts +17 -0
  290. package/dist/src/platforms/grok-permissions.js +311 -0
  291. package/dist/src/platforms/grok-permissions.js.map +1 -0
  292. package/dist/src/platforms/host-permission-policy.d.ts +38 -0
  293. package/dist/src/platforms/host-permission-policy.js +86 -0
  294. package/dist/src/platforms/host-permission-policy.js.map +1 -0
  295. package/dist/src/platforms/identity.d.ts +4 -0
  296. package/dist/src/platforms/identity.js +22 -0
  297. package/dist/src/platforms/identity.js.map +1 -0
  298. package/dist/src/platforms/inspection-grok.d.ts +4 -0
  299. package/dist/src/platforms/inspection-grok.js +380 -0
  300. package/dist/src/platforms/inspection-grok.js.map +1 -0
  301. package/dist/src/platforms/inspection-native.d.ts +8 -0
  302. package/dist/src/platforms/inspection-native.js +584 -0
  303. package/dist/src/platforms/inspection-native.js.map +1 -0
  304. package/dist/src/platforms/inspection-opencode.d.ts +4 -0
  305. package/dist/src/platforms/inspection-opencode.js +98 -0
  306. package/dist/src/platforms/inspection-opencode.js.map +1 -0
  307. package/dist/src/platforms/inspection-pi.d.ts +9 -0
  308. package/dist/src/platforms/inspection-pi.js +490 -0
  309. package/dist/src/platforms/inspection-pi.js.map +1 -0
  310. package/dist/src/platforms/inspection-query.d.ts +26 -0
  311. package/dist/src/platforms/inspection-query.js +118 -0
  312. package/dist/src/platforms/inspection-query.js.map +1 -0
  313. package/dist/src/platforms/inspection.d.ts +20 -0
  314. package/dist/src/platforms/inspection.js +259 -0
  315. package/dist/src/platforms/inspection.js.map +1 -0
  316. package/dist/src/platforms/layout.d.ts +35 -0
  317. package/dist/src/platforms/layout.js +332 -0
  318. package/dist/src/platforms/layout.js.map +1 -0
  319. package/dist/src/platforms/lifecycle-native-services.d.ts +3 -0
  320. package/dist/src/platforms/lifecycle-native-services.js +213 -0
  321. package/dist/src/platforms/lifecycle-native-services.js.map +1 -0
  322. package/dist/src/platforms/lifecycle-native.d.ts +14 -0
  323. package/dist/src/platforms/lifecycle-native.js +234 -0
  324. package/dist/src/platforms/lifecycle-native.js.map +1 -0
  325. package/dist/src/platforms/lifecycle.d.ts +29 -0
  326. package/dist/src/platforms/lifecycle.js +688 -0
  327. package/dist/src/platforms/lifecycle.js.map +1 -0
  328. package/dist/src/platforms/opencode-permission-config.d.ts +13 -0
  329. package/dist/src/platforms/opencode-permission-config.js +253 -0
  330. package/dist/src/platforms/opencode-permission-config.js.map +1 -0
  331. package/dist/src/platforms/opencode-permissions.d.ts +39 -0
  332. package/dist/src/platforms/opencode-permissions.js +212 -0
  333. package/dist/src/platforms/opencode-permissions.js.map +1 -0
  334. package/dist/src/platforms/opencode-related-permissions.d.ts +40 -0
  335. package/dist/src/platforms/opencode-related-permissions.js +177 -0
  336. package/dist/src/platforms/opencode-related-permissions.js.map +1 -0
  337. package/dist/src/platforms/permission-ownership.d.ts +89 -0
  338. package/dist/src/platforms/permission-ownership.js +543 -0
  339. package/dist/src/platforms/permission-ownership.js.map +1 -0
  340. package/dist/src/platforms/permission-sidecar.d.ts +70 -0
  341. package/dist/src/platforms/permission-sidecar.js +215 -0
  342. package/dist/src/platforms/permission-sidecar.js.map +1 -0
  343. package/dist/src/platforms/projection-code-extension.d.ts +8 -0
  344. package/dist/src/platforms/projection-code-extension.js +126 -0
  345. package/dist/src/platforms/projection-code-extension.js.map +1 -0
  346. package/dist/src/platforms/projection-command-resources.d.ts +7 -0
  347. package/dist/src/platforms/projection-command-resources.js +74 -0
  348. package/dist/src/platforms/projection-command-resources.js.map +1 -0
  349. package/dist/src/platforms/projection-files.d.ts +28 -0
  350. package/dist/src/platforms/projection-files.js +113 -0
  351. package/dist/src/platforms/projection-files.js.map +1 -0
  352. package/dist/src/platforms/projection-marketplace.d.ts +19 -0
  353. package/dist/src/platforms/projection-marketplace.js +42 -0
  354. package/dist/src/platforms/projection-marketplace.js.map +1 -0
  355. package/dist/src/platforms/projection.d.ts +13 -0
  356. package/dist/src/platforms/projection.js +578 -0
  357. package/dist/src/platforms/projection.js.map +1 -0
  358. package/dist/src/platforms/read-only-retry-policy.d.ts +34 -0
  359. package/dist/src/platforms/read-only-retry-policy.js +70 -0
  360. package/dist/src/platforms/read-only-retry-policy.js.map +1 -0
  361. package/dist/src/platforms/registry.d.ts +4 -0
  362. package/dist/src/platforms/registry.js +30 -0
  363. package/dist/src/platforms/registry.js.map +1 -0
  364. package/dist/src/platforms/retirement-native.d.ts +6 -0
  365. package/dist/src/platforms/retirement-native.js +95 -0
  366. package/dist/src/platforms/retirement-native.js.map +1 -0
  367. package/dist/src/platforms/supplement-layout.d.ts +20 -0
  368. package/dist/src/platforms/supplement-layout.js +54 -0
  369. package/dist/src/platforms/supplement-layout.js.map +1 -0
  370. package/dist/src/platforms/supplement-state.d.ts +13 -0
  371. package/dist/src/platforms/supplement-state.js +93 -0
  372. package/dist/src/platforms/supplement-state.js.map +1 -0
  373. package/dist/src/portable/commands.d.ts +60 -11
  374. package/dist/src/portable/commands.js +88 -346
  375. package/dist/src/portable/commands.js.map +1 -1
  376. package/dist/src/portable/historical-materialization.d.ts +25 -0
  377. package/dist/src/portable/historical-materialization.js +148 -0
  378. package/dist/src/portable/historical-materialization.js.map +1 -0
  379. package/dist/src/portable/materializer.d.ts +46 -2
  380. package/dist/src/portable/materializer.js +262 -259
  381. package/dist/src/portable/materializer.js.map +1 -1
  382. package/dist/src/portable/recovery-layout.d.ts +17 -0
  383. package/dist/src/portable/recovery-layout.js +42 -0
  384. package/dist/src/portable/recovery-layout.js.map +1 -0
  385. package/dist/src/portable/recovery.d.ts +177 -0
  386. package/dist/src/portable/recovery.js +597 -0
  387. package/dist/src/portable/recovery.js.map +1 -0
  388. package/dist/src/portable/writer.d.ts +67 -0
  389. package/dist/src/portable/writer.js +321 -0
  390. package/dist/src/portable/writer.js.map +1 -0
  391. package/dist/src/recovery/coordinator.d.ts +175 -0
  392. package/dist/src/recovery/coordinator.js +1629 -0
  393. package/dist/src/recovery/coordinator.js.map +1 -0
  394. package/dist/src/recovery/demand.d.ts +53 -0
  395. package/dist/src/recovery/demand.js +189 -0
  396. package/dist/src/recovery/demand.js.map +1 -0
  397. package/dist/src/recovery/install-concurrency.d.ts +48 -0
  398. package/dist/src/recovery/install-concurrency.js +196 -0
  399. package/dist/src/recovery/install-concurrency.js.map +1 -0
  400. package/dist/src/recovery/interruption.d.ts +19 -0
  401. package/dist/src/recovery/interruption.js +43 -0
  402. package/dist/src/recovery/interruption.js.map +1 -0
  403. package/dist/src/recovery/joint-coordinator.d.ts +46 -0
  404. package/dist/src/recovery/joint-coordinator.js +1728 -0
  405. package/dist/src/recovery/joint-coordinator.js.map +1 -0
  406. package/dist/src/recovery/joint-demand.d.ts +72 -0
  407. package/dist/src/recovery/joint-demand.js +332 -0
  408. package/dist/src/recovery/joint-demand.js.map +1 -0
  409. package/dist/src/recovery/joint-install-execution.d.ts +19 -0
  410. package/dist/src/recovery/joint-install-execution.js +312 -0
  411. package/dist/src/recovery/joint-install-execution.js.map +1 -0
  412. package/dist/src/recovery/joint-install-native-rebase.d.ts +4 -0
  413. package/dist/src/recovery/joint-install-native-rebase.js +67 -0
  414. package/dist/src/recovery/joint-install-native-rebase.js.map +1 -0
  415. package/dist/src/recovery/performance.d.ts +4 -0
  416. package/dist/src/recovery/performance.js +26 -0
  417. package/dist/src/recovery/performance.js.map +1 -0
  418. package/dist/src/recovery/receipt.d.ts +131 -0
  419. package/dist/src/recovery/receipt.js +91 -0
  420. package/dist/src/recovery/receipt.js.map +1 -0
  421. package/dist/src/recovery/retirement.d.ts +47 -0
  422. package/dist/src/recovery/retirement.js +504 -0
  423. package/dist/src/recovery/retirement.js.map +1 -0
  424. package/dist/src/recovery/status.d.ts +143 -0
  425. package/dist/src/recovery/status.js +1528 -0
  426. package/dist/src/recovery/status.js.map +1 -0
  427. package/dist/src/recovery/types.d.ts +85 -0
  428. package/dist/src/recovery/types.js +2 -0
  429. package/dist/src/recovery/types.js.map +1 -0
  430. package/dist/src/review/eval-source-input.d.ts +44 -0
  431. package/dist/src/review/eval-source-input.js +213 -0
  432. package/dist/src/review/eval-source-input.js.map +1 -0
  433. package/dist/src/review/platform-profile.d.ts +5 -0
  434. package/dist/src/review/platform-profile.js +13 -0
  435. package/dist/src/review/platform-profile.js.map +1 -0
  436. package/dist/src/review/review-profile.d.ts +20 -0
  437. package/dist/src/review/review-profile.js +286 -0
  438. package/dist/src/review/review-profile.js.map +1 -0
  439. package/dist/src/review/review-selection.d.ts +20 -0
  440. package/dist/src/review/review-selection.js +502 -0
  441. package/dist/src/review/review-selection.js.map +1 -0
  442. package/dist/src/review/review-types.d.ts +71 -0
  443. package/dist/src/review/review-types.js +16 -0
  444. package/dist/src/review/review-types.js.map +1 -0
  445. package/dist/src/review/skill-materialization.d.ts +67 -0
  446. package/dist/src/review/skill-materialization.js +235 -0
  447. package/dist/src/review/skill-materialization.js.map +1 -0
  448. package/dist/src/review/source-binding.d.ts +203 -0
  449. package/dist/src/review/source-binding.js +791 -0
  450. package/dist/src/review/source-binding.js.map +1 -0
  451. package/dist/src/tui/agent-management.d.ts +23 -0
  452. package/dist/src/tui/agent-management.js +319 -0
  453. package/dist/src/tui/agent-management.js.map +1 -0
  454. package/dist/src/tui/agent-settings.d.ts +47 -0
  455. package/dist/src/tui/agent-settings.js +97 -0
  456. package/dist/src/tui/agent-settings.js.map +1 -0
  457. package/dist/src/tui/catalog-generation.d.ts +9 -0
  458. package/dist/src/tui/catalog-generation.js +96 -6
  459. package/dist/src/tui/catalog-generation.js.map +1 -1
  460. package/dist/src/tui/catalog-sources/projection.d.ts +2 -2
  461. package/dist/src/tui/catalog-sources/screens.js +19 -12
  462. package/dist/src/tui/catalog-sources/screens.js.map +1 -1
  463. package/dist/src/tui/catalog-sources/session.d.ts +11 -1
  464. package/dist/src/tui/catalog-sources/session.js +80 -5
  465. package/dist/src/tui/catalog-sources/session.js.map +1 -1
  466. package/dist/src/tui/catalog-sources/types.d.ts +15 -2
  467. package/dist/src/tui/catalog-store-task.d.ts +16 -0
  468. package/dist/src/tui/catalog-store-task.js +19 -0
  469. package/dist/src/tui/catalog-store-task.js.map +1 -0
  470. package/dist/src/tui/clipboard.d.ts +13 -0
  471. package/dist/src/tui/clipboard.js +95 -0
  472. package/dist/src/tui/clipboard.js.map +1 -0
  473. package/dist/src/tui/components.d.ts +113 -3
  474. package/dist/src/tui/components.js +201 -34
  475. package/dist/src/tui/components.js.map +1 -1
  476. package/dist/src/tui/config-array-draft.d.ts +30 -0
  477. package/dist/src/tui/config-array-draft.js +51 -0
  478. package/dist/src/tui/config-array-draft.js.map +1 -0
  479. package/dist/src/tui/config-leaf-editor.d.ts +44 -0
  480. package/dist/src/tui/config-leaf-editor.js +227 -0
  481. package/dist/src/tui/config-leaf-editor.js.map +1 -0
  482. package/dist/src/tui/config-object-suggestions.d.ts +15 -0
  483. package/dist/src/tui/config-object-suggestions.js +71 -0
  484. package/dist/src/tui/config-object-suggestions.js.map +1 -0
  485. package/dist/src/tui/config-references.d.ts +38 -0
  486. package/dist/src/tui/config-references.js +82 -0
  487. package/dist/src/tui/config-references.js.map +1 -0
  488. package/dist/src/tui/config-suggestions.d.ts +27 -0
  489. package/dist/src/tui/config-suggestions.js +62 -0
  490. package/dist/src/tui/config-suggestions.js.map +1 -0
  491. package/dist/src/tui/config-value-presentation.d.ts +23 -0
  492. package/dist/src/tui/config-value-presentation.js +151 -0
  493. package/dist/src/tui/config-value-presentation.js.map +1 -0
  494. package/dist/src/tui/console-app-v4.d.ts +14 -5
  495. package/dist/src/tui/console-app-v4.js +9779 -2488
  496. package/dist/src/tui/console-app-v4.js.map +1 -1
  497. package/dist/src/tui/content-item-card.d.ts +13 -0
  498. package/dist/src/tui/content-item-card.js +51 -0
  499. package/dist/src/tui/content-item-card.js.map +1 -0
  500. package/dist/src/tui/controller-runtime.d.ts +4 -3
  501. package/dist/src/tui/controller-runtime.js +1610 -590
  502. package/dist/src/tui/controller-runtime.js.map +1 -1
  503. package/dist/src/tui/controller.d.ts +583 -80
  504. package/dist/src/tui/controller.js +3362 -263
  505. package/dist/src/tui/controller.js.map +1 -1
  506. package/dist/src/tui/dependency-graph-view.d.ts +39 -0
  507. package/dist/src/tui/dependency-graph-view.js +121 -0
  508. package/dist/src/tui/dependency-graph-view.js.map +1 -0
  509. package/dist/src/tui/dependency-graph.d.ts +81 -0
  510. package/dist/src/tui/dependency-graph.js +452 -0
  511. package/dist/src/tui/dependency-graph.js.map +1 -0
  512. package/dist/src/tui/deployment-view.d.ts +14 -0
  513. package/dist/src/tui/deployment-view.js +175 -0
  514. package/dist/src/tui/deployment-view.js.map +1 -0
  515. package/dist/src/tui/diagnostic-projection.d.ts +31 -0
  516. package/dist/src/tui/diagnostic-projection.js +681 -0
  517. package/dist/src/tui/diagnostic-projection.js.map +1 -0
  518. package/dist/src/tui/diagnostics.d.ts +6 -2
  519. package/dist/src/tui/diagnostics.js +14 -2
  520. package/dist/src/tui/diagnostics.js.map +1 -1
  521. package/dist/src/tui/entity-cards.d.ts +56 -0
  522. package/dist/src/tui/entity-cards.js +327 -0
  523. package/dist/src/tui/entity-cards.js.map +1 -0
  524. package/dist/src/tui/glossary.d.ts +25 -0
  525. package/dist/src/tui/glossary.js +78 -0
  526. package/dist/src/tui/glossary.js.map +1 -0
  527. package/dist/src/tui/guided-setup.d.ts +25 -0
  528. package/dist/src/tui/guided-setup.js +101 -0
  529. package/dist/src/tui/guided-setup.js.map +1 -0
  530. package/dist/src/tui/index.d.ts +4 -1
  531. package/dist/src/tui/index.js +4 -1
  532. package/dist/src/tui/index.js.map +1 -1
  533. package/dist/src/tui/input-display.d.ts +1 -0
  534. package/dist/src/tui/input-display.js +23 -1
  535. package/dist/src/tui/input-display.js.map +1 -1
  536. package/dist/src/tui/keys.d.ts +44 -0
  537. package/dist/src/tui/keys.js +43 -15
  538. package/dist/src/tui/keys.js.map +1 -1
  539. package/dist/src/tui/lifecycle-action-view.d.ts +6 -0
  540. package/dist/src/tui/lifecycle-action-view.js +36 -0
  541. package/dist/src/tui/lifecycle-action-view.js.map +1 -0
  542. package/dist/src/tui/model.d.ts +141 -28
  543. package/dist/src/tui/model.js +968 -285
  544. package/dist/src/tui/model.js.map +1 -1
  545. package/dist/src/tui/operation-diagnostic-screens.d.ts +8 -0
  546. package/dist/src/tui/operation-diagnostic-screens.js +76 -0
  547. package/dist/src/tui/operation-diagnostic-screens.js.map +1 -0
  548. package/dist/src/tui/operation-history.d.ts +91 -0
  549. package/dist/src/tui/operation-history.js +167 -0
  550. package/dist/src/tui/operation-history.js.map +1 -0
  551. package/dist/src/tui/operation-review-planner.d.ts +7 -0
  552. package/dist/src/tui/operation-review-planner.js +980 -146
  553. package/dist/src/tui/operation-review-planner.js.map +1 -1
  554. package/dist/src/tui/plugin-content.d.ts +33 -0
  555. package/dist/src/tui/plugin-content.js +245 -0
  556. package/dist/src/tui/plugin-content.js.map +1 -0
  557. package/dist/src/tui/plugin-detail.d.ts +75 -0
  558. package/dist/src/tui/plugin-detail.js +267 -0
  559. package/dist/src/tui/plugin-detail.js.map +1 -0
  560. package/dist/src/tui/plugin-write-task.d.ts +69 -0
  561. package/dist/src/tui/plugin-write-task.js +286 -0
  562. package/dist/src/tui/plugin-write-task.js.map +1 -0
  563. package/dist/src/tui/query-header.d.ts +30 -0
  564. package/dist/src/tui/query-header.js +40 -0
  565. package/dist/src/tui/query-header.js.map +1 -0
  566. package/dist/src/tui/reader.d.ts +38 -0
  567. package/dist/src/tui/reader.js +49 -0
  568. package/dist/src/tui/reader.js.map +1 -0
  569. package/dist/src/tui/router.d.ts +170 -39
  570. package/dist/src/tui/router.js +338 -50
  571. package/dist/src/tui/router.js.map +1 -1
  572. package/dist/src/tui/scoped-flow.d.ts +49 -0
  573. package/dist/src/tui/scoped-flow.js +212 -0
  574. package/dist/src/tui/scoped-flow.js.map +1 -0
  575. package/dist/src/tui/scoped-inventory.d.ts +139 -0
  576. package/dist/src/tui/scoped-inventory.js +295 -0
  577. package/dist/src/tui/scoped-inventory.js.map +1 -0
  578. package/dist/src/tui/screen-registry.d.ts +696 -0
  579. package/dist/src/tui/screen-registry.js +226 -0
  580. package/dist/src/tui/screen-registry.js.map +1 -0
  581. package/dist/src/tui/session-console-app.d.ts +8 -0
  582. package/dist/src/tui/session-console-app.js +24 -0
  583. package/dist/src/tui/session-console-app.js.map +1 -0
  584. package/dist/src/tui/session-host.d.ts +45 -0
  585. package/dist/src/tui/session-host.js +219 -0
  586. package/dist/src/tui/session-host.js.map +1 -0
  587. package/dist/src/tui/source-detail-card.d.ts +29 -0
  588. package/dist/src/tui/source-detail-card.js +45 -0
  589. package/dist/src/tui/source-detail-card.js.map +1 -0
  590. package/dist/src/tui/theme.d.ts +12 -0
  591. package/dist/src/tui/theme.js +12 -0
  592. package/dist/src/tui/theme.js.map +1 -1
  593. package/dist/src/tui/viewport.d.ts +1 -0
  594. package/dist/src/tui/viewport.js +23 -0
  595. package/dist/src/tui/viewport.js.map +1 -1
  596. package/dist/src/tui/wizard.js +26 -4
  597. package/dist/src/tui/wizard.js.map +1 -1
  598. package/dist/src/types.d.ts +105 -83
  599. package/dist/src/types.js +1 -1
  600. package/dist/src/types.js.map +1 -1
  601. package/dist/src/utils/agent-version.d.ts +10 -4
  602. package/dist/src/utils/agent-version.js +6 -8
  603. package/dist/src/utils/agent-version.js.map +1 -1
  604. package/dist/src/utils/artifact-plan.d.ts +18 -25
  605. package/dist/src/utils/artifact-plan.js +59 -445
  606. package/dist/src/utils/artifact-plan.js.map +1 -1
  607. package/dist/src/utils/artifact-renderer.d.ts +64 -90
  608. package/dist/src/utils/artifact-renderer.js +202 -303
  609. package/dist/src/utils/artifact-renderer.js.map +1 -1
  610. package/dist/src/utils/artifact-request.d.ts +19 -14
  611. package/dist/src/utils/artifact-request.js +51 -36
  612. package/dist/src/utils/artifact-request.js.map +1 -1
  613. package/dist/src/utils/artifact-sources.d.ts +4 -8
  614. package/dist/src/utils/artifact-sources.js +15 -6
  615. package/dist/src/utils/artifact-sources.js.map +1 -1
  616. package/dist/src/utils/aw-home-mutation-lock.d.ts +1 -0
  617. package/dist/src/utils/aw-home-mutation-lock.js +28 -6
  618. package/dist/src/utils/aw-home-mutation-lock.js.map +1 -1
  619. package/dist/src/utils/bundle-layout.d.ts +2 -0
  620. package/dist/src/utils/bundle-layout.js +88 -158
  621. package/dist/src/utils/bundle-layout.js.map +1 -1
  622. package/dist/src/utils/catalog-capability-projection.d.ts +8 -0
  623. package/dist/src/utils/catalog-capability-projection.js +14 -0
  624. package/dist/src/utils/catalog-capability-projection.js.map +1 -0
  625. package/dist/src/utils/catalog-digests.d.ts +2 -12
  626. package/dist/src/utils/catalog-digests.js +7 -55
  627. package/dist/src/utils/catalog-digests.js.map +1 -1
  628. package/dist/src/utils/catalog-generation-resolver.d.ts +28 -4
  629. package/dist/src/utils/catalog-generation-resolver.js +146 -40
  630. package/dist/src/utils/catalog-generation-resolver.js.map +1 -1
  631. package/dist/src/utils/catalog-generation-service.d.ts +25 -2
  632. package/dist/src/utils/catalog-generation-service.js +99 -48
  633. package/dist/src/utils/catalog-generation-service.js.map +1 -1
  634. package/dist/src/utils/catalog-generation-state.js +1 -1
  635. package/dist/src/utils/catalog-generation-state.js.map +1 -1
  636. package/dist/src/utils/catalog-generation-store.d.ts +5 -0
  637. package/dist/src/utils/catalog-generation-store.js +69 -10
  638. package/dist/src/utils/catalog-generation-store.js.map +1 -1
  639. package/dist/src/utils/catalog-operation-context.d.ts +61 -4
  640. package/dist/src/utils/catalog-operation-context.js +225 -4
  641. package/dist/src/utils/catalog-operation-context.js.map +1 -1
  642. package/dist/src/utils/catalog-public-error.js +4 -0
  643. package/dist/src/utils/catalog-public-error.js.map +1 -1
  644. package/dist/src/utils/catalog-runtime-projection.d.ts +4 -3
  645. package/dist/src/utils/catalog-runtime-projection.js.map +1 -1
  646. package/dist/src/utils/catalog-snapshot.d.ts +3 -0
  647. package/dist/src/utils/catalog-snapshot.js +4 -1
  648. package/dist/src/utils/catalog-snapshot.js.map +1 -1
  649. package/dist/src/utils/catalog-source-impact.d.ts +3 -2
  650. package/dist/src/utils/catalog-source-impact.js +142 -20
  651. package/dist/src/utils/catalog-source-impact.js.map +1 -1
  652. package/dist/src/utils/catalog-source-references.d.ts +57 -1
  653. package/dist/src/utils/catalog-source-references.js +755 -162
  654. package/dist/src/utils/catalog-source-references.js.map +1 -1
  655. package/dist/src/utils/catalog-sources.d.ts +1 -1
  656. package/dist/src/utils/catalog-sources.js +21 -5
  657. package/dist/src/utils/catalog-sources.js.map +1 -1
  658. package/dist/src/utils/codex-config.d.ts +3 -0
  659. package/dist/src/utils/codex-config.js +7 -0
  660. package/dist/src/utils/codex-config.js.map +1 -1
  661. package/dist/src/utils/codex-executable-discovery.d.ts +28 -0
  662. package/dist/src/utils/codex-executable-discovery.js +431 -0
  663. package/dist/src/utils/codex-executable-discovery.js.map +1 -0
  664. package/dist/src/utils/codex-manager.d.ts +23 -42
  665. package/dist/src/utils/codex-manager.js +79 -767
  666. package/dist/src/utils/codex-manager.js.map +1 -1
  667. package/dist/src/utils/codex-native-observation.d.ts +40 -1
  668. package/dist/src/utils/codex-native-observation.js +172 -0
  669. package/dist/src/utils/codex-native-observation.js.map +1 -1
  670. package/dist/src/utils/codex-reconciler.d.ts +2 -7
  671. package/dist/src/utils/codex-reconciler.js +33 -5
  672. package/dist/src/utils/codex-reconciler.js.map +1 -1
  673. package/dist/src/utils/codex-shared-native.d.ts +8 -26
  674. package/dist/src/utils/codex-shared-native.js +63 -83
  675. package/dist/src/utils/codex-shared-native.js.map +1 -1
  676. package/dist/src/utils/codex-skill-staging.d.ts +4 -3
  677. package/dist/src/utils/codex-skill-staging.js.map +1 -1
  678. package/dist/src/utils/codex-skills-root.d.ts +4 -0
  679. package/dist/src/utils/codex-skills-root.js +29 -0
  680. package/dist/src/utils/codex-skills-root.js.map +1 -0
  681. package/dist/src/utils/codex-surface-analysis.d.ts +6 -2
  682. package/dist/src/utils/codex-surface-analysis.js +31 -56
  683. package/dist/src/utils/codex-surface-analysis.js.map +1 -1
  684. package/dist/src/utils/component-agent-binding.d.ts +17 -0
  685. package/dist/src/utils/component-agent-binding.js +119 -0
  686. package/dist/src/utils/component-agent-binding.js.map +1 -0
  687. package/dist/src/utils/component-command-preparation.d.ts +33 -0
  688. package/dist/src/utils/component-command-preparation.js +129 -0
  689. package/dist/src/utils/component-command-preparation.js.map +1 -0
  690. package/dist/src/utils/component-gap.d.ts +4 -0
  691. package/dist/src/utils/component-gap.js +16 -0
  692. package/dist/src/utils/component-gap.js.map +1 -0
  693. package/dist/src/utils/component-resources.d.ts +53 -0
  694. package/dist/src/utils/component-resources.js +340 -0
  695. package/dist/src/utils/component-resources.js.map +1 -0
  696. package/dist/src/utils/config-platforms.d.ts +21 -0
  697. package/dist/src/utils/config-platforms.js +51 -0
  698. package/dist/src/utils/config-platforms.js.map +1 -0
  699. package/dist/src/utils/dynamic-skill-tree.d.ts +18 -6
  700. package/dist/src/utils/dynamic-skill-tree.js +33 -40
  701. package/dist/src/utils/dynamic-skill-tree.js.map +1 -1
  702. package/dist/src/utils/git-catalog-provider.d.ts +3 -0
  703. package/dist/src/utils/git-catalog-provider.js +49 -3
  704. package/dist/src/utils/git-catalog-provider.js.map +1 -1
  705. package/dist/src/utils/inventory-recovery-diagnostic.d.ts +4 -0
  706. package/dist/src/utils/inventory-recovery-diagnostic.js +15 -0
  707. package/dist/src/utils/inventory-recovery-diagnostic.js.map +1 -0
  708. package/dist/src/utils/local-marketplace.d.ts +19 -12
  709. package/dist/src/utils/local-marketplace.js +97 -194
  710. package/dist/src/utils/local-marketplace.js.map +1 -1
  711. package/dist/src/utils/managed-command-cli-review.d.ts +53 -0
  712. package/dist/src/utils/managed-command-cli-review.js +431 -0
  713. package/dist/src/utils/managed-command-cli-review.js.map +1 -0
  714. package/dist/src/utils/managed-command-closure.d.ts +14 -0
  715. package/dist/src/utils/managed-command-closure.js +156 -0
  716. package/dist/src/utils/managed-command-closure.js.map +1 -0
  717. package/dist/src/utils/managed-command-errors.d.ts +5 -0
  718. package/dist/src/utils/managed-command-errors.js +10 -0
  719. package/dist/src/utils/managed-command-errors.js.map +1 -0
  720. package/dist/src/utils/managed-command-materialization.d.ts +90 -0
  721. package/dist/src/utils/managed-command-materialization.js +375 -0
  722. package/dist/src/utils/managed-command-materialization.js.map +1 -0
  723. package/dist/src/utils/managed-command-preparation.d.ts +30 -0
  724. package/dist/src/utils/managed-command-preparation.js +39 -0
  725. package/dist/src/utils/managed-command-preparation.js.map +1 -0
  726. package/dist/src/utils/managed-command-review.d.ts +33 -0
  727. package/dist/src/utils/managed-command-review.js +80 -0
  728. package/dist/src/utils/managed-command-review.js.map +1 -0
  729. package/dist/src/utils/managed-command-runtime.d.ts +36 -0
  730. package/dist/src/utils/managed-command-runtime.js +126 -0
  731. package/dist/src/utils/managed-command-runtime.js.map +1 -0
  732. package/dist/src/utils/managed-command-snapshots.d.ts +24 -0
  733. package/dist/src/utils/managed-command-snapshots.js +89 -0
  734. package/dist/src/utils/managed-command-snapshots.js.map +1 -0
  735. package/dist/src/utils/managed-command-store.d.ts +141 -0
  736. package/dist/src/utils/managed-command-store.js +839 -0
  737. package/dist/src/utils/managed-command-store.js.map +1 -0
  738. package/dist/src/utils/multi-source-catalog.d.ts +6 -1
  739. package/dist/src/utils/multi-source-catalog.js +9 -4
  740. package/dist/src/utils/multi-source-catalog.js.map +1 -1
  741. package/dist/src/utils/native-cli-interruption.d.ts +11 -0
  742. package/dist/src/utils/native-cli-interruption.js +106 -0
  743. package/dist/src/utils/native-cli-interruption.js.map +1 -0
  744. package/dist/src/utils/native-cli.d.ts +37 -6
  745. package/dist/src/utils/native-cli.js +523 -60
  746. package/dist/src/utils/native-cli.js.map +1 -1
  747. package/dist/src/utils/native-demand.d.ts +29 -0
  748. package/dist/src/utils/native-demand.js +4 -0
  749. package/dist/src/utils/native-demand.js.map +1 -0
  750. package/dist/src/utils/native-tool-context.d.ts +17 -0
  751. package/dist/src/utils/native-tool-context.js +40 -0
  752. package/dist/src/utils/native-tool-context.js.map +1 -0
  753. package/dist/src/utils/native-tool-review.d.ts +8 -0
  754. package/dist/src/utils/native-tool-review.js +14 -0
  755. package/dist/src/utils/native-tool-review.js.map +1 -0
  756. package/dist/src/utils/ownership.d.ts +38 -3
  757. package/dist/src/utils/ownership.js +118 -11
  758. package/dist/src/utils/ownership.js.map +1 -1
  759. package/dist/src/utils/package-content.d.ts +7 -0
  760. package/dist/src/utils/package-content.js +70 -0
  761. package/dist/src/utils/package-content.js.map +1 -0
  762. package/dist/src/utils/path-catalog-provider.js +2 -0
  763. package/dist/src/utils/path-catalog-provider.js.map +1 -1
  764. package/dist/src/utils/paths.d.ts +1 -1
  765. package/dist/src/utils/paths.js +5 -2
  766. package/dist/src/utils/paths.js.map +1 -1
  767. package/dist/src/utils/platform-empty-state.d.ts +69 -0
  768. package/dist/src/utils/platform-empty-state.js +249 -0
  769. package/dist/src/utils/platform-empty-state.js.map +1 -0
  770. package/dist/src/utils/platform-support.d.ts +1 -1
  771. package/dist/src/utils/platform-support.js +1 -1
  772. package/dist/src/utils/platform-support.js.map +1 -1
  773. package/dist/src/utils/plugin-config-command-apply.d.ts +33 -0
  774. package/dist/src/utils/plugin-config-command-apply.js +142 -0
  775. package/dist/src/utils/plugin-config-command-apply.js.map +1 -0
  776. package/dist/src/utils/plugin-config-diagnostics.d.ts +16 -0
  777. package/dist/src/utils/plugin-config-diagnostics.js +44 -0
  778. package/dist/src/utils/plugin-config-diagnostics.js.map +1 -0
  779. package/dist/src/utils/plugin-config-impact.d.ts +76 -0
  780. package/dist/src/utils/plugin-config-impact.js +359 -0
  781. package/dist/src/utils/plugin-config-impact.js.map +1 -0
  782. package/dist/src/utils/plugin-config-references.d.ts +116 -0
  783. package/dist/src/utils/plugin-config-references.js +379 -0
  784. package/dist/src/utils/plugin-config-references.js.map +1 -0
  785. package/dist/src/utils/plugin-config-suggestion-runner.d.ts +83 -0
  786. package/dist/src/utils/plugin-config-suggestion-runner.js +308 -0
  787. package/dist/src/utils/plugin-config-suggestion-runner.js.map +1 -0
  788. package/dist/src/utils/plugin-config-suggestions.d.ts +50 -0
  789. package/dist/src/utils/plugin-config-suggestions.js +322 -0
  790. package/dist/src/utils/plugin-config-suggestions.js.map +1 -0
  791. package/dist/src/utils/plugin-config-write.d.ts +108 -19
  792. package/dist/src/utils/plugin-config-write.js +781 -568
  793. package/dist/src/utils/plugin-config-write.js.map +1 -1
  794. package/dist/src/utils/plugin-config.d.ts +122 -43
  795. package/dist/src/utils/plugin-config.js +574 -610
  796. package/dist/src/utils/plugin-config.js.map +1 -1
  797. package/dist/src/utils/plugin-dependencies.d.ts +1 -1
  798. package/dist/src/utils/plugin-dependencies.js.map +1 -1
  799. package/dist/src/utils/plugin-scripts.d.ts +41 -17
  800. package/dist/src/utils/plugin-scripts.js +586 -123
  801. package/dist/src/utils/plugin-scripts.js.map +1 -1
  802. package/dist/src/utils/process-lock.d.ts +1 -0
  803. package/dist/src/utils/process-lock.js +22 -5
  804. package/dist/src/utils/process-lock.js.map +1 -1
  805. package/dist/src/utils/process-tree.d.ts +2 -2
  806. package/dist/src/utils/process-tree.js +1 -1
  807. package/dist/src/utils/process-tree.js.map +1 -1
  808. package/dist/src/utils/project-boundary.d.ts +11 -1
  809. package/dist/src/utils/project-boundary.js +33 -11
  810. package/dist/src/utils/project-boundary.js.map +1 -1
  811. package/dist/src/utils/rendered-contract.js +24 -1
  812. package/dist/src/utils/rendered-contract.js.map +1 -1
  813. package/dist/src/utils/runtime-config.d.ts +18 -0
  814. package/dist/src/utils/runtime-config.js +64 -0
  815. package/dist/src/utils/runtime-config.js.map +1 -0
  816. package/dist/src/utils/runtime-skill-closure.d.ts +2 -2
  817. package/dist/src/utils/runtime-skill-closure.js +50 -7
  818. package/dist/src/utils/runtime-skill-closure.js.map +1 -1
  819. package/dist/src/utils/safe-operation-diagnostic.d.ts +15 -0
  820. package/dist/src/utils/safe-operation-diagnostic.js +33 -0
  821. package/dist/src/utils/safe-operation-diagnostic.js.map +1 -0
  822. package/dist/src/utils/sensitive-content.d.ts +4 -0
  823. package/dist/src/utils/sensitive-content.js +36 -0
  824. package/dist/src/utils/sensitive-content.js.map +1 -0
  825. package/dist/src/utils/skill-invocation-warning.d.ts +19 -0
  826. package/dist/src/utils/skill-invocation-warning.js +43 -0
  827. package/dist/src/utils/skill-invocation-warning.js.map +1 -0
  828. package/dist/src/utils/skill-validation.js +0 -5
  829. package/dist/src/utils/skill-validation.js.map +1 -1
  830. package/dist/src/utils/state-paths.d.ts +8 -3
  831. package/dist/src/utils/state-paths.js +53 -16
  832. package/dist/src/utils/state-paths.js.map +1 -1
  833. package/dist/src/utils/target-eligibility.d.ts +2 -2
  834. package/dist/src/utils/target-eligibility.js.map +1 -1
  835. package/dist/src/utils/windows-claude-shim.d.ts +7 -0
  836. package/dist/src/utils/windows-claude-shim.js +10 -0
  837. package/dist/src/utils/windows-claude-shim.js.map +1 -0
  838. package/dist/src/utils/windows-npm-shim.d.ts +16 -0
  839. package/dist/src/utils/windows-npm-shim.js +155 -0
  840. package/dist/src/utils/windows-npm-shim.js.map +1 -0
  841. package/dist/vitest.config.js +109 -9
  842. package/dist/vitest.config.js.map +1 -1
  843. package/package.json +20 -12
  844. package/dist/authoring/templates/aw-config-runtime.d.mts +0 -2
  845. package/dist/authoring/templates/aw-config-runtime.mjs +0 -407
  846. package/dist/authoring/templates/aw-config-runtime.mjs.map +0 -1
  847. package/dist/src/commands/review-publication.d.ts +0 -99
  848. package/dist/src/commands/review-publication.js +0 -904
  849. package/dist/src/commands/review-publication.js.map +0 -1
  850. package/dist/src/commands/sync-command.d.ts +0 -23
  851. package/dist/src/commands/sync-command.js +0 -242
  852. package/dist/src/commands/sync-command.js.map +0 -1
  853. package/dist/src/portable/skills-cli.d.ts +0 -43
  854. package/dist/src/portable/skills-cli.js +0 -148
  855. package/dist/src/portable/skills-cli.js.map +0 -1
  856. package/dist/src/utils/codex-native-render-receipt.d.ts +0 -40
  857. package/dist/src/utils/codex-native-render-receipt.js +0 -205
  858. package/dist/src/utils/codex-native-render-receipt.js.map +0 -1
  859. package/dist/src/utils/plugin-intent-state.d.ts +0 -34
  860. package/dist/src/utils/plugin-intent-state.js +0 -289
  861. package/dist/src/utils/plugin-intent-state.js.map +0 -1
  862. package/dist/src/utils/slash-commands.d.ts +0 -1
  863. package/dist/src/utils/slash-commands.js +0 -2
  864. package/dist/src/utils/slash-commands.js.map +0 -1
@@ -1,12 +1,32 @@
1
- import { stablePluginConfigStringify } from '@lesliechan721/aw-plugin-core/manifest';
2
- import { statusCommandV7, statusTargetIntent, } from '../commands/status-v6.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';
3
14
  import { syncWriteCommand } from '../commands/write-commands.js';
15
+ import { skillInvocationDiagnostics } from '../output/skill-invocation-notices.js';
4
16
  import { CONFIG_MUTATION_RECEIPT_SCHEMA_VERSION, } from '../types.js';
5
- import { getDefaultNativeCliRunner } from './native-cli.js';
6
- import { assertReadyPluginConfigStore, assertSafePluginConfigSegment, codexNativeRefreshKeys, coercePluginConfigUpdates, patchPluginConfigStore, readPluginConfigStore, readNamespacedPluginConfigStoreIdentity, resetPluginConfigStore, resolveConfigRead, resolveEffectivePluginConfig, resolvePluginConfigStorePath, resolvePluginConfigSchemaAccess, summarizeEffectivePluginConfig, } from './plugin-config.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, formatPluginConfigReferenceBlocker, PluginConfigReferenceBlockedError } 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';
7
24
  import { collectSensitivePluginConfigValues, redactPluginScriptOutput, } from './plugin-scripts.js';
8
- import { resolveClaudeProjectKey, resolveCodexProjectKey } from './paths.js';
25
+ import { resolveCliPackageRoot } from './paths.js';
26
+ import { readSafeOperationError } from './safe-operation-diagnostic.js';
9
27
  import { withAwHomeMutationLock, } from './aw-home-mutation-lock.js';
28
+ import fs from 'fs-extra';
29
+ import path from 'node:path';
10
30
  export function buildConfigMutationReceipt(command, receipt) {
11
31
  return {
12
32
  ...receipt,
@@ -14,6 +34,55 @@ export function buildConfigMutationReceipt(command, receipt) {
14
34
  command,
15
35
  };
16
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
+ }
17
86
  function uniqueInOrder(values) {
18
87
  return [...new Set(values)];
19
88
  }
@@ -21,7 +90,7 @@ function collectRemovedConfigKeys(values) {
21
90
  return uniqueInOrder(Object.keys(values));
22
91
  }
23
92
  function targetKey(target) {
24
- return `${target.platform}:${target.scope}:${target.projectKey ?? '-'}`;
93
+ return `${target.pluginName}:${target.platform}:${target.scope}:${target.projectKey ?? '-'}`;
25
94
  }
26
95
  function dedupeTargets(targets) {
27
96
  const deduped = new Map();
@@ -29,218 +98,158 @@ function dedupeTargets(targets) {
29
98
  deduped.set(targetKey(target), target);
30
99
  return [...deduped.values()];
31
100
  }
32
- async function resolveProjectKey(platform, cwd) {
33
- return platform === 'codex'
34
- ? resolveCodexProjectKey(cwd)
35
- : resolveClaudeProjectKey(cwd);
36
- }
37
- async function createCandidateTarget(options) {
38
- return {
39
- pluginName: options.pluginName,
40
- platform: options.platform,
41
- scope: options.scope,
42
- ...(options.scope === 'project'
43
- ? { projectKey: await resolveProjectKey(options.platform, options.cwd) }
44
- : {}),
45
- };
46
- }
47
- async function discoverVisibleTargets(options) {
48
- const targets = [];
49
- const failures = [];
50
- const selector = options.plugin.pluginId ?? options.pluginName;
51
- const status = await statusCommandV7({
52
- plugins: [selector],
53
- cwd: options.cwd,
54
- env: options.env,
55
- nativeCliRunner: options.nativeCliRunner,
56
- ...(options.scope === 'project' ? { scope: 'project' } : {}),
57
- ...(options.rebuildRuntime?.catalogOperationContext
58
- ? { catalogOperationContext: options.rebuildRuntime.catalogOperationContext }
59
- : {}),
60
- });
61
- for (const statusTarget of status.payload.targets) {
62
- const intent = statusTargetIntent(statusTarget);
63
- if ((statusTarget.pluginId !== selector && statusTarget.pluginName !== options.pluginName)
64
- || !intent.enabled)
65
- continue;
66
- for (const scope of intent.scopes) {
67
- if (options.scope === 'project' && scope !== 'project')
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))
68
107
  continue;
69
- targets.push(await createCandidateTarget({
70
- pluginName: options.pluginName,
71
- platform: statusTarget.platform,
72
- scope,
73
- cwd: options.cwd,
74
- }));
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;
75
114
  }
76
115
  }
77
- return { targets: dedupeTargets(targets), failures };
116
+ return false;
78
117
  }
79
- async function reinstallVisibleTargets(options) {
80
- const nativeCliRunner = options.nativeCliRunner ?? getDefaultNativeCliRunner();
81
- const discovered = options.discovered ?? (options.applyTargets === undefined
82
- ? await discoverVisibleTargets({
83
- pluginName: options.plugin.manifest.name,
84
- plugin: options.plugin,
85
- scope: options.scope,
86
- cwd: options.cwd,
87
- env: options.env,
88
- nativeCliRunner,
89
- rebuildRuntime: options.rebuildRuntime,
90
- })
91
- : { targets: dedupeTargets(options.applyTargets), failures: [] });
92
- const targetResults = [...discovered.failures];
93
- let runtimeFailed = discovered.failures.length > 0;
94
- const reinstall = options.reinstallCommandImpl ?? syncWriteCommand;
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
+ }
95
134
  if (options.plugin.sourceId && !options.plugin.pluginId) {
96
- throw new Error(`Plugin "${options.plugin.manifest.name}" is missing its namespaced plugin ID.`);
135
+ return {
136
+ targets: [],
137
+ availableApplyTargets: [],
138
+ unavailableTargetResults: applyTargets.map((target) => ({
139
+ target,
140
+ action: 'reinstall',
141
+ state: 'failed',
142
+ errorCode: 'sourceUnavailable',
143
+ message: 'The preApply authorization scope cannot be resolved for this target.',
144
+ })),
145
+ };
97
146
  }
98
147
  const selector = options.plugin.sourceId
99
148
  ? options.plugin.pluginId
100
149
  : options.plugin.manifest.name;
101
- const sanitizeFailure = async (message, target) => {
102
- let sensitiveValues = [];
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;
103
163
  try {
104
- const effective = await resolveEffectivePluginConfig({
105
- ...(options.plugin.sourceId ? {
106
- sourceId: options.plugin.sourceId,
107
- sourceIdentity: options.plugin.sourceIdentity,
108
- } : {}),
109
- pluginName: options.plugin.manifest.name,
110
- manifest: options.plugin.manifest,
111
- targetScope: target.scope,
112
- cwd: options.cwd,
113
- env: options.env,
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,
171
+ }, {
172
+ ...options.rebuildRuntime,
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
+ },
114
183
  });
115
- sensitiveValues = collectSensitivePluginConfigValues(options.plugin.manifest, effective.values);
184
+ if (preview.overallState !== 'succeeded' || !preview.preApplyAuthorization)
185
+ return false;
186
+ authorization.push(...preview.preApplyAuthorization);
187
+ availableApplyTargets.push(...targets);
188
+ return true;
116
189
  }
117
190
  catch {
118
- // Generic credential redaction and known config paths still apply.
191
+ return false;
119
192
  }
120
- let sanitized = redactPluginScriptOutput(message, sensitiveValues);
121
- for (const scope of ['user', 'project']) {
122
- const configPath = resolvePluginConfigStorePath({
123
- sourceId: options.plugin.sourceId,
124
- pluginName: options.plugin.manifest.name,
125
- scope,
126
- cwd: options.cwd,
127
- env: options.env,
128
- });
129
- const safeTarget = `${scope}/plugin-config/${[
130
- options.plugin.sourceId,
131
- options.plugin.manifest.name,
132
- 'config.json',
133
- ].filter(Boolean).join('/')}`;
134
- sanitized = sanitized.split(configPath).join(safeTarget);
193
+ finally {
194
+ await context?.dispose();
135
195
  }
136
- return sanitized;
137
196
  };
138
- const sanitizeProjection = async (value, target, freeText = false) => {
139
- if (typeof value === 'string')
140
- return freeText ? sanitizeFailure(value, target) : value;
141
- if (value === null || typeof value !== 'object')
142
- return value;
143
- if (Array.isArray(value)) {
144
- return Promise.all(value.map((entry) => sanitizeProjection(entry, target, freeText)));
145
- }
146
- return Object.fromEntries(await Promise.all(Object.entries(value).map(async ([key, entry]) => [
147
- key,
148
- await sanitizeProjection(entry, target, typeof entry === 'string'
149
- ? /^(?:message|error|stack|stdout|stderr|output|warning)$/u.test(key)
150
- : Array.isArray(entry) && /^(?:messages|warnings)$/u.test(key)),
151
- ])));
152
- };
153
- for (const target of discovered.targets) {
154
- try {
155
- const debugLogger = options.rebuildRuntime?.debugLogger;
156
- const reporter = options.rebuildRuntime?.reporter;
157
- const result = await reinstall([selector], {
158
- cwd: options.cwd,
159
- platform: target.platform,
160
- scope: target.scope,
161
- }, {
162
- ...options.rebuildRuntime,
163
- env: options.env,
164
- nativeCliRunner,
165
- ...(debugLogger ? {
166
- debugLogger: {
167
- ...debugLogger,
168
- log: async (value) => debugLogger.log(await sanitizeProjection(value, target)),
169
- },
170
- } : {}),
171
- ...(reporter ? {
172
- reporter: {
173
- event: async (value) => reporter.event(await sanitizeProjection(value, target)),
174
- notice: async (value) => reporter.notice(await sanitizeProjection(value, target)),
175
- },
176
- } : {}),
177
- });
178
- if (result.overallState === 'failed')
179
- runtimeFailed = true;
180
- targetResults.push(...await Promise.all(result.targetResults.map(async (entry) => ({
181
- ...entry,
182
- ...(entry.message ? { message: await sanitizeFailure(entry.message, entry.target) } : {}),
183
- }))));
184
- }
185
- catch (error) {
186
- runtimeFailed = true;
187
- const message = await sanitizeFailure(error instanceof Error ? error.message : String(error), target);
188
- targetResults.push({
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({
189
204
  target,
190
205
  action: 'reinstall',
191
206
  state: 'failed',
192
- message,
207
+ errorCode: 'sourceUnavailable',
208
+ message: 'The preApply authorization scope cannot be resolved for this target.',
193
209
  });
194
210
  }
195
211
  }
196
- const overallState = runtimeFailed || targetResults.some((entry) => entry.state === 'failed')
197
- ? 'partial' : 'succeeded';
198
212
  return {
199
- overallState,
200
- targetResults,
201
- ...(discovered.targets.length === 0 && discovered.failures.length === 0
202
- ? { applySkippedReason: 'noVisibleTarget' }
203
- : {}),
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,
204
220
  };
205
221
  }
206
- async function resolveConfigApplyTargets(options) {
207
- if (options.applyTargets !== undefined) {
208
- return { targets: dedupeTargets(options.applyTargets), failures: [] };
209
- }
210
- return discoverVisibleTargets({
211
- pluginName: options.plugin.manifest.name,
212
- plugin: options.plugin,
213
- scope: options.scope,
214
- cwd: options.cwd,
215
- env: options.env,
216
- nativeCliRunner: options.nativeCliRunner ?? getDefaultNativeCliRunner(),
217
- rebuildRuntime: options.rebuildRuntime,
218
- });
222
+ function pluginMayRunPreApply(plugin) {
223
+ return plugin.manifest.scripts?.preApply !== undefined
224
+ || (plugin.manifest.dependencies?.length ?? 0) > 0;
219
225
  }
220
- async function configApplyHasIssues(options) {
221
- const scopes = [...new Set(options.targets.map((target) => target.scope))];
222
- for (const scope of scopes) {
223
- if (options.knownValidScopes?.includes(scope))
224
- continue;
225
- const effective = await resolveEffectivePluginConfig({
226
- ...(options.plugin.sourceId ? {
227
- sourceId: options.plugin.sourceId,
228
- sourceIdentity: options.plugin.sourceIdentity,
229
- } : {}),
230
- pluginName: options.plugin.manifest.name,
231
- manifest: options.plugin.manifest,
232
- targetScope: scope,
233
- cwd: options.cwd,
234
- env: options.env,
235
- });
236
- if (effective.issues.length > 0)
237
- return true;
238
- }
239
- return false;
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')));
240
249
  }
241
250
  function otherProjectsWarning(scope) {
242
251
  return scope === 'user'
243
- ? ['其它项目不会由本次命令扫描或更新。请在每个项目目录中运行对应的 aw reinstall 命令。']
252
+ ? ['其它项目不会由本次命令扫描或更新,可能需要在对应项目目录中运行 aw plugin sync --context project。']
244
253
  : [];
245
254
  }
246
255
  function buildReceiptFieldEntry(options) {
@@ -255,247 +264,460 @@ function buildReceiptFieldEntry(options) {
255
264
  };
256
265
  }
257
266
  export async function replayConfigRuntimeWrites(options) {
258
- return withAwHomeMutationLock({
259
- env: options.env,
260
- token: options.awHomeMutationToken,
261
- action: async (awHomeMutationToken) => {
262
- const env = options.env ?? process.env;
263
- const rebuildRuntime = { ...options.rebuildRuntime, awHomeMutationToken };
264
- const discovered = await resolveConfigApplyTargets({
265
- plugin: options.plugin,
266
- scope: options.scope,
267
- cwd: options.cwd,
268
- env,
269
- applyTargets: options.applyTargets,
270
- nativeCliRunner: options.nativeCliRunner,
271
- rebuildRuntime,
272
- });
273
- const applied = await configApplyHasIssues({
274
- plugin: options.plugin,
275
- targets: discovered.targets,
276
- cwd: options.cwd,
277
- env,
278
- }) ? {
279
- overallState: 'partial',
280
- targetResults: [],
281
- applySkippedReason: 'invalidConfig',
282
- } : await reinstallVisibleTargets({
283
- plugin: options.plugin,
284
- scope: options.scope,
285
- cwd: options.cwd,
286
- env,
287
- applyTargets: options.applyTargets,
288
- nativeCliRunner: options.nativeCliRunner,
289
- reinstallCommandImpl: options.reinstallCommandImpl,
290
- rebuildRuntime,
291
- discovered,
292
- });
293
- return {
294
- configWrite: 'succeeded',
295
- overallState: applied.overallState,
296
- targetResults: applied.targetResults,
297
- ...(applied.applySkippedReason ? { applySkippedReason: applied.applySkippedReason } : {}),
298
- otherProjectsRequireReinstall: options.scope === 'user',
299
- };
300
- },
301
- });
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 };
302
273
  }
303
- function changedKeysAffectSharedNativeTarget(options) {
304
- const changedKeys = new Set(options.changedKeys);
305
- return (options.plugin.manifest.artifacts?.targets ?? []).some((target) => target.platform === 'codex'
306
- && target.target === 'codex.skill'
307
- && target.delivery?.mode === 'codex-native'
308
- && target.refreshKeys.some((key) => changedKeys.has(key)));
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')));
309
282
  }
310
- async function applyPluginConfigWriteUnlocked(options) {
311
- const requestedPluginName = options.pluginName ?? options.plugin?.manifest.name;
312
- if (!requestedPluginName)
313
- throw new Error('Plugin name is required for config write.');
314
- const pluginName = assertSafePluginConfigSegment(requestedPluginName);
315
- const configIdentity = options.plugin?.sourceId ? {
316
- sourceId: options.plugin.sourceId,
317
- sourceIdentity: options.plugin.sourceIdentity,
318
- } : {};
319
- const requestedUpdates = options.request.updates ?? {};
320
- const requestedRemoveKeys = uniqueInOrder(options.request.removeKeys ?? []);
321
- const duplicateKeys = requestedRemoveKeys.filter((key) => Object.hasOwn(requestedUpdates, key));
322
- if (duplicateKeys.length > 0) {
323
- throw new Error(`Config write cannot update and remove the same key: ${duplicateKeys.join(', ')}.`);
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;
323
+ },
324
+ };
325
+ }
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' });
337
+ });
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' });
344
+ }
324
345
  }
325
- const schemaAccess = await resolvePluginConfigSchemaAccess({
326
- pluginName,
327
- currentPlugin: options.plugin,
328
- currentPluginError: options.pluginError,
329
- scope: options.scope,
330
- cwd: options.cwd,
331
- env: options.env,
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;
378
+ });
379
+ }
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)));
332
392
  });
333
- const schemaPlugin = schemaAccess.plugin;
334
- const schema = schemaPlugin?.manifest.config?.fields;
335
- if (!schema || !schemaPlugin) {
336
- throw new Error(`configSchemaUnavailable: Plugin "${pluginName}" does not declare an AW config schema.`);
337
- }
338
- if (options.scope === 'project') {
339
- const userStore = await readPluginConfigStore({
340
- ...configIdentity,
341
- pluginName,
342
- scope: 'user',
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,
343
410
  cwd: options.cwd,
344
411
  env: options.env,
345
- schema,
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,
346
426
  });
347
- assertReadyPluginConfigStore(userStore);
348
- }
349
- for (const key of requestedRemoveKeys) {
350
- if (!schema[key])
351
- throw new Error(`Unknown config key "${key}".`);
352
- }
353
- if (options.scope === 'project') {
354
- const userOnlyKeys = codexNativeRefreshKeys(schemaPlugin.manifest);
355
- const rejectedKeys = Object.keys(requestedUpdates).filter((key) => userOnlyKeys.has(key));
356
- if (rejectedKeys.length > 0) {
357
- const error = new Error(`sharedNativeConfigUserScopeRequired: Codex native Skill refresh keys can only be set in user scope: ${rejectedKeys.join(', ')}.`);
358
- error.code = 'sharedNativeConfigUserScopeRequired';
359
- throw error;
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' });
360
438
  }
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 },
447
+ });
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 } };
361
460
  }
362
- const updates = await coercePluginConfigUpdates({ schema, updates: requestedUpdates, cwd: options.cwd });
363
- const store = await readPluginConfigStore({
364
- ...configIdentity,
365
- pluginName,
366
- scope: options.scope,
367
- cwd: options.cwd,
368
- env: options.env,
369
- schema,
370
- });
371
- assertReadyPluginConfigStore(store);
372
- const warnings = [];
373
- const removedKeys = requestedRemoveKeys.filter((key) => Object.hasOwn(store.values, key));
374
- const updatedKeys = Object.entries(updates)
375
- .filter(([key, value]) => !Object.hasOwn(store.values, key)
376
- || stablePluginConfigStringify(store.values[key]) !== stablePluginConfigStringify(value))
377
- .map(([key]) => key);
378
- const changedKeys = [...updatedKeys, ...removedKeys];
379
- let applyTargets = options.applyTargets;
380
- const sharedNativeAffected = changedKeysAffectSharedNativeTarget({
381
- plugin: schemaPlugin,
382
- changedKeys,
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;
383
510
  });
384
- if (options.apply !== false
385
- && options.scope === 'user'
386
- && options.sharedNativeApplyConfirmed === false
387
- && sharedNativeAffected) {
388
- applyTargets ??= (await discoverVisibleTargets({
389
- plugin: schemaPlugin,
390
- pluginName,
391
- scope: options.scope,
392
- cwd: options.cwd,
393
- env: options.env ?? process.env,
394
- nativeCliRunner: options.nativeCliRunner ?? getDefaultNativeCliRunner(),
395
- rebuildRuntime: options.rebuildRuntime,
396
- })).targets;
397
- if (applyTargets.some((target) => target.platform === 'codex')) {
398
- const error = new Error('sharedNativeConfigApplyConfirmationRequired: Applying this user config changes a shared Codex native artifact. Re-run with --yes.');
399
- error.code = 'sharedNativeConfigApplyConfirmationRequired';
400
- throw error;
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 new PluginConfigReferenceBlockedError(impact.referenceBlockers);
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);
401
653
  }
402
654
  }
403
- if (changedKeys.length > 0) {
404
- await patchPluginConfigStore({
405
- ...configIdentity,
406
- pluginName,
407
- scope: options.scope,
408
- cwd: options.cwd,
409
- env: options.env,
410
- updates: Object.fromEntries(updatedKeys.map((key) => [key, updates[key]])),
411
- removeKeys: requestedRemoveKeys,
412
- schema,
413
- });
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 }));
414
661
  }
415
- const effective = summarizeEffectivePluginConfig(await resolveEffectivePluginConfig({
416
- ...configIdentity,
417
- pluginName,
418
- manifest: schemaPlugin.manifest,
419
- targetScope: options.scope,
420
- cwd: options.cwd,
421
- env: options.env,
422
- }));
423
- let applied;
424
- if (changedKeys.length === 0) {
425
- applied = {
426
- overallState: 'succeeded',
427
- targetResults: [],
428
- applySkippedReason: 'noConfigChange',
429
- };
662
+ catch {
663
+ warnings.push('The saved configuration cannot be previewed. Check its schema and reference sources before applying it.');
430
664
  }
431
- else if (effective.issues.length > 0) {
432
- applied = {
433
- overallState: 'partial',
434
- targetResults: [],
435
- applySkippedReason: 'invalidConfig',
436
- };
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' } : {}) };
437
706
  }
438
- else if (options.apply === false) {
439
- applied = {
440
- overallState: 'succeeded',
441
- targetResults: [],
442
- applySkippedReason: 'notRequested',
443
- };
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;
444
712
  }
445
- else {
446
- const discovered = await resolveConfigApplyTargets({
447
- plugin: schemaPlugin,
448
- scope: options.scope,
449
- cwd: options.cwd,
450
- env: options.env ?? process.env,
451
- applyTargets: options.applyTargets,
452
- nativeCliRunner: options.nativeCliRunner,
453
- rebuildRuntime: options.rebuildRuntime,
454
- });
455
- applied = await configApplyHasIssues({
456
- plugin: schemaPlugin,
457
- targets: discovered.targets,
458
- cwd: options.cwd,
459
- env: options.env,
460
- knownValidScopes: [options.scope],
461
- }) ? {
462
- overallState: 'partial',
463
- targetResults: [],
464
- applySkippedReason: 'invalidConfig',
465
- } : await reinstallVisibleTargets({
466
- plugin: schemaPlugin,
467
- scope: options.scope,
468
- cwd: options.cwd,
469
- env: options.env ?? process.env,
470
- applyTargets,
471
- nativeCliRunner: options.nativeCliRunner,
472
- reinstallCommandImpl: options.reinstallCommandImpl,
473
- rebuildRuntime: options.rebuildRuntime,
474
- discovered,
475
- });
713
+ finally {
714
+ if (prepared)
715
+ await disposePluginConfigApply(prepared.plan);
476
716
  }
477
- const otherProjectsRequireReinstall = options.scope === 'user'
478
- && changedKeys.length > 0
479
- && effective.issues.length === 0
480
- && applied.applySkippedReason !== 'invalidConfig';
481
- if (otherProjectsRequireReinstall)
482
- warnings.push(...otherProjectsWarning(options.scope));
483
- return {
484
- plugin: pluginName,
485
- scope: options.scope,
486
- ...(schemaAccess.schema ? { schema: schemaAccess.schema } : {}),
487
- updatedKeys,
488
- removedKeys,
489
- effective,
490
- configWrite: 'succeeded',
491
- overallState: applied.overallState,
492
- targetResults: applied.targetResults,
493
- ...(applied.applySkippedReason ? { applySkippedReason: applied.applySkippedReason } : {}),
494
- otherProjectsRequireReinstall,
495
- warnings,
496
- };
497
717
  }
498
718
  export async function applyPluginConfigWrite(options) {
719
+ if (options.context)
720
+ await resolveWorkContext({ cwd: options.cwd, context: options.context });
499
721
  const requestedPluginName = options.pluginName ?? options.plugin?.manifest.name;
500
722
  if (!requestedPluginName)
501
723
  throw new Error('Plugin name is required for config write.');
@@ -505,16 +727,31 @@ export async function applyPluginConfigWrite(options) {
505
727
  token: options.awHomeMutationToken,
506
728
  action: async (awHomeMutationToken) => {
507
729
  await options.reviewPreflight?.();
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;
508
736
  try {
509
- return await applyPluginConfigWriteUnlocked({
510
- ...options,
511
- awHomeMutationToken,
512
- rebuildRuntime: { ...options.rebuildRuntime, awHomeMutationToken },
513
- });
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 };
514
751
  }
515
752
  catch (error) {
516
753
  let sensitiveValues = options.plugin
517
- ? collectSensitivePluginConfigValues(options.plugin.manifest, (options.request.updates ?? {}))
754
+ ? collectSensitivePluginConfigValues(options.plugin.manifest, (options.request.updates ?? {}), options.platform)
518
755
  : [];
519
756
  if (options.plugin) {
520
757
  try {
@@ -522,40 +759,73 @@ export async function applyPluginConfigWrite(options) {
522
759
  ...(options.plugin.sourceId ? {
523
760
  sourceId: options.plugin.sourceId,
524
761
  sourceIdentity: options.plugin.sourceIdentity,
762
+ logicalIdentity: options.plugin.catalogLogicalIdentity,
525
763
  } : {}),
526
764
  pluginName: options.plugin.manifest.name,
527
765
  manifest: options.plugin.manifest,
766
+ referencePlugins: options.rebuildRuntime?.referencePlugins,
528
767
  targetScope: options.scope,
768
+ platform: options.platform,
529
769
  cwd: options.cwd,
530
770
  env: options.env,
531
771
  });
532
772
  sensitiveValues = [
533
773
  ...sensitiveValues,
534
- ...collectSensitivePluginConfigValues(options.plugin.manifest, effective.values),
774
+ ...collectSensitivePluginConfigValues(options.plugin.manifest, effective.values, options.platform),
535
775
  ];
536
776
  }
537
777
  catch {
538
778
  // Requested sensitive values and generic credential redaction remain available.
539
779
  }
540
780
  }
541
- let message = redactPluginScriptOutput(error instanceof Error ? error.message : String(error), sensitiveValues);
542
- for (const scope of ['user', 'project']) {
543
- const configPath = resolvePluginConfigStorePath({
781
+ const configPaths = ['user', 'project'].map((scope) => ({
782
+ path: resolvePluginConfigStorePath({
544
783
  sourceId: options.plugin?.sourceId,
545
784
  pluginName: requestedPluginName,
546
785
  scope,
547
786
  cwd: options.cwd,
548
787
  env: options.env,
549
- });
550
- message = message.split(configPath).join(`${scope}/plugin-config/${[
788
+ }),
789
+ label: `${scope}/plugin-config/${[
551
790
  options.plugin?.sourceId,
552
791
  requestedPluginName,
553
792
  'config.json',
554
- ].filter(Boolean).join('/')}`);
793
+ ].filter(Boolean).join('/')}`,
794
+ }));
795
+ const redactText = (text) => {
796
+ let safe = redactPluginScriptOutput(text, sensitiveValues).split(options.cwd).join('<project>');
797
+ for (const { path, label } of configPaths)
798
+ safe = safe.split(path).join(label);
799
+ return safe;
800
+ };
801
+ const message = redactText(error instanceof Error ? error.message : String(error));
802
+ if (error instanceof ConfigApplyInterruptedError) {
803
+ error.message = message;
804
+ if (configCommitted)
805
+ error.configWrite = 'succeeded';
806
+ throw error;
555
807
  }
556
- const safeError = new Error(message);
808
+ // Preserve reference classification through the same redaction boundary as the
809
+ // public error text; saved credentials may not be present in the TUI draft.
810
+ const safeError = (error instanceof PluginConfigReferenceBlockedError
811
+ ? new PluginConfigReferenceBlockedError(error.blockers.map((blocker) => blocker.kind === 'unreadable'
812
+ ? { kind: 'unreadable', location: redactText(blocker.location) }
813
+ : { kind: 'validation', provider: redactText(blocker.provider), key: redactText(blocker.key),
814
+ consumer: redactText(blocker.consumer), issueCode: blocker.issueCode,
815
+ issuePath: redactText(blocker.issuePath), issueMessage: redactText(blocker.issueMessage) }))
816
+ : new Error(message));
817
+ safeError.message = message;
557
818
  const code = error.code;
558
- safeError.code = typeof code === 'string' ? code : 'configApplyFailed';
819
+ safeError.code = typeof code === 'string' ? code
820
+ : message.startsWith('schemaVersionUnsupported:') ? 'schemaVersionUnsupported'
821
+ : 'configApplyFailed';
822
+ const configWrite = error.configWrite;
823
+ if (configCommitted || configWrite === 'succeeded' || configWriteStateForError(error) === 'failed') {
824
+ safeError.configWrite = configCommitted || configWrite === 'succeeded' ? 'succeeded' : 'failed';
825
+ }
826
+ if (error && typeof error === 'object' && 'operationDiagnostic' in error) {
827
+ safeError.operationDiagnostic = error.operationDiagnostic;
828
+ }
559
829
  throw safeError;
560
830
  }
561
831
  },
@@ -563,166 +833,102 @@ export async function applyPluginConfigWrite(options) {
563
833
  }
564
834
  async function resetPluginConfigWithHelperUnlocked(options) {
565
835
  const pluginName = assertSafePluginConfigSegment(options.pluginName);
566
- const schemaAccess = options.plugin ? await resolvePluginConfigSchemaAccess({
567
- pluginName,
568
- currentPlugin: options.plugin,
569
- scope: options.scope,
570
- cwd: options.cwd,
571
- env: options.env,
572
- }) : undefined;
573
- let configIdentity = options.plugin?.sourceId ? {
574
- sourceId: options.plugin.sourceId,
575
- sourceIdentity: options.plugin.sourceIdentity,
576
- } : options.sourceId ? {
577
- sourceId: options.sourceId,
578
- sourceIdentity: options.sourceIdentity,
579
- } : {};
580
- if (options.sourceId && !options.sourceIdentity) {
836
+ let identity = options.plugin?.sourceId ? { sourceId: options.plugin.sourceId,
837
+ sourceIdentity: options.plugin.sourceIdentity, logicalIdentity: options.plugin.catalogLogicalIdentity }
838
+ : { sourceId: options.sourceId, sourceIdentity: options.sourceIdentity, logicalIdentity: options.logicalIdentity };
839
+ if (identity.sourceId && !identity.sourceIdentity) {
581
840
  try {
582
- const identity = await readNamespacedPluginConfigStoreIdentity({
583
- sourceId: options.sourceId,
584
- pluginName,
585
- scope: options.scope,
586
- cwd: options.cwd,
587
- env: options.env,
588
- });
589
- if (identity)
590
- configIdentity = {
591
- sourceId: options.sourceId,
592
- sourceIdentity: identity.sourceIdentity,
593
- };
594
- }
595
- catch {
596
- // Reset does not require a readable or valid envelope.
841
+ const stored = await readNamespacedPluginConfigStoreIdentity({ sourceId: identity.sourceId, pluginName,
842
+ scope: 'user', platform: options.platform, cwd: options.cwd, env: options.env });
843
+ if (stored)
844
+ identity = { ...identity, sourceIdentity: stored.binding.sourceIdentity };
597
845
  }
846
+ catch { /* Reset remains available for unreadable identity metadata. */ }
598
847
  }
599
848
  let removedKeys = [];
600
849
  try {
601
- const store = await readPluginConfigStore({
602
- ...configIdentity,
603
- pluginName,
604
- scope: options.scope,
605
- cwd: options.cwd,
606
- env: options.env,
607
- });
850
+ const store = await readPluginConfigStore({ ...identity, pluginName, scope: 'user', platform: options.platform,
851
+ cwd: options.cwd, env: options.env });
608
852
  removedKeys = collectRemovedConfigKeys(store.values);
609
853
  }
610
- catch {
611
- // Reset is the final recovery boundary and does not require a readable store.
612
- }
854
+ catch { /* Broken stores still have the path-based reset boundary. */ }
613
855
  const warnings = [];
614
- const reset = await resetPluginConfigStore({
615
- ...configIdentity,
616
- pluginName,
617
- scope: options.scope,
618
- cwd: options.cwd,
619
- env: options.env,
620
- });
621
- let applied = {
622
- overallState: 'succeeded',
623
- targetResults: [],
624
- applySkippedReason: reset.deleted ? 'notRequested' : 'noConfigChange',
625
- };
626
- let effective;
627
- if (schemaAccess?.plugin) {
628
- if (schemaAccess.plugin.manifest.config?.fields) {
629
- try {
630
- effective = summarizeEffectivePluginConfig(await resolveEffectivePluginConfig({
631
- ...configIdentity,
632
- pluginName,
633
- manifest: schemaAccess.plugin.manifest,
634
- targetScope: options.scope,
635
- cwd: options.cwd,
636
- env: options.env,
637
- }));
638
- }
639
- catch {
640
- if (options.apply !== false) {
641
- applied = {
642
- overallState: 'partial',
643
- targetResults: [],
644
- applySkippedReason: 'invalidConfig',
645
- };
646
- }
647
- }
856
+ if (options.plugin) {
857
+ try {
858
+ const impact = await analyzePluginConfigMutationImpact({ plugin: options.plugin, scope: options.scope,
859
+ platform: options.platform, cwd: options.cwd, env: options.env, visibleTargets: [],
860
+ commandDiscovery: { packages: [], errors: [] }, referencePlugins: options.rebuildRuntime?.referencePlugins,
861
+ mutation: { kind: 'reset' } });
862
+ warnings.push(...impact.referenceWarnings ?? [], ...(impact.referenceBlockers ?? []).map(formatPluginConfigReferenceBlocker));
648
863
  }
649
- if (reset.deleted && effective && effective.issues.length > 0) {
650
- applied = {
651
- overallState: 'partial',
652
- targetResults: [],
653
- applySkippedReason: 'invalidConfig',
654
- };
864
+ catch {
865
+ warnings.push('Configuration references could not be checked. Reset will still clear the selected layer.');
655
866
  }
656
- else if (reset.deleted && options.apply !== false && applied.applySkippedReason !== 'invalidConfig') {
657
- const discovered = await resolveConfigApplyTargets({
658
- plugin: schemaAccess.plugin,
659
- scope: options.scope,
660
- cwd: options.cwd,
661
- env: options.env ?? process.env,
662
- applyTargets: options.applyTargets,
663
- nativeCliRunner: options.nativeCliRunner,
664
- rebuildRuntime: options.rebuildRuntime,
665
- });
666
- applied = await configApplyHasIssues({
667
- plugin: schemaAccess.plugin,
668
- targets: discovered.targets,
669
- cwd: options.cwd,
670
- env: options.env,
671
- knownValidScopes: effective ? [options.scope] : undefined,
672
- }) ? {
673
- overallState: 'partial',
674
- targetResults: [],
675
- applySkippedReason: 'invalidConfig',
676
- } : await reinstallVisibleTargets({
677
- plugin: schemaAccess.plugin,
678
- scope: options.scope,
679
- cwd: options.cwd,
680
- env: options.env ?? process.env,
681
- applyTargets: options.applyTargets,
682
- nativeCliRunner: options.nativeCliRunner,
683
- reinstallCommandImpl: options.reinstallCommandImpl,
684
- rebuildRuntime: options.rebuildRuntime,
685
- discovered,
686
- });
867
+ }
868
+ let reset;
869
+ try {
870
+ reset = await resetPluginConfigStore({ ...identity, pluginName, scope: 'user', platform: options.platform,
871
+ cwd: options.cwd, env: options.env });
872
+ }
873
+ catch (error) {
874
+ throw markConfigWriteFailed(error);
875
+ }
876
+ let effective;
877
+ let schema;
878
+ if (options.plugin) {
879
+ try {
880
+ schema = (await resolvePluginConfigSchemaAccess({ pluginName, currentPlugin: options.plugin,
881
+ scope: options.scope, platform: options.platform, cwd: options.cwd, env: options.env })).schema;
882
+ effective = summarizeEffectivePluginConfig(await resolveEffectivePluginConfig({ ...identity, pluginName,
883
+ manifest: options.plugin.manifest, platform: options.platform, targetScope: options.scope, cwd: options.cwd,
884
+ env: options.env, referencePlugins: options.rebuildRuntime?.referencePlugins }));
885
+ }
886
+ catch {
887
+ warnings.push('The cleared configuration cannot be previewed. Check its schema and references before applying it.');
687
888
  }
688
889
  }
689
- const otherProjectsRequireReinstall = Boolean(schemaAccess?.plugin)
690
- && options.scope === 'user'
691
- && reset.deleted
692
- && (effective?.issues.length ?? 0) === 0
693
- && applied.applySkippedReason !== 'invalidConfig';
694
- if (otherProjectsRequireReinstall)
695
- warnings.push(...otherProjectsWarning(options.scope));
696
- return {
697
- plugin: pluginName,
698
- scope: options.scope,
699
- ...(schemaAccess?.schema ? { schema: schemaAccess.schema } : {}),
700
- existed: reset.existed,
701
- deleted: reset.deleted,
702
- resetDisposition: reset.resetDisposition,
703
- ...(reset.quarantineBasename ? { quarantineBasename: reset.quarantineBasename } : {}),
704
- removedKeys,
705
- ...(effective ? { effective } : {}),
706
- configWrite: 'succeeded',
707
- overallState: applied.overallState,
708
- targetResults: applied.targetResults,
709
- ...(applied.applySkippedReason ? { applySkippedReason: applied.applySkippedReason } : {}),
710
- otherProjectsRequireReinstall,
711
- warnings,
712
- };
890
+ if (reset.existed)
891
+ warnings.push(...otherProjectsWarning('user'));
892
+ return { plugin: pluginName, scope: 'user', context: options.scope, platform: options.platform, schema,
893
+ existed: reset.existed, deleted: reset.deleted, resetDisposition: reset.resetDisposition,
894
+ ...(reset.quarantineBasename ? { quarantineBasename: reset.quarantineBasename } : {}), removedKeys, effective,
895
+ configWrite: 'succeeded', overallState: 'succeeded', apply: skippedApply(reset.existed ? 'notRequested' : 'noConfigChange'),
896
+ otherProjectsMayRequireSync: reset.existed, warnings };
713
897
  }
714
898
  export async function resetPluginConfigWithHelper(options) {
899
+ if (options.context)
900
+ await resolveWorkContext({ cwd: options.cwd, context: options.context });
715
901
  assertSafePluginConfigSegment(options.pluginName);
716
902
  return withAwHomeMutationLock({
717
903
  env: options.env,
718
904
  token: options.awHomeMutationToken,
719
905
  action: async (awHomeMutationToken) => {
720
906
  await options.reviewPreflight?.();
721
- return resetPluginConfigWithHelperUnlocked({
722
- ...options,
723
- awHomeMutationToken,
724
- rebuildRuntime: { ...options.rebuildRuntime, awHomeMutationToken },
907
+ const layerError = options.plugin && options.apply
908
+ ? await observeConfigLayerError({ ...options, plugin: options.plugin }) : undefined;
909
+ const selection = layerError ? undefined : await prepareConfigMutationApplySelection({ ...options, awHomeMutationToken });
910
+ const saved = await resetPluginConfigWithHelperUnlocked({ ...options, scope: options.context ?? options.scope,
911
+ apply: false, awHomeMutationToken, rebuildRuntime: { ...options.rebuildRuntime, awHomeMutationToken } });
912
+ if (options.apply !== true)
913
+ return saved;
914
+ if (layerError)
915
+ return { ...saved, overallState: 'partial', apply: configApplyLayerFailure(layerError) };
916
+ if (!options.plugin) {
917
+ const apply = unavailableApply('sourceUnavailable', 'source');
918
+ const cause = configActiveAvailabilityError(options.pluginError);
919
+ return { ...saved, overallState: 'partial', apply: cause ? { ...apply, error: { stage: 'source', ...cause } } : apply };
920
+ }
921
+ if (saved.apply.state === 'skipped' && saved.apply.reason === 'noConfigChange')
922
+ return saved;
923
+ if (selection?.skipReason)
924
+ return { ...saved, apply: skippedApply(selection.skipReason) };
925
+ const applied = await applyPluginConfig({ ...options, ...selection, plugin: options.plugin, awHomeMutationToken })
926
+ .catch((error) => {
927
+ if (error instanceof ConfigApplyInterruptedError)
928
+ error.configWrite = 'succeeded';
929
+ throw error;
725
930
  });
931
+ return { ...saved, overallState: applied.overallState, apply: applied.apply };
726
932
  },
727
933
  });
728
934
  }
@@ -733,6 +939,8 @@ export async function describeResetAffectedFields(options) {
733
939
  plugin: options.plugin,
734
940
  ...(options.pluginError ? { pluginError: options.pluginError } : {}),
735
941
  scope: options.scope,
942
+ context: options.context,
943
+ platform: options.platform,
736
944
  cwd: options.cwd,
737
945
  env: options.env,
738
946
  });
@@ -742,7 +950,8 @@ export async function describeResetAffectedFields(options) {
742
950
  kind: field.kind,
743
951
  reserved: field.reserved,
744
952
  action: 'reset',
745
- scope: options.scope,
953
+ scope: 'user',
954
+ platform: options.platform,
746
955
  valueState: field.valueState,
747
956
  }));
748
957
  }
@@ -751,12 +960,15 @@ export async function describeResetAffectedFields(options) {
751
960
  ...(options.plugin?.sourceId ? {
752
961
  sourceId: options.plugin.sourceId,
753
962
  sourceIdentity: options.plugin.sourceIdentity,
963
+ logicalIdentity: options.plugin.catalogLogicalIdentity,
754
964
  } : options.sourceId ? {
755
965
  sourceId: options.sourceId,
756
966
  sourceIdentity: options.sourceIdentity,
967
+ logicalIdentity: options.logicalIdentity,
757
968
  } : {}),
758
969
  pluginName: options.pluginName,
759
- scope: options.scope,
970
+ scope: 'user',
971
+ platform: options.platform,
760
972
  cwd: options.cwd,
761
973
  env: options.env,
762
974
  });
@@ -766,7 +978,8 @@ export async function describeResetAffectedFields(options) {
766
978
  kind: 'manifest',
767
979
  reserved: false,
768
980
  action: 'reset',
769
- scope: options.scope,
981
+ scope: 'user',
982
+ platform: options.platform,
770
983
  }));
771
984
  }
772
985
  }