@lesliechan721/aw 0.1.0-beta.73 → 0.1.0-beta.75

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 (370) hide show
  1. package/dist/authoring/assets/aw-runtime-config.mjs +65 -43
  2. package/dist/authoring/assets/aw-runtime-config.mjs.map +1 -1
  3. package/dist/authoring/scripts/add-skill.mjs +5 -14
  4. package/dist/authoring/scripts/add-skill.mjs.map +1 -1
  5. package/dist/authoring/scripts/init-plugin.mjs +4 -28
  6. package/dist/authoring/scripts/init-plugin.mjs.map +1 -1
  7. package/dist/authoring/scripts/lib/plugin-version-check.mjs +2 -2
  8. package/dist/authoring/scripts/lib/plugin-version-check.mjs.map +1 -1
  9. package/dist/authoring/scripts/lib/skill-scaffold.mjs +0 -1
  10. package/dist/authoring/scripts/lib/skill-scaffold.mjs.map +1 -1
  11. package/dist/authoring/scripts/validate-plugin.mjs +234 -1422
  12. package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
  13. package/dist/scripts/aw-skill-eval-materializer.d.ts +2 -0
  14. package/dist/scripts/aw-skill-eval-materializer.js +19 -80
  15. package/dist/scripts/aw-skill-eval-materializer.js.map +1 -1
  16. package/dist/scripts/bundle-plugins.js.map +1 -1
  17. package/dist/scripts/test-plugin-scripts.js +6 -8
  18. package/dist/scripts/test-plugin-scripts.js.map +1 -1
  19. package/dist/src/commands/aw-capabilities.d.ts +1 -1
  20. package/dist/src/commands/aw-capabilities.js +2 -2
  21. package/dist/src/commands/aw-capabilities.js.map +1 -1
  22. package/dist/src/commands/dependency-operation-plan.js +3 -3
  23. package/dist/src/commands/dependency-operation-plan.js.map +1 -1
  24. package/dist/src/commands/deployment-confirmation.d.ts +4 -0
  25. package/dist/src/commands/deployment-confirmation.js +20 -0
  26. package/dist/src/commands/deployment-confirmation.js.map +1 -0
  27. package/dist/src/commands/managed-commands.js +4 -2
  28. package/dist/src/commands/managed-commands.js.map +1 -1
  29. package/dist/src/commands/offline-cleanup-evidence.d.ts +3 -1
  30. package/dist/src/commands/offline-cleanup-evidence.js +9 -4
  31. package/dist/src/commands/offline-cleanup-evidence.js.map +1 -1
  32. package/dist/src/commands/operation-plan.d.ts +6 -0
  33. package/dist/src/commands/operation-plan.js +29 -2
  34. package/dist/src/commands/operation-plan.js.map +1 -1
  35. package/dist/src/commands/options.d.ts +6 -2
  36. package/dist/src/commands/options.js +5 -4
  37. package/dist/src/commands/options.js.map +1 -1
  38. package/dist/src/commands/plugin-capabilities.js +29 -41
  39. package/dist/src/commands/plugin-capabilities.js.map +1 -1
  40. package/dist/src/commands/public-config-confirmation.js +5 -5
  41. package/dist/src/commands/public-config-confirmation.js.map +1 -1
  42. package/dist/src/commands/public-lifecycle-result.d.ts +47 -0
  43. package/dist/src/commands/public-lifecycle-result.js +125 -4
  44. package/dist/src/commands/public-lifecycle-result.js.map +1 -1
  45. package/dist/src/commands/public-lifecycle.d.ts +1 -0
  46. package/dist/src/commands/public-lifecycle.js +15 -2
  47. package/dist/src/commands/public-lifecycle.js.map +1 -1
  48. package/dist/src/commands/public-plugin-query.d.ts +1 -0
  49. package/dist/src/commands/public-plugin-query.js +27 -8
  50. package/dist/src/commands/public-plugin-query.js.map +1 -1
  51. package/dist/src/commands/rebuild-command.d.ts +12 -11
  52. package/dist/src/commands/rebuild-command.js +531 -769
  53. package/dist/src/commands/rebuild-command.js.map +1 -1
  54. package/dist/src/commands/rebuild-integration.d.ts +21 -43
  55. package/dist/src/commands/rebuild-integration.js +306 -3600
  56. package/dist/src/commands/rebuild-integration.js.map +1 -1
  57. package/dist/src/commands/rebuild-operations.d.ts +13 -0
  58. package/dist/src/commands/rebuild-operations.js +60 -15
  59. package/dist/src/commands/rebuild-operations.js.map +1 -1
  60. package/dist/src/commands/rebuild-platform-integration.d.ts +60 -0
  61. package/dist/src/commands/rebuild-platform-integration.js +1264 -0
  62. package/dist/src/commands/rebuild-platform-integration.js.map +1 -0
  63. package/dist/src/commands/review-inspection.js +41 -4
  64. package/dist/src/commands/review-inspection.js.map +1 -1
  65. package/dist/src/commands/review-preparation.d.ts +2 -0
  66. package/dist/src/commands/review-preparation.js +23 -60
  67. package/dist/src/commands/review-preparation.js.map +1 -1
  68. package/dist/src/commands/skill-eval.js +1 -0
  69. package/dist/src/commands/skill-eval.js.map +1 -1
  70. package/dist/src/commands/status-v6.d.ts +3 -1
  71. package/dist/src/commands/status-v6.js +24 -15
  72. package/dist/src/commands/status-v6.js.map +1 -1
  73. package/dist/src/commands/targets-command.d.ts +9 -0
  74. package/dist/src/commands/targets-command.js +57 -6
  75. package/dist/src/commands/targets-command.js.map +1 -1
  76. package/dist/src/commands/write-commands.js +43 -28
  77. package/dist/src/commands/write-commands.js.map +1 -1
  78. package/dist/src/constants.d.ts +2 -2
  79. package/dist/src/constants.js +2 -2
  80. package/dist/src/constants.js.map +1 -1
  81. package/dist/src/generators/local-plugin.js +59 -248
  82. package/dist/src/generators/local-plugin.js.map +1 -1
  83. package/dist/src/index.js +40 -14
  84. package/dist/src/index.js.map +1 -1
  85. package/dist/src/output/command-receipt.d.ts +1 -1
  86. package/dist/src/output/command-receipt.js +3 -1
  87. package/dist/src/output/command-receipt.js.map +1 -1
  88. package/dist/src/output/native-consent.d.ts +2 -0
  89. package/dist/src/output/native-consent.js +5 -0
  90. package/dist/src/output/native-consent.js.map +1 -0
  91. package/dist/src/output/public-result.js +72 -0
  92. package/dist/src/output/public-result.js.map +1 -1
  93. package/dist/src/output/rebuild-progress.js +5 -5
  94. package/dist/src/output/rebuild-progress.js.map +1 -1
  95. package/dist/src/output/receipt-projection.js +19 -2
  96. package/dist/src/output/receipt-projection.js.map +1 -1
  97. package/dist/src/platforms/capabilities.d.ts +10 -0
  98. package/dist/src/platforms/capabilities.js +158 -0
  99. package/dist/src/platforms/capabilities.js.map +1 -0
  100. package/dist/src/platforms/contracts.d.ts +351 -0
  101. package/dist/src/platforms/contracts.js +2 -0
  102. package/dist/src/platforms/contracts.js.map +1 -0
  103. package/dist/src/platforms/cursor-workspace-hook.d.ts +22 -0
  104. package/dist/src/platforms/cursor-workspace-hook.js +185 -0
  105. package/dist/src/platforms/cursor-workspace-hook.js.map +1 -0
  106. package/dist/src/platforms/discovery.d.ts +80 -0
  107. package/dist/src/platforms/discovery.js +604 -0
  108. package/dist/src/platforms/discovery.js.map +1 -0
  109. package/dist/src/platforms/gemini-activation.d.ts +36 -0
  110. package/dist/src/platforms/gemini-activation.js +331 -0
  111. package/dist/src/platforms/gemini-activation.js.map +1 -0
  112. package/dist/src/platforms/gemini-consent.d.ts +8 -0
  113. package/dist/src/platforms/gemini-consent.js +79 -0
  114. package/dist/src/platforms/gemini-consent.js.map +1 -0
  115. package/dist/src/platforms/identity.d.ts +4 -0
  116. package/dist/src/platforms/identity.js +22 -0
  117. package/dist/src/platforms/identity.js.map +1 -0
  118. package/dist/src/platforms/inspection-grok.d.ts +4 -0
  119. package/dist/src/platforms/inspection-grok.js +204 -0
  120. package/dist/src/platforms/inspection-grok.js.map +1 -0
  121. package/dist/src/platforms/inspection-native.d.ts +6 -0
  122. package/dist/src/platforms/inspection-native.js +401 -0
  123. package/dist/src/platforms/inspection-native.js.map +1 -0
  124. package/dist/src/platforms/inspection-opencode.d.ts +4 -0
  125. package/dist/src/platforms/inspection-opencode.js +97 -0
  126. package/dist/src/platforms/inspection-opencode.js.map +1 -0
  127. package/dist/src/platforms/inspection-pi.d.ts +3 -0
  128. package/dist/src/platforms/inspection-pi.js +287 -0
  129. package/dist/src/platforms/inspection-pi.js.map +1 -0
  130. package/dist/src/platforms/inspection-query.d.ts +5 -0
  131. package/dist/src/platforms/inspection-query.js +36 -0
  132. package/dist/src/platforms/inspection-query.js.map +1 -0
  133. package/dist/src/platforms/inspection.d.ts +13 -0
  134. package/dist/src/platforms/inspection.js +180 -0
  135. package/dist/src/platforms/inspection.js.map +1 -0
  136. package/dist/src/platforms/layout.d.ts +21 -0
  137. package/dist/src/platforms/layout.js +239 -0
  138. package/dist/src/platforms/layout.js.map +1 -0
  139. package/dist/src/platforms/lifecycle-native-services.d.ts +3 -0
  140. package/dist/src/platforms/lifecycle-native-services.js +147 -0
  141. package/dist/src/platforms/lifecycle-native-services.js.map +1 -0
  142. package/dist/src/platforms/lifecycle-native.d.ts +13 -0
  143. package/dist/src/platforms/lifecycle-native.js +276 -0
  144. package/dist/src/platforms/lifecycle-native.js.map +1 -0
  145. package/dist/src/platforms/lifecycle.d.ts +25 -0
  146. package/dist/src/platforms/lifecycle.js +470 -0
  147. package/dist/src/platforms/lifecycle.js.map +1 -0
  148. package/dist/src/platforms/managed-command-placement.d.ts +8 -0
  149. package/dist/src/platforms/managed-command-placement.js +79 -0
  150. package/dist/src/platforms/managed-command-placement.js.map +1 -0
  151. package/dist/src/platforms/projection-code-extension.d.ts +8 -0
  152. package/dist/src/platforms/projection-code-extension.js +121 -0
  153. package/dist/src/platforms/projection-code-extension.js.map +1 -0
  154. package/dist/src/platforms/projection-command-resources.d.ts +7 -0
  155. package/dist/src/platforms/projection-command-resources.js +74 -0
  156. package/dist/src/platforms/projection-command-resources.js.map +1 -0
  157. package/dist/src/platforms/projection-files.d.ts +27 -0
  158. package/dist/src/platforms/projection-files.js +111 -0
  159. package/dist/src/platforms/projection-files.js.map +1 -0
  160. package/dist/src/platforms/projection-marketplace.d.ts +19 -0
  161. package/dist/src/platforms/projection-marketplace.js +42 -0
  162. package/dist/src/platforms/projection-marketplace.js.map +1 -0
  163. package/dist/src/platforms/projection.d.ts +10 -0
  164. package/dist/src/platforms/projection.js +446 -0
  165. package/dist/src/platforms/projection.js.map +1 -0
  166. package/dist/src/platforms/registry.d.ts +4 -0
  167. package/dist/src/platforms/registry.js +30 -0
  168. package/dist/src/platforms/registry.js.map +1 -0
  169. package/dist/src/platforms/supplement-layout.d.ts +16 -0
  170. package/dist/src/platforms/supplement-layout.js +31 -0
  171. package/dist/src/platforms/supplement-layout.js.map +1 -0
  172. package/dist/src/portable/commands.d.ts +7 -5
  173. package/dist/src/portable/commands.js +6 -1
  174. package/dist/src/portable/commands.js.map +1 -1
  175. package/dist/src/portable/materializer.d.ts +8 -6
  176. package/dist/src/portable/materializer.js +47 -245
  177. package/dist/src/portable/materializer.js.map +1 -1
  178. package/dist/src/portable/recovery-layout.js +2 -15
  179. package/dist/src/portable/recovery-layout.js.map +1 -1
  180. package/dist/src/portable/recovery.d.ts +10 -1
  181. package/dist/src/portable/recovery.js +34 -8
  182. package/dist/src/portable/recovery.js.map +1 -1
  183. package/dist/src/recovery/coordinator.d.ts +4 -7
  184. package/dist/src/recovery/coordinator.js +151 -119
  185. package/dist/src/recovery/coordinator.js.map +1 -1
  186. package/dist/src/recovery/demand.d.ts +1 -1
  187. package/dist/src/recovery/demand.js +10 -42
  188. package/dist/src/recovery/demand.js.map +1 -1
  189. package/dist/src/recovery/joint-coordinator.js +112 -52
  190. package/dist/src/recovery/joint-coordinator.js.map +1 -1
  191. package/dist/src/recovery/joint-demand.d.ts +4 -22
  192. package/dist/src/recovery/joint-demand.js +51 -40
  193. package/dist/src/recovery/joint-demand.js.map +1 -1
  194. package/dist/src/recovery/receipt.d.ts +23 -8
  195. package/dist/src/recovery/retirement.d.ts +1 -1
  196. package/dist/src/recovery/retirement.js +131 -29
  197. package/dist/src/recovery/retirement.js.map +1 -1
  198. package/dist/src/recovery/status.d.ts +13 -6
  199. package/dist/src/recovery/status.js +483 -79
  200. package/dist/src/recovery/status.js.map +1 -1
  201. package/dist/src/recovery/types.d.ts +3 -3
  202. package/dist/src/review/platform-profile.d.ts +3 -0
  203. package/dist/src/review/platform-profile.js +16 -0
  204. package/dist/src/review/platform-profile.js.map +1 -0
  205. package/dist/src/review/review-profile.d.ts +1 -0
  206. package/dist/src/review/review-profile.js +8 -2
  207. package/dist/src/review/review-profile.js.map +1 -1
  208. package/dist/src/review/review-selection.d.ts +2 -11
  209. package/dist/src/review/review-selection.js +97 -71
  210. package/dist/src/review/review-selection.js.map +1 -1
  211. package/dist/src/review/review-types.d.ts +3 -0
  212. package/dist/src/review/review-types.js.map +1 -1
  213. package/dist/src/review/skill-materialization.d.ts +44 -9
  214. package/dist/src/review/skill-materialization.js +112 -136
  215. package/dist/src/review/skill-materialization.js.map +1 -1
  216. package/dist/src/review/source-binding.d.ts +8 -5
  217. package/dist/src/review/source-binding.js +99 -41
  218. package/dist/src/review/source-binding.js.map +1 -1
  219. package/dist/src/tui/agent-management.js +112 -10
  220. package/dist/src/tui/agent-management.js.map +1 -1
  221. package/dist/src/tui/agent-settings.d.ts +3 -0
  222. package/dist/src/tui/agent-settings.js +10 -11
  223. package/dist/src/tui/agent-settings.js.map +1 -1
  224. package/dist/src/tui/console-app-v4.js +58 -20
  225. package/dist/src/tui/console-app-v4.js.map +1 -1
  226. package/dist/src/tui/content-item-card.js +2 -2
  227. package/dist/src/tui/content-item-card.js.map +1 -1
  228. package/dist/src/tui/controller-runtime.js +198 -152
  229. package/dist/src/tui/controller-runtime.js.map +1 -1
  230. package/dist/src/tui/controller.d.ts +5 -9
  231. package/dist/src/tui/controller.js +40 -18
  232. package/dist/src/tui/controller.js.map +1 -1
  233. package/dist/src/tui/deployment-view.d.ts +10 -0
  234. package/dist/src/tui/deployment-view.js +103 -0
  235. package/dist/src/tui/deployment-view.js.map +1 -0
  236. package/dist/src/tui/glossary.js +4 -4
  237. package/dist/src/tui/glossary.js.map +1 -1
  238. package/dist/src/tui/model.d.ts +5 -0
  239. package/dist/src/tui/model.js +73 -12
  240. package/dist/src/tui/model.js.map +1 -1
  241. package/dist/src/tui/operation-diagnostic-screens.js +2 -1
  242. package/dist/src/tui/operation-diagnostic-screens.js.map +1 -1
  243. package/dist/src/tui/operation-history.d.ts +5 -4
  244. package/dist/src/tui/operation-history.js.map +1 -1
  245. package/dist/src/tui/operation-review-planner.d.ts +7 -2
  246. package/dist/src/tui/operation-review-planner.js +97 -42
  247. package/dist/src/tui/operation-review-planner.js.map +1 -1
  248. package/dist/src/tui/plugin-content.d.ts +5 -3
  249. package/dist/src/tui/plugin-content.js +70 -508
  250. package/dist/src/tui/plugin-content.js.map +1 -1
  251. package/dist/src/tui/plugin-detail.d.ts +3 -2
  252. package/dist/src/tui/plugin-detail.js +33 -25
  253. package/dist/src/tui/plugin-detail.js.map +1 -1
  254. package/dist/src/tui/scoped-inventory.d.ts +10 -6
  255. package/dist/src/tui/scoped-inventory.js +34 -1
  256. package/dist/src/tui/scoped-inventory.js.map +1 -1
  257. package/dist/src/types.d.ts +4 -63
  258. package/dist/src/types.js.map +1 -1
  259. package/dist/src/utils/agent-version.d.ts +10 -4
  260. package/dist/src/utils/agent-version.js.map +1 -1
  261. package/dist/src/utils/artifact-plan.d.ts +26 -2
  262. package/dist/src/utils/artifact-plan.js +113 -489
  263. package/dist/src/utils/artifact-plan.js.map +1 -1
  264. package/dist/src/utils/artifact-renderer.d.ts +100 -93
  265. package/dist/src/utils/artifact-renderer.js +173 -346
  266. package/dist/src/utils/artifact-renderer.js.map +1 -1
  267. package/dist/src/utils/artifact-request.d.ts +21 -11
  268. package/dist/src/utils/artifact-request.js +56 -80
  269. package/dist/src/utils/artifact-request.js.map +1 -1
  270. package/dist/src/utils/bundle-layout.js +30 -146
  271. package/dist/src/utils/bundle-layout.js.map +1 -1
  272. package/dist/src/utils/catalog-digests.d.ts +2 -12
  273. package/dist/src/utils/catalog-digests.js +0 -39
  274. package/dist/src/utils/catalog-digests.js.map +1 -1
  275. package/dist/src/utils/catalog-source-references.d.ts +7 -0
  276. package/dist/src/utils/catalog-source-references.js +234 -19
  277. package/dist/src/utils/catalog-source-references.js.map +1 -1
  278. package/dist/src/utils/codex-config-observation.d.ts +19 -0
  279. package/dist/src/utils/codex-config-observation.js +145 -0
  280. package/dist/src/utils/codex-config-observation.js.map +1 -0
  281. package/dist/src/utils/codex-executable-discovery.d.ts +2 -0
  282. package/dist/src/utils/codex-executable-discovery.js +47 -13
  283. package/dist/src/utils/codex-executable-discovery.js.map +1 -1
  284. package/dist/src/utils/codex-manager.js +1 -1
  285. package/dist/src/utils/codex-manager.js.map +1 -1
  286. package/dist/src/utils/codex-native-observation.d.ts +3 -0
  287. package/dist/src/utils/codex-native-observation.js +53 -0
  288. package/dist/src/utils/codex-native-observation.js.map +1 -1
  289. package/dist/src/utils/codex-shared-native.d.ts +3 -1
  290. package/dist/src/utils/codex-shared-native.js +46 -5
  291. package/dist/src/utils/codex-shared-native.js.map +1 -1
  292. package/dist/src/utils/codex-skill-staging.d.ts +4 -3
  293. package/dist/src/utils/codex-skill-staging.js.map +1 -1
  294. package/dist/src/utils/codex-surface-analysis.d.ts +5 -2
  295. package/dist/src/utils/codex-surface-analysis.js +28 -57
  296. package/dist/src/utils/codex-surface-analysis.js.map +1 -1
  297. package/dist/src/utils/component-command-preparation.d.ts +34 -0
  298. package/dist/src/utils/component-command-preparation.js +228 -0
  299. package/dist/src/utils/component-command-preparation.js.map +1 -0
  300. package/dist/src/utils/component-resources.d.ts +43 -0
  301. package/dist/src/utils/component-resources.js +304 -0
  302. package/dist/src/utils/component-resources.js.map +1 -0
  303. package/dist/src/utils/dynamic-skill-tree.d.ts +17 -6
  304. package/dist/src/utils/dynamic-skill-tree.js +7 -3
  305. package/dist/src/utils/dynamic-skill-tree.js.map +1 -1
  306. package/dist/src/utils/local-marketplace.d.ts +11 -44
  307. package/dist/src/utils/local-marketplace.js +11 -638
  308. package/dist/src/utils/local-marketplace.js.map +1 -1
  309. package/dist/src/utils/managed-command-evidence.d.ts +2 -2
  310. package/dist/src/utils/managed-command-evidence.js +5 -81
  311. package/dist/src/utils/managed-command-evidence.js.map +1 -1
  312. package/dist/src/utils/managed-command-materialization.d.ts +5 -2
  313. package/dist/src/utils/managed-command-materialization.js +35 -35
  314. package/dist/src/utils/managed-command-materialization.js.map +1 -1
  315. package/dist/src/utils/managed-command-preparation.d.ts +67 -0
  316. package/dist/src/utils/managed-command-preparation.js +146 -0
  317. package/dist/src/utils/managed-command-preparation.js.map +1 -0
  318. package/dist/src/utils/managed-command-review.d.ts +26 -0
  319. package/dist/src/utils/managed-command-review.js +68 -0
  320. package/dist/src/utils/managed-command-review.js.map +1 -0
  321. package/dist/src/utils/managed-command-store.js +26 -15
  322. package/dist/src/utils/managed-command-store.js.map +1 -1
  323. package/dist/src/utils/native-cli.d.ts +23 -0
  324. package/dist/src/utils/native-cli.js +51 -2
  325. package/dist/src/utils/native-cli.js.map +1 -1
  326. package/dist/src/utils/native-demand.d.ts +20 -1
  327. package/dist/src/utils/native-demand.js.map +1 -1
  328. package/dist/src/utils/native-tool-review.d.ts +3 -6
  329. package/dist/src/utils/native-tool-review.js +25 -11
  330. package/dist/src/utils/native-tool-review.js.map +1 -1
  331. package/dist/src/utils/ownership.d.ts +26 -3
  332. package/dist/src/utils/ownership.js +95 -9
  333. package/dist/src/utils/ownership.js.map +1 -1
  334. package/dist/src/utils/paths.d.ts +1 -1
  335. package/dist/src/utils/paths.js +2 -0
  336. package/dist/src/utils/paths.js.map +1 -1
  337. package/dist/src/utils/platform-empty-state.d.ts +46 -0
  338. package/dist/src/utils/platform-empty-state.js +123 -0
  339. package/dist/src/utils/platform-empty-state.js.map +1 -0
  340. package/dist/src/utils/plugin-config-impact.d.ts +17 -11
  341. package/dist/src/utils/plugin-config-impact.js +46 -62
  342. package/dist/src/utils/plugin-config-impact.js.map +1 -1
  343. package/dist/src/utils/plugin-config-write.js +52 -53
  344. package/dist/src/utils/plugin-config-write.js.map +1 -1
  345. package/dist/src/utils/plugin-config.d.ts +0 -2
  346. package/dist/src/utils/plugin-config.js +0 -6
  347. package/dist/src/utils/plugin-config.js.map +1 -1
  348. package/dist/src/utils/plugin-dependencies.d.ts +1 -1
  349. package/dist/src/utils/plugin-dependencies.js.map +1 -1
  350. package/dist/src/utils/plugin-scripts.d.ts +4 -0
  351. package/dist/src/utils/plugin-scripts.js +11 -0
  352. package/dist/src/utils/plugin-scripts.js.map +1 -1
  353. package/dist/src/utils/runtime-config.d.ts +5 -7
  354. package/dist/src/utils/runtime-config.js +12 -25
  355. package/dist/src/utils/runtime-config.js.map +1 -1
  356. package/dist/src/utils/windows-npm-shim.js +19 -2
  357. package/dist/src/utils/windows-npm-shim.js.map +1 -1
  358. package/package.json +3 -3
  359. package/dist/src/utils/claude-native-render-receipt.d.ts +0 -14
  360. package/dist/src/utils/claude-native-render-receipt.js +0 -26
  361. package/dist/src/utils/claude-native-render-receipt.js.map +0 -1
  362. package/dist/src/utils/claude-skills-root.d.ts +0 -8
  363. package/dist/src/utils/claude-skills-root.js +0 -87
  364. package/dist/src/utils/claude-skills-root.js.map +0 -1
  365. package/dist/src/utils/codex-native-render-receipt.d.ts +0 -40
  366. package/dist/src/utils/codex-native-render-receipt.js +0 -205
  367. package/dist/src/utils/codex-native-render-receipt.js.map +0 -1
  368. package/dist/src/utils/slash-commands.d.ts +0 -1
  369. package/dist/src/utils/slash-commands.js +0 -2
  370. package/dist/src/utils/slash-commands.js.map +0 -1
