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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (829) hide show
  1. package/dist/authoring/assets/aw-config.mjs +100 -501
  2. package/dist/authoring/assets/aw-config.mjs.map +1 -1
  3. package/dist/authoring/assets/aw-runtime-config.d.mts +13 -0
  4. package/dist/authoring/assets/aw-runtime-config.mjs +221 -0
  5. package/dist/authoring/assets/aw-runtime-config.mjs.map +1 -0
  6. package/dist/authoring/assets/command-runtime-config.d.mts +9 -0
  7. package/dist/authoring/assets/command-runtime-config.mjs +134 -0
  8. package/dist/authoring/assets/command-runtime-config.mjs.map +1 -0
  9. package/dist/authoring/scripts/add-skill.mjs +15 -38
  10. package/dist/authoring/scripts/add-skill.mjs.map +1 -1
  11. package/dist/authoring/scripts/init-plugin.mjs +72 -96
  12. package/dist/authoring/scripts/init-plugin.mjs.map +1 -1
  13. package/dist/authoring/scripts/lib/plugin-root.mjs +4 -4
  14. package/dist/authoring/scripts/lib/plugin-root.mjs.map +1 -1
  15. package/dist/authoring/scripts/lib/plugin-version-check.d.mts +1 -0
  16. package/dist/authoring/scripts/lib/plugin-version-check.mjs +230 -9
  17. package/dist/authoring/scripts/lib/plugin-version-check.mjs.map +1 -1
  18. package/dist/authoring/scripts/lib/skill-scaffold.d.mts +2 -2
  19. package/dist/authoring/scripts/lib/skill-scaffold.mjs +4 -7
  20. package/dist/authoring/scripts/lib/skill-scaffold.mjs.map +1 -1
  21. package/dist/authoring/scripts/remove-plugin.mjs +1 -1
  22. package/dist/authoring/scripts/remove-plugin.mjs.map +1 -1
  23. package/dist/authoring/scripts/validate-plugin.mjs +416 -1995
  24. package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
  25. package/dist/authoring/scripts/validate-skill.mjs +1 -1
  26. package/dist/index.js +2 -6
  27. package/dist/index.js.map +1 -1
  28. package/dist/native-runtime/reader-runtime.mjs +34 -0
  29. package/dist/native-runtime/reader.d.mts +6 -0
  30. package/dist/native-runtime/reader.mjs +11 -0
  31. package/dist/scripts/aw-skill-eval-materializer.d.ts +11 -1
  32. package/dist/scripts/aw-skill-eval-materializer.js +118 -115
  33. package/dist/scripts/aw-skill-eval-materializer.js.map +1 -1
  34. package/dist/scripts/bundle-plugins.js +25 -7
  35. package/dist/scripts/bundle-plugins.js.map +1 -1
  36. package/dist/scripts/plugin-staging.d.ts +7 -7
  37. package/dist/scripts/plugin-staging.js +10 -8
  38. package/dist/scripts/plugin-staging.js.map +1 -1
  39. package/dist/scripts/plugin-test-reporter.d.mts +2 -0
  40. package/dist/scripts/plugin-test-reporter.mjs +21 -0
  41. package/dist/scripts/plugin-test-reporter.mjs.map +1 -0
  42. package/dist/scripts/test-plugin-scripts.d.ts +5 -0
  43. package/dist/scripts/test-plugin-scripts.js +284 -78
  44. package/dist/scripts/test-plugin-scripts.js.map +1 -1
  45. package/dist/scripts/test-workers.d.mts +24 -0
  46. package/dist/scripts/test-workers.mjs +59 -0
  47. package/dist/scripts/test-workers.mjs.map +1 -0
  48. package/dist/src/adapters/helpers.d.ts +7 -0
  49. package/dist/src/adapters/helpers.js.map +1 -1
  50. package/dist/src/authoring/workspace-commands.d.ts +3 -0
  51. package/dist/src/authoring/workspace-commands.js +7 -2
  52. package/dist/src/authoring/workspace-commands.js.map +1 -1
  53. package/dist/src/commands/aw-capabilities.d.ts +1 -1
  54. package/dist/src/commands/aw-capabilities.js +42 -21
  55. package/dist/src/commands/aw-capabilities.js.map +1 -1
  56. package/dist/src/commands/catalog-dev-source.d.ts +42 -3
  57. package/dist/src/commands/catalog-dev-source.js +351 -43
  58. package/dist/src/commands/catalog-dev-source.js.map +1 -1
  59. package/dist/src/commands/catalog-generation.d.ts +8 -0
  60. package/dist/src/commands/catalog-generation.js +1 -5
  61. package/dist/src/commands/catalog-generation.js.map +1 -1
  62. package/dist/src/commands/catalog-publication-inspection.d.ts +42 -3
  63. package/dist/src/commands/catalog-publication-inspection.js +379 -48
  64. package/dist/src/commands/catalog-publication-inspection.js.map +1 -1
  65. package/dist/src/commands/catalog-publication-journal.d.ts +23 -4
  66. package/dist/src/commands/catalog-publication-journal.js +165 -20
  67. package/dist/src/commands/catalog-publication-journal.js.map +1 -1
  68. package/dist/src/commands/catalog-publish.d.ts +34 -3
  69. package/dist/src/commands/catalog-publish.js +311 -165
  70. package/dist/src/commands/catalog-publish.js.map +1 -1
  71. package/dist/src/commands/catalog-source.d.ts +54 -8
  72. package/dist/src/commands/catalog-source.js +277 -15
  73. package/dist/src/commands/catalog-source.js.map +1 -1
  74. package/dist/src/commands/catalog-status.js +2 -2
  75. package/dist/src/commands/catalog-status.js.map +1 -1
  76. package/dist/src/commands/catalog-store.d.ts +104 -0
  77. package/dist/src/commands/catalog-store.js +685 -0
  78. package/dist/src/commands/catalog-store.js.map +1 -0
  79. package/dist/src/commands/catalog-workspace-resolution.d.ts +4 -0
  80. package/dist/src/commands/catalog-workspace-resolution.js +18 -3
  81. package/dist/src/commands/catalog-workspace-resolution.js.map +1 -1
  82. package/dist/src/commands/console.js +33 -20
  83. package/dist/src/commands/console.js.map +1 -1
  84. package/dist/src/commands/dependency-operation-plan.d.ts +14 -56
  85. package/dist/src/commands/dependency-operation-plan.js +90 -133
  86. package/dist/src/commands/dependency-operation-plan.js.map +1 -1
  87. package/dist/src/commands/deployment-confirmation.d.ts +11 -0
  88. package/dist/src/commands/deployment-confirmation.js +88 -0
  89. package/dist/src/commands/deployment-confirmation.js.map +1 -0
  90. package/dist/src/commands/init.js +1 -1
  91. package/dist/src/commands/init.js.map +1 -1
  92. package/dist/src/commands/intent-command.d.ts +34 -0
  93. package/dist/src/commands/intent-command.js +174 -0
  94. package/dist/src/commands/intent-command.js.map +1 -0
  95. package/dist/src/commands/lifecycle-command-package.d.ts +45 -0
  96. package/dist/src/commands/lifecycle-command-package.js +199 -0
  97. package/dist/src/commands/lifecycle-command-package.js.map +1 -0
  98. package/dist/src/commands/managed-commands.d.ts +41 -0
  99. package/dist/src/commands/managed-commands.js +404 -0
  100. package/dist/src/commands/managed-commands.js.map +1 -0
  101. package/dist/src/commands/offline-cleanup-evidence.d.ts +29 -3
  102. package/dist/src/commands/offline-cleanup-evidence.js +80 -10
  103. package/dist/src/commands/offline-cleanup-evidence.js.map +1 -1
  104. package/dist/src/commands/operation-plan.d.ts +191 -0
  105. package/dist/src/commands/operation-plan.js +96 -0
  106. package/dist/src/commands/operation-plan.js.map +1 -0
  107. package/dist/src/commands/operation-planner.d.ts +47 -0
  108. package/dist/src/commands/operation-planner.js +142 -0
  109. package/dist/src/commands/operation-planner.js.map +1 -0
  110. package/dist/src/commands/options.d.ts +11 -20
  111. package/dist/src/commands/options.js +31 -36
  112. package/dist/src/commands/options.js.map +1 -1
  113. package/dist/src/commands/permission-batch.d.ts +5 -0
  114. package/dist/src/commands/permission-batch.js +80 -0
  115. package/dist/src/commands/permission-batch.js.map +1 -0
  116. package/dist/src/commands/plugin-capabilities.js +96 -46
  117. package/dist/src/commands/plugin-capabilities.js.map +1 -1
  118. package/dist/src/commands/public-config-confirmation.d.ts +14 -0
  119. package/dist/src/commands/public-config-confirmation.js +73 -0
  120. package/dist/src/commands/public-config-confirmation.js.map +1 -0
  121. package/dist/src/commands/public-interruption.d.ts +9 -0
  122. package/dist/src/commands/public-interruption.js +23 -0
  123. package/dist/src/commands/public-interruption.js.map +1 -0
  124. package/dist/src/commands/public-lifecycle-result.d.ts +106 -0
  125. package/dist/src/commands/public-lifecycle-result.js +518 -0
  126. package/dist/src/commands/public-lifecycle-result.js.map +1 -0
  127. package/dist/src/commands/public-lifecycle.d.ts +27 -0
  128. package/dist/src/commands/public-lifecycle.js +563 -0
  129. package/dist/src/commands/public-lifecycle.js.map +1 -0
  130. package/dist/src/commands/public-plugin-query.d.ts +16 -0
  131. package/dist/src/commands/public-plugin-query.js +230 -0
  132. package/dist/src/commands/public-plugin-query.js.map +1 -0
  133. package/dist/src/commands/rebuild-command.d.ts +176 -25
  134. package/dist/src/commands/rebuild-command.js +3989 -1392
  135. package/dist/src/commands/rebuild-command.js.map +1 -1
  136. package/dist/src/commands/rebuild-integration.d.ts +133 -52
  137. package/dist/src/commands/rebuild-integration.js +1097 -2692
  138. package/dist/src/commands/rebuild-integration.js.map +1 -1
  139. package/dist/src/commands/rebuild-operations.d.ts +74 -23
  140. package/dist/src/commands/rebuild-operations.js +334 -227
  141. package/dist/src/commands/rebuild-operations.js.map +1 -1
  142. package/dist/src/commands/rebuild-platform-integration.d.ts +81 -0
  143. package/dist/src/commands/rebuild-platform-integration.js +1992 -0
  144. package/dist/src/commands/rebuild-platform-integration.js.map +1 -0
  145. package/dist/src/commands/reconcile-operation-plan.d.ts +31 -0
  146. package/dist/src/commands/reconcile-operation-plan.js +48 -0
  147. package/dist/src/commands/reconcile-operation-plan.js.map +1 -0
  148. package/dist/src/commands/review-inspection.d.ts +60 -0
  149. package/dist/src/commands/review-inspection.js +436 -0
  150. package/dist/src/commands/review-inspection.js.map +1 -0
  151. package/dist/src/commands/review-preparation.d.ts +51 -0
  152. package/dist/src/commands/review-preparation.js +400 -0
  153. package/dist/src/commands/review-preparation.js.map +1 -0
  154. package/dist/src/commands/runtime.d.ts +6 -6
  155. package/dist/src/commands/runtime.js +44 -24
  156. package/dist/src/commands/runtime.js.map +1 -1
  157. package/dist/src/commands/skill-eval.d.ts +8 -0
  158. package/dist/src/commands/skill-eval.js +126 -73
  159. package/dist/src/commands/skill-eval.js.map +1 -1
  160. package/dist/src/commands/status-v6.d.ts +185 -68
  161. package/dist/src/commands/status-v6.js +1592 -499
  162. package/dist/src/commands/status-v6.js.map +1 -1
  163. package/dist/src/commands/targets-command.d.ts +38 -0
  164. package/dist/src/commands/targets-command.js +182 -0
  165. package/dist/src/commands/targets-command.js.map +1 -0
  166. package/dist/src/commands/wizard.d.ts +8 -5
  167. package/dist/src/commands/wizard.js +7 -4
  168. package/dist/src/commands/wizard.js.map +1 -1
  169. package/dist/src/commands/write-commands.d.ts +9 -3
  170. package/dist/src/commands/write-commands.js +144 -44
  171. package/dist/src/commands/write-commands.js.map +1 -1
  172. package/dist/src/constants.d.ts +2 -3
  173. package/dist/src/constants.js +2 -3
  174. package/dist/src/constants.js.map +1 -1
  175. package/dist/src/eval/manifest-v1.d.ts +6 -2
  176. package/dist/src/eval/manifest-v1.js +58 -26
  177. package/dist/src/eval/manifest-v1.js.map +1 -1
  178. package/dist/src/generators/local-plugin.d.ts +4 -2
  179. package/dist/src/generators/local-plugin.js +207 -346
  180. package/dist/src/generators/local-plugin.js.map +1 -1
  181. package/dist/src/generators/permissions.d.ts +20 -2
  182. package/dist/src/generators/permissions.js +82 -15
  183. package/dist/src/generators/permissions.js.map +1 -1
  184. package/dist/src/index.d.ts +3 -33
  185. package/dist/src/index.js +1786 -1945
  186. package/dist/src/index.js.map +1 -1
  187. package/dist/src/intent/deployment-preferences.d.ts +63 -0
  188. package/dist/src/intent/deployment-preferences.js +170 -0
  189. package/dist/src/intent/deployment-preferences.js.map +1 -0
  190. package/dist/src/intent/diagnostics.d.ts +11 -0
  191. package/dist/src/intent/diagnostics.js +14 -0
  192. package/dist/src/intent/diagnostics.js.map +1 -0
  193. package/dist/src/intent/intent-codec.d.ts +19 -0
  194. package/dist/src/intent/intent-codec.js +117 -0
  195. package/dist/src/intent/intent-codec.js.map +1 -0
  196. package/dist/src/intent/intent-store.d.ts +43 -0
  197. package/dist/src/intent/intent-store.js +118 -0
  198. package/dist/src/intent/intent-store.js.map +1 -0
  199. package/dist/src/intent/scope-context.d.ts +35 -0
  200. package/dist/src/intent/scope-context.js +179 -0
  201. package/dist/src/intent/scope-context.js.map +1 -0
  202. package/dist/src/intent/work-context.d.ts +13 -0
  203. package/dist/src/intent/work-context.js +22 -0
  204. package/dist/src/intent/work-context.js.map +1 -0
  205. package/dist/src/output/command-receipt.d.ts +37 -86
  206. package/dist/src/output/command-receipt.js +257 -179
  207. package/dist/src/output/command-receipt.js.map +1 -1
  208. package/dist/src/output/component-delivery.d.ts +28 -0
  209. package/dist/src/output/component-delivery.js +138 -0
  210. package/dist/src/output/component-delivery.js.map +1 -0
  211. package/dist/src/output/public-result.d.ts +69 -0
  212. package/dist/src/output/public-result.js +403 -0
  213. package/dist/src/output/public-result.js.map +1 -0
  214. package/dist/src/output/rebuild-progress.d.ts +3 -0
  215. package/dist/src/output/rebuild-progress.js +34 -16
  216. package/dist/src/output/rebuild-progress.js.map +1 -1
  217. package/dist/src/output/receipt-projection.d.ts +7 -0
  218. package/dist/src/output/receipt-projection.js +664 -0
  219. package/dist/src/output/receipt-projection.js.map +1 -0
  220. package/dist/src/output/skill-invocation-notices.d.ts +18 -0
  221. package/dist/src/output/skill-invocation-notices.js +84 -0
  222. package/dist/src/output/skill-invocation-notices.js.map +1 -0
  223. package/dist/src/platforms/antigravity-permissions.d.ts +50 -0
  224. package/dist/src/platforms/antigravity-permissions.js +388 -0
  225. package/dist/src/platforms/antigravity-permissions.js.map +1 -0
  226. package/dist/src/platforms/capabilities.d.ts +17 -0
  227. package/dist/src/platforms/capabilities.js +328 -0
  228. package/dist/src/platforms/capabilities.js.map +1 -0
  229. package/dist/src/platforms/contracts.d.ts +402 -0
  230. package/dist/src/platforms/contracts.js +2 -0
  231. package/dist/src/platforms/contracts.js.map +1 -0
  232. package/dist/src/platforms/cursor-workspace-hook.d.ts +28 -0
  233. package/dist/src/platforms/cursor-workspace-hook.js +198 -0
  234. package/dist/src/platforms/cursor-workspace-hook.js.map +1 -0
  235. package/dist/src/platforms/discovery.d.ts +98 -0
  236. package/dist/src/platforms/discovery.js +777 -0
  237. package/dist/src/platforms/discovery.js.map +1 -0
  238. package/dist/src/platforms/grok-permission-config.d.ts +23 -0
  239. package/dist/src/platforms/grok-permission-config.js +184 -0
  240. package/dist/src/platforms/grok-permission-config.js.map +1 -0
  241. package/dist/src/platforms/grok-permission-document.d.ts +4 -0
  242. package/dist/src/platforms/grok-permission-document.js +145 -0
  243. package/dist/src/platforms/grok-permission-document.js.map +1 -0
  244. package/dist/src/platforms/grok-permissions.d.ts +17 -0
  245. package/dist/src/platforms/grok-permissions.js +311 -0
  246. package/dist/src/platforms/grok-permissions.js.map +1 -0
  247. package/dist/src/platforms/host-permission-policy.d.ts +38 -0
  248. package/dist/src/platforms/host-permission-policy.js +86 -0
  249. package/dist/src/platforms/host-permission-policy.js.map +1 -0
  250. package/dist/src/platforms/identity.d.ts +4 -0
  251. package/dist/src/platforms/identity.js +22 -0
  252. package/dist/src/platforms/identity.js.map +1 -0
  253. package/dist/src/platforms/inspection-grok.d.ts +4 -0
  254. package/dist/src/platforms/inspection-grok.js +366 -0
  255. package/dist/src/platforms/inspection-grok.js.map +1 -0
  256. package/dist/src/platforms/inspection-native.d.ts +6 -0
  257. package/dist/src/platforms/inspection-native.js +373 -0
  258. package/dist/src/platforms/inspection-native.js.map +1 -0
  259. package/dist/src/platforms/inspection-opencode.d.ts +4 -0
  260. package/dist/src/platforms/inspection-opencode.js +98 -0
  261. package/dist/src/platforms/inspection-opencode.js.map +1 -0
  262. package/dist/src/platforms/inspection-pi.d.ts +9 -0
  263. package/dist/src/platforms/inspection-pi.js +482 -0
  264. package/dist/src/platforms/inspection-pi.js.map +1 -0
  265. package/dist/src/platforms/inspection-query.d.ts +24 -0
  266. package/dist/src/platforms/inspection-query.js +119 -0
  267. package/dist/src/platforms/inspection-query.js.map +1 -0
  268. package/dist/src/platforms/inspection.d.ts +20 -0
  269. package/dist/src/platforms/inspection.js +259 -0
  270. package/dist/src/platforms/inspection.js.map +1 -0
  271. package/dist/src/platforms/layout.d.ts +35 -0
  272. package/dist/src/platforms/layout.js +317 -0
  273. package/dist/src/platforms/layout.js.map +1 -0
  274. package/dist/src/platforms/lifecycle-native-services.d.ts +3 -0
  275. package/dist/src/platforms/lifecycle-native-services.js +147 -0
  276. package/dist/src/platforms/lifecycle-native-services.js.map +1 -0
  277. package/dist/src/platforms/lifecycle-native.d.ts +14 -0
  278. package/dist/src/platforms/lifecycle-native.js +223 -0
  279. package/dist/src/platforms/lifecycle-native.js.map +1 -0
  280. package/dist/src/platforms/lifecycle.d.ts +27 -0
  281. package/dist/src/platforms/lifecycle.js +567 -0
  282. package/dist/src/platforms/lifecycle.js.map +1 -0
  283. package/dist/src/platforms/opencode-permission-config.d.ts +13 -0
  284. package/dist/src/platforms/opencode-permission-config.js +253 -0
  285. package/dist/src/platforms/opencode-permission-config.js.map +1 -0
  286. package/dist/src/platforms/opencode-permissions.d.ts +39 -0
  287. package/dist/src/platforms/opencode-permissions.js +212 -0
  288. package/dist/src/platforms/opencode-permissions.js.map +1 -0
  289. package/dist/src/platforms/opencode-related-permissions.d.ts +40 -0
  290. package/dist/src/platforms/opencode-related-permissions.js +177 -0
  291. package/dist/src/platforms/opencode-related-permissions.js.map +1 -0
  292. package/dist/src/platforms/permission-ownership.d.ts +89 -0
  293. package/dist/src/platforms/permission-ownership.js +543 -0
  294. package/dist/src/platforms/permission-ownership.js.map +1 -0
  295. package/dist/src/platforms/permission-sidecar.d.ts +70 -0
  296. package/dist/src/platforms/permission-sidecar.js +215 -0
  297. package/dist/src/platforms/permission-sidecar.js.map +1 -0
  298. package/dist/src/platforms/projection-code-extension.d.ts +8 -0
  299. package/dist/src/platforms/projection-code-extension.js +126 -0
  300. package/dist/src/platforms/projection-code-extension.js.map +1 -0
  301. package/dist/src/platforms/projection-command-resources.d.ts +7 -0
  302. package/dist/src/platforms/projection-command-resources.js +74 -0
  303. package/dist/src/platforms/projection-command-resources.js.map +1 -0
  304. package/dist/src/platforms/projection-files.d.ts +27 -0
  305. package/dist/src/platforms/projection-files.js +111 -0
  306. package/dist/src/platforms/projection-files.js.map +1 -0
  307. package/dist/src/platforms/projection-marketplace.d.ts +19 -0
  308. package/dist/src/platforms/projection-marketplace.js +42 -0
  309. package/dist/src/platforms/projection-marketplace.js.map +1 -0
  310. package/dist/src/platforms/projection.d.ts +13 -0
  311. package/dist/src/platforms/projection.js +576 -0
  312. package/dist/src/platforms/projection.js.map +1 -0
  313. package/dist/src/platforms/registry.d.ts +4 -0
  314. package/dist/src/platforms/registry.js +30 -0
  315. package/dist/src/platforms/registry.js.map +1 -0
  316. package/dist/src/platforms/supplement-layout.d.ts +20 -0
  317. package/dist/src/platforms/supplement-layout.js +53 -0
  318. package/dist/src/platforms/supplement-layout.js.map +1 -0
  319. package/dist/src/platforms/supplement-state.d.ts +13 -0
  320. package/dist/src/platforms/supplement-state.js +93 -0
  321. package/dist/src/platforms/supplement-state.js.map +1 -0
  322. package/dist/src/portable/commands.d.ts +58 -11
  323. package/dist/src/portable/commands.js +99 -345
  324. package/dist/src/portable/commands.js.map +1 -1
  325. package/dist/src/portable/historical-materialization.d.ts +22 -0
  326. package/dist/src/portable/historical-materialization.js +124 -0
  327. package/dist/src/portable/historical-materialization.js.map +1 -0
  328. package/dist/src/portable/materializer.d.ts +29 -1
  329. package/dist/src/portable/materializer.js +197 -258
  330. package/dist/src/portable/materializer.js.map +1 -1
  331. package/dist/src/portable/recovery-layout.d.ts +17 -0
  332. package/dist/src/portable/recovery-layout.js +42 -0
  333. package/dist/src/portable/recovery-layout.js.map +1 -0
  334. package/dist/src/portable/recovery.d.ts +176 -0
  335. package/dist/src/portable/recovery.js +556 -0
  336. package/dist/src/portable/recovery.js.map +1 -0
  337. package/dist/src/portable/writer.d.ts +67 -0
  338. package/dist/src/portable/writer.js +321 -0
  339. package/dist/src/portable/writer.js.map +1 -0
  340. package/dist/src/recovery/coordinator.d.ts +168 -0
  341. package/dist/src/recovery/coordinator.js +1558 -0
  342. package/dist/src/recovery/coordinator.js.map +1 -0
  343. package/dist/src/recovery/demand.d.ts +53 -0
  344. package/dist/src/recovery/demand.js +189 -0
  345. package/dist/src/recovery/demand.js.map +1 -0
  346. package/dist/src/recovery/install-concurrency.d.ts +48 -0
  347. package/dist/src/recovery/install-concurrency.js +196 -0
  348. package/dist/src/recovery/install-concurrency.js.map +1 -0
  349. package/dist/src/recovery/interruption.d.ts +19 -0
  350. package/dist/src/recovery/interruption.js +43 -0
  351. package/dist/src/recovery/interruption.js.map +1 -0
  352. package/dist/src/recovery/joint-coordinator.d.ts +46 -0
  353. package/dist/src/recovery/joint-coordinator.js +1641 -0
  354. package/dist/src/recovery/joint-coordinator.js.map +1 -0
  355. package/dist/src/recovery/joint-demand.d.ts +72 -0
  356. package/dist/src/recovery/joint-demand.js +332 -0
  357. package/dist/src/recovery/joint-demand.js.map +1 -0
  358. package/dist/src/recovery/joint-install-execution.d.ts +19 -0
  359. package/dist/src/recovery/joint-install-execution.js +308 -0
  360. package/dist/src/recovery/joint-install-execution.js.map +1 -0
  361. package/dist/src/recovery/joint-install-native-rebase.d.ts +4 -0
  362. package/dist/src/recovery/joint-install-native-rebase.js +67 -0
  363. package/dist/src/recovery/joint-install-native-rebase.js.map +1 -0
  364. package/dist/src/recovery/performance.d.ts +4 -0
  365. package/dist/src/recovery/performance.js +26 -0
  366. package/dist/src/recovery/performance.js.map +1 -0
  367. package/dist/src/recovery/receipt.d.ts +129 -0
  368. package/dist/src/recovery/receipt.js +91 -0
  369. package/dist/src/recovery/receipt.js.map +1 -0
  370. package/dist/src/recovery/retirement.d.ts +47 -0
  371. package/dist/src/recovery/retirement.js +463 -0
  372. package/dist/src/recovery/retirement.js.map +1 -0
  373. package/dist/src/recovery/status.d.ts +143 -0
  374. package/dist/src/recovery/status.js +1517 -0
  375. package/dist/src/recovery/status.js.map +1 -0
  376. package/dist/src/recovery/types.d.ts +85 -0
  377. package/dist/src/recovery/types.js +2 -0
  378. package/dist/src/recovery/types.js.map +1 -0
  379. package/dist/src/review/eval-source-input.d.ts +44 -0
  380. package/dist/src/review/eval-source-input.js +213 -0
  381. package/dist/src/review/eval-source-input.js.map +1 -0
  382. package/dist/src/review/platform-profile.d.ts +6 -0
  383. package/dist/src/review/platform-profile.js +24 -0
  384. package/dist/src/review/platform-profile.js.map +1 -0
  385. package/dist/src/review/review-profile.d.ts +20 -0
  386. package/dist/src/review/review-profile.js +276 -0
  387. package/dist/src/review/review-profile.js.map +1 -0
  388. package/dist/src/review/review-selection.d.ts +20 -0
  389. package/dist/src/review/review-selection.js +502 -0
  390. package/dist/src/review/review-selection.js.map +1 -0
  391. package/dist/src/review/review-types.d.ts +71 -0
  392. package/dist/src/review/review-types.js +16 -0
  393. package/dist/src/review/review-types.js.map +1 -0
  394. package/dist/src/review/skill-materialization.d.ts +65 -0
  395. package/dist/src/review/skill-materialization.js +228 -0
  396. package/dist/src/review/skill-materialization.js.map +1 -0
  397. package/dist/src/review/source-binding.d.ts +201 -0
  398. package/dist/src/review/source-binding.js +782 -0
  399. package/dist/src/review/source-binding.js.map +1 -0
  400. package/dist/src/tui/agent-management.d.ts +23 -0
  401. package/dist/src/tui/agent-management.js +319 -0
  402. package/dist/src/tui/agent-management.js.map +1 -0
  403. package/dist/src/tui/agent-settings.d.ts +47 -0
  404. package/dist/src/tui/agent-settings.js +97 -0
  405. package/dist/src/tui/agent-settings.js.map +1 -0
  406. package/dist/src/tui/catalog-freshness.d.ts +1 -0
  407. package/dist/src/tui/catalog-freshness.js +2 -0
  408. package/dist/src/tui/catalog-freshness.js.map +1 -0
  409. package/dist/src/tui/catalog-generation.d.ts +8 -16
  410. package/dist/src/tui/catalog-generation.js +97 -10
  411. package/dist/src/tui/catalog-generation.js.map +1 -1
  412. package/dist/src/tui/catalog-sources/projection.d.ts +4 -0
  413. package/dist/src/tui/catalog-sources/projection.js +17 -0
  414. package/dist/src/tui/catalog-sources/projection.js.map +1 -0
  415. package/dist/src/tui/catalog-sources/review.d.ts +3 -0
  416. package/dist/src/tui/catalog-sources/review.js +13 -0
  417. package/dist/src/tui/catalog-sources/review.js.map +1 -0
  418. package/dist/src/tui/catalog-sources/screens.d.ts +12 -0
  419. package/dist/src/tui/catalog-sources/screens.js +40 -0
  420. package/dist/src/tui/catalog-sources/screens.js.map +1 -0
  421. package/dist/src/tui/catalog-sources/session.d.ts +32 -0
  422. package/dist/src/tui/catalog-sources/session.js +300 -0
  423. package/dist/src/tui/catalog-sources/session.js.map +1 -0
  424. package/dist/src/tui/catalog-sources/types.d.ts +54 -0
  425. package/dist/src/tui/catalog-sources/types.js +2 -0
  426. package/dist/src/tui/catalog-sources/types.js.map +1 -0
  427. package/dist/src/tui/catalog-store-task.d.ts +16 -0
  428. package/dist/src/tui/catalog-store-task.js +19 -0
  429. package/dist/src/tui/catalog-store-task.js.map +1 -0
  430. package/dist/src/tui/clipboard.d.ts +13 -0
  431. package/dist/src/tui/clipboard.js +95 -0
  432. package/dist/src/tui/clipboard.js.map +1 -0
  433. package/dist/src/tui/components.d.ts +113 -3
  434. package/dist/src/tui/components.js +201 -34
  435. package/dist/src/tui/components.js.map +1 -1
  436. package/dist/src/tui/config-array-draft.d.ts +30 -0
  437. package/dist/src/tui/config-array-draft.js +51 -0
  438. package/dist/src/tui/config-array-draft.js.map +1 -0
  439. package/dist/src/tui/config-leaf-editor.d.ts +44 -0
  440. package/dist/src/tui/config-leaf-editor.js +227 -0
  441. package/dist/src/tui/config-leaf-editor.js.map +1 -0
  442. package/dist/src/tui/config-object-suggestions.d.ts +15 -0
  443. package/dist/src/tui/config-object-suggestions.js +71 -0
  444. package/dist/src/tui/config-object-suggestions.js.map +1 -0
  445. package/dist/src/tui/config-references.d.ts +38 -0
  446. package/dist/src/tui/config-references.js +82 -0
  447. package/dist/src/tui/config-references.js.map +1 -0
  448. package/dist/src/tui/config-suggestions.d.ts +27 -0
  449. package/dist/src/tui/config-suggestions.js +62 -0
  450. package/dist/src/tui/config-suggestions.js.map +1 -0
  451. package/dist/src/tui/config-value-presentation.d.ts +21 -0
  452. package/dist/src/tui/config-value-presentation.js +129 -0
  453. package/dist/src/tui/config-value-presentation.js.map +1 -0
  454. package/dist/src/tui/console-app-v4.d.ts +14 -5
  455. package/dist/src/tui/console-app-v4.js +10344 -2133
  456. package/dist/src/tui/console-app-v4.js.map +1 -1
  457. package/dist/src/tui/content-item-card.d.ts +13 -0
  458. package/dist/src/tui/content-item-card.js +51 -0
  459. package/dist/src/tui/content-item-card.js.map +1 -0
  460. package/dist/src/tui/controller-runtime.d.ts +8 -3
  461. package/dist/src/tui/controller-runtime.js +2301 -842
  462. package/dist/src/tui/controller-runtime.js.map +1 -1
  463. package/dist/src/tui/controller.d.ts +664 -79
  464. package/dist/src/tui/controller.js +3670 -830
  465. package/dist/src/tui/controller.js.map +1 -1
  466. package/dist/src/tui/dependency-graph-view.d.ts +39 -0
  467. package/dist/src/tui/dependency-graph-view.js +121 -0
  468. package/dist/src/tui/dependency-graph-view.js.map +1 -0
  469. package/dist/src/tui/dependency-graph.d.ts +81 -0
  470. package/dist/src/tui/dependency-graph.js +452 -0
  471. package/dist/src/tui/dependency-graph.js.map +1 -0
  472. package/dist/src/tui/deployment-view.d.ts +13 -0
  473. package/dist/src/tui/deployment-view.js +155 -0
  474. package/dist/src/tui/deployment-view.js.map +1 -0
  475. package/dist/src/tui/diagnostic-projection.d.ts +31 -0
  476. package/dist/src/tui/diagnostic-projection.js +681 -0
  477. package/dist/src/tui/diagnostic-projection.js.map +1 -0
  478. package/dist/src/tui/diagnostics.d.ts +6 -2
  479. package/dist/src/tui/diagnostics.js +14 -2
  480. package/dist/src/tui/diagnostics.js.map +1 -1
  481. package/dist/src/tui/entity-cards.d.ts +56 -0
  482. package/dist/src/tui/entity-cards.js +321 -0
  483. package/dist/src/tui/entity-cards.js.map +1 -0
  484. package/dist/src/tui/glossary.d.ts +25 -0
  485. package/dist/src/tui/glossary.js +78 -0
  486. package/dist/src/tui/glossary.js.map +1 -0
  487. package/dist/src/tui/guided-setup.d.ts +25 -0
  488. package/dist/src/tui/guided-setup.js +101 -0
  489. package/dist/src/tui/guided-setup.js.map +1 -0
  490. package/dist/src/tui/index.d.ts +5 -1
  491. package/dist/src/tui/index.js +4 -1
  492. package/dist/src/tui/index.js.map +1 -1
  493. package/dist/src/tui/input-display.d.ts +1 -0
  494. package/dist/src/tui/input-display.js +23 -1
  495. package/dist/src/tui/input-display.js.map +1 -1
  496. package/dist/src/tui/keys.d.ts +44 -0
  497. package/dist/src/tui/keys.js +43 -15
  498. package/dist/src/tui/keys.js.map +1 -1
  499. package/dist/src/tui/lifecycle-action-view.d.ts +6 -0
  500. package/dist/src/tui/lifecycle-action-view.js +36 -0
  501. package/dist/src/tui/lifecycle-action-view.js.map +1 -0
  502. package/dist/src/tui/model.d.ts +187 -52
  503. package/dist/src/tui/model.js +1202 -426
  504. package/dist/src/tui/model.js.map +1 -1
  505. package/dist/src/tui/operation-diagnostic-screens.d.ts +8 -0
  506. package/dist/src/tui/operation-diagnostic-screens.js +76 -0
  507. package/dist/src/tui/operation-diagnostic-screens.js.map +1 -0
  508. package/dist/src/tui/operation-history.d.ts +91 -0
  509. package/dist/src/tui/operation-history.js +167 -0
  510. package/dist/src/tui/operation-history.js.map +1 -0
  511. package/dist/src/tui/operation-review-planner.d.ts +28 -0
  512. package/dist/src/tui/operation-review-planner.js +1456 -0
  513. package/dist/src/tui/operation-review-planner.js.map +1 -0
  514. package/dist/src/tui/plugin-content.d.ts +33 -0
  515. package/dist/src/tui/plugin-content.js +245 -0
  516. package/dist/src/tui/plugin-content.js.map +1 -0
  517. package/dist/src/tui/plugin-detail.d.ts +75 -0
  518. package/dist/src/tui/plugin-detail.js +267 -0
  519. package/dist/src/tui/plugin-detail.js.map +1 -0
  520. package/dist/src/tui/plugin-write-task.d.ts +69 -0
  521. package/dist/src/tui/plugin-write-task.js +286 -0
  522. package/dist/src/tui/plugin-write-task.js.map +1 -0
  523. package/dist/src/tui/prompt.js +4 -15
  524. package/dist/src/tui/prompt.js.map +1 -1
  525. package/dist/src/tui/query-header.d.ts +30 -0
  526. package/dist/src/tui/query-header.js +40 -0
  527. package/dist/src/tui/query-header.js.map +1 -0
  528. package/dist/src/tui/reader.d.ts +38 -0
  529. package/dist/src/tui/reader.js +49 -0
  530. package/dist/src/tui/reader.js.map +1 -0
  531. package/dist/src/tui/router.d.ts +182 -39
  532. package/dist/src/tui/router.js +338 -50
  533. package/dist/src/tui/router.js.map +1 -1
  534. package/dist/src/tui/scoped-flow.d.ts +49 -0
  535. package/dist/src/tui/scoped-flow.js +212 -0
  536. package/dist/src/tui/scoped-flow.js.map +1 -0
  537. package/dist/src/tui/scoped-inventory.d.ts +131 -0
  538. package/dist/src/tui/scoped-inventory.js +280 -0
  539. package/dist/src/tui/scoped-inventory.js.map +1 -0
  540. package/dist/src/tui/screen-registry.d.ts +696 -0
  541. package/dist/src/tui/screen-registry.js +226 -0
  542. package/dist/src/tui/screen-registry.js.map +1 -0
  543. package/dist/src/tui/session-console-app.d.ts +8 -0
  544. package/dist/src/tui/session-console-app.js +24 -0
  545. package/dist/src/tui/session-console-app.js.map +1 -0
  546. package/dist/src/tui/session-host.d.ts +45 -0
  547. package/dist/src/tui/session-host.js +219 -0
  548. package/dist/src/tui/session-host.js.map +1 -0
  549. package/dist/src/tui/source-detail-card.d.ts +29 -0
  550. package/dist/src/tui/source-detail-card.js +45 -0
  551. package/dist/src/tui/source-detail-card.js.map +1 -0
  552. package/dist/src/tui/theme.d.ts +12 -0
  553. package/dist/src/tui/theme.js +12 -0
  554. package/dist/src/tui/theme.js.map +1 -1
  555. package/dist/src/tui/viewport.d.ts +1 -0
  556. package/dist/src/tui/viewport.js +23 -0
  557. package/dist/src/tui/viewport.js.map +1 -1
  558. package/dist/src/tui/wizard.js +37 -13
  559. package/dist/src/tui/wizard.js.map +1 -1
  560. package/dist/src/types.d.ts +177 -85
  561. package/dist/src/types.js +1 -0
  562. package/dist/src/types.js.map +1 -1
  563. package/dist/src/utils/agent-version.d.ts +10 -4
  564. package/dist/src/utils/agent-version.js +6 -8
  565. package/dist/src/utils/agent-version.js.map +1 -1
  566. package/dist/src/utils/artifact-plan.d.ts +17 -24
  567. package/dist/src/utils/artifact-plan.js +59 -436
  568. package/dist/src/utils/artifact-plan.js.map +1 -1
  569. package/dist/src/utils/artifact-renderer.d.ts +61 -89
  570. package/dist/src/utils/artifact-renderer.js +187 -364
  571. package/dist/src/utils/artifact-renderer.js.map +1 -1
  572. package/dist/src/utils/artifact-request.d.ts +21 -0
  573. package/dist/src/utils/artifact-request.js +57 -0
  574. package/dist/src/utils/artifact-request.js.map +1 -0
  575. package/dist/src/utils/artifact-sources.d.ts +4 -8
  576. package/dist/src/utils/artifact-sources.js +15 -6
  577. package/dist/src/utils/artifact-sources.js.map +1 -1
  578. package/dist/src/utils/aw-home-mutation-lock.js +2 -1
  579. package/dist/src/utils/aw-home-mutation-lock.js.map +1 -1
  580. package/dist/src/utils/bundle-layout.js +59 -173
  581. package/dist/src/utils/bundle-layout.js.map +1 -1
  582. package/dist/src/utils/catalog-capability-projection.d.ts +8 -0
  583. package/dist/src/utils/catalog-capability-projection.js +14 -0
  584. package/dist/src/utils/catalog-capability-projection.js.map +1 -0
  585. package/dist/src/utils/catalog-digests.d.ts +2 -9
  586. package/dist/src/utils/catalog-digests.js +7 -45
  587. package/dist/src/utils/catalog-digests.js.map +1 -1
  588. package/dist/src/utils/catalog-generation-error.d.ts +4 -1
  589. package/dist/src/utils/catalog-generation-error.js +2 -0
  590. package/dist/src/utils/catalog-generation-error.js.map +1 -1
  591. package/dist/src/utils/catalog-generation-resolver.d.ts +32 -3
  592. package/dist/src/utils/catalog-generation-resolver.js +182 -40
  593. package/dist/src/utils/catalog-generation-resolver.js.map +1 -1
  594. package/dist/src/utils/catalog-generation-service.d.ts +142 -2
  595. package/dist/src/utils/catalog-generation-service.js +1146 -171
  596. package/dist/src/utils/catalog-generation-service.js.map +1 -1
  597. package/dist/src/utils/catalog-generation-state.d.ts +5 -0
  598. package/dist/src/utils/catalog-generation-state.js +25 -1
  599. package/dist/src/utils/catalog-generation-state.js.map +1 -1
  600. package/dist/src/utils/catalog-generation-store.d.ts +29 -2
  601. package/dist/src/utils/catalog-generation-store.js +240 -36
  602. package/dist/src/utils/catalog-generation-store.js.map +1 -1
  603. package/dist/src/utils/catalog-manifest-v7.d.ts +5 -0
  604. package/dist/src/utils/{catalog-manifest-v6.js → catalog-manifest-v7.js} +23 -23
  605. package/dist/src/utils/{catalog-manifest-v6.js.map → catalog-manifest-v7.js.map} +1 -1
  606. package/dist/src/utils/catalog-operation-context.d.ts +27 -3
  607. package/dist/src/utils/catalog-operation-context.js +75 -4
  608. package/dist/src/utils/catalog-operation-context.js.map +1 -1
  609. package/dist/src/utils/catalog-public-error.js +7 -0
  610. package/dist/src/utils/catalog-public-error.js.map +1 -1
  611. package/dist/src/utils/catalog-runtime-projection.d.ts +4 -3
  612. package/dist/src/utils/catalog-runtime-projection.js.map +1 -1
  613. package/dist/src/utils/catalog-snapshot.d.ts +5 -2
  614. package/dist/src/utils/catalog-snapshot.js +4 -1
  615. package/dist/src/utils/catalog-snapshot.js.map +1 -1
  616. package/dist/src/utils/catalog-source-impact.d.ts +21 -0
  617. package/dist/src/utils/catalog-source-impact.js +344 -0
  618. package/dist/src/utils/catalog-source-impact.js.map +1 -0
  619. package/dist/src/utils/catalog-source-references.d.ts +22 -8
  620. package/dist/src/utils/catalog-source-references.js +457 -365
  621. package/dist/src/utils/catalog-source-references.js.map +1 -1
  622. package/dist/src/utils/catalog-sources.d.ts +14 -1
  623. package/dist/src/utils/catalog-sources.js +155 -11
  624. package/dist/src/utils/catalog-sources.js.map +1 -1
  625. package/dist/src/utils/codex-executable-discovery.d.ts +28 -0
  626. package/dist/src/utils/codex-executable-discovery.js +431 -0
  627. package/dist/src/utils/codex-executable-discovery.js.map +1 -0
  628. package/dist/src/utils/codex-manager.d.ts +23 -42
  629. package/dist/src/utils/codex-manager.js +79 -767
  630. package/dist/src/utils/codex-manager.js.map +1 -1
  631. package/dist/src/utils/codex-marketplace-path.d.ts +5 -0
  632. package/dist/src/utils/codex-marketplace-path.js +45 -0
  633. package/dist/src/utils/codex-marketplace-path.js.map +1 -0
  634. package/dist/src/utils/codex-native-observation.d.ts +55 -0
  635. package/dist/src/utils/codex-native-observation.js +198 -0
  636. package/dist/src/utils/codex-native-observation.js.map +1 -0
  637. package/dist/src/utils/codex-reconciler.d.ts +6 -14
  638. package/dist/src/utils/codex-reconciler.js +45 -50
  639. package/dist/src/utils/codex-reconciler.js.map +1 -1
  640. package/dist/src/utils/codex-shared-native.d.ts +28 -39
  641. package/dist/src/utils/codex-shared-native.js +92 -57
  642. package/dist/src/utils/codex-shared-native.js.map +1 -1
  643. package/dist/src/utils/codex-skill-staging.d.ts +4 -3
  644. package/dist/src/utils/codex-skill-staging.js.map +1 -1
  645. package/dist/src/utils/codex-skills-root.d.ts +4 -0
  646. package/dist/src/utils/codex-skills-root.js +25 -0
  647. package/dist/src/utils/codex-skills-root.js.map +1 -0
  648. package/dist/src/utils/codex-surface-analysis.d.ts +8 -3
  649. package/dist/src/utils/codex-surface-analysis.js +35 -62
  650. package/dist/src/utils/codex-surface-analysis.js.map +1 -1
  651. package/dist/src/utils/component-command-preparation.d.ts +31 -0
  652. package/dist/src/utils/component-command-preparation.js +127 -0
  653. package/dist/src/utils/component-command-preparation.js.map +1 -0
  654. package/dist/src/utils/component-gap.d.ts +4 -0
  655. package/dist/src/utils/component-gap.js +20 -0
  656. package/dist/src/utils/component-gap.js.map +1 -0
  657. package/dist/src/utils/component-resources.d.ts +51 -0
  658. package/dist/src/utils/component-resources.js +320 -0
  659. package/dist/src/utils/component-resources.js.map +1 -0
  660. package/dist/src/utils/config-platforms.d.ts +21 -0
  661. package/dist/src/utils/config-platforms.js +51 -0
  662. package/dist/src/utils/config-platforms.js.map +1 -0
  663. package/dist/src/utils/dynamic-skill-tree.d.ts +18 -6
  664. package/dist/src/utils/dynamic-skill-tree.js +33 -40
  665. package/dist/src/utils/dynamic-skill-tree.js.map +1 -1
  666. package/dist/src/utils/git-catalog-provider.d.ts +16 -0
  667. package/dist/src/utils/git-catalog-provider.js +112 -6
  668. package/dist/src/utils/git-catalog-provider.js.map +1 -1
  669. package/dist/src/utils/inventory-recovery-diagnostic.d.ts +4 -0
  670. package/dist/src/utils/inventory-recovery-diagnostic.js +15 -0
  671. package/dist/src/utils/inventory-recovery-diagnostic.js.map +1 -0
  672. package/dist/src/utils/local-marketplace.d.ts +17 -12
  673. package/dist/src/utils/local-marketplace.js +85 -195
  674. package/dist/src/utils/local-marketplace.js.map +1 -1
  675. package/dist/src/utils/managed-command-cli-review.d.ts +53 -0
  676. package/dist/src/utils/managed-command-cli-review.js +431 -0
  677. package/dist/src/utils/managed-command-cli-review.js.map +1 -0
  678. package/dist/src/utils/managed-command-closure.d.ts +14 -0
  679. package/dist/src/utils/managed-command-closure.js +156 -0
  680. package/dist/src/utils/managed-command-closure.js.map +1 -0
  681. package/dist/src/utils/managed-command-errors.d.ts +5 -0
  682. package/dist/src/utils/managed-command-errors.js +10 -0
  683. package/dist/src/utils/managed-command-errors.js.map +1 -0
  684. package/dist/src/utils/managed-command-materialization.d.ts +90 -0
  685. package/dist/src/utils/managed-command-materialization.js +375 -0
  686. package/dist/src/utils/managed-command-materialization.js.map +1 -0
  687. package/dist/src/utils/managed-command-preparation.d.ts +30 -0
  688. package/dist/src/utils/managed-command-preparation.js +39 -0
  689. package/dist/src/utils/managed-command-preparation.js.map +1 -0
  690. package/dist/src/utils/managed-command-review.d.ts +33 -0
  691. package/dist/src/utils/managed-command-review.js +80 -0
  692. package/dist/src/utils/managed-command-review.js.map +1 -0
  693. package/dist/src/utils/managed-command-runtime.d.ts +36 -0
  694. package/dist/src/utils/managed-command-runtime.js +126 -0
  695. package/dist/src/utils/managed-command-runtime.js.map +1 -0
  696. package/dist/src/utils/managed-command-snapshots.d.ts +24 -0
  697. package/dist/src/utils/managed-command-snapshots.js +89 -0
  698. package/dist/src/utils/managed-command-snapshots.js.map +1 -0
  699. package/dist/src/utils/managed-command-store.d.ts +141 -0
  700. package/dist/src/utils/managed-command-store.js +839 -0
  701. package/dist/src/utils/managed-command-store.js.map +1 -0
  702. package/dist/src/utils/multi-source-catalog.d.ts +4 -0
  703. package/dist/src/utils/multi-source-catalog.js +7 -3
  704. package/dist/src/utils/multi-source-catalog.js.map +1 -1
  705. package/dist/src/utils/native-cli-interruption.d.ts +8 -0
  706. package/dist/src/utils/native-cli-interruption.js +65 -0
  707. package/dist/src/utils/native-cli-interruption.js.map +1 -0
  708. package/dist/src/utils/native-cli.d.ts +37 -6
  709. package/dist/src/utils/native-cli.js +523 -60
  710. package/dist/src/utils/native-cli.js.map +1 -1
  711. package/dist/src/utils/native-demand.d.ts +29 -0
  712. package/dist/src/utils/native-demand.js +4 -0
  713. package/dist/src/utils/native-demand.js.map +1 -0
  714. package/dist/src/utils/native-tool-context.d.ts +17 -0
  715. package/dist/src/utils/native-tool-context.js +40 -0
  716. package/dist/src/utils/native-tool-context.js.map +1 -0
  717. package/dist/src/utils/native-tool-review.d.ts +8 -0
  718. package/dist/src/utils/native-tool-review.js +14 -0
  719. package/dist/src/utils/native-tool-review.js.map +1 -0
  720. package/dist/src/utils/orphan-marketplace-cleanup.js +0 -2
  721. package/dist/src/utils/orphan-marketplace-cleanup.js.map +1 -1
  722. package/dist/src/utils/ownership.d.ts +111 -11
  723. package/dist/src/utils/ownership.js +247 -126
  724. package/dist/src/utils/ownership.js.map +1 -1
  725. package/dist/src/utils/package-content.d.ts +7 -0
  726. package/dist/src/utils/package-content.js +70 -0
  727. package/dist/src/utils/package-content.js.map +1 -0
  728. package/dist/src/utils/path-catalog-provider.js +2 -0
  729. package/dist/src/utils/path-catalog-provider.js.map +1 -1
  730. package/dist/src/utils/paths.d.ts +1 -1
  731. package/dist/src/utils/paths.js +5 -2
  732. package/dist/src/utils/paths.js.map +1 -1
  733. package/dist/src/utils/platform-empty-state.d.ts +69 -0
  734. package/dist/src/utils/platform-empty-state.js +226 -0
  735. package/dist/src/utils/platform-empty-state.js.map +1 -0
  736. package/dist/src/utils/platform-support.d.ts +1 -1
  737. package/dist/src/utils/platform-support.js +1 -1
  738. package/dist/src/utils/platform-support.js.map +1 -1
  739. package/dist/src/utils/plugin-config-command-apply.d.ts +33 -0
  740. package/dist/src/utils/plugin-config-command-apply.js +142 -0
  741. package/dist/src/utils/plugin-config-command-apply.js.map +1 -0
  742. package/dist/src/utils/plugin-config-diagnostics.d.ts +16 -0
  743. package/dist/src/utils/plugin-config-diagnostics.js +44 -0
  744. package/dist/src/utils/plugin-config-diagnostics.js.map +1 -0
  745. package/dist/src/utils/plugin-config-impact.d.ts +75 -0
  746. package/dist/src/utils/plugin-config-impact.js +355 -0
  747. package/dist/src/utils/plugin-config-impact.js.map +1 -0
  748. package/dist/src/utils/plugin-config-references.d.ts +96 -0
  749. package/dist/src/utils/plugin-config-references.js +357 -0
  750. package/dist/src/utils/plugin-config-references.js.map +1 -0
  751. package/dist/src/utils/plugin-config-suggestion-runner.d.ts +83 -0
  752. package/dist/src/utils/plugin-config-suggestion-runner.js +308 -0
  753. package/dist/src/utils/plugin-config-suggestion-runner.js.map +1 -0
  754. package/dist/src/utils/plugin-config-suggestions.d.ts +50 -0
  755. package/dist/src/utils/plugin-config-suggestions.js +302 -0
  756. package/dist/src/utils/plugin-config-suggestions.js.map +1 -0
  757. package/dist/src/utils/plugin-config-write.d.ts +123 -31
  758. package/dist/src/utils/plugin-config-write.js +828 -399
  759. package/dist/src/utils/plugin-config-write.js.map +1 -1
  760. package/dist/src/utils/plugin-config.d.ts +192 -109
  761. package/dist/src/utils/plugin-config.js +970 -1150
  762. package/dist/src/utils/plugin-config.js.map +1 -1
  763. package/dist/src/utils/plugin-dependencies.d.ts +1 -1
  764. package/dist/src/utils/plugin-dependencies.js.map +1 -1
  765. package/dist/src/utils/plugin-scripts.d.ts +80 -127
  766. package/dist/src/utils/plugin-scripts.js +655 -524
  767. package/dist/src/utils/plugin-scripts.js.map +1 -1
  768. package/dist/src/utils/process-lock.js +14 -5
  769. package/dist/src/utils/process-lock.js.map +1 -1
  770. package/dist/src/utils/process-tree.d.ts +2 -2
  771. package/dist/src/utils/process-tree.js +1 -1
  772. package/dist/src/utils/process-tree.js.map +1 -1
  773. package/dist/src/utils/project-boundary.d.ts +11 -13
  774. package/dist/src/utils/project-boundary.js +28 -34
  775. package/dist/src/utils/project-boundary.js.map +1 -1
  776. package/dist/src/utils/rendered-contract.js +24 -1
  777. package/dist/src/utils/rendered-contract.js.map +1 -1
  778. package/dist/src/utils/runtime-config.d.ts +18 -0
  779. package/dist/src/utils/runtime-config.js +64 -0
  780. package/dist/src/utils/runtime-config.js.map +1 -0
  781. package/dist/src/utils/runtime-skill-closure.d.ts +2 -2
  782. package/dist/src/utils/runtime-skill-closure.js +47 -6
  783. package/dist/src/utils/runtime-skill-closure.js.map +1 -1
  784. package/dist/src/utils/safe-fs.d.ts +21 -0
  785. package/dist/src/utils/safe-fs.js +111 -0
  786. package/dist/src/utils/safe-fs.js.map +1 -0
  787. package/dist/src/utils/safe-operation-diagnostic.d.ts +15 -0
  788. package/dist/src/utils/safe-operation-diagnostic.js +33 -0
  789. package/dist/src/utils/safe-operation-diagnostic.js.map +1 -0
  790. package/dist/src/utils/sensitive-content.d.ts +4 -0
  791. package/dist/src/utils/sensitive-content.js +36 -0
  792. package/dist/src/utils/sensitive-content.js.map +1 -0
  793. package/dist/src/utils/skill-invocation-warning.d.ts +20 -0
  794. package/dist/src/utils/skill-invocation-warning.js +68 -0
  795. package/dist/src/utils/skill-invocation-warning.js.map +1 -0
  796. package/dist/src/utils/state-paths.d.ts +8 -3
  797. package/dist/src/utils/state-paths.js +53 -16
  798. package/dist/src/utils/state-paths.js.map +1 -1
  799. package/dist/src/utils/target-eligibility.d.ts +3 -3
  800. package/dist/src/utils/target-eligibility.js +11 -6
  801. package/dist/src/utils/target-eligibility.js.map +1 -1
  802. package/dist/src/utils/windows-claude-shim.d.ts +7 -0
  803. package/dist/src/utils/windows-claude-shim.js +10 -0
  804. package/dist/src/utils/windows-claude-shim.js.map +1 -0
  805. package/dist/src/utils/windows-npm-shim.d.ts +16 -0
  806. package/dist/src/utils/windows-npm-shim.js +155 -0
  807. package/dist/src/utils/windows-npm-shim.js.map +1 -0
  808. package/dist/vitest.config.js +106 -9
  809. package/dist/vitest.config.js.map +1 -1
  810. package/package.json +30 -21
  811. package/dist/src/commands/review-publication.d.ts +0 -99
  812. package/dist/src/commands/review-publication.js +0 -904
  813. package/dist/src/commands/review-publication.js.map +0 -1
  814. package/dist/src/commands/sync-command.d.ts +0 -21
  815. package/dist/src/commands/sync-command.js +0 -206
  816. package/dist/src/commands/sync-command.js.map +0 -1
  817. package/dist/src/portable/skills-cli.d.ts +0 -43
  818. package/dist/src/portable/skills-cli.js +0 -148
  819. package/dist/src/portable/skills-cli.js.map +0 -1
  820. package/dist/src/utils/catalog-manifest-v6.d.ts +0 -5
  821. package/dist/src/utils/lifecycle-active-store.d.ts +0 -147
  822. package/dist/src/utils/lifecycle-active-store.js +0 -1064
  823. package/dist/src/utils/lifecycle-active-store.js.map +0 -1
  824. package/dist/src/utils/plugin-intent-state.d.ts +0 -39
  825. package/dist/src/utils/plugin-intent-state.js +0 -325
  826. package/dist/src/utils/plugin-intent-state.js.map +0 -1
  827. package/dist/src/utils/slash-commands.d.ts +0 -1
  828. package/dist/src/utils/slash-commands.js +0 -2
  829. package/dist/src/utils/slash-commands.js.map +0 -1
