@lesliechan721/aw 0.1.0-beta.84 → 0.1.0-beta.86

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 (339) hide show
  1. package/dist/authoring/assets/command-runtime-config.d.mts +9 -0
  2. package/dist/authoring/assets/command-runtime-config.mjs +106 -0
  3. package/dist/authoring/assets/command-runtime-config.mjs.map +1 -0
  4. package/dist/authoring/scripts/validate-plugin.mjs +17 -22
  5. package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
  6. package/dist/index.js +2 -6
  7. package/dist/index.js.map +1 -1
  8. package/dist/scripts/aw-skill-eval-materializer.d.ts +4 -0
  9. package/dist/scripts/aw-skill-eval-materializer.js +27 -0
  10. package/dist/scripts/aw-skill-eval-materializer.js.map +1 -1
  11. package/dist/scripts/bundle-plugins.js +1 -1
  12. package/dist/scripts/bundle-plugins.js.map +1 -1
  13. package/dist/scripts/test-plugin-scripts.js +13 -2
  14. package/dist/scripts/test-plugin-scripts.js.map +1 -1
  15. package/dist/src/commands/aw-capabilities.d.ts +1 -1
  16. package/dist/src/commands/aw-capabilities.js +2 -2
  17. package/dist/src/commands/catalog-source.d.ts +2 -1
  18. package/dist/src/commands/catalog-source.js +8 -7
  19. package/dist/src/commands/catalog-source.js.map +1 -1
  20. package/dist/src/commands/deployment-confirmation.d.ts +8 -1
  21. package/dist/src/commands/deployment-confirmation.js +79 -11
  22. package/dist/src/commands/deployment-confirmation.js.map +1 -1
  23. package/dist/src/commands/lifecycle-command-package.d.ts +44 -0
  24. package/dist/src/commands/lifecycle-command-package.js +195 -0
  25. package/dist/src/commands/lifecycle-command-package.js.map +1 -0
  26. package/dist/src/commands/managed-commands.d.ts +6 -0
  27. package/dist/src/commands/managed-commands.js +203 -152
  28. package/dist/src/commands/managed-commands.js.map +1 -1
  29. package/dist/src/commands/operation-plan.d.ts +22 -21
  30. package/dist/src/commands/operation-plan.js +2 -5
  31. package/dist/src/commands/operation-plan.js.map +1 -1
  32. package/dist/src/commands/permission-batch.d.ts +5 -0
  33. package/dist/src/commands/permission-batch.js +80 -0
  34. package/dist/src/commands/permission-batch.js.map +1 -0
  35. package/dist/src/commands/plugin-capabilities.js +17 -13
  36. package/dist/src/commands/plugin-capabilities.js.map +1 -1
  37. package/dist/src/commands/public-config-confirmation.d.ts +8 -2
  38. package/dist/src/commands/public-config-confirmation.js +22 -5
  39. package/dist/src/commands/public-config-confirmation.js.map +1 -1
  40. package/dist/src/commands/public-lifecycle-result.d.ts +7 -12
  41. package/dist/src/commands/public-lifecycle-result.js +136 -40
  42. package/dist/src/commands/public-lifecycle-result.js.map +1 -1
  43. package/dist/src/commands/public-lifecycle.js +49 -8
  44. package/dist/src/commands/public-lifecycle.js.map +1 -1
  45. package/dist/src/commands/public-plugin-query.js +21 -5
  46. package/dist/src/commands/public-plugin-query.js.map +1 -1
  47. package/dist/src/commands/rebuild-command.d.ts +4 -0
  48. package/dist/src/commands/rebuild-command.js +150 -48
  49. package/dist/src/commands/rebuild-command.js.map +1 -1
  50. package/dist/src/commands/rebuild-integration.d.ts +12 -3
  51. package/dist/src/commands/rebuild-integration.js +52 -164
  52. package/dist/src/commands/rebuild-integration.js.map +1 -1
  53. package/dist/src/commands/rebuild-operations.d.ts +2 -1
  54. package/dist/src/commands/rebuild-operations.js +7 -2
  55. package/dist/src/commands/rebuild-operations.js.map +1 -1
  56. package/dist/src/commands/rebuild-platform-integration.d.ts +12 -5
  57. package/dist/src/commands/rebuild-platform-integration.js +691 -186
  58. package/dist/src/commands/rebuild-platform-integration.js.map +1 -1
  59. package/dist/src/commands/skill-eval.js +10 -1
  60. package/dist/src/commands/skill-eval.js.map +1 -1
  61. package/dist/src/generators/local-plugin.js +14 -15
  62. package/dist/src/generators/local-plugin.js.map +1 -1
  63. package/dist/src/generators/permissions.d.ts +18 -4
  64. package/dist/src/generators/permissions.js +76 -22
  65. package/dist/src/generators/permissions.js.map +1 -1
  66. package/dist/src/index.d.ts +1 -0
  67. package/dist/src/index.js +84 -44
  68. package/dist/src/index.js.map +1 -1
  69. package/dist/src/intent/scope-context.d.ts +4 -2
  70. package/dist/src/intent/scope-context.js +37 -7
  71. package/dist/src/intent/scope-context.js.map +1 -1
  72. package/dist/src/output/command-receipt.js +7 -8
  73. package/dist/src/output/command-receipt.js.map +1 -1
  74. package/dist/src/output/component-delivery.d.ts +28 -0
  75. package/dist/src/output/component-delivery.js +138 -0
  76. package/dist/src/output/component-delivery.js.map +1 -0
  77. package/dist/src/output/public-result.d.ts +17 -0
  78. package/dist/src/output/public-result.js +121 -25
  79. package/dist/src/output/public-result.js.map +1 -1
  80. package/dist/src/output/rebuild-progress.js +7 -4
  81. package/dist/src/output/rebuild-progress.js.map +1 -1
  82. package/dist/src/output/receipt-projection.js +51 -31
  83. package/dist/src/output/receipt-projection.js.map +1 -1
  84. package/dist/src/output/skill-invocation-notices.d.ts +2 -0
  85. package/dist/src/output/skill-invocation-notices.js +40 -4
  86. package/dist/src/output/skill-invocation-notices.js.map +1 -1
  87. package/dist/src/platforms/antigravity-permissions.d.ts +50 -0
  88. package/dist/src/platforms/antigravity-permissions.js +388 -0
  89. package/dist/src/platforms/antigravity-permissions.js.map +1 -0
  90. package/dist/src/platforms/capabilities.d.ts +4 -1
  91. package/dist/src/platforms/capabilities.js +93 -9
  92. package/dist/src/platforms/capabilities.js.map +1 -1
  93. package/dist/src/platforms/contracts.d.ts +46 -2
  94. package/dist/src/platforms/discovery.d.ts +13 -0
  95. package/dist/src/platforms/discovery.js +170 -30
  96. package/dist/src/platforms/discovery.js.map +1 -1
  97. package/dist/src/platforms/grok-permission-config.d.ts +22 -0
  98. package/dist/src/platforms/grok-permission-config.js +184 -0
  99. package/dist/src/platforms/grok-permission-config.js.map +1 -0
  100. package/dist/src/platforms/grok-permission-document.d.ts +4 -0
  101. package/dist/src/platforms/grok-permission-document.js +145 -0
  102. package/dist/src/platforms/grok-permission-document.js.map +1 -0
  103. package/dist/src/platforms/grok-permissions.d.ts +17 -0
  104. package/dist/src/platforms/grok-permissions.js +311 -0
  105. package/dist/src/platforms/grok-permissions.js.map +1 -0
  106. package/dist/src/platforms/host-permission-policy.d.ts +38 -0
  107. package/dist/src/platforms/host-permission-policy.js +86 -0
  108. package/dist/src/platforms/host-permission-policy.js.map +1 -0
  109. package/dist/src/platforms/inspection-grok.js +165 -11
  110. package/dist/src/platforms/inspection-grok.js.map +1 -1
  111. package/dist/src/platforms/inspection-native.js +53 -18
  112. package/dist/src/platforms/inspection-native.js.map +1 -1
  113. package/dist/src/platforms/inspection-pi.d.ts +7 -1
  114. package/dist/src/platforms/inspection-pi.js +295 -95
  115. package/dist/src/platforms/inspection-pi.js.map +1 -1
  116. package/dist/src/platforms/inspection-query.d.ts +4 -2
  117. package/dist/src/platforms/inspection-query.js +24 -8
  118. package/dist/src/platforms/inspection-query.js.map +1 -1
  119. package/dist/src/platforms/inspection.d.ts +4 -1
  120. package/dist/src/platforms/inspection.js +36 -4
  121. package/dist/src/platforms/inspection.js.map +1 -1
  122. package/dist/src/platforms/layout.d.ts +13 -0
  123. package/dist/src/platforms/layout.js +90 -12
  124. package/dist/src/platforms/layout.js.map +1 -1
  125. package/dist/src/platforms/lifecycle-native.d.ts +1 -0
  126. package/dist/src/platforms/lifecycle-native.js +25 -1
  127. package/dist/src/platforms/lifecycle-native.js.map +1 -1
  128. package/dist/src/platforms/lifecycle.d.ts +2 -0
  129. package/dist/src/platforms/lifecycle.js +98 -25
  130. package/dist/src/platforms/lifecycle.js.map +1 -1
  131. package/dist/src/platforms/opencode-permission-config.d.ts +13 -0
  132. package/dist/src/platforms/opencode-permission-config.js +253 -0
  133. package/dist/src/platforms/opencode-permission-config.js.map +1 -0
  134. package/dist/src/platforms/opencode-permissions.d.ts +39 -0
  135. package/dist/src/platforms/opencode-permissions.js +212 -0
  136. package/dist/src/platforms/opencode-permissions.js.map +1 -0
  137. package/dist/src/platforms/opencode-related-permissions.d.ts +40 -0
  138. package/dist/src/platforms/opencode-related-permissions.js +177 -0
  139. package/dist/src/platforms/opencode-related-permissions.js.map +1 -0
  140. package/dist/src/platforms/permission-ownership.d.ts +89 -0
  141. package/dist/src/platforms/permission-ownership.js +543 -0
  142. package/dist/src/platforms/permission-ownership.js.map +1 -0
  143. package/dist/src/platforms/permission-sidecar.d.ts +70 -0
  144. package/dist/src/platforms/permission-sidecar.js +215 -0
  145. package/dist/src/platforms/permission-sidecar.js.map +1 -0
  146. package/dist/src/platforms/projection-code-extension.js +2 -1
  147. package/dist/src/platforms/projection-code-extension.js.map +1 -1
  148. package/dist/src/platforms/projection.js +127 -29
  149. package/dist/src/platforms/projection.js.map +1 -1
  150. package/dist/src/platforms/supplement-layout.d.ts +5 -1
  151. package/dist/src/platforms/supplement-layout.js +23 -1
  152. package/dist/src/platforms/supplement-layout.js.map +1 -1
  153. package/dist/src/platforms/supplement-state.d.ts +1 -1
  154. package/dist/src/platforms/supplement-state.js +18 -7
  155. package/dist/src/platforms/supplement-state.js.map +1 -1
  156. package/dist/src/portable/commands.js +1 -1
  157. package/dist/src/portable/commands.js.map +1 -1
  158. package/dist/src/portable/materializer.d.ts +4 -0
  159. package/dist/src/portable/materializer.js +8 -1
  160. package/dist/src/portable/materializer.js.map +1 -1
  161. package/dist/src/portable/recovery.d.ts +2 -0
  162. package/dist/src/portable/recovery.js +45 -8
  163. package/dist/src/portable/recovery.js.map +1 -1
  164. package/dist/src/recovery/coordinator.d.ts +3 -1
  165. package/dist/src/recovery/coordinator.js +101 -37
  166. package/dist/src/recovery/coordinator.js.map +1 -1
  167. package/dist/src/recovery/install-concurrency.js +3 -2
  168. package/dist/src/recovery/install-concurrency.js.map +1 -1
  169. package/dist/src/recovery/joint-coordinator.d.ts +7 -0
  170. package/dist/src/recovery/joint-coordinator.js +270 -64
  171. package/dist/src/recovery/joint-coordinator.js.map +1 -1
  172. package/dist/src/recovery/joint-demand.d.ts +14 -2
  173. package/dist/src/recovery/joint-demand.js +54 -7
  174. package/dist/src/recovery/joint-demand.js.map +1 -1
  175. package/dist/src/recovery/joint-install-execution.js +2 -1
  176. package/dist/src/recovery/joint-install-execution.js.map +1 -1
  177. package/dist/src/recovery/receipt.d.ts +15 -4
  178. package/dist/src/recovery/receipt.js +23 -0
  179. package/dist/src/recovery/receipt.js.map +1 -1
  180. package/dist/src/recovery/retirement.js +11 -17
  181. package/dist/src/recovery/retirement.js.map +1 -1
  182. package/dist/src/recovery/status.d.ts +20 -8
  183. package/dist/src/recovery/status.js +411 -91
  184. package/dist/src/recovery/status.js.map +1 -1
  185. package/dist/src/review/eval-source-input.d.ts +1 -0
  186. package/dist/src/review/eval-source-input.js +7 -1
  187. package/dist/src/review/eval-source-input.js.map +1 -1
  188. package/dist/src/review/platform-profile.js +2 -1
  189. package/dist/src/review/platform-profile.js.map +1 -1
  190. package/dist/src/review/review-selection.js +12 -5
  191. package/dist/src/review/review-selection.js.map +1 -1
  192. package/dist/src/review/skill-materialization.d.ts +2 -1
  193. package/dist/src/review/skill-materialization.js +45 -43
  194. package/dist/src/review/skill-materialization.js.map +1 -1
  195. package/dist/src/review/source-binding.js +5 -1
  196. package/dist/src/review/source-binding.js.map +1 -1
  197. package/dist/src/tui/console-app-v4.js +101 -57
  198. package/dist/src/tui/console-app-v4.js.map +1 -1
  199. package/dist/src/tui/controller-runtime.js +72 -7
  200. package/dist/src/tui/controller-runtime.js.map +1 -1
  201. package/dist/src/tui/controller.d.ts +6 -2
  202. package/dist/src/tui/controller.js +17 -4
  203. package/dist/src/tui/controller.js.map +1 -1
  204. package/dist/src/tui/deployment-view.d.ts +6 -3
  205. package/dist/src/tui/deployment-view.js +52 -10
  206. package/dist/src/tui/deployment-view.js.map +1 -1
  207. package/dist/src/tui/diagnostic-projection.d.ts +7 -1
  208. package/dist/src/tui/diagnostic-projection.js +55 -5
  209. package/dist/src/tui/diagnostic-projection.js.map +1 -1
  210. package/dist/src/tui/entity-cards.d.ts +2 -1
  211. package/dist/src/tui/entity-cards.js +34 -11
  212. package/dist/src/tui/entity-cards.js.map +1 -1
  213. package/dist/src/tui/glossary.js +5 -0
  214. package/dist/src/tui/glossary.js.map +1 -1
  215. package/dist/src/tui/model.js +2 -1
  216. package/dist/src/tui/model.js.map +1 -1
  217. package/dist/src/tui/operation-diagnostic-screens.js +3 -1
  218. package/dist/src/tui/operation-diagnostic-screens.js.map +1 -1
  219. package/dist/src/tui/operation-history.d.ts +6 -0
  220. package/dist/src/tui/operation-history.js +20 -2
  221. package/dist/src/tui/operation-history.js.map +1 -1
  222. package/dist/src/tui/operation-review-planner.js +130 -70
  223. package/dist/src/tui/operation-review-planner.js.map +1 -1
  224. package/dist/src/tui/plugin-detail.d.ts +4 -1
  225. package/dist/src/tui/plugin-detail.js +9 -2
  226. package/dist/src/tui/plugin-detail.js.map +1 -1
  227. package/dist/src/tui/scoped-flow.js +34 -16
  228. package/dist/src/tui/scoped-flow.js.map +1 -1
  229. package/dist/src/tui/scoped-inventory.d.ts +6 -2
  230. package/dist/src/tui/scoped-inventory.js +29 -7
  231. package/dist/src/tui/scoped-inventory.js.map +1 -1
  232. package/dist/src/types.d.ts +10 -21
  233. package/dist/src/types.js.map +1 -1
  234. package/dist/src/utils/artifact-plan.d.ts +3 -36
  235. package/dist/src/utils/artifact-plan.js +16 -78
  236. package/dist/src/utils/artifact-plan.js.map +1 -1
  237. package/dist/src/utils/artifact-renderer.d.ts +1 -60
  238. package/dist/src/utils/artifact-renderer.js +31 -57
  239. package/dist/src/utils/artifact-renderer.js.map +1 -1
  240. package/dist/src/utils/artifact-request.d.ts +3 -26
  241. package/dist/src/utils/artifact-request.js +13 -36
  242. package/dist/src/utils/artifact-request.js.map +1 -1
  243. package/dist/src/utils/artifact-sources.d.ts +0 -8
  244. package/dist/src/utils/artifact-sources.js +0 -8
  245. package/dist/src/utils/artifact-sources.js.map +1 -1
  246. package/dist/src/utils/bundle-layout.js +2 -7
  247. package/dist/src/utils/bundle-layout.js.map +1 -1
  248. package/dist/src/utils/catalog-source-references.js +22 -3
  249. package/dist/src/utils/catalog-source-references.js.map +1 -1
  250. package/dist/src/utils/codex-native-observation.d.ts +6 -0
  251. package/dist/src/utils/codex-native-observation.js +32 -3
  252. package/dist/src/utils/codex-native-observation.js.map +1 -1
  253. package/dist/src/utils/component-command-preparation.d.ts +8 -11
  254. package/dist/src/utils/component-command-preparation.js +110 -210
  255. package/dist/src/utils/component-command-preparation.js.map +1 -1
  256. package/dist/src/utils/component-gap.d.ts +4 -0
  257. package/dist/src/utils/component-gap.js +20 -0
  258. package/dist/src/utils/component-gap.js.map +1 -0
  259. package/dist/src/utils/component-resources.js +2 -4
  260. package/dist/src/utils/component-resources.js.map +1 -1
  261. package/dist/src/utils/dynamic-skill-tree.js +2 -32
  262. package/dist/src/utils/dynamic-skill-tree.js.map +1 -1
  263. package/dist/src/utils/managed-command-cli-review.d.ts +43 -0
  264. package/dist/src/utils/managed-command-cli-review.js +389 -0
  265. package/dist/src/utils/managed-command-cli-review.js.map +1 -0
  266. package/dist/src/utils/managed-command-closure.d.ts +14 -3
  267. package/dist/src/utils/managed-command-closure.js +144 -23
  268. package/dist/src/utils/managed-command-closure.js.map +1 -1
  269. package/dist/src/utils/managed-command-errors.d.ts +5 -0
  270. package/dist/src/utils/managed-command-errors.js +10 -0
  271. package/dist/src/utils/managed-command-errors.js.map +1 -0
  272. package/dist/src/utils/managed-command-materialization.d.ts +77 -113
  273. package/dist/src/utils/managed-command-materialization.js +324 -323
  274. package/dist/src/utils/managed-command-materialization.js.map +1 -1
  275. package/dist/src/utils/managed-command-preparation.d.ts +28 -65
  276. package/dist/src/utils/managed-command-preparation.js +33 -140
  277. package/dist/src/utils/managed-command-preparation.js.map +1 -1
  278. package/dist/src/utils/managed-command-review.d.ts +11 -4
  279. package/dist/src/utils/managed-command-review.js +33 -21
  280. package/dist/src/utils/managed-command-review.js.map +1 -1
  281. package/dist/src/utils/managed-command-runtime.d.ts +1 -0
  282. package/dist/src/utils/managed-command-runtime.js +6 -3
  283. package/dist/src/utils/managed-command-runtime.js.map +1 -1
  284. package/dist/src/utils/managed-command-snapshots.d.ts +17 -0
  285. package/dist/src/utils/managed-command-snapshots.js +84 -0
  286. package/dist/src/utils/managed-command-snapshots.js.map +1 -0
  287. package/dist/src/utils/managed-command-store.d.ts +65 -78
  288. package/dist/src/utils/managed-command-store.js +446 -383
  289. package/dist/src/utils/managed-command-store.js.map +1 -1
  290. package/dist/src/utils/multi-source-catalog.d.ts +2 -0
  291. package/dist/src/utils/multi-source-catalog.js +3 -1
  292. package/dist/src/utils/multi-source-catalog.js.map +1 -1
  293. package/dist/src/utils/native-cli-interruption.d.ts +8 -0
  294. package/dist/src/utils/native-cli-interruption.js +65 -0
  295. package/dist/src/utils/native-cli-interruption.js.map +1 -0
  296. package/dist/src/utils/native-cli.d.ts +5 -0
  297. package/dist/src/utils/native-cli.js +166 -53
  298. package/dist/src/utils/native-cli.js.map +1 -1
  299. package/dist/src/utils/native-tool-context.d.ts +6 -3
  300. package/dist/src/utils/native-tool-context.js +3 -1
  301. package/dist/src/utils/native-tool-context.js.map +1 -1
  302. package/dist/src/utils/native-tool-review.d.ts +2 -12
  303. package/dist/src/utils/native-tool-review.js +6 -108
  304. package/dist/src/utils/native-tool-review.js.map +1 -1
  305. package/dist/src/utils/ownership.d.ts +8 -0
  306. package/dist/src/utils/ownership.js +17 -3
  307. package/dist/src/utils/ownership.js.map +1 -1
  308. package/dist/src/utils/package-content.d.ts +7 -0
  309. package/dist/src/utils/package-content.js +70 -0
  310. package/dist/src/utils/package-content.js.map +1 -0
  311. package/dist/src/utils/platform-empty-state.d.ts +32 -6
  312. package/dist/src/utils/platform-empty-state.js +146 -75
  313. package/dist/src/utils/platform-empty-state.js.map +1 -1
  314. package/dist/src/utils/plugin-config-command-apply.d.ts +33 -0
  315. package/dist/src/utils/plugin-config-command-apply.js +134 -0
  316. package/dist/src/utils/plugin-config-command-apply.js.map +1 -0
  317. package/dist/src/utils/plugin-config-impact.d.ts +19 -9
  318. package/dist/src/utils/plugin-config-impact.js +56 -37
  319. package/dist/src/utils/plugin-config-impact.js.map +1 -1
  320. package/dist/src/utils/plugin-config-write.d.ts +19 -19
  321. package/dist/src/utils/plugin-config-write.js +196 -770
  322. package/dist/src/utils/plugin-config-write.js.map +1 -1
  323. package/dist/src/utils/plugin-scripts.js +19 -8
  324. package/dist/src/utils/plugin-scripts.js.map +1 -1
  325. package/dist/src/utils/process-tree.d.ts +1 -1
  326. package/dist/src/utils/process-tree.js +1 -1
  327. package/dist/src/utils/process-tree.js.map +1 -1
  328. package/dist/src/utils/rendered-contract.js +12 -6
  329. package/dist/src/utils/rendered-contract.js.map +1 -1
  330. package/dist/src/utils/skill-invocation-warning.d.ts +8 -3
  331. package/dist/src/utils/skill-invocation-warning.js +27 -1
  332. package/dist/src/utils/skill-invocation-warning.js.map +1 -1
  333. package/package.json +4 -3
  334. package/dist/src/platforms/managed-command-placement.d.ts +0 -8
  335. package/dist/src/platforms/managed-command-placement.js +0 -79
  336. package/dist/src/platforms/managed-command-placement.js.map +0 -1
  337. package/dist/src/utils/managed-command-evidence.d.ts +0 -7
  338. package/dist/src/utils/managed-command-evidence.js +0 -10
  339. package/dist/src/utils/managed-command-evidence.js.map +0 -1