@@ -6,7 +6,7 @@ import { createRequire } from 'node:module';
6
6
  import * as os from 'node:os';
7
7
  import * as path from 'node:path';
8
8
  import { fileURLToPath, pathToFileURL } from 'node:url';
9
- import { assertPluginConfigReferenceSchemas, AW_RUNTIME_CONFIG_READER_PATH, createNativeToolReaderSource, createRuntimeConfigSnapshot, getPluginAuthoringAcceptedValues as getCorePluginAuthoringAcceptedValues, getSkillFrontmatterCapabilityRegistry, getManagedCommandArtifactTargets, normalizePluginConfigDefinition, compilePluginConfigDefinition, resolveSupportedPlatforms, PLATFORM_TARGETS, isPortablePlatformTarget, SOURCE_PLUGIN_MANIFEST_CONTRACT_VERSION, parseManagedCommandPlaceholders, replaceManagedCommandPlaceholders, validateCommandEntryFiles, validatePluginConfigCandidate, formatPluginConfigIssue, } from '@lesliechan721/aw-plugin-core/manifest';
9
+ import { assertPluginConfigReferenceSchemas, AW_RUNTIME_CONFIG_READER_PATH, createNativeToolReaderSource, getPluginAuthoringAcceptedValues as getCorePluginAuthoringAcceptedValues, getSkillFrontmatterCapabilityRegistry, normalizePluginConfigDefinition, compilePluginConfigDefinition, renderTemplate, resolveSupportedPlatforms, PLATFORM_TARGETS, isPortablePlatformTarget, isAuthorOnlySkillDirectory, getCommandPackageId, SOURCE_PLUGIN_MANIFEST_CONTRACT_VERSION, } from '@lesliechan721/aw-plugin-core/manifest';
10
10
  import { readCatalogWorkspace } from '@lesliechan721/aw-plugin-core';
11
11
  import { checkPluginVersions } from './lib/plugin-version-check.mjs';
12
12
  import { scanJavaScriptImportSpecifiers } from './lib/javascript-import-scanner.mjs';
@@ -36,13 +36,6 @@ const MAX_OPENAI_DEPENDENCY_DESCRIPTION_LEN = 1024;
36
36
  const MAX_OPENAI_DEPENDENCY_COMMAND_LEN = 1024;
37
37
  const MAX_OPENAI_DEPENDENCY_URL_LEN = 1024;
38
38
  const CLAUDE_FRONTMATTER_SHELLS = new Set(['bash', 'powershell']);
