@lesliechan721/aw 0.1.0-beta.3

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 (429) hide show
  1. package/dist/authoring/assets/aw-config.d.mts +2 -0
  2. package/dist/authoring/assets/aw-config.mjs +556 -0
  3. package/dist/authoring/assets/aw-config.mjs.map +1 -0
  4. package/dist/authoring/scripts/add-skill.d.mts +2 -0
  5. package/dist/authoring/scripts/add-skill.mjs +355 -0
  6. package/dist/authoring/scripts/add-skill.mjs.map +1 -0
  7. package/dist/authoring/scripts/check-plugin-versions.d.mts +2 -0
  8. package/dist/authoring/scripts/check-plugin-versions.mjs +5 -0
  9. package/dist/authoring/scripts/check-plugin-versions.mjs.map +1 -0
  10. package/dist/authoring/scripts/init-plugin.d.mts +2 -0
  11. package/dist/authoring/scripts/init-plugin.mjs +512 -0
  12. package/dist/authoring/scripts/init-plugin.mjs.map +1 -0
  13. package/dist/authoring/scripts/lib/javascript-import-scanner.d.mts +4 -0
  14. package/dist/authoring/scripts/lib/javascript-import-scanner.mjs +261 -0
  15. package/dist/authoring/scripts/lib/javascript-import-scanner.mjs.map +1 -0
  16. package/dist/authoring/scripts/lib/plugin-root.d.mts +26 -0
  17. package/dist/authoring/scripts/lib/plugin-root.mjs +125 -0
  18. package/dist/authoring/scripts/lib/plugin-root.mjs.map +1 -0
  19. package/dist/authoring/scripts/lib/plugin-version-check.d.mts +55 -0
  20. package/dist/authoring/scripts/lib/plugin-version-check.mjs +777 -0
  21. package/dist/authoring/scripts/lib/plugin-version-check.mjs.map +1 -0
  22. package/dist/authoring/scripts/lib/semver.d.mts +9 -0
  23. package/dist/authoring/scripts/lib/semver.mjs +63 -0
  24. package/dist/authoring/scripts/lib/semver.mjs.map +1 -0
  25. package/dist/authoring/scripts/lib/skill-scaffold.d.mts +124 -0
  26. package/dist/authoring/scripts/lib/skill-scaffold.mjs +374 -0
  27. package/dist/authoring/scripts/lib/skill-scaffold.mjs.map +1 -0
  28. package/dist/authoring/scripts/plugin-status.d.mts +2 -0
  29. package/dist/authoring/scripts/plugin-status.mjs +96 -0
  30. package/dist/authoring/scripts/plugin-status.mjs.map +1 -0
  31. package/dist/authoring/scripts/validate-plugin.d.mts +2 -0
  32. package/dist/authoring/scripts/validate-plugin.mjs +4442 -0
  33. package/dist/authoring/scripts/validate-plugin.mjs.map +1 -0
  34. package/dist/authoring/scripts/validate-skill.d.mts +2 -0
  35. package/dist/authoring/scripts/validate-skill.mjs +126 -0
  36. package/dist/authoring/scripts/validate-skill.mjs.map +1 -0
  37. package/dist/index.d.ts +2 -0
  38. package/dist/index.js +8 -0
  39. package/dist/index.js.map +1 -0
  40. package/dist/scripts/aw-skill-eval-engine.d.ts +13 -0
  41. package/dist/scripts/aw-skill-eval-engine.js +31 -0
  42. package/dist/scripts/aw-skill-eval-engine.js.map +1 -0
  43. package/dist/scripts/bundle-plugins.d.ts +18 -0
  44. package/dist/scripts/bundle-plugins.js +123 -0
  45. package/dist/scripts/bundle-plugins.js.map +1 -0
  46. package/dist/scripts/codex-eval-app-server.d.ts +89 -0
  47. package/dist/scripts/codex-eval-app-server.js +1228 -0
  48. package/dist/scripts/codex-eval-app-server.js.map +1 -0
  49. package/dist/scripts/codex-eval-isolation.d.ts +61 -0
  50. package/dist/scripts/codex-eval-isolation.js +318 -0
  51. package/dist/scripts/codex-eval-isolation.js.map +1 -0
  52. package/dist/scripts/codex-eval-process-management.d.ts +8 -0
  53. package/dist/scripts/codex-eval-process-management.js +69 -0
  54. package/dist/scripts/codex-eval-process-management.js.map +1 -0
  55. package/dist/scripts/codex-eval-process-tree.d.ts +38 -0
  56. package/dist/scripts/codex-eval-process-tree.js +803 -0
  57. package/dist/scripts/codex-eval-process-tree.js.map +1 -0
  58. package/dist/scripts/codex-eval-runtime-config.d.ts +62 -0
  59. package/dist/scripts/codex-eval-runtime-config.js +843 -0
  60. package/dist/scripts/codex-eval-runtime-config.js.map +1 -0
  61. package/dist/scripts/codex-trigger-eval.d.ts +84 -0
  62. package/dist/scripts/codex-trigger-eval.js +968 -0
  63. package/dist/scripts/codex-trigger-eval.js.map +1 -0
  64. package/dist/scripts/eval-plugin-skills-audited.d.ts +6 -0
  65. package/dist/scripts/eval-plugin-skills-audited.js +261 -0
  66. package/dist/scripts/eval-plugin-skills-audited.js.map +1 -0
  67. package/dist/scripts/eval-plugin-skills.d.ts +45 -0
  68. package/dist/scripts/eval-plugin-skills.js +1586 -0
  69. package/dist/scripts/eval-plugin-skills.js.map +1 -0
  70. package/dist/scripts/eval-run-layout.d.ts +17 -0
  71. package/dist/scripts/eval-run-layout.js +26 -0
  72. package/dist/scripts/eval-run-layout.js.map +1 -0
  73. package/dist/scripts/plugin-eval-contract.d.ts +185 -0
  74. package/dist/scripts/plugin-eval-contract.js +695 -0
  75. package/dist/scripts/plugin-eval-contract.js.map +1 -0
  76. package/dist/scripts/plugin-eval-materializer.d.ts +13 -0
  77. package/dist/scripts/plugin-eval-materializer.js +421 -0
  78. package/dist/scripts/plugin-eval-materializer.js.map +1 -0
  79. package/dist/scripts/plugin-staging.d.ts +43 -0
  80. package/dist/scripts/plugin-staging.js +196 -0
  81. package/dist/scripts/plugin-staging.js.map +1 -0
  82. package/dist/scripts/skill-reporting.d.ts +212 -0
  83. package/dist/scripts/skill-reporting.js +922 -0
  84. package/dist/scripts/skill-reporting.js.map +1 -0
  85. package/dist/scripts/test-plugin-scripts.d.ts +7 -0
  86. package/dist/scripts/test-plugin-scripts.js +674 -0
  87. package/dist/scripts/test-plugin-scripts.js.map +1 -0
  88. package/dist/src/adapters/helpers.d.ts +44 -0
  89. package/dist/src/adapters/helpers.js +95 -0
  90. package/dist/src/adapters/helpers.js.map +1 -0
  91. package/dist/src/authoring/workspace-commands.d.ts +46 -0
  92. package/dist/src/authoring/workspace-commands.js +133 -0
  93. package/dist/src/authoring/workspace-commands.js.map +1 -0
  94. package/dist/src/commands/catalog-publish.d.ts +33 -0
  95. package/dist/src/commands/catalog-publish.js +374 -0
  96. package/dist/src/commands/catalog-publish.js.map +1 -0
  97. package/dist/src/commands/catalog-source.d.ts +111 -0
  98. package/dist/src/commands/catalog-source.js +266 -0
  99. package/dist/src/commands/catalog-source.js.map +1 -0
  100. package/dist/src/commands/console.d.ts +3 -0
  101. package/dist/src/commands/console.js +44 -0
  102. package/dist/src/commands/console.js.map +1 -0
  103. package/dist/src/commands/dependency-operation-plan.d.ts +28 -0
  104. package/dist/src/commands/dependency-operation-plan.js +15 -0
  105. package/dist/src/commands/dependency-operation-plan.js.map +1 -0
  106. package/dist/src/commands/init.d.ts +31 -0
  107. package/dist/src/commands/init.js +63 -0
  108. package/dist/src/commands/init.js.map +1 -0
  109. package/dist/src/commands/options.d.ts +68 -0
  110. package/dist/src/commands/options.js +146 -0
  111. package/dist/src/commands/options.js.map +1 -0
  112. package/dist/src/commands/rebuild-command.d.ts +77 -0
  113. package/dist/src/commands/rebuild-command.js +1681 -0
  114. package/dist/src/commands/rebuild-command.js.map +1 -0
  115. package/dist/src/commands/rebuild-integration.d.ts +94 -0
  116. package/dist/src/commands/rebuild-integration.js +3289 -0
  117. package/dist/src/commands/rebuild-integration.js.map +1 -0
  118. package/dist/src/commands/rebuild-operations.d.ts +110 -0
  119. package/dist/src/commands/rebuild-operations.js +791 -0
  120. package/dist/src/commands/rebuild-operations.js.map +1 -0
  121. package/dist/src/commands/review-publication.d.ts +99 -0
  122. package/dist/src/commands/review-publication.js +904 -0
  123. package/dist/src/commands/review-publication.js.map +1 -0
  124. package/dist/src/commands/runtime.d.ts +176 -0
  125. package/dist/src/commands/runtime.js +746 -0
  126. package/dist/src/commands/runtime.js.map +1 -0
  127. package/dist/src/commands/status-v4.d.ts +102 -0
  128. package/dist/src/commands/status-v4.js +844 -0
  129. package/dist/src/commands/status-v4.js.map +1 -0
  130. package/dist/src/commands/status.d.ts +93 -0
  131. package/dist/src/commands/status.js +442 -0
  132. package/dist/src/commands/status.js.map +1 -0
  133. package/dist/src/commands/wizard.d.ts +57 -0
  134. package/dist/src/commands/wizard.js +58 -0
  135. package/dist/src/commands/wizard.js.map +1 -0
  136. package/dist/src/commands/write-commands.d.ts +7 -0
  137. package/dist/src/commands/write-commands.js +167 -0
  138. package/dist/src/commands/write-commands.js.map +1 -0
  139. package/dist/src/constants.d.ts +25 -0
  140. package/dist/src/constants.js +26 -0
  141. package/dist/src/constants.js.map +1 -0
  142. package/dist/src/generators/agents.d.ts +3 -0
  143. package/dist/src/generators/agents.js +46 -0
  144. package/dist/src/generators/agents.js.map +1 -0
  145. package/dist/src/generators/hooks.d.ts +15 -0
  146. package/dist/src/generators/hooks.js +76 -0
  147. package/dist/src/generators/hooks.js.map +1 -0
  148. package/dist/src/generators/instructions.d.ts +13 -0
  149. package/dist/src/generators/instructions.js +66 -0
  150. package/dist/src/generators/instructions.js.map +1 -0
  151. package/dist/src/generators/local-plugin.d.ts +53 -0
  152. package/dist/src/generators/local-plugin.js +1268 -0
  153. package/dist/src/generators/local-plugin.js.map +1 -0
  154. package/dist/src/generators/permissions.d.ts +10 -0
  155. package/dist/src/generators/permissions.js +37 -0
  156. package/dist/src/generators/permissions.js.map +1 -0
  157. package/dist/src/generators/shared.d.ts +2 -0
  158. package/dist/src/generators/shared.js +15 -0
  159. package/dist/src/generators/shared.js.map +1 -0
  160. package/dist/src/index.d.ts +35 -0
  161. package/dist/src/index.js +2344 -0
  162. package/dist/src/index.js.map +1 -0
  163. package/dist/src/output/command-receipt.d.ts +90 -0
  164. package/dist/src/output/command-receipt.js +129 -0
  165. package/dist/src/output/command-receipt.js.map +1 -0
  166. package/dist/src/output/debug-log.d.ts +4 -0
  167. package/dist/src/output/debug-log.js +97 -0
  168. package/dist/src/output/debug-log.js.map +1 -0
  169. package/dist/src/output/equivalent-command.d.ts +9 -0
  170. package/dist/src/output/equivalent-command.js +39 -0
  171. package/dist/src/output/equivalent-command.js.map +1 -0
  172. package/dist/src/output/model.d.ts +117 -0
  173. package/dist/src/output/model.js +145 -0
  174. package/dist/src/output/model.js.map +1 -0
  175. package/dist/src/output/rebuild-progress.d.ts +21 -0
  176. package/dist/src/output/rebuild-progress.js +138 -0
  177. package/dist/src/output/rebuild-progress.js.map +1 -0
  178. package/dist/src/output/redact.d.ts +3 -0
  179. package/dist/src/output/redact.js +39 -0
  180. package/dist/src/output/redact.js.map +1 -0
  181. package/dist/src/output/reporter.d.ts +9 -0
  182. package/dist/src/output/reporter.js +133 -0
  183. package/dist/src/output/reporter.js.map +1 -0
  184. package/dist/src/portable/commands.d.ts +120 -0
  185. package/dist/src/portable/commands.js +506 -0
  186. package/dist/src/portable/commands.js.map +1 -0
  187. package/dist/src/portable/materializer.d.ts +50 -0
  188. package/dist/src/portable/materializer.js +408 -0
  189. package/dist/src/portable/materializer.js.map +1 -0
  190. package/dist/src/portable/skills-cli.d.ts +43 -0
  191. package/dist/src/portable/skills-cli.js +148 -0
  192. package/dist/src/portable/skills-cli.js.map +1 -0
  193. package/dist/src/tui/components.d.ts +32 -0
  194. package/dist/src/tui/components.js +42 -0
  195. package/dist/src/tui/components.js.map +1 -0
  196. package/dist/src/tui/console-app-v4.d.ts +20 -0
  197. package/dist/src/tui/console-app-v4.js +2613 -0
  198. package/dist/src/tui/console-app-v4.js.map +1 -0
  199. package/dist/src/tui/controller-runtime.d.ts +11 -0
  200. package/dist/src/tui/controller-runtime.js +902 -0
  201. package/dist/src/tui/controller-runtime.js.map +1 -0
  202. package/dist/src/tui/controller.d.ts +367 -0
  203. package/dist/src/tui/controller.js +1724 -0
  204. package/dist/src/tui/controller.js.map +1 -0
  205. package/dist/src/tui/index.d.ts +13 -0
  206. package/dist/src/tui/index.js +14 -0
  207. package/dist/src/tui/index.js.map +1 -0
  208. package/dist/src/tui/keys.d.ts +12 -0
  209. package/dist/src/tui/keys.js +22 -0
  210. package/dist/src/tui/keys.js.map +1 -0
  211. package/dist/src/tui/layout.d.ts +12 -0
  212. package/dist/src/tui/layout.js +19 -0
  213. package/dist/src/tui/layout.js.map +1 -0
  214. package/dist/src/tui/model.d.ts +279 -0
  215. package/dist/src/tui/model.js +652 -0
  216. package/dist/src/tui/model.js.map +1 -0
  217. package/dist/src/tui/prompt.d.ts +8 -0
  218. package/dist/src/tui/prompt.js +242 -0
  219. package/dist/src/tui/prompt.js.map +1 -0
  220. package/dist/src/tui/router.d.ts +153 -0
  221. package/dist/src/tui/router.js +102 -0
  222. package/dist/src/tui/router.js.map +1 -0
  223. package/dist/src/tui/runner.d.ts +11 -0
  224. package/dist/src/tui/runner.js +71 -0
  225. package/dist/src/tui/runner.js.map +1 -0
  226. package/dist/src/tui/theme.d.ts +18 -0
  227. package/dist/src/tui/theme.js +20 -0
  228. package/dist/src/tui/theme.js.map +1 -0
  229. package/dist/src/tui/views.d.ts +57 -0
  230. package/dist/src/tui/views.js +173 -0
  231. package/dist/src/tui/views.js.map +1 -0
  232. package/dist/src/tui/wizard.d.ts +11 -0
  233. package/dist/src/tui/wizard.js +321 -0
  234. package/dist/src/tui/wizard.js.map +1 -0
  235. package/dist/src/types.d.ts +313 -0
  236. package/dist/src/types.js +33 -0
  237. package/dist/src/types.js.map +1 -0
  238. package/dist/src/utils/active-marketplace-runtime-lock.d.ts +12 -0
  239. package/dist/src/utils/active-marketplace-runtime-lock.js +133 -0
  240. package/dist/src/utils/active-marketplace-runtime-lock.js.map +1 -0
  241. package/dist/src/utils/agent-version.d.ts +13 -0
  242. package/dist/src/utils/agent-version.js +172 -0
  243. package/dist/src/utils/agent-version.js.map +1 -0
  244. package/dist/src/utils/artifact-plan.d.ts +26 -0
  245. package/dist/src/utils/artifact-plan.js +444 -0
  246. package/dist/src/utils/artifact-plan.js.map +1 -0
  247. package/dist/src/utils/artifact-renderer.d.ts +124 -0
  248. package/dist/src/utils/artifact-renderer.js +442 -0
  249. package/dist/src/utils/artifact-renderer.js.map +1 -0
  250. package/dist/src/utils/artifact-sources.d.ts +8 -0
  251. package/dist/src/utils/artifact-sources.js +10 -0
  252. package/dist/src/utils/artifact-sources.js.map +1 -0
  253. package/dist/src/utils/aw-home-mutation-lock.d.ts +10 -0
  254. package/dist/src/utils/aw-home-mutation-lock.js +55 -0
  255. package/dist/src/utils/aw-home-mutation-lock.js.map +1 -0
  256. package/dist/src/utils/bundle-integrity.d.ts +3 -0
  257. package/dist/src/utils/bundle-integrity.js +88 -0
  258. package/dist/src/utils/bundle-integrity.js.map +1 -0
  259. package/dist/src/utils/bundle-layout.d.ts +4 -0
  260. package/dist/src/utils/bundle-layout.js +546 -0
  261. package/dist/src/utils/bundle-layout.js.map +1 -0
  262. package/dist/src/utils/catalog-digests.d.ts +8 -0
  263. package/dist/src/utils/catalog-digests.js +108 -0
  264. package/dist/src/utils/catalog-digests.js.map +1 -0
  265. package/dist/src/utils/catalog-manifest-v3.d.ts +2 -0
  266. package/dist/src/utils/catalog-manifest-v3.js +3 -0
  267. package/dist/src/utils/catalog-manifest-v3.js.map +1 -0
  268. package/dist/src/utils/catalog-manifest-v4.d.ts +5 -0
  269. package/dist/src/utils/catalog-manifest-v4.js +106 -0
  270. package/dist/src/utils/catalog-manifest-v4.js.map +1 -0
  271. package/dist/src/utils/catalog-public-error.d.ts +15 -0
  272. package/dist/src/utils/catalog-public-error.js +84 -0
  273. package/dist/src/utils/catalog-public-error.js.map +1 -0
  274. package/dist/src/utils/catalog-runtime-projection.d.ts +36 -0
  275. package/dist/src/utils/catalog-runtime-projection.js +172 -0
  276. package/dist/src/utils/catalog-runtime-projection.js.map +1 -0
  277. package/dist/src/utils/catalog-snapshot.d.ts +8 -0
  278. package/dist/src/utils/catalog-snapshot.js +12 -0
  279. package/dist/src/utils/catalog-snapshot.js.map +1 -0
  280. package/dist/src/utils/catalog-source-cache.d.ts +61 -0
  281. package/dist/src/utils/catalog-source-cache.js +276 -0
  282. package/dist/src/utils/catalog-source-cache.js.map +1 -0
  283. package/dist/src/utils/catalog-source-identity.d.ts +4 -0
  284. package/dist/src/utils/catalog-source-identity.js +118 -0
  285. package/dist/src/utils/catalog-source-identity.js.map +1 -0
  286. package/dist/src/utils/catalog-source-presentation.d.ts +1 -0
  287. package/dist/src/utils/catalog-source-presentation.js +32 -0
  288. package/dist/src/utils/catalog-source-presentation.js.map +1 -0
  289. package/dist/src/utils/catalog-source-references.d.ts +65 -0
  290. package/dist/src/utils/catalog-source-references.js +1418 -0
  291. package/dist/src/utils/catalog-source-references.js.map +1 -0
  292. package/dist/src/utils/catalog-sources.d.ts +39 -0
  293. package/dist/src/utils/catalog-sources.js +293 -0
  294. package/dist/src/utils/catalog-sources.js.map +1 -0
  295. package/dist/src/utils/codex-config.d.ts +124 -0
  296. package/dist/src/utils/codex-config.js +1011 -0
  297. package/dist/src/utils/codex-config.js.map +1 -0
  298. package/dist/src/utils/codex-project-surface.d.ts +3 -0
  299. package/dist/src/utils/codex-project-surface.js +49 -0
  300. package/dist/src/utils/codex-project-surface.js.map +1 -0
  301. package/dist/src/utils/codex-roles.d.ts +71 -0
  302. package/dist/src/utils/codex-roles.js +257 -0
  303. package/dist/src/utils/codex-roles.js.map +1 -0
  304. package/dist/src/utils/codex-skill-staging.d.ts +9 -0
  305. package/dist/src/utils/codex-skill-staging.js +8 -0
  306. package/dist/src/utils/codex-skill-staging.js.map +1 -0
  307. package/dist/src/utils/config-value.d.ts +3 -0
  308. package/dist/src/utils/config-value.js +23 -0
  309. package/dist/src/utils/config-value.js.map +1 -0
  310. package/dist/src/utils/dynamic-skill-tree.d.ts +32 -0
  311. package/dist/src/utils/dynamic-skill-tree.js +436 -0
  312. package/dist/src/utils/dynamic-skill-tree.js.map +1 -0
  313. package/dist/src/utils/file-rules.d.ts +1 -0
  314. package/dist/src/utils/file-rules.js +2 -0
  315. package/dist/src/utils/file-rules.js.map +1 -0
  316. package/dist/src/utils/git-catalog-provider.d.ts +7 -0
  317. package/dist/src/utils/git-catalog-provider.js +510 -0
  318. package/dist/src/utils/git-catalog-provider.js.map +1 -0
  319. package/dist/src/utils/hooks-contract.d.ts +1 -0
  320. package/dist/src/utils/hooks-contract.js +2 -0
  321. package/dist/src/utils/hooks-contract.js.map +1 -0
  322. package/dist/src/utils/json.d.ts +4 -0
  323. package/dist/src/utils/json.js +29 -0
  324. package/dist/src/utils/json.js.map +1 -0
  325. package/dist/src/utils/lifecycle-active-store.d.ts +175 -0
  326. package/dist/src/utils/lifecycle-active-store.js +1276 -0
  327. package/dist/src/utils/lifecycle-active-store.js.map +1 -0
  328. package/dist/src/utils/local-marketplace.d.ts +41 -0
  329. package/dist/src/utils/local-marketplace.js +317 -0
  330. package/dist/src/utils/local-marketplace.js.map +1 -0
  331. package/dist/src/utils/manifest.d.ts +14 -0
  332. package/dist/src/utils/manifest.js +36 -0
  333. package/dist/src/utils/manifest.js.map +1 -0
  334. package/dist/src/utils/marketplace.d.ts +3 -0
  335. package/dist/src/utils/marketplace.js +76 -0
  336. package/dist/src/utils/marketplace.js.map +1 -0
  337. package/dist/src/utils/multi-source-catalog.d.ts +72 -0
  338. package/dist/src/utils/multi-source-catalog.js +402 -0
  339. package/dist/src/utils/multi-source-catalog.js.map +1 -0
  340. package/dist/src/utils/native-cli.d.ts +75 -0
  341. package/dist/src/utils/native-cli.js +435 -0
  342. package/dist/src/utils/native-cli.js.map +1 -0
  343. package/dist/src/utils/orphan-marketplace-cleanup.d.ts +18 -0
  344. package/dist/src/utils/orphan-marketplace-cleanup.js +202 -0
  345. package/dist/src/utils/orphan-marketplace-cleanup.js.map +1 -0
  346. package/dist/src/utils/ownership.d.ts +130 -0
  347. package/dist/src/utils/ownership.js +766 -0
  348. package/dist/src/utils/ownership.js.map +1 -0
  349. package/dist/src/utils/path-catalog-provider.d.ts +7 -0
  350. package/dist/src/utils/path-catalog-provider.js +87 -0
  351. package/dist/src/utils/path-catalog-provider.js.map +1 -0
  352. package/dist/src/utils/paths.d.ts +41 -0
  353. package/dist/src/utils/paths.js +138 -0
  354. package/dist/src/utils/paths.js.map +1 -0
  355. package/dist/src/utils/platform-entries.d.ts +1 -0
  356. package/dist/src/utils/platform-entries.js +2 -0
  357. package/dist/src/utils/platform-entries.js.map +1 -0
  358. package/dist/src/utils/platform-support.d.ts +1 -0
  359. package/dist/src/utils/platform-support.js +2 -0
  360. package/dist/src/utils/platform-support.js.map +1 -0
  361. package/dist/src/utils/plugin-authoring-capabilities.d.ts +23 -0
  362. package/dist/src/utils/plugin-authoring-capabilities.js +37 -0
  363. package/dist/src/utils/plugin-authoring-capabilities.js.map +1 -0
  364. package/dist/src/utils/plugin-authoring-capabilities.json +92 -0
  365. package/dist/src/utils/plugin-config-write.d.ts +107 -0
  366. package/dist/src/utils/plugin-config-write.js +565 -0
  367. package/dist/src/utils/plugin-config-write.js.map +1 -0
  368. package/dist/src/utils/plugin-config.d.ts +396 -0
  369. package/dist/src/utils/plugin-config.js +1898 -0
  370. package/dist/src/utils/plugin-config.js.map +1 -0
  371. package/dist/src/utils/plugin-dependencies.d.ts +12 -0
  372. package/dist/src/utils/plugin-dependencies.js +162 -0
  373. package/dist/src/utils/plugin-dependencies.js.map +1 -0
  374. package/dist/src/utils/plugin-release.d.ts +2 -0
  375. package/dist/src/utils/plugin-release.js +2 -0
  376. package/dist/src/utils/plugin-release.js.map +1 -0
  377. package/dist/src/utils/plugin-script-contract.d.ts +1 -0
  378. package/dist/src/utils/plugin-script-contract.js +2 -0
  379. package/dist/src/utils/plugin-script-contract.js.map +1 -0
  380. package/dist/src/utils/plugin-scripts.d.ts +172 -0
  381. package/dist/src/utils/plugin-scripts.js +585 -0
  382. package/dist/src/utils/plugin-scripts.js.map +1 -0
  383. package/dist/src/utils/process-lock.d.ts +47 -0
  384. package/dist/src/utils/process-lock.js +532 -0
  385. package/dist/src/utils/process-lock.js.map +1 -0
  386. package/dist/src/utils/process-tree.d.ts +2 -0
  387. package/dist/src/utils/process-tree.js +2 -0
  388. package/dist/src/utils/process-tree.js.map +1 -0
  389. package/dist/src/utils/project-boundary.d.ts +21 -0
  390. package/dist/src/utils/project-boundary.js +95 -0
  391. package/dist/src/utils/project-boundary.js.map +1 -0
  392. package/dist/src/utils/rendered-contract.d.ts +8 -0
  393. package/dist/src/utils/rendered-contract.js +134 -0
  394. package/dist/src/utils/rendered-contract.js.map +1 -0
  395. package/dist/src/utils/runtime-skill-closure.d.ts +13 -0
  396. package/dist/src/utils/runtime-skill-closure.js +863 -0
  397. package/dist/src/utils/runtime-skill-closure.js.map +1 -0
  398. package/dist/src/utils/skill-authoring.d.ts +1 -0
  399. package/dist/src/utils/skill-authoring.js +2 -0
  400. package/dist/src/utils/skill-authoring.js.map +1 -0
  401. package/dist/src/utils/skill-frontmatter-capabilities.d.ts +201 -0
  402. package/dist/src/utils/skill-frontmatter-capabilities.js +5 -0
  403. package/dist/src/utils/skill-frontmatter-capabilities.js.map +1 -0
  404. package/dist/src/utils/skill-frontmatter-capabilities.json +200 -0
  405. package/dist/src/utils/skill-validation.d.ts +37 -0
  406. package/dist/src/utils/skill-validation.js +326 -0
  407. package/dist/src/utils/skill-validation.js.map +1 -0
  408. package/dist/src/utils/slash-commands.d.ts +1 -0
  409. package/dist/src/utils/slash-commands.js +2 -0
  410. package/dist/src/utils/slash-commands.js.map +1 -0
  411. package/dist/src/utils/state-paths.d.ts +13 -0
  412. package/dist/src/utils/state-paths.js +129 -0
  413. package/dist/src/utils/state-paths.js.map +1 -0
  414. package/dist/src/utils/target-eligibility.d.ts +7 -0
  415. package/dist/src/utils/target-eligibility.js +26 -0
  416. package/dist/src/utils/target-eligibility.js.map +1 -0
  417. package/dist/src/utils/target-order.d.ts +7 -0
  418. package/dist/src/utils/target-order.js +10 -0
  419. package/dist/src/utils/target-order.js.map +1 -0
  420. package/dist/src/utils/template-engine.d.ts +1 -0
  421. package/dist/src/utils/template-engine.js +2 -0
  422. package/dist/src/utils/template-engine.js.map +1 -0
  423. package/dist/src/utils/test-path-fence.d.ts +12 -0
  424. package/dist/src/utils/test-path-fence.js +31 -0
  425. package/dist/src/utils/test-path-fence.js.map +1 -0
  426. package/dist/vitest.config.d.ts +2 -0
  427. package/dist/vitest.config.js +16 -0
  428. package/dist/vitest.config.js.map +1 -0
  429. package/package.json +61 -0
