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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (529) hide show
  1. package/dist/authoring/assets/aw-config.mjs +100 -501
  2. package/dist/authoring/assets/aw-config.mjs.map +1 -1
  3. package/dist/authoring/scripts/add-skill.mjs +4 -4
  4. package/dist/authoring/scripts/add-skill.mjs.map +1 -1
  5. package/dist/authoring/scripts/init-plugin.mjs +67 -97
  6. package/dist/authoring/scripts/init-plugin.mjs.map +1 -1
  7. package/dist/authoring/scripts/lib/plugin-version-check.d.mts +15 -0
  8. package/dist/authoring/scripts/lib/plugin-version-check.mjs +239 -232
  9. package/dist/authoring/scripts/lib/plugin-version-check.mjs.map +1 -1
  10. package/dist/authoring/scripts/lib/skill-scaffold.d.mts +77 -90
  11. package/dist/authoring/scripts/lib/skill-scaffold.mjs +99 -120
  12. package/dist/authoring/scripts/lib/skill-scaffold.mjs.map +1 -1
  13. package/dist/authoring/scripts/plugin-status.mjs +8 -11
  14. package/dist/authoring/scripts/plugin-status.mjs.map +1 -1
  15. package/dist/authoring/scripts/remove-plugin.mjs +367 -0
  16. package/dist/authoring/scripts/remove-plugin.mjs.map +1 -0
  17. package/dist/authoring/scripts/validate-plugin.mjs +307 -1173
  18. package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
  19. package/dist/scripts/aw-skill-eval-materializer.d.ts +26 -0
  20. package/dist/scripts/aw-skill-eval-materializer.js +306 -0
  21. package/dist/scripts/aw-skill-eval-materializer.js.map +1 -0
  22. package/dist/scripts/bundle-plugins.d.ts +1 -2
  23. package/dist/scripts/bundle-plugins.js +24 -7
  24. package/dist/scripts/bundle-plugins.js.map +1 -1
  25. package/dist/scripts/plugin-staging.d.ts +7 -24
  26. package/dist/scripts/plugin-staging.js +22 -142
  27. package/dist/scripts/plugin-staging.js.map +1 -1
  28. package/dist/scripts/test-plugin-scripts.d.ts +2 -0
  29. package/dist/scripts/test-plugin-scripts.js +27 -75
  30. package/dist/scripts/test-plugin-scripts.js.map +1 -1
  31. package/dist/src/adapters/helpers.js +2 -2
  32. package/dist/src/adapters/helpers.js.map +1 -1
  33. package/dist/src/authoring/workspace-commands.d.ts +26 -2
  34. package/dist/src/authoring/workspace-commands.js +44 -19
  35. package/dist/src/authoring/workspace-commands.js.map +1 -1
  36. package/dist/src/commands/aw-capabilities.d.ts +78 -0
  37. package/dist/src/commands/aw-capabilities.js +256 -0
  38. package/dist/src/commands/aw-capabilities.js.map +1 -0
  39. package/dist/src/commands/catalog-dev-source.d.ts +154 -0
  40. package/dist/src/commands/catalog-dev-source.js +655 -0
  41. package/dist/src/commands/catalog-dev-source.js.map +1 -0
  42. package/dist/src/commands/catalog-generation.d.ts +21 -0
  43. package/dist/src/commands/catalog-generation.js +9 -0
  44. package/dist/src/commands/catalog-generation.js.map +1 -0
  45. package/dist/src/commands/catalog-publication-inspection.d.ts +138 -0
  46. package/dist/src/commands/catalog-publication-inspection.js +757 -0
  47. package/dist/src/commands/catalog-publication-inspection.js.map +1 -0
  48. package/dist/src/commands/catalog-publication-journal.d.ts +68 -0
  49. package/dist/src/commands/catalog-publication-journal.js +292 -0
  50. package/dist/src/commands/catalog-publication-journal.js.map +1 -0
  51. package/dist/src/commands/catalog-publication-target.d.ts +18 -0
  52. package/dist/src/commands/catalog-publication-target.js +95 -0
  53. package/dist/src/commands/catalog-publication-target.js.map +1 -0
  54. package/dist/src/commands/catalog-publish.d.ts +77 -7
  55. package/dist/src/commands/catalog-publish.js +746 -316
  56. package/dist/src/commands/catalog-publish.js.map +1 -1
  57. package/dist/src/commands/catalog-source.d.ts +60 -22
  58. package/dist/src/commands/catalog-source.js +311 -91
  59. package/dist/src/commands/catalog-source.js.map +1 -1
  60. package/dist/src/commands/catalog-status.d.ts +56 -0
  61. package/dist/src/commands/catalog-status.js +217 -0
  62. package/dist/src/commands/catalog-status.js.map +1 -0
  63. package/dist/src/commands/catalog-store.d.ts +104 -0
  64. package/dist/src/commands/catalog-store.js +685 -0
  65. package/dist/src/commands/catalog-store.js.map +1 -0
  66. package/dist/src/commands/catalog-workspace-resolution.d.ts +13 -0
  67. package/dist/src/commands/catalog-workspace-resolution.js +42 -0
  68. package/dist/src/commands/catalog-workspace-resolution.js.map +1 -0
  69. package/dist/src/commands/console.js +28 -17
  70. package/dist/src/commands/console.js.map +1 -1
  71. package/dist/src/commands/dependency-operation-plan.d.ts +52 -15
  72. package/dist/src/commands/dependency-operation-plan.js +289 -7
  73. package/dist/src/commands/dependency-operation-plan.js.map +1 -1
  74. package/dist/src/commands/init.d.ts +5 -11
  75. package/dist/src/commands/init.js +30 -51
  76. package/dist/src/commands/init.js.map +1 -1
  77. package/dist/src/commands/offline-cleanup-evidence.d.ts +67 -0
  78. package/dist/src/commands/offline-cleanup-evidence.js +181 -0
  79. package/dist/src/commands/offline-cleanup-evidence.js.map +1 -0
  80. package/dist/src/commands/operation-plan.d.ts +127 -0
  81. package/dist/src/commands/operation-plan.js +71 -0
  82. package/dist/src/commands/operation-plan.js.map +1 -0
  83. package/dist/src/commands/operation-planner.d.ts +46 -0
  84. package/dist/src/commands/operation-planner.js +141 -0
  85. package/dist/src/commands/operation-planner.js.map +1 -0
  86. package/dist/src/commands/options.d.ts +9 -7
  87. package/dist/src/commands/options.js +83 -21
  88. package/dist/src/commands/options.js.map +1 -1
  89. package/dist/src/commands/plugin-capabilities.d.ts +22 -0
  90. package/dist/src/commands/plugin-capabilities.js +159 -0
  91. package/dist/src/commands/plugin-capabilities.js.map +1 -0
  92. package/dist/src/commands/rebuild-command.d.ts +77 -30
  93. package/dist/src/commands/rebuild-command.js +3993 -711
  94. package/dist/src/commands/rebuild-command.js.map +1 -1
  95. package/dist/src/commands/rebuild-integration.d.ts +120 -21
  96. package/dist/src/commands/rebuild-integration.js +2765 -1326
  97. package/dist/src/commands/rebuild-integration.js.map +1 -1
  98. package/dist/src/commands/rebuild-operations.d.ts +58 -30
  99. package/dist/src/commands/rebuild-operations.js +260 -319
  100. package/dist/src/commands/rebuild-operations.js.map +1 -1
  101. package/dist/src/commands/reconcile-operation-plan.d.ts +28 -0
  102. package/dist/src/commands/reconcile-operation-plan.js +47 -0
  103. package/dist/src/commands/reconcile-operation-plan.js.map +1 -0
  104. package/dist/src/commands/review-inspection.d.ts +228 -0
  105. package/dist/src/commands/review-inspection.js +1341 -0
  106. package/dist/src/commands/review-inspection.js.map +1 -0
  107. package/dist/src/commands/review-preparation.d.ts +49 -0
  108. package/dist/src/commands/review-preparation.js +427 -0
  109. package/dist/src/commands/review-preparation.js.map +1 -0
  110. package/dist/src/commands/runtime.d.ts +1 -5
  111. package/dist/src/commands/runtime.js +24 -50
  112. package/dist/src/commands/runtime.js.map +1 -1
  113. package/dist/src/commands/skill-eval.d.ts +38 -0
  114. package/dist/src/commands/skill-eval.js +388 -0
  115. package/dist/src/commands/skill-eval.js.map +1 -0
  116. package/dist/src/commands/status-v6.d.ts +279 -0
  117. package/dist/src/commands/status-v6.js +2697 -0
  118. package/dist/src/commands/status-v6.js.map +1 -0
  119. package/dist/src/commands/sync-command.d.ts +40 -0
  120. package/dist/src/commands/sync-command.js +250 -0
  121. package/dist/src/commands/sync-command.js.map +1 -0
  122. package/dist/src/commands/wizard.d.ts +3 -4
  123. package/dist/src/commands/wizard.js +2 -2
  124. package/dist/src/commands/wizard.js.map +1 -1
  125. package/dist/src/commands/write-commands.d.ts +9 -3
  126. package/dist/src/commands/write-commands.js +124 -31
  127. package/dist/src/commands/write-commands.js.map +1 -1
  128. package/dist/src/constants.d.ts +7 -1
  129. package/dist/src/constants.js +7 -1
  130. package/dist/src/constants.js.map +1 -1
  131. package/dist/src/eval/manifest-v1.d.ts +71 -0
  132. package/dist/src/eval/manifest-v1.js +370 -0
  133. package/dist/src/eval/manifest-v1.js.map +1 -0
  134. package/dist/src/generators/local-plugin.d.ts +5 -1
  135. package/dist/src/generators/local-plugin.js +225 -104
  136. package/dist/src/generators/local-plugin.js.map +1 -1
  137. package/dist/src/index.d.ts +10 -4
  138. package/dist/src/index.js +1787 -476
  139. package/dist/src/index.js.map +1 -1
  140. package/dist/src/output/command-receipt.d.ts +43 -46
  141. package/dist/src/output/command-receipt.js +256 -80
  142. package/dist/src/output/command-receipt.js.map +1 -1
  143. package/dist/src/output/model.d.ts +3 -44
  144. package/dist/src/output/model.js +1 -144
  145. package/dist/src/output/model.js.map +1 -1
  146. package/dist/src/output/rebuild-progress.js +1 -13
  147. package/dist/src/output/rebuild-progress.js.map +1 -1
  148. package/dist/src/portable/commands.d.ts +46 -7
  149. package/dist/src/portable/commands.js +349 -37
  150. package/dist/src/portable/commands.js.map +1 -1
  151. package/dist/src/portable/materializer.d.ts +17 -4
  152. package/dist/src/portable/materializer.js +160 -38
  153. package/dist/src/portable/materializer.js.map +1 -1
  154. package/dist/src/portable/skills-cli.d.ts +15 -7
  155. package/dist/src/portable/skills-cli.js +66 -19
  156. package/dist/src/portable/skills-cli.js.map +1 -1
  157. package/dist/src/review/eval-source-input.d.ts +43 -0
  158. package/dist/src/review/eval-source-input.js +207 -0
  159. package/dist/src/review/eval-source-input.js.map +1 -0
  160. package/dist/src/review/review-profile.d.ts +17 -0
  161. package/dist/src/review/review-profile.js +177 -0
  162. package/dist/src/review/review-profile.js.map +1 -0
  163. package/dist/src/review/review-selection.d.ts +30 -0
  164. package/dist/src/review/review-selection.js +527 -0
  165. package/dist/src/review/review-selection.js.map +1 -0
  166. package/dist/src/review/review-types.d.ts +68 -0
  167. package/dist/src/review/review-types.js +16 -0
  168. package/dist/src/review/review-types.js.map +1 -0
  169. package/dist/src/review/skill-materialization.d.ts +13 -0
  170. package/dist/src/review/skill-materialization.js +75 -0
  171. package/dist/src/review/skill-materialization.js.map +1 -0
  172. package/dist/src/review/source-binding.d.ts +182 -0
  173. package/dist/src/review/source-binding.js +682 -0
  174. package/dist/src/review/source-binding.js.map +1 -0
  175. package/dist/src/tui/catalog-freshness.d.ts +1 -0
  176. package/dist/src/tui/catalog-freshness.js +2 -0
  177. package/dist/src/tui/catalog-freshness.js.map +1 -0
  178. package/dist/src/tui/catalog-generation.d.ts +21 -0
  179. package/dist/src/tui/catalog-generation.js +156 -0
  180. package/dist/src/tui/catalog-generation.js.map +1 -0
  181. package/dist/src/tui/catalog-sources/projection.d.ts +4 -0
  182. package/dist/src/tui/catalog-sources/projection.js +17 -0
  183. package/dist/src/tui/catalog-sources/projection.js.map +1 -0
  184. package/dist/src/tui/catalog-sources/review.d.ts +3 -0
  185. package/dist/src/tui/catalog-sources/review.js +13 -0
  186. package/dist/src/tui/catalog-sources/review.js.map +1 -0
  187. package/dist/src/tui/catalog-sources/screens.d.ts +12 -0
  188. package/dist/src/tui/catalog-sources/screens.js +40 -0
  189. package/dist/src/tui/catalog-sources/screens.js.map +1 -0
  190. package/dist/src/tui/catalog-sources/session.d.ts +28 -0
  191. package/dist/src/tui/catalog-sources/session.js +295 -0
  192. package/dist/src/tui/catalog-sources/session.js.map +1 -0
  193. package/dist/src/tui/catalog-sources/types.d.ts +53 -0
  194. package/dist/src/tui/catalog-sources/types.js +2 -0
  195. package/dist/src/tui/catalog-sources/types.js.map +1 -0
  196. package/dist/src/tui/catalog-store-task.d.ts +16 -0
  197. package/dist/src/tui/catalog-store-task.js +19 -0
  198. package/dist/src/tui/catalog-store-task.js.map +1 -0
  199. package/dist/src/tui/components.d.ts +128 -0
  200. package/dist/src/tui/components.js +251 -7
  201. package/dist/src/tui/components.js.map +1 -1
  202. package/dist/src/tui/console-app-v4.d.ts +14 -4
  203. package/dist/src/tui/console-app-v4.js +9248 -1461
  204. package/dist/src/tui/console-app-v4.js.map +1 -1
  205. package/dist/src/tui/controller-runtime.d.ts +13 -1
  206. package/dist/src/tui/controller-runtime.js +3338 -410
  207. package/dist/src/tui/controller-runtime.js.map +1 -1
  208. package/dist/src/tui/controller.d.ts +614 -40
  209. package/dist/src/tui/controller.js +3478 -708
  210. package/dist/src/tui/controller.js.map +1 -1
  211. package/dist/src/tui/dependency-graph.d.ts +81 -0
  212. package/dist/src/tui/dependency-graph.js +455 -0
  213. package/dist/src/tui/dependency-graph.js.map +1 -0
  214. package/dist/src/tui/diagnostic-projection.d.ts +23 -0
  215. package/dist/src/tui/diagnostic-projection.js +567 -0
  216. package/dist/src/tui/diagnostic-projection.js.map +1 -0
  217. package/dist/src/tui/diagnostics.d.ts +30 -0
  218. package/dist/src/tui/diagnostics.js +76 -0
  219. package/dist/src/tui/diagnostics.js.map +1 -0
  220. package/dist/src/tui/glossary.d.ts +23 -0
  221. package/dist/src/tui/glossary.js +42 -0
  222. package/dist/src/tui/glossary.js.map +1 -0
  223. package/dist/src/tui/index.d.ts +11 -4
  224. package/dist/src/tui/index.js +8 -2
  225. package/dist/src/tui/index.js.map +1 -1
  226. package/dist/src/tui/input-display.d.ts +8 -0
  227. package/dist/src/tui/input-display.js +36 -0
  228. package/dist/src/tui/input-display.js.map +1 -0
  229. package/dist/src/tui/keys.d.ts +44 -0
  230. package/dist/src/tui/keys.js +43 -15
  231. package/dist/src/tui/keys.js.map +1 -1
  232. package/dist/src/tui/lifecycle-action-view.d.ts +6 -0
  233. package/dist/src/tui/lifecycle-action-view.js +36 -0
  234. package/dist/src/tui/lifecycle-action-view.js.map +1 -0
  235. package/dist/src/tui/model.d.ts +235 -27
  236. package/dist/src/tui/model.js +1652 -304
  237. package/dist/src/tui/model.js.map +1 -1
  238. package/dist/src/tui/operation-diagnostic-screens.d.ts +21 -0
  239. package/dist/src/tui/operation-diagnostic-screens.js +102 -0
  240. package/dist/src/tui/operation-diagnostic-screens.js.map +1 -0
  241. package/dist/src/tui/operation-history.d.ts +81 -0
  242. package/dist/src/tui/operation-history.js +135 -0
  243. package/dist/src/tui/operation-history.js.map +1 -0
  244. package/dist/src/tui/operation-review-planner.d.ts +21 -0
  245. package/dist/src/tui/operation-review-planner.js +1254 -0
  246. package/dist/src/tui/operation-review-planner.js.map +1 -0
  247. package/dist/src/tui/plugin-content.d.ts +23 -0
  248. package/dist/src/tui/plugin-content.js +336 -0
  249. package/dist/src/tui/plugin-content.js.map +1 -0
  250. package/dist/src/tui/plugin-write-task.d.ts +69 -0
  251. package/dist/src/tui/plugin-write-task.js +286 -0
  252. package/dist/src/tui/plugin-write-task.js.map +1 -0
  253. package/dist/src/tui/prompt.js +4 -15
  254. package/dist/src/tui/prompt.js.map +1 -1
  255. package/dist/src/tui/router.d.ts +183 -11
  256. package/dist/src/tui/router.js +352 -29
  257. package/dist/src/tui/router.js.map +1 -1
  258. package/dist/src/tui/screen-registry.d.ts +702 -0
  259. package/dist/src/tui/screen-registry.js +231 -0
  260. package/dist/src/tui/screen-registry.js.map +1 -0
  261. package/dist/src/tui/session-console-app.d.ts +6 -0
  262. package/dist/src/tui/session-console-app.js +13 -0
  263. package/dist/src/tui/session-console-app.js.map +1 -0
  264. package/dist/src/tui/session-host.d.ts +45 -0
  265. package/dist/src/tui/session-host.js +209 -0
  266. package/dist/src/tui/session-host.js.map +1 -0
  267. package/dist/src/tui/source-ref-presets.d.ts +3 -0
  268. package/dist/src/tui/source-ref-presets.js +11 -0
  269. package/dist/src/tui/source-ref-presets.js.map +1 -0
  270. package/dist/src/tui/theme.d.ts +18 -10
  271. package/dist/src/tui/theme.js +18 -10
  272. package/dist/src/tui/theme.js.map +1 -1
  273. package/dist/src/tui/viewport.d.ts +20 -0
  274. package/dist/src/tui/viewport.js +29 -0
  275. package/dist/src/tui/viewport.js.map +1 -0
  276. package/dist/src/tui/views.js +31 -3
  277. package/dist/src/tui/views.js.map +1 -1
  278. package/dist/src/tui/wizard.js +11 -9
  279. package/dist/src/tui/wizard.js.map +1 -1
  280. package/dist/src/types.d.ts +242 -20
  281. package/dist/src/types.js +1 -0
  282. package/dist/src/types.js.map +1 -1
  283. package/dist/src/utils/agent-version.d.ts +7 -1
  284. package/dist/src/utils/agent-version.js +41 -8
  285. package/dist/src/utils/agent-version.js.map +1 -1
  286. package/dist/src/utils/artifact-plan.d.ts +5 -4
  287. package/dist/src/utils/artifact-plan.js +18 -7
  288. package/dist/src/utils/artifact-plan.js.map +1 -1
  289. package/dist/src/utils/artifact-renderer.d.ts +13 -7
  290. package/dist/src/utils/artifact-renderer.js +196 -219
  291. package/dist/src/utils/artifact-renderer.js.map +1 -1
  292. package/dist/src/utils/artifact-request.d.ts +21 -0
  293. package/dist/src/utils/artifact-request.js +82 -0
  294. package/dist/src/utils/artifact-request.js.map +1 -0
  295. package/dist/src/utils/aw-home-mutation-lock.d.ts +1 -0
  296. package/dist/src/utils/aw-home-mutation-lock.js +32 -4
  297. package/dist/src/utils/aw-home-mutation-lock.js.map +1 -1
  298. package/dist/src/utils/bundle-integrity.d.ts +0 -1
  299. package/dist/src/utils/bundle-integrity.js +0 -25
  300. package/dist/src/utils/bundle-integrity.js.map +1 -1
  301. package/dist/src/utils/bundle-layout.js +14 -29
  302. package/dist/src/utils/bundle-layout.js.map +1 -1
  303. package/dist/src/utils/catalog-capability-projection.d.ts +8 -0
  304. package/dist/src/utils/catalog-capability-projection.js +14 -0
  305. package/dist/src/utils/catalog-capability-projection.js.map +1 -0
  306. package/dist/src/utils/catalog-digests.d.ts +10 -0
  307. package/dist/src/utils/catalog-digests.js +50 -2
  308. package/dist/src/utils/catalog-digests.js.map +1 -1
  309. package/dist/src/utils/catalog-generation-control-snapshot.d.ts +11 -0
  310. package/dist/src/utils/catalog-generation-control-snapshot.js +45 -0
  311. package/dist/src/utils/catalog-generation-control-snapshot.js.map +1 -0
  312. package/dist/src/utils/catalog-generation-error.d.ts +16 -0
  313. package/dist/src/utils/catalog-generation-error.js +30 -0
  314. package/dist/src/utils/catalog-generation-error.js.map +1 -0
  315. package/dist/src/utils/catalog-generation-resolver.d.ts +44 -0
  316. package/dist/src/utils/catalog-generation-resolver.js +273 -0
  317. package/dist/src/utils/catalog-generation-resolver.js.map +1 -0
  318. package/dist/src/utils/catalog-generation-service.d.ts +172 -0
  319. package/dist/src/utils/catalog-generation-service.js +1271 -0
  320. package/dist/src/utils/catalog-generation-service.js.map +1 -0
  321. package/dist/src/utils/catalog-generation-state.d.ts +22 -0
  322. package/dist/src/utils/catalog-generation-state.js +192 -0
  323. package/dist/src/utils/catalog-generation-state.js.map +1 -0
  324. package/dist/src/utils/catalog-generation-store.d.ts +58 -0
  325. package/dist/src/utils/catalog-generation-store.js +452 -0
  326. package/dist/src/utils/catalog-generation-store.js.map +1 -0
  327. package/dist/src/utils/catalog-manifest-v7.d.ts +5 -0
  328. package/dist/src/utils/{catalog-manifest-v4.js → catalog-manifest-v7.js} +35 -43
  329. package/dist/src/utils/catalog-manifest-v7.js.map +1 -0
  330. package/dist/src/utils/catalog-operation-context.d.ts +20 -0
  331. package/dist/src/utils/catalog-operation-context.js +142 -0
  332. package/dist/src/utils/catalog-operation-context.js.map +1 -0
  333. package/dist/src/utils/catalog-public-error.d.ts +7 -3
  334. package/dist/src/utils/catalog-public-error.js +28 -8
  335. package/dist/src/utils/catalog-public-error.js.map +1 -1
  336. package/dist/src/utils/catalog-runtime-projection.d.ts +4 -7
  337. package/dist/src/utils/catalog-runtime-projection.js +7 -102
  338. package/dist/src/utils/catalog-runtime-projection.js.map +1 -1
  339. package/dist/src/utils/catalog-snapshot.d.ts +5 -3
  340. package/dist/src/utils/catalog-snapshot.js +11 -3
  341. package/dist/src/utils/catalog-snapshot.js.map +1 -1
  342. package/dist/src/utils/catalog-source-identity.d.ts +1 -0
  343. package/dist/src/utils/catalog-source-identity.js +21 -2
  344. package/dist/src/utils/catalog-source-identity.js.map +1 -1
  345. package/dist/src/utils/catalog-source-impact.d.ts +21 -0
  346. package/dist/src/utils/catalog-source-impact.js +344 -0
  347. package/dist/src/utils/catalog-source-impact.js.map +1 -0
  348. package/dist/src/utils/catalog-source-references.d.ts +3 -2
  349. package/dist/src/utils/catalog-source-references.js +195 -347
  350. package/dist/src/utils/catalog-source-references.js.map +1 -1
  351. package/dist/src/utils/catalog-sources.d.ts +15 -1
  352. package/dist/src/utils/catalog-sources.js +206 -27
  353. package/dist/src/utils/catalog-sources.js.map +1 -1
  354. package/dist/src/utils/codex-config.d.ts +2 -0
  355. package/dist/src/utils/codex-config.js +26 -5
  356. package/dist/src/utils/codex-config.js.map +1 -1
  357. package/dist/src/utils/codex-manager.d.ts +79 -0
  358. package/dist/src/utils/codex-manager.js +745 -0
  359. package/dist/src/utils/codex-manager.js.map +1 -0
  360. package/dist/src/utils/codex-marketplace-path.d.ts +5 -0
  361. package/dist/src/utils/codex-marketplace-path.js +45 -0
  362. package/dist/src/utils/codex-marketplace-path.js.map +1 -0
  363. package/dist/src/utils/codex-native-observation.d.ts +49 -0
  364. package/dist/src/utils/codex-native-observation.js +154 -0
  365. package/dist/src/utils/codex-native-observation.js.map +1 -0
  366. package/dist/src/utils/codex-native-render-receipt.d.ts +40 -0
  367. package/dist/src/utils/codex-native-render-receipt.js +205 -0
  368. package/dist/src/utils/codex-native-render-receipt.js.map +1 -0
  369. package/dist/src/utils/codex-reconciler.d.ts +126 -0
  370. package/dist/src/utils/codex-reconciler.js +298 -0
  371. package/dist/src/utils/codex-reconciler.js.map +1 -0
  372. package/dist/src/utils/codex-shared-native.d.ts +43 -0
  373. package/dist/src/utils/codex-shared-native.js +81 -0
  374. package/dist/src/utils/codex-shared-native.js.map +1 -0
  375. package/dist/src/utils/codex-skill-staging.d.ts +2 -0
  376. package/dist/src/utils/codex-skill-staging.js.map +1 -1
  377. package/dist/src/utils/codex-surface-analysis.d.ts +46 -0
  378. package/dist/src/utils/codex-surface-analysis.js +247 -0
  379. package/dist/src/utils/codex-surface-analysis.js.map +1 -0
  380. package/dist/src/utils/dynamic-skill-tree.d.ts +4 -0
  381. package/dist/src/utils/dynamic-skill-tree.js +36 -6
  382. package/dist/src/utils/dynamic-skill-tree.js.map +1 -1
  383. package/dist/src/utils/git-catalog-provider.d.ts +18 -0
  384. package/dist/src/utils/git-catalog-provider.js +170 -144
  385. package/dist/src/utils/git-catalog-provider.js.map +1 -1
  386. package/dist/src/utils/local-marketplace.d.ts +15 -1
  387. package/dist/src/utils/local-marketplace.js +307 -84
  388. package/dist/src/utils/local-marketplace.js.map +1 -1
  389. package/dist/src/utils/manifest.d.ts +1 -4
  390. package/dist/src/utils/manifest.js +1 -4
  391. package/dist/src/utils/manifest.js.map +1 -1
  392. package/dist/src/utils/multi-source-catalog.d.ts +3 -9
  393. package/dist/src/utils/multi-source-catalog.js +54 -110
  394. package/dist/src/utils/multi-source-catalog.js.map +1 -1
  395. package/dist/src/utils/native-cli.d.ts +55 -7
  396. package/dist/src/utils/native-cli.js +386 -57
  397. package/dist/src/utils/native-cli.js.map +1 -1
  398. package/dist/src/utils/orphan-marketplace-cleanup.js +0 -4
  399. package/dist/src/utils/orphan-marketplace-cleanup.js.map +1 -1
  400. package/dist/src/utils/ownership.d.ts +84 -20
  401. package/dist/src/utils/ownership.js +179 -222
  402. package/dist/src/utils/ownership.js.map +1 -1
  403. package/dist/src/utils/path-catalog-provider.d.ts +1 -1
  404. package/dist/src/utils/path-catalog-provider.js +54 -65
  405. package/dist/src/utils/path-catalog-provider.js.map +1 -1
  406. package/dist/src/utils/paths.d.ts +0 -1
  407. package/dist/src/utils/paths.js +0 -1
  408. package/dist/src/utils/paths.js.map +1 -1
  409. package/dist/src/utils/plugin-config-impact.d.ts +33 -0
  410. package/dist/src/utils/plugin-config-impact.js +298 -0
  411. package/dist/src/utils/plugin-config-impact.js.map +1 -0
  412. package/dist/src/utils/plugin-config-write.d.ts +52 -27
  413. package/dist/src/utils/plugin-config-write.js +990 -298
  414. package/dist/src/utils/plugin-config-write.js.map +1 -1
  415. package/dist/src/utils/plugin-config.d.ts +140 -93
  416. package/dist/src/utils/plugin-config.js +992 -980
  417. package/dist/src/utils/plugin-config.js.map +1 -1
  418. package/dist/src/utils/plugin-intent-state.d.ts +49 -0
  419. package/dist/src/utils/plugin-intent-state.js +320 -0
  420. package/dist/src/utils/plugin-intent-state.js.map +1 -0
  421. package/dist/src/utils/plugin-scripts.d.ts +62 -125
  422. package/dist/src/utils/plugin-scripts.js +468 -525
  423. package/dist/src/utils/plugin-scripts.js.map +1 -1
  424. package/dist/src/utils/process-tree.d.ts +2 -2
  425. package/dist/src/utils/process-tree.js +1 -1
  426. package/dist/src/utils/process-tree.js.map +1 -1
  427. package/dist/src/utils/project-boundary.d.ts +11 -13
  428. package/dist/src/utils/project-boundary.js +28 -34
  429. package/dist/src/utils/project-boundary.js.map +1 -1
  430. package/dist/src/utils/safe-fs.d.ts +21 -0
  431. package/dist/src/utils/safe-fs.js +111 -0
  432. package/dist/src/utils/safe-fs.js.map +1 -0
  433. package/dist/src/utils/safe-operation-diagnostic.d.ts +15 -0
  434. package/dist/src/utils/safe-operation-diagnostic.js +33 -0
  435. package/dist/src/utils/safe-operation-diagnostic.js.map +1 -0
  436. package/dist/src/utils/sensitive-content.d.ts +4 -0
  437. package/dist/src/utils/sensitive-content.js +36 -0
  438. package/dist/src/utils/sensitive-content.js.map +1 -0
  439. package/dist/src/utils/skill-validation.d.ts +1 -1
  440. package/dist/src/utils/skill-validation.js +1 -1
  441. package/dist/src/utils/skill-validation.js.map +1 -1
  442. package/dist/src/utils/state-paths.d.ts +1 -0
  443. package/dist/src/utils/state-paths.js +12 -2
  444. package/dist/src/utils/state-paths.js.map +1 -1
  445. package/dist/src/utils/target-eligibility.d.ts +8 -2
  446. package/dist/src/utils/target-eligibility.js +17 -8
  447. package/dist/src/utils/target-eligibility.js.map +1 -1
  448. package/dist/src/utils/windows-claude-shim.d.ts +9 -0
  449. package/dist/src/utils/windows-claude-shim.js +141 -0
  450. package/dist/src/utils/windows-claude-shim.js.map +1 -0
  451. package/dist/vitest.config.js +91 -10
  452. package/dist/vitest.config.js.map +1 -1
  453. package/package.json +22 -19
  454. package/dist/authoring/scripts/check-plugin-versions.mjs +0 -5
  455. package/dist/authoring/scripts/check-plugin-versions.mjs.map +0 -1
  456. package/dist/scripts/aw-skill-eval-engine.d.ts +0 -13
  457. package/dist/scripts/aw-skill-eval-engine.js +0 -31
  458. package/dist/scripts/aw-skill-eval-engine.js.map +0 -1
  459. package/dist/scripts/codex-eval-app-server.d.ts +0 -89
  460. package/dist/scripts/codex-eval-app-server.js +0 -1228
  461. package/dist/scripts/codex-eval-app-server.js.map +0 -1
  462. package/dist/scripts/codex-eval-isolation.d.ts +0 -61
  463. package/dist/scripts/codex-eval-isolation.js +0 -318
  464. package/dist/scripts/codex-eval-isolation.js.map +0 -1
  465. package/dist/scripts/codex-eval-process-management.d.ts +0 -8
  466. package/dist/scripts/codex-eval-process-management.js +0 -69
  467. package/dist/scripts/codex-eval-process-management.js.map +0 -1
  468. package/dist/scripts/codex-eval-process-tree.d.ts +0 -38
  469. package/dist/scripts/codex-eval-process-tree.js +0 -803
  470. package/dist/scripts/codex-eval-process-tree.js.map +0 -1
  471. package/dist/scripts/codex-eval-runtime-config.d.ts +0 -62
  472. package/dist/scripts/codex-eval-runtime-config.js +0 -843
  473. package/dist/scripts/codex-eval-runtime-config.js.map +0 -1
  474. package/dist/scripts/codex-trigger-eval.d.ts +0 -84
  475. package/dist/scripts/codex-trigger-eval.js +0 -968
  476. package/dist/scripts/codex-trigger-eval.js.map +0 -1
  477. package/dist/scripts/eval-plugin-skills-audited.d.ts +0 -6
  478. package/dist/scripts/eval-plugin-skills-audited.js +0 -261
  479. package/dist/scripts/eval-plugin-skills-audited.js.map +0 -1
  480. package/dist/scripts/eval-plugin-skills.d.ts +0 -45
  481. package/dist/scripts/eval-plugin-skills.js +0 -1586
  482. package/dist/scripts/eval-plugin-skills.js.map +0 -1
  483. package/dist/scripts/eval-run-layout.d.ts +0 -17
  484. package/dist/scripts/eval-run-layout.js +0 -26
  485. package/dist/scripts/eval-run-layout.js.map +0 -1
  486. package/dist/scripts/plugin-eval-contract.d.ts +0 -185
  487. package/dist/scripts/plugin-eval-contract.js +0 -695
  488. package/dist/scripts/plugin-eval-contract.js.map +0 -1
  489. package/dist/scripts/plugin-eval-materializer.d.ts +0 -13
  490. package/dist/scripts/plugin-eval-materializer.js +0 -421
  491. package/dist/scripts/plugin-eval-materializer.js.map +0 -1
  492. package/dist/scripts/skill-reporting.d.ts +0 -212
  493. package/dist/scripts/skill-reporting.js +0 -922
  494. package/dist/scripts/skill-reporting.js.map +0 -1
  495. package/dist/src/commands/status-v4.d.ts +0 -102
  496. package/dist/src/commands/status-v4.js +0 -844
  497. package/dist/src/commands/status-v4.js.map +0 -1
  498. package/dist/src/commands/status.d.ts +0 -93
  499. package/dist/src/commands/status.js +0 -442
  500. package/dist/src/commands/status.js.map +0 -1
  501. package/dist/src/utils/active-marketplace-runtime-lock.d.ts +0 -12
  502. package/dist/src/utils/active-marketplace-runtime-lock.js +0 -133
  503. package/dist/src/utils/active-marketplace-runtime-lock.js.map +0 -1
  504. package/dist/src/utils/catalog-manifest-v3.d.ts +0 -2
  505. package/dist/src/utils/catalog-manifest-v3.js +0 -3
  506. package/dist/src/utils/catalog-manifest-v3.js.map +0 -1
  507. package/dist/src/utils/catalog-manifest-v4.d.ts +0 -5
  508. package/dist/src/utils/catalog-manifest-v4.js.map +0 -1
  509. package/dist/src/utils/catalog-source-cache.d.ts +0 -61
  510. package/dist/src/utils/catalog-source-cache.js +0 -276
  511. package/dist/src/utils/catalog-source-cache.js.map +0 -1
  512. package/dist/src/utils/codex-project-surface.d.ts +0 -3
  513. package/dist/src/utils/codex-project-surface.js +0 -49
  514. package/dist/src/utils/codex-project-surface.js.map +0 -1
  515. package/dist/src/utils/lifecycle-active-store.d.ts +0 -175
  516. package/dist/src/utils/lifecycle-active-store.js +0 -1276
  517. package/dist/src/utils/lifecycle-active-store.js.map +0 -1
  518. package/dist/src/utils/plugin-authoring-capabilities.d.ts +0 -23
  519. package/dist/src/utils/plugin-authoring-capabilities.js +0 -37
  520. package/dist/src/utils/plugin-authoring-capabilities.js.map +0 -1
  521. package/dist/src/utils/plugin-authoring-capabilities.json +0 -92
  522. package/dist/src/utils/plugin-release.d.ts +0 -2
  523. package/dist/src/utils/plugin-release.js +0 -2
  524. package/dist/src/utils/plugin-release.js.map +0 -1
  525. package/dist/src/utils/skill-frontmatter-capabilities.d.ts +0 -201
  526. package/dist/src/utils/skill-frontmatter-capabilities.js +0 -5
  527. package/dist/src/utils/skill-frontmatter-capabilities.js.map +0 -1
  528. package/dist/src/utils/skill-frontmatter-capabilities.json +0 -200
  529. /package/dist/authoring/scripts/{check-plugin-versions.d.mts → remove-plugin.d.mts} +0 -0
