@lesliechan721/aw 0.1.0-beta.6 → 0.1.0-beta.60

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