39
- const CLAUDE_SLASH_COMMAND_ONLY_FIELDS = new Set([
40
- 'allowed-tools',
41
- 'model',
42
- 'argument-hint',
43
- 'disable-model-invocation',
44
- 'shell',
45
- ]);
46
39
  const CODEX_POLICY_PRODUCTS = new Set([
47
40
  'atlas',
48
41
  'ATLAS',
@@ -54,76 +47,7 @@ const CODEX_POLICY_PRODUCTS = new Set([
54
47
  const MANIFEST_PLATFORMS = new Set(getPluginAuthoringAcceptedValues('manifest', 'platforms'));
55
48
  const MARKETPLACE_AUTHENTICATION_POLICIES = new Set(getPluginAuthoringAcceptedValues('manifest', 'marketplace.policy.authentication'));
56
49
  const MARKETPLACE_INSTALLATION_POLICIES = new Set(getPluginAuthoringAcceptedValues('manifest', 'marketplace.policy.installation'));
57
- const PUBLIC_HOOK_EVENTS = new Set(['before_tool', 'after_tool', 'session_start']);
58
- const PUBLIC_SESSION_START_SOURCES = new Set(['startup', 'resume', 'clear']);
59
- const PUBLIC_SESSION_START_DEFAULT_MATCHER = 'startup|resume|clear';
60
- const PUBLIC_HOOK_RENDER_MAP = {
61
- claude: {
62
- before_tool: 'PreToolUse',
63
- after_tool: 'PostToolUse',
64
- session_start: 'SessionStart',
65
- },
66
- codex: {
67
- before_tool: 'PreToolUse',
68
- after_tool: 'PostToolUse',
69
- session_start: 'SessionStart',
70
- },
71
- };
72
- const NATIVE_HOOK_EVENTS = {
73
- claude: new Set([
74
- 'PreToolUse',
75
- 'PostToolUse',
76
- 'PostToolUseFailure',
77
- 'Notification',
78
- 'UserPromptSubmit',
79
- 'SessionStart',
80
- 'SessionEnd',
81
- 'Stop',
82
- 'StopFailure',
83
- 'SubagentStart',
84
- 'SubagentStop',
85
- 'PreCompact',
86
- 'PostCompact',
87
- 'PermissionRequest',
88
- 'PermissionDenied',
89
- 'Setup',
90
- 'TeammateIdle',
91
- 'TaskCreated',
92
- 'TaskCompleted',
93
- 'Elicitation',
94
- 'ElicitationResult',
95
- 'ConfigChange',
96
- 'WorktreeCreate',
97
- 'WorktreeRemove',
98
- 'InstructionsLoaded',
99
- 'CwdChanged',
100
- 'FileChanged',
101
- ]),
102
- codex: new Set([
103
- 'PreToolUse',
104
- 'PermissionRequest',
105
- 'PostToolUse',
106
- 'SessionStart',
107
- 'UserPromptSubmit',
108
- 'Stop',
109
- ]),
110
- };
111
- const MATCHERLESS_NATIVE_HOOK_EVENTS = {
112
- claude: new Set([
113
- 'UserPromptSubmit',
114
- 'Stop',
115
- 'TeammateIdle',
116
- 'TaskCreated',
117
- 'TaskCompleted',
118
- 'WorktreeCreate',
119
- 'WorktreeRemove',
120
- 'CwdChanged',
121
- ]),
122
- codex: new Set(['UserPromptSubmit', 'Stop']),
123
- };
124
50
  const TEMPLATE_TEXT_FILE_EXTENSIONS = /\.(md|markdown|txt|json|yaml|yml|toml|rules)$/i;
125
- const SLASH_COMMAND_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
126
- const DEFAULT_SLASH_COMMANDS_DIR = 'slash-commands';
127
51
  const SCRIPT_NODE_EXTENSIONS = new Set(['.js', '.mjs', '.cjs']);
128
52
  const SCRIPT_TIMEOUT_MIN_MS = 1000;
129
53
  const SCRIPT_TIMEOUT_MAX_MS = 1800000;
@@ -207,56 +131,12 @@ function templateIncludesPath(manifest, relativePath) {
207
131
  return false;
208
132
  return include.some((pattern) => matchesGlob(normalized, pattern));
209
133
  }
210
- function resolveTemplateValue(vars, platform) {
211
- const resolved = {};
212
- for (const [key, entry] of Object.entries(vars)) {
213
- if (entry && typeof entry === 'object' && !Array.isArray(entry)) {
214
- resolved[key] = entry[platform];
215
- }
216
- }
217
- return resolved;
218
- }
219
- function replaceConditionalBlocks(input, resolvedVars, tagName) {
220
- const pattern = new RegExp(`{{#${tagName}\\s+([a-zA-Z0-9_]+)}}([\\s\\S]*?){{\\/${tagName}}}`, 'g');
221
- return input.replace(pattern, (_match, rawKey, blockContent) => {
222
- const truthy = resolvedVars[rawKey] === true;
223
- if (tagName === 'if') {
224
- return truthy ? blockContent : '';
225
- }
226
- return truthy ? '' : blockContent;
227
- });
228
- }
229
- function renderTemplate(content, vars, platform) {
230
- const resolvedVars = resolveTemplateValue(vars, platform);
231
- const withConditionals = replaceConditionalBlocks(replaceConditionalBlocks(content, resolvedVars, 'if'), resolvedVars, 'unless');
232
- return withConditionals.replace(/{{([a-zA-Z0-9_]+)}}/g, (_match, rawKey) => {
233
- const value = resolvedVars[rawKey];
234
- if (value === undefined)
235
- return '';
236
- return String(value);
237
- });
238
- }
239
134
  function renderTemplateForPlatform(manifest, relativePath, content, platform) {
240
135
  if (!templateIncludesPath(manifest, relativePath))
241
136
  return content;
242
137
  const vars = manifest.buildConfig?.templates?.vars ?? {};
243
138
  return renderTemplate(content, vars, platform);
244
139
  }
245
- function renderedContentVariants(manifest, relativePath, content, platforms) {
246
- if (!templateIncludesPath(manifest, relativePath)) {
247
- return [{ content, platform: null }];
248
- }
249
- const seen = new Set();
250
- const variants = [];
251
- for (const platform of platforms) {
252
- const rendered = renderTemplateForPlatform(manifest, relativePath, content, platform);
253
- if (seen.has(rendered))
254
- continue;
255
- seen.add(rendered);
256
- variants.push({ content: rendered, platform });
257
- }
258
- return variants;
259
- }
260
140
  function formatYamlError(parseError, lineCounter, sourceName) {
261
141
  let location = '';
262
142
  if (Array.isArray(parseError.pos) && Number.isInteger(parseError.pos[0])) {
@@ -298,25 +178,23 @@ async function tryLoadCliManifestTools() {
298
178
  const manifestModulePath = path.join(CLI_PACKAGE_ROOT, 'dist', 'src', 'utils', 'manifest.js');
299
179
  const runtimeProjectionModulePath = path.join(CLI_PACKAGE_ROOT, 'dist', 'src', 'utils', 'catalog-runtime-projection.js');
300
180
  const capabilityModulePath = path.join(CLI_PACKAGE_ROOT, 'dist', 'src', 'commands', 'aw-capabilities.js');
301
- const artifactPlanPath = path.join(CLI_PACKAGE_ROOT, 'dist', 'src', 'utils', 'artifact-plan.js');
302
- const artifactRequestPath = path.join(CLI_PACKAGE_ROOT, 'dist', 'src', 'utils', 'artifact-request.js');
181
+ const materializationPath = path.join(CLI_PACKAGE_ROOT, 'dist', 'src', 'review', 'skill-materialization.js');
303
182
  const commandMaterializationPath = path.join(CLI_PACKAGE_ROOT, 'dist', 'src', 'utils', 'managed-command-materialization.js');
304
183
  if (!fs.existsSync(manifestModulePath)
305
184
  || !fs.existsSync(runtimeProjectionModulePath)
306
185
  || !fs.existsSync(capabilityModulePath))
307
186
  return null;
308
187
  try {
309
- const [manifestModule, runtimeProjectionModule, capabilityModule, artifactPlanModule, artifactRequestModule, commandModule] = await Promise.all([
188
+ const [manifestModule, runtimeProjectionModule, capabilityModule, materializationModule, commandModule] = await Promise.all([
310
189
  import(pathToFileURL(manifestModulePath).href),
311
190
  import(pathToFileURL(runtimeProjectionModulePath).href),
312
191
  import(pathToFileURL(capabilityModulePath).href),
313
- import(pathToFileURL(artifactPlanPath).href),
314
- import(pathToFileURL(artifactRequestPath).href),
192
+ import(pathToFileURL(materializationPath).href),
315
193
  import(pathToFileURL(commandMaterializationPath).href),
316
194
  ]);
317
195
  if (manifestModule.SOURCE_PLUGIN_MANIFEST_CONTRACT_VERSION
318
196
  !== SOURCE_PLUGIN_MANIFEST_CONTRACT_VERSION
319
- || typeof artifactRequestModule.requiresNonSensitiveArtifactInput !== 'function') {
197
+ || typeof materializationModule.materializeProfilePluginComponents !== 'function') {
320
198
  return null;
321
199
  }
322
200
  return {
@@ -328,11 +206,11 @@ async function tryLoadCliManifestTools() {
328
206
  resolvePluginRequirements: manifestModule.resolvePluginRequirements ?? null,
329
207
  implementedCapabilities: capabilityModule.IMPLEMENTED_AW_CAPABILITIES ?? null,
330
208
  createRuntimeResolver: runtimeProjectionModule.createCatalogRuntimeImportResolver ?? null,
331
- validateArtifactPlan: artifactPlanModule.validateArtifactPlan,
332
- requiresNonSensitiveArtifactInput: artifactRequestModule.requiresNonSensitiveArtifactInput,
333
- prepareManagedCommandPackageFiles: commandModule.prepareManagedCommandPackageFiles,
209
+ materializeProfilePluginComponents: materializationModule.materializeProfilePluginComponents,
210
+ createIsolatedSkillEnv: materializationModule.createIsolatedSkillEnv,
211
+ prepareManagedCommandPackage: commandModule.prepareManagedCommandPackage,
334
212
  managedCommandProducerIdentity: commandModule.managedCommandProducerIdentity,
335
- createManagedCommandReferenceResolver: commandModule.createManagedCommandReferenceResolver,
213
+ validateRuntimeSkillClosure: (await import(pathToFileURL(path.join(CLI_PACKAGE_ROOT, 'dist', 'src', 'utils', 'runtime-skill-closure.js')).href)).validateRuntimeSkillClosure,
336
214
  };
337
215
  }
338
216
  catch {
@@ -495,52 +373,21 @@ function hasNonEmptyOverride(value) {
495
373
  return isRecord(value) && Object.keys(value).length > 0;
496
374
  }
497
375
  function validatePlatformFieldSupport(manifest) {
498
- if (manifest.buildConfig?.fileRules?.claude !== undefined) {
499
- assertPlatformFieldSupported(manifest, 'buildConfig.fileRules.claude', 'claude');
500
- }
501
- if (manifest.buildConfig?.fileRules?.codex !== undefined) {
502
- assertPlatformFieldSupported(manifest, 'buildConfig.fileRules.codex', 'codex');
503
- }
504
- if (manifest.buildConfig?.manifestOverrides?.claude !== undefined) {
505
- assertPlatformFieldSupported(manifest, 'buildConfig.manifestOverrides.claude', 'claude');
506
- }
507
- if (manifest.buildConfig?.manifestOverrides?.codex !== undefined) {
508
- assertPlatformFieldSupported(manifest, 'buildConfig.manifestOverrides.codex', 'codex');
509
- }
510
- if (manifest.apps) {
511
- assertPlatformFieldSupported(manifest, 'apps', 'codex');
512
- }
513
- if (Array.isArray(manifest.extensions?.nativeHooks?.claude) && manifest.extensions.nativeHooks.claude.length > 0) {
514
- assertPlatformFieldSupported(manifest, 'extensions.nativeHooks.claude', 'claude');
515
- }
516
- if (Array.isArray(manifest.extensions?.nativeHooks?.codex) && manifest.extensions.nativeHooks.codex.length > 0) {
517
- assertPlatformFieldSupported(manifest, 'extensions.nativeHooks.codex', 'codex');
518
- }
519
- for (const [fieldName, entries] of [
520
- ['extensions.instructions', manifest.extensions?.instructions],
521
- ['extensions.permissions', manifest.extensions?.permissions],
522
- ['extensions.hooks', manifest.extensions?.hooks],
523
- ['extensions.agents', manifest.extensions?.agents],
524
- ]) {
525
- if (!Array.isArray(entries))
526
- continue;
527
- entries.forEach((entry, index) => {
528
- if (!isRecord(entry.agentOverrides))
529
- return;
530
- for (const platform of ['claude', 'codex']) {
531
- if (hasNonEmptyOverride(entry.agentOverrides[platform])) {
532
- assertPlatformFieldSupported(manifest, `${fieldName}[${index}].agentOverrides.${platform}`, platform);
376
+ for (const platform of PLATFORM_TARGETS) {
377
+ if (manifest.buildConfig?.fileRules?.[platform] !== undefined) {
378
+ assertPlatformFieldSupported(manifest, `buildConfig.fileRules.${platform}`, platform);
379
+ }
380
+ if ((manifest.extensions?.nativeHooks?.[platform]?.length ?? 0) > 0) {
381
+ assertPlatformFieldSupported(manifest, `extensions.nativeHooks.${platform}`, platform);
382
+ }
383
+ for (const fieldName of ['instructions', 'permissions', 'hooks', 'agents']) {
384
+ for (const [index, entry] of (manifest.extensions?.[fieldName] ?? []).entries()) {
385
+ if (hasNonEmptyOverride(entry.agentOverrides?.[platform])) {
386
+ assertPlatformFieldSupported(manifest, `extensions.${fieldName}[${index}].agentOverrides.${platform}`, platform);
533
387
  }
534
388
  }
535
- });
536
- }
537
- if (!Array.isArray(manifest.artifacts?.targets))
538
- return;
539
- manifest.artifacts.targets.forEach((target, index) => {
540
- if (target?.platform === 'claude' || target?.platform === 'codex') {
541
- assertPlatformFieldSupported(manifest, `artifacts.targets[${index}].platform`, target.platform);
542
389
  }
543
- });
390
+ }
544
391
  }
545
392
  function isTemplateAsset(manifest, relativePath) {
546
393
  return templateIncludesPath(manifest, relativePath);
@@ -560,185 +407,7 @@ function validateManifestString(value, fieldName) {
560
407
  error(`${fieldName} must be a non-empty string`);
561
408
  return null;
562
409
  }
563
- return value;
564
- }
565
- function validatePublicHookEvent(value, fieldName) {
566
- const event = validateManifestString(value, fieldName);
567
- if (!event)
568
- return null;
569
- if (event === 'session_stop') {
570
- error(`${fieldName}: public event "session_stop" has been removed; use extensions.nativeHooks.claude[].event = "Stop" or "SessionEnd", or extensions.nativeHooks.codex[].event = "Stop"`);
571
- return null;
572
- }
573
- if (!PUBLIC_HOOK_EVENTS.has(event)) {
574
- error(`${fieldName}: unsupported public hook event "${event}"`);
575
- return null;
576
- }
577
- return event;
578
- }
579
- function normalizePublicSessionStartMatcher(matcher, fieldName) {
580
- if (matcher === undefined)
581
- return PUBLIC_SESSION_START_DEFAULT_MATCHER;
582
- if (typeof matcher !== 'string' || matcher.trim() === '') {
583
- error(`${fieldName} must be a non-empty string`);
584
- return null;
585
- }
586
- const selected = new Set();
587
- for (const part of matcher.split('|')) {
588
- if (!PUBLIC_SESSION_START_SOURCES.has(part)) {
589
- error(`${fieldName}: public session_start only allows startup, resume, clear, or their "|" union`);
590
- return null;
591
- }
592
- selected.add(part);
593
- }
594
- return ['startup', 'resume', 'clear'].filter((part) => selected.has(part)).join('|');
595
- }
596
- function validatePublicHookMatcher(event, matcher, fieldName) {
597
- if (matcher === undefined)
598
- return event === 'session_start' ? PUBLIC_SESSION_START_DEFAULT_MATCHER : undefined;
599
- if (typeof matcher !== 'string' || matcher.trim() === '') {
600
- error(`${fieldName} must be a non-empty string`);
601
- return null;
602
- }
603
- if (event === 'session_start') {
604
- return normalizePublicSessionStartMatcher(matcher, fieldName);
605
- }
606
- return matcher;
607
- }
608
- function validateNativeHookEvent(value, platform, fieldName) {
609
- const event = validateManifestString(value, fieldName);
610
- if (!event)
611
- return null;
612
- if (!NATIVE_HOOK_EVENTS[platform].has(event)) {
613
- error(`${fieldName}: unsupported ${platform} hook event "${event}"`);
614
- return null;
615
- }
616
- return event;
617
- }
618
- function validateNativeHookMatcher(event, platform, matcher, fieldName) {
619
- if (matcher === undefined)
620
- return undefined;
621
- if (typeof matcher !== 'string' || matcher.trim() === '') {
622
- error(`${fieldName} must be a non-empty string`);
623
- return null;
624
- }
625
- if (MATCHERLESS_NATIVE_HOOK_EVENTS[platform].has(event)) {
626
- error(`${fieldName}: ${platform} event "${event}" does not allow matcher`);
627
- return null;
628
- }
629
- return matcher;
630
- }
631
- function validateHookAgentOverrides(value, baseHook, fieldName, duplicateCollector) {
632
- if (value === undefined) {
633
- for (const platform of ['claude', 'codex']) {
634
- duplicateCollector(platform, baseHook);
635
- }
636
- return;
637
- }
638
- const overrides = expectRecord(value, fieldName);
639
- if (!overrides)
640
- return;
641
- validateAllowedKeys(overrides, fieldName, ['claude', 'codex']);
642
- for (const platform of ['claude', 'codex']) {
643
- const override = overrides[platform];
644
- if (override === null)
645
- continue;
646
- if (override === undefined) {
647
- duplicateCollector(platform, baseHook);
648
- continue;
649
- }
650
- const overrideRecord = expectRecord(override, `${fieldName}.${platform}`);
651
- if (!overrideRecord)
652
- continue;
653
- validateAllowedKeys(overrideRecord, `${fieldName}.${platform}`, ['event', 'matcher', 'command']);
654
- const event = overrideRecord.event === undefined
655
- ? baseHook.event
656
- : validatePublicHookEvent(overrideRecord.event, `${fieldName}.${platform}.event`);
657
- const matcherValue = overrideRecord.matcher === undefined
658
- ? baseHook.matcher
659
- : overrideRecord.matcher;
660
- const matcher = event
661
- ? validatePublicHookMatcher(event, matcherValue, `${fieldName}.${platform}.matcher`)
662
- : null;
663
- const command = overrideRecord.command === undefined
664
- ? baseHook.command
665
- : validateManifestString(overrideRecord.command, `${fieldName}.${platform}.command`);
666
- if (event && matcher !== null && command) {
667
- duplicateCollector(platform, { event, matcher, command });
668
- }
669
- }
670
- }
671
- function validateHookEntryLightweight(entry, fieldName, duplicateCollector) {
672
- const input = expectRecord(entry, fieldName);
673
- if (!input)
674
- return;
675
- validateAllowedKeys(input, fieldName, ['event', 'matcher', 'command', 'agentOverrides']);
676
- const event = validatePublicHookEvent(input.event, `${fieldName}.event`);
677
- const matcher = event
678
- ? validatePublicHookMatcher(event, input.matcher, `${fieldName}.matcher`)
679
- : null;
680
- const command = validateManifestString(input.command, `${fieldName}.command`);
681
- if (!event || matcher === null || !command)
682
- return;
683
- validateHookAgentOverrides(input.agentOverrides, { event, matcher, command }, `${fieldName}.agentOverrides`, duplicateCollector);
684
- }
685
- function validateNativeHookEntryLightweight(entry, platform, fieldName, duplicateCollector) {
686
- const input = expectRecord(entry, fieldName);
687
- if (!input)
688
- return;
689
- validateAllowedKeys(input, fieldName, ['event', 'matcher', 'command']);
690
- const event = validateNativeHookEvent(input.event, platform, `${fieldName}.event`);
691
- const matcher = event
692
- ? validateNativeHookMatcher(event, platform, input.matcher, `${fieldName}.matcher`)
693
- : null;
694
- const command = validateManifestString(input.command, `${fieldName}.command`);
695
- if (!event || matcher === null || !command)
696
- return;
697
- duplicateCollector(platform, { event, matcher, command, native: true });
698
- }
699
- function validateExtensionsLightweight(extensions) {
700
- if (extensions === undefined)
701
- return;
702
- const input = expectRecord(extensions, 'extensions');
703
- if (!input)
704
- return;
705
- validateAllowedKeys(input, 'extensions', ['instructions', 'permissions', 'hooks', 'nativeHooks', 'agents']);
706
- const seenHooks = {
707
- claude: new Set(),
708
- codex: new Set(),
709
- };
710
- const collectHook = (platform, hook) => {
711
- const event = hook.native ? hook.event : PUBLIC_HOOK_RENDER_MAP[platform][hook.event];
712
- const matcher = hook.matcher === '*' ? undefined : hook.matcher;
713
- const key = JSON.stringify([event, matcher ?? null, hook.command]);
714
- if (seenHooks[platform].has(key)) {
715
- error(`extensions has duplicate ${platform} hook for event "${event}" and command "${hook.command}"`);
716
- }
717
- seenHooks[platform].add(key);
718
- };
719
- if (input.hooks !== undefined) {
720
- if (!Array.isArray(input.hooks)) {
721
- error('extensions.hooks must be an array');
722
- }
723
- else {
724
- input.hooks.forEach((entry, index) => validateHookEntryLightweight(entry, `extensions.hooks[${index}]`, collectHook));
725
- }
726
- }
727
- if (input.nativeHooks !== undefined) {
728
- const nativeHooks = expectRecord(input.nativeHooks, 'extensions.nativeHooks');
729
- if (nativeHooks) {
730
- validateAllowedKeys(nativeHooks, 'extensions.nativeHooks', ['claude', 'codex']);
731
- for (const platform of ['claude', 'codex']) {
732
- if (nativeHooks[platform] === undefined)
733
- continue;
734
- if (!Array.isArray(nativeHooks[platform])) {
735
- error(`extensions.nativeHooks.${platform} must be an array`);
736
- continue;
737
- }
738
- nativeHooks[platform].forEach((entry, index) => validateNativeHookEntryLightweight(entry, platform, `extensions.nativeHooks.${platform}[${index}]`, collectHook));
739
- }
740
- }
741
- }
410
+ return value.trim();
742
411
  }
743
412
  function expectRecord(value, fieldName) {
744
413
  if (!isRecord(value)) {
@@ -779,9 +448,9 @@ async function validatePluginEvalManifest(pluginDir, pluginManifest) {
779
448
  if (fs.existsSync(legacyRoot)) {
780
449
  error('Plugin-root evals/ is legacy; put evals/ inside its owning static or dynamic Skill directory.');
781
450
  }
782
- const skillRoots = [...collectDeclaredSkillNames(pluginDir, pluginManifest).all]
783
- .sort()
784
- .map((skill) => ({ skill, root: path.join(pluginDir, 'skills', skill) }));
451
+ const sourceSkills = path.join(pluginDir, 'skills');
452
+ const skillRoots = fs.existsSync(sourceSkills) ? fs.readdirSync(sourceSkills, { withFileTypes: true })
453
+ .filter((entry) => entry.isDirectory()).map((entry) => ({ skill: entry.name, root: path.join(sourceSkills, entry.name) })) : [];
785
454
  const seenSkills = new Set();
786
455
  let manifestTools = null;
787
456
  for (const owner of skillRoots) {
@@ -1105,7 +774,7 @@ function validateNoBuildOutputDirs(pluginDir) {
1105
774
  }
1106
775
  }
1107
776
  function validateDeclaredPathsExist(pluginDir, manifest) {
1108
- for (const field of ['skills', 'slashCommands', 'mcpServers', 'apps']) {
777
+ for (const field of ['skills', 'mcpServers']) {
1109
778
  if (!manifest[field])
1110
779
  continue;
1111
780
  const resolved = path.join(pluginDir, manifest[field]);
@@ -1114,7 +783,7 @@ function validateDeclaredPathsExist(pluginDir, manifest) {
1114
783
  }
1115
784
  }
1116
785
  }
1117
- function validateCanonicalSkillLayout(pluginDir, manifest) {
786
+ async function validateCanonicalSkillLayout(pluginDir, manifest) {
1118
787
  if (manifest.skills && normalizeRelativePath(manifest.skills) !== 'skills') {
1119
788
  error('skills must be "./skills"');
1120
789
  }
@@ -1127,18 +796,8 @@ function validateCanonicalSkillLayout(pluginDir, manifest) {
1127
796
  if (content.trim() === '')
1128
797
  error('Plugin root README.md must not be empty');
1129
798
  }
1130
- const declared = collectDeclaredSkillNames(pluginDir, manifest);
1131
- const sourceBackedDynamicSkills = (Array.isArray(manifest.artifacts?.targets)
1132
- ? manifest.artifacts.targets
1133
- : [])
1134
- .filter((target) => target &&
1135
- typeof target === 'object' &&
1136
- (target.target === 'codex.skill' || target.target === 'claude.skill' || target.target === 'agent-skills.skill') &&
1137
- typeof target.skillKey === 'string' &&
1138
- Array.isArray(target.sourceDirs) &&
1139
- target.sourceDirs.length > 0)
1140
- .map((target) => target.skillKey.trim());
1141
- for (const skill of new Set([...declared.static, ...sourceBackedDynamicSkills])) {
799
+ const declared = await collectDeclaredSkillNames(pluginDir, manifest);
800
+ for (const skill of declared.static) {
1142
801
  const skillRoot = path.join(pluginDir, 'skills', skill);
1143
802
  if (!fs.statSync(skillRoot, { throwIfNoEntry: false })?.isDirectory()) {
1144
803
  error(`Skill ${JSON.stringify(skill)} must use source root "./skills/${skill}"`);
@@ -1156,68 +815,30 @@ function validateCanonicalSkillLayout(pluginDir, manifest) {
1156
815
  }
1157
816
  }
1158
817
  function validateDeclaredNativeAssets(pluginDir, manifest) {
1159
- const defaults = [
1160
- ['skills', 'skills'],
1161
- [DEFAULT_SLASH_COMMANDS_DIR, 'slashCommands'],
1162
- ['.mcp.json', 'mcpServers'],
1163
- ['.app.json', 'apps'],
1164
- ];
1165
- for (const [filename, field] of defaults) {
818
+ for (const [filename, field] of [['skills', 'skills'], ['.mcp.json', 'mcpServers']]) {
1166
819
  const fullPath = path.join(pluginDir, filename);
1167
- if (fs.existsSync(fullPath) && !manifest[field]) {
1168
- if (field === 'skills') {
1169
- const dynamicSkills = new Set((Array.isArray(manifest.artifacts?.targets) ? manifest.artifacts.targets : [])
1170
- .filter((target) => {
1171
- if (!target ||
1172
- typeof target !== 'object' ||
1173
- (target.target !== 'codex.skill' && target.target !== 'claude.skill') ||
1174
- typeof target.skillKey !== 'string' ||
1175
- !Array.isArray(target.sourceDirs) ||
1176
- target.sourceDirs.length === 0)
1177
- return false;
1178
- return target.sourceDirs.every((sourceDir) => typeof sourceDir === 'string' &&
1179
- (normalizeRelativePath(sourceDir) === `skills/${target.skillKey}` ||
1180
- normalizeRelativePath(sourceDir).startsWith(`skills/${target.skillKey}/`)));
1181
- })
1182
- .map((target) => target.skillKey));
1183
- const entries = fs.readdirSync(fullPath, { withFileTypes: true });
1184
- if (entries.length > 0 &&
1185
- entries.every((entry) => entry.isDirectory() && dynamicSkills.has(entry.name))) {
1186
- continue;
1187
- }
1188
- }
1189
- error(`"${filename}" exists but manifest does not declare "${field}" — declare it or remove the file`);
820
+ if (!fs.existsSync(fullPath) || manifest[field])
821
+ continue;
822
+ if (field === 'skills') {
823
+ const sources = (manifest.artifacts?.sourceDirs ?? []).map(normalizeRelativePath);
824
+ const entries = fs.readdirSync(fullPath, { withFileTypes: true });
825
+ if (entries.length && entries.every((entry) => entry.isDirectory() && sources.some((source) => source === 'skills' || source === `skills/${entry.name}`)))
826
+ continue;
1190
827
  }
828
+ error(`"${filename}" exists but manifest does not declare "${field}" or an artifacts.sourceDirs input`);
1191
829
  }
1192
830
  }
1193
- function collectDeclaredSkillNames(pluginDir, manifest) {
1194
- const skillsRoot = typeof manifest.skills === 'string'
1195
- ? path.join(pluginDir, manifest.skills)
1196
- : null;
1197
- const staticSkillNames = skillsRoot && fs.existsSync(skillsRoot)
1198
- ? fs.readdirSync(skillsRoot, { withFileTypes: true })
1199
- .filter((entry) => entry.isDirectory())
1200
- .map((entry) => entry.name)
1201
- .sort()
1202
- : [];
1203
- const staticSkillNameSet = new Set(staticSkillNames);
1204
- const artifactTargets = Array.isArray(manifest.artifacts?.targets)
1205
- ? manifest.artifacts.targets
1206
- : [];
1207
- const dynamicSkillNames = artifactTargets
1208
- .filter((target) => target
1209
- && typeof target === 'object'
1210
- && (target.target === 'codex.skill' || target.target === 'claude.skill')
1211
- && typeof target.skillKey === 'string'
1212
- && target.skillKey.trim() !== '')
1213
- .map((target) => target.skillKey.trim())
1214
- .sort();
1215
- const dynamicSkillNameSet = new Set(dynamicSkillNames);
1216
- return {
1217
- static: staticSkillNameSet,
1218
- dynamic: dynamicSkillNameSet,
1219
- all: new Set([...staticSkillNames, ...dynamicSkillNames]),
1220
- };
831
+ async function collectDeclaredSkillNames(pluginDir, manifest) {
832
+ const root = manifest.skills && path.join(pluginDir, manifest.skills);
833
+ const names = [];
834
+ if (root && fs.existsSync(root)) {
835
+ for (const entry of fs.readdirSync(root, { withFileTypes: true })) {
836
+ if (entry.isDirectory() && !await isAuthorOnlySkillDirectory(path.join(root, entry.name)))
837
+ names.push(entry.name);
838
+ }
839
+ }
840
+ names.sort();
841
+ return { static: new Set(names), dynamic: new Set(), all: new Set(names) };
1221
842
  }
1222
843
  function isNodeRunnablePath(relativePath) {
1223
844
  return SCRIPT_NODE_EXTENSIONS.has(path.posix.extname(normalizeRelativePath(relativePath)));
@@ -1528,62 +1149,6 @@ function configFieldContainsSensitiveValue(field) {
1528
1149
  || (isRecord(field.additionalProperties)
1529
1150
  && field.additionalProperties.sensitive === true));
1530
1151
  }
1531
- function validateArtifactId(value, fieldName) {
1532
- const id = validateManifestString(value, fieldName);
1533
- if (!id)
1534
- return null;
1535
- if (!/^[A-Za-z][A-Za-z0-9_.-]*$/.test(id)) {
1536
- error(`${fieldName}: expected a stable id using letters, numbers, ".", "_" or "-"`);
1537
- }
1538
- return id;
1539
- }
1540
- function validateStringArray(value, fieldName, options = {}) {
1541
- if (!Array.isArray(value)) {
1542
- error(`${fieldName} must be an array`);
1543
- return [];
1544
- }
1545
- const output = [];
1546
- for (const [index, entry] of value.entries()) {
1547
- const itemFieldName = `${fieldName}[${index}]`;
1548
- if (typeof entry !== 'string' || entry.trim() === '') {
1549
- error(`${itemFieldName} must be a non-empty string`);
1550
- continue;
1551
- }
1552
- if (options.allowed && !options.allowed.has(entry)) {
1553
- error(`${itemFieldName}: unsupported ${options.label ?? 'value'} "${entry}"`);
1554
- continue;
1555
- }
1556
- if (!output.includes(entry))
1557
- output.push(entry);
1558
- }
1559
- if (options.requireNonEmpty && output.length === 0) {
1560
- error(`${fieldName} must contain at least one value`);
1561
- }
1562
- return output;
1563
- }
1564
- function validateArtifactsConfigLightweight(_pluginDir, manifest) {
1565
- return (manifest.artifacts?.targets ?? []).map((target) => ({ ...target, sourceDirs: target.sourceDirs ?? [] }));
1566
- }
1567
- function validateArtifactPlanRefreshKeys(refreshKeys, declaration, fieldName) {
1568
- const keys = validateStringArray(refreshKeys, `${fieldName}.refreshKeys`);
1569
- for (const [index, key] of keys.entries()) {
1570
- if (!declaration.refreshKeys.includes(key)) {
1571
- error(`${fieldName}.refreshKeys[${index}]: "${key}" is not declared for artifact "${declaration.id}"`);
1572
- }
1573
- }
1574
- for (const declaredKey of declaration.refreshKeys) {
1575
- if (!keys.includes(declaredKey)) {
1576
- error(`${fieldName}: artifact "${declaration.id}" must preserve declared refresh key "${declaredKey}"`);
1577
- }
1578
- }
1579
- }
1580
- function isValidArtifactFilePath(relativePath) {
1581
- return (relativePath.trim() !== '' &&
1582
- !relativePath.includes('\\') &&
1583
- !relativePath.startsWith('/') &&
1584
- path.posix.normalize(relativePath) === relativePath &&
1585
- !relativePath.split('/').some((segment) => segment === '' || segment === '.' || segment === '..'));
1586
- }
1587
1152
  function isSkillAuthorOnlyPath(relativePath) {
1588
1153
  const [topLevel] = relativePath.split('/').filter(Boolean);
1589
1154
  return topLevel === 'evals' || topLevel === 'reports';
@@ -1617,26 +1182,12 @@ function collectArtifactSourceFiles(rootDir, fieldName, files, transform = (_rel
1617
1182
  };
1618
1183
  visit(rootDir, '');
1619
1184
  }
1620
- function findArtifactFilePrefixConflict(files) {
1621
- const paths = [...files.keys()].sort();
1622
- for (const [index, relativePath] of paths.entries()) {
1623
- const prefix = paths.slice(0, index).find((candidate) => relativePath.startsWith(`${candidate}/`));
1624
- if (prefix)
1625
- return [prefix, relativePath];
1626
- }
1627
- return null;
1628
- }
1629
- function authorRuntimeImportKey(artifactId, importIndex, platform) {
1630
- return `${platform ?? "common"}\0${artifactId}\0${importIndex}`;
1631
- }
1632
1185
  async function resolveAuthorRuntimeImports(options) {
1633
- const artifactImports = (options.manifest.artifacts?.targets ?? []).flatMap((target) => (target.runtimeImports ?? []).map((reference, importIndex) => ({
1634
- key: authorRuntimeImportKey(target.id, importIndex, target.platform),
1635
- label: `artifacts target ${JSON.stringify(target.id)} runtime import ${JSON.stringify(reference.name)}`,
1636
- purpose: 'artifact-runtime',
1637
- platforms: target.platform ? [target.platform] : [undefined],
1638
- reference,
1639
- })));
1186
+ const artifactImports = (options.manifest.artifacts?.runtimeImports ?? []).map((reference) => ({
1187
+ key: reference.name,
1188
+ label: `artifacts.runtimeImports ${JSON.stringify(reference.name)}`,
1189
+ purpose: 'artifact-runtime', platforms: [...resolveSupportedPlatforms(options.manifest)], reference,
1190
+ }));
1640
1191
  const skillRuntimeImports = (options.manifest.buildConfig?.skillRuntimeFiles ?? []).flatMap((entry, importIndex) => {
1641
1192
  if (!isRecord(entry.import))
1642
1193
  return [];
@@ -1657,25 +1208,28 @@ async function resolveAuthorRuntimeImports(options) {
1657
1208
  || typeof options.cliManifestTools?.readPluginManifest !== 'function'
1658
1209
  || typeof options.cliManifestTools?.discoverPlugins !== 'function'
1659
1210
  || typeof options.cliManifestTools?.createRuntimeResolver !== 'function') {
1660
- error('Portable runtime imports require a complete built CLI and canonical same-source Git workspace.');
1211
+ error('Runtime imports require a complete built CLI and canonical same-source Git workspace.');
1661
1212
  return null;
1662
1213
  }
1663
1214
  let consumer;
1664
1215
  let resolver;
1216
+ let referencePlugins;
1665
1217
  try {
1666
1218
  const sourceSet = await options.cliManifestTools.discoverPlugins(options.repoRoot);
1667
1219
  consumer = await options.cliManifestTools.readPluginManifest(options.pluginDir);
1668
1220
  if (!sourceSet.some((candidate) => candidate.manifest.name === consumer.manifest.name)) {
1669
1221
  sourceSet.push(consumer);
1670
1222
  }
1223
+ referencePlugins = sourceSet;
1671
1224
  resolver = options.cliManifestTools.createRuntimeResolver(sourceSet);
1672
1225
  }
1673
1226
  catch {
1674
- error('Portable runtime imports could not load the canonical same-source plugin set.');
1227
+ error('Runtime imports could not load the canonical same-source plugin set.');
1675
1228
  return null;
1676
1229
  }
1677
1230
  const resolvedArtifacts = new Map();
1678
1231
  const resolvedSkillRuntimeFiles = new Map();
1232
+ let unresolved = false;
1679
1233
  for (const request of requested) {
1680
1234
  let value;
1681
1235
  try {
@@ -1697,6 +1251,9 @@ async function resolveAuthorRuntimeImports(options) {
1697
1251
  providerVersion: resolution.providerVersion,
1698
1252
  exportName: resolution.name,
1699
1253
  source: resolution.source,
1254
+ requiredCapabilities: resolution.requiredCapabilities,
1255
+ capabilitySetDigest: resolution.capabilitySetDigest,
1256
+ mode: fs.statSync(resolution.sourcePath).mode & 0o111 ? 0o755 : 0o644,
1700
1257
  };
1701
1258
  if (value && (value.digest !== current.digest
1702
1259
  || value.providerPluginId !== current.providerPluginId
@@ -1716,6 +1273,7 @@ async function resolveAuthorRuntimeImports(options) {
1716
1273
  ? JSON.stringify(request.reference.export)
1717
1274
  : '<invalid-export>';
1718
1275
  error(`Cannot resolve ${request.label} from provider ${provider} export ${exportName}.`);
1276
+ unresolved = true;
1719
1277
  continue;
1720
1278
  }
1721
1279
  if (request.purpose === 'artifact-runtime')
@@ -1723,9 +1281,10 @@ async function resolveAuthorRuntimeImports(options) {
1723
1281
  else
1724
1282
  resolvedSkillRuntimeFiles.set(request.key, value);
1725
1283
  }
1726
- return {
1284
+ return unresolved ? null : {
1727
1285
  artifactImports: resolvedArtifacts,
1728
1286
  skillRuntimeImports: resolvedSkillRuntimeFiles,
1287
+ referencePlugins,
1729
1288
  };
1730
1289
  }
1731
1290
  function overlayPortableRuntimeFiles(files, manifest, pluginDir, skillKey, runtimeImports, platform) {
@@ -1753,661 +1312,162 @@ function overlayPortableRuntimeFiles(files, manifest, pluginDir, skillKey, runti
1753
1312
  }
1754
1313
  }
1755
1314
  }
1756
- function validateRenderedSkillTree(options) {
1757
- const { entry, declaration, fieldName, pluginDir, manifest, materializedRoot, skillValidationTools, } = options;
1758
- if (entry.state !== 'present' || !isRecord(entry.content) || !isRecord(entry.content.files)) {
1315
+ async function validateAuthorComponentFixtures(pluginDir, manifest, runtimeImports, tools, referenceContext, referencePlugins, skillValidationTools, validationOptions) {
1316
+ if (!manifest.skills && !manifest.artifacts && !(manifest.managedCommands?.sets?.length || manifest.managedCommands?.packages?.length))
1759
1317
  return;
1760
- }
1761
- const files = new Map();
1762
- declaration.sourceDirs.forEach((sourceDir, index) => {
1763
- collectArtifactSourceFiles(path.join(pluginDir, normalizeRelativePath(sourceDir)), `artifacts.targets sourceDirs[${index}] for artifact "${declaration.id}"`, files, (relative, bytes) => isTemplateTextFile(relative)
1764
- ? Buffer.from(renderTemplateForPlatform(manifest, `${normalizeRelativePath(sourceDir)}/${relative}`, bytes.toString('utf8'), declaration.platform))
1765
- : bytes);
1766
- });
1767
- if (declaration.target === 'agent-skills.skill') {
1768
- overlayPortableRuntimeFiles(files, manifest, pluginDir, declaration.skillKey, options.runtimeImports, declaration.platform);
1769
- }
1770
- for (const [relativePath, content] of Object.entries(entry.content.files)) {
1771
- if (isSkillAuthorOnlyPath(relativePath)) {
1772
- error(`${fieldName}.content.files path "${relativePath}" uses an author-only Skill directory`);
1773
- continue;
1774
- }
1775
- if (isValidArtifactFilePath(relativePath) && typeof content === 'string') {
1776
- files.set(relativePath, Buffer.from(content, 'utf8'));
1777
- }
1778
- }
1779
- const conflict = findArtifactFilePrefixConflict(files);
1780
- if (conflict) {
1781
- error(`${fieldName} final file tree path "${conflict[0]}" conflicts with "${conflict[1]}"`);
1318
+ if (runtimeImports === null)
1782
1319
  return;
1783
- }
1784
- const skillFile = files.get('SKILL.md');
1785
- if (!skillFile || skillFile.toString('utf8').trim() === '') {
1786
- error(`${fieldName} final file tree must contain a non-empty SKILL.md`);
1787
- }
1788
- else if (!skillValidationTools) {
1789
- error(`${fieldName} final SKILL.md cannot be validated because the shared CLI Skill validator is unavailable`);
1790
- }
1791
- else {
1792
- const sourcePath = `${fieldName} final SKILL.md`;
1793
- const parsed = skillValidationTools.parseSkillFrontmatter(skillFile.toString('utf8'), sourcePath);
1794
- for (const diagnostic of parsed.errors) {
1795
- error(`${diagnostic.path} [${diagnostic.code}] ${diagnostic.message}`);
1796
- }
1797
- if (parsed.frontmatter) {
1798
- const diagnostics = skillValidationTools.validateSkillFrontmatter(parsed.frontmatter, {
1799
- profile: declaration.platform === 'claude' ? 'claude-2.1.88' : 'portable-agent-skills',
1800
- expectedName: declaration.skillKey,
1801
- sourcePath,
1802
- });
1803
- for (const diagnostic of diagnostics) {
1804
- error(`${diagnostic.path} [${diagnostic.code}] ${diagnostic.message}`);
1805
- }
1806
- }
1807
- }
1808
- const readme = files.get('README.md');
1809
- if (!readme || readme.toString('utf8').trim() === '') {
1810
- error(`${fieldName} final file tree must contain a non-empty README.md`);
1811
- }
1812
- for (const [relativePath, content] of files) {
1813
- const text = content.toString('utf8');
1814
- let remaining = text;
1815
- if (relativePath.endsWith('.md')) {
1816
- try {
1817
- const placeholders = parseManagedCommandPlaceholders(text);
1818
- if (placeholders.length > 0 && !(manifest.requires?.aw?.capabilities ?? []).includes('aw.managed-commands.v1')) {
1819
- error(`${fieldName} managed command references require aw.managed-commands.v1`);
1820
- }
1821
- if (declaration.target === 'agent-skills.skill' && placeholders.length > 0) {
1822
- error(`${fieldName} managedCommandPortableUnsupported: Portable Skills cannot contain managed command references`);
1823
- }
1824
- else if (options.managedTrees) {
1825
- remaining = replaceManagedCommandPlaceholders(text, () => `cmdp_${'0'.repeat(16)}`);
1826
- }
1827
- }
1828
- catch (cause) {
1829
- error(`${fieldName} ${cause.message}`);
1830
- }
1831
- }
1832
- if (/\{\{[^{}]+\}\}/u.test(remaining)) {
1833
- error(`${fieldName} final file tree contains an unresolved template in "${relativePath}"`);
1834
- }
1835
- }
1836
- if (declaration.target === 'codex.skill') {
1837
- const openAiYaml = files.get('agents/openai.yaml');
1838
- if (!openAiYaml || openAiYaml.toString('utf8').trim() === '') {
1839
- error(`${fieldName} final file tree must contain a non-empty agents/openai.yaml`);
1840
- }
1841
- }
1842
- fs.rmSync(materializedRoot, { recursive: true, force: true });
1843
- for (const [relativePath, content] of files) {
1844
- const targetPath = path.join(materializedRoot, ...relativePath.split('/'));
1845
- fs.mkdirSync(path.dirname(targetPath), { recursive: true });
1846
- fs.writeFileSync(targetPath, content);
1847
- }
1848
- if (declaration.target === 'codex.skill' && files.has('agents/openai.yaml')) {
1849
- validateOpenAiYaml(path.join(materializedRoot, 'agents', 'openai.yaml'), declaration.skillKey, true, manifest, materializedRoot, skillValidationTools);
1850
- }
1851
- options.managedTrees?.push({ declaration, files, scope: options.managedScope });
1852
- }
1853
- function validateStaticPortableFinalTrees(pluginDir, manifest, runtimeImports, skillValidationTools) {
1854
- if (!manifest.skills)
1855
- return;
1856
- const rootDir = path.join(pluginDir, normalizeRelativePath(manifest.skills));
1857
- const rootStats = fs.lstatSync(rootDir, { throwIfNoEntry: false });
1858
- if (!rootStats?.isDirectory() || rootStats.isSymbolicLink())
1859
- return;
1860
- const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'aw-static-portable-final-'));
1320
+ const tempRoot = fs.mkdtempSync(path.join(fs.realpathSync(os.tmpdir()), 'aw-author-components-'));
1321
+ const packagePreparationCache = new Map();
1861
1322
  try {
1323
+ const root = path.join(tempRoot, 'plugin');
1324
+ fs.cpSync(pluginDir, root, { recursive: true, filter: (source) => !['.git', 'node_modules'].includes(path.basename(source)) });
1325
+ const packageRoot = manifest.scripts?.node?.packageRoot;
1326
+ if (packageRoot) {
1327
+ const installedModules = path.join(pluginDir, packageRoot, 'node_modules');
1328
+ if (fs.statSync(installedModules, { throwIfNoEntry: false })?.isDirectory()) {
1329
+ const destination = path.join(root, packageRoot, 'node_modules');
1330
+ fs.mkdirSync(path.dirname(destination), { recursive: true });
1331
+ // Source validation uses already installed declared dependencies. It does
1332
+ // not install packages or publish this temporary dependency link.
1333
+ fs.symlinkSync(installedModules, destination, 'junction');
1334
+ }
1335
+ }
1336
+ const fixtureManifest = structuredClone(manifest);
1337
+ for (const reference of fixtureManifest.artifacts?.runtimeImports ?? []) {
1338
+ const input = runtimeImports?.artifactImports.get(reference.name);
1339
+ if (!input)
1340
+ throw new Error(`Unresolved runtime input: ${reference.name}`);
1341
+ const relative = `./.agents-plugin/runtime-imports/${reference.name}`;
1342
+ const destination = path.join(root, relative);
1343
+ fs.mkdirSync(path.dirname(destination), { recursive: true });
1344
+ fs.writeFileSync(destination, input.bytes, { mode: input.mode });
1345
+ reference.resolved = { path: relative, digest: input.digest, providerPluginId: input.providerPluginId,
1346
+ providerVersion: input.providerVersion, source: input.source, requiredCapabilities: input.requiredCapabilities,
1347
+ capabilitySetDigest: input.capabilitySetDigest };
1348
+ }
1349
+ if (manifest.nativeTools) {
1350
+ const reader = path.join(root, normalizeRelativePath(manifest.nativeTools.reader ?? './.aw/native-tool-reader.mjs'));
1351
+ fs.mkdirSync(path.dirname(reader), { recursive: true });
1352
+ fs.writeFileSync(reader, createNativeToolReaderSource());
1353
+ }
1354
+ // Apply the declared static source projection before the shared normalizer reads it.
1862
1355
  for (const platform of resolveSupportedPlatforms(manifest)) {
1863
- if (!isPortablePlatformTarget(platform))
1356
+ if (manifest.mcpServers) {
1357
+ const relative = normalizeRelativePath(manifest.mcpServers);
1358
+ const input = fs.readFileSync(path.join(pluginDir, relative), 'utf8');
1359
+ const output = path.join(root, platform, relative);
1360
+ fs.mkdirSync(path.dirname(output), { recursive: true });
1361
+ fs.writeFileSync(output, renderTemplateForPlatform(manifest, relative, input, platform));
1362
+ }
1363
+ const sourceRoot = manifest.skills && path.join(pluginDir, manifest.skills);
1364
+ if (!sourceRoot || !fs.existsSync(sourceRoot))
1864
1365
  continue;
1865
- const dynamicKeys = new Set((manifest.artifacts?.targets ?? [])
1866
- .filter((target) => target.platform === platform && target.target === 'agent-skills.skill')
1867
- .map((target) => target.skillKey));
1868
- for (const entry of fs.readdirSync(rootDir, { withFileTypes: true })) {
1869
- if (!entry.isDirectory() || dynamicKeys.has(entry.name))
1366
+ for (const entry of fs.readdirSync(sourceRoot, { withFileTypes: true })) {
1367
+ if (!entry.isDirectory() || await isAuthorOnlySkillDirectory(path.join(sourceRoot, entry.name)))
1870
1368
  continue;
1871
- validateRenderedSkillTree({
1872
- entry: { state: 'present', content: { files: {} } },
1873
- declaration: { id: `static:${entry.name}`, platform, distribution: 'agent-skills',
1874
- target: 'agent-skills.skill', skillKey: entry.name, sourceDirs: [`${manifest.skills}/${entry.name}`] },
1875
- fieldName: `static Portable Skill "${entry.name}" (${platform})`, pluginDir, manifest, runtimeImports,
1876
- materializedRoot: path.join(tempRoot, platform, entry.name), skillValidationTools,
1877
- });
1878
- }
1879
- }
1880
- }
1881
- finally {
1882
- fs.rmSync(tempRoot, { recursive: true, force: true });
1883
- }
1884
- }
1885
- function validateRenderedArtifactPlan(plan, declarations, scopeLabel, options) {
1886
- const planField = `scripts.artifacts.render fixture (${scopeLabel})`;
1887
- const root = expectRecord(plan, planField);
1888
- if (!root)
1889
- return;
1890
- validateAllowedKeys(root, planField, ['version', 'artifacts']);
1891
- if (root.version !== 2) {
1892
- error(`${planField}.version must be 2`);
1893
- }
1894
- if (!Array.isArray(root.artifacts)) {
1895
- error(`${planField}.artifacts must be an array`);
1896
- return;
1897
- }
1898
- const byKey = new Map(declarations.map((target) => [`${target.id}:${target.target}`, target]));
1899
- const returned = new Set();
1900
- root.artifacts.forEach((artifact, index) => {
1901
- const fieldName = `${planField}.artifacts[${index}]`;
1902
- const entry = expectRecord(artifact, fieldName);
1903
- if (!entry)
1904
- return;
1905
- if (entry.target === 'aw.command-set' || entry.target === 'aw.command-package') {
1906
- const declaration = byKey.get(`${entry.id}:${entry.target}`);
1907
- if (declaration)
1908
- returned.add(`${entry.id}:${entry.target}`);
1909
- return; // Shared ArtifactPlan validation owns command response fields.
1910
- }
1911
- validateAllowedKeys(entry, fieldName, [
1912
- 'id',
1913
- 'platform',
1914
- 'distribution',
1915
- 'target',
1916
- 'kind',
1917
- 'state',
1918
- 'refreshKeys',
1919
- 'disabledReason',
1920
- 'roleKey',
1921
- 'skillKey',
1922
- 'content',
1923
- ]);
1924
- const id = validateArtifactId(entry.id, `${fieldName}.id`);
1925
- const target = validateManifestString(entry.target, `${fieldName}.target`);
1926
- const key = id && target ? `${id}:${target}` : null;
1927
- const declaration = key ? byKey.get(key) : null;
1928
- if (!declaration) {
1929
- error(`${fieldName}: artifact "${key ?? '<unknown>'}" is not declared for ${scopeLabel}`);
1930
- return;
1931
- }
1932
- if (returned.has(key)) {
1933
- error(`${fieldName}: duplicate artifact id + target "${key}"`);
1934
- }
1935
- returned.add(key);
1936
- if (declaration.distribution) {
1937
- if (entry.distribution !== declaration.distribution) {
1938
- error(`${fieldName}.distribution: expected "${declaration.distribution}"`);
1939
- }
1940
- }
1941
- if (entry.platform !== declaration.platform) {
1942
- error(`${fieldName}.platform: expected "${declaration.platform}"`);
1943
- }
1944
- if (entry.kind !== declaration.kind) {
1945
- error(`${fieldName}.kind: expected "${declaration.kind}"`);
1946
- }
1947
- if (!declaration.states.includes(entry.state)) {
1948
- error(`${fieldName}.state: "${entry.state}" is not declared for artifact "${declaration.id}"`);
1949
- }
1950
- validateArtifactPlanRefreshKeys(entry.refreshKeys, declaration, fieldName);
1951
- if (entry.state === 'present' && entry.content === undefined) {
1952
- error(`${fieldName}.content is required when state is "present"`);
1953
- }
1954
- if (entry.disabledReason !== undefined &&
1955
- (typeof entry.disabledReason !== 'string' || entry.disabledReason.trim() === '')) {
1956
- error(`${fieldName}.disabledReason must be a non-empty string`);
1957
- }
1958
- if (declaration.target === 'codex.agentRole') {
1959
- if (entry.roleKey !== declaration.roleKey) {
1960
- error(`${fieldName}.roleKey: expected "${declaration.roleKey}" from static metadata`);
1961
- }
1962
- if (isRecord(entry.content)) {
1963
- const registration = entry.content.registration;
1964
- if (isRecord(registration) && registration.config_file !== undefined) {
1965
- error(`${fieldName}.content.registration.config_file must be generated by AW, not renderer`);
1369
+ const files = new Map();
1370
+ collectArtifactSourceFiles(path.join(sourceRoot, entry.name), `static Skill ${entry.name}`, files, (relative, bytes) => isTemplateTextFile(relative)
1371
+ ? Buffer.from(renderTemplateForPlatform(manifest, `${normalizeRelativePath(manifest.skills)}/${entry.name}/${relative}`, bytes.toString('utf8'), platform)) : bytes);
1372
+ overlayPortableRuntimeFiles(files, manifest, pluginDir, entry.name, runtimeImports, platform);
1373
+ for (const [relative, bytes] of files) {
1374
+ const output = path.join(root, platform, 'skills', entry.name, relative);
1375
+ fs.mkdirSync(path.dirname(output), { recursive: true });
1376
+ const original = path.join(sourceRoot, entry.name, relative);
1377
+ const projection = (manifest.buildConfig?.skillRuntimeFiles ?? []).find((file) => file.skill === entry.name && file.target === relative && (!file.platforms?.length || file.platforms.includes(platform)));
1378
+ const mode = projection?.source ? fs.statSync(path.join(pluginDir, projection.source)).mode
1379
+ : fs.existsSync(original) ? fs.statSync(original).mode : 0o644;
1380
+ fs.writeFileSync(output, bytes, { mode: mode & 0o111 ? 0o755 : 0o644 });
1966
1381
  }
1967
- const roleFile = entry.content.roleFile;
1968
- if (isRecord(roleFile) && roleFile.name !== declaration.roleKey) {
1969
- error(`${fieldName}.content.roleFile.name: expected "${declaration.roleKey}"`);
1970
- }
1971
- }
1972
- }
1973
- else if (entry.roleKey !== undefined) {
1974
- error(`${fieldName}.roleKey is only supported for codex.agentRole artifacts`);
1975
- }
1976
- if (declaration.target === 'codex.skill' || declaration.target === 'claude.skill' || declaration.target === 'agent-skills.skill') {
1977
- if (entry.skillKey !== declaration.skillKey) {
1978
- error(`${fieldName}.skillKey: expected "${declaration.skillKey}" from static metadata`);
1979
1382
  }
1980
- if (entry.state === 'present') {
1981
- if (!isRecord(entry.content)) {
1982
- error(`${fieldName}.content must be an object for dynamic skill artifacts`);
1983
- }
1984
- else {
1985
- validateAllowedKeys(entry.content, `${fieldName}.content`, ['files']);
1986
- const files = expectRecord(entry.content.files, `${fieldName}.content.files`);
1987
- if (files) {
1988
- const filePaths = Object.keys(files).sort();
1989
- for (const [relativePath, content] of Object.entries(files)) {
1990
- if (!isValidArtifactFilePath(relativePath)) {
1991
- error(`${fieldName}.content.files path "${relativePath}" must be a normalized POSIX relative path`);
1992
- }
1993
- if (typeof content !== 'string') {
1994
- error(`${fieldName}.content.files.${relativePath} must be a string`);
1995
- }
1996
- }
1997
- for (const [pathIndex, relativePath] of filePaths.entries()) {
1998
- const conflict = filePaths.slice(0, pathIndex).find((candidate) => relativePath.startsWith(`${candidate}/`));
1999
- if (conflict) {
2000
- error(`${fieldName}.content.files path "${conflict}" conflicts with "${relativePath}"`);
2001
- }
2002
- }
2003
- }
2004
- }
2005
- validateRenderedSkillTree({
2006
- entry,
2007
- declaration,
2008
- fieldName,
2009
- pluginDir: options.pluginDir,
2010
- manifest: options.manifest,
2011
- runtimeImports: options.runtimeImports,
2012
- materializedRoot: path.join(options.tempRoot, `${declaration.platform ?? declaration.distribution}-${scopeLabel.split('/')[1]}-${index}`),
2013
- skillValidationTools: options.skillValidationTools,
2014
- managedTrees: options.managedTrees,
2015
- managedScope: scopeLabel.split('/')[1],
2016
- });
2017
- }
2018
- }
2019
- else if (entry.skillKey !== undefined) {
2020
- error(`${fieldName}.skillKey is only supported for dynamic skill artifacts`);
2021
- }
2022
- });
2023
- for (const declaration of declarations) {
2024
- const key = `${declaration.id}:${declaration.target}`;
2025
- if (!returned.has(key)) {
2026
- error(`${planField}: renderer must return artifact "${declaration.id}" target "${declaration.target}"`);
2027
1383
  }
2028
- }
2029
- }
2030
- function resolveArtifactRendererFixtureRequests(declarations, manifest, requiresNonSensitiveArtifactInput) {
2031
- const requests = new Map();
2032
- for (const declaration of declarations) {
2033
- const nativeSkill = declaration.target === 'codex.skill' || declaration.target === 'claude.skill';
2034
- const surface = declaration.surface?.kind === 'aw' ? declaration.surface.name : declaration.platform;
2035
- if (!surface)
2036
- continue;
2037
- for (const scope of nativeSkill ? ['user'] : declaration.scopes) {
2038
- const key = `${nativeSkill ? 'native' : 'ordinary'}:${surface}:${scope}`;
2039
- const request = requests.get(key) ?? { kind: nativeSkill ? 'native' : 'ordinary', surface, scope,
2040
- configScope: nativeSkill ? 'user' : scope, declarations: [] };
2041
- request.declarations.push(declaration);
2042
- requests.set(key, request);
2043
- }
2044
- }
2045
- return [...requests.values()].flatMap((request) => {
2046
- const definition = compilePluginConfigDefinition(manifest.config ?? { fields: {} }, MANIFEST_PLATFORMS.has(request.surface) ? request.surface : undefined);
2047
- const hasNonSensitiveTarget = request.declarations.some(requiresNonSensitiveArtifactInput);
2048
- const hasSensitiveOtherTarget = request.declarations.some((declaration) => !requiresNonSensitiveArtifactInput(declaration)
2049
- && declaration.refreshKeys.some((key) => configFieldContainsSensitiveValue(definition.fields[key])));
2050
- if (!hasNonSensitiveTarget || !hasSensitiveOtherTarget)
2051
- return [request];
2052
- return [
2053
- { ...request, declarations: request.declarations.filter(requiresNonSensitiveArtifactInput) },
2054
- { ...request, declarations: request.declarations.filter((declaration) => !requiresNonSensitiveArtifactInput(declaration)) },
2055
- ];
2056
- });
2057
- }
2058
- async function runArtifactRendererFixture(pluginDir, manifest, renderEntry, declarations, resolvedRuntimeImports, skillValidationTools, managedContext, requiresNonSensitiveArtifactInput, referenceContext) {
2059
- if (!renderEntry || declarations.length === 0)
2060
- return [];
2061
- const requests = resolveArtifactRendererFixtureRequests(declarations, manifest, requiresNonSensitiveArtifactInput);
2062
- const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'aw-artifact-render-'));
2063
- const returnedArtifacts = [];
2064
- try {
2065
- for (const [requestIndex, request] of requests.entries()) {
2066
- const { kind, surface, scope, configScope, declarations: scopedDeclarations, } = request;
2067
- const distribution = isPortablePlatformTarget(surface) ? 'agent-skills' : undefined;
2068
- const awSurface = surface === 'managed-commands';
2069
- const platform = awSurface ? undefined : surface;
2070
- const definition = compilePluginConfigDefinition(manifest.config ?? { fields: {} }, platform);
2071
- const values = defaultConfigValues(manifest, platform);
2072
- const platformReferences = referenceContext ? { ...referenceContext, platform,
2073
- plugins: Object.fromEntries(Object.entries(referenceContext.plugins).map(([name, entry]) => {
2074
- const compiled = compilePluginConfigDefinition(entry.definition, platform);
2075
- return [name, { ...entry, definition: compiled, values: defaultConfigValues({ config: compiled }) }];
2076
- })),
2077
- } : undefined;
2078
- const event = distribution ? 'materialize' : 'install';
2079
- const requestRoot = path.join(tempRoot, `${requestIndex}-${kind}-${surface}-${scope}`);
2080
- const rendererAwHome = path.join(requestRoot, 'aw-home');
2081
- const rendererCodexHome = path.join(requestRoot, 'codex-home');
2082
- const rendererClaudeHome = path.join(requestRoot, 'claude-home');
2083
- fs.mkdirSync(requestRoot, { recursive: true });
2084
- const contextPath = path.join(requestRoot, 'context.json');
2085
- const runtimeImports = scopedDeclarations.flatMap((target) => (target.runtimeImports ?? []).map((runtimeImport, importIndex) => {
2086
- const resolved = resolvedRuntimeImports?.artifactImports.get(authorRuntimeImportKey(target.id, importIndex, target.platform));
2087
- if (!resolved)
2088
- return null;
2089
- const importPath = path.join(requestRoot, `runtime-${target.id}-${importIndex}`);
2090
- fs.writeFileSync(importPath, resolved.bytes);
2091
- return {
2092
- artifactId: target.id,
2093
- name: runtimeImport.name,
2094
- providerPluginId: resolved.providerPluginId,
2095
- exportName: resolved.exportName,
2096
- path: importPath,
2097
- digest: resolved.digest,
2098
- };
2099
- }).filter(Boolean));
2100
- const refreshKeys = [...new Set(scopedDeclarations.flatMap((target) => target.refreshKeys))];
2101
- const scopedSchema = Object.fromEntries(refreshKeys.flatMap((key) => definition.fields[key] === undefined ? [] : [[key, definition.fields[key]]]));
2102
- const scopedValues = Object.fromEntries(refreshKeys.flatMap((key) => Object.prototype.hasOwnProperty.call(values, key) ? [[key, values[key]]] : []));
2103
- try {
2104
- if (manifest.config) {
2105
- const issues = validatePluginConfigCandidate(definition, values, refreshKeys, platformReferences);
2106
- if (issues.length > 0)
2107
- throw new Error(formatPluginConfigIssue(issues[0]));
2108
- }
2109
- for (const target of scopedDeclarations.filter((declaration) => declaration.runtimeConfig)) {
2110
- createRuntimeConfigSnapshot({
2111
- installedIdentity: {
2112
- sourceId: 'authoring',
2113
- sourceIdentity: 'authoring',
2114
- pluginId: `authoring/${manifest.name}`,
2115
- pluginName: manifest.name,
2116
- pluginVersion: manifest.version,
2117
- platform: target.platform,
2118
- scope: target.target === 'codex.skill' || target.target === 'claude.skill' ? 'user' : scope,
2119
- configScope,
2120
- artifactId: target.id,
2121
- skillKey: target.skillKey,
2122
- },
2123
- declaration: target.runtimeConfig,
2124
- definition,
2125
- values,
2126
- referenceContext: platformReferences,
2127
- });
2128
- }
2129
- }
2130
- catch (runtimeConfigError) {
2131
- error(`scripts.artifacts.render fixture (${surface}/${scope}) runtime config failed: ${runtimeConfigError.message}`);
2132
- continue;
2133
- }
2134
- fs.writeFileSync(contextPath, JSON.stringify({
2135
- event,
2136
- surface: awSurface ? { kind: 'aw', name: 'managed-commands' } : distribution
2137
- ? { kind: 'distribution', name: distribution }
2138
- : { kind: 'platform', name: platform },
2139
- ...(platform ? { platform } : {}),
2140
- ...(distribution ? { distribution } : {}),
2141
- scope,
2142
- plugin: {
2143
- name: manifest.name,
2144
- version: manifest.version,
2145
- rootDir: pluginDir,
2146
- },
2147
- config: {
2148
- mode: 'artifact-render',
2149
- targetScope: configScope,
2150
- ...(manifest.config?.fields === undefined ? {} : { schema: scopedSchema }),
2151
- values: scopedValues,
2152
- sources: Object.fromEntries(Object.keys(scopedValues).map((key) => [key, 'default'])),
2153
- issues: [],
2154
- },
2155
- changedConfigKeys: [],
2156
- requestedArtifactIds: scopedDeclarations.map((target) => target.id),
2157
- previousArtifacts: [],
2158
- artifactSources: declarations.filter((target) => (target.target === 'codex.skill' || target.target === 'claude.skill' || target.target === 'agent-skills.skill')
2159
- && target.platform === platform
2160
- && target.scopes.includes(scope)).map((target) => ({
2161
- id: target.id,
2162
- target: target.target,
2163
- sourceDirs: (target.sourceDirs ?? []).map((sourceDir) => path.join(pluginDir, normalizeRelativePath(sourceDir))),
2164
- })),
2165
- commandSources: (managedContext?.manifest.managedCommands?.packages ?? [])
2166
- .filter((entry) => scopedDeclarations.some((target) => target.packageKey === entry.key))
2167
- .map((entry) => ({ packageKey: entry.key, sourceDir: path.join(pluginDir, normalizeRelativePath(entry.sourceDir)) })),
2168
- runtimeImports,
2169
- paths: {
2170
- awHome: rendererAwHome,
2171
- codexHome: rendererCodexHome,
2172
- claudeHome: rendererClaudeHome,
2173
- manifestPath: path.join(pluginDir, '.agents-plugin', 'plugin.json'),
2174
- },
2175
- renderer: {
2176
- runner: renderEntry.runner,
2177
- path: renderEntry.path,
2178
- args: renderEntry.args ?? [],
2179
- manifestDigest: 'author-validator-fixture',
2180
- rendererDigest: 'author-validator-fixture',
2181
- },
2182
- }), 'utf8');
2183
- const rendererHome = path.join(requestRoot, 'home');
2184
- const rendererTemp = path.join(requestRoot, 'tmp');
2185
- for (const rendererStateHome of [rendererAwHome, rendererCodexHome, rendererClaudeHome]) {
2186
- fs.mkdirSync(rendererStateHome, { recursive: true });
2187
- }
2188
- fs.mkdirSync(rendererHome, { recursive: true });
2189
- fs.mkdirSync(rendererTemp, { recursive: true });
2190
- const rendererEnv = {
2191
- AW_HOME: rendererAwHome,
2192
- CODEX_HOME: rendererCodexHome,
2193
- CLAUDE_CONFIG_DIR: rendererClaudeHome,
2194
- HOME: rendererHome,
2195
- USERPROFILE: rendererHome,
2196
- XDG_CONFIG_HOME: path.join(requestRoot, 'xdg-config'),
2197
- XDG_CACHE_HOME: path.join(requestRoot, 'xdg-cache'),
2198
- XDG_STATE_HOME: path.join(requestRoot, 'xdg-state'),
2199
- XDG_DATA_HOME: path.join(requestRoot, 'xdg-data'),
2200
- XDG_RUNTIME_DIR: path.join(requestRoot, 'xdg-runtime'),
2201
- PATH: process.env.PATH ?? process.env.Path ?? '',
2202
- AW_PLUGIN_CONTEXT: contextPath,
2203
- AW_PLUGIN_ROOT: pluginDir,
2204
- AW_PLUGIN_NAME: typeof manifest.name === 'string' ? manifest.name : '',
2205
- AW_PLUGIN_VERSION: typeof manifest.version === 'string' ? manifest.version : '',
2206
- AW_PLUGIN_EVENT: event,
2207
- ...(platform ? { AW_PLUGIN_PLATFORM: platform } : {}),
2208
- ...(distribution ? { AW_PLUGIN_DISTRIBUTION: distribution } : {}),
2209
- ...(awSurface ? { AW_PLUGIN_SURFACE: 'managed-commands' } : {}),
2210
- AW_PLUGIN_SCOPE: scope,
2211
- };
2212
- if (process.platform === 'win32') {
2213
- rendererEnv.TEMP = rendererTemp;
2214
- rendererEnv.TMP = rendererTemp;
2215
- if (process.env.SystemRoot)
2216
- rendererEnv.SystemRoot = process.env.SystemRoot;
2217
- if (process.env.ComSpec)
2218
- rendererEnv.ComSpec = process.env.ComSpec;
2219
- }
2220
- else {
2221
- rendererEnv.TMPDIR = rendererTemp;
2222
- }
2223
- const result = spawnSync(process.execPath, [path.join(pluginDir, renderEntry.path), ...(renderEntry.args ?? [])], {
2224
- cwd: pluginDir,
2225
- env: rendererEnv,
2226
- encoding: 'utf8',
2227
- timeout: 5000,
2228
- maxBuffer: 1024 * 1024,
2229
- });
2230
- const fieldName = `scripts.artifacts.render fixture (${surface}/${scope})`;
2231
- if (result.error) {
2232
- error(`${fieldName} failed: ${result.error.message}`);
2233
- continue;
2234
- }
2235
- if (result.status !== 0) {
2236
- const stderr = String(result.stderr ?? '').trim().split('\n')[0] ?? '';
2237
- error(`${fieldName} exited with code ${result.status}${stderr ? `: ${stderr}` : ''}`);
2238
- continue;
2239
- }
2240
- let plan;
2241
- try {
2242
- plan = JSON.parse(result.stdout);
2243
- }
2244
- catch (e) {
2245
- error(`${fieldName} stdout must be JSON ArtifactPlan: ${e.message}`);
1384
+ for (const platform of resolveSupportedPlatforms(manifest)) {
1385
+ const skillsRoot = path.join(root, platform, 'skills');
1386
+ if (!fs.existsSync(skillsRoot))
2246
1387
  continue;
2247
- }
2248
- validateRenderedArtifactPlan(plan, scopedDeclarations, `${surface}/${scope}`, {
2249
- pluginDir,
2250
- manifest,
2251
- runtimeImports: resolvedRuntimeImports,
2252
- tempRoot,
2253
- skillValidationTools,
2254
- managedTrees: managedContext?.trees,
2255
- });
2256
- if (managedContext) {
2257
- try {
2258
- const validated = managedContext.tools.validateArtifactPlan({
2259
- manifest: managedContext.manifest,
2260
- plan,
2261
- platform: surface,
2262
- scope,
2263
- requestedArtifactIds: scopedDeclarations.map((target) => target.id),
2264
- renderConfig: { values: scopedValues, sources: Object.fromEntries(Object.keys(scopedValues).map((key) => [key, 'default'])), issues: [] },
2265
- });
2266
- returnedArtifacts.push(...validated.artifacts.map((artifact) => ({ artifact, scope, surface })));
2267
- }
2268
- catch (cause) {
2269
- error(`${fieldName}: ${cause.message}`);
2270
- }
2271
- }
2272
- }
2273
- }
2274
- finally {
2275
- fs.rmSync(tempRoot, { recursive: true, force: true });
2276
- }
2277
- return returnedArtifacts;
2278
- }
2279
- async function validateDynamicArtifactsLightweight(pluginDir, manifest, renderEntry, runtimeImports, skillValidationTools, managedContext, requiresNonSensitiveArtifactInput, referenceContext) {
2280
- const declarations = validateArtifactsConfigLightweight(pluginDir, manifest);
2281
- if (managedContext)
2282
- declarations.push(...getManagedCommandArtifactTargets(managedContext.manifest));
2283
- const hasTargets = declarations.length > 0;
2284
- const hasRenderer = Boolean(manifest.scripts?.artifacts?.render);
2285
- if (hasTargets && !hasRenderer) {
2286
- error('artifacts.targets requires scripts.artifacts.render');
2287
- }
2288
- if (hasRenderer && !hasTargets) {
2289
- error('scripts.artifacts.render requires artifacts.targets or dynamic managedCommands targets');
2290
- }
2291
- return runArtifactRendererFixture(pluginDir, manifest, renderEntry, declarations, runtimeImports, skillValidationTools, managedContext, requiresNonSensitiveArtifactInput, referenceContext);
2292
- }
2293
- async function validateAuthorManagedCommands(pluginDir, manifest, rendered, context) {
2294
- const { tools, trees } = context;
2295
- const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'aw-author-commands-'));
2296
- const env = { AW_HOME: path.join(tempRoot, 'aw-home'), AW_CODEX_HOME: path.join(tempRoot, 'codex-home'), AW_CLAUDE_HOME: path.join(tempRoot, 'claude-home') };
2297
- const plugin = { manifest, rootDir: pluginDir, sourceId: 'authoring', sourceIdentity: `sha256:${'0'.repeat(64)}` };
2298
- const candidates = [];
2299
- const cleanups = [];
2300
- try {
2301
- const root = manifest.skills && path.join(pluginDir, normalizeRelativePath(manifest.skills));
2302
- if (root && fs.existsSync(root)) {
2303
- for (const entry of fs.readdirSync(root, { withFileTypes: true })) {
1388
+ for (const entry of fs.readdirSync(skillsRoot, { withFileTypes: true })) {
2304
1389
  if (!entry.isDirectory())
2305
1390
  continue;
2306
- for (const platform of targetedPlatforms(manifest)) {
2307
- if ((manifest.artifacts?.targets ?? []).some((target) => target.platform === platform && target.kind === 'skill' && target.skillKey === entry.name))
2308
- continue;
2309
- const files = new Map();
2310
- collectArtifactSourceFiles(path.join(root, entry.name), `static Skill ${entry.name}`, files);
2311
- for (const [relative, bytes] of files) {
2312
- if (isTemplateTextFile(relative))
2313
- files.set(relative, Buffer.from(renderTemplateForPlatform(manifest, `${normalizeRelativePath(manifest.skills)}/${entry.name}/${relative}`, bytes.toString('utf8'), platform)));
1391
+ const generated = (manifest.buildConfig?.generatedSkillRuntimeFiles ?? [])
1392
+ .filter((file) => file.skill === entry.name && (!file.platforms?.length || file.platforms.includes(platform)))
1393
+ .map((file) => file.target);
1394
+ await tools.validateRuntimeSkillClosure(path.join(skillsRoot, entry.name), { declaredGeneratedFiles: new Set(generated) });
1395
+ }
1396
+ }
1397
+ const manifestPath = path.join(root, '.agents-plugin', 'plugin.json');
1398
+ fs.writeFileSync(manifestPath, JSON.stringify(fixtureManifest));
1399
+ const plugin = { rootDir: root, manifestPath, manifest: fixtureManifest, sourceId: 'authoring',
1400
+ sourceIdentity: `sha256:${createHash('sha256').update(fs.realpathSync(pluginDir)).digest('hex')}` };
1401
+ const plugins = [plugin, ...(referencePlugins ?? runtimeImports?.referencePlugins ?? []).filter((entry) => entry.manifest.name !== manifest.name)];
1402
+ const env = await tools.createIsolatedSkillEnv(process.env, path.join(tempRoot, 'state'));
1403
+ for (const platform of resolveSupportedPlatforms(manifest)) {
1404
+ for (const scope of ['user', 'project']) {
1405
+ const definition = compilePluginConfigDefinition(manifest.config ?? { fields: {} }, platform);
1406
+ const values = defaultConfigValues(manifest, platform);
1407
+ const references = referenceContext ? { ...referenceContext, platform, plugins: Object.fromEntries(Object.entries(referenceContext.plugins).map(([name, entry]) => [name, { ...entry,
1408
+ definition: compilePluginConfigDefinition(entry.definition, platform),
1409
+ values: defaultConfigValues({ config: entry.definition }, platform) }])) } : undefined;
1410
+ const config = { mode: 'artifact-render', targetScope: scope, definition, schema: definition.fields, values,
1411
+ sources: Object.fromEntries(Object.keys(values).map((key) => [key, 'default'])),
1412
+ issues: [], stores: {}, referenceContext: references };
1413
+ try {
1414
+ const prepared = await tools.materializeProfilePluginComponents({ plugin, plugins, platform, scope,
1415
+ cwd: pluginDir, env, outputRoot: path.join(tempRoot, `${platform}-${scope}`), config, packagePreparationCache });
1416
+ if (prepared.skills.length && !skillValidationTools)
1417
+ throw new Error('Prepared Skills require the shared CLI Skill validator.');
1418
+ for (const skill of prepared.skills) {
1419
+ // These directories retain the component's logical name. Native host
1420
+ // namespacing belongs to the separate platform projection.
1421
+ const sourceName = `component ${skill.id} (${platform}/${scope}) SKILL.md`;
1422
+ const parsed = skillValidationTools.parseSkillFrontmatter(fs.readFileSync(path.join(skill.path, 'SKILL.md'), 'utf8'), sourceName);
1423
+ for (const entry of parsed.errors)
1424
+ error(`${entry.path} [${entry.code}] ${entry.message}`);
1425
+ if (parsed.frontmatter) {
1426
+ for (const entry of skillValidationTools.validateSkillFrontmatter(parsed.frontmatter, {
1427
+ profile: selectSkillFrontmatterProfile(validationOptions, platform), expectedName: skill.name, sourcePath: sourceName,
1428
+ }))
1429
+ error(`${entry.path} [${entry.code}] ${entry.message}`);
1430
+ }
2314
1431
  }
2315
- const producer = await tools.managedCommandProducerIdentity({
2316
- plugin,
2317
- producer: { kind: 'static-skill', platform, skillKey: entry.name },
2318
- scope: 'user',
2319
- cwd: pluginDir,
2320
- });
2321
- trees.push({ declaration: { target: `${platform}.skill`, platform, skillKey: entry.name, staticSkill: true }, files, scope: producer.scope });
1432
+ for (const unit of prepared.preparation)
1433
+ for (const gap of unit.unmet) {
1434
+ warn(`component unmet (${platform}/${unit.renderScope}): ${gap.id} [${gap.reasonCode}] ${JSON.stringify(gap.requiredFeatures)}`);
1435
+ }
2322
1436
  }
2323
- }
2324
- }
2325
- const setOutputs = (set, platform, scope) => {
2326
- if (set.mode === 'static')
2327
- return { set: set.set, state: 'present', entries: set.entries };
2328
- const output = rendered.find((entry) => entry.artifact.id === `command-set.${set.set}` && entry.scope === scope && entry.surface === platform)?.artifact;
2329
- if (!output)
2330
- throw new Error(`commandReferenceInvalid: dynamic command set ${set.set} was not returned`);
2331
- return { set: set.set, state: output.state, entries: output.entries };
2332
- };
2333
- for (const commandPackage of manifest.managedCommands?.packages ?? []) {
2334
- const sets = (manifest.managedCommands?.sets ?? [])
2335
- .filter((set) => set.producer.kind === 'package' && set.producer.packageKey === commandPackage.key)
2336
- .map((set) => setOutputs(set, 'managed-commands', commandPackage.scope));
2337
- const sourceRoot = path.join(pluginDir, normalizeRelativePath(commandPackage.sourceDir));
2338
- const files = { ...(rendered.find((entry) => entry.artifact.id === `command-package.${commandPackage.key}`)?.artifact.files ?? {}) };
2339
- if (manifest.nativeTools) {
2340
- const readerPath = path.join(pluginDir, normalizeRelativePath(manifest.nativeTools.reader));
2341
- const relativeReader = path.relative(sourceRoot, readerPath);
2342
- if (relativeReader && relativeReader !== '..' && !relativeReader.startsWith(`..${path.sep}`) && !path.isAbsolute(relativeReader) && !fs.existsSync(readerPath)) {
2343
- const readerFile = relativeReader.split(path.sep).join('/');
2344
- const readerSource = createNativeToolReaderSource();
2345
- if (Object.hasOwn(files, readerFile) && files[readerFile] !== readerSource)
2346
- throw new Error('nativeToolReaderMismatch');
2347
- files[readerFile] = readerSource;
1437
+ catch (cause) {
1438
+ const pending = (manifest.buildConfig?.generatedSkillRuntimeFiles ?? []).filter((file) => (!file.platforms?.length || file.platforms.includes(platform))
1439
+ && !fs.existsSync(path.join(root, platform, 'skills', file.skill, file.target)));
1440
+ if (cause.message.startsWith('Invalid runtime Skill closure:') && cause.message.endsWith(' is missing.')
1441
+ && pending.some((file) => cause.message.includes(JSON.stringify(file.target)))) {
1442
+ warn(`component profile unverified (${platform}/${scope}): declared generated runtime files require a staging build; ${cause.message}`);
1443
+ }
1444
+ else
1445
+ error(`component profile fixture (${platform}/${scope}): ${cause.message}`);
2348
1446
  }
2349
1447
  }
2350
- const prepared = await tools.prepareManagedCommandPackageFiles({ sourceRoot, files, entries: sets.flatMap((set) => set.entries) });
2351
- cleanups.push(prepared.cleanup);
2352
- candidates.push({ producer: await tools.managedCommandProducerIdentity({ plugin, producer: { kind: 'package', packageKey: commandPackage.key }, scope: commandPackage.scope, cwd: pluginDir }), sets });
2353
- }
2354
- for (const [index, tree] of trees.entries()) {
2355
- const { declaration } = tree;
2356
- const scope = declaration.target === 'codex.skill' || declaration.target === 'claude.skill' ? 'user' : tree.scope;
2357
- if (declaration.platform !== 'codex' && declaration.platform !== 'claude')
2358
- continue;
2359
- const producer = declaration.staticSkill
2360
- ? { kind: 'static-skill', platform: declaration.platform, skillKey: declaration.skillKey }
2361
- : { kind: 'artifact', artifactId: declaration.id };
2362
- const sets = (manifest.managedCommands?.sets ?? []).filter((set) => JSON.stringify(set.producer) === JSON.stringify(producer))
2363
- .map((set) => setOutputs(set, declaration.platform, scope));
2364
- const resourceRoot = path.join(tempRoot, `skill-${index}`);
2365
- for (const [relative, bytes] of tree.files) {
2366
- const target = path.join(resourceRoot, ...relative.split('/'));
2367
- fs.mkdirSync(path.dirname(target), { recursive: true });
2368
- fs.writeFileSync(target, bytes);
2369
- }
2370
- await validateCommandEntryFiles(resourceRoot, sets.flatMap((set) => set.entries));
2371
- candidates.push({ producer: await tools.managedCommandProducerIdentity({ plugin, producer, scope, cwd: pluginDir }), sets });
2372
1448
  }
2373
- for (const tree of trees) {
2374
- if (tree.declaration.platform !== 'codex' && tree.declaration.platform !== 'claude')
2375
- continue;
2376
- const scope = tree.declaration.target === 'codex.skill' || tree.declaration.target === 'claude.skill' ? 'user' : tree.scope;
2377
- const resolve = await tools.createManagedCommandReferenceResolver({ plugin, platform: tree.declaration.platform, scope, cwd: pluginDir, env, candidates });
2378
- for (const [relative, bytes] of tree.files) {
2379
- if (!relative.endsWith('.md'))
2380
- continue;
2381
- const text = bytes.toString('utf8');
2382
- if (parseManagedCommandPlaceholders(text).length > 0 && !(manifest.requires?.aw?.capabilities ?? []).includes('aw.managed-commands.v1'))
2383
- throw new Error('managed command references require aw.managed-commands.v1');
2384
- replaceManagedCommandPlaceholders(text, resolve);
2385
- }
2386
- }
2387
- for (const permission of manifest.extensions?.permissions ?? []) {
2388
- for (const platform of targetedPlatforms(manifest)) {
2389
- for (const scope of platform === 'codex' ? ['user'] : ['user', 'project']) {
2390
- const resolve = await tools.createManagedCommandReferenceResolver({ plugin, platform, scope, cwd: pluginDir, env, candidates });
2391
- const override = permission.agentOverrides?.[platform];
2392
- if (override === null)
2393
- continue;
2394
- for (const decision of ['allow', 'ask', 'deny'])
2395
- for (const rule of override?.[decision] ?? permission[decision] ?? [])
2396
- if (typeof rule !== 'string')
2397
- resolve(rule.command);
2398
- if (platform === 'claude')
2399
- for (const rule of override?.sandbox?.excludedCommands ?? [])
2400
- resolve(rule.command);
2401
- }
1449
+ for (const declaration of manifest.managedCommands?.packages ?? []) {
1450
+ const identity = await tools.managedCommandProducerIdentity({ plugin,
1451
+ producer: { kind: 'package', packageKey: declaration.key }, scope: declaration.scope, cwd: pluginDir });
1452
+ const key = getCommandPackageId(identity);
1453
+ if (!packagePreparationCache.has(key)) {
1454
+ packagePreparationCache.set(key, tools.prepareManagedCommandPackage({ plugin, referencePlugins: plugins,
1455
+ packageKey: declaration.key, scope: declaration.scope, cwd: pluginDir, env, event: 'materialize' }));
2402
1456
  }
1457
+ await packagePreparationCache.get(key);
2403
1458
  }
2404
1459
  }
2405
1460
  catch (cause) {
2406
- error(`managed command authoring candidate: ${cause.message}`);
1461
+ error(`author component preparation: ${cause.message}`);
2407
1462
  }
2408
1463
  finally {
2409
- for (const cleanup of cleanups)
2410
- await cleanup();
1464
+ const preparedPackages = await Promise.allSettled(packagePreparationCache.values());
1465
+ const cleanedPackages = await Promise.allSettled(preparedPackages
1466
+ .filter((entry) => entry.status === 'fulfilled').map((entry) => entry.value.cleanup()));
1467
+ for (const entry of cleanedPackages) {
1468
+ if (entry.status === 'rejected')
1469
+ error(`author component cleanup: ${entry.reason.message}`);
1470
+ }
2411
1471
  fs.rmSync(tempRoot, { recursive: true, force: true });
2412
1472
  }
2413
1473
  }
@@ -2423,10 +1483,7 @@ function validateScriptsLightweight(pluginDir, manifest) {
2423
1483
  let artifactRenderEntry = null;
2424
1484
  let packageMeta = null;
2425
1485
  const nativeToolReader = manifest.nativeTools ? normalizeRelativePath(manifest.nativeTools.reader ?? './.aw/native-tool-reader.mjs') : undefined;
2426
- const runtimeConfigSkillRoots = (manifest.artifacts?.targets ?? [])
2427
- .filter((target) => target.runtimeConfig !== undefined)
2428
- .flatMap((target) => target.sourceDirs ?? [])
2429
- .map(normalizeRelativePath);
1486
+ const runtimeConfigSkillRoots = (manifest.artifacts?.sourceDirs ?? []).map(normalizeRelativePath);
2430
1487
  if (scripts.helpers !== undefined) {
2431
1488
  const helpers = expectRecord(scripts.helpers, 'scripts.helpers');
2432
1489
  if (helpers) {
@@ -2559,55 +1616,6 @@ function validateMcpContent(pluginDir, manifest) {
2559
1616
  error(`${manifest.mcpServers} is not valid JSON: ${e.message}`);
2560
1617
  }
2561
1618
  }
2562
- function validateAppsContent(pluginDir, manifest) {
2563
- if (!manifest.apps)
2564
- return;
2565
- if (isTemplateAsset(manifest, manifest.apps))
2566
- return;
2567
- const appsPath = path.join(pluginDir, manifest.apps);
2568
- if (!fs.existsSync(appsPath))
2569
- return;
2570
- try {
2571
- const content = JSON.parse(fs.readFileSync(appsPath, 'utf8'));
2572
- if (!content.apps || typeof content.apps !== 'object') {
2573
- error(`${manifest.apps} must have an "apps" top-level key`);
2574
- }
2575
- }
2576
- catch (e) {
2577
- error(`${manifest.apps} is not valid JSON: ${e.message}`);
2578
- }
2579
- }
2580
- function hasCodexRepoManagedSurface(manifest) {
2581
- if (manifest.skills || manifest.slashCommands || manifest.mcpServers) {
2582
- return true;
2583
- }
2584
- if ((manifest.artifacts?.targets ?? []).some((target) => target?.platform === 'codex' &&
2585
- Array.isArray(target.scopes) &&
2586
- target.scopes.includes('project') &&
2587
- typeof target.projectManagedKind === 'string')) {
2588
- return true;
2589
- }
2590
- const extensions = manifest.extensions;
2591
- if (!extensions || typeof extensions !== 'object' || Array.isArray(extensions)) {
2592
- return false;
2593
- }
2594
- return ['instructions', 'permissions', 'hooks', 'agents'].some((key) => Array.isArray(extensions[key]) && extensions[key].length > 0) || (extensions.nativeHooks &&
2595
- typeof extensions.nativeHooks === 'object' &&
2596
- !Array.isArray(extensions.nativeHooks) &&
2597
- Array.isArray(extensions.nativeHooks.codex) &&
2598
- extensions.nativeHooks.codex.length > 0);
2599
- }
2600
- function warnCodexProjectScopeLimitations(manifest) {
2601
- if (!isCodexTargeted(manifest)) {
2602
- return;
2603
- }
2604
- if (manifest.apps) {
2605
- warn('Codex project scope does not support apps; users must install this app surface with `aw plugin install <plugin> --target codex --scope user` or split the plugin.');
2606
- }
2607
- if (!hasCodexRepoManagedSurface(manifest)) {
2608
- warn('This Codex-targeted plugin has no repo-managed project surface; Codex project scope will fail fast and only Codex user native install is applicable.');
2609
- }
2610
- }
2611
1619
  function validateExtensionNameUniqueness(manifest) {
2612
1620
  if (!manifest.extensions)
2613
1621
  return;
@@ -2661,7 +1669,12 @@ function validateOpenAiYaml(openaiYamlPath, skillName, required, manifest, plugi
2661
1669
  error(`${fieldName} shared validation failed: ${e.message}`);
2662
1670
  }
2663
1671
  }
2664
- function validateSkills(pluginDir, manifest, options, skillValidationTools) {
1672
+ function selectSkillFrontmatterProfile(options, platform) {
1673
+ return options.strictAgentSkills ? 'portable-agent-skills'
1674
+ : platform === 'claude' && options.claudeSkillProfile === 'minimum'
1675
+ ? 'claude-2.1.88' : 'claude-current';
1676
+ }
1677
+ async function validateSkills(pluginDir, manifest, options, skillValidationTools) {
2665
1678
  if (!manifest.skills)
2666
1679
  return;
2667
1680
  const skillsDir = path.join(pluginDir, manifest.skills);
@@ -2674,11 +1687,12 @@ function validateSkills(pluginDir, manifest, options, skillValidationTools) {
2674
1687
  error('skills directory exists but contains no skill subdirectories');
2675
1688
  }
2676
1689
  for (const dir of skillDirs) {
2677
- const staticPlatforms = [...resolveSupportedPlatforms(manifest)].filter((platform) => !(manifest.artifacts?.targets ?? []).some((target) => target.platform === platform && target.skillKey === dir.name));
1690
+ if (await isAuthorOnlySkillDirectory(path.join(skillsDir, dir.name)))
1691
+ continue;
1692
+ const staticPlatforms = [...resolveSupportedPlatforms(manifest)];
2678
1693
  if (staticPlatforms.length === 0)
2679
1694
  continue;
2680
1695
  const requiresCodexMetadata = staticPlatforms.includes('codex');
2681
- const targetsClaude = staticPlatforms.includes('claude');
2682
1696
  const skillPath = path.join(skillsDir, dir.name);
2683
1697
  const skillMdPath = path.join(skillPath, 'SKILL.md');
2684
1698
  const openaiYamlPath = path.join(skillPath, 'agents', 'openai.yaml');
@@ -2692,9 +1706,23 @@ function validateSkills(pluginDir, manifest, options, skillValidationTools) {
2692
1706
  if (lineCount >= MAX_SKILL_LINES) {
2693
1707
  warn(`skills/${dir.name}/SKILL.md has ${lineCount} lines; Agent Skills recommends keeping SKILL.md under ${MAX_SKILL_LINES} lines`);
2694
1708
  }
2695
- const variants = renderedContentVariants(manifest, skillMdRelativePath, content, staticPlatforms);
1709
+ const variants = [];
1710
+ for (const platform of staticPlatforms) {
1711
+ try {
1712
+ variants.push({ platform, content: renderTemplateForPlatform(manifest, skillMdRelativePath, content, platform) });
1713
+ }
1714
+ catch (cause) {
1715
+ error(`${skillMdRelativePath} (${platform} render): ${cause.message}`);
1716
+ }
1717
+ }
1718
+ const validatedVariants = new Set();
2696
1719
  for (const variant of variants) {
2697
- const sourceName = variant.platform
1720
+ const profile = selectSkillFrontmatterProfile(options, variant.platform);
1721
+ const key = JSON.stringify([profile, variant.content]);
1722
+ if (validatedVariants.has(key))
1723
+ continue;
1724
+ validatedVariants.add(key);
1725
+ const sourceName = templateIncludesPath(manifest, skillMdRelativePath)
2698
1726
  ? `skills/${dir.name}/SKILL.md (${variant.platform} render)`
2699
1727
  : `skills/${dir.name}/SKILL.md`;
2700
1728
  if (!skillValidationTools) {
@@ -2706,11 +1734,8 @@ function validateSkills(pluginDir, manifest, options, skillValidationTools) {
2706
1734
  error(`${entry.path} [${entry.code}] ${entry.message}`);
2707
1735
  }
2708
1736
  if (parsed.frontmatter) {
2709
- const profile = options.strictAgentSkills || !targetsClaude || isPortablePlatformTarget(variant.platform)
2710
- ? 'portable-agent-skills'
2711
- : options.claudeSkillProfile === 'current'
2712
- ? 'claude-current'
2713
- : 'claude-2.1.88';
1737
+ // Source metadata preserves requested behavior. Host support is checked
1738
+ // later by the selected component profile, including explicit unmet.
2714
1739
  const diagnostics = skillValidationTools.validateSkillFrontmatter(parsed.frontmatter, {
2715
1740
  profile,
2716
1741
  expectedName: dir.name,
@@ -2728,212 +1753,6 @@ function validateSkills(pluginDir, manifest, options, skillValidationTools) {
2728
1753
  }
2729
1754
  }
2730
1755
  }
2731
- function detectCodexSlashCommandForbiddenSyntax(content) {
2732
- const checks = [
2733
- [/\$ARGUMENTS\b/, '$ARGUMENTS'],
2734
- [/\$\d+\b/, '$1'],
2735
- [/```!/, '```!'],
2736
- [/!`[^`\r\n]+`/, '!`command`'],
2737
- ];
2738
- for (const [pattern, label] of checks) {
2739
- if (pattern.test(content)) {
2740
- return label;
2741
- }
2742
- }
2743
- return null;
2744
- }
2745
- function validateSlashCommandAssetReference(commandRoot, commandRelativePath, value, fieldName) {
2746
- if (value === undefined)
2747
- return;
2748
- validateCodexIconPath({ [fieldName]: value }, fieldName, `${commandRelativePath}.codex.interface`);
2749
- if (typeof value !== 'string' || value.trim().length === 0)
2750
- return;
2751
- const normalized = normalizeRelativePath(stripDotSlash(value));
2752
- const absolutePath = path.join(commandRoot, normalized);
2753
- const stats = fs.statSync(absolutePath, { throwIfNoEntry: false });
2754
- if (!stats) {
2755
- error(`${commandRelativePath}.codex.interface.${fieldName} references missing asset "${value}"`);
2756
- return;
2757
- }
2758
- if (!stats.isFile()) {
2759
- error(`${commandRelativePath}.codex.interface.${fieldName} must reference a file, got "${value}"`);
2760
- }
2761
- }
2762
- function validateSlashCommandFrontmatter(commandRoot, commandRelativePath, frontmatter, platform) {
2763
- const fieldName = `${commandRelativePath} frontmatter`;
2764
- const fm = expectRecord(frontmatter, fieldName);
2765
- if (!fm)
2766
- return;
2767
- for (const key of Object.keys(fm)) {
2768
- if (CLAUDE_SLASH_COMMAND_ONLY_FIELDS.has(key)) {
2769
- error(`${fieldName}: "${key}" must be nested under "claude"`);
2770
- }
2771
- }
2772
- validateAllowedKeys(fm, fieldName, ['description', 'claude', 'codex']);
2773
- validateNonEmptyString(fm.description, `${fieldName}.description`, MAX_SKILL_DESCRIPTION_LEN);
2774
- if (platform === 'claude' && fm.claude !== undefined) {
2775
- const claudeBlock = expectRecord(fm.claude, `${fieldName}.claude`);
2776
- if (claudeBlock) {
2777
- validateAllowedKeys(claudeBlock, `${fieldName}.claude`, [
2778
- 'description',
2779
- 'allowed-tools',
2780
- 'model',
2781
- 'argument-hint',
2782
- 'shell',
2783
- ]);
2784
- if (claudeBlock.description !== undefined) {
2785
- validateNonEmptyString(claudeBlock.description, `${fieldName}.claude.description`, MAX_SKILL_DESCRIPTION_LEN);
2786
- }
2787
- if (claudeBlock['allowed-tools'] !== undefined) {
2788
- validateAllowedTools(claudeBlock['allowed-tools'], `${fieldName}.claude.allowed-tools`, { allowArray: true });
2789
- }
2790
- if (claudeBlock.model !== undefined) {
2791
- validateNonEmptyString(claudeBlock.model, `${fieldName}.claude.model`);
2792
- }
2793
- if (claudeBlock['argument-hint'] !== undefined) {
2794
- validateNonEmptyString(claudeBlock['argument-hint'], `${fieldName}.claude.argument-hint`);
2795
- }
2796
- if (claudeBlock.shell !== undefined) {
2797
- if (typeof claudeBlock.shell !== 'string') {
2798
- error(`${fieldName}.claude.shell must be a string`);
2799
- }
2800
- else if (!CLAUDE_FRONTMATTER_SHELLS.has(claudeBlock.shell.trim().toLowerCase())) {
2801
- error(`${fieldName}.claude.shell must be "bash" or "powershell"`);
2802
- }
2803
- }
2804
- }
2805
- }
2806
- if (platform === 'codex' && fm.codex !== undefined) {
2807
- const codexBlock = expectRecord(fm.codex, `${fieldName}.codex`);
2808
- if (codexBlock) {
2809
- if (codexBlock.policy !== undefined) {
2810
- error(`${fieldName}.codex.policy is not supported; generated slashCommands skills are always manual-only`);
2811
- }
2812
- validateAllowedKeys(codexBlock, `${fieldName}.codex`, ['description', 'interface']);
2813
- if (codexBlock.description !== undefined) {
2814
- validateNonEmptyString(codexBlock.description, `${fieldName}.codex.description`, MAX_SKILL_DESCRIPTION_LEN);
2815
- }
2816
- if (codexBlock.interface !== undefined) {
2817
- const interfaceBlock = expectRecord(codexBlock.interface, `${fieldName}.codex.interface`);
2818
- if (interfaceBlock) {
2819
- validateAllowedKeys(interfaceBlock, `${fieldName}.codex.interface`, [
2820
- 'display_name',
2821
- 'short_description',
2822
- 'icon_small',
2823
- 'icon_large',
2824
- 'brand_color',
2825
- 'default_prompt',
2826
- ]);
2827
- validateCodexMetadataString(interfaceBlock, 'display_name', `${fieldName}.codex.interface`, MAX_OPENAI_INTERFACE_NAME_LEN);
2828
- validateCodexShortDescription(interfaceBlock, `${fieldName}.codex.interface`);
2829
- validateCodexDefaultPrompt(interfaceBlock, 'default_prompt', `${fieldName}.codex.interface`, MAX_OPENAI_DEFAULT_PROMPT_LEN, path.basename(commandRelativePath, path.extname(commandRelativePath)));
2830
- validateCodexBrandColor(interfaceBlock, 'brand_color', `${fieldName}.codex.interface`);
2831
- validateSlashCommandAssetReference(commandRoot, commandRelativePath, interfaceBlock.icon_small, 'icon_small');
2832
- validateSlashCommandAssetReference(commandRoot, commandRelativePath, interfaceBlock.icon_large, 'icon_large');
2833
- }
2834
- }
2835
- }
2836
- }
2837
- }
2838
- function validateSlashCommands(pluginDir, manifest) {
2839
- const defaultSlashCommandsDir = path.join(pluginDir, DEFAULT_SLASH_COMMANDS_DIR);
2840
- if (fs.existsSync(defaultSlashCommandsDir) && !manifest.slashCommands) {
2841
- error(`"${DEFAULT_SLASH_COMMANDS_DIR}" exists but manifest does not declare "slashCommands"`);
2842
- }
2843
- if (!manifest.slashCommands)
2844
- return;
2845
- const targetPlatforms = resolveSupportedPlatforms(manifest);
2846
- const slashCommandsRoot = path.join(pluginDir, manifest.slashCommands);
2847
- const stats = fs.statSync(slashCommandsRoot, { throwIfNoEntry: false });
2848
- if (!stats) {
2849
- error(`slashCommands points to "${manifest.slashCommands}" but path does not exist`);
2850
- return;
2851
- }
2852
- if (!stats.isDirectory()) {
2853
- error(`slashCommands must point to a directory, got "${manifest.slashCommands}"`);
2854
- return;
2855
- }
2856
- const skillNames = new Set();
2857
- if (manifest.skills) {
2858
- const skillsRoot = path.join(pluginDir, manifest.skills);
2859
- if (fs.existsSync(skillsRoot)) {
2860
- for (const entry of fs.readdirSync(skillsRoot, { withFileTypes: true })) {
2861
- if (entry.isDirectory()) {
2862
- skillNames.add(entry.name);
2863
- }
2864
- }
2865
- }
2866
- }
2867
- const seenCommands = new Set();
2868
- const commandFiles = [];
2869
- for (const entry of fs.readdirSync(slashCommandsRoot, { withFileTypes: true })) {
2870
- const relativePath = normalizeRelativePath(path.join(stripDotSlash(manifest.slashCommands), entry.name));
2871
- if (entry.isDirectory()) {
2872
- if (entry.name !== 'assets') {
2873
- error(`slashCommands does not support nested directory "${relativePath}"; only root *.md files and assets/ are allowed`);
2874
- }
2875
- continue;
2876
- }
2877
- if (!entry.isFile()) {
2878
- error(`slashCommands has unsupported entry "${relativePath}"`);
2879
- continue;
2880
- }
2881
- if (path.posix.extname(entry.name) !== '.md') {
2882
- error(`slashCommands only accepts root *.md files; found "${relativePath}"`);
2883
- continue;
2884
- }
2885
- commandFiles.push(entry.name);
2886
- }
2887
- if (commandFiles.length === 0) {
2888
- error(`slashCommands "${manifest.slashCommands}" must contain at least one root *.md command file`);
2889
- return;
2890
- }
2891
- for (const fileName of commandFiles.sort()) {
2892
- const commandName = path.posix.basename(fileName, '.md');
2893
- const commandRelativePath = normalizeRelativePath(path.join(stripDotSlash(manifest.slashCommands), fileName));
2894
- if (commandName.length === 0 ||
2895
- commandName.length > 64 ||
2896
- !SLASH_COMMAND_NAME_PATTERN.test(commandName)) {
2897
- error(`${commandRelativePath} command name must use lowercase hyphen-case and be <= 64 characters`);
2898
- continue;
2899
- }
2900
- if (seenCommands.has(commandName)) {
2901
- error(`slashCommands has duplicate command name "${commandName}"`);
2902
- continue;
2903
- }
2904
- if (skillNames.has(commandName)) {
2905
- error(`slashCommands command "${commandName}" conflicts with source skill "${commandName}"`);
2906
- continue;
2907
- }
2908
- seenCommands.add(commandName);
2909
- const absolutePath = path.join(slashCommandsRoot, fileName);
2910
- const rawContent = fs.readFileSync(absolutePath, 'utf8');
2911
- for (const platform of ['claude', 'codex']) {
2912
- if (!targetPlatforms.has(platform))
2913
- continue;
2914
- const rendered = renderTemplateForPlatform(manifest, commandRelativePath, rawContent, platform);
2915
- if (platform === 'codex') {
2916
- const codexForbiddenSyntax = detectCodexSlashCommandForbiddenSyntax(rendered);
2917
- if (codexForbiddenSyntax) {
2918
- error(`${commandRelativePath} Codex render still contains Claude-only syntax "${codexForbiddenSyntax}"`);
2919
- }
2920
- }
2921
- let frontmatter;
2922
- try {
2923
- frontmatter = parseFrontmatter(rendered, `${commandRelativePath} (${platform} render)`);
2924
- }
2925
- catch (parseError) {
2926
- error(`${commandRelativePath} (${platform} render) has invalid YAML frontmatter: ${parseError.message}`);
2927
- continue;
2928
- }
2929
- if (!frontmatter) {
2930
- error(`${commandRelativePath} (${platform} render) is missing YAML frontmatter`);
2931
- continue;
2932
- }
2933
- validateSlashCommandFrontmatter(slashCommandsRoot, commandRelativePath, frontmatter, platform);
2934
- }
2935
- }
2936
- }
2937
1756
  // ---------------------------------------------------------------------------
2938
1757
  // Main
2939
1758
  // ---------------------------------------------------------------------------
@@ -2944,7 +1763,7 @@ function printUsage() {
2944
1763
  Options:
2945
1764
  --strict-agent-skills Allow only Agent Skills portable core frontmatter.
2946
1765
  --claude-skill-profile <minimum|current>
2947
- Validate Claude fields at AW minimum 2.1.88 (default) or current docs.
1766
+ Validate current source fields (default), or explicitly require Claude 2.1.88 fields.
2948
1767
  --version-base <git-ref> Compare the production bundle against this Git base. Default: HEAD.
2949
1768
  --workspace-root <path> Workspace root. Default: current directory.
2950
1769
  --json Emit one machine-readable JSON result to stdout.
@@ -3013,6 +1832,7 @@ async function validatePluginDir(pluginDir, options) {
3013
1832
  const sourceConfig = manifest.config;
3014
1833
  let normalizedManifest;
3015
1834
  let referenceContext;
1835
+ let referencePlugins;
3016
1836
  try {
3017
1837
  normalizedManifest = await cliManifestTools.validateSourcePluginManifest(pluginDir, manifest);
3018
1838
  manifest = normalizedManifest;
@@ -3032,6 +1852,7 @@ async function validatePluginDir(pluginDir, options) {
3032
1852
  }
3033
1853
  plugins = workspace.plugins;
3034
1854
  }
1855
+ referencePlugins = plugins;
3035
1856
  referenceContext = {
3036
1857
  plugin: manifest.name,
3037
1858
  dependencies: manifest.dependencies ?? [],
@@ -3072,28 +1893,19 @@ async function validatePluginDir(pluginDir, options) {
3072
1893
  validateNameMatchesDirectory(pluginDir, manifest);
3073
1894
  validateNoBuildOutputDirs(pluginDir);
3074
1895
  validateDeclaredNativeAssets(pluginDir, manifest);
3075
- validateCanonicalSkillLayout(pluginDir, manifest);
1896
+ await validateCanonicalSkillLayout(pluginDir, manifest);
3076
1897
  await validatePluginEvalManifest(pluginDir, manifest);
3077
- const artifactRenderEntry = validateScriptsLightweight(pluginDir, manifest);
1898
+ validateScriptsLightweight(pluginDir, manifest);
3078
1899
  const runtimeImports = await resolveAuthorRuntimeImports({
3079
1900
  pluginDir,
3080
1901
  manifest,
3081
1902
  repoRoot: options.repoRoot,
3082
1903
  cliManifestTools,
3083
1904
  });
3084
- validateStaticPortableFinalTrees(pluginDir, manifest, runtimeImports, skillValidationTools);
3085
- const managedContext = normalizedManifest
3086
- ? { manifest: normalizedManifest, tools: cliManifestTools, trees: [] }
3087
- : undefined;
3088
- const rendered = await validateDynamicArtifactsLightweight(pluginDir, manifest, artifactRenderEntry, runtimeImports, skillValidationTools, managedContext, cliManifestTools.requiresNonSensitiveArtifactInput, referenceContext);
3089
- if (managedContext)
3090
- await validateAuthorManagedCommands(pluginDir, normalizedManifest, rendered ?? [], managedContext);
1905
+ await validateAuthorComponentFixtures(pluginDir, manifest, runtimeImports, cliManifestTools, referenceContext, referencePlugins, skillValidationTools, options);
3091
1906
  validateMcpContent(pluginDir, manifest);
3092
- validateAppsContent(pluginDir, manifest);
3093
- warnCodexProjectScopeLimitations(manifest);
3094
1907
  validateExtensionNameUniqueness(manifest);
3095
- validateSkills(pluginDir, manifest, options, skillValidationTools);
3096
- validateSlashCommands(pluginDir, manifest);
1908
+ await validateSkills(pluginDir, manifest, options, skillValidationTools);
3097
1909
  if (errors.length === 0) {
3098
1910
  const repoRoot = resolveCanonicalRepoRoot(pluginDir, manifest.name ?? '', options.gitRoot);
3099
1911
  if (repoRoot) {
@@ -3129,7 +1941,7 @@ function parseArgs(argv) {
3129
1941
  const options = {
3130
1942
  pluginDir: null,
3131
1943
  strictAgentSkills: false,
3132
- claudeSkillProfile: 'minimum',
1944
+ claudeSkillProfile: 'current',
3133
1945
  versionBase: 'HEAD',
3134
1946
  workspaceRoot: null,
3135
1947
  json: args.includes('--json'),