@@ -1,35 +1,156 @@
1
+ import { createHash } from 'node:crypto';
1
2
  import path from 'node:path';
2
3
  import fs from 'fs-extra';
3
- import { validateCommandEntryFiles } from '@lesliechan721/aw-plugin-core/manifest';
4
+ import { canonicalizeIdentityValue, getCommandPackageInjectedReaders, validateCommandEntryFiles, validateManagedCommandSources, } from '@lesliechan721/aw-plugin-core/manifest';
5
+ import { listCatalogBundleFiles } from '@lesliechan721/aw-plugin-core';
6
+ import { resolveCommandSourceDirectory } from './artifact-sources.js';
7
+ import { calculateFileDigest } from './bundle-integrity.js';
8
+ import { ManagedCommandError } from './managed-command-errors.js';
4
9
  import { scanNodeImportContract } from './plugin-script-contract.js';
5
- /** Command packages are self-contained; imports cannot use the plugin's dependencies. */
6
- export async function validateManagedCommandPackageClosure(resourceRoot, entries) {
10
+ const NODE_FILE = /\.[cm]?js$/iu;
11
+ export function commandRouteEntries(routes) {
12
+ return routes.fallback === undefined ? routes.subcommands : [...routes.subcommands, routes.fallback];
13
+ }
14
+ async function readCommandTree(root) {
15
+ const entries = [];
16
+ async function visit(relative) {
17
+ const location = path.join(root, relative);
18
+ const stat = await fs.lstat(location);
19
+ if (stat.isSymbolicLink() || (!stat.isDirectory() && !stat.isFile())) {
20
+ throw new ManagedCommandError('commandResourceInvalid', 'Command package resources must be ordinary files and directories.');
21
+ }
22
+ if (stat.isDirectory()) {
23
+ if (relative)
24
+ entries.push({ path: relative, mode: 0 });
25
+ for (const name of (await fs.readdir(location)).sort())
26
+ await visit(path.posix.join(relative, name));
27
+ }
28
+ else {
29
+ entries.push({ path: relative, mode: stat.mode & 0o111, digest: await calculateFileDigest(location) });
30
+ }
31
+ }
32
+ await visit('');
33
+ return entries;
34
+ }
35
+ /** Validate against the copied command package itself, without searching its plugin's dependencies. */
36
+ export async function validateManagedCommandPackageClosure(resourceRoot, entries, injectedReaders = []) {
7
37
  await validateCommandEntryFiles(resourceRoot, entries);
8
38
  const entryFiles = entries.filter((entry) => entry.runner === 'node').map((entry) => entry.entry);
9
39
  if (entryFiles.length === 0)
10
40
  return;
11
- const filePaths = [];
12
- const files = {};
13
- async function visit(relative) {
14
- const directory = path.join(resourceRoot, relative);
15
- for (const entry of await fs.readdir(directory, { withFileTypes: true })) {
16
- const relativePath = relative ? `${relative}/${entry.name}` : entry.name;
17
- if (entry.isSymbolicLink() || (!entry.isDirectory() && !entry.isFile())) {
18
- throw new Error('Invalid managed command package: only ordinary files and directories are supported.');
19
- }
20
- if (entry.isDirectory())
21
- await visit(relativePath);
22
- else {
23
- filePaths.push(relativePath);
24
- if (entryFiles.includes(relativePath) || /\.[cm]?js$/iu.test(relativePath) || entry.name === 'package.json') {
25
- files[relativePath] = await fs.readFile(path.join(resourceRoot, relativePath), 'utf8');
26
- }
27
- }
41
+ const filePaths = await listCatalogBundleFiles(resourceRoot);
42
+ const files = Object.fromEntries(injectedReaders.map((file) => [file, '']));
43
+ for (const relative of filePaths) {
44
+ const location = path.join(resourceRoot, relative);
45
+ if (!(await fs.lstat(location)).isFile())
46
+ throw new ManagedCommandError('commandResourceInvalid', 'Invalid command resource file.');
47
+ if (entryFiles.includes(relative) || NODE_FILE.test(relative) || path.posix.basename(relative) === 'package.json') {
48
+ files[relative] = await fs.readFile(location, 'utf8');
28
49
  }
29
50
  }
30
- await visit('');
31
- const scan = scanNodeImportContract({ files, filePaths, entryFiles, dependencies: [], devDependencies: [] });
51
+ const scan = scanNodeImportContract({ files, filePaths, entryFiles });
32
52
  if (scan.errors.length > 0)
33
- throw new Error(`Invalid managed command package runtime imports:\n${scan.errors.join('\n')}`);
53
+ throw new ManagedCommandError('commandResourceInvalid', `Invalid command package runtime imports:\n${scan.errors.join('\n')}`);
54
+ }
55
+ async function commandSourceRoot(pluginRoot, manifest) {
56
+ try {
57
+ await validateManagedCommandSources(pluginRoot, manifest);
58
+ return await resolveCommandSourceDirectory({ bundleRoot: pluginRoot, pluginRelativePath: manifest.command.sourceDir });
59
+ }
60
+ catch (error) {
61
+ throw new ManagedCommandError('commandResourceInvalid', error.message);
62
+ }
63
+ }
64
+ export async function validateManagedCommandSourceClosure(pluginRoot, manifest) {
65
+ const command = manifest.command;
66
+ if (!command)
67
+ return;
68
+ const resourceRoot = await commandSourceRoot(pluginRoot, manifest);
69
+ if (command.mode !== 'static')
70
+ return;
71
+ const readers = getCommandPackageInjectedReaders(manifest);
72
+ await validateManagedCommandPackageClosure(resourceRoot, commandRouteEntries(command.routes), readers?.paths);
73
+ }
74
+ function dependencyNames(value) {
75
+ return value && typeof value === 'object' && !Array.isArray(value) ? Object.keys(value) : [];
76
+ }
77
+ /** Use the same import contract as bundle generation to identify the renderer's transitive imports. */
78
+ async function rendererClosureDigest(plugin) {
79
+ const renderer = plugin.manifest.scripts?.artifacts?.render;
80
+ if (!renderer)
81
+ return undefined;
82
+ const bundleRoot = await fs.realpath(plugin.rootDir);
83
+ const entry = renderer.path.replace(/^\.\//u, '');
84
+ const allFiles = await listCatalogBundleFiles(bundleRoot);
85
+ const runtimeFiles = allFiles.filter((file) => !file.split('/').includes('node_modules'));
86
+ const runtimeFileSet = new Set(runtimeFiles);
87
+ const files = {};
88
+ for (const file of runtimeFiles) {
89
+ if (file !== entry && !NODE_FILE.test(file) && path.posix.basename(file) !== 'package.json')
90
+ continue;
91
+ const location = path.join(bundleRoot, file);
92
+ if ((await fs.lstat(location)).isFile())
93
+ files[file] = await fs.readFile(location, 'utf8');
94
+ }
95
+ const packageRoot = plugin.manifest.scripts?.node?.packageRoot?.replace(/^\.\//u, '');
96
+ const packageJson = packageRoot === undefined ? undefined : path.posix.join(packageRoot, 'package.json');
97
+ const packageInfo = packageJson === undefined ? {} : JSON.parse(files[packageJson] ?? '{}');
98
+ const scan = scanNodeImportContract({ files, filePaths: runtimeFiles, entryFiles: [entry],
99
+ dependencies: dependencyNames(packageInfo.dependencies), devDependencies: dependencyNames(packageInfo.devDependencies),
100
+ runtimeConfigSkillRoots: plugin.manifest.artifacts?.sourceDirs });
101
+ if (scan.errors.length)
102
+ throw new ManagedCommandError('commandResourceInvalid', `Invalid command renderer imports:\n${scan.errors.join('\n')}`);
103
+ const closure = new Set(scan.files);
104
+ for (const file of scan.files) {
105
+ let directory = path.posix.dirname(file);
106
+ while (true) {
107
+ const metadata = path.posix.join(directory, 'package.json');
108
+ if (runtimeFileSet.has(metadata))
109
+ closure.add(metadata);
110
+ if (directory === '.')
111
+ break;
112
+ directory = path.posix.dirname(directory);
113
+ }
114
+ }
115
+ if (packageRoot !== undefined && packageJson !== undefined && scan.bareSpecifiers.length) {
116
+ closure.add(packageJson);
117
+ const dependencyRoot = path.posix.join(packageRoot, 'node_modules');
118
+ for (const file of allFiles)
119
+ if (file.startsWith(`${dependencyRoot}/`))
120
+ closure.add(file);
121
+ }
122
+ const digests = [];
123
+ for (const file of [...closure].sort()) {
124
+ const location = path.join(bundleRoot, file);
125
+ const stat = await fs.lstat(location);
126
+ if (stat.isFile())
127
+ digests.push({ path: file, digest: await calculateFileDigest(location) });
128
+ else if (stat.isSymbolicLink() && file.split('/').includes('node_modules')) {
129
+ digests.push({ path: file, link: await fs.readlink(location) });
130
+ }
131
+ else
132
+ throw new ManagedCommandError('commandResourceInvalid', 'The command renderer closure contains an unsafe file.');
133
+ }
134
+ return commandInputDigest(digests);
135
+ }
136
+ export function commandInputDigest(value) {
137
+ return `sha256:${createHash('sha256').update(canonicalizeIdentityValue(value)).digest('hex')}`;
138
+ }
139
+ export async function calculateManagedCommandResourceDigest(resourceRoot) {
140
+ const root = await fs.lstat(resourceRoot);
141
+ if (!root.isDirectory())
142
+ throw new ManagedCommandError('commandResourceInvalid', 'The command source must be a regular directory.');
143
+ return commandInputDigest(await readCommandTree(resourceRoot));
144
+ }
145
+ export async function readManagedCommandSource(plugin) {
146
+ const declaration = plugin.manifest.command;
147
+ if (!declaration)
148
+ throw new ManagedCommandError('commandPackageDeclarationMissing', 'The active plugin does not declare a command package.');
149
+ const sourceRoot = await commandSourceRoot(plugin.rootDir, plugin.manifest);
150
+ const [sourceTreeDigest, manifestDigest, rendererDigest] = await Promise.all([
151
+ calculateManagedCommandResourceDigest(sourceRoot), calculateFileDigest(plugin.manifestPath), rendererClosureDigest(plugin),
152
+ ]);
153
+ return { sourceRoot, sourceTreeDigest,
154
+ sourceContentDigest: commandInputDigest({ sourceDir: declaration.sourceDir, sourceTreeDigest, manifestDigest, rendererDigest: rendererDigest ?? null }) };
34
155
  }
35
156
  //# sourceMappingURL=managed-command-closure.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"managed-command-closure.js","sourceRoot":"","sources":["../../../src/utils/managed-command-closure.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,EAAE,yBAAyB,EAA0B,MAAM,wCAAwC,CAAC;AAE3G,OAAO,EAAE,sBAAsB,EA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,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC5E,MAAM,CAAC,gBAAgB,EAAE,cAAc,EAAE,cAAc,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAC3E,qCAAqC,CAAC,UAAU,CAAC,EAAE,mBAAmB,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,qBAAqB,CAAC,MAAM,CAAC;KAC3H,CAAC,CAAC;IACH,OAAO,EAAE,UAAU,EAAE,gBAAgB;QACnC,mBAAmB,EAAE,kBAAkB,CAAC,EAAE,SAAS,EAAE,WAAW,CAAC,SAAS,EAAE,gBAAgB,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,IAAI,IAAI,EAAE,CAAC,EAAE,CAAC;AAC9J,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare class ManagedCommandError extends Error {
2
+ readonly code: string;
3
+ readonly argumentError: boolean;
4
+ constructor(code: string, message: string, argumentError?: boolean);
5
+ }
@@ -0,0 +1,10 @@
1
+ export class ManagedCommandError extends Error {
2
+ code;
3
+ argumentError;
4
+ constructor(code, message, argumentError = false) {
5
+ super(message);
6
+ this.code = code;
7
+ this.argumentError = argumentError;
8
+ }
9
+ }
10
+ //# sourceMappingURL=managed-command-errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"managed-command-errors.js","sourceRoot":"","sources":["../../../src/utils/managed-command-errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAChB;IAA+C;IAA3E,YAA4B,IAAY,EAAE,OAAe,EAAkB,gBAAgB,KAAK;QAC9F,KAAK,CAAC,OAAO,CAAC,CAAC;QADW,SAAI,GAAJ,IAAI,CAAQ;QAAmC,kBAAa,GAAb,aAAa,CAAQ;IAEhG,CAAC;CACF"}
@@ -1,125 +1,89 @@
1
- import { type NativeToolClosure, type ManagedCommandProducerRef, type ManagedCommandReference, type ProducerIdentity, type CommandDefinition } from '@lesliechan721/aw-plugin-core/manifest';
2
- import type { CommandProducerResult, PlatformName, PluginMeta, ReceiptTargetIdentity, Scope } from '../types.js';
3
- import type { RenderUnit } from '../platforms/contracts.js';
4
- import type { ValidatedArtifactPlanArtifact } from './artifact-plan.js';
5
- import type { DynamicSkillTree } from './dynamic-skill-tree.js';
6
- import { type InstalledCommandSet, type ManagedCommandPackageEvidence } from './managed-command-store.js';
7
- export interface ManagedCommandCandidate {
8
- producer: ProducerIdentity;
9
- sets: InstalledCommandSet[];
10
- nativeTools?: NativeToolClosure;
11
- }
12
- export interface PreparedManagedCommandPackage extends ManagedCommandCandidate {
13
- resourceRoot: string;
14
- cleanup(): Promise<void>;
15
- }
16
- export interface ManagedCommandPackageDiscovery {
17
- packages: Array<{
18
- producer: ProducerIdentity;
19
- packageId: string;
20
- packageKey: string;
21
- refreshKeys: string[];
22
- declared: boolean;
23
- installed: boolean;
24
- }>;
25
- errors: Array<{
26
- code: string;
27
- message: string;
28
- subject?: string;
29
- }>;
30
- }
31
- export interface RetainedManagedCommandPackage {
32
- producer: ProducerIdentity;
33
- packageId: string;
34
- commandIds: string[];
35
- availability: 'ready' | 'empty' | 'unavailable';
36
- errors: CommandProducerResult['errors'];
37
- recoveryAction: string;
38
- }
39
- export declare function discoverRetainedManagedCommandPackages(options: {
40
- selectors: readonly {
41
- sourceId?: string;
42
- pluginName: string;
43
- }[];
44
- all?: boolean;
45
- scope: Scope;
46
- cwd: string;
47
- env: NodeJS.ProcessEnv;
48
- }): Promise<RetainedManagedCommandPackage[]>;
49
- export declare function retainedManagedCommandPackageResult(entry: RetainedManagedCommandPackage): CommandProducerResult;
50
- export declare function prepareManagedCommandPackageFiles(options: {
51
- sourceRoot: string;
52
- files: Record<string, string>;
53
- entries: readonly CommandDefinition[];
54
- }): Promise<{
55
- resourceRoot: string;
56
- cleanup(): Promise<void>;
57
- }>;
58
- export declare function managedCommandProducerIdentity(options: {
1
+ import { type CommandRoutes, type InstalledCommandProducer, type NativeToolClosure, type PlatformName, type ProducerIdentity } from '@lesliechan721/aw-plugin-core/manifest';
2
+ import type { PluginMeta } from '../types.js';
3
+ import { type ResolvedArtifactRenderConfig } from './artifact-renderer.js';
4
+ import { type ManagedCommandPackageEvidence } from './managed-command-store.js';
5
+ import { type PluginConfigValue, type ResolvedEffectivePluginConfig } from './plugin-config.js';
6
+ export { readManagedCommandSource } from './managed-command-closure.js';
7
+ export type ManagedCommandPackageOperation = {
8
+ kind: 'materialize';
9
+ } | {
10
+ kind: 'explicit-sync';
11
+ } | {
12
+ kind: 'platform-sync';
13
+ platforms: readonly PlatformName[];
14
+ } | {
15
+ kind: 'config-apply';
16
+ platforms: readonly PlatformName[];
17
+ refreshRoutes: boolean;
18
+ };
19
+ export interface ManagedCommandRoutesRenderOptions {
59
20
  plugin: PluginMeta;
60
- producer: ManagedCommandProducerRef;
61
- scope: Scope;
62
21
  cwd: string;
63
- renderUnit?: Pick<RenderUnit, 'physicalKey' | 'renderScope'>;
64
- }): Promise<ProducerIdentity>;
65
- export declare function commandSetsForProducer(options: {
66
- plugin: PluginMeta;
67
- producer: ManagedCommandProducerRef;
68
- artifacts?: readonly ValidatedArtifactPlanArtifact[];
69
- requestedSetNames?: ReadonlySet<string>;
70
- previousSets?: readonly InstalledCommandSet[];
71
- }): InstalledCommandSet[];
72
- export declare function nativeToolsForCommandSets(plugin: PluginMeta, sets: readonly Pick<InstalledCommandSet, 'set'>[]): Promise<NativeToolClosure | undefined>;
73
- /** Config refresh cannot adopt native declarations that its config Review did not show. */
74
- export declare function assertManagedCommandPackageNativeToolsUnchanged(options: {
75
- plugin: PluginMeta;
76
- producer: ProducerIdentity;
77
22
  env: NodeJS.ProcessEnv;
78
- }): Promise<void>;
79
- export declare function injectNativeToolClosureFiles(files: Record<string, Buffer>, closure: NativeToolClosure | undefined): NativeToolClosure | undefined;
80
- export declare function prepareManagedCommandPackage(options: {
81
- referencePlugins?: readonly PluginMeta[];
82
- plugin: PluginMeta;
83
- packageKey: string;
84
- scope: Scope;
85
- cwd: string;
86
- env: NodeJS.ProcessEnv;
87
- event?: 'install' | 'refresh' | 'materialize';
23
+ sourceDir: string;
24
+ previous?: InstalledCommandProducer;
25
+ commonConfig?: ResolvedArtifactRenderConfig;
26
+ event: 'install' | 'refresh' | 'materialize';
88
27
  changedConfigKeys?: string[];
89
- requestedArtifactIds?: readonly string[];
28
+ referencePlugins?: readonly PluginMeta[];
90
29
  signal?: AbortSignal;
91
30
  scriptTimeoutMs?: number;
92
- }): Promise<PreparedManagedCommandPackage>;
93
- export declare function syncPluginManagedCommandPackage(options: {
94
- referencePlugins?: readonly PluginMeta[];
31
+ }
32
+ interface PackageInputs {
95
33
  plugin: PluginMeta;
96
- packageKey: string;
97
- scope: Scope;
98
34
  cwd: string;
99
35
  env: NodeJS.ProcessEnv;
100
- event?: 'install' | 'refresh' | 'materialize';
101
- changedConfigKeys?: string[];
102
- requestedArtifactIds?: readonly string[];
36
+ referencePlugins?: readonly PluginMeta[];
37
+ resolveConfig?: (platform?: PlatformName) => Promise<ResolvedEffectivePluginConfig>;
38
+ }
39
+ interface PreparedManagedCommandPackageOptions extends PackageInputs {
40
+ operation: ManagedCommandPackageOperation;
41
+ renderRoutes?: (options: ManagedCommandRoutesRenderOptions) => Promise<CommandRoutes>;
103
42
  signal?: AbortSignal;
104
43
  scriptTimeoutMs?: number;
105
- managedCommandProducerCache?: Map<string, Promise<CommandProducerResult>>;
106
- expectedPackage?: ManagedCommandPackageEvidence;
107
- }): Promise<CommandProducerResult>;
108
- export declare function discoverInstalledPluginManagedCommandPackages(options: {
109
- plugin: PluginMeta;
110
- scope: Scope;
111
- cwd: string;
112
- env: NodeJS.ProcessEnv;
113
- platformTargets?: readonly Pick<ReceiptTargetIdentity, 'platform' | 'scope'>[];
114
- }): Promise<ManagedCommandPackageDiscovery>;
115
- export declare function createManagedCommandReferenceResolver(options: {
116
- plugin: PluginMeta;
44
+ }
45
+ interface InstalledPackage {
46
+ resourceRoot: string;
47
+ record: InstalledCommandProducer;
48
+ }
49
+ interface RuntimeConfigChange {
117
50
  platform: PlatformName;
118
- scope: Scope;
119
- cwd: string;
120
- env: NodeJS.ProcessEnv;
121
- renderUnit: Pick<RenderUnit, 'physicalKey' | 'renderScope'>;
122
- candidates?: readonly ManagedCommandCandidate[];
123
- unavailableProducers?: readonly ProducerIdentity[];
124
- }): Promise<(reference: ManagedCommandReference) => string>;
125
- export declare function resolveSkillManagedCommandReferences(tree: DynamicSkillTree, resolve: (reference: ManagedCommandReference) => string): void;
51
+ before?: Record<string, PluginConfigValue>;
52
+ after?: Record<string, PluginConfigValue>;
53
+ }
54
+ export interface PreparedManagedCommandPackage {
55
+ resourceRoot: string;
56
+ resourceDigest: string;
57
+ record: InstalledCommandProducer;
58
+ previous?: InstalledPackage;
59
+ expectedPackage: ManagedCommandPackageEvidence | null;
60
+ runtimeConfigChanges: RuntimeConfigChange[];
61
+ /** Per-platform config inputs actually read to build or validate the reviewed snapshots. */
62
+ runtimeConfigEvidence: ReadonlyMap<PlatformName, string>;
63
+ /** Dynamic rendering uses the common user config store. */
64
+ routeConfigEvidence?: string;
65
+ cleanup(): Promise<void>;
66
+ }
67
+ export declare function managedCommandProducerIdentity(options: {
68
+ plugin: PluginMeta;
69
+ }): ProducerIdentity;
70
+ export declare function nativeToolsForPluginCommand(plugin: PluginMeta): Promise<NativeToolClosure | undefined>;
71
+ /** Select only the snapshots and routes whose applied inputs differ. */
72
+ export declare function inspectManagedCommandConfigApply(options: PackageInputs & {
73
+ platform?: PlatformName;
74
+ }): Promise<Extract<ManagedCommandPackageOperation, {
75
+ kind: 'config-apply';
76
+ }> | undefined>;
77
+ export declare function prepareManagedCommandPackage(options: PreparedManagedCommandPackageOptions): Promise<PreparedManagedCommandPackage>;
78
+ /** Recheck inputs under the caller's existing write lock, without repeating the renderer. */
79
+ export declare function verifyPreparedManagedCommandPackage(options: PackageInputs & {
80
+ candidate: PreparedManagedCommandPackage;
81
+ }): Promise<void>;
82
+ export declare function publishPreparedManagedCommandPackage(options: PackageInputs & {
83
+ candidate: PreparedManagedCommandPackage;
84
+ }): Promise<{
85
+ id: string;
86
+ resourceRoot: string;
87
+ errors: import("./managed-command-store.js").ManagedCommandDiagnostic[];
88
+ recoveryActions: string[];
89
+ }>;