@@ -1,9 +1,44 @@
1
1
  import crypto from 'node:crypto';
2
+ import { resolveWorkContext } from '../intent/work-context.js';
3
+ import { observePreferences } from '../intent/deployment-preferences.js';
2
4
  import * as nodeFs from 'node:fs/promises';
3
5
  import path from 'node:path';
4
6
  import fs from 'fs-extra';
5
- import { assertTestReadablePath, assertTestWritablePath, } from './test-path-fence.js';
7
+ import { canonicalizePluginConfigValues, selectPluginConfigProfile, PLATFORM_TARGETS, formatPluginConfigIssue, getPluginConfigDependencyKeys, getPluginConfigDependencyFields, matchPluginConfigPreset, redactPluginConfigValue, resolvePluginConfigObjectProperties, stablePluginConfigStringify, validatePluginConfigCandidate, validatePluginConfigDocument, validatePluginConfigValue as validateCorePluginConfigValue, } from '@lesliechan721/aw-plugin-core/manifest';
6
8
  import { canonicalizePathThroughExistingAncestor, resolveAwHome, resolveRepoRootSync, } from './paths.js';
9
+ import { assertRealFileParentWithinRoot, assertSafeFileMutationPath, atomicReplaceSafeFile, } from './safe-fs.js';
10
+ import { pluginConfigHasExternalReferences, resolvePluginConfigReferenceContext, } from './plugin-config-references.js';
11
+ import { assertConfigLayerWritable, resolveConfigurableLayers } from './config-platforms.js';
12
+ export { resolvePluginConfigReferenceContext } from './plugin-config-references.js';
13
+ function readPluginConfigBinding(value) {
14
+ return isRecord(value) && value.kind === 'source'
15
+ && typeof value.sourceIdentity === 'string'
16
+ && /^sha256:[0-9a-f]{64}$/u.test(value.sourceIdentity)
17
+ && Object.keys(value).every((key) => ['kind', 'sourceIdentity'].includes(key))
18
+ ? { kind: 'source', sourceIdentity: value.sourceIdentity } : null;
19
+ }
20
+ function readPluginConfigEnvelopeV6(value, _scope) {
21
+ if (!isRecord(value) || value.schemaVersion !== 6
22
+ || typeof value.sourceId !== 'string' || typeof value.pluginName !== 'string'
23
+ || !isRecord(value.common) || !isRecord(value.platforms)
24
+ || Object.keys(value).some((key) => !['schemaVersion', 'sourceId', 'pluginName', 'binding', 'common', 'platforms'].includes(key))
25
+ || Object.keys(value.platforms).some((key) => !PLATFORM_TARGETS.includes(key)))
26
+ return null;
27
+ const binding = readPluginConfigBinding(value.binding);
28
+ return binding ? { schemaVersion: 6, sourceId: value.sourceId, pluginName: value.pluginName,
29
+ binding, common: value.common,
30
+ platforms: value.platforms } : null;
31
+ }
32
+ export class PluginConfigResetError extends Error {
33
+ code;
34
+ osCode;
35
+ constructor(code, message, osCode) {
36
+ super(`${code}: ${message}`);
37
+ this.name = 'PluginConfigResetError';
38
+ this.code = code;
39
+ this.osCode = osCode;
40
+ }
41
+ }
7
42
  export class PluginConfigSchemaResolutionError extends Error {
8
43
  code;
9
44
  details;
@@ -97,28 +132,6 @@ async function inspectConfigInventoryStoreRoot(boundaryRoot, storeRoot) {
97
132
  }
98
133
  return true;
99
134
  }