@@ -0,0 +1,1254 @@
1
+ import { requestedIntentAction } from '../output/command-receipt.js';
2
+ import { catalogSourceAutoCheckOnlyValue } from './catalog-sources/review.js';
3
+ import { parseScriptTimeoutMs, SCRIPT_TIMEOUT_DEFAULT_MS, } from '../commands/options.js';
4
+ import { MANAGED_CODEX_VERSION } from '../utils/codex-manager.js';
5
+ import { platformLabel, scopeLabel } from './glossary.js';
6
+ function plannerError(code, message) {
7
+ return new Error(`${code}: ${message}`);
8
+ }
9
+ function pluginNameFromId(pluginId) {
10
+ const separator = pluginId.indexOf('/');
11
+ return separator < 0 ? pluginId : pluginId.slice(separator + 1);
12
+ }
13
+ function scriptTimeoutChanges(intent) {
14
+ let configuredTimeoutMs;
15
+ if (intent.kind === 'pluginWriteTask') {
16
+ configuredTimeoutMs = intent.scriptTimeoutMs;
17
+ }
18
+ else if ((intent.kind === 'pluginWrite' || intent.kind === 'pluginWriteBatch')
19
+ && (intent.action === 'install' || intent.action === 'refreshAndSync'
20
+ || intent.action === 'reinstall' || intent.action === 'sync')) {
21
+ configuredTimeoutMs = intent.scriptTimeoutMs;
22
+ }
23
+ else if ((intent.kind === 'configSave' || intent.kind === 'configSaveBatch') && intent.apply) {
24
+ configuredTimeoutMs = intent.scriptTimeoutMs;
25
+ }
26
+ else {
27
+ return [];
28
+ }
29
+ const timeoutMs = parseScriptTimeoutMs(configuredTimeoutMs ?? SCRIPT_TIMEOUT_DEFAULT_MS);
30
+ return [{
31
+ kind: 'keep',
32
+ group: 'runtime',
33
+ title: 'preApply 脚本超时',
34
+ description: `${timeoutMs} ms`,
35
+ }];
36
+ }
37
+ function preApplyScopeChanges(targets) {
38
+ return [...new Map(targets.map((target) => [[
39
+ target.pluginId,
40
+ target.platform,
41
+ target.scope,
42
+ ].join('\0'), target])).values()].map((target) => ({
43
+ kind: 'change',
44
+ group: 'runtime',
45
+ pluginId: target.pluginId,
46
+ ...(target.relation ? { relation: target.relation } : {}),
47
+ title: `运行 ${target.pluginId} preApply`,
48
+ description: `${platformLabel(target.platform)} · ${scopeLabel(target.scope)}`,
49
+ }));
50
+ }
51
+ function operationPreApplyTargets(evidence) {
52
+ return (evidence?.operationPlan?.actions ?? []).flatMap((action) => action.kind === 'runPreApply'
53
+ ? [{
54
+ ...action,
55
+ ...(evidence?.dependencyPlan
56
+ ? { relation: dependencyRelation(evidence.dependencyPlan, action.pluginId) }
57
+ : {}),
58
+ }]
59
+ : []);
60
+ }
61
+ function offlineCleanupPlans(evidence) {
62
+ if (!evidence)
63
+ return [];
64
+ return evidence.offlineCleanupPlans
65
+ ?? (evidence.offlineCleanup ? [evidence.offlineCleanup] : []);
66
+ }
67
+ function removesOfflineCleanupIntent(plan, target) {
68
+ return plan.changes.includes(`${target.pluginId}:${target.platform}:${target.scope}:removeIntent`);
69
+ }
70
+ function offlineCleanupReviewChanges(evidence) {
71
+ const operationPlan = evidence.operationPlan;
72
+ return offlineCleanupPlans(evidence).flatMap((target) => {
73
+ const targetDescription = `${platformLabel(target.platform)} · ${scopeLabel(target.scope)}`;
74
+ const removesIntent = operationPlan !== undefined && removesOfflineCleanupIntent(operationPlan, target);
75
+ const actions = target.plan.actions.length;
76
+ return [
77
+ {
78
+ kind: 'change',
79
+ group: 'requested',
80
+ pluginId: target.pluginId,
81
+ relation: 'requested',
82
+ title: '核验当前 AW 管理现场',
83
+ description: targetDescription,
84
+ },
85
+ ...(removesIntent ? [{
86
+ kind: 'remove',
87
+ group: 'requested',
88
+ pluginId: target.pluginId,
89
+ relation: 'requested',
90
+ title: '取消已保存的使用设置',
91
+ description: targetDescription,
92
+ }] : []),
93
+ actions > 0 ? {
94
+ kind: 'remove',
95
+ group: 'requested',
96
+ pluginId: target.pluginId,
97
+ relation: 'requested',
98
+ title: '移除可验证的 AW 输出',
99
+ description: `${targetDescription} · ${actions} 项`,
100
+ } : {
101
+ kind: 'keep',
102
+ group: 'preserved',
103
+ pluginId: target.pluginId,
104
+ relation: 'requested',
105
+ title: '没有可验证的 AW 输出',
106
+ description: removesIntent
107
+ ? `${targetDescription} · 仍会取消此位置的使用设置`
108
+ : `${targetDescription} · 不会删除现场内容`,
109
+ },
110
+ ];
111
+ });
112
+ }
113
+ function offlineCleanupPreservedChanges(evidence) {
114
+ const plans = offlineCleanupPlans(evidence);
115
+ if (plans.length === 0)
116
+ return [];
117
+ const warnings = evidence.operationPlan?.warnings ?? [];
118
+ return [
119
+ ...(warnings.length > 0 ? [{
120
+ kind: 'warning',
121
+ group: 'preserved',
122
+ title: '部分现场残留无法完整核验',
123
+ description: '这些残留会保留;可在之后重新清理。',
124
+ }] : []),
125
+ {
126
+ kind: 'keep',
127
+ group: 'preserved',
128
+ title: '保留不属于插件或被共用的内容、插件设置、依赖使用范围和其他平台或位置',
129
+ },
130
+ {
131
+ kind: 'keep',
132
+ group: 'preserved',
133
+ title: '其他根插件仍可按自己的设置使用或安装此依赖',
134
+ },
135
+ ];
136
+ }
137
+ function sourceMutationReviewChanges(mutation) {
138
+ if (mutation.action === 'add') {
139
+ const source = mutation.source;
140
+ return [
141
+ { kind: 'add', title: '保存来源配置' },
142
+ { kind: 'add', title: source.type === 'git' ? 'Git URL' : '本地目录', description: '已设置' },
143
+ ...(source.type === 'git' ? [{
144
+ kind: 'add',
145
+ title: 'Git ref policy',
146
+ description: source.refPolicy.type === 'cliChannel'
147
+ ? '跟随 CLI channel'
148
+ : `固定 ref · ${source.refPolicy.ref}`,
149
+ }, {
150
+ kind: 'add',
151
+ title: '插件目录子目录',
152
+ description: source.subdir ?? '根目录',
153
+ }] : []),
154
+ {
155
+ kind: 'add',
156
+ title: '自动检查',
157
+ description: source.autoCheck === false ? '关闭' : '开启',
158
+ },
159
+ ];
160
+ }
161
+ const update = mutation.update;
162
+ const changes = [];
163
+ if ('url' in update && update.url !== undefined) {
164
+ changes.push({ kind: 'change', title: 'Git URL', description: '将更新' });
165
+ }
166
+ if ('path' in update && update.path !== undefined) {
167
+ changes.push({ kind: 'change', title: '本地目录', description: '将更新' });
168
+ }
169
+ if ('refPolicy' in update && update.refPolicy)
170
+ changes.push({
171
+ kind: 'change',
172
+ title: 'Git ref policy',
173
+ description: update.refPolicy.type === 'cliChannel'
174
+ ? '跟随 CLI channel'
175
+ : `固定 ref · ${update.refPolicy.ref}`,
176
+ });
177
+ if ('subdir' in update && update.subdir !== undefined)
178
+ changes.push({
179
+ kind: 'change',
180
+ title: '插件目录子目录',
181
+ description: update.subdir ?? '根目录',
182
+ });
183
+ if ('autoCheck' in update && update.autoCheck !== undefined)
184
+ changes.push({
185
+ kind: 'change',
186
+ title: '自动检查',
187
+ description: update.autoCheck ? '开启' : '关闭',
188
+ });
189
+ return changes.length > 0 ? changes : [{ kind: 'change', title: '更新来源配置' }];
190
+ }
191
+ function operationLabels(intent, evidence) {
192
+ if (intent.kind === 'catalogStorePrune') {
193
+ const count = evidence?.catalogStore?.authorizedItems.length ?? 0;
194
+ return {
195
+ title: '清理 Catalog 本地存储',
196
+ description: `只删除本次预览确认的 ${count} 个可回收项。`,
197
+ primaryLabel: `清理 ${count} 个项目`,
198
+ destructive: true,
199
+ };
200
+ }
201
+ if (intent.kind === 'catalogSourcesRecovery') {
202
+ return {
203
+ title: '恢复插件目录来源配置',
204
+ description: '备份损坏配置,并恢复唯一的主来源 official。',
205
+ primaryLabel: '备份并恢复官方默认来源',
206
+ destructive: false,
207
+ };
208
+ }
209
+ if (intent.kind === 'portableInstall') {
210
+ return {
211
+ title: '确认安装通用 Skills',
212
+ description: '只安装已选择的 Skills;不会修改原生插件安装。',
213
+ primaryLabel: `开始安装 ${intent.selectedSkills.length} 个 Skills`,
214
+ destructive: false,
215
+ };
216
+ }
217
+ if (intent.kind === 'pluginWriteBatch') {
218
+ const labels = {
219
+ install: ['批量添加插件', '添加所选插件及其必需依赖。'],
220
+ sync: ['批量同步插件', '按已保存的设置同步所选插件。'],
221
+ reinstall: ['批量重新安装插件', '清理 AW 管理的内容后完整重建所选插件。'],
222
+ uninstall: ['批量移除插件', '移除所选插件的 AW 管理安装内容。配置保持不变。'],
223
+ cleanup: ['批量清理插件', '先核验所选位置,再取消其使用设置,并尽力清理可验证的 AW 输出。'],
224
+ };
225
+ const [title, description] = labels[intent.action];
226
+ return {
227
+ title,
228
+ description,
229
+ primaryLabel: title,
230
+ destructive: intent.action === 'reinstall' || intent.action === 'uninstall'
231
+ || intent.action === 'cleanup',
232
+ };
233
+ }
234
+ if (intent.kind === 'pluginWriteTask') {
235
+ const targetVersions = [...new Set(intent.targets.flatMap((target) => target.expectedUpdate ? [target.expectedUpdate.activeVersion] : []))];
236
+ const updateVersion = targetVersions.length === 1 ? `到 ${targetVersions[0]}` : '';
237
+ return {
238
+ title: intent.goal === 'update' ? `确认更新${updateVersion}` : '确认恢复所选插件',
239
+ description: intent.goal === 'update'
240
+ ? '使用当前已启用目录中的已确认版本更新所选安装位置。'
241
+ : '按已确认根因恢复所选安装位置,并保持已安装版本。',
242
+ primaryLabel: intent.goal === 'update' ? '开始更新' : '开始恢复',
243
+ destructive: false,
244
+ };
245
+ }
246
+ if (intent.kind === 'pluginWrite') {
247
+ if (intent.originIssue) {
248
+ if (intent.action === 'cleanup') {
249
+ return {
250
+ title: '清理已安装内容',
251
+ description: '先核验所选位置,再取消其使用设置,并尽力清理可验证的 AW 输出。',
252
+ primaryLabel: '开始清理',
253
+ destructive: true,
254
+ };
255
+ }
256
+ return {
257
+ title: '处理问题',
258
+ description: '只执行所选问题处理动作;插件设置保持不变。',
259
+ primaryLabel: '开始处理',
260
+ destructive: intent.action !== 'reinstall',
261
+ };
262
+ }
263
+ if (intent.action === 'cleanup' && intent.force === true) {
264
+ return {
265
+ title: '强制清理插件',
266
+ description: '先核验专属 AW 输出,再取消所选位置的使用设置并尽力清理;插件设置保持不变,依赖者会变为不完整。',
267
+ primaryLabel: '确认强制清理',
268
+ destructive: true,
269
+ };
270
+ }
271
+ const labels = {
272
+ install: ['添加插件', '添加所选平台和使用位置。', false],
273
+ refreshAndSync: ['刷新并同步', '刷新相关来源后,使用新的当前启用版本同步所选安装。', false],
274
+ reinstall: ['重新安装插件', '清理 AW 管理的内容后完整重建。', true],
275
+ uninstall: ['移除插件', '移除 AW 管理的安装内容。配置保持不变。', true],
276
+ cleanup: ['清理插件', '先核验所选位置,再取消其使用设置,并尽力清理可验证的 AW 输出。', true],
277
+ sync: ['同步插件', '按已保存使用设置修复当前使用位置。', false],
278
+ };
279
+ if (intent.expectedUpdate)
280
+ return {
281
+ title: `更新到 ${intent.expectedUpdate.activeVersion}`,
282
+ description: `使用当前启用目录中已确认的 ${intent.expectedUpdate.activeVersion} 同步所选安装。`,
283
+ primaryLabel: `更新到 ${intent.expectedUpdate.activeVersion}`,
284
+ destructive: false,
285
+ };
286
+ const [title, description, destructive] = labels[intent.action];
287
+ return { title, description, primaryLabel: title, destructive };
288
+ }
289
+ if (intent.kind === 'configSave') {
290
+ if (intent.retryApply) {
291
+ return {
292
+ title: '重试应用插件设置',
293
+ description: '重新读取当前设置和安装证据;不会恢复或重写历史值。',
294
+ primaryLabel: '重试应用',
295
+ destructive: false,
296
+ };
297
+ }
298
+ return {
299
+ title: intent.apply ? '保存并应用插件设置' : '保存插件设置',
300
+ description: intent.apply
301
+ ? '保存所选设置层,并重新应用可见安装。'
302
+ : '只保存所选设置层;当前安装保持不变。',
303
+ primaryLabel: intent.apply ? '保存并应用' : '保存',
304
+ destructive: false,
305
+ };
306
+ }
307
+ if (intent.kind === 'configSaveBatch') {
308
+ return {
309
+ title: '确认保存设置',
310
+ description: intent.apply
311
+ ? '按当前项目、个人默认的顺序保存设置,并应用实际受影响的安装位置。'
312
+ : '按当前项目、个人默认的顺序保存设置。',
313
+ primaryLabel: intent.apply ? '保存并应用设置' : '保存设置',
314
+ destructive: false,
315
+ };
316
+ }
317
+ if (intent.kind === 'configReset') {
318
+ return {
319
+ title: '重置插件设置',
320
+ description: '删除所选设置层的值,恢复继承。',
321
+ primaryLabel: '重置设置',
322
+ destructive: true,
323
+ };
324
+ }
325
+ if (intent.kind === 'sourceMutation') {
326
+ const autoCheck = intent.action === 'update'
327
+ ? catalogSourceAutoCheckOnlyValue(intent.update) : undefined;
328
+ if (autoCheck !== undefined) {
329
+ return {
330
+ title: '保存自动检查设置',
331
+ description: '只保存自动检查设置;当前启用版本和本地目录副本保持不变。',
332
+ primaryLabel: '保存设置',
333
+ destructive: false,
334
+ };
335
+ }
336
+ const labels = {
337
+ add: ['添加来源', '只保存来源配置。保存后请在终端运行 source sync。', '保存来源', false],
338
+ update: ['修改来源', '只保存来源配置。保存后请在终端运行 source sync。', '保存来源', false],
339
+ setPrimary: ['设为主来源', '只改变默认 marketplace,不迁移安装。', '设为主来源', false],
340
+ remove: ['移除来源', '移除来源配置;不会删除其它来源。', '移除来源', true],
341
+ };
342
+ const [title, description, primaryLabel, destructive] = labels[intent.action];
343
+ return { title, description, primaryLabel, destructive };
344
+ }
345
+ if (intent.kind === 'catalogGeneration') {
346
+ if (intent.action === 'update' && evidence?.catalogGeneration?.exactRepair) {
347
+ return {
348
+ title: '验证并精确修复插件目录',
349
+ description: '待检查版本与当前启用版本的技术标识相同。精确替换损坏内容,并保留当前启用版本。',
350
+ primaryLabel: '验证并精确修复',
351
+ destructive: false,
352
+ };
353
+ }
354
+ const labels = {
355
+ activate: ['获取并启用插件目录', '检查待检查版本后启用。不会升级已安装插件,也不会修改其他来源。', '获取并启用'],
356
+ update: ['检查并切换插件目录', '检查待检查版本后切换当前启用版本。失败时保留原当前启用版本。', '检查并切换'],
357
+ repair: ['重新下载并修复插件目录', '只修复这个来源的当前启用版本,不删除其他目录版本副本。', '重新下载并修复'],
358
+ replaceDamaged: ['替换损坏的当前启用版本', '使用待检查版本替换无法精确修复的当前启用版本。失败时保留原版本。', '确认并替换'],
359
+ recoverState: ['恢复插件目录状态并启用', '重建无效的目录版本状态,并只启用已确认的目标来源。来源配置和本地目录副本保持不变。', '恢复状态并启用'],
360
+ };
361
+ const [title, description, primaryLabel] = labels[intent.action];
362
+ return { title, description, primaryLabel, destructive: false };
363
+ }
364
+ throw plannerError('operationNotImplemented', '问题修复操作尚未接入。');
365
+ }
366
+ function dependencyRelation(plan, pluginId) {
367
+ if (plan.requestedPluginIds.includes(pluginId))
368
+ return 'requested';
369
+ return plan.dependencyEdges.some((edge) => plan.requestedPluginIds.includes(edge.from) && edge.to === pluginId)
370
+ ? 'direct'
371
+ : 'transitive';
372
+ }
373
+ function reviewChanges(intent, evidence, dependencyOverview) {
374
+ if (intent.kind === 'catalogStorePrune') {
375
+ const store = evidence?.catalogStore;
376
+ if (!store)
377
+ throw plannerError('catalogStorePrepareFailed', '缺少 Catalog 本地存储预览证据。');
378
+ const bytes = store.reclaimableBytes === null
379
+ ? '大小未知'
380
+ : `${store.reclaimableBytes} bytes`;
381
+ return [
382
+ {
383
+ kind: 'remove',
384
+ title: `删除 ${store.authorizedItems.length} 个已确认的可回收项`,
385
+ description: bytes,
386
+ },
387
+ { kind: 'keep', title: '保留 Active Catalog、foreign 内容和无法证明安全的项目' },
388
+ { kind: 'keep', title: '保留预览以后出现的新项目' },
389
+ ];
390
+ }
391
+ if (intent.kind === 'catalogSourcesRecovery') {
392
+ return [
393
+ { kind: 'add', title: '备份损坏的 catalog-sources.json' },
394
+ { kind: 'change', title: '恢复唯一的主来源 official' },
395
+ { kind: 'keep', title: '保留 catalog-state.json 和 catalog-store' },
396
+ {
397
+ kind: 'warning',
398
+ title: '自定义来源需要之后重新添加',
399
+ description: '无法从损坏配置中安全恢复自定义来源。',
400
+ },
401
+ ];
402
+ }
403
+ if (intent.kind === 'portableInstall') {
404
+ const review = evidence?.portable;
405
+ if (!review)
406
+ throw plannerError('portablePrepareFailed', '缺少通用 Skills Review 证据。');
407
+ const retry = 'targetGroups' in review ? review : undefined;
408
+ return [
409
+ ...review.selected.map((skill) => ({
410
+ kind: 'add',
411
+ group: skill.relation === 'requested' ? 'requested' : 'dependencies',
412
+ pluginId: skill.providerPluginId,
413
+ relation: skill.relation,
414
+ title: skill.name,
415
+ description: `${skill.description} · ${skill.providerDisplayName}${skill.dynamic ? ' · 按设置生成' : ''}`,
416
+ })),
417
+ ...(retry ? retry.targetGroups.map((group) => ({
418
+ kind: 'change',
419
+ group: 'portableTarget',
420
+ title: `精确重试 · ${group.agent}`,
421
+ description: group.skills.join('、'),
422
+ })) : [{ kind: 'change', group: 'portableTarget', title: 'Agent', description: review.agentMode === 'automatic'
423
+ ? '自动选择检测到的 Agent;实际目标由 Skills CLI 决定,不表示安装到所有 Agent'
424
+ : review.requestedAgents.join('、') }]),
425
+ { kind: 'change', group: 'portableTarget', title: '范围', description: review.scope === 'project' ? '当前项目' : '所有项目' },
426
+ { kind: review.dependencies.length > 0 ? 'keep' : 'change', group: 'portableInputs', title: '插件依赖', description: review.dependencies.length > 0
427
+ ? `${review.dependencies.length} 个依赖用于生成,不能取消` : '无需插件依赖' },
428
+ ...(review.collisions.length > 0 ? [{ kind: 'warning', group: 'portableWarnings', title: '同名覆盖',
429
+ description: review.collisions.map((collision) => collision.name).join('、') }] : []),
430
+ ];
431
+ }
432
+ if (intent.kind === 'pluginWrite') {
433
+ const desiredIntentKind = requestedIntentAction(intent.action === 'refreshAndSync' ? 'sync' : intent.action);
434
+ const runtimeChanges = [
435
+ ...scriptTimeoutChanges(intent),
436
+ ...preApplyScopeChanges(operationPreApplyTargets(evidence)),
437
+ ...(evidence?.codexManager
438
+ ? [{
439
+ kind: evidence.codexManager.state === 'requires-install' ? 'add' : 'keep',
440
+ group: 'runtime',
441
+ title: evidence.codexManager.state === 'requires-install'
442
+ ? '获取 Codex 运行组件'
443
+ : 'Codex 运行组件',
444
+ description: evidence.codexManager.state === 'requires-install'
445
+ ? `${evidence.codexManager.packageName}@${evidence.codexManager.version} · AW 管理缓存`
446
+ : evidence.codexManager.state === 'cached'
447
+ ? `${evidence.codexManager.packageName}@${evidence.codexManager.version} · 复用 AW 管理缓存`
448
+ : `使用兼容的系统 Codex ${evidence.codexManager.version}`,
449
+ }]
450
+ : []),
451
+ ];
452
+ const codexChanges = (evidence?.codexReconcilePlans ?? []).flatMap((codexPlan) => [
453
+ ...codexPlan.sharedNativeActions.map((action) => ({
454
+ kind: action.action === 'reuse' || action.action === 'none' ? 'keep'
455
+ : action.action === 'install' ? 'add' : 'change',
456
+ group: 'sharedCodexNative',
457
+ pluginId: action.pluginId,
458
+ title: action.codexPluginId,
459
+ description: action.action === 'reuse'
460
+ ? '复用完全相同的由平台共用内容'
461
+ : `${{
462
+ install: '添加',
463
+ update: '更新',
464
+ repair: '修复',
465
+ replace: '替换',
466
+ remove: '移除',
467
+ none: '保持不变',
468
+ }[action.action]}由平台共用的内容${action.affectsOtherScopes ? ' · 可能影响其他项目' : ''}`,
469
+ })),
470
+ ...codexPlan.activationActions.user.map((action) => ({
471
+ kind: action.action === 'none' ? 'keep' : action.desired ? 'change' : 'remove',
472
+ group: 'userActivation',
473
+ pluginId: action.pluginId,
474
+ title: action.codexPluginId,
475
+ description: `${action.desired ? '启用' : '停用'}所有项目位置 · ${action.action === 'none' ? '保持不变' : '将更新'}`,
476
+ })),
477
+ ...codexPlan.activationActions.project.map((action) => ({
478
+ kind: action.action === 'none' ? 'keep' : action.desired ? 'change' : 'remove',
479
+ group: 'projectActivation',
480
+ pluginId: action.pluginId,
481
+ title: action.codexPluginId,
482
+ description: `${action.desired ? '启用' : '停用'}当前项目位置 · ${action.action === 'none' ? '保持不变' : '将更新'}`,
483
+ })),
484
+ ...[...codexPlan.extensionWrites, ...codexPlan.extensionRemovals]
485
+ .map((action) => ({
486
+ kind: action.action === 'write' ? 'change' : 'remove',
487
+ group: 'awExtensions',
488
+ pluginId: action.pluginId,
489
+ title: action.componentKey,
490
+ description: `${scopeLabel(action.scope)} · ${action.action === 'write' ? '写入' : '移除'}`,
491
+ })),
492
+ ]);
493
+ const plan = evidence?.dependencyPlan;
494
+ if (plan && (intent.action === 'install' || intent.action === 'refreshAndSync'
495
+ || intent.action === 'reinstall' || intent.action === 'sync')) {
496
+ const changes = plan.targets.map((target) => {
497
+ const relation = dependencyRelation(plan, target.pluginId);
498
+ return {
499
+ kind: desiredIntentKind,
500
+ group: relation === 'requested' ? 'requested' : 'dependencies',
501
+ pluginId: target.pluginId,
502
+ relation,
503
+ title: pluginNameFromId(target.pluginId),
504
+ description: `${platformLabel(target.platform)} · ${scopeLabel(target.resolvedScope)}${target.action === 'keep' ? ' · 已可用' : ''}${target.assignmentSource === 'existingWiderTarget' ? ' · 复用健康的所有项目安装' : target.assignmentSource === 'consumerPromotion' ? ' · 根据依赖自动扩大范围' : ''}`,
505
+ };
506
+ });
507
+ changes.push({
508
+ kind: 'keep',
509
+ group: 'preserved',
510
+ title: '插件设置和已有依赖保持不变',
511
+ description: '移除根插件时不会自动清理依赖。',
512
+ });
513
+ return [...changes, ...codexChanges, ...runtimeChanges];
514
+ }
515
+ if (intent.action === 'cleanup' && evidence) {
516
+ const cleanupChanges = offlineCleanupReviewChanges(evidence);
517
+ if (cleanupChanges.length > 0) {
518
+ const changes = [
519
+ ...cleanupChanges,
520
+ ...offlineCleanupPreservedChanges(evidence),
521
+ ];
522
+ if (intent.force === true)
523
+ changes.push({
524
+ kind: 'warning',
525
+ title: '跳过依赖保护',
526
+ description: '依赖此插件的插件会变为不完整,需重新安装后恢复。',
527
+ });
528
+ return [...changes, ...codexChanges, ...runtimeChanges];
529
+ }
530
+ }
531
+ const platforms = intent.platform === 'both'
532
+ ? ['codex', 'claude']
533
+ : [intent.platform];
534
+ const changes = platforms.map((platform) => ({
535
+ kind: intent.action === 'uninstall' || intent.action === 'cleanup' ? 'remove' : intent.action === 'install' ? 'add' : 'change',
536
+ group: 'requested',
537
+ pluginId: intent.pluginId,
538
+ relation: 'requested',
539
+ title: `${platformLabel(platform)} · ${scopeLabel(intent.scope)}`,
540
+ description: intent.action === 'uninstall' || intent.action === 'cleanup'
541
+ ? '插件设置不会删除。'
542
+ : '执行前会再次检查当前安装状态。',
543
+ }));
544
+ if (intent.action === 'uninstall' || intent.action === 'cleanup') {
545
+ changes.push(...(dependencyOverview?.dependencies ?? []).map((dependency) => ({
546
+ kind: 'keep',
547
+ group: 'preserved',
548
+ pluginId: dependency.pluginId,
549
+ relation: dependency.relation === 'direct' ? 'direct' : 'transitive',
550
+ title: dependency.displayName,
551
+ description: '依赖保持安装。',
552
+ })));
553
+ }
554
+ if (intent.action === 'cleanup' && intent.force === true) {
555
+ changes.push({
556
+ kind: 'warning',
557
+ title: '跳过依赖保护',
558
+ description: '依赖此插件的插件会变为不完整,需重新安装后恢复。',
559
+ });
560
+ }
561
+ if (intent.originIssue) {
562
+ changes.push({ kind: 'keep', title: '插件设置保持不变' }, { kind: 'warning', title: '执行前重新检查完整目标和来源证据' });
563
+ }
564
+ if (intent.recoveryDescription) {
565
+ changes.push({
566
+ kind: 'warning',
567
+ group: 'preserved',
568
+ title: `后续:同步${intent.scope === 'user' ? '当前项目' : '所有项目'}位置`,
569
+ description: '完成此操作后,同步要保留的使用位置。',
570
+ });
571
+ }
572
+ return [...changes, ...codexChanges, ...runtimeChanges];
573
+ }
574
+ if (intent.kind === 'configReset') {
575
+ const layerLabel = intent.scope === 'user'
576
+ ? '个人默认'
577
+ : '当前项目';
578
+ const impact = evidence?.config;
579
+ const impactChanges = impact?.impactState === 'unknown'
580
+ ? [{
581
+ kind: 'warning', group: 'configImpact', title: '设置重置后的应用影响未知',
582
+ description: '当前无法解析来源或设置;重置仍会删除所选设置层。',
583
+ }]
584
+ : impact?.noEffectiveChange
585
+ ? [{ kind: 'keep', group: 'configImpact', title: '有效设置输入不变;无需同步当前安装' }]
586
+ : (impact?.affectedTargets ?? []).length > 0
587
+ ? impact.affectedTargets.map((target) => ({
588
+ kind: 'warning', group: 'configImpact',
589
+ title: `重置后需同步 ${target.platform === 'codex' ? 'Codex' : 'Claude Code'} · ${target.scope === 'user' ? '所有项目' : '当前项目'}`,
590
+ }))
591
+ : [{ kind: 'keep', group: 'configImpact', title: '只删除设置层;当前安装保持不变' }];
592
+ return [
593
+ ...(intent.changes?.map((change) => ({
594
+ kind: 'remove', group: 'configChanges', title: `${layerLabel} · ${change.title}`,
595
+ description: change.children && change.children.length > 0
596
+ ? `${change.before} → ${change.after};${change.children.length} 个子项变化;${change.children.map((child) => `${child.property}: ${child.private ? '已设置 → 将更新' : `${child.before} → ${child.after}`}`).join(';')}`
597
+ : `${change.before} → ${change.after}`,
598
+ })) ?? [{ kind: 'remove', group: 'configChanges', title: `删除${layerLabel}中的已存值`, description: '删除整个设置层且不创建备份;有效值将恢复为继承值或默认值。' }]),
599
+ ...impactChanges,
600
+ { kind: 'keep', group: 'preserved', title: intent.scope === 'user' ? '当前项目设置保持不变' : '个人默认保持不变' },
601
+ ];
602
+ }
603
+ if (intent.kind === 'sourceMutation') {
604
+ const changes = (intent.changes ?? []).map((change) => ({
605
+ kind: intent.action === 'remove' ? 'remove' : intent.action === 'add' ? 'add' : 'change',
606
+ title: change.title,
607
+ ...(change.private
608
+ ? { description: change.before ? '已设置 → 将更新' : '已选择' }
609
+ : change.before || change.after
610
+ ? { description: `${change.before ?? '未设置'} → ${change.after ?? '未设置'}` }
611
+ : {}),
612
+ }));
613
+ if (intent.action === 'add')
614
+ changes.push({ kind: 'keep', title: '保留现有主来源' });
615
+ if (intent.action === 'setPrimary')
616
+ changes.push({ kind: 'keep', title: '同名插件选择保持不变' }, { kind: 'keep', title: '现有安装和设置不会迁移' });
617
+ if (intent.action === 'remove')
618
+ changes.push({ kind: 'keep', title: '保留其他来源' });
619
+ const impact = evidence?.sourceWrite?.impact;
620
+ if (impact) {
621
+ for (const category of ['installation', 'config', 'lifecycle', 'marketplace']) {
622
+ const count = impact.affectedReferences.filter((reference) => reference.category === category).length;
623
+ if (count > 0)
624
+ changes.push({
625
+ kind: 'warning',
626
+ title: `${category === 'installation' ? '安装' : category === 'config' ? '设置' : category === 'lifecycle' ? '生命周期意图' : 'Marketplace'}引用受影响`,
627
+ description: `${count} 项`,
628
+ });
629
+ }
630
+ if (!impact.inventoryComplete)
631
+ changes.push({
632
+ kind: 'warning',
633
+ title: '来源影响未知',
634
+ description: '部分状态无法读取;不能把影响视为零。',
635
+ });
636
+ }
637
+ return changes;
638
+ }
639
+ if (intent.kind === 'catalogGeneration') {
640
+ const generation = evidence?.catalogGeneration;
641
+ if (!generation) {
642
+ throw plannerError('catalogGenerationUnavailable', '缺少插件目录待检查版本证据。');
643
+ }
644
+ return [
645
+ ...(generation.previousActive ? [{
646
+ kind: 'keep',
647
+ title: generation.previousActiveVersion
648
+ ? `当前启用版本 ${generation.previousActiveVersion}` : '当前启用版本',
649
+ description: `${generation.previousActive.resolvedCommit.slice(0, 8)} · ${generation.previousActive.snapshotDigest.slice(0, 15)}`,
650
+ }] : []),
651
+ {
652
+ kind: intent.action === 'activate' ? 'add' : 'change',
653
+ title: generation.exactRepair
654
+ ? `精确修复待检查版本 ${generation.candidate.catalogVersion}`
655
+ : `待检查版本 ${generation.candidate.catalogVersion}`,
656
+ description: `${generation.candidate.resolvedCommit.slice(0, 8)} · ${generation.candidate.snapshotDigest.slice(0, 15)}`,
657
+ },
658
+ ...(generation.exactRepair ? [{
659
+ kind: 'change',
660
+ title: '精确替换损坏的当前启用版本',
661
+ description: '版本和内容的技术标识保持不变。',
662
+ }] : []),
663
+ ...(intent.action === 'replaceDamaged' ? [{
664
+ kind: 'warning',
665
+ title: '使用待检查版本替换损坏的当前启用版本',
666
+ description: '旧版本无法安全比较;确认后只切换到本次已检查的版本。',
667
+ }] : []),
668
+ ...(generation.sourceMutation ? sourceMutationReviewChanges(generation.sourceMutation) : []),
669
+ ...(generation.explicitSourceChange && generation.candidateRelation === 'rollbackDetected' ? [{
670
+ kind: 'warning',
671
+ title: '来源切换将降低插件目录版本',
672
+ description: `${generation.previousActiveVersion ?? '当前版本'} → ${generation.candidate.catalogVersion}`,
673
+ }] : generation.explicitSourceChange && generation.candidateRelation === 'versionConflict' ? [{
674
+ kind: 'warning',
675
+ title: '来源切换包含同版本不同内容',
676
+ description: `${generation.candidate.catalogVersion} · ${generation.candidate.snapshotDigest.slice(0, 15)}`,
677
+ }] : generation.explicitSourceChange && generation.candidateRelation === 'incompatible' ? [{
678
+ kind: 'warning',
679
+ title: '来源切换将改变插件目录身份',
680
+ description: '确认前请核对新来源身份和待检查版本摘要。',
681
+ }] : []),
682
+ ...((generation.impact?.affectedReferences ?? []).length > 0 ? [{
683
+ kind: 'warning',
684
+ title: '现有引用受待检查版本影响',
685
+ description: `${generation.impact.affectedReferences.length} 项;已安装插件不会自动修改。`,
686
+ }] : []),
687
+ ...(generation.impact && !generation.impact.inventoryComplete ? [{
688
+ kind: 'warning',
689
+ title: '待检查版本的影响未知',
690
+ description: '部分状态或旧插件定义无法读取;不能把影响视为零。',
691
+ }] : []),
692
+ ...((generation.primaryImpact?.affectedReferences ?? []).length > 0 ? [{
693
+ kind: 'warning',
694
+ title: '切换主来源会影响现有引用',
695
+ description: `${generation.primaryImpact.affectedReferences.length} 项;切换将在插件目录启用后执行。`,
696
+ }] : []),
697
+ ...(generation.primaryImpact && !generation.primaryImpact.inventoryComplete ? [{
698
+ kind: 'warning',
699
+ title: '主来源切换影响未知',
700
+ description: '部分状态无法读取;不能把影响视为零。',
701
+ }] : []),
702
+ { kind: 'keep', title: '不会升级已安装插件' },
703
+ { kind: 'keep', title: intent.action === 'recoverState'
704
+ ? '不会修改其他来源配置或本地目录副本' : '不会修改其他来源' },
705
+ { kind: 'keep', title: '失败时保留原当前启用版本' },
706
+ ...(intent.action === 'recoverState' ? [{
707
+ kind: 'warning',
708
+ title: '无效状态中的其他当前启用版本记录不会保留',
709
+ description: '其他来源配置和本地目录副本不会删除;可分别重新启用。',
710
+ }] : []),
711
+ ];
712
+ }
713
+ if (intent.kind === 'configSaveBatch') {
714
+ if (!evidence?.configBatch
715
+ || evidence.configBatch.groups.length !== intent.groups.length) {
716
+ throw plannerError('configBatchPrepareFailed', '缺少多层设置 Review 证据。');
717
+ }
718
+ return [
719
+ ...scriptTimeoutChanges(intent),
720
+ ...intent.groups.flatMap((group) => {
721
+ const groupEvidence = evidence.configBatch.groups.find((item) => item.scope === group.scope);
722
+ if (!groupEvidence) {
723
+ throw plannerError('configBatchPrepareFailed', '设置层 Review 证据不完整。');
724
+ }
725
+ return reviewChanges({
726
+ kind: 'configSave',
727
+ pluginId: intent.pluginId,
728
+ scope: group.scope,
729
+ apply: intent.apply,
730
+ ...(group.updates ? { updates: group.updates } : {}),
731
+ ...(group.removeKeys ? { removeKeys: group.removeKeys } : {}),
732
+ ...(group.sensitiveKeys ? { sensitiveKeys: group.sensitiveKeys } : {}),
733
+ ...(group.privateKeys ? { privateKeys: group.privateKeys } : {}),
734
+ ...(group.changes ? { changes: group.changes } : {}),
735
+ }, {
736
+ catalog: evidence.catalog,
737
+ ...(evidence.source ? { source: evidence.source } : {}),
738
+ targetFingerprint: groupEvidence.targetFingerprint,
739
+ config: groupEvidence.config,
740
+ }, dependencyOverview);
741
+ }),
742
+ ];
743
+ }
744
+ if (intent.kind !== 'configSave') {
745
+ throw plannerError('operationNotImplemented', '这个写操作尚未接入新 Controller。');
746
+ }
747
+ const privateKeys = new Set([...(intent.sensitiveKeys ?? []), ...(intent.privateKeys ?? [])]);
748
+ const removeKeys = new Set(intent.removeKeys ?? []);
749
+ const layerLabel = intent.scope === 'user' ? '个人默认' : '当前项目';
750
+ if (intent.retryApply) {
751
+ return [
752
+ ...scriptTimeoutChanges(intent),
753
+ ...preApplyScopeChanges(evidence?.config?.preApplyAuthorization ?? []),
754
+ ...(evidence?.config?.affectedTargets.map((target) => ({
755
+ kind: 'change',
756
+ group: 'configImpact',
757
+ title: `重新应用 ${target.platform === 'codex' ? 'Codex' : 'Claude Code'} · ${target.scope === 'user' ? '所有项目' : '当前项目'}`,
758
+ })) ?? []),
759
+ { kind: 'keep', group: 'preserved', title: `${layerLabel}中的当前值保持不变` },
760
+ { kind: 'keep', group: 'preserved', title: '不会恢复历史设置值' },
761
+ ];
762
+ }
763
+ if (intent.changes) {
764
+ const noEffectiveChange = evidence?.config?.noEffectiveChange === true;
765
+ const hasAffectedCodexTarget = evidence?.config?.affectedTargets.some((target) => target.platform === 'codex') ?? false;
766
+ const sharedNativeTargets = hasAffectedCodexTarget
767
+ ? evidence?.config?.sharedNativeRenderTargets ?? []
768
+ : [];
769
+ const sharedNativeImpact = noEffectiveChange || sharedNativeTargets.length === 0
770
+ ? []
771
+ : intent.apply
772
+ ? [
773
+ {
774
+ kind: 'change', group: 'configImpact',
775
+ title: `重新生成 ${sharedNativeTargets.map((target) => target.skillKey).join('、')} 动态 Skill`,
776
+ description: '配置来源为个人默认;更新 Codex 由平台共用的内容会影响所有启用项目。',
777
+ },
778
+ { kind: 'keep', group: 'preserved', title: '保留所有项目和当前项目的启用位置' },
779
+ { kind: 'keep', group: 'preserved', title: '当前项目 Agent role 继续使用当前项目配置' },
780
+ ]
781
+ : [
782
+ {
783
+ kind: 'warning', group: 'configImpact',
784
+ title: 'Codex 由平台共用的内容待同步',
785
+ description: '个人默认已保存;动态 Skill 尚未重新生成。',
786
+ },
787
+ { kind: 'keep', group: 'preserved', title: '当前由平台共用的内容和启用位置保持不变' },
788
+ { kind: 'keep', group: 'preserved', title: '当前项目 Agent role 继续使用当前项目配置' },
789
+ ];
790
+ return [
791
+ ...scriptTimeoutChanges(intent),
792
+ ...preApplyScopeChanges(evidence?.config?.preApplyAuthorization ?? []),
793
+ ...(evidence?.config?.shareability === 'unverified' ? [{
794
+ kind: 'warning',
795
+ group: 'configImpact',
796
+ title: 'Git 无法验证 project config 可共享',
797
+ description: '可以继续写入,但不要将该路径视为已验证可提交。',
798
+ }] : []),
799
+ ...intent.changes.map((change) => ({
800
+ kind: removeKeys.has(change.key) ? 'remove' : 'change',
801
+ group: 'configChanges',
802
+ title: removeKeys.has(change.key)
803
+ ? `${layerLabel} · 删除 ${change.title} 中的值`
804
+ : `${layerLabel} · ${change.title}`,
805
+ description: change.children && change.children.length > 0
806
+ ? `${change.before} → ${change.after};${change.children.length} 个子项变化;${change.children.map((child) => `${child.property}: ${child.private ? '已设置 → 将更新' : `${child.before} → ${child.after}`}`).join(';')}`
807
+ : removeKeys.has(change.key)
808
+ ? privateKeys.has(change.key) ? `已设置 → ${change.after}` : `${change.before} → ${change.after}`
809
+ : privateKeys.has(change.key) ? '已设置 → 将更新'
810
+ : `${change.before} → ${change.after}`,
811
+ })),
812
+ ...(evidence?.config?.impactState === 'unknown' ? [{
813
+ kind: 'warning', group: 'configImpact',
814
+ title: '设置的应用影响未知',
815
+ description: '当前无法比较保存前后的有效设置输入。',
816
+ }] : noEffectiveChange ? [{
817
+ kind: 'keep', group: 'configImpact',
818
+ title: '有效设置输入不变;无需重新应用',
819
+ }] : []),
820
+ ...sharedNativeImpact,
821
+ ...(evidence?.config?.impactState === 'unknown' || noEffectiveChange || sharedNativeTargets.length > 0
822
+ ? []
823
+ : intent.apply && (evidence?.config?.affectedTargets.length ?? 0) > 0
824
+ ? evidence.config.affectedTargets.map((target) => ({
825
+ kind: 'change', group: 'configImpact', title: `重新应用 ${target.platform === 'codex' ? 'Codex' : 'Claude Code'} · ${target.scope === 'user' ? '所有项目' : '当前项目'}`,
826
+ }))
827
+ : !intent.apply && (evidence?.config?.affectedTargets.length ?? 0) > 0
828
+ ? evidence.config.affectedTargets.map((target) => ({
829
+ kind: 'warning', group: 'configImpact', title: `保存后需同步 ${target.platform === 'codex' ? 'Codex' : 'Claude Code'} · ${target.scope === 'user' ? '所有项目' : '当前项目'}`,
830
+ }))
831
+ : [{ kind: 'keep', group: 'configImpact', title: '当前没有可见安装;只保存设置' }]),
832
+ { kind: 'keep', group: 'preserved', title: '其他项目不会被自动扫描' },
833
+ ];
834
+ }
835
+ const updateKeys = Object.keys(intent.updates ?? {});
836
+ return [
837
+ ...scriptTimeoutChanges(intent),
838
+ ...preApplyScopeChanges(evidence?.config?.preApplyAuthorization ?? []),
839
+ ...updateKeys.map((key) => ({
840
+ kind: 'change',
841
+ title: key,
842
+ description: privateKeys.has(key) ? '已设置 → 将更新' : '将更新',
843
+ })),
844
+ ...(intent.removeKeys ?? []).map((key) => ({
845
+ kind: 'remove',
846
+ title: key,
847
+ description: privateKeys.has(key) ? '已设置 → 未设置' : '恢复继承',
848
+ })),
849
+ ];
850
+ }
851
+ function batchGroupEvidence(evidence, group) {
852
+ const manager = group.preview.codexManagerPreview;
853
+ return {
854
+ catalog: evidence.catalog,
855
+ ...(group.preview.offlineCleanupPlans
856
+ ? { offlineCleanupPlans: group.preview.offlineCleanupPlans }
857
+ : {}),
858
+ ...(group.preview.dependencyPlan ? { dependencyPlan: group.preview.dependencyPlan } : {}),
859
+ ...(group.preview.codexReconcilePlans ? { codexReconcilePlans: group.preview.codexReconcilePlans } : {}),
860
+ ...(group.preview.operationPlan ? { operationPlan: group.preview.operationPlan } : {}),
861
+ ...(manager && manager.state !== 'blocked' ? {
862
+ codexManager: {
863
+ state: manager.state,
864
+ packageName: '@openai/codex',
865
+ version: manager.state === 'requires-install'
866
+ ? MANAGED_CODEX_VERSION
867
+ : manager.manager.version,
868
+ },
869
+ } : {}),
870
+ };
871
+ }
872
+ function taskSourceEvidence(evidence, source) {
873
+ return {
874
+ catalog: evidence.catalog,
875
+ ...(source.preview.dependencyPlan ? { dependencyPlan: source.preview.dependencyPlan } : {}),
876
+ ...(source.preview.codexReconcilePlans
877
+ ? { codexReconcilePlans: source.preview.codexReconcilePlans } : {}),
878
+ ...(source.preview.operationPlan ? { operationPlan: source.preview.operationPlan } : {}),
879
+ };
880
+ }
881
+ function taskReviewChanges(intent, evidence) {
882
+ const requested = evidence.taskPlan.executableTargets.map((target) => ({
883
+ kind: 'change',
884
+ group: 'requested',
885
+ pluginId: target.pluginId,
886
+ sourceId: target.pluginId.slice(0, target.pluginId.indexOf('/')),
887
+ relation: 'requested',
888
+ title: pluginNameFromId(target.pluginId),
889
+ description: `${platformLabel(target.platform)} · ${scopeLabel(target.scope)}`
890
+ + (target.expectedUpdate
891
+ ? ` · ${target.expectedUpdate.installedVersion} → ${target.expectedUpdate.activeVersion}`
892
+ : ' · 保持已安装版本'),
893
+ }));
894
+ const causes = evidence.taskPlan.causes.map((cause) => ({
895
+ kind: 'change',
896
+ group: 'dependencies',
897
+ pluginId: cause.repairTarget.pluginId,
898
+ sourceId: cause.sourceId,
899
+ relation: cause.consumers.some((consumer) => consumer.pluginId === cause.repairTarget.pluginId
900
+ && consumer.platform === cause.repairTarget.platform
901
+ && consumer.scope === cause.repairTarget.scope) ? 'requested' : 'direct',
902
+ title: pluginNameFromId(cause.repairTarget.pluginId),
903
+ description: `${cause.method === 'reinstall' ? '重新安装' : '同步'} · `
904
+ + `${platformLabel(cause.repairTarget.platform)} · ${scopeLabel(cause.repairTarget.scope)}`
905
+ + (cause.restoreVersionEvidence?.state === 'preserved'
906
+ ? ` · 保持 ${cause.restoreVersionEvidence.installedVersion}`
907
+ : cause.restoreVersionEvidence?.state === 'absent'
908
+ ? ` · 补齐 ${cause.restoreVersionEvidence.activeVersion}` : '')
909
+ + ` · 影响 ${cause.consumers.length} 个所选安装位置`,
910
+ }));
911
+ const runtime = evidence.taskPlan.sources.flatMap((source) => preApplyScopeChanges(operationPreApplyTargets(taskSourceEvidence(evidence, source))));
912
+ const blocked = evidence.taskPlan.blockedTargets.map((target) => ({
913
+ kind: 'warning',
914
+ group: 'portableWarnings',
915
+ pluginId: target.target.pluginId,
916
+ relation: 'requested',
917
+ title: `${pluginNameFromId(target.target.pluginId)} 不在本次执行中`,
918
+ description: `${platformLabel(target.target.platform)} · ${scopeLabel(target.target.scope)}`
919
+ + (target.errorCodes?.length ? ` · ${target.errorCodes.join('、')}` : ''),
920
+ }));
921
+ return [
922
+ ...scriptTimeoutChanges(intent),
923
+ ...requested,
924
+ ...causes,
925
+ ...runtime,
926
+ ...blocked,
927
+ ...(evidence.taskPlan.blockedTargets.length > 0 ? [{
928
+ kind: 'warning',
929
+ group: 'portableWarnings',
930
+ title: `${evidence.taskPlan.blockedTargets.length} 个目标不在本次执行中`,
931
+ description: '用户已明确选择先处理可执行子集;阻止项保持不变。',
932
+ }] : []),
933
+ ...(evidence.taskPlan.executableTargets.some((target) => target.scope === 'user') ? [{
934
+ kind: 'warning',
935
+ group: 'requested',
936
+ title: '包含所有项目安装位置',
937
+ description: '这些写入可能影响当前项目之外的使用位置。',
938
+ }] : []),
939
+ { kind: 'keep', group: 'preserved', title: '插件设置保持不变' },
940
+ ];
941
+ }
942
+ function batchReviewChanges(intent, evidence) {
943
+ const changes = evidence.groups.flatMap((group) => {
944
+ const representative = group.requestedPluginIds[0];
945
+ const groupEvidence = batchGroupEvidence(evidence, group);
946
+ const projected = reviewChanges({
947
+ kind: 'pluginWrite',
948
+ action: intent.action,
949
+ pluginId: representative,
950
+ platform: group.platform,
951
+ scope: group.scope,
952
+ ...(intent.scriptTimeoutMs === undefined ? {} : { scriptTimeoutMs: intent.scriptTimeoutMs }),
953
+ }, groupEvidence);
954
+ const targetChanges = group.preview.targetResults.map((target) => {
955
+ const pluginId = target.target.pluginId ?? `${group.sourceId}/${target.target.pluginName}`;
956
+ const requested = group.requestedPluginIds.includes(pluginId);
957
+ return {
958
+ kind: intent.action === 'uninstall' || intent.action === 'cleanup' ? 'remove'
959
+ : intent.action === 'install' ? 'add' : 'change',
960
+ group: requested ? 'requested' : 'dependencies',
961
+ pluginId,
962
+ relation: requested ? 'requested'
963
+ : (target.requiredBy ?? []).some((plugin) => group.requestedPluginIds.includes(plugin))
964
+ ? 'direct' : 'transitive',
965
+ title: pluginNameFromId(pluginId),
966
+ description: `${group.sourceId} · ${target.target.platform === 'codex' ? 'Codex' : 'Claude Code'} · ${target.target.scope === 'user' ? '所有项目' : '当前项目'}${target.state === 'failed' || target.action === 'skipped' ? ` · 无法执行${target.errorCode ? ` (${target.errorCode})` : ''}` : ''}`,
967
+ };
968
+ });
969
+ const selectedTargetChanges = group.preview.targetResults.length === 0
970
+ && (intent.selection.kind === 'targets'
971
+ || intent.selection.kind === 'currentProjectIntentTargets')
972
+ ? intent.selection.targets.filter((target) => target.pluginId.startsWith(`${group.sourceId}/`)
973
+ && target.platform === group.platform
974
+ && target.scope === group.scope).map((target) => ({
975
+ kind: intent.action === 'uninstall' || intent.action === 'cleanup' ? 'remove'
976
+ : intent.action === 'install' ? 'add' : 'change',
977
+ group: 'requested',
978
+ pluginId: target.pluginId,
979
+ relation: 'requested',
980
+ title: pluginNameFromId(target.pluginId),
981
+ description: `${group.sourceId} · ${platformLabel(target.platform)} · ${scopeLabel(target.scope)}`,
982
+ }))
983
+ : [];
984
+ const effective = intent.action === 'cleanup' || group.preview.dependencyPlan
985
+ ? projected
986
+ : [
987
+ ...targetChanges,
988
+ ...selectedTargetChanges,
989
+ ...projected.filter((change) => change.group !== 'requested'
990
+ && change.group !== 'dependencies'),
991
+ ];
992
+ const withVersionEvidence = effective.map((change) => {
993
+ if (change.group !== 'requested' || !change.pluginId)
994
+ return change;
995
+ const version = evidence.targetVersions?.find((target) => target.pluginId === change.pluginId && target.platform === group.platform
996
+ && target.scope === group.scope);
997
+ if (!version)
998
+ return change;
999
+ const summary = version.presence === 'installed'
1000
+ ? version.installedVersion
1001
+ ? `已有安装 ${version.installedVersion}`
1002
+ : '已有安装,版本待确认'
1003
+ : version.presence === 'new'
1004
+ ? `新增${version.scope === 'user' ? '所有项目' : '当前项目'}安装`
1005
+ : '现场状态待确认';
1006
+ const available = version.availableVersion
1007
+ ? ` · 目录版本 ${version.availableVersion}` : '';
1008
+ return {
1009
+ ...change,
1010
+ description: `${change.description ? `${change.description} · ` : ''}${summary}${available}`,
1011
+ };
1012
+ });
1013
+ return [
1014
+ ...withVersionEvidence.filter((change) => change.title !== 'preApply 脚本超时')
1015
+ .map((change) => ({
1016
+ ...change,
1017
+ batchGroupId: group.groupId,
1018
+ sourceId: group.sourceId,
1019
+ })),
1020
+ ...(!group.executable ? [{
1021
+ kind: 'warning',
1022
+ group: 'portableWarnings',
1023
+ batchGroupId: group.groupId,
1024
+ sourceId: group.sourceId,
1025
+ title: `${group.sourceId} 组无法执行`,
1026
+ description: '确认后保留本次预览失败;不会重新求值或开始写入。',
1027
+ }] : []),
1028
+ ];
1029
+ });
1030
+ const projectPreApplyCount = intent.action === 'sync'
1031
+ && intent.selection.kind === 'currentProjectIntentTargets'
1032
+ ? changes.filter((change) => change.title.startsWith('运行 ')
1033
+ && change.title.endsWith(' preApply')).length
1034
+ : 0;
1035
+ return [
1036
+ ...scriptTimeoutChanges(intent),
1037
+ ...(projectPreApplyCount > 0 ? [{
1038
+ kind: 'warning',
1039
+ group: 'runtime',
1040
+ title: `${projectPreApplyCount} 个当前项目同步目标将运行 preApply`,
1041
+ description: '脚本在同步写入前运行;范围只限本次确认的当前项目位置。',
1042
+ }] : []),
1043
+ ...changes,
1044
+ { kind: 'keep', group: 'preserved', title: '插件设置保持不变' },
1045
+ ];
1046
+ }
1047
+ function technicalDetails(evidence) {
1048
+ const short = (value) => {
1049
+ const normalized = value.startsWith('sha256:') ? value.slice(7) : value;
1050
+ return normalized.slice(0, 8);
1051
+ };
1052
+ const details = [
1053
+ `Catalog 配置:${short(evidence.catalog.configDigest)}`,
1054
+ `Catalog 组合:${short(evidence.catalog.compositeDigest)}`,
1055
+ ];
1056
+ if ('groups' in evidence && Array.isArray(evidence.groups)) {
1057
+ const batch = evidence;
1058
+ details.push(`批量根插件:${batch.requestedPluginIds.length} 个`);
1059
+ for (const group of batch.groups) {
1060
+ details.push(`批量分组:${group.sourceId} · ${group.platform} · ${group.requestedPluginIds.length} 个根插件 · ${group.executable ? `计划 ${short(group.preview.operationPlan.planFingerprint)}` : '预览失败'}`);
1061
+ }
1062
+ }
1063
+ if ('taskPlan' in evidence) {
1064
+ const task = evidence;
1065
+ details.push(`任务目标:${task.taskPlan.requestedTargets.length} 个`);
1066
+ details.push(`可执行目标:${task.taskPlan.executableTargets.length} 个`);
1067
+ details.push(`共同原因:${task.taskPlan.causes.length} 个`);
1068
+ for (const source of task.taskPlan.sources) {
1069
+ details.push(`任务来源:${source.sourceId} · ${source.requestedTargets.length} 个目标 · 计划 ${short(source.preview.operationPlan.planFingerprint)}`);
1070
+ }
1071
+ }
1072
+ if (evidence.catalog.generationSetDigest) {
1073
+ details.push(`Catalog generation:${short(evidence.catalog.generationSetDigest)}`);
1074
+ }
1075
+ if (evidence.source) {
1076
+ details.push(`来源:${evidence.source.sourceId}`);
1077
+ if (evidence.source.sourceIdentity)
1078
+ details.push(`来源身份:${short(evidence.source.sourceIdentity)}`);
1079
+ if (evidence.source.resolvedCommit)
1080
+ details.push(`Snapshot commit:${short(evidence.source.resolvedCommit)}`);
1081
+ if (evidence.source.snapshotDigest)
1082
+ details.push(`Snapshot digest:${short(evidence.source.snapshotDigest)}`);
1083
+ if (evidence.source.contentDigest)
1084
+ details.push(`Content digest:${short(evidence.source.contentDigest)}`);
1085
+ }
1086
+ if (evidence.targetFingerprint)
1087
+ details.push(`目标状态:${short(evidence.targetFingerprint)}`);
1088
+ details.push(...(evidence.preparationWarnings ?? []).map((warning) => `刷新警告:${warning}`));
1089
+ for (const target of offlineCleanupPlans(evidence)) {
1090
+ details.push(`离线清理目标:${target.pluginId} · ${target.platform}/${target.scope}`);
1091
+ details.push(`离线清理计划:${target.plan.actions.length} 个动作 · ${short(target.planDigest)}`);
1092
+ }
1093
+ if (evidence.dependencyPlan)
1094
+ details.push(`安装计划:${evidence.dependencyPlan.resolvedPluginIds.length} 个插件`);
1095
+ if (evidence.config)
1096
+ details.push(`设置层:${evidence.config.scope} · ${short(evidence.config.storeDigest)}`);
1097
+ for (const group of evidence.configBatch?.groups ?? []) {
1098
+ details.push(`设置层:${group.scope} · ${short(group.config.storeDigest)}`);
1099
+ }
1100
+ if (evidence.sourceWrite) {
1101
+ details.push(`新配置:${short(evidence.sourceWrite.proposedConfigDigest)}`);
1102
+ details.push(`引用清单:${short(evidence.sourceWrite.inventoryDigest)} · ${evidence.sourceWrite.referenceCount} 项`);
1103
+ }
1104
+ if (evidence.catalogGeneration) {
1105
+ const generation = evidence.catalogGeneration;
1106
+ details.push(`候选版本:${generation.candidate.catalogVersion}`);
1107
+ details.push(`候选 commit:${short(generation.candidate.resolvedCommit)}`);
1108
+ details.push(`候选 digest:${short(generation.candidate.snapshotDigest)}`);
1109
+ const impact = generation.impact;
1110
+ if (impact) {
1111
+ const referenceKey = (reference) => [
1112
+ reference.category,
1113
+ reference.sourceId,
1114
+ reference.pluginId ?? '',
1115
+ reference.platform ?? '',
1116
+ reference.scope ?? '',
1117
+ reference.projectRecord ?? '',
1118
+ reference.marketplaceName ?? '',
1119
+ ].join('\0');
1120
+ const affected = new Set(impact.affectedReferences.map(referenceKey));
1121
+ const categoryLabel = {
1122
+ installation: '安装',
1123
+ config: '设置',
1124
+ lifecycle: '生命周期',
1125
+ marketplace: 'Marketplace',
1126
+ };
1127
+ for (const reference of impact.references) {
1128
+ const location = [
1129
+ reference.platform ? platformLabel(reference.platform) : undefined,
1130
+ reference.scope ? scopeLabel(reference.scope) : undefined,
1131
+ reference.projectRecord === 'current' ? '当前项目'
1132
+ : reference.projectRecord === 'historical' ? '历史项目'
1133
+ : reference.projectRecord === 'unknown' ? '项目未知' : undefined,
1134
+ ].filter((value) => Boolean(value)).join(' · ');
1135
+ details.push([
1136
+ `引用影响:${affected.has(referenceKey(reference)) ? '受影响' : '未受本次变化影响'}`,
1137
+ categoryLabel[reference.category],
1138
+ reference.pluginId ?? reference.marketplaceName ?? reference.sourceId,
1139
+ location || undefined,
1140
+ ].filter((value) => Boolean(value)).join(' · '));
1141
+ }
1142
+ }
1143
+ }
1144
+ if (evidence.catalogStore) {
1145
+ details.push(`已授权清理:${evidence.catalogStore.authorizedItems.length} 项`);
1146
+ details.push(`检查结果:${evidence.catalogStore.entries.length} 项`);
1147
+ }
1148
+ if (evidence.portable) {
1149
+ details.push(`Portable 候选:${evidence.portable.selected.length} 个`);
1150
+ details.push(`Materialization:${short(evidence.portable.materializationDigest)}`);
1151
+ details.push(`Skills CLI:${evidence.portable.skillsCliVersion}`);
1152
+ }
1153
+ return details;
1154
+ }
1155
+ export function buildOperationReviewProjection(options) {
1156
+ const { intent, evidence } = options;
1157
+ const batchEvidence = intent.kind === 'pluginWriteBatch'
1158
+ ? evidence
1159
+ : undefined;
1160
+ const taskEvidence = intent.kind === 'pluginWriteTask'
1161
+ ? evidence
1162
+ : undefined;
1163
+ const labels = operationLabels(intent, evidence);
1164
+ const hasPreApply = intent.kind === 'pluginWriteBatch'
1165
+ ? Boolean(batchEvidence?.groups.some((group) => operationPreApplyTargets(batchGroupEvidence(batchEvidence, group)).length > 0))
1166
+ : intent.kind === 'pluginWriteTask'
1167
+ ? Boolean(taskEvidence?.taskPlan.sources.some((source) => operationPreApplyTargets(taskSourceEvidence(taskEvidence, source)).length > 0))
1168
+ : intent.kind === 'configSaveBatch'
1169
+ ? evidence.configBatch?.groups.some((group) => (group.config.preApplyAuthorization?.length ?? 0) > 0) === true
1170
+ : operationPreApplyTargets(evidence).length > 0
1171
+ || (evidence.config?.preApplyAuthorization?.length ?? 0) > 0;
1172
+ const projectPreApplyConfirmation = hasPreApply
1173
+ && intent.kind === 'pluginWriteBatch'
1174
+ && intent.action === 'sync'
1175
+ && intent.selection.kind === 'currentProjectIntentTargets';
1176
+ const sharedNativeConfigApply = (intent.kind === 'configSave'
1177
+ && intent.apply
1178
+ && (evidence.config?.sharedNativeRenderTargets?.length ?? 0) > 0
1179
+ && (evidence.config?.affectedTargets.some((target) => target.platform === 'codex') ?? false))
1180
+ || (intent.kind === 'configSaveBatch'
1181
+ && intent.apply
1182
+ && (evidence.configBatch?.groups.some((group) => (group.config.sharedNativeRenderTargets?.length ?? 0) > 0
1183
+ && group.config.affectedTargets.some((target) => target.platform === 'codex')) ?? false));
1184
+ const requiresConfirmation = projectPreApplyConfirmation
1185
+ || sharedNativeConfigApply
1186
+ || intent.kind === 'catalogStorePrune'
1187
+ || Boolean(batchEvidence?.groups.some((group) => (group.preview.codexReconcilePlans ?? []).some((plan) => plan.review.requiresConfirmation)))
1188
+ || Boolean(taskEvidence?.taskPlan.sources.some((source) => (source.preview.codexReconcilePlans ?? []).some((plan) => plan.review.requiresConfirmation)))
1189
+ || (evidence.codexReconcilePlans ?? []).some((plan) => plan.review.requiresConfirmation)
1190
+ || Boolean(evidence.sourceWrite
1191
+ && (!evidence.sourceWrite.inventoryComplete || evidence.sourceWrite.referenceCount > 0))
1192
+ || Boolean(evidence.catalogGeneration?.impact
1193
+ && (!evidence.catalogGeneration.impact.inventoryComplete
1194
+ || evidence.catalogGeneration.impact.affectedReferences.length > 0))
1195
+ || Boolean(evidence.catalogGeneration?.primaryImpact
1196
+ && (!evidence.catalogGeneration.primaryImpact.inventoryComplete
1197
+ || evidence.catalogGeneration.primaryImpact.affectedReferences.length > 0));
1198
+ const warning = (evidence.codexReconcilePlans ?? []).find((plan) => plan.review.sharedImpact.warning)?.review.sharedImpact.warning
1199
+ ?? batchEvidence?.groups.flatMap((group) => group.preview.codexReconcilePlans ?? [])
1200
+ .find((plan) => plan.review.sharedImpact.warning)?.review.sharedImpact.warning
1201
+ ?? taskEvidence?.taskPlan.sources.flatMap((source) => source.preview.codexReconcilePlans ?? [])
1202
+ .find((plan) => plan.review.sharedImpact.warning)?.review.sharedImpact.warning;
1203
+ const preparationWarnings = (evidence.preparationWarnings ?? []).map(() => ({
1204
+ kind: 'warning',
1205
+ group: 'portableWarnings',
1206
+ title: '来源刷新失败;本次使用旧 Active',
1207
+ description: '同步可以继续。再次刷新并同步时会重试来源刷新。',
1208
+ }));
1209
+ return {
1210
+ title: labels.title,
1211
+ description: labels.description,
1212
+ changes: [
1213
+ ...preparationWarnings,
1214
+ ...(intent.kind === 'pluginWriteBatch'
1215
+ ? batchReviewChanges(intent, batchEvidence)
1216
+ : intent.kind === 'pluginWriteTask'
1217
+ ? taskReviewChanges(intent, taskEvidence)
1218
+ : reviewChanges(intent, evidence, options.dependencyOverview)),
1219
+ ],
1220
+ technicalDetails: technicalDetails(evidence),
1221
+ ...(intent.kind === 'pluginWrite'
1222
+ ? { equivalentCommand: `aw ${intent.action === 'refreshAndSync' ? 'sync' : intent.action} ${intent.pluginId} --platform ${intent.platform} --scope ${intent.scope}${intent.action === 'refreshAndSync' ? ' --refresh' : ''}${scriptTimeoutChanges(intent).length > 0 ? ` --script-timeout ${parseScriptTimeoutMs(intent.scriptTimeoutMs ?? SCRIPT_TIMEOUT_DEFAULT_MS)}` : ''}${(intent.dependencyScopeOverrides ?? []).map((override) => ` --dependency-scope ${override.pluginId}#${override.platform}=${override.scope}`).join('')}${intent.action === 'cleanup' && intent.force === true ? ' --force' : ''}${evidence.codexManager?.state === 'requires-install' ? ' --allow-managed-codex-install' : ''}${requiresConfirmation || hasPreApply ? ' --yes' : ''}` }
1223
+ : {}),
1224
+ primaryLabel: intent.kind === 'pluginWriteBatch'
1225
+ ? `${labels.primaryLabel} ${batchEvidence.requestedPluginIds.length} 个插件`
1226
+ : intent.kind === 'pluginWriteTask'
1227
+ ? `${labels.primaryLabel} ${taskEvidence.taskPlan.executableTargets.length} 个安装位置`
1228
+ : intent.kind === 'pluginWrite' && evidence.dependencyPlan
1229
+ ? `${labels.primaryLabel} ${evidence.dependencyPlan.resolvedPluginIds.length} 个插件`
1230
+ : labels.primaryLabel,
1231
+ ...(labels.destructive ? { destructive: true } : {}),
1232
+ requiresConfirmation,
1233
+ sharedImpact: {
1234
+ pluginIds: [...new Set([
1235
+ ...(evidence.codexReconcilePlans ?? []).flatMap((plan) => plan.review.sharedImpact.pluginIds),
1236
+ ...(batchEvidence?.groups.flatMap((group) => (group.preview.codexReconcilePlans ?? []).flatMap((plan) => plan.review.sharedImpact.pluginIds)) ?? []),
1237
+ ...(taskEvidence?.taskPlan.sources.flatMap((source) => (source.preview.codexReconcilePlans ?? []).flatMap((plan) => plan.review.sharedImpact.pluginIds)) ?? []),
1238
+ ...(evidence.sourceWrite?.impact?.affectedReferences ?? []).flatMap((reference) => reference.pluginId ? [reference.pluginId] : []),
1239
+ ...(evidence.catalogGeneration?.impact?.affectedReferences ?? []).flatMap((reference) => reference.pluginId ? [reference.pluginId] : []),
1240
+ ...(evidence.catalogGeneration?.primaryImpact?.affectedReferences ?? []).flatMap((reference) => reference.pluginId ? [reference.pluginId] : []),
1241
+ ...(sharedNativeConfigApply && 'pluginId' in intent ? [intent.pluginId] : []),
1242
+ ])],
1243
+ ...(warning ? { warning }
1244
+ : sharedNativeConfigApply
1245
+ ? { warning: '更新被共用的 Codex native 动态 Skill 会影响所有启用项目。' }
1246
+ : requiresConfirmation && (evidence.sourceWrite
1247
+ || evidence.catalogGeneration?.impact
1248
+ || evidence.catalogGeneration?.primaryImpact)
1249
+ ? { warning: '确认来源影响后才会继续。未知影响不会按零处理。' }
1250
+ : {}),
1251
+ },
1252
+ };
1253
+ }
1254
+ //# sourceMappingURL=operation-review-planner.js.map