@@ -0,0 +1,777 @@
1
+ import { execFile } from 'node:child_process';
2
+ import crypto from 'node:crypto';
3
+ import * as fs from 'node:fs/promises';
4
+ import * as os from 'node:os';
5
+ import * as path from 'node:path';
6
+ import { promisify } from 'node:util';
7
+ import { fileURLToPath, pathToFileURL } from 'node:url';
8
+ import { compareStrictSemVer, parseStrictSemVer } from './semver.mjs';
9
+ import { assertAuthoringPluginPathFence, resolveAuthoringPluginRoot, } from './plugin-root.mjs';
10
+ const execFileAsync = promisify(execFile);
11
+ const EXPECTED_MANIFEST_CONTRACT_VERSION = 7;
12
+ const CLI_PACKAGE_NAME = '@lesliechan721/aw';
13
+ const PLUGIN_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
14
+ const CLI_REGISTRY_RELATIVE_PATHS = [
15
+ 'src/utils/skill-frontmatter-capabilities.json',
16
+ 'src/utils/plugin-authoring-capabilities.json',
17
+ ];
18
+ const CLI_PACKAGE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..', '..', '..');
19
+ export class PluginVersionCheckError extends Error {
20
+ constructor(code, message) {
21
+ super(message);
22
+ this.name = 'PluginVersionCheckError';
23
+ this.code = code;
24
+ }
25
+ }
26
+ function codedError(code, message) {
27
+ return new PluginVersionCheckError(code, message);
28
+ }
29
+ function parseStablePluginVersion(version, fieldName) {
30
+ const parsed = parseStrictSemVer(version, fieldName);
31
+ if (parsed.prerelease.length > 0 || parsed.build.length > 0) {
32
+ throw codedError('invalidPlugin', `${fieldName} must be a stable SemVer without prerelease or build metadata.`);
33
+ }
34
+ return parsed;
35
+ }
36
+ async function runGit(repoRoot, args, options = {}) {
37
+ try {
38
+ const result = await execFileAsync('git', args, {
39
+ cwd: repoRoot,
40
+ encoding: options.buffer ? null : 'utf8',
41
+ maxBuffer: 50 * 1024 * 1024,
42
+ });
43
+ return result.stdout;
44
+ }
45
+ catch (error) {
46
+ const detail = Buffer.isBuffer(error.stderr)
47
+ ? error.stderr.toString('utf8').trim()
48
+ : String(error.stderr ?? error.message).trim();
49
+ throw codedError(options.code ?? 'gitFailed', `${options.label ?? `git ${args.join(' ')}`} failed${detail ? `: ${detail}` : '.'}`);
50
+ }
51
+ }
52
+ async function resolveBaseCommit(repoRoot, base) {
53
+ await runGit(repoRoot, ['rev-parse', '--show-toplevel'], {
54
+ code: 'gitUnavailable',
55
+ label: 'Git repository discovery',
56
+ });
57
+ const output = await runGit(repoRoot, ['rev-parse', '--verify', `${base}^{commit}`], {
58
+ code: 'invalidBase',
59
+ label: `Git base ${JSON.stringify(base)}`,
60
+ });
61
+ return output.trim();
62
+ }
63
+ async function loadProductionBundler(cliPackageRoot) {
64
+ const manifestModulePath = path.join(cliPackageRoot, 'dist', 'src', 'utils', 'manifest.js');
65
+ const generatorModulePath = path.join(cliPackageRoot, 'dist', 'src', 'generators', 'local-plugin.js');
66
+ const digestModulePath = path.join(cliPackageRoot, 'dist', 'src', 'utils', 'catalog-digests.js');
67
+ const runtimeProjectionModulePath = path.join(cliPackageRoot, 'dist', 'src', 'utils', 'catalog-runtime-projection.js');
68
+ const requiredPaths = [
69
+ manifestModulePath,
70
+ generatorModulePath,
71
+ digestModulePath,
72
+ runtimeProjectionModulePath,
73
+ ];
74
+ const exists = await Promise.all(requiredPaths.map((filePath) => fs.stat(filePath).then((stat) => stat.isFile(), () => false)));
75
+ if (exists.some((value) => !value)) {
76
+ throw codedError('bundlerUnavailable', 'Plugin version checking requires a built CLI; run `pnpm build` first.');
77
+ }
78
+ let manifestModule;
79
+ let generatorModule;
80
+ let digestModule;
81
+ let runtimeProjectionModule;
82
+ try {
83
+ [manifestModule, generatorModule, digestModule, runtimeProjectionModule] = await Promise.all([
84
+ import(pathToFileURL(manifestModulePath).href),
85
+ import(pathToFileURL(generatorModulePath).href),
86
+ import(pathToFileURL(digestModulePath).href),
87
+ import(pathToFileURL(runtimeProjectionModulePath).href),
88
+ ]);
89
+ }
90
+ catch (error) {
91
+ throw codedError('bundlerUnavailable', `Failed to load built CLI bundler: ${error.message}`);
92
+ }
93
+ if (manifestModule.SOURCE_PLUGIN_MANIFEST_CONTRACT_VERSION
94
+ !== EXPECTED_MANIFEST_CONTRACT_VERSION
95
+ || typeof manifestModule.readPluginManifest !== 'function'
96
+ || typeof manifestModule.discoverPlugins !== 'function'
97
+ || typeof generatorModule.bundleLocalPlugin !== 'function'
98
+ || typeof digestModule.calculateCatalogEntryArtifactDigest !== 'function'
99
+ || typeof runtimeProjectionModule.createCatalogRuntimeImportResolver !== 'function') {
100
+ throw codedError('bundlerUnavailable', 'Built CLI authoring contract is incompatible; run `pnpm build` and retry.');
101
+ }
102
+ return {
103
+ readPluginManifest: manifestModule.readPluginManifest,
104
+ discoverPlugins: manifestModule.discoverPlugins,
105
+ bundleLocalPlugin: generatorModule.bundleLocalPlugin,
106
+ calculateArtifactDigest: digestModule.calculateCatalogEntryArtifactDigest,
107
+ createRuntimeResolver: runtimeProjectionModule.createCatalogRuntimeImportResolver,
108
+ };
109
+ }
110
+ function parseTreeRecord(record) {
111
+ const tabIndex = record.indexOf('\t');
112
+ const metadata = record.slice(0, tabIndex).split(' ');
113
+ return {
114
+ mode: metadata[0],
115
+ type: metadata[1],
116
+ objectId: metadata[2],
117
+ filePath: record.slice(tabIndex + 1),
118
+ };
119
+ }
120
+ async function materializeBaseAuthoringSourceSet(repoRoot, baseCommit, outputRoot, pluginRootPath) {
121
+ const sourcePaths = [
122
+ 'plugins',
123
+ 'packages/cli/package.json',
124
+ 'packages/cli/src/utils/skill-frontmatter-capabilities.json',
125
+ 'packages/cli/src/utils/plugin-authoring-capabilities.json',
126
+ ];
127
+ if (pluginRootPath && !sourcePaths.includes(pluginRootPath))
128
+ sourcePaths.push(pluginRootPath);
129
+ const output = await runGit(repoRoot, ['ls-tree', '-r', '-z', baseCommit, '--', ...sourcePaths], { buffer: true, label: 'Git authoring source tree' });
130
+ const records = output.toString('utf8').split('\0').filter(Boolean).map(parseTreeRecord);
131
+ for (const record of records) {
132
+ if (record.type !== 'blob')
133
+ continue;
134
+ const normalizedPath = path.posix.normalize(record.filePath);
135
+ if (normalizedPath !== record.filePath
136
+ || normalizedPath === '..'
137
+ || normalizedPath.startsWith('../')
138
+ || path.posix.isAbsolute(normalizedPath)) {
139
+ throw codedError('gitFailed', `Unsafe Git authoring path: ${JSON.stringify(record.filePath)}.`);
140
+ }
141
+ const targetPath = path.join(outputRoot, ...normalizedPath.split('/'));
142
+ await fs.mkdir(path.dirname(targetPath), { recursive: true });
143
+ const content = await runGit(repoRoot, ['cat-file', 'blob', record.objectId], {
144
+ buffer: true,
145
+ label: `Git blob ${record.objectId}`,
146
+ });
147
+ if (record.mode === '120000') {
148
+ await fs.symlink(content.toString('utf8'), targetPath);
149
+ }
150
+ else {
151
+ await fs.writeFile(targetPath, content);
152
+ if (record.mode === '100755')
153
+ await fs.chmod(targetPath, 0o755);
154
+ }
155
+ }
156
+ return outputRoot;
157
+ }
158
+ async function lstatOrNull(filePath) {
159
+ return fs.lstat(filePath).catch((error) => {
160
+ if (error?.code === 'ENOENT')
161
+ return null;
162
+ throw error;
163
+ });
164
+ }
165
+ async function assertRegularFilePath(rootDir, relativePath, label) {
166
+ const rootStat = await lstatOrNull(rootDir);
167
+ if (!rootStat || rootStat.isSymbolicLink() || !rootStat.isDirectory()) {
168
+ throw codedError('invalidPlugin', `${label} root must be a non-symbolic-link directory.`);
169
+ }
170
+ let currentPath = rootDir;
171
+ const segments = relativePath.split('/');
172
+ for (const [index, segment] of segments.entries()) {
173
+ currentPath = path.join(currentPath, segment);
174
+ const stat = await lstatOrNull(currentPath);
175
+ if (!stat) {
176
+ throw codedError('invalidPlugin', `${label} is missing ${JSON.stringify(relativePath)}.`);
177
+ }
178
+ if (stat.isSymbolicLink()) {
179
+ throw codedError('invalidPlugin', `${label} contains a symbolic-link node: ${currentPath}`);
180
+ }
181
+ if (index < segments.length - 1 && !stat.isDirectory()) {
182
+ throw codedError('invalidPlugin', `${label} contains a non-directory path node: ${currentPath}`);
183
+ }
184
+ if (index === segments.length - 1 && !stat.isFile()) {
185
+ throw codedError('invalidPlugin', `${label} must use a regular file: ${currentPath}`);
186
+ }
187
+ }
188
+ return currentPath;
189
+ }
190
+ async function assertDirectoryPathChain(boundaryRoot, targetRoot, label) {
191
+ const relative = path.relative(boundaryRoot, targetRoot);
192
+ if (relative === '..' || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) {
193
+ throw codedError('invalidPlugin', `${label} source root must stay inside its workspace.`);
194
+ }
195
+ let currentPath = boundaryRoot;
196
+ for (const segment of relative.split(path.sep).filter(Boolean)) {
197
+ currentPath = path.join(currentPath, segment);
198
+ const stat = await lstatOrNull(currentPath);
199
+ if (!stat)
200
+ return;
201
+ if (stat.isSymbolicLink()) {
202
+ throw codedError('invalidPlugin', `${label} contains a symbolic-link path node: ${currentPath}`);
203
+ }
204
+ if (!stat.isDirectory()) {
205
+ throw codedError('invalidPlugin', `${label} contains a non-directory path node: ${currentPath}`);
206
+ }
207
+ }
208
+ }
209
+ function calculateCliSourceSetDigest(packageBytes, registryEntries) {
210
+ const hash = crypto.createHash('sha256').update('package.json\0').update(packageBytes);
211
+ for (const [relativePath, bytes] of registryEntries) {
212
+ hash.update(`\0${relativePath}\0`).update(bytes);
213
+ }
214
+ return `sha256:${hash.digest('hex')}`;
215
+ }
216
+ async function inspectWorkspaceCliSourceSet(cliRoot, label, boundaryRoot) {
217
+ if (boundaryRoot)
218
+ await assertDirectoryPathChain(boundaryRoot, cliRoot, label);
219
+ const packagePath = path.join(cliRoot, 'package.json');
220
+ const registryPaths = CLI_REGISTRY_RELATIVE_PATHS.map((relativePath) => path.join(cliRoot, ...relativePath.split('/')));
221
+ const [packageStat, ...registryStats] = await Promise.all([
222
+ lstatOrNull(packagePath),
223
+ ...registryPaths.map((registryPath) => lstatOrNull(registryPath)),
224
+ ]);
225
+ if (!packageStat && registryStats.every((stat) => !stat)) {
226
+ const cliRootStat = await lstatOrNull(cliRoot);
227
+ if (cliRootStat?.isSymbolicLink() || (cliRootStat && !cliRootStat.isDirectory())) {
228
+ throw codedError('invalidPlugin', `${label} @aw/cli source root has an invalid node: ${cliRoot}`);
229
+ }
230
+ return { state: 'none', root: cliRoot };
231
+ }
232
+ if (!packageStat || !registryStats[0]) {
233
+ return { state: 'partial', root: cliRoot };
234
+ }
235
+ const availableRegistryRelativePaths = CLI_REGISTRY_RELATIVE_PATHS
236
+ .filter((_relativePath, index) => registryStats[index]);
237
+ await Promise.all([
238
+ assertRegularFilePath(cliRoot, 'package.json', `${label} @aw/cli source set`),
239
+ ...availableRegistryRelativePaths.map((relativePath) => assertRegularFilePath(cliRoot, relativePath, `${label} @aw/cli source set`)),
240
+ ]);
241
+ const availableRegistryPaths = availableRegistryRelativePaths.map((relativePath) => path.join(cliRoot, ...relativePath.split('/')));
242
+ const [packageBytes, ...registryBytes] = await Promise.all([
243
+ fs.readFile(packagePath),
244
+ ...availableRegistryPaths.map((registryPath) => fs.readFile(registryPath)),
245
+ ]);
246
+ let packageDocument;
247
+ try {
248
+ packageDocument = JSON.parse(packageBytes.toString('utf8'));
249
+ for (const bytes of registryBytes)
250
+ JSON.parse(bytes.toString('utf8'));
251
+ }
252
+ catch (error) {
253
+ throw codedError('invalidPlugin', `${label} @aw/cli source set contains invalid JSON: ${error.message}`);
254
+ }
255
+ if (typeof packageDocument?.name !== 'string' || packageDocument.name.trim() === '') {
256
+ throw codedError('invalidPlugin', `${label} @aw/cli package name is missing.`);
257
+ }
258
+ parseStrictSemVer(packageDocument.version, `${label} @aw/cli package version`);
259
+ return {
260
+ state: 'complete',
261
+ root: cliRoot,
262
+ packageName: packageDocument.name,
263
+ providerVersion: packageDocument.version,
264
+ digest: calculateCliSourceSetDigest(packageBytes, availableRegistryRelativePaths.map((relativePath, index) => [relativePath, registryBytes[index]])),
265
+ registryRelativePaths: availableRegistryRelativePaths,
266
+ };
267
+ }
268
+ async function materializeCliSourceSet(source, outputRoot, label) {
269
+ await fs.mkdir(path.join(outputRoot, 'src', 'utils'), { recursive: true });
270
+ await Promise.all([
271
+ fs.copyFile(path.join(source.root, 'package.json'), path.join(outputRoot, 'package.json')),
272
+ ...source.registryRelativePaths.map((relativePath) => fs.copyFile(path.join(source.root, ...relativePath.split('/')), path.join(outputRoot, ...relativePath.split('/')))),
273
+ ]);
274
+ const materialized = await inspectWorkspaceCliSourceSet(outputRoot, label);
275
+ if (materialized.state !== 'complete'
276
+ || materialized.packageName !== source.packageName
277
+ || materialized.providerVersion !== source.providerVersion
278
+ || materialized.digest !== source.digest) {
279
+ throw codedError('invalidPlugin', `${label} @aw/cli source identity changed during materialization.`);
280
+ }
281
+ return materialized;
282
+ }
283
+ async function inspectExternalCliProvider(cliPackageRoot) {
284
+ const canonicalRoot = await fs.realpath(cliPackageRoot).catch(() => null);
285
+ if (!canonicalRoot) {
286
+ throw codedError('bundlerUnavailable', 'Plugin version checking cannot resolve the installed CLI package root.');
287
+ }
288
+ const packagePath = await assertRegularFilePath(canonicalRoot, 'package.json', 'Installed CLI provider');
289
+ const registryPaths = await Promise.all(CLI_REGISTRY_RELATIVE_PATHS.map((relativePath) => assertRegularFilePath(canonicalRoot, `dist/${relativePath}`, 'Installed CLI provider')));
290
+ const [packageBytes, ...registryBytes] = await Promise.all([
291
+ fs.readFile(packagePath),
292
+ ...registryPaths.map((registryPath) => fs.readFile(registryPath)),
293
+ ]);
294
+ let packageDocument;
295
+ try {
296
+ packageDocument = JSON.parse(packageBytes.toString('utf8'));
297
+ for (const bytes of registryBytes)
298
+ JSON.parse(bytes.toString('utf8'));
299
+ }
300
+ catch (error) {
301
+ throw codedError('bundlerUnavailable', `Installed CLI provider contains invalid JSON: ${error.message}`);
302
+ }
303
+ if (packageDocument?.name !== CLI_PACKAGE_NAME) {
304
+ throw codedError('bundlerUnavailable', `Installed CLI provider package name must be ${JSON.stringify(CLI_PACKAGE_NAME)}.`);
305
+ }
306
+ parseStrictSemVer(packageDocument.version, 'installed CLI provider version');
307
+ return {
308
+ root: canonicalRoot,
309
+ packagePath,
310
+ registryPaths,
311
+ packageName: packageDocument.name,
312
+ providerVersion: packageDocument.version,
313
+ digest: calculateCliSourceSetDigest(packageBytes, CLI_REGISTRY_RELATIVE_PATHS.map((relativePath, index) => [relativePath, registryBytes[index]])),
314
+ };
315
+ }
316
+ async function materializeExternalCliProvider(provider, outputRoot, label) {
317
+ await fs.mkdir(path.join(outputRoot, 'src', 'utils'), { recursive: true });
318
+ await Promise.all([
319
+ fs.copyFile(provider.packagePath, path.join(outputRoot, 'package.json')),
320
+ ...CLI_REGISTRY_RELATIVE_PATHS.map((relativePath, index) => fs.copyFile(provider.registryPaths[index], path.join(outputRoot, ...relativePath.split('/')))),
321
+ ]);
322
+ return inspectWorkspaceCliSourceSet(outputRoot, label);
323
+ }
324
+ async function resolveCliVirtualSourceSets(options) {
325
+ const baseSource = await inspectWorkspaceCliSourceSet(path.join(options.baseSourceRoot, 'packages', 'cli'), 'Git base', options.baseSourceRoot);
326
+ const currentSource = await inspectWorkspaceCliSourceSet(path.join(options.repoRoot, 'packages', 'cli'), 'current workspace', options.repoRoot);
327
+ if (baseSource.state === 'partial') {
328
+ throw codedError('invalidPlugin', 'Git base contains an incomplete @aw/cli virtual authoring source set.');
329
+ }
330
+ if (currentSource.state === 'partial') {
331
+ throw codedError('invalidPlugin', 'Found an incomplete current workspace @aw/cli source set.');
332
+ }
333
+ if (baseSource.state !== currentSource.state) {
334
+ throw codedError('invalidPlugin', 'Git base and current workspace CLI source ownership differs; version checking cannot mix workspace and external providers.');
335
+ }
336
+ if (baseSource.state === 'complete') {
337
+ const currentMaterialized = await materializeCliSourceSet(currentSource, path.join(options.tempRoot, 'current-cli-workspace'), 'current workspace materialization');
338
+ return {
339
+ base: baseSource,
340
+ current: currentMaterialized,
341
+ };
342
+ }
343
+ const externalProvider = await inspectExternalCliProvider(options.cliPackageRoot);
344
+ const [baseExternal, currentExternal] = await Promise.all([
345
+ materializeExternalCliProvider(externalProvider, path.join(options.tempRoot, 'base-cli-external'), 'base external CLI provider'),
346
+ materializeExternalCliProvider(externalProvider, path.join(options.tempRoot, 'current-cli-external'), 'current external CLI provider'),
347
+ ]);
348
+ for (const materialized of [baseExternal, currentExternal]) {
349
+ if (materialized.state !== 'complete'
350
+ || materialized.packageName !== externalProvider.packageName
351
+ || materialized.providerVersion !== externalProvider.providerVersion
352
+ || materialized.digest !== externalProvider.digest) {
353
+ throw codedError('invalidPlugin', 'External CLI provider identity changed during independent materialization.');
354
+ }
355
+ }
356
+ if (baseExternal.root === currentExternal.root || baseExternal.digest !== currentExternal.digest) {
357
+ throw codedError('invalidPlugin', 'External CLI provider materializations are not independent and identical.');
358
+ }
359
+ return { base: baseExternal, current: currentExternal };
360
+ }
361
+ async function readManifestDocument(pluginRoot) {
362
+ const manifestPath = path.join(pluginRoot, '.agents-plugin', 'plugin.json');
363
+ let manifest;
364
+ try {
365
+ manifest = JSON.parse(await fs.readFile(manifestPath, 'utf8'));
366
+ }
367
+ catch (error) {
368
+ throw codedError('invalidPlugin', `Cannot read ${manifestPath}: ${error.message}`);
369
+ }
370
+ if (!manifest || typeof manifest !== 'object' || Array.isArray(manifest)) {
371
+ throw codedError('invalidPlugin', `${manifestPath} must contain a JSON object.`);
372
+ }
373
+ return { manifestPath, manifest };
374
+ }
375
+ async function hashBundleEntries(rootDir) {
376
+ const entries = new Map();
377
+ async function visit(currentDir, prefix = '') {
378
+ const children = await fs.readdir(currentDir, { withFileTypes: true });
379
+ for (const child of children.sort((left, right) => left.name.localeCompare(right.name))) {
380
+ const relativePath = prefix ? `${prefix}/${child.name}` : child.name;
381
+ const absolutePath = path.join(currentDir, child.name);
382
+ const stat = await fs.lstat(absolutePath);
383
+ if (stat.isDirectory()) {
384
+ await visit(absolutePath, relativePath);
385
+ }
386
+ else if (stat.isSymbolicLink()) {
387
+ entries.set(relativePath, `symlink:${await fs.readlink(absolutePath)}`);
388
+ }
389
+ else {
390
+ const digest = crypto.createHash('sha256').update(await fs.readFile(absolutePath)).digest('hex');
391
+ entries.set(relativePath, `sha256:${digest}`);
392
+ }
393
+ }
394
+ }
395
+ await visit(rootDir);
396
+ return entries;
397
+ }
398
+ function compareBundleEntries(baseEntries, currentEntries) {
399
+ const paths = new Set([...baseEntries.keys(), ...currentEntries.keys()]);
400
+ return [...paths]
401
+ .filter((filePath) => baseEntries.get(filePath) !== currentEntries.get(filePath))
402
+ .sort();
403
+ }
404
+ async function bundlePlugin(bundler, sourceSetRoot, cliVirtualExportRoot, cliProviderVersion, pluginRoot, outputRoot, runtimeSkillClosureValidation = 'current') {
405
+ const sourceSetPlugins = await bundler.discoverPlugins(sourceSetRoot);
406
+ const plugin = await bundler.readPluginManifest(pluginRoot);
407
+ if (!sourceSetPlugins.some((candidate) => candidate.manifest.name === plugin.manifest.name)) {
408
+ sourceSetPlugins.push(plugin);
409
+ }
410
+ const runtimeResolver = bundler.createRuntimeResolver(sourceSetPlugins, {
411
+ cliVirtualExportRoot,
412
+ cliProviderVersion,
413
+ });
414
+ await bundler.bundleLocalPlugin(plugin, outputRoot, {
415
+ buildMode: 'staging',
416
+ runtimeResolver,
417
+ runtimeSkillClosureValidation,
418
+ });
419
+ return {
420
+ digest: await bundler.calculateArtifactDigest(outputRoot),
421
+ entries: await hashBundleEntries(outputRoot),
422
+ };
423
+ }
424
+ function createCheckResult(pluginName, values = {}) {
425
+ return {
426
+ plugin: pluginName,
427
+ ok: values.ok ?? true,
428
+ status: values.status ?? 'unchanged',
429
+ baseVersion: values.baseVersion ?? null,
430
+ currentVersion: values.currentVersion ?? null,
431
+ baseTarget: values.baseTarget ?? values.baseVersion ?? null,
432
+ currentTarget: values.currentTarget ?? values.currentVersion ?? null,
433
+ productionChanged: values.productionChanged ?? null,
434
+ baseDigest: values.baseDigest ?? null,
435
+ currentDigest: values.currentDigest ?? null,
436
+ changedPaths: values.changedPaths ?? [],
437
+ warnings: values.warnings ?? [],
438
+ errors: values.errors ?? [],
439
+ };
440
+ }
441
+ async function checkOnePlugin(options) {
442
+ const { repoRoot, pluginName, bundler, tempRoot, baseSourceRoot, cliVirtualSources, currentRoot, baseRoot, } = options;
443
+ if (!PLUGIN_NAME_PATTERN.test(pluginName)) {
444
+ return createCheckResult(pluginName, {
445
+ ok: false,
446
+ status: 'error',
447
+ errors: [`Invalid plugin name ${JSON.stringify(pluginName)}.`],
448
+ });
449
+ }
450
+ const currentExists = await fs.stat(currentRoot).then((stat) => stat.isDirectory(), () => false);
451
+ if (!currentExists && !baseRoot) {
452
+ return createCheckResult(pluginName, {
453
+ ok: false,
454
+ status: 'error',
455
+ errors: [`Plugin ${JSON.stringify(pluginName)} does not exist in the base or working tree.`],
456
+ });
457
+ }
458
+ if (!currentExists) {
459
+ return createCheckResult(pluginName, { status: 'deleted' });
460
+ }
461
+ let currentDocument;
462
+ try {
463
+ currentDocument = await readManifestDocument(currentRoot);
464
+ if (currentDocument.manifest.name !== pluginName) {
465
+ throw codedError('invalidPlugin', `Current manifest name ${JSON.stringify(currentDocument.manifest.name)} does not match ${JSON.stringify(pluginName)}.`);
466
+ }
467
+ parseStablePluginVersion(currentDocument.manifest.version, 'current plugin version');
468
+ }
469
+ catch (error) {
470
+ return createCheckResult(pluginName, {
471
+ ok: false,
472
+ status: 'error',
473
+ errors: [error.message],
474
+ });
475
+ }
476
+ if (!baseRoot) {
477
+ let currentBundle;
478
+ try {
479
+ currentBundle = await bundlePlugin(bundler, repoRoot, cliVirtualSources.current.root, cliVirtualSources.current.providerVersion, currentRoot, path.join(tempRoot, 'bundles', pluginName, 'current'));
480
+ }
481
+ catch (error) {
482
+ return createCheckResult(pluginName, {
483
+ ok: false,
484
+ status: 'error',
485
+ currentVersion: currentDocument.manifest.version,
486
+ errors: [`Production bundle failed: current: ${error.message}`],
487
+ });
488
+ }
489
+ return createCheckResult(pluginName, {
490
+ status: 'new',
491
+ currentVersion: currentDocument.manifest.version,
492
+ productionChanged: true,
493
+ currentDigest: currentBundle.digest,
494
+ changedPaths: [...currentBundle.entries.keys()].sort(),
495
+ });
496
+ }
497
+ let baseDocument;
498
+ try {
499
+ baseDocument = await readManifestDocument(baseRoot);
500
+ if (baseDocument.manifest.name !== pluginName) {
501
+ throw codedError('invalidPlugin', `Base manifest name ${JSON.stringify(baseDocument.manifest.name)} does not match ${JSON.stringify(pluginName)}.`);
502
+ }
503
+ parseStablePluginVersion(baseDocument.manifest.version, 'base plugin version');
504
+ }
505
+ catch (error) {
506
+ return createCheckResult(pluginName, {
507
+ ok: false,
508
+ status: 'error',
509
+ currentVersion: currentDocument.manifest.version,
510
+ errors: [error.message],
511
+ });
512
+ }
513
+ const baseVersion = baseDocument.manifest.version;
514
+ const currentVersion = currentDocument.manifest.version;
515
+ const precedence = compareStrictSemVer(currentVersion, baseVersion);
516
+ baseDocument.manifest.version = currentVersion;
517
+ await fs.writeFile(baseDocument.manifestPath, `${JSON.stringify(baseDocument.manifest, null, 2)}\n`, 'utf8');
518
+ let baseBundle;
519
+ let currentBundle;
520
+ let bundleResults;
521
+ try {
522
+ bundleResults = await Promise.allSettled([
523
+ bundlePlugin(bundler, baseSourceRoot, cliVirtualSources.base.root, cliVirtualSources.base.providerVersion, baseRoot, path.join(tempRoot, 'bundles', pluginName, 'base'), 'historical'),
524
+ bundlePlugin(bundler, repoRoot, cliVirtualSources.current.root, cliVirtualSources.current.providerVersion, currentRoot, path.join(tempRoot, 'bundles', pluginName, 'current')),
525
+ ]);
526
+ }
527
+ finally {
528
+ baseDocument.manifest.version = baseVersion;
529
+ await fs.writeFile(baseDocument.manifestPath, `${JSON.stringify(baseDocument.manifest, null, 2)}\n`, 'utf8');
530
+ }
531
+ const bundleFailures = bundleResults
532
+ .map((result, index) => result.status === 'rejected'
533
+ ? `${index === 0 ? 'base' : 'current'}: ${result.reason?.message ?? String(result.reason)}`
534
+ : null)
535
+ .filter(Boolean);
536
+ if (bundleFailures.length > 0) {
537
+ return createCheckResult(pluginName, {
538
+ ok: false,
539
+ status: 'error',
540
+ baseVersion,
541
+ currentVersion,
542
+ errors: [
543
+ `Production bundle failed: ${bundleFailures[0]}`,
544
+ ...bundleFailures.slice(1).map((failure) => `Secondary bundle failure: ${failure}`),
545
+ ],
546
+ });
547
+ }
548
+ [baseBundle, currentBundle] = bundleResults.map((result) => result.value);
549
+ const changedPaths = compareBundleEntries(baseBundle.entries, currentBundle.entries);
550
+ const productionChanged = baseBundle.digest !== currentBundle.digest;
551
+ const common = {
552
+ baseVersion,
553
+ currentVersion,
554
+ productionChanged,
555
+ baseDigest: baseBundle.digest,
556
+ currentDigest: currentBundle.digest,
557
+ changedPaths,
558
+ };
559
+ if (precedence < 0) {
560
+ return createCheckResult(pluginName, {
561
+ ...common,
562
+ ok: false,
563
+ status: 'versionDowngrade',
564
+ errors: [`Plugin version decreased from ${baseVersion} to ${currentVersion}.`],
565
+ });
566
+ }
567
+ if (precedence === 0 && currentVersion !== baseVersion) {
568
+ return createCheckResult(pluginName, {
569
+ ...common,
570
+ ok: false,
571
+ status: 'nonIncreasingVersion',
572
+ errors: [
573
+ `Plugin version changed from ${baseVersion} to ${currentVersion} without higher SemVer precedence.`,
574
+ ],
575
+ });
576
+ }
577
+ if (productionChanged && precedence === 0) {
578
+ return createCheckResult(pluginName, {
579
+ ...common,
580
+ status: 'unreleasedChanges',
581
+ warnings: [
582
+ `Production bundle changed while the current stable target remains ${currentVersion}; the release target may need adjustment before publishing.`,
583
+ ],
584
+ });
585
+ }
586
+ if (!productionChanged && precedence > 0) {
587
+ return createCheckResult(pluginName, {
588
+ ...common,
589
+ status: 'versionOnly',
590
+ warnings: [`Plugin version increased from ${baseVersion} to ${currentVersion}, but the production bundle is unchanged.`],
591
+ });
592
+ }
593
+ return createCheckResult(pluginName, {
594
+ ...common,
595
+ status: productionChanged ? 'versionBumped' : 'unchanged',
596
+ });
597
+ }
598
+ async function listPluginNames(sourceSetRoot) {
599
+ const entries = await fs.readdir(path.join(sourceSetRoot, 'plugins'), {
600
+ withFileTypes: true,
601
+ }).catch((error) => {
602
+ if (error?.code === 'ENOENT')
603
+ return [];
604
+ throw error;
605
+ });
606
+ return entries
607
+ .filter((entry) => entry.isDirectory() || entry.isSymbolicLink())
608
+ .map((entry) => entry.name);
609
+ }
610
+ export async function checkPluginVersions(options = {}) {
611
+ const requestedRepoRoot = path.resolve(options.repoRoot ?? '.');
612
+ const cliPackageRoot = path.resolve(options.cliPackageRoot ?? CLI_PACKAGE_ROOT);
613
+ const requestedBase = options.base;
614
+ assertAuthoringPluginPathFence({
615
+ repoRoot: requestedRepoRoot,
616
+ pluginRoot: requestedRepoRoot,
617
+ });
618
+ const explicitRoot = options.pluginRoot === undefined
619
+ ? null
620
+ : resolveAuthoringPluginRoot({
621
+ repoRoot: requestedRepoRoot,
622
+ pluginRoot: options.pluginRoot,
623
+ pluginName: options.pluginNames?.[0],
624
+ });
625
+ const repoRoot = explicitRoot?.repoRoot ?? requestedRepoRoot;
626
+ if (requestedBase === undefined) {
627
+ let pluginNames = options.all
628
+ ? (await listPluginNames(repoRoot)).sort()
629
+ : [...new Set(options.pluginNames ?? [])].sort();
630
+ if (explicitRoot)
631
+ pluginNames = [...new Set(options.pluginNames ?? [])].sort();
632
+ if (pluginNames.length === 0 && !options.all) {
633
+ throw codedError('usage', 'Provide a plugin name or use --all.');
634
+ }
635
+ const checks = [];
636
+ for (const pluginName of pluginNames) {
637
+ const currentRoot = explicitRoot?.pluginRoot ?? path.join(repoRoot, 'plugins', pluginName);
638
+ assertAuthoringPluginPathFence({
639
+ repoRoot,
640
+ pluginRoot: currentRoot,
641
+ requireManifest: true,
642
+ });
643
+ try {
644
+ const document = await readManifestDocument(currentRoot);
645
+ if (document.manifest.name !== pluginName) {
646
+ throw codedError('invalidPlugin', `Current manifest name ${JSON.stringify(document.manifest.name)} does not match ${JSON.stringify(pluginName)}.`);
647
+ }
648
+ parseStablePluginVersion(document.manifest.version, 'current plugin version');
649
+ checks.push(createCheckResult(pluginName, {
650
+ status: 'current',
651
+ currentVersion: document.manifest.version,
652
+ }));
653
+ }
654
+ catch (error) {
655
+ checks.push(createCheckResult(pluginName, {
656
+ ok: false,
657
+ status: 'error',
658
+ errors: [error.message],
659
+ }));
660
+ }
661
+ }
662
+ return {
663
+ schemaVersion: 3,
664
+ policy: 'development',
665
+ ok: checks.every((check) => check.ok),
666
+ base: null,
667
+ requestedBase: null,
668
+ baseCommit: null,
669
+ checkedPlugins: pluginNames.length,
670
+ checks,
671
+ };
672
+ }
673
+ const baseCommit = await resolveBaseCommit(repoRoot, requestedBase);
674
+ const bundler = await loadProductionBundler(cliPackageRoot);
675
+ const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'aw-plugin-version-check-'));
676
+ try {
677
+ const baseSourceRoot = path.join(tempRoot, 'base-source');
678
+ await materializeBaseAuthoringSourceSet(repoRoot, baseCommit, baseSourceRoot, explicitRoot?.relativePluginRoot);
679
+ let pluginNames;
680
+ if (options.all) {
681
+ const [basePluginNames, currentPluginNames] = await Promise.all([
682
+ listPluginNames(baseSourceRoot),
683
+ listPluginNames(repoRoot),
684
+ ]);
685
+ pluginNames = [...new Set([...basePluginNames, ...currentPluginNames])].sort();
686
+ }
687
+ else {
688
+ pluginNames = [...new Set(options.pluginNames ?? [])].sort();
689
+ }
690
+ if (pluginNames.length === 0 && !options.all) {
691
+ throw codedError('usage', 'Provide a plugin name or use --all.');
692
+ }
693
+ const currentRoots = new Map();
694
+ for (const pluginName of pluginNames) {
695
+ const currentRoot = explicitRoot?.pluginRoot ?? path.join(repoRoot, 'plugins', pluginName);
696
+ if (await lstatOrNull(currentRoot)) {
697
+ assertAuthoringPluginPathFence({
698
+ repoRoot,
699
+ pluginRoot: currentRoot,
700
+ requireManifest: true,
701
+ });
702
+ }
703
+ currentRoots.set(pluginName, currentRoot);
704
+ }
705
+ const cliVirtualSources = await resolveCliVirtualSourceSets({
706
+ baseSourceRoot,
707
+ repoRoot,
708
+ cliPackageRoot,
709
+ tempRoot,
710
+ });
711
+ const checks = [];
712
+ for (const pluginName of pluginNames) {
713
+ const currentRoot = currentRoots.get(pluginName);
714
+ const candidateBaseRoot = explicitRoot
715
+ ? path.join(baseSourceRoot, ...explicitRoot.relativePluginRoot.split('/'))
716
+ : path.join(baseSourceRoot, 'plugins', pluginName);
717
+ const baseNode = await lstatOrNull(candidateBaseRoot);
718
+ const baseRoot = baseNode ? candidateBaseRoot : null;
719
+ if (baseRoot) {
720
+ assertAuthoringPluginPathFence({
721
+ repoRoot: baseSourceRoot,
722
+ pluginRoot: baseRoot,
723
+ requirePluginRoot: true,
724
+ requireManifest: true,
725
+ });
726
+ }
727
+ checks.push(await checkOnePlugin({
728
+ repoRoot,
729
+ pluginName,
730
+ bundler,
731
+ tempRoot,
732
+ baseSourceRoot,
733
+ cliVirtualSources,
734
+ currentRoot,
735
+ baseRoot,
736
+ }));
737
+ }
738
+ return {
739
+ schemaVersion: 3,
740
+ policy: 'development',
741
+ ok: checks.every((check) => check.ok),
742
+ base: {
743
+ requested: requestedBase,
744
+ commit: baseCommit,
745
+ },
746
+ requestedBase,
747
+ baseCommit,
748
+ checkedPlugins: pluginNames.length,
749
+ checks,
750
+ };
751
+ }
752
+ finally {
753
+ await fs.rm(tempRoot, { recursive: true, force: true });
754
+ }
755
+ }
756
+ export function formatPluginVersionCheck(result) {
757
+ if (result.checkedPlugins === 0) {
758
+ return result.requestedBase
759
+ ? `[PASS] No plugin source changes relative to ${result.requestedBase}.`
760
+ : '[PASS] No current workspace plugins.';
761
+ }
762
+ const lines = [];
763
+ for (const check of result.checks) {
764
+ lines.push(`${check.ok ? '[PASS]' : '[FAIL]'} ${check.plugin}: ${check.status}`);
765
+ if (check.baseVersion || check.currentVersion) {
766
+ lines.push(` stable target: ${check.baseTarget ?? '(new)'} -> ${check.currentTarget ?? '(deleted)'}`);
767
+ }
768
+ for (const changedPath of check.changedPaths)
769
+ lines.push(` changed: ${changedPath}`);
770
+ for (const warning of check.warnings)
771
+ lines.push(` warning: ${warning}`);
772
+ for (const error of check.errors)
773
+ lines.push(` error: ${error}`);
774
+ }
775
+ return lines.join('\n');
776
+ }
777
+ //# sourceMappingURL=plugin-version-check.mjs.map