100
- async function readConfigDirectoryIdentity(directoryPath) {
101
- const stats = await fs.lstat(directoryPath);
102
- if (stats.isSymbolicLink() || !stats.isDirectory()) {
103
- throw new Error(`Config parent must be a real directory: ${directoryPath}`);
104
- }
105
- return {
106
- dev: stats.dev,
107
- ino: stats.ino,
108
- realPath: await fs.realpath(directoryPath),
109
- };
110
- }
111
- function assertConfigDirectoryStable(label, before, after) {
112
- if (before.dev !== after.dev || before.ino !== after.ino || before.realPath !== after.realPath) {
113
- throw new Error(`${label} identity changed before atomic config replacement.`);
114
- }
115
- }
116
- function assertRealConfigBoundary(root, parent) {
117
- const relative = path.relative(root.realPath, parent.realPath);
118
- if (relative === '..' || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) {
119
- throw new Error('Config parent realpath escapes its allowed root.');
120
- }
121
- }
122
135
  async function prepareConfigFileParent(filePath, allowedRoot) {
123
136
  assertConfigPathBoundary(allowedRoot, filePath);
124
137
  await assertNoConfigSymlink(allowedRoot, filePath);
@@ -131,66 +144,28 @@ export async function withConfigFileMutation(options) {
131
144
  return options.action();
132
145
  }
133
146
  export async function atomicReplaceConfigFile(options) {
134
- await prepareConfigFileParent(options.filePath, options.allowedRoot);
135
- const rootPath = path.resolve(options.allowedRoot);
136
- const parentPath = path.dirname(path.resolve(options.filePath));
137
- const rootIdentity = await readConfigDirectoryIdentity(rootPath);
138
- const parentIdentity = await readConfigDirectoryIdentity(parentPath);
139
- assertRealConfigBoundary(rootIdentity, parentIdentity);
140
- const currentTarget = await lstatIfExists(options.filePath);
141
- if (currentTarget && (!currentTarget.isFile() || currentTarget.isSymbolicLink())) {
142
- throw new Error(`Config target must be a regular file: ${options.filePath}`);
143
- }
144
- const temporaryPath = path.join(parentPath, `.${path.basename(options.filePath)}.tmp-${process.pid}-${crypto.randomUUID()}`);
145
- assertConfigPathBoundary(options.allowedRoot, temporaryPath);
146
- let handle;
147
- try {
148
- handle = await nodeFs.open(temporaryPath, 'wx', options.mode ?? (currentTarget ? currentTarget.mode & 0o777 : 0o600));
149
- await handle.writeFile(options.content, 'utf8');
150
- await handle.sync();
151
- await handle.close();
152
- handle = undefined;
153
- await atomicConfigBeforeRenameHookForTests?.(options.filePath, temporaryPath);
154
- await assertNoConfigSymlink(options.allowedRoot, options.filePath);
155
- const currentRootIdentity = await readConfigDirectoryIdentity(rootPath);
156
- const currentParentIdentity = await readConfigDirectoryIdentity(parentPath);
157
- assertRealConfigBoundary(currentRootIdentity, currentParentIdentity);
158
- assertConfigDirectoryStable('Config allowed root', rootIdentity, currentRootIdentity);
159
- assertConfigDirectoryStable('Config parent', parentIdentity, currentParentIdentity);
160
- const targetBeforeRename = await lstatIfExists(options.filePath);
161
- if (targetBeforeRename && (!targetBeforeRename.isFile() || targetBeforeRename.isSymbolicLink())) {
162
- throw new Error(`Config target must be a regular file: ${options.filePath}`);
163
- }
164
- await nodeFs.rename(temporaryPath, options.filePath);
165
- // rename is the commit point. Diagnostics and durability work after it are best effort,
166
- // because reporting failure here would leave the new generation on disk without giving
167
- // the caller a safe way to restore the old generation.
168
- await atomicConfigAfterRenameHookForTests?.(options.filePath).catch(() => undefined);
169
- await (async () => {
170
- const finalTarget = await fs.lstat(options.filePath);
171
- if (!finalTarget.isFile() || finalTarget.isSymbolicLink()) {
172
- throw new Error('Atomic config replacement produced an invalid target.');
173
- }
174
- if (await fs.readFile(options.filePath, 'utf8') !== options.content) {
175
- throw new Error('Atomic config replacement content differs from the committed content.');
176
- }
177
- })().catch(() => undefined);
178
- const directoryHandle = await nodeFs.open(parentPath, 'r').catch(() => null);
179
- await directoryHandle?.sync().catch(() => undefined);
180
- await directoryHandle?.close().catch(() => undefined);
181
- }
182
- finally {
183
- await handle?.close().catch(() => undefined);
184
- await nodeFs.rm(temporaryPath, { force: true }).catch(() => undefined);
185
- }
147
+ await atomicReplaceSafeFile({
148
+ ...options,
149
+ label: 'Config path',
150
+ temporaryTag: 'tmp',
151
+ beforeRename: atomicConfigBeforeRenameHookForTests,
152
+ afterRename: async (targetPath) => {
153
+ await atomicConfigAfterRenameHookForTests?.(targetPath).catch(() => undefined);
154
+ },
155
+ });
186
156
  }
187
157
  export async function atomicRemoveConfigFile(options) {
188
158
  await prepareConfigFileParent(options.filePath, options.allowedRoot);
189
- const rootPath = path.resolve(options.allowedRoot);
190
- const parentPath = path.dirname(path.resolve(options.filePath));
191
- const rootIdentity = await readConfigDirectoryIdentity(rootPath);
192
- const parentIdentity = await readConfigDirectoryIdentity(parentPath);
193
- assertRealConfigBoundary(rootIdentity, parentIdentity);
159
+ await assertSafeFileMutationPath({
160
+ filePath: options.filePath,
161
+ allowedRoot: options.allowedRoot,
162
+ label: 'Config path',
163
+ });
164
+ await assertRealFileParentWithinRoot({
165
+ filePath: options.filePath,
166
+ allowedRoot: options.allowedRoot,
167
+ label: 'Config path',
168
+ });
194
169
  const currentTarget = await lstatIfExists(options.filePath);
195
170
  if (!currentTarget)
196
171
  return false;
@@ -198,12 +173,16 @@ export async function atomicRemoveConfigFile(options) {
198
173
  throw new Error(`Config target must be a regular file: ${options.filePath}`);
199
174
  }
200
175
  await atomicConfigBeforeRenameHookForTests?.(options.filePath, options.filePath);
201
- await assertNoConfigSymlink(options.allowedRoot, options.filePath);
202
- const currentRootIdentity = await readConfigDirectoryIdentity(rootPath);
203
- const currentParentIdentity = await readConfigDirectoryIdentity(parentPath);
204
- assertRealConfigBoundary(currentRootIdentity, currentParentIdentity);
205
- assertConfigDirectoryStable('Config allowed root', rootIdentity, currentRootIdentity);
206
- assertConfigDirectoryStable('Config parent', parentIdentity, currentParentIdentity);
176
+ await assertSafeFileMutationPath({
177
+ filePath: options.filePath,
178
+ allowedRoot: options.allowedRoot,
179
+ label: 'Config path',
180
+ });
181
+ await assertRealFileParentWithinRoot({
182
+ filePath: options.filePath,
183
+ allowedRoot: options.allowedRoot,
184
+ label: 'Config path',
185
+ });
207
186
  const targetBeforeRemove = await lstatIfExists(options.filePath);
208
187
  if (!targetBeforeRemove)
209
188
  return false;
@@ -212,16 +191,21 @@ export async function atomicRemoveConfigFile(options) {
212
191
  }
213
192
  await nodeFs.unlink(options.filePath);
214
193
  await atomicConfigAfterRenameHookForTests?.(options.filePath).catch(() => undefined);
215
- const directoryHandle = await nodeFs.open(parentPath, 'r').catch(() => null);
216
- await directoryHandle?.sync().catch(() => undefined);
217
- await directoryHandle?.close().catch(() => undefined);
218
194
  return true;
219
195
  }
220
196
  function isRecord(value) {
221
197
  return typeof value === 'object' && value !== null && !Array.isArray(value);
222
198
  }
223
199
  function formatValue(value) {
224
- return typeof value === 'string' ? value : JSON.stringify(value);
200
+ if (typeof value === 'string')
201
+ return value;
202
+ if (typeof value === 'number' || typeof value === 'boolean') {
203
+ return stablePluginConfigStringify(value);
204
+ }
205
+ if (isRecord(value) || Array.isArray(value)) {
206
+ return stablePluginConfigStringify(value);
207
+ }
208
+ return JSON.stringify(value);
225
209
  }
226
210
  async function calculateConfigManifestDigest(filePath) {
227
211
  const hash = crypto.createHash('sha256');
@@ -236,16 +220,17 @@ async function calculateConfigSchemaManifestDigestForPlugin(plugin) {
236
220
  hash.update(JSON.stringify(plugin.manifest));
237
221
  return `sha256:${hash.digest('hex')}`;
238
222
  }
239
- function createConfigSchemaEvidenceFromCurrentCatalog(plugin, manifestDigest) {
223
+ function createConfigSchemaEvidenceFromCurrentCatalog(plugin, manifestDigest, platform) {
240
224
  return {
241
225
  source: 'currentCatalog',
242
- identity: createPluginConfigSchemaIdentity(plugin.manifest),
226
+ identity: createPluginConfigSchemaIdentity(plugin.manifest, platform),
227
+ platform,
243
228
  pluginVersion: plugin.manifest.version,
244
229
  manifestDigest,
245
230
  };
246
231
  }
247
232
  function getStoreEntries(values) {
248
- return { ...values };
233
+ return Object.fromEntries(Object.entries(values));
249
234
  }
250
235
  export function assertSafePluginConfigSegment(pluginName) {
251
236
  if (typeof pluginName !== 'string' || pluginName.trim() === '') {
@@ -267,111 +252,178 @@ export function resolveAwProjectRoot(cwd) {
267
252
  return path.resolve(resolveRepoRootSync(cwd));
268
253
  }
269
254
  function resolvePluginConfigAllowedRoot(options) {
270
- return options.scope === 'user'
271
- ? resolveAwHome(options.env)
272
- : path.join(resolveAwProjectRoot(options.cwd), '.agent-workflows');
255
+ return resolveAwHome(options.env);
273
256
  }
257
+ /** Scope selects source context. All config values belong to the user document. */
274
258
  export function resolvePluginConfigStorePath(options) {
275
259
  const pluginName = assertSafePluginConfigSegment(options.pluginName);
276
- const sourceId = options.sourceId === undefined
277
- ? undefined
278
- : assertSafePluginConfigSegment(options.sourceId);
279
- const root = options.scope === 'user'
280
- ? resolveAwHome(options.env)
281
- : path.join(resolveAwProjectRoot(options.cwd), '.agent-workflows');
282
- const configDir = options.scope === 'project' && options.projectLayer === 'local'
283
- ? 'plugin-config.local'
284
- : CONFIG_DIR;
285
- const filePath = path.join(root, configDir, ...(sourceId ? [sourceId] : []), pluginName, CONFIG_FILE);
286
- if (options.scope !== 'project') {
287
- return filePath;
288
- }
289
- if (options.access === 'read') {
290
- return assertTestReadablePath(filePath, options.projectLayer === 'local'
291
- ? 'project local plugin config store (.agent-workflows/plugin-config.local)'
292
- : 'project shared plugin config store (.agent-workflows/plugin-config)', '用 registerReadonlyFixtureRoot() 或 runWithRepositoryCwdAsReadOnly() 登记只读 project fixture 根;需要写入时改用 withSafeTestCwd() 或 registerWritableStateRoot()。');
293
- }
294
- if (options.access === 'write') {
295
- return assertTestWritablePath(filePath, options.projectLayer === 'local'
296
- ? 'project local plugin config store (.agent-workflows/plugin-config.local)'
297
- : 'project shared plugin config store (.agent-workflows/plugin-config)', '用 withSafeTestCwd() 切到测试可写 cwd,或通过 registerWritableStateRoot() 登记 project fixture 根。');
298
- }
299
- return filePath;
260
+ const sourceId = options.sourceId === undefined ? undefined : assertSafePluginConfigSegment(options.sourceId);
261
+ return path.join(resolveAwHome(options.env), CONFIG_DIR, ...(sourceId ? [sourceId] : []), pluginName, CONFIG_FILE);
300
262
  }
301
263
  export function resolvePluginConfigStoreTargets(options) {
302
- if (options.scope === 'user') {
303
- return [{
304
- storeKind: 'user',
305
- path: resolvePluginConfigStorePath(options),
306
- }];
307
- }
308
- return [
309
- {
310
- storeKind: 'projectShared',
311
- path: resolvePluginConfigStorePath({
312
- ...options,
313
- projectLayer: 'shared',
314
- }),
315
- projectLayer: 'shared',
316
- },
317
- {
318
- storeKind: 'projectLocal',
319
- path: resolvePluginConfigStorePath({
320
- ...options,
321
- projectLayer: 'local',
322
- }),
323
- projectLayer: 'local',
324
- },
325
- ];
264
+ return [{ storeKind: 'user', path: resolvePluginConfigStorePath(options) }];
326
265
  }
327
- async function readStoreFile(filePath) {
328
- const value = await fs.readJson(filePath);
329
- if (!isRecord(value)) {
330
- throw new Error(`Invalid plugin config store "${filePath}": expected a JSON object.`);
331
- }
332
- return value;
266
+ function isPluginConfigScalar(value) {
267
+ if (typeof value === 'string' || typeof value === 'boolean')
268
+ return true;
269
+ return typeof value === 'number' && Number.isFinite(value);
333
270
  }
334
- async function readNamespacedStoreFile(options) {
335
- const raw = await fs.readJson(options.filePath);
336
- if (!isRecord(raw) || raw.schemaVersion !== 2 || !isRecord(raw.values)) {
337
- throw new Error(`legacyStateUnsupported: invalid or legacy plugin config store "${options.filePath}".`);
271
+ function isPluginConfigObject(value, objectArrayLevels) {
272
+ if (!isRecord(value))
273
+ return false;
274
+ return Object.values(value).every((property) => {
275
+ if (isPluginConfigScalar(property))
276
+ return true;
277
+ if (Array.isArray(property))
278
+ return isPluginConfigArray(property, objectArrayLevels);
279
+ return isRecord(property) && Object.values(property).every(isPluginConfigScalar);
280
+ });
281
+ }
282
+ function isPluginConfigArray(value, objectArrayLevels) {
283
+ if (Object.keys(value).length !== value.length)
284
+ return false;
285
+ const elementType = typeof value[0];
286
+ return value.every((item, index) => Object.hasOwn(value, index)
287
+ && typeof item === elementType
288
+ && (isPluginConfigScalar(item) || (objectArrayLevels > 0 && isPluginConfigObject(item, objectArrayLevels - 1))));
289
+ }
290
+ function isPluginConfigValue(value) {
291
+ return isPluginConfigScalar(value) || (Array.isArray(value)
292
+ ? isPluginConfigArray(value, 2)
293
+ : isPluginConfigObject(value, 1));
294
+ }
295
+ function invalidStore(filePath, code, message, rawDigest) {
296
+ return {
297
+ path: filePath,
298
+ exists: true,
299
+ state: 'invalid',
300
+ values: {},
301
+ ...(rawDigest ? { rawDigest } : {}),
302
+ invalidCode: code,
303
+ issues: [message],
304
+ };
305
+ }
306
+ function readyStore(filePath, values, rawDigest) {
307
+ return {
308
+ path: filePath,
309
+ exists: true,
310
+ state: 'ready',
311
+ values: canonicalizePluginConfigValues(values),
312
+ ...(rawDigest ? { rawDigest } : {}),
313
+ issues: [],
314
+ };
315
+ }
316
+ export function assertReadyPluginConfigStore(store) {
317
+ if (store.state !== 'invalid')
318
+ return;
319
+ throw new Error(`${store.invalidCode}: Invalid plugin config store "${store.path}". ${store.issues.join(' ')}`);
320
+ }
321
+ async function parseStoreJson(filePath) {
322
+ const content = await fs.readFile(filePath);
323
+ const rawDigest = `sha256:${crypto.createHash('sha256').update(content).digest('hex')}`;
324
+ try {
325
+ return {
326
+ state: 'parsed',
327
+ value: JSON.parse(content.toString('utf8')),
328
+ rawDigest,
329
+ };
338
330
  }
339
- if (raw.sourceId !== options.sourceId || raw.pluginName !== options.pluginName) {
340
- throw new Error('Plugin config target identity does not match its namespaced path.');
331
+ catch (error) {
332
+ if (error instanceof SyntaxError) {
333
+ return {
334
+ state: 'invalidJson',
335
+ store: invalidStore(filePath, 'invalidJson', 'The store is not valid JSON.', rawDigest),
336
+ };
337
+ }
338
+ throw error;
341
339
  }
342
- if (raw.sourceIdentity !== options.sourceIdentity) {
343
- throw new Error('sourceChanged: plugin config source identity does not match the configured source.');
340
+ }
341
+ function validateStoreValues(options) {
342
+ if (!isRecord(options.values)) {
343
+ return invalidStore(options.filePath, 'invalidValues', 'The values field must be an object.', options.rawDigest);
344
344
  }
345
- return raw.values;
345
+ const values = Object.create(null);
346
+ const issues = [];
347
+ for (const [key, value] of Object.entries(options.values)) {
348
+ if (!isPluginConfigValue(value)) {
349
+ issues.push(`Config "${key}" is not a supported config value.`);
350
+ continue;
351
+ }
352
+ values[key] = value;
353
+ }
354
+ return issues.length > 0
355
+ ? invalidStore(options.filePath, 'invalidValues', issues.join(' '), options.rawDigest)
356
+ : readyStore(options.filePath, values, options.rawDigest);
357
+ }
358
+ function documentStore(options) {
359
+ const common = validateStoreValues({ filePath: options.filePath, values: options.common, rawDigest: options.rawDigest });
360
+ if (common.state === 'invalid')
361
+ return common;
362
+ if (!isRecord(options.platforms) || Object.keys(options.platforms).some((key) => !PLATFORM_TARGETS.includes(key))) {
363
+ return invalidStore(options.filePath, 'invalidValues', 'The platforms field must contain known platform objects.', options.rawDigest);
364
+ }
365
+ const platforms = {};
366
+ for (const [platform, values] of Object.entries(options.platforms)) {
367
+ const store = validateStoreValues({ filePath: options.filePath, values, rawDigest: options.rawDigest });
368
+ if (store.state === 'invalid')
369
+ return store;
370
+ platforms[platform] = store.values;
371
+ }
372
+ return { ...common, common: common.values, platforms, ...(options.platform ? { platform: options.platform } : {}),
373
+ values: options.platform ? platforms[options.platform] ?? {} : common.values };
374
+ }
375
+ export function pluginConfigStoreForProfile(store, platform) {
376
+ return { ...store, platform, values: platform ? store.platforms?.[platform] ?? {} : store.common ?? store.values };
377
+ }
378
+ /** Replace one layer in memory without changing any other profile. */
379
+ export function replacePluginConfigStoreLayer(store, values, platform) {
380
+ const common = platform ? store.common ?? store.values : canonicalizePluginConfigValues(values);
381
+ const platforms = { ...store.platforms };
382
+ if (platform) {
383
+ if (Object.keys(values).length)
384
+ platforms[platform] = canonicalizePluginConfigValues(values);
385
+ else
386
+ delete platforms[platform];
387
+ }
388
+ const exists = Object.keys(common).length > 0 || Object.keys(platforms).length > 0;
389
+ return { ...store, common, platforms, platform, values: platform ? platforms[platform] ?? {} : common,
390
+ exists, state: exists ? 'ready' : 'missing', issues: [], rawDigest: undefined };
391
+ }
392
+ async function readStoreFile(filePath, platform) {
393
+ const parsed = await parseStoreJson(filePath);
394
+ if (parsed.state === 'invalidJson')
395
+ return parsed.store;
396
+ const raw = parsed.value;
397
+ if (!isRecord(raw) || raw.schemaVersion !== 6
398
+ || Object.keys(raw).some((key) => !['schemaVersion', 'common', 'platforms'].includes(key))) {
399
+ return invalidStore(filePath, 'schemaVersionUnsupported', 'Only plugin config store schemaVersion 6 is supported. Reset the old document, then save the required values.', parsed.rawDigest);
400
+ }
401
+ return documentStore({ filePath, common: raw.common, platforms: raw.platforms, rawDigest: parsed.rawDigest, platform });
402
+ }
403
+ async function readNamespacedStoreFile(options) {
404
+ const parsed = await parseStoreJson(options.filePath);
405
+ if (parsed.state === 'invalidJson')
406
+ return parsed.store;
407
+ const envelope = readPluginConfigEnvelopeV6(parsed.value);
408
+ if (!envelope)
409
+ return invalidStore(options.filePath, 'schemaVersionUnsupported', 'Only a valid plugin config store schemaVersion 6 is supported. Reset the old document, then save the required values.', parsed.rawDigest);
410
+ if (envelope.sourceId !== options.sourceId || envelope.pluginName !== options.pluginName
411
+ || !options.sourceIdentity || envelope.binding.sourceIdentity !== options.sourceIdentity) {
412
+ return invalidStore(options.filePath, 'identityMismatch', 'The user store is not bound to the requested source and plugin identity.', parsed.rawDigest);
413
+ }
414
+ return documentStore({ filePath: options.filePath, common: envelope.common, platforms: envelope.platforms,
415
+ rawDigest: parsed.rawDigest, platform: options.platform });
346
416
  }
347
417
  function namespacedConfigContent(options) {
418
+ const document = { schemaVersion: 6, common: canonicalizePluginConfigValues(options.common),
419
+ platforms: Object.fromEntries(Object.entries(options.platforms).sort(([a], [b]) => a.localeCompare(b, 'en'))
420
+ .map(([platform, values]) => [platform, canonicalizePluginConfigValues(values)])) };
348
421
  if (!options.sourceId)
349
- return `${JSON.stringify(options.values, null, 2)}\n`;
422
+ return `${JSON.stringify(document, null, 2)}\n`;
350
423
  if (!options.sourceIdentity)
351
- throw new Error('sourceIdentity is required for namespaced plugin config.');
352
- const envelope = {
353
- schemaVersion: 2,
354
- sourceId: options.sourceId,
355
- sourceIdentity: options.sourceIdentity,
356
- pluginName: options.pluginName,
357
- values: options.values,
358
- };
359
- return `${JSON.stringify(envelope, null, 2)}\n`;
360
- }
361
- async function assertNoLegacyConfigCoexistence(options) {
362
- if (!options.sourceId)
363
- return;
364
- const legacyPath = resolvePluginConfigStorePath({
365
- pluginName: options.pluginName,
366
- scope: options.scope,
367
- cwd: options.cwd,
368
- env: options.env,
369
- projectLayer: options.projectLayer,
370
- ...(options.scope === 'project' ? { access: 'read' } : {}),
371
- });
372
- if (await lstatIfExists(legacyPath)) {
373
- throw new Error('legacyStateUnsupported: legacy and namespaced plugin config stores cannot coexist.');
374
- }
424
+ throw new Error('sourceChanged: user plugin config requires a source identity.');
425
+ return `${JSON.stringify({ ...document, sourceId: options.sourceId, pluginName: options.pluginName,
426
+ binding: { kind: 'source', sourceIdentity: options.sourceIdentity } }, null, 2)}\n`;
375
427
  }
376
428
  export async function readPluginConfigStore(options) {
377
429
  const filePath = resolvePluginConfigStorePath({
@@ -380,14 +432,11 @@ export async function readPluginConfigStore(options) {
380
432
  });
381
433
  const allowedRoot = resolvePluginConfigAllowedRoot(options);
382
434
  if (options.sourceId) {
383
- if (!options.sourceIdentity)
384
- throw new Error('sourceIdentity is required for namespaced plugin config.');
385
435
  const legacyPath = resolvePluginConfigStorePath({
386
436
  pluginName: options.pluginName,
387
437
  scope: options.scope,
388
438
  cwd: options.cwd,
389
439
  env: options.env,
390
- projectLayer: options.projectLayer,
391
440
  ...(options.scope === 'project' ? { access: 'read' } : {}),
392
441
  });
393
442
  if (await inspectConfigReadTarget(allowedRoot, legacyPath)) {
@@ -398,21 +447,22 @@ export async function readPluginConfigStore(options) {
398
447
  return {
399
448
  path: filePath,
400
449
  exists: false,
450
+ state: 'missing',
401
451
  values: {},
452
+ issues: [],
402
453
  };
403
454
  }
404
- return {
405
- path: filePath,
406
- exists: true,
407
- values: options.sourceId
408
- ? await readNamespacedStoreFile({
409
- filePath,
410
- sourceId: options.sourceId,
411
- sourceIdentity: options.sourceIdentity,
412
- pluginName: options.pluginName,
413
- })
414
- : await readStoreFile(filePath),
415
- };
455
+ return options.sourceId
456
+ ? readNamespacedStoreFile({
457
+ filePath,
458
+ sourceId: options.sourceId,
459
+ scope: options.scope,
460
+ sourceIdentity: options.sourceIdentity,
461
+ logicalIdentity: options.logicalIdentity,
462
+ pluginName: options.pluginName,
463
+ platform: options.platform,
464
+ })
465
+ : readStoreFile(filePath, options.platform);
416
466
  }
417
467
  export async function readNamespacedPluginConfigStoreIdentity(options) {
418
468
  const filePath = resolvePluginConfigStorePath({
@@ -421,15 +471,21 @@ export async function readNamespacedPluginConfigStoreIdentity(options) {
421
471
  });
422
472
  if (!await inspectConfigReadTarget(resolvePluginConfigAllowedRoot(options), filePath))
423
473
  return null;
424
- const raw = await fs.readJson(filePath);
425
- if (!isRecord(raw) || raw.schemaVersion !== 2 || !isRecord(raw.values)
426
- || raw.sourceId !== options.sourceId || raw.pluginName !== options.pluginName
427
- || typeof raw.sourceIdentity !== 'string') {
428
- throw new Error('legacyStateUnsupported: invalid namespaced plugin config store.');
429
- }
474
+ const parsed = await parseStoreJson(filePath);
475
+ if (parsed.state === 'invalidJson') {
476
+ throw new Error(`${parsed.store.invalidCode}: invalid namespaced plugin config store.`);
477
+ }
478
+ const envelope = readPluginConfigEnvelopeV6(parsed.value, options.scope);
479
+ if (!envelope
480
+ || envelope.sourceId !== options.sourceId
481
+ || envelope.pluginName !== options.pluginName) {
482
+ throw new Error('schemaVersionUnsupported: invalid namespaced plugin config store.');
483
+ }
484
+ const store = documentStore({ filePath, common: envelope.common, platforms: envelope.platforms, platform: options.platform });
485
+ assertReadyPluginConfigStore(store);
430
486
  return {
431
- sourceIdentity: raw.sourceIdentity,
432
- store: { path: filePath, exists: true, values: raw.values },
487
+ binding: envelope.binding,
488
+ store,
433
489
  };
434
490
  }
435
491
  async function listConfigStoreDirectoryPluginNames(storeRoot) {
@@ -456,32 +512,75 @@ async function listConfigStoreDirectoryPluginNames(storeRoot) {
456
512
  return pluginNames;
457
513
  }
458
514
  export async function listPluginConfigStorePluginNames(options) {
459
- const projectRoot = resolveAwProjectRoot(options.cwd);
460
- const storeRoots = options.scope === 'user'
461
- ? [path.join(resolveAwHome(options.env), CONFIG_DIR)]
462
- : options.scope === 'project'
463
- ? [path.join(projectRoot, '.agent-workflows', options.projectLayer === 'local' ? 'plugin-config.local' : CONFIG_DIR)]
464
- : [
465
- path.join(resolveAwHome(options.env), CONFIG_DIR),
466
- path.join(projectRoot, '.agent-workflows', CONFIG_DIR),
467
- path.join(projectRoot, '.agent-workflows', 'plugin-config.local'),
468
- ];
515
+ const storeRoots = [path.join(resolveAwHome(options.env), CONFIG_DIR)];
469
516
  const pluginNames = (await Promise.all(storeRoots.map((storeRoot) => listConfigStoreDirectoryPluginNames(storeRoot)))).flat();
470
517
  return [...new Set(pluginNames)].sort((left, right) => left.localeCompare(right));
471
518
  }
519
+ export async function listNamespacedPluginConfigStoreIdentities(options) {
520
+ const boundaryRoot = resolveAwHome(options.env);
521
+ if (options.scope === 'user') {
522
+ await canonicalizePathThroughExistingAncestor(boundaryRoot);
523
+ }
524
+ else {
525
+ await fs.realpath(boundaryRoot);
526
+ }
527
+ const storeRoot = path.join(boundaryRoot, CONFIG_DIR);
528
+ if (!await inspectConfigInventoryStoreRoot(boundaryRoot, storeRoot))
529
+ return [];
530
+ const output = [];
531
+ for (const sourceEntry of await fs.readdir(storeRoot, { withFileTypes: true })) {
532
+ if (!sourceEntry.isDirectory() || sourceEntry.isSymbolicLink())
533
+ continue;
534
+ let sourceId;
535
+ try {
536
+ sourceId = assertSafePluginConfigSegment(sourceEntry.name);
537
+ }
538
+ catch {
539
+ continue;
540
+ }
541
+ const sourceRoot = path.join(storeRoot, sourceId);
542
+ let pluginEntries;
543
+ try {
544
+ await assertNoConfigSymlink(boundaryRoot, sourceRoot);
545
+ pluginEntries = await fs.readdir(sourceRoot, { withFileTypes: true });
546
+ }
547
+ catch {
548
+ continue;
549
+ }
550
+ for (const pluginEntry of pluginEntries) {
551
+ if (!pluginEntry.isDirectory() || pluginEntry.isSymbolicLink())
552
+ continue;
553
+ let pluginName;
554
+ try {
555
+ pluginName = assertSafePluginConfigSegment(pluginEntry.name);
556
+ await assertNoConfigSymlink(boundaryRoot, path.join(sourceRoot, pluginName));
557
+ }
558
+ catch {
559
+ continue;
560
+ }
561
+ let target;
562
+ try {
563
+ target = await lstatIfExists(path.join(sourceRoot, pluginName, CONFIG_FILE));
564
+ }
565
+ catch {
566
+ continue;
567
+ }
568
+ if (!target)
569
+ continue;
570
+ output.push({ sourceId, pluginName, pluginId: `${sourceId}/${pluginName}` });
571
+ }
572
+ }
573
+ return output.sort((left, right) => left.pluginId.localeCompare(right.pluginId));
574
+ }
472
575
  export async function listNamespacedPluginConfigStores(options) {
473
- const boundaryRoot = options.scope === 'user'
474
- ? resolveAwHome(options.env)
475
- : resolveAwProjectRoot(options.cwd);
576
+ const boundaryRoot = resolveAwHome(options.env);
476
577
  if (options.scope === 'user') {
477
578
  await canonicalizePathThroughExistingAncestor(boundaryRoot);
478
579
  }
479
580
  else {
480
581
  await fs.realpath(boundaryRoot);
481
582
  }
482
- const storeRoot = path.join(boundaryRoot, ...(options.scope === 'project' ? ['.agent-workflows'] : []), options.scope === 'project' && options.projectLayer === 'local'
483
- ? 'plugin-config.local'
484
- : CONFIG_DIR);
583
+ const storeRoot = path.join(boundaryRoot, CONFIG_DIR);
485
584
  const output = [];
486
585
  if (!await inspectConfigInventoryStoreRoot(boundaryRoot, storeRoot))
487
586
  return output;
@@ -503,362 +602,362 @@ export async function listNamespacedPluginConfigStores(options) {
503
602
  const filePath = path.join(storeRoot, sourceId, pluginName, CONFIG_FILE);
504
603
  if (!await inspectConfigReadTarget(storeRoot, filePath))
505
604
  continue;
506
- const raw = await fs.readJson(filePath);
507
- if (!isRecord(raw) || raw.schemaVersion !== 2 || !isRecord(raw.values)
508
- || raw.sourceId !== sourceId || raw.pluginName !== pluginName
509
- || typeof raw.sourceIdentity !== 'string') {
510
- throw new Error(`legacyStateUnsupported: invalid namespaced plugin config store "${filePath}".`);
605
+ const parsed = await parseStoreJson(filePath);
606
+ if (parsed.state === 'invalidJson') {
607
+ throw new Error(`${parsed.store.invalidCode}: invalid namespaced plugin config store "${filePath}".`);
511
608
  }
609
+ const envelope = readPluginConfigEnvelopeV6(parsed.value, options.scope);
610
+ if (!envelope
611
+ || envelope.sourceId !== sourceId
612
+ || envelope.pluginName !== pluginName) {
613
+ throw new Error(`schemaVersionUnsupported: invalid namespaced plugin config store "${filePath}".`);
614
+ }
615
+ const store = documentStore({ filePath, common: envelope.common, platforms: envelope.platforms });
616
+ assertReadyPluginConfigStore(store);
512
617
  output.push({
513
618
  sourceId,
514
- sourceIdentity: raw.sourceIdentity,
619
+ binding: envelope.binding,
515
620
  pluginName,
516
621
  pluginId: `${sourceId}/${pluginName}`,
517
- values: raw.values,
622
+ values: store.values,
518
623
  });
519
624
  }
520
625
  }
521
626
  return output.sort((left, right) => left.pluginId.localeCompare(right.pluginId));
522
627
  }
523
628
  export async function writePluginConfigStore(options) {
524
- await assertNoLegacyConfigCoexistence(options);
525
- const filePath = resolvePluginConfigStorePath({
526
- ...options,
527
- ...(options.scope === 'project' ? { access: 'write' } : {}),
528
- });
629
+ const current = await readPluginConfigStore(options);
630
+ assertReadyPluginConfigStore(current);
631
+ const validated = validateStoreValues({ filePath: current.path, values: options.values });
632
+ assertReadyPluginConfigStore(validated);
633
+ return commitPluginConfigLayer(options, current, validated.values);
634
+ }
635
+ async function commitPluginConfigLayer(options, current, values) {
636
+ const next = replacePluginConfigStoreLayer(current, values, options.platform);
529
637
  const allowedRoot = resolvePluginConfigAllowedRoot(options);
530
- await withConfigFileMutation({
531
- filePath,
532
- allowedRoot,
533
- action: async () => atomicReplaceConfigFile({
534
- filePath,
535
- allowedRoot,
536
- content: namespacedConfigContent(options),
537
- mode: 0o600,
538
- }),
539
- });
540
- return {
541
- pluginName: options.pluginName,
542
- scope: options.scope,
543
- path: filePath,
544
- };
638
+ await withConfigFileMutation({ filePath: current.path, allowedRoot, action: async () => {
639
+ if (!next.exists)
640
+ await atomicRemoveConfigFile({ filePath: current.path, allowedRoot });
641
+ else
642
+ await atomicReplaceConfigFile({ filePath: current.path, allowedRoot,
643
+ content: namespacedConfigContent({ ...options, common: next.common, platforms: next.platforms }), mode: 0o600 });
644
+ } });
645
+ return { pluginName: options.pluginName, scope: 'user', platform: options.platform, path: current.path, warnings: [] };
545
646
  }
546
647
  export async function patchPluginConfigStore(options) {
547
- await assertNoLegacyConfigCoexistence(options);
548
- const filePath = resolvePluginConfigStorePath({
549
- ...options,
550
- ...(options.scope === 'project' ? { access: 'write' } : {}),
551
- });
552
- const allowedRoot = resolvePluginConfigAllowedRoot(options);
648
+ await options.reviewPreflight?.();
649
+ const current = await readPluginConfigStore(options);
650
+ assertReadyPluginConfigStore(current);
553
651
  const removedKeys = options.removeKeys ?? [];
554
- await withConfigFileMutation({
555
- filePath,
556
- allowedRoot,
557
- action: async () => {
558
- await options.reviewPreflight?.();
559
- const current = (await lstatIfExists(filePath))
560
- ? options.sourceId
561
- ? await readNamespacedStoreFile({
562
- filePath,
563
- sourceId: options.sourceId,
564
- sourceIdentity: options.sourceIdentity,
565
- pluginName: options.pluginName,
566
- })
567
- : await readStoreFile(filePath)
568
- : {};
569
- if (options.requireExistingRemoveKeys) {
570
- const missingKey = removedKeys.find((key) => !Object.hasOwn(current, key));
571
- if (missingKey)
572
- throw new Error(`Unknown config key "${missingKey}".`);
573
- }
574
- const next = { ...current };
575
- for (const key of removedKeys) {
576
- delete next[key];
577
- }
578
- for (const [key, value] of Object.entries(options.updates)) {
579
- next[key] = value;
580
- }
581
- await atomicReplaceConfigFile({
582
- filePath,
583
- allowedRoot,
584
- content: namespacedConfigContent({ ...options, values: next }),
585
- mode: 0o600,
586
- });
587
- },
588
- });
589
- return {
590
- pluginName: options.pluginName,
591
- scope: options.scope,
592
- path: filePath,
593
- updatedKeys: Object.keys(options.updates),
594
- removedKeys,
595
- };
652
+ if (options.requireExistingRemoveKeys) {
653
+ const missing = removedKeys.find((key) => !Object.hasOwn(current.values, key));
654
+ if (missing)
655
+ throw new Error(`Unknown config key "${missing}".`);
656
+ }
657
+ const next = Object.assign(Object.create(null), current.values);
658
+ for (const key of removedKeys)
659
+ delete next[key];
660
+ for (const [key, value] of Object.entries(options.updates))
661
+ next[key] = value;
662
+ const validated = validateStoreValues({ filePath: current.path, values: next });
663
+ assertReadyPluginConfigStore(validated);
664
+ return { ...await commitPluginConfigLayer(options, current, validated.values), updatedKeys: Object.keys(options.updates), removedKeys };
596
665
  }
597
666
  export async function resetPluginConfigStore(options) {
598
- await assertNoLegacyConfigCoexistence(options);
667
+ return resetPluginConfigStoreTarget(options, false);
668
+ }
669
+ /** Delete the plugin's complete user document, including every platform profile. */
670
+ export async function deletePluginConfigStore(options) {
671
+ return resetPluginConfigStoreTarget(options, true);
672
+ }
673
+ async function resetPluginConfigStoreTarget(options, wholeDocument) {
599
674
  const filePath = resolvePluginConfigStorePath({
600
675
  ...options,
601
676
  ...(options.scope === 'project' ? { access: 'write' } : {}),
602
677
  });
603
678
  const allowedRoot = resolvePluginConfigAllowedRoot(options);
604
- const existed = await withConfigFileMutation({
605
- filePath,
606
- allowedRoot,
607
- action: async () => {
608
- await options.reviewPreflight?.();
609
- const target = await lstatIfExists(filePath);
610
- if (!target)
611
- return false;
612
- if (!target.isFile() || target.isSymbolicLink()) {
613
- throw new Error(`Config target must be a regular file: ${filePath}`);
614
- }
615
- if (options.sourceId) {
616
- if (!options.sourceIdentity) {
617
- throw new Error('sourceIdentity is required for namespaced plugin config.');
618
- }
619
- await readNamespacedStoreFile({
620
- filePath,
621
- sourceId: options.sourceId,
622
- sourceIdentity: options.sourceIdentity,
679
+ const publicTarget = `${options.scope}/plugin-config/${[
680
+ options.sourceId,
681
+ options.pluginName,
682
+ CONFIG_FILE,
683
+ ].filter(Boolean).join('/')}`;
684
+ const { root, candidate } = assertConfigPathBoundary(allowedRoot, filePath);
685
+ let current = root;
686
+ try {
687
+ for (const segment of path.relative(root, path.dirname(candidate)).split(path.sep).filter(Boolean)) {
688
+ const stats = await lstatIfExists(current);
689
+ if (!stats) {
690
+ return {
623
691
  pluginName: options.pluginName,
624
- });
692
+ scope: 'user',
693
+ storeKind: 'user',
694
+ path: filePath,
695
+ existed: false,
696
+ deleted: false,
697
+ resetDisposition: 'absent',
698
+ };
625
699
  }
626
- else {
627
- await readStoreFile(filePath);
700
+ if (stats.isSymbolicLink() || !stats.isDirectory()) {
701
+ throw new PluginConfigResetError('configResetTargetUnsupported', `${publicTarget} has an unsafe ancestor. Repair it manually, then retry config reset.`);
628
702
  }
629
- return atomicRemoveConfigFile({ filePath, allowedRoot });
630
- },
631
- });
632
- return {
633
- pluginName: options.pluginName,
634
- scope: options.scope,
635
- storeKind: options.scope === 'user'
636
- ? 'user'
637
- : options.projectLayer === 'local'
638
- ? 'projectLocal'
639
- : 'projectShared',
640
- path: filePath,
641
- existed,
642
- deleted: existed,
643
- };
644
- }
645
- export async function resetPluginConfigStores(options) {
646
- await assertNoLegacyConfigCoexistence(options);
647
- const targets = resolvePluginConfigStoreTargets({
648
- ...options,
649
- ...(options.scope === 'project' ? { access: 'write' } : {}),
650
- });
651
- const allowedRoot = resolvePluginConfigAllowedRoot(options);
652
- const receipts = [];
653
- const existing = [];
654
- for (const target of targets) {
655
- await prepareConfigFileParent(target.path, allowedRoot);
656
- await assertNoConfigSymlink(allowedRoot, target.path);
657
- const stats = await lstatIfExists(target.path);
658
- existing.push(stats !== null);
659
- if (!stats)
660
- continue;
661
- if (!stats.isFile() || stats.isSymbolicLink()) {
662
- throw new Error(`Config target must be a regular file: ${target.path}`);
703
+ current = path.join(current, segment);
663
704
  }
664
- if (options.sourceId) {
665
- if (!options.sourceIdentity) {
666
- throw new Error('sourceIdentity is required for namespaced plugin config.');
667
- }
668
- await readNamespacedStoreFile({
669
- filePath: target.path,
670
- sourceId: options.sourceId,
671
- sourceIdentity: options.sourceIdentity,
705
+ const parentStats = await lstatIfExists(current);
706
+ if (!parentStats) {
707
+ return {
672
708
  pluginName: options.pluginName,
673
- });
674
- }
675
- else {
676
- await readStoreFile(target.path);
709
+ scope: 'user',
710
+ storeKind: 'user',
711
+ path: filePath,
712
+ existed: false,
713
+ deleted: false,
714
+ resetDisposition: 'absent',
715
+ };
677
716
  }
678
- }
679
- for (const [index, target] of targets.entries()) {
680
- const deleted = await atomicRemoveConfigFile({
681
- filePath: target.path,
682
- allowedRoot,
683
- });
684
- receipts.push({
685
- pluginName: options.pluginName,
686
- scope: options.scope,
687
- storeKind: target.storeKind,
688
- path: target.path,
689
- existed: existing[index],
690
- deleted,
691
- });
692
- }
693
- return receipts;
694
- }
695
- function coercePrimitiveValue(key, field, value) {
696
- if (field.type === 'string') {
697
- if (typeof value !== 'string') {
698
- throw new Error(`Config "${key}" must be a string.`);
717
+ if (parentStats.isSymbolicLink() || !parentStats.isDirectory()) {
718
+ throw new PluginConfigResetError('configResetTargetUnsupported', `${publicTarget} has an unsafe ancestor. Repair it manually, then retry config reset.`);
699
719
  }
700
- return value;
701
- }
702
- if (field.type === 'number') {
703
- const numberValue = typeof value === 'number'
704
- ? value
705
- : typeof value === 'string' && value.trim() !== ''
706
- ? Number(value)
707
- : Number.NaN;
708
- if (!Number.isFinite(numberValue)) {
709
- throw new Error(`Config "${key}" must be a number.`);
720
+ await options.reviewPreflight?.();
721
+ const target = await lstatIfExists(filePath);
722
+ if (!target) {
723
+ return {
724
+ pluginName: options.pluginName,
725
+ scope: 'user',
726
+ storeKind: 'user',
727
+ path: filePath,
728
+ existed: false,
729
+ deleted: false,
730
+ resetDisposition: 'absent',
731
+ };
710
732
  }
711
- if (field.min !== undefined && numberValue < field.min) {
712
- throw new Error(`Config "${key}" must be greater than or equal to ${field.min}.`);
733
+ let store;
734
+ if (target.isFile()) {
735
+ try {
736
+ store = await readPluginConfigStore(options);
737
+ }
738
+ catch {
739
+ // A broken document still has the schema-independent reset recovery below.
740
+ }
713
741
  }
714
- if (field.max !== undefined && numberValue > field.max) {
715
- throw new Error(`Config "${key}" must be less than or equal to ${field.max}.`);
742
+ if (!wholeDocument && store && store.state !== 'invalid' && replacePluginConfigStoreLayer(store, {}, options.platform).exists) {
743
+ await commitPluginConfigLayer(options, store, {});
744
+ return { pluginName: options.pluginName, scope: 'user', platform: options.platform, storeKind: 'user',
745
+ path: filePath, existed: true, deleted: false, resetDisposition: 'clearedLayer' };
716
746
  }
717
- return numberValue;
718
- }
719
- if (field.type === 'boolean') {
720
- if (typeof value === 'boolean') {
721
- return value;
747
+ if (target.isFile() || target.isSymbolicLink()) {
748
+ await assertNoConfigSymlink(allowedRoot, path.dirname(filePath));
749
+ await nodeFs.unlink(filePath);
750
+ return {
751
+ pluginName: options.pluginName,
752
+ scope: 'user',
753
+ storeKind: 'user',
754
+ path: filePath,
755
+ existed: true,
756
+ deleted: true,
757
+ resetDisposition: target.isSymbolicLink() ? 'unlinkedSymlink' : 'deletedFile',
758
+ };
722
759
  }
723
- if (typeof value === 'string') {
724
- const normalized = value.trim().toLowerCase();
725
- if (['true', '1', 'yes', 'y'].includes(normalized)) {
726
- return true;
727
- }
728
- if (['false', '0', 'no', 'n'].includes(normalized)) {
729
- return false;
730
- }
760
+ if (target.isDirectory()) {
761
+ const timestamp = new Date().toISOString().replace(/[-:]/gu, '').replace(/\..*$/u, '');
762
+ const quarantineBasename = `config.broken-${timestamp}-${crypto.randomUUID()}.json`;
763
+ await assertNoConfigSymlink(allowedRoot, path.dirname(filePath));
764
+ await nodeFs.rename(filePath, path.join(path.dirname(filePath), quarantineBasename));
765
+ return {
766
+ pluginName: options.pluginName,
767
+ scope: 'user',
768
+ storeKind: 'user',
769
+ path: filePath,
770
+ existed: true,
771
+ deleted: true,
772
+ resetDisposition: 'quarantinedDirectory',
773
+ quarantineBasename,
774
+ };
731
775
  }
732
- throw new Error(`Config "${key}" must be a boolean.`);
776
+ throw new PluginConfigResetError('configResetTargetUnsupported', `${publicTarget} is a special filesystem node. Move it manually, then retry config reset.`);
733
777
  }
734
- if (field.type === 'enum') {
735
- if (typeof value !== 'string') {
736
- throw new Error(`Config "${key}" must be an enum string.`);
737
- }
738
- if (!field.values?.includes(value)) {
739
- throw new Error(`Config "${key}" must be one of: ${(field.values ?? []).join(', ')}.`);
778
+ catch (error) {
779
+ if (error instanceof PluginConfigResetError)
780
+ throw error;
781
+ const osCode = error.code;
782
+ throw new PluginConfigResetError('configResetFailed', `Cannot reset ${publicTarget}${osCode ? ` (${osCode})` : ''}. Fix filesystem access, then retry config reset.`, osCode);
783
+ }
784
+ }
785
+ export async function inspectPluginConfigResetTarget(options) {
786
+ const filePath = resolvePluginConfigStorePath({
787
+ ...options,
788
+ ...(options.scope === 'project' ? { access: 'write' } : {}),
789
+ });
790
+ const allowedRoot = resolvePluginConfigAllowedRoot(options);
791
+ const publicTarget = `${options.scope}/plugin-config/${[
792
+ options.sourceId,
793
+ options.pluginName,
794
+ CONFIG_FILE,
795
+ ].filter(Boolean).join('/')}`;
796
+ const { root, candidate } = assertConfigPathBoundary(allowedRoot, filePath);
797
+ let current = root;
798
+ for (const segment of path.relative(root, path.dirname(candidate)).split(path.sep).filter(Boolean)) {
799
+ const stats = await lstatIfExists(current);
800
+ if (!stats)
801
+ return resetTargetInspection('absent');
802
+ if (stats.isSymbolicLink() || !stats.isDirectory()) {
803
+ throw new PluginConfigResetError('configResetTargetUnsupported', `${publicTarget} has an unsafe ancestor. Repair it manually, then retry config reset.`);
740
804
  }
741
- return value;
805
+ current = path.join(current, segment);
742
806
  }
743
- if (field.type === 'file' || field.type === 'directory') {
744
- if (typeof value !== 'string' || value.trim() === '') {
745
- throw new Error(`Config "${key}" must be a path string.`);
807
+ const parentStats = await lstatIfExists(current);
808
+ if (!parentStats)
809
+ return resetTargetInspection('absent');
810
+ if (parentStats.isSymbolicLink() || !parentStats.isDirectory()) {
811
+ throw new PluginConfigResetError('configResetTargetUnsupported', `${publicTarget} has an unsafe ancestor. Repair it manually, then retry config reset.`);
812
+ }
813
+ const target = await lstatIfExists(filePath);
814
+ if (!target)
815
+ return resetTargetInspection('absent');
816
+ const kind = target.isSymbolicLink() ? 'symbolicLink'
817
+ : target.isFile() ? 'regularFile'
818
+ : target.isDirectory() ? 'directory'
819
+ : 'special';
820
+ return resetTargetInspection(kind, target);
821
+ }
822
+ function resetTargetInspection(kind, stats) {
823
+ const fingerprint = `sha256:${crypto.createHash('sha256').update(JSON.stringify({
824
+ kind,
825
+ ...(stats ? {
826
+ dev: stats.dev,
827
+ ino: stats.ino,
828
+ mode: stats.mode,
829
+ size: stats.size,
830
+ mtimeMs: stats.mtimeMs,
831
+ ctimeMs: stats.ctimeMs,
832
+ } : {}),
833
+ })).digest('hex')}`;
834
+ return {
835
+ exists: kind !== 'absent',
836
+ kind,
837
+ resettable: kind !== 'special',
838
+ fingerprint,
839
+ };
840
+ }
841
+ export async function resetPluginConfigStores(options) {
842
+ return [await resetPluginConfigStore(options)];
843
+ }
844
+ export class PluginConfigValueValidationError extends Error {
845
+ publicMessage;
846
+ constructor(issue, publicMessage) {
847
+ super(formatPluginConfigIssue(issue));
848
+ this.publicMessage = publicMessage;
849
+ }
850
+ }
851
+ function configValueIssuePublicMessage(initialField, input, issue) {
852
+ const segments = issue.path.segments;
853
+ if (segments === undefined || segments.length < 2 || initialField.sensitive === true)
854
+ return undefined;
855
+ let field = initialField;
856
+ let value = input;
857
+ // User-supplied object keys may contain private text. Only report declared properties and row positions.
858
+ for (const segment of segments.slice(1)) {
859
+ if (typeof segment === 'number' && field.type === 'array' && Array.isArray(value)) {
860
+ field = field.items;
861
+ value = value[segment];
746
862
  }
747
- return value;
863
+ else if (typeof segment === 'string' && field.type === 'object' && isRecord(value)) {
864
+ const { properties } = resolvePluginConfigObjectProperties(field, value);
865
+ if (!Object.hasOwn(properties, segment) || !/^[A-Za-z0-9_-]+$/u.test(segment))
866
+ return undefined;
867
+ field = properties[segment];
868
+ value = Object.hasOwn(value, segment) ? value[segment] : undefined;
869
+ }
870
+ else
871
+ return undefined;
748
872
  }
749
- throw new Error(`Config "${key}" has unsupported type "${field.type}".`);
873
+ return formatPluginConfigIssue(issue);
750
874
  }
751
- async function resolvePathConfigValue(options) {
752
- if (options.field.type !== 'file' && options.field.type !== 'directory') {
753
- return String(options.value);
875
+ function coerceConfigValue(key, field, value) {
876
+ let coerced = value;
877
+ if (field.type === 'number' && typeof value === 'string' && value.trim() !== '') {
878
+ coerced = Number(value);
754
879
  }
755
- const rawPath = String(options.value);
756
- const resolvedPath = path.isAbsolute(rawPath)
757
- ? rawPath
758
- : path.resolve(options.projectRoot, rawPath);
759
- const realPath = await fs.realpath(resolvedPath);
760
- const stats = await fs.stat(realPath);
761
- if (options.field.type === 'file' && !stats.isFile()) {
762
- throw new Error(`Config "${options.key}" must point to an existing file.`);
880
+ else if (field.type === 'boolean' && typeof value === 'string') {
881
+ const normalized = value.trim().toLowerCase();
882
+ if (['true', '1', 'yes', 'y'].includes(normalized))
883
+ coerced = true;
884
+ if (['false', '0', 'no', 'n'].includes(normalized))
885
+ coerced = false;
763
886
  }
764
- if (options.field.type === 'directory' && !stats.isDirectory()) {
765
- throw new Error(`Config "${options.key}" must point to an existing directory.`);
887
+ const issues = validateCorePluginConfigValue(field, coerced, key);
888
+ if (issues.length > 0) {
889
+ const issue = issues[0];
890
+ throw new PluginConfigValueValidationError(issue, configValueIssuePublicMessage(field, coerced, issue));
766
891
  }
767
- return realPath;
892
+ return coerced;
768
893
  }
769
894
  export async function coercePluginConfigValue(options) {
770
- const primitive = coercePrimitiveValue(options.key, options.field, options.value);
771
- if (options.field.type === 'file' || options.field.type === 'directory') {
772
- return resolvePathConfigValue({
773
- key: options.key,
774
- field: options.field,
775
- value: primitive,
776
- projectRoot: options.projectRoot,
777
- });
778
- }
779
- return primitive;
895
+ return coerceConfigValue(options.key, options.field, options.value);
780
896
  }
781
897
  function redactValue(field, value) {
782
- return field.sensitive ? '[redacted]' : value;
783
- }
784
- function sourceForStoreLayer(scope, projectLayer = 'shared') {
785
- if (scope === 'user') {
786
- return 'user';
787
- }
788
- return projectLayer === 'local' ? 'projectLocal' : 'project';
789
- }
790
- function isPathTypeField(field) {
791
- return field.type === 'file' || field.type === 'directory';
898
+ return redactPluginConfigValue(field, value);
792
899
  }
793
900
  async function applyConfigLayer(options) {
794
901
  for (const [key, field] of Object.entries(options.schema)) {
795
902
  if (!Object.hasOwn(options.entries, key)) {
796
903
  continue;
797
904
  }
798
- try {
799
- const coerced = await coercePluginConfigValue({
800
- key,
801
- field,
802
- value: options.entries[key],
803
- projectRoot: options.projectRoot,
804
- });
805
- options.values[key] = coerced;
806
- options.redactedValues[key] = redactValue(field, coerced);
905
+ const value = options.entries[key];
906
+ const validationIssues = validateCorePluginConfigValue(field, value, key);
907
+ if (validationIssues.length === 0) {
908
+ const redactedValue = redactValue(field, value);
909
+ options.values[key] = value;
910
+ options.redactedValues[key] = redactedValue;
807
911
  options.sources[key] = options.source;
808
- options.invalidIssues.delete(key);
912
+ options.fieldStates[key] = {
913
+ effective: { value, redactedValue, source: options.source },
914
+ };
809
915
  }
810
- catch (error) {
916
+ else {
917
+ const fallback = options.fieldStates[key]?.effective;
811
918
  delete options.values[key];
812
919
  delete options.redactedValues[key];
813
920
  options.sources[key] = options.source;
814
- options.invalidIssues.set(key, {
921
+ const issues = validationIssues.map((issue) => ({
815
922
  type: 'invalid-config',
816
923
  key,
817
924
  source: options.source,
818
- message: error instanceof Error ? error.message : String(error),
819
- });
925
+ message: formatPluginConfigIssue(issue),
926
+ }));
927
+ options.fieldStates[key] = {
928
+ invalidOverride: { source: options.source, issues },
929
+ ...(fallback ? { fallback } : {}),
930
+ };
820
931
  }
821
932
  }
822
933
  }
823
934
  export async function resolveEffectivePluginConfig(options) {
935
+ const workContext = options.context ? await resolveWorkContext({ cwd: options.cwd, context: options.context }) : undefined;
824
936
  const pluginName = assertSafePluginConfigSegment(options.pluginName ?? options.manifest.name);
825
- const schema = options.manifest.config?.schema;
937
+ const user = await readPluginConfigStore({ ...options, pluginName, scope: 'user' });
938
+ assertReadyPluginConfigStore(user);
939
+ const references = !options.referenceContext && pluginConfigHasExternalReferences(options.manifest)
940
+ ? await resolvePluginConfigReferenceContext({ ...options, scope: options.context ?? options.targetScope ?? 'user', plugins: options.referencePlugins }) : undefined;
941
+ return resolveEffectivePluginConfigFromStores({ ...options, pluginName, projectRoot: workContext?.projectRoot ?? ((options.context ?? options.targetScope) === 'project' ? resolveAwProjectRoot(options.cwd) : ''),
942
+ referenceContext: options.referenceContext ?? references?.context, referenceEvidence: references?.evidence,
943
+ stores: { user } });
944
+ }
945
+ export async function resolveEffectivePluginConfigFromStores(options) {
946
+ const pluginName = assertSafePluginConfigSegment(options.pluginName ?? options.manifest.name);
947
+ const definition = options.manifest.config ? selectPluginConfigProfile(options.manifest.config, options.platform) : undefined;
948
+ const schema = definition?.fields;
826
949
  if (!schema) {
827
- throw new Error(`Plugin "${pluginName}" does not declare an AW config schema.`);
950
+ throw new PluginConfigSchemaResolutionError('configSchemaUnavailable', `Plugin "${pluginName}" does not declare an AW config schema.`);
828
951
  }
829
- const projectRoot = resolveAwProjectRoot(options.cwd);
830
- const [userStore, projectStore, projectLocalStore] = await Promise.all([
831
- readPluginConfigStore({
832
- sourceId: options.sourceId,
833
- sourceIdentity: options.sourceIdentity,
834
- pluginName,
835
- scope: 'user',
836
- cwd: options.cwd,
837
- env: options.env,
838
- }),
839
- readPluginConfigStore({
840
- sourceId: options.sourceId,
841
- sourceIdentity: options.sourceIdentity,
842
- pluginName,
843
- scope: 'project',
844
- cwd: options.cwd,
845
- env: options.env,
846
- }),
847
- readPluginConfigStore({
848
- sourceId: options.sourceId,
849
- sourceIdentity: options.sourceIdentity,
850
- pluginName,
851
- scope: 'project',
852
- cwd: options.cwd,
853
- env: options.env,
854
- projectLayer: 'local',
855
- }),
856
- ]);
952
+ const userStore = options.stores.user;
953
+ assertReadyPluginConfigStore(userStore);
857
954
  const values = {};
858
955
  const redactedValues = {};
859
956
  const sources = {};
860
- const invalidIssues = new Map();
957
+ const fieldStates = {};
861
958
  const ignoredUnknownKeys = [];
959
+ const unsupportedLayerOverrides = [];
960
+ const dangerousKeyIssues = [];
862
961
  const schemaKeys = new Set(Object.keys(schema));
863
962
  for (const key of schemaKeys) {
864
963
  sources[key] = 'missing';
@@ -871,43 +970,151 @@ export async function resolveEffectivePluginConfig(options) {
871
970
  values,
872
971
  redactedValues,
873
972
  sources,
874
- invalidIssues,
973
+ fieldStates,
875
974
  schema: { [key]: field },
876
975
  entries: { [key]: field.default },
877
976
  source: 'default',
878
- projectRoot,
879
977
  });
880
978
  }
881
- for (const [scope, store, projectLayer] of [
882
- ['user', userStore, 'shared'],
883
- ['project', projectStore, 'shared'],
884
- ['project', projectLocalStore, 'local'],
885
- ]) {
886
- const plainEntries = getStoreEntries(store.values);
979
+ const commonFields = selectPluginConfigProfile(options.manifest.config, undefined).fields;
980
+ const layers = [
981
+ { entries: options.platform
982
+ ? Object.fromEntries(Object.entries(userStore.common ?? (userStore.platform ? {} : userStore.values))
983
+ .filter(([key]) => {
984
+ // Unknown keys remain available to the existing dangerous-key check and
985
+ // unknown-key reporting; only declared, platform-specific values are isolated.
986
+ if (!Object.hasOwn(schema, key))
987
+ return true;
988
+ const field = schema[key];
989
+ return Object.hasOwn(commonFields, key) && !('platformOnly' in field && field.platformOnly);
990
+ }))
991
+ : userStore.common ?? userStore.values, source: 'common' },
992
+ ...(options.platform ? [{ entries: userStore.platforms?.[options.platform] ?? {}, source: 'platform' }] : []),
993
+ ];
994
+ for (const { entries, source } of layers) {
995
+ const plainEntries = getStoreEntries(entries);
996
+ const dangerousIssues = new Map(validatePluginConfigDocument(definition, plainEntries)
997
+ .filter((issue) => issue.code === 'dangerousKey').map((issue) => [issue.path.field, issue]));
887
998
  for (const key of Object.keys(plainEntries)) {
888
- if (!schemaKeys.has(key)) {
889
- ignoredUnknownKeys.push({
890
- scope,
891
- projectLayer,
892
- source: sourceForStoreLayer(scope, projectLayer),
893
- key,
894
- });
895
- }
999
+ if (schemaKeys.has(key))
1000
+ continue;
1001
+ const dangerousIssue = dangerousIssues.get(key);
1002
+ if (dangerousIssue)
1003
+ dangerousKeyIssues.push({ type: 'invalid-config', code: dangerousIssue.code,
1004
+ key, source, message: formatPluginConfigIssue(dangerousIssue) });
1005
+ else
1006
+ ignoredUnknownKeys.push({ scope: 'user', source, key });
896
1007
  }
897
1008
  await applyConfigLayer({
898
1009
  values,
899
1010
  redactedValues,
900
1011
  sources,
901
- invalidIssues,
1012
+ fieldStates,
902
1013
  schema,
903
1014
  entries: plainEntries,
904
- source: sourceForStoreLayer(scope, projectLayer),
905
- projectRoot,
1015
+ source,
906
1016
  });
907
1017
  }
908
- const issues = [...invalidIssues.values()];
1018
+ const candidateValues = {};
909
1019
  for (const [key, field] of Object.entries(schema)) {
910
- if (field.required && values[key] === undefined) {
1020
+ const source = sources[key];
1021
+ if (source === 'default')
1022
+ candidateValues[key] = field.default;
1023
+ if (source === 'common')
1024
+ candidateValues[key] = ownStoreValue(userStore.common ?? userStore.values, key);
1025
+ if (source === 'platform' && options.platform)
1026
+ candidateValues[key] = ownStoreValue(userStore.platforms?.[options.platform] ?? {}, key);
1027
+ }
1028
+ const candidateIssues = validatePluginConfigCandidate(definition, candidateValues, undefined, options.referenceContext);
1029
+ const referenceIssues = candidateIssues.filter((issue) => issue.code.startsWith('valueRef')
1030
+ && (!issue.path.plugin || issue.path.plugin === pluginName));
1031
+ const missingReferenceIssues = [];
1032
+ for (const issue of referenceIssues) {
1033
+ const key = issue.path.field;
1034
+ const source = sources[key];
1035
+ const state = fieldStates[key];
1036
+ const configIssue = {
1037
+ type: 'invalid-config', code: issue.code, key, source,
1038
+ message: formatPluginConfigIssue(issue),
1039
+ };
1040
+ if (source === 'missing') {
1041
+ missingReferenceIssues.push(configIssue);
1042
+ continue;
1043
+ }
1044
+ delete values[key];
1045
+ delete redactedValues[key];
1046
+ fieldStates[key] = {
1047
+ invalidOverride: { source, issues: [...(state?.invalidOverride?.issues ?? []), configIssue] },
1048
+ ...(state?.fallback ? { fallback: state.fallback } : {}),
1049
+ };
1050
+ }
1051
+ // Provider errors stay private, while each field that reads them remains unusable.
1052
+ if (options.referenceContext) {
1053
+ for (const foreign of candidateIssues.filter((issue) => issue.code.startsWith('valueRef')
1054
+ && issue.path.plugin && issue.path.plugin !== pluginName)) {
1055
+ for (const key of schemaKeys) {
1056
+ let dependencies;
1057
+ try {
1058
+ dependencies = getPluginConfigDependencyFields(definition, [key], options.referenceContext);
1059
+ }
1060
+ catch {
1061
+ continue; // The local association issue already reports the invalid schema.
1062
+ }
1063
+ if (!dependencies.some((entry) => entry.plugin === foreign.path.plugin && entry.field === foreign.path.field))
1064
+ continue;
1065
+ const source = sources[key];
1066
+ const state = fieldStates[key];
1067
+ const configIssue = { type: 'invalid-config', code: 'valueRefSource', key, source,
1068
+ message: `Config "${key}" depends on invalid config "${foreign.path.plugin}/${foreign.path.field}". Fix the dependency before using this field.` };
1069
+ if (state?.invalidOverride?.issues.some((issue) => issue.code === configIssue.code && issue.message === configIssue.message))
1070
+ continue;
1071
+ delete values[key];
1072
+ delete redactedValues[key];
1073
+ if (source === 'missing')
1074
+ missingReferenceIssues.push(configIssue);
1075
+ else
1076
+ fieldStates[key] = { invalidOverride: { source, issues: [...(state?.invalidOverride?.issues ?? []), configIssue] },
1077
+ ...(state?.fallback ? { fallback: state.fallback } : {}) };
1078
+ }
1079
+ }
1080
+ }
1081
+ // Consumers must retain dependency failures after invalid source values are omitted.
1082
+ const invalidKeys = new Set([
1083
+ ...Object.entries(fieldStates).filter(([, state]) => state.invalidOverride !== undefined).map(([key]) => key),
1084
+ ...missingReferenceIssues.map((issue) => issue.key),
1085
+ ]);
1086
+ for (const key of schemaKeys) {
1087
+ if (invalidKeys.has(key))
1088
+ continue;
1089
+ const dependency = getPluginConfigDependencyKeys(definition, [key])
1090
+ .find((dependencyKey) => dependencyKey !== key && invalidKeys.has(dependencyKey));
1091
+ if (dependency === undefined)
1092
+ continue;
1093
+ const source = sources[key];
1094
+ const configIssue = {
1095
+ type: 'invalid-config', code: 'valueRefSource', key, source,
1096
+ message: `Config "${key}" depends on invalid config "${dependency}". Fix the dependency before using this field.`,
1097
+ };
1098
+ delete values[key];
1099
+ delete redactedValues[key];
1100
+ if (source === 'missing') {
1101
+ missingReferenceIssues.push(configIssue);
1102
+ }
1103
+ else {
1104
+ const state = fieldStates[key];
1105
+ fieldStates[key] = {
1106
+ invalidOverride: { source, issues: [configIssue] },
1107
+ ...(state?.fallback ? { fallback: state.fallback } : {}),
1108
+ };
1109
+ }
1110
+ }
1111
+ const issues = [
1112
+ ...Object.values(fieldStates).flatMap((state) => state.invalidOverride?.issues ?? []),
1113
+ ...dangerousKeyIssues,
1114
+ ...missingReferenceIssues,
1115
+ ];
1116
+ for (const [key, field] of Object.entries(schema)) {
1117
+ if (field.required && values[key] === undefined && !fieldStates[key]?.invalidOverride) {
911
1118
  issues.push({
912
1119
  type: 'missing-required',
913
1120
  key,
@@ -918,650 +1125,216 @@ export async function resolveEffectivePluginConfig(options) {
918
1125
  }
919
1126
  return {
920
1127
  pluginName,
921
- projectRoot,
1128
+ platform: options.platform,
1129
+ context: options.context ?? options.targetScope ?? 'user',
1130
+ definition: definition,
1131
+ projectRoot: options.projectRoot,
922
1132
  values,
923
1133
  redactedValues,
924
1134
  sources,
1135
+ fieldStates,
925
1136
  issues,
1137
+ unsupportedLayerOverrides,
926
1138
  ignoredUnknownKeys,
927
1139
  schema,
928
1140
  stores: {
929
1141
  user: userStore,
930
- project: projectStore,
931
- projectLocal: projectLocalStore,
932
1142
  },
1143
+ ...(options.referenceContext ? { referenceContext: options.referenceContext } : {}),
1144
+ ...(options.referenceEvidence ? { referenceEvidence: options.referenceEvidence } : {}),
933
1145
  };
934
1146
  }
1147
+ function ownStoreValue(values, key) {
1148
+ return Object.hasOwn(values, key) ? values[key] : undefined;
1149
+ }
1150
+ /** Check cross-field relations before saving one complete layer candidate. */
1151
+ export async function assertPluginConfigMutationCandidate(options) {
1152
+ const pluginId = options.sourceId ? `${options.sourceId}/${options.pluginName}` : options.pluginName;
1153
+ const preferences = await observePreferences(options);
1154
+ if (Object.keys(options.updates).length) {
1155
+ assertConfigLayerWritable(pluginId, options.manifest, preferences, options.platform);
1156
+ }
1157
+ const user = await readPluginConfigStore({ ...options, scope: 'user' });
1158
+ assertReadyPluginConfigStore(user);
1159
+ // Unsetting an unknown (stale) key has no effective profile to validate.
1160
+ const selectedFields = options.manifest.config ? selectPluginConfigProfile(options.manifest.config, options.platform).fields : {};
1161
+ if (!Object.keys(options.updates).length && options.removeKeys.every((key) => !Object.hasOwn(selectedFields, key)))
1162
+ return;
1163
+ const layers = resolveConfigurableLayers(pluginId, options.manifest, preferences);
1164
+ if (!layers.includes(options.platform ?? 'common'))
1165
+ return;
1166
+ const values = { ...user.values };
1167
+ for (const key of options.removeKeys)
1168
+ delete values[key];
1169
+ for (const [key, value] of Object.entries(options.updates))
1170
+ values[key] = value;
1171
+ const candidate = replacePluginConfigStoreLayer(user, values, options.platform);
1172
+ const profiles = options.platform ? [options.platform] : layers.map((layer) => layer === 'common' ? undefined : layer);
1173
+ for (const platform of profiles) {
1174
+ const references = pluginConfigHasExternalReferences(options.manifest)
1175
+ ? await resolvePluginConfigReferenceContext({ ...options, platform, plugins: options.referencePlugins }) : undefined;
1176
+ const resolve = (store) => resolveEffectivePluginConfigFromStores({ ...options, platform,
1177
+ targetScope: options.scope, projectRoot: options.scope === 'project' ? resolveAwProjectRoot(options.cwd) : '', stores: { user: store }, referenceContext: references?.context });
1178
+ const [before, after] = await Promise.all([resolve(user), resolve(candidate)]);
1179
+ const existing = new Set(before.issues.map((issue) => `${issue.key}\0${issue.code}\0${issue.message}`));
1180
+ const selectedSource = options.platform ? 'platform' : 'common';
1181
+ const issues = after.issues.filter((issue) => (Object.hasOwn(options.updates, issue.key) && after.sources[issue.key] === selectedSource)
1182
+ || !existing.has(`${issue.key}\0${issue.code}\0${issue.message}`));
1183
+ if (issues.length)
1184
+ throw Object.assign(new Error(`configReferenceInvalid: ${platform ?? 'common'}: ${issues.map((issue) => issue.message).join(' ')}`), { code: 'configReferenceInvalid' });
1185
+ }
1186
+ }
935
1187
  export async function coercePluginConfigUpdates(options) {
936
- const projectRoot = resolveAwProjectRoot(options.cwd);
937
1188
  const output = {};
938
1189
  for (const [key, value] of Object.entries(options.updates)) {
939
1190
  const field = options.schema[key];
940
1191
  if (!field) {
941
1192
  throw new Error(`Unknown config key "${key}".`);
942
1193
  }
943
- output[key] = await coercePluginConfigValue({
1194
+ const coerced = await coercePluginConfigValue({
944
1195
  key,
945
1196
  field,
946
1197
  value,
947
- projectRoot,
948
1198
  });
1199
+ output[key] = coerced;
949
1200
  }
950
1201
  return output;
951
1202
  }
952
- function createProjectArtifactBoundaryIssue(options) {
953
- if (options.reason === 'pathTypeDefault') {
954
- return {
955
- key: options.key,
956
- source: options.source,
957
- reason: options.reason,
958
- message: `Config "${options.key}" uses file/directory default value, ` +
959
- 'which cannot participate in repo-visible project artifact truth.',
960
- };
961
- }
962
- if (options.reason === 'pathTypeRequired') {
963
- return {
964
- key: options.key,
965
- source: options.source,
966
- reason: options.reason,
967
- message: `Config "${options.key}" is a required file/directory key, ` +
968
- 'which is not portable enough for repo-visible project artifacts.',
969
- };
970
- }
971
- if (options.reason === 'sharedPathValue') {
972
- return {
973
- key: options.key,
974
- source: options.source,
975
- reason: options.reason,
976
- message: `Config "${options.key}" is stored in project shared config as a file/directory path. ` +
977
- 'Use user or project local config for machine-local paths.',
978
- };
979
- }
980
- return {
981
- key: options.key,
982
- source: options.source,
983
- reason: options.reason,
984
- message: `Config "${options.key}" is declared as a refresh key for repo-visible project artifacts, ` +
985
- 'but file/directory config is machine-local and cannot drive shared artifact refresh.',
986
- };
987
- }
988
- export function collectProjectArtifactConfigBoundaryIssues(options) {
989
- const issues = [];
990
- const refreshKeySet = new Set(options.refreshKeys ?? []);
991
- for (const [key, field] of Object.entries(options.schema)) {
992
- if (!isPathTypeField(field)) {
993
- continue;
994
- }
995
- if (field.default !== undefined) {
996
- issues.push(createProjectArtifactBoundaryIssue({
997
- key,
998
- source: 'default',
999
- reason: 'pathTypeDefault',
1000
- }));
1001
- }
1002
- if (field.required) {
1003
- issues.push(createProjectArtifactBoundaryIssue({
1004
- key,
1005
- source: 'missing',
1006
- reason: 'pathTypeRequired',
1007
- }));
1008
- }
1009
- if (options.sharedEntries && Object.hasOwn(options.sharedEntries, key)) {
1010
- issues.push(createProjectArtifactBoundaryIssue({
1011
- key,
1012
- source: 'project',
1013
- reason: 'sharedPathValue',
1014
- }));
1015
- }
1016
- if (refreshKeySet.has(key)) {
1017
- issues.push(createProjectArtifactBoundaryIssue({
1018
- key,
1019
- source: 'project',
1020
- reason: 'pathTypeRefreshKey',
1021
- }));
1022
- }
1023
- }
1024
- return issues;
1025
- }
1026
1203
  export async function resolveProjectArtifactRenderConfig(options) {
1027
- const pluginName = assertSafePluginConfigSegment(options.pluginName ?? options.manifest.name);
1028
- const schema = options.manifest.config?.schema;
1029
- const projectRoot = resolveAwProjectRoot(options.cwd);
1030
- const [userStore, projectStore, projectLocalStore] = await Promise.all([
1031
- readPluginConfigStore({
1032
- sourceId: options.sourceId,
1033
- sourceIdentity: options.sourceIdentity,
1034
- pluginName,
1035
- scope: 'user',
1036
- cwd: options.cwd,
1037
- env: options.env,
1038
- }),
1039
- readPluginConfigStore({
1040
- sourceId: options.sourceId,
1041
- sourceIdentity: options.sourceIdentity,
1042
- pluginName,
1043
- scope: 'project',
1044
- cwd: options.cwd,
1045
- env: options.env,
1046
- }),
1047
- readPluginConfigStore({
1048
- sourceId: options.sourceId,
1049
- sourceIdentity: options.sourceIdentity,
1050
- pluginName,
1051
- scope: 'project',
1052
- cwd: options.cwd,
1053
- env: options.env,
1054
- projectLayer: 'local',
1055
- }),
1056
- ]);
1057
- if (!schema) {
1204
+ if (!options.manifest.config?.fields) {
1205
+ const pluginName = assertSafePluginConfigSegment(options.pluginName ?? options.manifest.name);
1206
+ const [userStore] = await Promise.all([
1207
+ readPluginConfigStore({
1208
+ sourceId: options.sourceId,
1209
+ sourceIdentity: options.sourceIdentity,
1210
+ logicalIdentity: options.logicalIdentity,
1211
+ pluginName,
1212
+ scope: 'user',
1213
+ cwd: options.cwd,
1214
+ env: options.env,
1215
+ }),
1216
+ ]);
1217
+ assertReadyPluginConfigStore(userStore);
1058
1218
  return {
1059
1219
  pluginName,
1060
- projectRoot,
1220
+ projectRoot: resolveAwProjectRoot(options.cwd),
1061
1221
  values: {},
1062
1222
  sources: {},
1063
1223
  issues: [],
1224
+ unsupportedLayerOverrides: [],
1064
1225
  ignoredUnknownKeys: [],
1065
- boundaryIssues: [],
1066
1226
  schema: {},
1067
- stores: {
1068
- user: userStore,
1069
- project: projectStore,
1070
- projectLocal: projectLocalStore,
1071
- },
1227
+ stores: { user: userStore },
1072
1228
  };
1073
1229
  }
1074
- const values = {};
1075
- const sources = {};
1076
- const invalidIssues = new Map();
1077
- const ignoredUnknownKeys = [];
1078
- const schemaKeys = new Set(Object.keys(schema));
1079
- const boundaryIssues = collectProjectArtifactConfigBoundaryIssues({
1080
- schema,
1081
- sharedEntries: projectStore.values,
1082
- refreshKeys: options.refreshKeys,
1083
- });
1084
- for (const key of Object.keys(schema)) {
1085
- sources[key] = 'missing';
1086
- }
1087
- const projectPlainEntries = getStoreEntries(projectStore.values);
1088
- const userPlainEntries = getStoreEntries(userStore.values);
1089
- const projectLocalPlainEntries = getStoreEntries(projectLocalStore.values);
1090
- for (const key of Object.keys(projectPlainEntries)) {
1091
- if (!schemaKeys.has(key)) {
1092
- ignoredUnknownKeys.push({ scope: 'project', projectLayer: 'shared', source: 'project', key });
1093
- }
1094
- }
1095
- for (const key of Object.keys(userPlainEntries)) {
1096
- if (!schemaKeys.has(key)) {
1097
- ignoredUnknownKeys.push({ scope: 'user', projectLayer: 'shared', source: 'user', key });
1098
- }
1099
- }
1100
- for (const key of Object.keys(projectLocalPlainEntries)) {
1101
- if (!schemaKeys.has(key)) {
1102
- ignoredUnknownKeys.push({ scope: 'project', projectLayer: 'local', source: 'projectLocal', key });
1103
- }
1104
- }
1105
- for (const [key, field] of Object.entries(schema)) {
1106
- if (!isPathTypeField(field) && field.default !== undefined) {
1107
- await applyConfigLayer({
1108
- values,
1109
- redactedValues: {},
1110
- sources,
1111
- invalidIssues,
1112
- schema: { [key]: field },
1113
- entries: { [key]: field.default },
1114
- source: 'default',
1115
- projectRoot,
1116
- });
1117
- }
1118
- }
1119
- const sharedSchema = Object.fromEntries(Object.entries(schema).filter(([, field]) => !isPathTypeField(field)));
1120
- await applyConfigLayer({
1121
- values,
1122
- redactedValues: {},
1123
- sources,
1124
- invalidIssues,
1125
- schema: sharedSchema,
1126
- entries: projectPlainEntries,
1127
- source: 'project',
1128
- projectRoot,
1230
+ const effective = await resolveEffectivePluginConfig({
1231
+ ...options,
1232
+ targetScope: 'project',
1129
1233
  });
1130
- const issues = [
1131
- ...invalidIssues.values(),
1132
- ...boundaryIssues.map((issue) => ({
1133
- type: 'invalid-config',
1134
- key: issue.key,
1135
- source: issue.source,
1136
- message: issue.message,
1137
- })),
1138
- ];
1139
- for (const [key, field] of Object.entries(schema)) {
1140
- if (isPathTypeField(field)) {
1141
- continue;
1142
- }
1143
- if (field.required && values[key] === undefined) {
1144
- issues.push({
1145
- type: 'missing-required',
1146
- key,
1147
- source: sources[key],
1148
- message: `Config "${key}" is required.`,
1149
- });
1150
- }
1151
- }
1152
- return {
1153
- pluginName,
1154
- projectRoot,
1155
- values,
1156
- sources,
1157
- issues,
1158
- ignoredUnknownKeys,
1159
- boundaryIssues,
1160
- schema,
1161
- stores: {
1162
- user: userStore,
1163
- project: projectStore,
1164
- projectLocal: projectLocalStore,
1165
- },
1166
- };
1167
- }
1168
- export async function resolveProjectLocalPluginConfigView(options) {
1169
- const effective = await resolveEffectivePluginConfig(options);
1170
- const artifactConfig = await resolveProjectArtifactRenderConfig(options);
1171
- const values = {};
1172
- const redactedValues = {};
1173
- const sources = {};
1174
- const issues = [];
1175
- for (const [key, field] of Object.entries(effective.schema)) {
1176
- sources[key] = 'missing';
1177
- const localPlainEntries = getStoreEntries(effective.stores.projectLocal.values);
1178
- if (!Object.hasOwn(localPlainEntries, key)) {
1179
- continue;
1180
- }
1181
- sources[key] = 'projectLocal';
1182
- try {
1183
- const coerced = await coercePluginConfigValue({
1184
- key,
1185
- field,
1186
- value: localPlainEntries[key],
1187
- projectRoot: effective.projectRoot,
1188
- });
1189
- values[key] = coerced;
1190
- redactedValues[key] = redactValue(field, coerced);
1191
- }
1192
- catch (error) {
1193
- issues.push({
1194
- type: 'invalid-config',
1195
- key,
1196
- source: 'projectLocal',
1197
- message: error instanceof Error ? error.message : String(error),
1198
- });
1199
- }
1200
- }
1201
1234
  return {
1202
1235
  pluginName: effective.pluginName,
1203
1236
  projectRoot: effective.projectRoot,
1204
- schema: effective.schema,
1205
- localStore: effective.stores.projectLocal,
1206
- values,
1207
- redactedValues,
1208
- sources,
1209
- issues,
1210
- ignoredUnknownKeys: effective.ignoredUnknownKeys.filter((entry) => entry.source === 'projectLocal'),
1211
- repoVisibleArtifactConfig: {
1212
- values: artifactConfig.values,
1213
- sources: artifactConfig.sources,
1214
- issues: artifactConfig.issues,
1215
- boundaryIssues: artifactConfig.boundaryIssues,
1216
- },
1217
- };
1218
- }
1219
- async function resolveRedactedLayerValue(options) {
1220
- try {
1221
- const coerced = await coercePluginConfigValue({
1222
- key: options.key,
1223
- field: options.field,
1224
- value: options.value,
1225
- projectRoot: options.projectRoot,
1226
- });
1227
- return {
1228
- value: redactValue(options.field, coerced),
1229
- };
1230
- }
1231
- catch (error) {
1232
- return {
1233
- issue: {
1234
- type: 'invalid-config',
1235
- key: options.key,
1236
- source: options.source,
1237
- message: error instanceof Error ? error.message : String(error),
1238
- },
1239
- };
1240
- }
1241
- }
1242
- export async function resolveProjectScopedPluginConfigView(options) {
1243
- const effective = await resolveEffectivePluginConfig(options);
1244
- const artifactConfig = await resolveProjectArtifactRenderConfig(options);
1245
- const entries = {};
1246
- for (const [key, field] of Object.entries(effective.schema)) {
1247
- const entry = {
1248
- key,
1249
- effectiveValue: effective.redactedValues[key],
1250
- effectiveSource: effective.sources[key] ?? 'missing',
1251
- repoVisibleArtifactValue: artifactConfig.values[key] === undefined
1252
- ? undefined
1253
- : redactValue(field, artifactConfig.values[key]),
1254
- repoVisibleArtifactSource: artifactConfig.sources[key] ?? 'missing',
1255
- repoVisibleArtifactUsesSharedTruth: true,
1256
- };
1257
- if (field.default !== undefined) {
1258
- const resolvedDefault = await resolveRedactedLayerValue({
1259
- key,
1260
- field,
1261
- projectRoot: effective.projectRoot,
1262
- source: 'default',
1263
- value: field.default,
1264
- });
1265
- if (resolvedDefault.value !== undefined) {
1266
- entry.defaultValue = resolvedDefault.value;
1267
- }
1268
- }
1269
- const userPlainEntries = getStoreEntries(effective.stores.user.values);
1270
- if (Object.hasOwn(userPlainEntries, key)) {
1271
- const resolvedUser = await resolveRedactedLayerValue({
1272
- key,
1273
- field,
1274
- projectRoot: effective.projectRoot,
1275
- source: 'user',
1276
- value: userPlainEntries[key],
1277
- });
1278
- if (resolvedUser.value !== undefined) {
1279
- entry.userValue = resolvedUser.value;
1280
- }
1281
- }
1282
- const projectPlainEntries = getStoreEntries(effective.stores.project.values);
1283
- if (Object.hasOwn(projectPlainEntries, key)) {
1284
- const resolvedProject = await resolveRedactedLayerValue({
1285
- key,
1286
- field,
1287
- projectRoot: effective.projectRoot,
1288
- source: 'project',
1289
- value: projectPlainEntries[key],
1290
- });
1291
- if (resolvedProject.value !== undefined) {
1292
- entry.projectSharedValue = resolvedProject.value;
1293
- }
1294
- }
1295
- const localPlainEntries = getStoreEntries(effective.stores.projectLocal.values);
1296
- if (Object.hasOwn(localPlainEntries, key)) {
1297
- const resolvedLocal = await resolveRedactedLayerValue({
1298
- key,
1299
- field,
1300
- projectRoot: effective.projectRoot,
1301
- source: 'projectLocal',
1302
- value: localPlainEntries[key],
1303
- });
1304
- if (resolvedLocal.value !== undefined) {
1305
- entry.projectLocalValue = resolvedLocal.value;
1306
- }
1307
- }
1308
- entries[key] = entry;
1309
- }
1310
- return {
1311
- pluginName: effective.pluginName,
1312
- projectRoot: effective.projectRoot,
1313
- schema: effective.schema,
1314
- stores: effective.stores,
1315
- redactedValues: effective.redactedValues,
1237
+ values: effective.values,
1316
1238
  sources: effective.sources,
1317
- entries,
1318
1239
  issues: effective.issues,
1240
+ unsupportedLayerOverrides: effective.unsupportedLayerOverrides,
1319
1241
  ignoredUnknownKeys: effective.ignoredUnknownKeys,
1320
- repoVisibleArtifactConfig: {
1321
- values: artifactConfig.values,
1322
- sources: artifactConfig.sources,
1323
- issues: artifactConfig.issues,
1324
- boundaryIssues: artifactConfig.boundaryIssues,
1242
+ schema: effective.schema,
1243
+ stores: {
1244
+ user: effective.stores.user,
1325
1245
  },
1326
1246
  };
1327
1247
  }
1328
1248
  function toConfigSourceLayer(source) {
1329
- if (source === 'default') {
1330
- return 'default';
1331
- }
1332
- if (source === 'user') {
1333
- return 'user';
1334
- }
1335
- if (source === 'project') {
1336
- return 'project';
1337
- }
1338
- if (source === 'projectLocal') {
1339
- return 'local';
1340
- }
1341
- return null;
1249
+ return source === undefined || source === 'missing' ? null : source;
1250
+ }
1251
+ function configFieldProjection(options) {
1252
+ const source = options.source ?? 'missing';
1253
+ const issues = options.issues ?? [];
1254
+ const presetSensitive = options.field.sensitive === true
1255
+ || (options.field.type === 'object'
1256
+ && (Object.values(options.field.properties ?? {}).some((child) => child.sensitive === true)
1257
+ || (options.field.additionalProperties !== false
1258
+ && options.field.additionalProperties?.sensitive === true)));
1259
+ return {
1260
+ value: options.value === undefined ? null : redactValue(options.field, options.value),
1261
+ source,
1262
+ matchedPreset: options.value === undefined || presetSensitive
1263
+ ? null
1264
+ : matchPluginConfigPreset(options.field, options.value)?.id ?? null,
1265
+ valid: issues.length === 0,
1266
+ issues,
1267
+ };
1342
1268
  }
1343
1269
  async function buildManifestFieldEntries(options) {
1344
- const schema = options.plugin.manifest.config?.schema;
1345
- if (!schema) {
1346
- return [];
1347
- }
1348
- const projectRoot = resolveAwProjectRoot(options.cwd);
1349
- const [userStore, projectStore, projectLocalStore] = await Promise.all([
1350
- readPluginConfigStore({
1351
- sourceId: options.plugin.sourceId,
1352
- sourceIdentity: options.plugin.sourceIdentity,
1353
- pluginName: options.plugin.manifest.name,
1354
- scope: 'user',
1355
- cwd: options.cwd,
1356
- env: options.env,
1357
- }),
1358
- readPluginConfigStore({
1359
- sourceId: options.plugin.sourceId,
1360
- sourceIdentity: options.plugin.sourceIdentity,
1361
- pluginName: options.plugin.manifest.name,
1362
- scope: 'project',
1363
- projectLayer: 'shared',
1364
- cwd: options.cwd,
1365
- env: options.env,
1366
- }),
1367
- readPluginConfigStore({
1368
- sourceId: options.plugin.sourceId,
1369
- sourceIdentity: options.plugin.sourceIdentity,
1370
- pluginName: options.plugin.manifest.name,
1371
- scope: 'project',
1372
- projectLayer: 'local',
1373
- cwd: options.cwd,
1374
- env: options.env,
1375
- }),
1376
- ]);
1377
- const userPlainEntries = getStoreEntries(userStore.values);
1378
- const projectPlainEntries = getStoreEntries(projectStore.values);
1379
- const localPlainEntries = getStoreEntries(projectLocalStore.values);
1380
1270
  const effective = await resolveEffectivePluginConfig({
1381
1271
  sourceId: options.plugin.sourceId,
1382
1272
  sourceIdentity: options.plugin.sourceIdentity,
1383
- pluginName: options.plugin.manifest.name,
1273
+ logicalIdentity: options.plugin.catalogLogicalIdentity,
1384
1274
  manifest: options.plugin.manifest,
1275
+ platform: options.platform,
1276
+ targetScope: options.context ?? (options.scope === 'project' ? 'project' : 'user'),
1385
1277
  cwd: options.cwd,
1386
1278
  env: options.env,
1387
1279
  });
1388
- const effectiveFieldState = (key) => {
1389
- const field = schema[key];
1390
- const source = effective.sources[key];
1391
- const sourceLayer = toConfigSourceLayer(source);
1392
- if (source === undefined || source === 'missing') {
1393
- return { valueState: 'default', effectiveValue: null, sourceLayer: null };
1280
+ const stored = pluginConfigStoreForProfile(effective.stores.user, options.platform).values;
1281
+ const fields = await Promise.all(Object.entries(effective.schema).map(async ([key, field]) => {
1282
+ const state = effective.fieldStates[key];
1283
+ const source = effective.sources[key] ?? 'missing';
1284
+ const issues = effective.issues.filter((issue) => issue.key === key);
1285
+ const hasStored = Object.hasOwn(stored, key);
1286
+ const storedSourceLayer = options.platform ? 'platform' : 'common';
1287
+ let fallback;
1288
+ if (hasStored) {
1289
+ const inherited = { ...stored };
1290
+ delete inherited[key];
1291
+ const withoutOverride = await resolveEffectivePluginConfigFromStores({
1292
+ manifest: options.plugin.manifest,
1293
+ platform: options.platform,
1294
+ projectRoot: effective.projectRoot,
1295
+ stores: { user: replacePluginConfigStoreLayer(effective.stores.user, inherited, options.platform) },
1296
+ referenceContext: effective.referenceContext,
1297
+ });
1298
+ const fallbackIssues = withoutOverride.issues.filter((issue) => issue.key === key);
1299
+ const fallbackSource = withoutOverride.sources[key];
1300
+ fallback = fallbackSource === 'missing' || fallbackSource === undefined
1301
+ ? { state: 'missing' }
1302
+ : fallbackIssues.length
1303
+ ? { state: 'invalid', sourceLayer: fallbackSource, issues: fallbackIssues }
1304
+ : { state: 'valid', sourceLayer: fallbackSource, effectiveValue: withoutOverride.redactedValues[key] };
1394
1305
  }
1395
- const issue = effective.issues.find((entry) => entry.key === key && entry.source === source);
1396
1306
  return {
1397
- valueState: issue ? 'invalid' : source === 'default' ? 'default' : 'configured',
1398
- effectiveValue: issue
1399
- ? null
1400
- : isPathTypeField(field) && effective.redactedValues[key] !== undefined
1401
- ? '[redacted]'
1402
- : effective.redactedValues[key] ?? null,
1403
- sourceLayer,
1404
- };
1405
- };
1406
- const fields = [];
1407
- for (const [key, field] of Object.entries(schema)) {
1408
- const base = {
1409
1307
  key,
1410
1308
  title: field.title ?? key,
1411
1309
  kind: 'manifest',
1412
1310
  reserved: false,
1413
1311
  writable: true,
1414
- valueState: 'default',
1415
- effectiveValue: null,
1416
- sourceLayer: null,
1312
+ canSet: true,
1313
+ canUnset: hasStored,
1314
+ valueState: issues.length ? 'invalid' : source === 'default' || source === 'missing' ? 'default' : 'configured',
1315
+ effectiveValue: effective.redactedValues[key] ?? null,
1316
+ sourceLayer: toConfigSourceLayer(source),
1317
+ ...(hasStored ? { storedSourceLayer, ...(validateCorePluginConfigValue(field, stored[key], key).length
1318
+ ? {} : { storedValue: redactValue(field, stored[key]) }) } : {}),
1319
+ ...(state?.invalidOverride ? { invalidOverride: { sourceLayer: state.invalidOverride.source, issues: state.invalidOverride.issues } } : {}),
1320
+ ...(fallback ? { fallback } : {}),
1321
+ ...configFieldProjection({ field, value: effective.values[key], source, issues }),
1417
1322
  };
1418
- if (options.scope === 'user') {
1419
- if (Object.hasOwn(userPlainEntries, key)) {
1420
- try {
1421
- const value = await coercePluginConfigValue({
1422
- key,
1423
- field,
1424
- value: userPlainEntries[key],
1425
- projectRoot,
1426
- });
1427
- fields.push({
1428
- ...base,
1429
- valueState: 'configured',
1430
- effectiveValue: isPathTypeField(field) ? '[redacted]' : redactValue(field, value),
1431
- sourceLayer: 'user',
1432
- storedValue: isPathTypeField(field) ? '[redacted]' : redactValue(field, value),
1433
- storedSourceLayer: 'user',
1434
- });
1435
- }
1436
- catch {
1437
- fields.push({
1438
- ...base,
1439
- valueState: 'invalid',
1440
- sourceLayer: 'user',
1441
- storedSourceLayer: 'user',
1442
- });
1443
- }
1444
- continue;
1445
- }
1446
- if (field.default !== undefined) {
1447
- try {
1448
- const value = await coercePluginConfigValue({
1449
- key,
1450
- field,
1451
- value: field.default,
1452
- projectRoot,
1453
- });
1454
- fields.push({
1455
- ...base,
1456
- effectiveValue: isPathTypeField(field) ? '[redacted]' : redactValue(field, value),
1457
- sourceLayer: 'default',
1458
- });
1459
- }
1460
- catch {
1461
- fields.push({
1462
- ...base,
1463
- valueState: 'invalid',
1464
- sourceLayer: 'default',
1465
- });
1466
- }
1467
- continue;
1468
- }
1469
- fields.push(base);
1470
- continue;
1471
- }
1472
- if (options.projectLayer === 'local') {
1473
- if (Object.hasOwn(localPlainEntries, key)) {
1474
- try {
1475
- const value = await coercePluginConfigValue({
1476
- key,
1477
- field,
1478
- value: localPlainEntries[key],
1479
- projectRoot,
1480
- });
1481
- fields.push({
1482
- ...base,
1483
- valueState: 'configured',
1484
- effectiveValue: isPathTypeField(field) ? '[redacted]' : redactValue(field, value),
1485
- sourceLayer: 'local',
1486
- storedValue: isPathTypeField(field) ? '[redacted]' : redactValue(field, value),
1487
- storedSourceLayer: 'local',
1488
- });
1489
- }
1490
- catch {
1491
- fields.push({
1492
- ...base,
1493
- valueState: 'invalid',
1494
- sourceLayer: 'local',
1495
- storedSourceLayer: 'local',
1496
- });
1497
- }
1498
- }
1499
- else {
1500
- fields.push(base);
1501
- }
1502
- continue;
1503
- }
1504
- let storedProjectValue;
1505
- if (options.scope === 'project' && Object.hasOwn(projectPlainEntries, key)) {
1506
- try {
1507
- const value = await coercePluginConfigValue({
1508
- key,
1509
- field,
1510
- value: projectPlainEntries[key],
1511
- projectRoot,
1512
- });
1513
- storedProjectValue = {
1514
- storedValue: isPathTypeField(field) ? '[redacted]' : redactValue(field, value),
1515
- storedSourceLayer: 'project',
1516
- };
1517
- }
1518
- catch {
1519
- storedProjectValue = { storedSourceLayer: 'project' };
1520
- }
1521
- }
1522
- fields.push({ ...base, ...effectiveFieldState(key), ...storedProjectValue });
1323
+ }));
1324
+ for (const key of Object.keys(stored).filter((key) => !Object.hasOwn(effective.schema, key)).sort()) {
1325
+ const source = options.platform ? 'platform' : 'common';
1326
+ fields.push({ key, title: key, kind: 'manifest', reserved: false, writable: false, canSet: false, canUnset: true,
1327
+ valueState: 'configured', effectiveValue: '[redacted]', sourceLayer: source, storedSourceLayer: source,
1328
+ value: '[redacted]', source, matchedPreset: null, valid: false, issues: [] });
1523
1329
  }
1524
1330
  return fields;
1525
1331
  }
1526
1332
  async function buildLegacyStoreFieldEntries(options) {
1527
- const locations = options.scope === 'effective'
1528
- ? [
1529
- { scope: 'user', projectLayer: 'shared', sourceLayer: 'user' },
1530
- { scope: 'project', projectLayer: 'shared', sourceLayer: 'project' },
1531
- { scope: 'project', projectLayer: 'local', sourceLayer: 'local' },
1532
- ]
1533
- : [{
1534
- scope: options.scope,
1535
- projectLayer: options.projectLayer,
1536
- sourceLayer: options.scope === 'user'
1537
- ? 'user'
1538
- : options.projectLayer === 'local' ? 'local' : 'project',
1539
- }];
1540
- const fields = new Map();
1541
- for (const location of locations) {
1542
- const store = await readPluginConfigStore({
1543
- sourceId: options.sourceId,
1544
- sourceIdentity: options.sourceIdentity,
1545
- pluginName: options.pluginName,
1546
- scope: location.scope,
1547
- ...(location.scope === 'project' ? { projectLayer: location.projectLayer } : {}),
1548
- cwd: options.cwd,
1549
- env: options.env,
1550
- });
1551
- for (const key of Object.keys(store.values)) {
1552
- fields.set(key, {
1553
- key,
1554
- title: key,
1555
- kind: 'manifest',
1556
- reserved: false,
1557
- writable: false,
1558
- valueState: 'configured',
1559
- effectiveValue: '[redacted]',
1560
- sourceLayer: location.sourceLayer,
1561
- });
1562
- }
1563
- }
1564
- return [...fields.values()].sort((left, right) => left.key.localeCompare(right.key));
1333
+ const store = await readPluginConfigStore({ ...options, scope: 'user' });
1334
+ const source = options.platform ? 'platform' : 'common';
1335
+ return Object.keys(store.values).sort().map((key) => ({ key, title: key, kind: 'manifest', reserved: false,
1336
+ writable: false, canSet: false, canUnset: true, valueState: 'configured', effectiveValue: '[redacted]',
1337
+ sourceLayer: source, value: '[redacted]', source, matchedPreset: null, valid: true, issues: [] }));
1565
1338
  }
1566
1339
  export async function resolvePluginConfigSchemaAccess(options) {
1567
1340
  const pluginName = assertSafePluginConfigSegment(options.pluginName);
@@ -1577,42 +1350,50 @@ export async function resolvePluginConfigSchemaAccess(options) {
1577
1350
  return {
1578
1351
  pluginName,
1579
1352
  plugin: options.currentPlugin,
1580
- schema: createConfigSchemaEvidenceFromCurrentCatalog(options.currentPlugin, await calculateConfigSchemaManifestDigestForPlugin(options.currentPlugin)),
1353
+ schema: createConfigSchemaEvidenceFromCurrentCatalog(options.currentPlugin, await calculateConfigSchemaManifestDigestForPlugin(options.currentPlugin), options.platform),
1581
1354
  };
1582
1355
  }
1583
1356
  export async function resolveConfigRead(options) {
1357
+ if (options.context)
1358
+ await resolveWorkContext({ cwd: options.cwd, context: options.context });
1584
1359
  const pluginName = assertSafePluginConfigSegment(options.pluginName);
1585
1360
  const schemaAccess = await resolvePluginConfigSchemaAccess({
1586
1361
  pluginName,
1587
1362
  currentPlugin: options.plugin,
1588
1363
  currentPluginError: options.pluginError,
1364
+ platform: options.platform,
1589
1365
  scope: options.scope,
1590
- projectLayer: options.projectLayer,
1591
1366
  cwd: options.cwd,
1592
1367
  env: options.env,
1593
1368
  });
1594
- const manifestFields = schemaAccess.plugin
1369
+ const manifestFields = options.schemaOnly ? [] : schemaAccess.plugin?.manifest.config
1595
1370
  ? await buildManifestFieldEntries({
1596
1371
  plugin: schemaAccess.plugin,
1372
+ context: options.context,
1373
+ platform: options.platform,
1597
1374
  scope: options.scope,
1598
- projectLayer: options.projectLayer,
1599
1375
  cwd: options.cwd,
1600
1376
  env: options.env,
1601
1377
  })
1602
1378
  : await buildLegacyStoreFieldEntries({
1603
- sourceId: options.sourceId,
1604
- sourceIdentity: options.sourceIdentity,
1379
+ sourceId: schemaAccess.plugin?.sourceId ?? options.sourceId,
1380
+ sourceIdentity: schemaAccess.plugin?.sourceIdentity ?? options.sourceIdentity,
1381
+ logicalIdentity: schemaAccess.plugin?.catalogLogicalIdentity ?? options.logicalIdentity,
1605
1382
  pluginName,
1606
1383
  scope: options.scope,
1607
- projectLayer: options.projectLayer,
1384
+ platform: options.platform,
1608
1385
  cwd: options.cwd,
1609
1386
  env: options.env,
1610
1387
  });
1611
1388
  return {
1612
1389
  pluginName,
1390
+ platform: options.platform,
1391
+ context: options.context ?? 'user',
1613
1392
  scope: options.scope,
1614
- projectLayer: options.projectLayer,
1615
1393
  ...(schemaAccess.schema ? { schema: schemaAccess.schema } : {}),
1394
+ ...(schemaAccess.plugin?.manifest.config?.fields
1395
+ ? { fieldDefinitions: selectPluginConfigProfile(schemaAccess.plugin.manifest.config, options.platform).fields }
1396
+ : {}),
1616
1397
  fields: manifestFields,
1617
1398
  };
1618
1399
  }
@@ -1626,67 +1407,100 @@ export function summarizeEffectivePluginConfig(config) {
1626
1407
  return {
1627
1408
  values: config.redactedValues,
1628
1409
  sources: config.sources,
1410
+ fieldStates: Object.fromEntries(Object.entries(config.fieldStates).map(([key, state]) => [key, {
1411
+ ...(state.effective ? {
1412
+ effective: { value: state.effective.redactedValue, source: state.effective.source },
1413
+ } : {}),
1414
+ ...(state.invalidOverride ? { invalidOverride: state.invalidOverride } : {}),
1415
+ ...(state.fallback ? {
1416
+ fallback: { value: state.fallback.redactedValue, source: state.fallback.source },
1417
+ } : {}),
1418
+ }])),
1629
1419
  issues: config.issues,
1630
1420
  ignoredUnknownKeys: config.ignoredUnknownKeys,
1631
1421
  };
1632
1422
  }
1633
- export function createPluginConfigSchemaIdentity(manifest) {
1423
+ export function createPluginConfigSchemaIdentity(manifest, platform) {
1634
1424
  const hash = crypto
1635
1425
  .createHash('sha256')
1636
1426
  .update(JSON.stringify({
1637
1427
  name: manifest.name,
1638
1428
  version: manifest.version,
1639
- config: manifest.config ?? null,
1429
+ platform: platform ?? null,
1430
+ config: manifest.config ? selectPluginConfigProfile(manifest.config, platform) : null,
1640
1431
  }))
1641
1432
  .digest('hex');
1642
1433
  return `${manifest.name}:${hash}`;
1643
1434
  }
1435
+ function cliConfigPromptEnumValues(field) {
1436
+ if (!field.choices)
1437
+ return undefined;
1438
+ const values = field.choices.presets
1439
+ .map((preset) => preset.value);
1440
+ if (field.type !== 'boolean') {
1441
+ return field.choices.allowCustom ? undefined : values;
1442
+ }
1443
+ if (field.choices.allowCustom) {
1444
+ for (const value of [true, false]) {
1445
+ if (!values.includes(value))
1446
+ values.push(value);
1447
+ }
1448
+ }
1449
+ return values;
1450
+ }
1644
1451
  export function toCliConfigPromptSchema(schema) {
1645
1452
  const promptSchema = {};
1646
1453
  for (const [key, field] of Object.entries(schema)) {
1454
+ if (field.type === 'object' || field.type === 'array')
1455
+ continue;
1647
1456
  promptSchema[key] = {
1648
- type: field.type === 'enum' ? 'string' : field.type,
1457
+ type: field.type,
1649
1458
  label: field.title ?? key,
1650
1459
  description: field.description,
1651
1460
  required: field.required,
1652
1461
  sensitive: field.sensitive,
1653
1462
  default: field.default,
1654
- enum: field.type === 'enum' ? field.values : undefined,
1655
- min: field.min,
1656
- max: field.max,
1463
+ enum: cliConfigPromptEnumValues(field),
1464
+ min: field.type === 'number' ? field.validation?.minimum : undefined,
1465
+ max: field.type === 'number' ? field.validation?.maximum : undefined,
1657
1466
  };
1658
1467
  }
1659
1468
  return promptSchema;
1660
1469
  }
1661
1470
  export function createPluginConfigFormModel(options) {
1662
- const schema = options.manifest.config?.schema;
1471
+ const schema = options.effective.schema;
1663
1472
  if (!schema) {
1664
- throw new Error(`Plugin "${options.pluginName ?? options.manifest.name}" does not declare an AW config schema.`);
1473
+ throw new PluginConfigSchemaResolutionError('configSchemaUnavailable', `Plugin "${options.pluginName ?? options.manifest.name}" does not declare an AW config schema.`);
1665
1474
  }
1666
1475
  const requiredKeys = [...new Set(options.effective.issues
1667
1476
  .filter((issue) => issue.type === 'missing-required' || issue.type === 'invalid-config')
1668
1477
  .map((issue) => issue.key))];
1478
+ const fields = Object.entries(schema).flatMap(([key, field]) => {
1479
+ if (field.type === 'object' || field.type === 'array')
1480
+ return [];
1481
+ return [{
1482
+ key,
1483
+ type: field.type,
1484
+ label: field.title ?? key,
1485
+ description: field.description,
1486
+ required: field.required === true,
1487
+ sensitive: field.sensitive === true,
1488
+ defaultValue: field.default,
1489
+ enumValues: cliConfigPromptEnumValues(field),
1490
+ min: field.type === 'number' ? field.validation?.minimum : undefined,
1491
+ max: field.type === 'number' ? field.validation?.maximum : undefined,
1492
+ configured: options.effective.values[key] !== undefined,
1493
+ currentValue: field.sensitive
1494
+ ? undefined
1495
+ : options.effective.values[key],
1496
+ }];
1497
+ });
1669
1498
  return {
1670
1499
  pluginName: options.pluginName ?? options.manifest.name,
1671
- allowedScopes: options.allowedScopes ?? ['user', 'project'],
1672
- initialScope: options.initialScope,
1500
+ allowedScopes: ['user'],
1501
+ initialScope: 'user',
1673
1502
  requiredKeys,
1674
- fields: Object.entries(schema).map(([key, field]) => ({
1675
- key,
1676
- type: field.type,
1677
- label: field.title ?? key,
1678
- description: field.description,
1679
- required: field.required === true,
1680
- sensitive: field.sensitive === true,
1681
- defaultValue: field.default,
1682
- enumValues: field.type === 'enum' ? field.values : undefined,
1683
- min: field.min,
1684
- max: field.max,
1685
- configured: options.effective.values[key] !== undefined,
1686
- currentValue: field.sensitive || isPathTypeField(field)
1687
- ? undefined
1688
- : options.effective.values[key],
1689
- })),
1503
+ fields,
1690
1504
  };
1691
1505
  }
1692
1506
  export function toCliConfigPromptOptions(model) {
@@ -1705,7 +1519,7 @@ export function toCliConfigPromptOptions(model) {
1705
1519
  schema: Object.fromEntries(model.fields.map((field) => [
1706
1520
  field.key,
1707
1521
  {
1708
- type: field.type === 'enum' ? 'string' : field.type,
1522
+ type: field.type,
1709
1523
  label: field.label,
1710
1524
  description: field.description,
1711
1525
  required: field.required,
@@ -1723,13 +1537,17 @@ export function toCliConfigPromptOptions(model) {
1723
1537
  requiredKeys: [...model.requiredKeys],
1724
1538
  };
1725
1539
  }
1726
- function formatRequiredConfigSetCommands(pluginName, issues, defaultScope) {
1540
+ export function formatPluginConfigSetRecoveryCommand(pluginName, key, field, context, platform) {
1541
+ const command = `aw plugin config set ${pluginName} ${key} --context ${context}`
1542
+ + (platform ? ` --platform ${platform}` : '');
1543
+ return field.sensitive === true ? `${command} --value-stdin` : `${command} --value-json '<json>'`;
1544
+ }
1545
+ function formatRequiredConfigSetCommands(pluginName, issues, context, schema, platform) {
1727
1546
  const commands = new Set();
1728
1547
  for (const issue of issues) {
1729
- const scope = issue.source === 'user' || issue.source === 'project'
1730
- ? issue.source
1731
- : defaultScope;
1732
- commands.add(`aw config set ${pluginName} ${issue.key} <value> -s ${scope}`);
1548
+ const field = schema[issue.key];
1549
+ if (field)
1550
+ commands.add(formatPluginConfigSetRecoveryCommand(pluginName, issue.key, field, context, platform));
1733
1551
  }
1734
1552
  return [...commands].map((command) => `\`${command}\``).join(' 或 ');
1735
1553
  }
@@ -1742,21 +1560,23 @@ export async function preflightRequiredPluginConfigs(options) {
1742
1560
  };
1743
1561
  for (const target of options.targets) {
1744
1562
  const pluginName = target.pluginName ?? target.manifest.name;
1745
- const identity = target.schemaSourceIdentity ?? createPluginConfigSchemaIdentity(target.manifest);
1746
- const dedupeKey = `${pluginName}\0${identity}`;
1563
+ const identity = target.schemaSourceIdentity ?? createPluginConfigSchemaIdentity(target.manifest, target.platform);
1564
+ const dedupeKey = `${pluginName}\0${target.platform ?? 'common'}\0${identity}`;
1747
1565
  if (visited.has(dedupeKey)) {
1748
1566
  continue;
1749
1567
  }
1750
1568
  visited.add(dedupeKey);
1751
1569
  result.checked += 1;
1752
- if (!target.manifest.config?.schema) {
1570
+ if (!target.manifest.config?.fields) {
1753
1571
  continue;
1754
1572
  }
1755
- let effective = await resolveEffectivePluginConfig({
1573
+ const effective = await resolveEffectivePluginConfig({
1756
1574
  sourceId: target.sourceId,
1757
1575
  sourceIdentity: target.sourceIdentity,
1576
+ logicalIdentity: target.logicalIdentity,
1758
1577
  pluginName,
1759
1578
  manifest: target.manifest,
1579
+ platform: target.platform,
1760
1580
  cwd: options.cwd,
1761
1581
  env: options.context.env,
1762
1582
  });
@@ -1765,7 +1585,7 @@ export async function preflightRequiredPluginConfigs(options) {
1765
1585
  continue;
1766
1586
  }
1767
1587
  const details = blockingIssues.map((issue) => issue.key).join(', ');
1768
- const setCommands = formatRequiredConfigSetCommands(pluginName, blockingIssues, options.defaultScope);
1588
+ const setCommands = formatRequiredConfigSetCommands(target.sourceId ? `${target.sourceId}/${pluginName}` : pluginName, blockingIssues, options.defaultScope, effective.schema, target.platform);
1769
1589
  throw new Error(`${pluginName} requires valid AW config before install/upgrade: ${details}. ` +
1770
1590
  `Run ${setCommands}, or open \`aw\` to complete setup.`);
1771
1591
  }