@lesliechan721/aw 0.1.0-beta.8 → 0.1.0-beta.80

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 (802) hide show
  1. package/dist/authoring/assets/aw-config.mjs +100 -501
  2. package/dist/authoring/assets/aw-config.mjs.map +1 -1
  3. package/dist/authoring/assets/aw-runtime-config.d.mts +13 -0
  4. package/dist/authoring/assets/aw-runtime-config.mjs +221 -0
  5. package/dist/authoring/assets/aw-runtime-config.mjs.map +1 -0
  6. package/dist/authoring/scripts/add-skill.mjs +17 -40
  7. package/dist/authoring/scripts/add-skill.mjs.map +1 -1
  8. package/dist/authoring/scripts/init-plugin.mjs +74 -98
  9. package/dist/authoring/scripts/init-plugin.mjs.map +1 -1
  10. package/dist/authoring/scripts/lib/plugin-root.mjs +4 -4
  11. package/dist/authoring/scripts/lib/plugin-root.mjs.map +1 -1
  12. package/dist/authoring/scripts/lib/plugin-version-check.d.mts +1 -0
  13. package/dist/authoring/scripts/lib/plugin-version-check.mjs +230 -9
  14. package/dist/authoring/scripts/lib/plugin-version-check.mjs.map +1 -1
  15. package/dist/authoring/scripts/lib/skill-scaffold.d.mts +79 -92
  16. package/dist/authoring/scripts/lib/skill-scaffold.mjs +103 -127
  17. package/dist/authoring/scripts/lib/skill-scaffold.mjs.map +1 -1
  18. package/dist/authoring/scripts/remove-plugin.mjs +2 -2
  19. package/dist/authoring/scripts/remove-plugin.mjs.map +1 -1
  20. package/dist/authoring/scripts/validate-plugin.mjs +459 -2843
  21. package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
  22. package/dist/authoring/scripts/validate-skill.mjs +1 -1
  23. package/dist/native-runtime/reader-runtime.mjs +34 -0
  24. package/dist/native-runtime/reader.d.mts +6 -0
  25. package/dist/native-runtime/reader.mjs +11 -0
  26. package/dist/scripts/aw-skill-eval-materializer.d.ts +30 -0
  27. package/dist/scripts/aw-skill-eval-materializer.js +278 -0
  28. package/dist/scripts/aw-skill-eval-materializer.js.map +1 -0
  29. package/dist/scripts/bundle-plugins.d.ts +1 -0
  30. package/dist/scripts/bundle-plugins.js +27 -8
  31. package/dist/scripts/bundle-plugins.js.map +1 -1
  32. package/dist/scripts/plugin-staging.d.ts +7 -8
  33. package/dist/scripts/plugin-staging.js +16 -15
  34. package/dist/scripts/plugin-staging.js.map +1 -1
  35. package/dist/scripts/plugin-test-reporter.d.mts +2 -0
  36. package/dist/scripts/plugin-test-reporter.mjs +21 -0
  37. package/dist/scripts/plugin-test-reporter.mjs.map +1 -0
  38. package/dist/scripts/test-plugin-scripts.d.ts +5 -0
  39. package/dist/scripts/test-plugin-scripts.js +273 -78
  40. package/dist/scripts/test-plugin-scripts.js.map +1 -1
  41. package/dist/scripts/test-workers.d.mts +24 -0
  42. package/dist/scripts/test-workers.mjs +59 -0
  43. package/dist/scripts/test-workers.mjs.map +1 -0
  44. package/dist/src/adapters/helpers.d.ts +7 -0
  45. package/dist/src/adapters/helpers.js.map +1 -1
  46. package/dist/src/authoring/workspace-commands.d.ts +5 -1
  47. package/dist/src/authoring/workspace-commands.js +7 -2
  48. package/dist/src/authoring/workspace-commands.js.map +1 -1
  49. package/dist/src/commands/aw-capabilities.d.ts +2 -2
  50. package/dist/src/commands/aw-capabilities.js +41 -29
  51. package/dist/src/commands/aw-capabilities.js.map +1 -1
  52. package/dist/src/commands/catalog-dev-source.d.ts +58 -13
  53. package/dist/src/commands/catalog-dev-source.js +549 -305
  54. package/dist/src/commands/catalog-dev-source.js.map +1 -1
  55. package/dist/src/commands/catalog-generation.d.ts +14 -19
  56. package/dist/src/commands/catalog-generation.js +5 -10
  57. package/dist/src/commands/catalog-generation.js.map +1 -1
  58. package/dist/src/commands/catalog-publication-inspection.d.ts +70 -29
  59. package/dist/src/commands/catalog-publication-inspection.js +475 -62
  60. package/dist/src/commands/catalog-publication-inspection.js.map +1 -1
  61. package/dist/src/commands/catalog-publication-journal.d.ts +68 -0
  62. package/dist/src/commands/catalog-publication-journal.js +292 -0
  63. package/dist/src/commands/catalog-publication-journal.js.map +1 -0
  64. package/dist/src/commands/catalog-publication-target.d.ts +2 -1
  65. package/dist/src/commands/catalog-publication-target.js +37 -2
  66. package/dist/src/commands/catalog-publication-target.js.map +1 -1
  67. package/dist/src/commands/catalog-publish.d.ts +82 -15
  68. package/dist/src/commands/catalog-publish.js +722 -219
  69. package/dist/src/commands/catalog-publish.js.map +1 -1
  70. package/dist/src/commands/catalog-source.d.ts +55 -35
  71. package/dist/src/commands/catalog-source.js +298 -148
  72. package/dist/src/commands/catalog-source.js.map +1 -1
  73. package/dist/src/commands/catalog-status.d.ts +6 -26
  74. package/dist/src/commands/catalog-status.js +9 -147
  75. package/dist/src/commands/catalog-status.js.map +1 -1
  76. package/dist/src/commands/catalog-store.d.ts +104 -0
  77. package/dist/src/commands/catalog-store.js +685 -0
  78. package/dist/src/commands/catalog-store.js.map +1 -0
  79. package/dist/src/commands/catalog-workspace-resolution.d.ts +17 -0
  80. package/dist/src/commands/catalog-workspace-resolution.js +57 -0
  81. package/dist/src/commands/catalog-workspace-resolution.js.map +1 -0
  82. package/dist/src/commands/console.js +32 -20
  83. package/dist/src/commands/console.js.map +1 -1
  84. package/dist/src/commands/dependency-operation-plan.d.ts +52 -15
  85. package/dist/src/commands/dependency-operation-plan.js +289 -7
  86. package/dist/src/commands/dependency-operation-plan.js.map +1 -1
  87. package/dist/src/commands/deployment-confirmation.d.ts +4 -0
  88. package/dist/src/commands/deployment-confirmation.js +20 -0
  89. package/dist/src/commands/deployment-confirmation.js.map +1 -0
  90. package/dist/src/commands/init.d.ts +5 -11
  91. package/dist/src/commands/init.js +30 -51
  92. package/dist/src/commands/init.js.map +1 -1
  93. package/dist/src/commands/intent-command.d.ts +32 -0
  94. package/dist/src/commands/intent-command.js +171 -0
  95. package/dist/src/commands/intent-command.js.map +1 -0
  96. package/dist/src/commands/managed-commands.d.ts +35 -0
  97. package/dist/src/commands/managed-commands.js +361 -0
  98. package/dist/src/commands/managed-commands.js.map +1 -0
  99. package/dist/src/commands/offline-cleanup-evidence.d.ts +46 -0
  100. package/dist/src/commands/offline-cleanup-evidence.js +158 -10
  101. package/dist/src/commands/offline-cleanup-evidence.js.map +1 -1
  102. package/dist/src/commands/operation-plan.d.ts +190 -0
  103. package/dist/src/commands/operation-plan.js +99 -0
  104. package/dist/src/commands/operation-plan.js.map +1 -0
  105. package/dist/src/commands/operation-planner.d.ts +47 -0
  106. package/dist/src/commands/operation-planner.js +142 -0
  107. package/dist/src/commands/operation-planner.js.map +1 -0
  108. package/dist/src/commands/options.d.ts +16 -20
  109. package/dist/src/commands/options.js +94 -41
  110. package/dist/src/commands/options.js.map +1 -1
  111. package/dist/src/commands/plugin-capabilities.js +88 -45
  112. package/dist/src/commands/plugin-capabilities.js.map +1 -1
  113. package/dist/src/commands/public-config-confirmation.d.ts +8 -0
  114. package/dist/src/commands/public-config-confirmation.js +56 -0
  115. package/dist/src/commands/public-config-confirmation.js.map +1 -0
  116. package/dist/src/commands/public-interruption.d.ts +9 -0
  117. package/dist/src/commands/public-interruption.js +23 -0
  118. package/dist/src/commands/public-interruption.js.map +1 -0
  119. package/dist/src/commands/public-lifecycle-result.d.ts +102 -0
  120. package/dist/src/commands/public-lifecycle-result.js +307 -0
  121. package/dist/src/commands/public-lifecycle-result.js.map +1 -0
  122. package/dist/src/commands/public-lifecycle.d.ts +28 -0
  123. package/dist/src/commands/public-lifecycle.js +492 -0
  124. package/dist/src/commands/public-lifecycle.js.map +1 -0
  125. package/dist/src/commands/public-plugin-query.d.ts +16 -0
  126. package/dist/src/commands/public-plugin-query.js +193 -0
  127. package/dist/src/commands/public-plugin-query.js.map +1 -0
  128. package/dist/src/commands/rebuild-command.d.ts +166 -28
  129. package/dist/src/commands/rebuild-command.js +3745 -813
  130. package/dist/src/commands/rebuild-command.js.map +1 -1
  131. package/dist/src/commands/rebuild-integration.d.ts +137 -25
  132. package/dist/src/commands/rebuild-integration.js +1343 -2535
  133. package/dist/src/commands/rebuild-integration.js.map +1 -1
  134. package/dist/src/commands/rebuild-operations.d.ts +73 -22
  135. package/dist/src/commands/rebuild-operations.js +313 -216
  136. package/dist/src/commands/rebuild-operations.js.map +1 -1
  137. package/dist/src/commands/rebuild-platform-integration.d.ts +62 -0
  138. package/dist/src/commands/rebuild-platform-integration.js +1317 -0
  139. package/dist/src/commands/rebuild-platform-integration.js.map +1 -0
  140. package/dist/src/commands/reconcile-operation-plan.d.ts +28 -0
  141. package/dist/src/commands/reconcile-operation-plan.js +47 -0
  142. package/dist/src/commands/reconcile-operation-plan.js.map +1 -0
  143. package/dist/src/commands/review-inspection.d.ts +60 -0
  144. package/dist/src/commands/review-inspection.js +436 -0
  145. package/dist/src/commands/review-inspection.js.map +1 -0
  146. package/dist/src/commands/review-preparation.d.ts +51 -0
  147. package/dist/src/commands/review-preparation.js +400 -0
  148. package/dist/src/commands/review-preparation.js.map +1 -0
  149. package/dist/src/commands/runtime.d.ts +6 -6
  150. package/dist/src/commands/runtime.js +44 -24
  151. package/dist/src/commands/runtime.js.map +1 -1
  152. package/dist/src/commands/skill-eval.d.ts +41 -0
  153. package/dist/src/commands/skill-eval.js +407 -0
  154. package/dist/src/commands/skill-eval.js.map +1 -0
  155. package/dist/src/commands/status-v6.d.ts +319 -0
  156. package/dist/src/commands/status-v6.js +2979 -0
  157. package/dist/src/commands/status-v6.js.map +1 -0
  158. package/dist/src/commands/targets-command.d.ts +38 -0
  159. package/dist/src/commands/targets-command.js +182 -0
  160. package/dist/src/commands/targets-command.js.map +1 -0
  161. package/dist/src/commands/wizard.d.ts +8 -5
  162. package/dist/src/commands/wizard.js +7 -4
  163. package/dist/src/commands/wizard.js.map +1 -1
  164. package/dist/src/commands/write-commands.d.ts +9 -3
  165. package/dist/src/commands/write-commands.js +143 -85
  166. package/dist/src/commands/write-commands.js.map +1 -1
  167. package/dist/src/constants.d.ts +6 -6
  168. package/dist/src/constants.js +6 -6
  169. package/dist/src/constants.js.map +1 -1
  170. package/dist/src/eval/manifest-v1.d.ts +70 -0
  171. package/dist/src/eval/manifest-v1.js +358 -0
  172. package/dist/src/eval/manifest-v1.js.map +1 -0
  173. package/dist/src/generators/local-plugin.d.ts +7 -2
  174. package/dist/src/generators/local-plugin.js +313 -389
  175. package/dist/src/generators/local-plugin.js.map +1 -1
  176. package/dist/src/generators/permissions.d.ts +5 -2
  177. package/dist/src/generators/permissions.js +28 -15
  178. package/dist/src/generators/permissions.js.map +1 -1
  179. package/dist/src/index.d.ts +2 -31
  180. package/dist/src/index.js +1666 -1827
  181. package/dist/src/index.js.map +1 -1
  182. package/dist/src/intent/deployment-preferences.d.ts +63 -0
  183. package/dist/src/intent/deployment-preferences.js +170 -0
  184. package/dist/src/intent/deployment-preferences.js.map +1 -0
  185. package/dist/src/intent/diagnostics.d.ts +11 -0
  186. package/dist/src/intent/diagnostics.js +14 -0
  187. package/dist/src/intent/diagnostics.js.map +1 -0
  188. package/dist/src/intent/intent-codec.d.ts +19 -0
  189. package/dist/src/intent/intent-codec.js +117 -0
  190. package/dist/src/intent/intent-codec.js.map +1 -0
  191. package/dist/src/intent/intent-store.d.ts +43 -0
  192. package/dist/src/intent/intent-store.js +118 -0
  193. package/dist/src/intent/intent-store.js.map +1 -0
  194. package/dist/src/intent/scope-context.d.ts +33 -0
  195. package/dist/src/intent/scope-context.js +149 -0
  196. package/dist/src/intent/scope-context.js.map +1 -0
  197. package/dist/src/intent/work-context.d.ts +13 -0
  198. package/dist/src/intent/work-context.js +22 -0
  199. package/dist/src/intent/work-context.js.map +1 -0
  200. package/dist/src/output/command-receipt.d.ts +47 -46
  201. package/dist/src/output/command-receipt.js +286 -79
  202. package/dist/src/output/command-receipt.js.map +1 -1
  203. package/dist/src/output/model.d.ts +3 -11
  204. package/dist/src/output/native-consent.d.ts +2 -0
  205. package/dist/src/output/native-consent.js +5 -0
  206. package/dist/src/output/native-consent.js.map +1 -0
  207. package/dist/src/output/public-result.d.ts +49 -0
  208. package/dist/src/output/public-result.js +240 -0
  209. package/dist/src/output/public-result.js.map +1 -0
  210. package/dist/src/output/rebuild-progress.js +20 -15
  211. package/dist/src/output/rebuild-progress.js.map +1 -1
  212. package/dist/src/output/receipt-projection.d.ts +7 -0
  213. package/dist/src/output/receipt-projection.js +592 -0
  214. package/dist/src/output/receipt-projection.js.map +1 -0
  215. package/dist/src/platforms/capabilities.d.ts +12 -0
  216. package/dist/src/platforms/capabilities.js +205 -0
  217. package/dist/src/platforms/capabilities.js.map +1 -0
  218. package/dist/src/platforms/contracts.d.ts +358 -0
  219. package/dist/src/platforms/contracts.js +2 -0
  220. package/dist/src/platforms/contracts.js.map +1 -0
  221. package/dist/src/platforms/cursor-workspace-hook.d.ts +28 -0
  222. package/dist/src/platforms/cursor-workspace-hook.js +198 -0
  223. package/dist/src/platforms/cursor-workspace-hook.js.map +1 -0
  224. package/dist/src/platforms/discovery.d.ts +91 -0
  225. package/dist/src/platforms/discovery.js +653 -0
  226. package/dist/src/platforms/discovery.js.map +1 -0
  227. package/dist/src/platforms/gemini-activation.d.ts +36 -0
  228. package/dist/src/platforms/gemini-activation.js +331 -0
  229. package/dist/src/platforms/gemini-activation.js.map +1 -0
  230. package/dist/src/platforms/gemini-consent.d.ts +8 -0
  231. package/dist/src/platforms/gemini-consent.js +81 -0
  232. package/dist/src/platforms/gemini-consent.js.map +1 -0
  233. package/dist/src/platforms/identity.d.ts +4 -0
  234. package/dist/src/platforms/identity.js +22 -0
  235. package/dist/src/platforms/identity.js.map +1 -0
  236. package/dist/src/platforms/inspection-grok.d.ts +4 -0
  237. package/dist/src/platforms/inspection-grok.js +212 -0
  238. package/dist/src/platforms/inspection-grok.js.map +1 -0
  239. package/dist/src/platforms/inspection-native.d.ts +6 -0
  240. package/dist/src/platforms/inspection-native.js +406 -0
  241. package/dist/src/platforms/inspection-native.js.map +1 -0
  242. package/dist/src/platforms/inspection-opencode.d.ts +4 -0
  243. package/dist/src/platforms/inspection-opencode.js +98 -0
  244. package/dist/src/platforms/inspection-opencode.js.map +1 -0
  245. package/dist/src/platforms/inspection-pi.d.ts +3 -0
  246. package/dist/src/platforms/inspection-pi.js +282 -0
  247. package/dist/src/platforms/inspection-pi.js.map +1 -0
  248. package/dist/src/platforms/inspection-query.d.ts +12 -0
  249. package/dist/src/platforms/inspection-query.js +96 -0
  250. package/dist/src/platforms/inspection-query.js.map +1 -0
  251. package/dist/src/platforms/inspection.d.ts +17 -0
  252. package/dist/src/platforms/inspection.js +227 -0
  253. package/dist/src/platforms/inspection.js.map +1 -0
  254. package/dist/src/platforms/layout.d.ts +21 -0
  255. package/dist/src/platforms/layout.js +239 -0
  256. package/dist/src/platforms/layout.js.map +1 -0
  257. package/dist/src/platforms/lifecycle-native-services.d.ts +3 -0
  258. package/dist/src/platforms/lifecycle-native-services.js +147 -0
  259. package/dist/src/platforms/lifecycle-native-services.js.map +1 -0
  260. package/dist/src/platforms/lifecycle-native.d.ts +13 -0
  261. package/dist/src/platforms/lifecycle-native.js +283 -0
  262. package/dist/src/platforms/lifecycle-native.js.map +1 -0
  263. package/dist/src/platforms/lifecycle.d.ts +25 -0
  264. package/dist/src/platforms/lifecycle.js +494 -0
  265. package/dist/src/platforms/lifecycle.js.map +1 -0
  266. package/dist/src/platforms/managed-command-placement.d.ts +8 -0
  267. package/dist/src/platforms/managed-command-placement.js +79 -0
  268. package/dist/src/platforms/managed-command-placement.js.map +1 -0
  269. package/dist/src/platforms/projection-code-extension.d.ts +8 -0
  270. package/dist/src/platforms/projection-code-extension.js +121 -0
  271. package/dist/src/platforms/projection-code-extension.js.map +1 -0
  272. package/dist/src/platforms/projection-command-resources.d.ts +7 -0
  273. package/dist/src/platforms/projection-command-resources.js +74 -0
  274. package/dist/src/platforms/projection-command-resources.js.map +1 -0
  275. package/dist/src/platforms/projection-files.d.ts +27 -0
  276. package/dist/src/platforms/projection-files.js +111 -0
  277. package/dist/src/platforms/projection-files.js.map +1 -0
  278. package/dist/src/platforms/projection-marketplace.d.ts +19 -0
  279. package/dist/src/platforms/projection-marketplace.js +42 -0
  280. package/dist/src/platforms/projection-marketplace.js.map +1 -0
  281. package/dist/src/platforms/projection.d.ts +10 -0
  282. package/dist/src/platforms/projection.js +446 -0
  283. package/dist/src/platforms/projection.js.map +1 -0
  284. package/dist/src/platforms/registry.d.ts +4 -0
  285. package/dist/src/platforms/registry.js +30 -0
  286. package/dist/src/platforms/registry.js.map +1 -0
  287. package/dist/src/platforms/supplement-layout.d.ts +16 -0
  288. package/dist/src/platforms/supplement-layout.js +31 -0
  289. package/dist/src/platforms/supplement-layout.js.map +1 -0
  290. package/dist/src/platforms/supplement-state.d.ts +13 -0
  291. package/dist/src/platforms/supplement-state.js +82 -0
  292. package/dist/src/platforms/supplement-state.js.map +1 -0
  293. package/dist/src/portable/commands.d.ts +58 -11
  294. package/dist/src/portable/commands.js +94 -350
  295. package/dist/src/portable/commands.js.map +1 -1
  296. package/dist/src/portable/historical-materialization.d.ts +22 -0
  297. package/dist/src/portable/historical-materialization.js +124 -0
  298. package/dist/src/portable/historical-materialization.js.map +1 -0
  299. package/dist/src/portable/materializer.d.ts +24 -4
  300. package/dist/src/portable/materializer.js +189 -259
  301. package/dist/src/portable/materializer.js.map +1 -1
  302. package/dist/src/portable/recovery-layout.d.ts +17 -0
  303. package/dist/src/portable/recovery-layout.js +42 -0
  304. package/dist/src/portable/recovery-layout.js.map +1 -0
  305. package/dist/src/portable/recovery.d.ts +153 -0
  306. package/dist/src/portable/recovery.js +367 -0
  307. package/dist/src/portable/recovery.js.map +1 -0
  308. package/dist/src/portable/writer.d.ts +67 -0
  309. package/dist/src/portable/writer.js +321 -0
  310. package/dist/src/portable/writer.js.map +1 -0
  311. package/dist/src/recovery/coordinator.d.ts +141 -0
  312. package/dist/src/recovery/coordinator.js +1254 -0
  313. package/dist/src/recovery/coordinator.js.map +1 -0
  314. package/dist/src/recovery/demand.d.ts +51 -0
  315. package/dist/src/recovery/demand.js +159 -0
  316. package/dist/src/recovery/demand.js.map +1 -0
  317. package/dist/src/recovery/joint-coordinator.d.ts +25 -0
  318. package/dist/src/recovery/joint-coordinator.js +991 -0
  319. package/dist/src/recovery/joint-coordinator.js.map +1 -0
  320. package/dist/src/recovery/joint-demand.d.ts +50 -0
  321. package/dist/src/recovery/joint-demand.js +197 -0
  322. package/dist/src/recovery/joint-demand.js.map +1 -0
  323. package/dist/src/recovery/performance.d.ts +4 -0
  324. package/dist/src/recovery/performance.js +26 -0
  325. package/dist/src/recovery/performance.js.map +1 -0
  326. package/dist/src/recovery/receipt.d.ts +98 -0
  327. package/dist/src/recovery/receipt.js +2 -0
  328. package/dist/src/recovery/receipt.js.map +1 -0
  329. package/dist/src/recovery/retirement.d.ts +47 -0
  330. package/dist/src/recovery/retirement.js +469 -0
  331. package/dist/src/recovery/retirement.js.map +1 -0
  332. package/dist/src/recovery/status.d.ts +126 -0
  333. package/dist/src/recovery/status.js +1073 -0
  334. package/dist/src/recovery/status.js.map +1 -0
  335. package/dist/src/recovery/types.d.ts +85 -0
  336. package/dist/src/recovery/types.js +2 -0
  337. package/dist/src/recovery/types.js.map +1 -0
  338. package/dist/src/review/eval-source-input.d.ts +43 -0
  339. package/dist/src/review/eval-source-input.js +207 -0
  340. package/dist/src/review/eval-source-input.js.map +1 -0
  341. package/dist/src/review/platform-profile.d.ts +3 -0
  342. package/dist/src/review/platform-profile.js +14 -0
  343. package/dist/src/review/platform-profile.js.map +1 -0
  344. package/dist/src/review/review-profile.d.ts +20 -0
  345. package/dist/src/review/review-profile.js +276 -0
  346. package/dist/src/review/review-profile.js.map +1 -0
  347. package/dist/src/review/review-selection.d.ts +20 -0
  348. package/dist/src/review/review-selection.js +495 -0
  349. package/dist/src/review/review-selection.js.map +1 -0
  350. package/dist/src/review/review-types.d.ts +71 -0
  351. package/dist/src/review/review-types.js +16 -0
  352. package/dist/src/review/review-types.js.map +1 -0
  353. package/dist/src/review/skill-materialization.d.ts +62 -0
  354. package/dist/src/review/skill-materialization.js +205 -0
  355. package/dist/src/review/skill-materialization.js.map +1 -0
  356. package/dist/src/review/source-binding.d.ts +201 -0
  357. package/dist/src/review/source-binding.js +773 -0
  358. package/dist/src/review/source-binding.js.map +1 -0
  359. package/dist/src/tui/agent-management.d.ts +23 -0
  360. package/dist/src/tui/agent-management.js +319 -0
  361. package/dist/src/tui/agent-management.js.map +1 -0
  362. package/dist/src/tui/agent-settings.d.ts +47 -0
  363. package/dist/src/tui/agent-settings.js +97 -0
  364. package/dist/src/tui/agent-settings.js.map +1 -0
  365. package/dist/src/tui/catalog-freshness.d.ts +1 -0
  366. package/dist/src/tui/catalog-freshness.js +2 -0
  367. package/dist/src/tui/catalog-freshness.js.map +1 -0
  368. package/dist/src/tui/catalog-generation.d.ts +18 -53
  369. package/dist/src/tui/catalog-generation.js +136 -224
  370. package/dist/src/tui/catalog-generation.js.map +1 -1
  371. package/dist/src/tui/catalog-sources/projection.d.ts +4 -0
  372. package/dist/src/tui/catalog-sources/projection.js +17 -0
  373. package/dist/src/tui/catalog-sources/projection.js.map +1 -0
  374. package/dist/src/tui/catalog-sources/review.d.ts +3 -0
  375. package/dist/src/tui/catalog-sources/review.js +13 -0
  376. package/dist/src/tui/catalog-sources/review.js.map +1 -0
  377. package/dist/src/tui/catalog-sources/screens.d.ts +12 -0
  378. package/dist/src/tui/catalog-sources/screens.js +40 -0
  379. package/dist/src/tui/catalog-sources/screens.js.map +1 -0
  380. package/dist/src/tui/catalog-sources/session.d.ts +32 -0
  381. package/dist/src/tui/catalog-sources/session.js +300 -0
  382. package/dist/src/tui/catalog-sources/session.js.map +1 -0
  383. package/dist/src/tui/catalog-sources/types.d.ts +54 -0
  384. package/dist/src/tui/catalog-sources/types.js +2 -0
  385. package/dist/src/tui/catalog-sources/types.js.map +1 -0
  386. package/dist/src/tui/catalog-store-task.d.ts +16 -0
  387. package/dist/src/tui/catalog-store-task.js +19 -0
  388. package/dist/src/tui/catalog-store-task.js.map +1 -0
  389. package/dist/src/tui/clipboard.d.ts +13 -0
  390. package/dist/src/tui/clipboard.js +95 -0
  391. package/dist/src/tui/clipboard.js.map +1 -0
  392. package/dist/src/tui/components.d.ts +113 -3
  393. package/dist/src/tui/components.js +201 -36
  394. package/dist/src/tui/components.js.map +1 -1
  395. package/dist/src/tui/config-array-draft.d.ts +29 -0
  396. package/dist/src/tui/config-array-draft.js +48 -0
  397. package/dist/src/tui/config-array-draft.js.map +1 -0
  398. package/dist/src/tui/config-leaf-editor.d.ts +43 -0
  399. package/dist/src/tui/config-leaf-editor.js +224 -0
  400. package/dist/src/tui/config-leaf-editor.js.map +1 -0
  401. package/dist/src/tui/config-references.d.ts +38 -0
  402. package/dist/src/tui/config-references.js +82 -0
  403. package/dist/src/tui/config-references.js.map +1 -0
  404. package/dist/src/tui/config-value-presentation.d.ts +20 -0
  405. package/dist/src/tui/config-value-presentation.js +104 -0
  406. package/dist/src/tui/config-value-presentation.js.map +1 -0
  407. package/dist/src/tui/console-app-v4.d.ts +13 -4
  408. package/dist/src/tui/console-app-v4.js +9764 -2210
  409. package/dist/src/tui/console-app-v4.js.map +1 -1
  410. package/dist/src/tui/content-item-card.d.ts +13 -0
  411. package/dist/src/tui/content-item-card.js +51 -0
  412. package/dist/src/tui/content-item-card.js.map +1 -0
  413. package/dist/src/tui/controller-runtime.d.ts +7 -4
  414. package/dist/src/tui/controller-runtime.js +2064 -779
  415. package/dist/src/tui/controller-runtime.js.map +1 -1
  416. package/dist/src/tui/controller.d.ts +669 -106
  417. package/dist/src/tui/controller.js +3617 -971
  418. package/dist/src/tui/controller.js.map +1 -1
  419. package/dist/src/tui/dependency-graph-view.d.ts +39 -0
  420. package/dist/src/tui/dependency-graph-view.js +121 -0
  421. package/dist/src/tui/dependency-graph-view.js.map +1 -0
  422. package/dist/src/tui/dependency-graph.d.ts +81 -0
  423. package/dist/src/tui/dependency-graph.js +452 -0
  424. package/dist/src/tui/dependency-graph.js.map +1 -0
  425. package/dist/src/tui/deployment-view.d.ts +10 -0
  426. package/dist/src/tui/deployment-view.js +108 -0
  427. package/dist/src/tui/deployment-view.js.map +1 -0
  428. package/dist/src/tui/diagnostic-projection.d.ts +23 -0
  429. package/dist/src/tui/diagnostic-projection.js +595 -0
  430. package/dist/src/tui/diagnostic-projection.js.map +1 -0
  431. package/dist/src/tui/diagnostics.d.ts +6 -3
  432. package/dist/src/tui/diagnostics.js +14 -2
  433. package/dist/src/tui/diagnostics.js.map +1 -1
  434. package/dist/src/tui/entity-cards.d.ts +55 -0
  435. package/dist/src/tui/entity-cards.js +298 -0
  436. package/dist/src/tui/entity-cards.js.map +1 -0
  437. package/dist/src/tui/glossary.d.ts +25 -0
  438. package/dist/src/tui/glossary.js +72 -0
  439. package/dist/src/tui/glossary.js.map +1 -0
  440. package/dist/src/tui/index.d.ts +6 -2
  441. package/dist/src/tui/index.js +5 -2
  442. package/dist/src/tui/index.js.map +1 -1
  443. package/dist/src/tui/input-display.d.ts +1 -0
  444. package/dist/src/tui/input-display.js +23 -1
  445. package/dist/src/tui/input-display.js.map +1 -1
  446. package/dist/src/tui/keys.d.ts +44 -0
  447. package/dist/src/tui/keys.js +43 -15
  448. package/dist/src/tui/keys.js.map +1 -1
  449. package/dist/src/tui/lifecycle-action-view.d.ts +6 -0
  450. package/dist/src/tui/lifecycle-action-view.js +36 -0
  451. package/dist/src/tui/lifecycle-action-view.js.map +1 -0
  452. package/dist/src/tui/model.d.ts +243 -45
  453. package/dist/src/tui/model.js +1402 -415
  454. package/dist/src/tui/model.js.map +1 -1
  455. package/dist/src/tui/operation-diagnostic-screens.d.ts +8 -0
  456. package/dist/src/tui/operation-diagnostic-screens.js +72 -0
  457. package/dist/src/tui/operation-diagnostic-screens.js.map +1 -0
  458. package/dist/src/tui/operation-history.d.ts +82 -0
  459. package/dist/src/tui/operation-history.js +136 -0
  460. package/dist/src/tui/operation-history.js.map +1 -0
  461. package/dist/src/tui/operation-review-planner.d.ts +28 -0
  462. package/dist/src/tui/operation-review-planner.js +1396 -0
  463. package/dist/src/tui/operation-review-planner.js.map +1 -0
  464. package/dist/src/tui/plugin-content.d.ts +33 -0
  465. package/dist/src/tui/plugin-content.js +245 -0
  466. package/dist/src/tui/plugin-content.js.map +1 -0
  467. package/dist/src/tui/plugin-detail.d.ts +72 -0
  468. package/dist/src/tui/plugin-detail.js +260 -0
  469. package/dist/src/tui/plugin-detail.js.map +1 -0
  470. package/dist/src/tui/plugin-write-task.d.ts +69 -0
  471. package/dist/src/tui/plugin-write-task.js +286 -0
  472. package/dist/src/tui/plugin-write-task.js.map +1 -0
  473. package/dist/src/tui/prompt.js +4 -15
  474. package/dist/src/tui/prompt.js.map +1 -1
  475. package/dist/src/tui/query-header.d.ts +30 -0
  476. package/dist/src/tui/query-header.js +40 -0
  477. package/dist/src/tui/query-header.js.map +1 -0
  478. package/dist/src/tui/reader.d.ts +38 -0
  479. package/dist/src/tui/reader.js +49 -0
  480. package/dist/src/tui/reader.js.map +1 -0
  481. package/dist/src/tui/router.d.ts +186 -35
  482. package/dist/src/tui/router.js +338 -50
  483. package/dist/src/tui/router.js.map +1 -1
  484. package/dist/src/tui/scoped-flow.d.ts +45 -0
  485. package/dist/src/tui/scoped-flow.js +96 -0
  486. package/dist/src/tui/scoped-flow.js.map +1 -0
  487. package/dist/src/tui/scoped-inventory.d.ts +126 -0
  488. package/dist/src/tui/scoped-inventory.js +258 -0
  489. package/dist/src/tui/scoped-inventory.js.map +1 -0
  490. package/dist/src/tui/screen-registry.d.ts +701 -0
  491. package/dist/src/tui/screen-registry.js +226 -0
  492. package/dist/src/tui/screen-registry.js.map +1 -0
  493. package/dist/src/tui/session-console-app.d.ts +6 -0
  494. package/dist/src/tui/session-console-app.js +13 -0
  495. package/dist/src/tui/session-console-app.js.map +1 -0
  496. package/dist/src/tui/session-host.d.ts +45 -0
  497. package/dist/src/tui/session-host.js +219 -0
  498. package/dist/src/tui/session-host.js.map +1 -0
  499. package/dist/src/tui/source-detail-card.d.ts +29 -0
  500. package/dist/src/tui/source-detail-card.js +45 -0
  501. package/dist/src/tui/source-detail-card.js.map +1 -0
  502. package/dist/src/tui/theme.d.ts +12 -0
  503. package/dist/src/tui/theme.js +12 -0
  504. package/dist/src/tui/theme.js.map +1 -1
  505. package/dist/src/tui/viewport.d.ts +1 -0
  506. package/dist/src/tui/viewport.js +23 -0
  507. package/dist/src/tui/viewport.js.map +1 -1
  508. package/dist/src/tui/wizard.js +37 -13
  509. package/dist/src/tui/wizard.js.map +1 -1
  510. package/dist/src/types.d.ts +220 -118
  511. package/dist/src/types.js +1 -0
  512. package/dist/src/types.js.map +1 -1
  513. package/dist/src/utils/agent-version.d.ts +13 -4
  514. package/dist/src/utils/agent-version.js +27 -4
  515. package/dist/src/utils/agent-version.js.map +1 -1
  516. package/dist/src/utils/artifact-plan.d.ts +33 -7
  517. package/dist/src/utils/artifact-plan.js +115 -430
  518. package/dist/src/utils/artifact-plan.js.map +1 -1
  519. package/dist/src/utils/artifact-renderer.d.ts +114 -83
  520. package/dist/src/utils/artifact-renderer.js +213 -364
  521. package/dist/src/utils/artifact-renderer.js.map +1 -1
  522. package/dist/src/utils/artifact-request.d.ts +44 -0
  523. package/dist/src/utils/artifact-request.js +80 -0
  524. package/dist/src/utils/artifact-request.js.map +1 -0
  525. package/dist/src/utils/artifact-sources.d.ts +6 -2
  526. package/dist/src/utils/artifact-sources.js +17 -0
  527. package/dist/src/utils/artifact-sources.js.map +1 -1
  528. package/dist/src/utils/bundle-layout.js +57 -173
  529. package/dist/src/utils/bundle-layout.js.map +1 -1
  530. package/dist/src/utils/catalog-capability-projection.d.ts +8 -0
  531. package/dist/src/utils/catalog-capability-projection.js +14 -0
  532. package/dist/src/utils/catalog-capability-projection.js.map +1 -0
  533. package/dist/src/utils/catalog-digests.d.ts +2 -2
  534. package/dist/src/utils/catalog-digests.js +7 -18
  535. package/dist/src/utils/catalog-digests.js.map +1 -1
  536. package/dist/src/utils/catalog-generation-control-snapshot.d.ts +11 -0
  537. package/dist/src/utils/catalog-generation-control-snapshot.js +45 -0
  538. package/dist/src/utils/catalog-generation-control-snapshot.js.map +1 -0
  539. package/dist/src/utils/catalog-generation-error.d.ts +5 -1
  540. package/dist/src/utils/catalog-generation-error.js +14 -0
  541. package/dist/src/utils/catalog-generation-error.js.map +1 -1
  542. package/dist/src/utils/catalog-generation-resolver.d.ts +36 -5
  543. package/dist/src/utils/catalog-generation-resolver.js +221 -77
  544. package/dist/src/utils/catalog-generation-resolver.js.map +1 -1
  545. package/dist/src/utils/catalog-generation-service.d.ts +159 -28
  546. package/dist/src/utils/catalog-generation-service.js +1186 -525
  547. package/dist/src/utils/catalog-generation-service.js.map +1 -1
  548. package/dist/src/utils/catalog-generation-state.d.ts +9 -0
  549. package/dist/src/utils/catalog-generation-state.js +97 -106
  550. package/dist/src/utils/catalog-generation-state.js.map +1 -1
  551. package/dist/src/utils/catalog-generation-store.d.ts +38 -24
  552. package/dist/src/utils/catalog-generation-store.js +337 -272
  553. package/dist/src/utils/catalog-generation-store.js.map +1 -1
  554. package/dist/src/utils/catalog-manifest-v7.d.ts +5 -0
  555. package/dist/src/utils/{catalog-manifest-v5.js → catalog-manifest-v7.js} +23 -35
  556. package/dist/src/utils/catalog-manifest-v7.js.map +1 -0
  557. package/dist/src/utils/catalog-operation-context.d.ts +6 -14
  558. package/dist/src/utils/catalog-operation-context.js +69 -169
  559. package/dist/src/utils/catalog-operation-context.js.map +1 -1
  560. package/dist/src/utils/catalog-public-error.js +8 -4
  561. package/dist/src/utils/catalog-public-error.js.map +1 -1
  562. package/dist/src/utils/catalog-runtime-projection.d.ts +7 -3
  563. package/dist/src/utils/catalog-runtime-projection.js +5 -40
  564. package/dist/src/utils/catalog-runtime-projection.js.map +1 -1
  565. package/dist/src/utils/catalog-snapshot.d.ts +2 -2
  566. package/dist/src/utils/catalog-source-impact.d.ts +21 -0
  567. package/dist/src/utils/catalog-source-impact.js +344 -0
  568. package/dist/src/utils/catalog-source-impact.js.map +1 -0
  569. package/dist/src/utils/catalog-source-references.d.ts +23 -2
  570. package/dist/src/utils/catalog-source-references.js +456 -382
  571. package/dist/src/utils/catalog-source-references.js.map +1 -1
  572. package/dist/src/utils/catalog-sources.d.ts +14 -1
  573. package/dist/src/utils/catalog-sources.js +178 -18
  574. package/dist/src/utils/catalog-sources.js.map +1 -1
  575. package/dist/src/utils/codex-config.d.ts +2 -0
  576. package/dist/src/utils/codex-config.js +22 -1
  577. package/dist/src/utils/codex-config.js.map +1 -1
  578. package/dist/src/utils/codex-executable-discovery.d.ts +28 -0
  579. package/dist/src/utils/codex-executable-discovery.js +431 -0
  580. package/dist/src/utils/codex-executable-discovery.js.map +1 -0
  581. package/dist/src/utils/codex-manager.d.ts +47 -18
  582. package/dist/src/utils/codex-manager.js +88 -622
  583. package/dist/src/utils/codex-manager.js.map +1 -1
  584. package/dist/src/utils/codex-marketplace-path.d.ts +5 -0
  585. package/dist/src/utils/codex-marketplace-path.js +45 -0
  586. package/dist/src/utils/codex-marketplace-path.js.map +1 -0
  587. package/dist/src/utils/codex-native-observation.d.ts +49 -0
  588. package/dist/src/utils/codex-native-observation.js +169 -0
  589. package/dist/src/utils/codex-native-observation.js.map +1 -0
  590. package/dist/src/utils/codex-reconciler.d.ts +123 -0
  591. package/dist/src/utils/codex-reconciler.js +322 -0
  592. package/dist/src/utils/codex-reconciler.js.map +1 -0
  593. package/dist/src/utils/codex-shared-native.d.ts +45 -0
  594. package/dist/src/utils/codex-shared-native.js +122 -0
  595. package/dist/src/utils/codex-shared-native.js.map +1 -0
  596. package/dist/src/utils/codex-skill-staging.d.ts +4 -3
  597. package/dist/src/utils/codex-skill-staging.js.map +1 -1
  598. package/dist/src/utils/codex-skills-root.d.ts +4 -0
  599. package/dist/src/utils/codex-skills-root.js +25 -0
  600. package/dist/src/utils/codex-skills-root.js.map +1 -0
  601. package/dist/src/utils/codex-surface-analysis.d.ts +49 -0
  602. package/dist/src/utils/codex-surface-analysis.js +220 -0
  603. package/dist/src/utils/codex-surface-analysis.js.map +1 -0
  604. package/dist/src/utils/component-command-preparation.d.ts +34 -0
  605. package/dist/src/utils/component-command-preparation.js +228 -0
  606. package/dist/src/utils/component-command-preparation.js.map +1 -0
  607. package/dist/src/utils/component-resources.d.ts +51 -0
  608. package/dist/src/utils/component-resources.js +322 -0
  609. package/dist/src/utils/component-resources.js.map +1 -0
  610. package/dist/src/utils/dynamic-skill-tree.d.ts +18 -6
  611. package/dist/src/utils/dynamic-skill-tree.js +32 -9
  612. package/dist/src/utils/dynamic-skill-tree.js.map +1 -1
  613. package/dist/src/utils/git-catalog-provider.d.ts +16 -0
  614. package/dist/src/utils/git-catalog-provider.js +167 -120
  615. package/dist/src/utils/git-catalog-provider.js.map +1 -1
  616. package/dist/src/utils/inventory-recovery-diagnostic.d.ts +4 -0
  617. package/dist/src/utils/inventory-recovery-diagnostic.js +15 -0
  618. package/dist/src/utils/inventory-recovery-diagnostic.js.map +1 -0
  619. package/dist/src/utils/local-marketplace.d.ts +17 -12
  620. package/dist/src/utils/local-marketplace.js +85 -195
  621. package/dist/src/utils/local-marketplace.js.map +1 -1
  622. package/dist/src/utils/managed-command-closure.d.ts +3 -0
  623. package/dist/src/utils/managed-command-closure.js +35 -0
  624. package/dist/src/utils/managed-command-closure.js.map +1 -0
  625. package/dist/src/utils/managed-command-evidence.d.ts +7 -0
  626. package/dist/src/utils/managed-command-evidence.js +10 -0
  627. package/dist/src/utils/managed-command-evidence.js.map +1 -0
  628. package/dist/src/utils/managed-command-materialization.d.ts +124 -0
  629. package/dist/src/utils/managed-command-materialization.js +369 -0
  630. package/dist/src/utils/managed-command-materialization.js.map +1 -0
  631. package/dist/src/utils/managed-command-preparation.d.ts +67 -0
  632. package/dist/src/utils/managed-command-preparation.js +146 -0
  633. package/dist/src/utils/managed-command-preparation.js.map +1 -0
  634. package/dist/src/utils/managed-command-review.d.ts +26 -0
  635. package/dist/src/utils/managed-command-review.js +68 -0
  636. package/dist/src/utils/managed-command-review.js.map +1 -0
  637. package/dist/src/utils/managed-command-runtime.d.ts +33 -0
  638. package/dist/src/utils/managed-command-runtime.js +121 -0
  639. package/dist/src/utils/managed-command-runtime.js.map +1 -0
  640. package/dist/src/utils/managed-command-store.d.ts +143 -0
  641. package/dist/src/utils/managed-command-store.js +665 -0
  642. package/dist/src/utils/managed-command-store.js.map +1 -0
  643. package/dist/src/utils/manifest.d.ts +1 -3
  644. package/dist/src/utils/manifest.js +1 -3
  645. package/dist/src/utils/manifest.js.map +1 -1
  646. package/dist/src/utils/multi-source-catalog.d.ts +1 -10
  647. package/dist/src/utils/multi-source-catalog.js +9 -175
  648. package/dist/src/utils/multi-source-catalog.js.map +1 -1
  649. package/dist/src/utils/native-cli.d.ts +74 -5
  650. package/dist/src/utils/native-cli.js +479 -31
  651. package/dist/src/utils/native-cli.js.map +1 -1
  652. package/dist/src/utils/native-demand.d.ts +29 -0
  653. package/dist/src/utils/native-demand.js +4 -0
  654. package/dist/src/utils/native-demand.js.map +1 -0
  655. package/dist/src/utils/native-tool-context.d.ts +14 -0
  656. package/dist/src/utils/native-tool-context.js +38 -0
  657. package/dist/src/utils/native-tool-context.js.map +1 -0
  658. package/dist/src/utils/native-tool-review.d.ts +18 -0
  659. package/dist/src/utils/native-tool-review.js +116 -0
  660. package/dist/src/utils/native-tool-review.js.map +1 -0
  661. package/dist/src/utils/orphan-marketplace-cleanup.js +0 -1
  662. package/dist/src/utils/orphan-marketplace-cleanup.js.map +1 -1
  663. package/dist/src/utils/ownership.d.ts +103 -21
  664. package/dist/src/utils/ownership.js +232 -210
  665. package/dist/src/utils/ownership.js.map +1 -1
  666. package/dist/src/utils/path-catalog-provider.d.ts +1 -1
  667. package/dist/src/utils/path-catalog-provider.js +47 -62
  668. package/dist/src/utils/path-catalog-provider.js.map +1 -1
  669. package/dist/src/utils/paths.d.ts +1 -2
  670. package/dist/src/utils/paths.js +5 -3
  671. package/dist/src/utils/paths.js.map +1 -1
  672. package/dist/src/utils/platform-empty-state.d.ts +45 -0
  673. package/dist/src/utils/platform-empty-state.js +159 -0
  674. package/dist/src/utils/platform-empty-state.js.map +1 -0
  675. package/dist/src/utils/platform-support.d.ts +1 -1
  676. package/dist/src/utils/platform-support.js +1 -1
  677. package/dist/src/utils/platform-support.js.map +1 -1
  678. package/dist/src/utils/plugin-config-impact.d.ts +64 -0
  679. package/dist/src/utils/plugin-config-impact.js +307 -0
  680. package/dist/src/utils/plugin-config-impact.js.map +1 -0
  681. package/dist/src/utils/plugin-config-references.d.ts +89 -0
  682. package/dist/src/utils/plugin-config-references.js +335 -0
  683. package/dist/src/utils/plugin-config-references.js.map +1 -0
  684. package/dist/src/utils/plugin-config-write.d.ts +109 -27
  685. package/dist/src/utils/plugin-config-write.js +1242 -348
  686. package/dist/src/utils/plugin-config-write.js.map +1 -1
  687. package/dist/src/utils/plugin-config.d.ts +187 -109
  688. package/dist/src/utils/plugin-config.js +916 -1147
  689. package/dist/src/utils/plugin-config.js.map +1 -1
  690. package/dist/src/utils/plugin-dependencies.d.ts +1 -1
  691. package/dist/src/utils/plugin-dependencies.js.map +1 -1
  692. package/dist/src/utils/plugin-scripts.d.ts +78 -127
  693. package/dist/src/utils/plugin-scripts.js +566 -524
  694. package/dist/src/utils/plugin-scripts.js.map +1 -1
  695. package/dist/src/utils/process-lock.js +14 -5
  696. package/dist/src/utils/process-lock.js.map +1 -1
  697. package/dist/src/utils/process-tree.d.ts +2 -2
  698. package/dist/src/utils/process-tree.js +1 -1
  699. package/dist/src/utils/process-tree.js.map +1 -1
  700. package/dist/src/utils/project-boundary.d.ts +11 -13
  701. package/dist/src/utils/project-boundary.js +28 -34
  702. package/dist/src/utils/project-boundary.js.map +1 -1
  703. package/dist/src/utils/rendered-contract.js +18 -1
  704. package/dist/src/utils/rendered-contract.js.map +1 -1
  705. package/dist/src/utils/runtime-config.d.ts +18 -0
  706. package/dist/src/utils/runtime-config.js +64 -0
  707. package/dist/src/utils/runtime-config.js.map +1 -0
  708. package/dist/src/utils/runtime-skill-closure.d.ts +2 -2
  709. package/dist/src/utils/runtime-skill-closure.js +47 -6
  710. package/dist/src/utils/runtime-skill-closure.js.map +1 -1
  711. package/dist/src/utils/safe-fs.d.ts +21 -0
  712. package/dist/src/utils/safe-fs.js +111 -0
  713. package/dist/src/utils/safe-fs.js.map +1 -0
  714. package/dist/src/utils/safe-operation-diagnostic.d.ts +15 -0
  715. package/dist/src/utils/safe-operation-diagnostic.js +33 -0
  716. package/dist/src/utils/safe-operation-diagnostic.js.map +1 -0
  717. package/dist/src/utils/sensitive-content.d.ts +4 -0
  718. package/dist/src/utils/sensitive-content.js +36 -0
  719. package/dist/src/utils/sensitive-content.js.map +1 -0
  720. package/dist/src/utils/state-paths.d.ts +8 -3
  721. package/dist/src/utils/state-paths.js +53 -16
  722. package/dist/src/utils/state-paths.js.map +1 -1
  723. package/dist/src/utils/target-eligibility.d.ts +4 -3
  724. package/dist/src/utils/target-eligibility.js +12 -6
  725. package/dist/src/utils/target-eligibility.js.map +1 -1
  726. package/dist/src/utils/windows-claude-shim.d.ts +7 -0
  727. package/dist/src/utils/windows-claude-shim.js +10 -0
  728. package/dist/src/utils/windows-claude-shim.js.map +1 -0
  729. package/dist/src/utils/windows-npm-shim.d.ts +16 -0
  730. package/dist/src/utils/windows-npm-shim.js +155 -0
  731. package/dist/src/utils/windows-npm-shim.js.map +1 -0
  732. package/dist/vitest.config.js +105 -9
  733. package/dist/vitest.config.js.map +1 -1
  734. package/package.json +30 -21
  735. package/dist/scripts/aw-skill-eval-engine.d.ts +0 -13
  736. package/dist/scripts/aw-skill-eval-engine.js +0 -31
  737. package/dist/scripts/aw-skill-eval-engine.js.map +0 -1
  738. package/dist/scripts/codex-eval-app-server.d.ts +0 -91
  739. package/dist/scripts/codex-eval-app-server.js +0 -1334
  740. package/dist/scripts/codex-eval-app-server.js.map +0 -1
  741. package/dist/scripts/codex-eval-isolation.d.ts +0 -61
  742. package/dist/scripts/codex-eval-isolation.js +0 -318
  743. package/dist/scripts/codex-eval-isolation.js.map +0 -1
  744. package/dist/scripts/codex-eval-process-management.d.ts +0 -8
  745. package/dist/scripts/codex-eval-process-management.js +0 -69
  746. package/dist/scripts/codex-eval-process-management.js.map +0 -1
  747. package/dist/scripts/codex-eval-process-tree.d.ts +0 -38
  748. package/dist/scripts/codex-eval-process-tree.js +0 -803
  749. package/dist/scripts/codex-eval-process-tree.js.map +0 -1
  750. package/dist/scripts/codex-eval-runtime-config.d.ts +0 -62
  751. package/dist/scripts/codex-eval-runtime-config.js +0 -843
  752. package/dist/scripts/codex-eval-runtime-config.js.map +0 -1
  753. package/dist/scripts/codex-trigger-eval.d.ts +0 -84
  754. package/dist/scripts/codex-trigger-eval.js +0 -968
  755. package/dist/scripts/codex-trigger-eval.js.map +0 -1
  756. package/dist/scripts/eval-plugin-skills-audited.d.ts +0 -6
  757. package/dist/scripts/eval-plugin-skills-audited.js +0 -261
  758. package/dist/scripts/eval-plugin-skills-audited.js.map +0 -1
  759. package/dist/scripts/eval-plugin-skills.d.ts +0 -45
  760. package/dist/scripts/eval-plugin-skills.js +0 -1589
  761. package/dist/scripts/eval-plugin-skills.js.map +0 -1
  762. package/dist/scripts/eval-run-layout.d.ts +0 -17
  763. package/dist/scripts/eval-run-layout.js +0 -26
  764. package/dist/scripts/eval-run-layout.js.map +0 -1
  765. package/dist/scripts/plugin-eval-contract.d.ts +0 -189
  766. package/dist/scripts/plugin-eval-contract.js +0 -745
  767. package/dist/scripts/plugin-eval-contract.js.map +0 -1
  768. package/dist/scripts/plugin-eval-materializer.d.ts +0 -13
  769. package/dist/scripts/plugin-eval-materializer.js +0 -421
  770. package/dist/scripts/plugin-eval-materializer.js.map +0 -1
  771. package/dist/scripts/skill-reporting.d.ts +0 -212
  772. package/dist/scripts/skill-reporting.js +0 -922
  773. package/dist/scripts/skill-reporting.js.map +0 -1
  774. package/dist/src/commands/catalog-context.d.ts +0 -52
  775. package/dist/src/commands/catalog-context.js +0 -156
  776. package/dist/src/commands/catalog-context.js.map +0 -1
  777. package/dist/src/commands/review-publication.d.ts +0 -99
  778. package/dist/src/commands/review-publication.js +0 -904
  779. package/dist/src/commands/review-publication.js.map +0 -1
  780. package/dist/src/commands/status-v5.d.ts +0 -169
  781. package/dist/src/commands/status-v5.js +0 -1135
  782. package/dist/src/commands/status-v5.js.map +0 -1
  783. package/dist/src/portable/skills-cli.d.ts +0 -43
  784. package/dist/src/portable/skills-cli.js +0 -148
  785. package/dist/src/portable/skills-cli.js.map +0 -1
  786. package/dist/src/utils/catalog-manifest-v5.d.ts +0 -5
  787. package/dist/src/utils/catalog-manifest-v5.js.map +0 -1
  788. package/dist/src/utils/catalog-source-cache.d.ts +0 -62
  789. package/dist/src/utils/catalog-source-cache.js +0 -321
  790. package/dist/src/utils/catalog-source-cache.js.map +0 -1
  791. package/dist/src/utils/codex-project-surface.d.ts +0 -3
  792. package/dist/src/utils/codex-project-surface.js +0 -49
  793. package/dist/src/utils/codex-project-surface.js.map +0 -1
  794. package/dist/src/utils/lifecycle-active-store.d.ts +0 -147
  795. package/dist/src/utils/lifecycle-active-store.js +0 -1064
  796. package/dist/src/utils/lifecycle-active-store.js.map +0 -1
  797. package/dist/src/utils/plugin-release.d.ts +0 -2
  798. package/dist/src/utils/plugin-release.js +0 -2
  799. package/dist/src/utils/plugin-release.js.map +0 -1
  800. package/dist/src/utils/slash-commands.d.ts +0 -1
  801. package/dist/src/utils/slash-commands.js +0 -2
  802. package/dist/src/utils/slash-commands.js.map +0 -1
@@ -6,7 +6,8 @@ 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 { getPluginAuthoringAcceptedValues as getCorePluginAuthoringAcceptedValues, getSkillFrontmatterCapabilityRegistry, } 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
+ import { readCatalogWorkspace } from '@lesliechan721/aw-plugin-core';
10
11
  import { checkPluginVersions } from './lib/plugin-version-check.mjs';
11
12
  import { scanJavaScriptImportSpecifiers } from './lib/javascript-import-scanner.mjs';
12
13
  import { assertAuthoringPluginPathFence, assertCanonicalAuthoringPluginRoot, } from './lib/plugin-root.mjs';
@@ -18,7 +19,6 @@ const CLI_PACKAGE_ROOT = path.basename(authoringRuntimeRoot) === 'dist'
18
19
  : authoringRuntimeRoot;
19
20
  const errors = [];
20
21
  const warnings = [];
21
- const SOURCE_PLUGIN_MANIFEST_CONTRACT_VERSION = 8;
22
22
  let capabilityDiagnostic = null;
23
23
  const MAX_SKILL_NAME_LEN = 64;
24
24
  const MAX_SKILL_DESCRIPTION_LEN = 1024;
@@ -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',
@@ -51,121 +44,17 @@ const CODEX_POLICY_PRODUCTS = new Set([
51
44
  'codex',
52
45
  'CODEX',
53
46
  ]);
54
- const MANIFEST_POLICY_PRODUCTS = new Set(getPluginAuthoringAcceptedValues('manifest', 'marketplace.policy.products'));
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
- const SCRIPT_AUTO_EXTENSIONS = new Set(['.js', '.mjs', '.cjs', '.sh', '.ps1', '.cmd', '.bat']);
129
- const SCRIPT_RUNNERS = new Set(['node', 'sh', 'bash', 'pwsh', 'powershell', 'cmd', 'auto']);
130
- const SCRIPT_OS_SELECTORS = new Set(['default', 'unix', 'windows', 'linux', 'darwin', 'win32']);
131
- const SCRIPT_LIFECYCLE_EVENTS = new Set(['install', 'upgrade', 'uninstall']);
132
52
  const SCRIPT_TIMEOUT_MIN_MS = 1000;
133
- const SCRIPT_TIMEOUT_MAX_MS = 300000;
134
- const CONFIG_FIELD_TYPES = new Set(getPluginAuthoringAcceptedValues('config', 'config.schema.<key>.type'));
135
- const ARTIFACT_TARGETS = new Set(getPluginAuthoringAcceptedValues('artifacts', 'artifacts.targets[].target'));
136
- const ARTIFACT_STATES = new Set(getPluginAuthoringAcceptedValues('artifacts', 'artifacts.targets[].states'));
137
- const ARTIFACT_SCOPES = new Set(['user', 'project']);
138
- const ARTIFACT_KINDS = new Set(['instruction', 'codexRole', 'skill']);
139
- const ARTIFACT_PROJECT_MANAGED_KINDS = new Set(['instruction', 'agent', 'skill']);
140
- const ARTIFACT_KIND_BY_TARGET = {
141
- 'codex.developerInstructionsBlock': 'instruction',
142
- 'codex.agentRole': 'codexRole',
143
- 'codex.skill': 'skill',
144
- 'claude.skill': 'skill',
145
- 'agent-skills.skill': 'skill',
146
- };
147
- const ARTIFACT_PROJECT_MANAGED_KIND_BY_TARGET = {
148
- 'codex.developerInstructionsBlock': 'instruction',
149
- 'codex.agentRole': 'agent',
150
- 'codex.skill': 'skill',
151
- };
53
+ const SCRIPT_TIMEOUT_MAX_MS = 1800000;
152
54
  const PLUGIN_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
153
- const PLUGIN_EVAL_SCHEMA_VERSION = 2;
154
- const PLUGIN_EVAL_CASE_SCHEMA_VERSION = 1;
155
- const PLUGIN_EVAL_SCOPES = new Set(['user', 'project']);
156
- const PLUGIN_EVAL_SPLITS = new Set(['train', 'validation', 'sanity', 'all']);
157
- const PLUGIN_EVAL_TRIGGER_CASE_SPLITS = new Set(['train', 'validation', 'sanity']);
158
- const PLUGIN_EVAL_COMMAND_SUPPORTS = new Set([
159
- 'split',
160
- 'runs',
161
- 'case',
162
- 'model',
163
- 'codexBin',
164
- 'timeout',
165
- 'allowEnvironmentSkips',
166
- ]);
167
55
  let yamlParser = null;
168
56
  let pluginVersionCheckResult = null;
57
+ let skillEvalManifestTools = null;
169
58
  function error(msg) {
170
59
  errors.push(msg);
171
60
  }
@@ -242,56 +131,12 @@ function templateIncludesPath(manifest, relativePath) {
242
131
  return false;
243
132
  return include.some((pattern) => matchesGlob(normalized, pattern));
244
133
  }
245
- function resolveTemplateValue(vars, platform) {
246
- const resolved = {};
247
- for (const [key, entry] of Object.entries(vars)) {
248
- if (entry && typeof entry === 'object' && !Array.isArray(entry)) {
249
- resolved[key] = entry[platform];
250
- }
251
- }
252
- return resolved;
253
- }
254
- function replaceConditionalBlocks(input, resolvedVars, tagName) {
255
- const pattern = new RegExp(`{{#${tagName}\\s+([a-zA-Z0-9_]+)}}([\\s\\S]*?){{\\/${tagName}}}`, 'g');
256
- return input.replace(pattern, (_match, rawKey, blockContent) => {
257
- const truthy = resolvedVars[rawKey] === true;
258
- if (tagName === 'if') {
259
- return truthy ? blockContent : '';
260
- }
261
- return truthy ? '' : blockContent;
262
- });
263
- }
264
- function renderTemplate(content, vars, platform) {
265
- const resolvedVars = resolveTemplateValue(vars, platform);
266
- const withConditionals = replaceConditionalBlocks(replaceConditionalBlocks(content, resolvedVars, 'if'), resolvedVars, 'unless');
267
- return withConditionals.replace(/{{([a-zA-Z0-9_]+)}}/g, (_match, rawKey) => {
268
- const value = resolvedVars[rawKey];
269
- if (value === undefined)
270
- return '';
271
- return String(value);
272
- });
273
- }
274
134
  function renderTemplateForPlatform(manifest, relativePath, content, platform) {
275
135
  if (!templateIncludesPath(manifest, relativePath))
276
136
  return content;
277
137
  const vars = manifest.buildConfig?.templates?.vars ?? {};
278
138
  return renderTemplate(content, vars, platform);
279
139
  }
280
- function renderedContentVariants(manifest, relativePath, content, platforms) {
281
- if (!templateIncludesPath(manifest, relativePath)) {
282
- return [{ content, platform: null }];
283
- }
284
- const seen = new Set();
285
- const variants = [];
286
- for (const platform of platforms) {
287
- const rendered = renderTemplateForPlatform(manifest, relativePath, content, platform);
288
- if (seen.has(rendered))
289
- continue;
290
- seen.add(rendered);
291
- variants.push({ content: rendered, platform });
292
- }
293
- return variants;
294
- }
295
140
  function formatYamlError(parseError, lineCounter, sourceName) {
296
141
  let location = '';
297
142
  if (Array.isArray(parseError.pos) && Number.isInteger(parseError.pos[0])) {
@@ -333,28 +178,39 @@ async function tryLoadCliManifestTools() {
333
178
  const manifestModulePath = path.join(CLI_PACKAGE_ROOT, 'dist', 'src', 'utils', 'manifest.js');
334
179
  const runtimeProjectionModulePath = path.join(CLI_PACKAGE_ROOT, 'dist', 'src', 'utils', 'catalog-runtime-projection.js');
335
180
  const capabilityModulePath = path.join(CLI_PACKAGE_ROOT, 'dist', 'src', 'commands', 'aw-capabilities.js');
181
+ const materializationPath = path.join(CLI_PACKAGE_ROOT, 'dist', 'src', 'review', 'skill-materialization.js');
182
+ const commandMaterializationPath = path.join(CLI_PACKAGE_ROOT, 'dist', 'src', 'utils', 'managed-command-materialization.js');
336
183
  if (!fs.existsSync(manifestModulePath)
337
184
  || !fs.existsSync(runtimeProjectionModulePath)
338
185
  || !fs.existsSync(capabilityModulePath))
339
186
  return null;
340
187
  try {
341
- const [manifestModule, runtimeProjectionModule, capabilityModule] = await Promise.all([
188
+ const [manifestModule, runtimeProjectionModule, capabilityModule, materializationModule, commandModule] = await Promise.all([
342
189
  import(pathToFileURL(manifestModulePath).href),
343
190
  import(pathToFileURL(runtimeProjectionModulePath).href),
344
191
  import(pathToFileURL(capabilityModulePath).href),
192
+ import(pathToFileURL(materializationPath).href),
193
+ import(pathToFileURL(commandMaterializationPath).href),
345
194
  ]);
346
195
  if (manifestModule.SOURCE_PLUGIN_MANIFEST_CONTRACT_VERSION
347
- !== SOURCE_PLUGIN_MANIFEST_CONTRACT_VERSION) {
196
+ !== SOURCE_PLUGIN_MANIFEST_CONTRACT_VERSION
197
+ || typeof materializationModule.materializeProfilePluginComponents !== 'function') {
348
198
  return null;
349
199
  }
350
200
  return {
351
201
  assertPluginInputTree: manifestModule.assertPluginInputTree ?? null,
352
202
  validateSourcePluginManifest: manifestModule.validateSourcePluginManifest ?? null,
203
+ reservedImports: manifestModule.CLI_RESERVED_IMPORTS,
353
204
  readPluginManifest: manifestModule.readPluginManifest ?? null,
354
205
  discoverPlugins: manifestModule.discoverPlugins ?? null,
355
206
  resolvePluginRequirements: manifestModule.resolvePluginRequirements ?? null,
356
207
  implementedCapabilities: capabilityModule.IMPLEMENTED_AW_CAPABILITIES ?? null,
357
208
  createRuntimeResolver: runtimeProjectionModule.createCatalogRuntimeImportResolver ?? null,
209
+ materializeProfilePluginComponents: materializationModule.materializeProfilePluginComponents,
210
+ createIsolatedSkillEnv: materializationModule.createIsolatedSkillEnv,
211
+ prepareManagedCommandPackage: commandModule.prepareManagedCommandPackage,
212
+ managedCommandProducerIdentity: commandModule.managedCommandProducerIdentity,
213
+ validateRuntimeSkillClosure: (await import(pathToFileURL(path.join(CLI_PACKAGE_ROOT, 'dist', 'src', 'utils', 'runtime-skill-closure.js')).href)).validateRuntimeSkillClosure,
358
214
  };
359
215
  }
360
216
  catch {
@@ -497,166 +353,11 @@ function validateStrictSemVerString(value, fieldName) {
497
353
  }
498
354
  return value;
499
355
  }
500
- function validateManifestLightweight(manifest) {
501
- const input = expectRecord(manifest, 'plugin manifest');
502
- if (!input)
503
- return;
504
- if (Object.prototype.hasOwnProperty.call(input, 'commands')) {
505
- error('top-level "commands" has been removed; use "slashCommands" instead');
506
- }
507
- validateAllowedKeys(input, 'plugin manifest', [
508
- 'schemaVersion',
509
- 'name',
510
- 'version',
511
- 'description',
512
- 'dependencies',
513
- 'requires',
514
- 'skills',
515
- 'slashCommands',
516
- 'mcpServers',
517
- 'apps',
518
- 'distributions',
519
- 'marketplace',
520
- 'interface',
521
- 'extensions',
522
- 'buildConfig',
523
- 'scripts',
524
- 'config',
525
- 'artifacts',
526
- ]);
527
- if (manifest.dependencies !== undefined) {
528
- if (!Array.isArray(manifest.dependencies)) {
529
- error('dependencies must be an array');
530
- }
531
- else if (manifest.dependencies.length > 64) {
532
- error('dependencies must contain at most 64 direct plugin dependencies');
533
- }
534
- else {
535
- const seen = new Set();
536
- for (const [index, dependency] of manifest.dependencies.entries()) {
537
- if (typeof dependency !== 'string' || !PLUGIN_NAME_PATTERN.test(dependency)) {
538
- error(`dependencies[${index}] must be an ASCII lowercase hyphen-case plugin name`);
539
- continue;
540
- }
541
- if (dependency === manifest.name) {
542
- error(`plugin "${manifest.name}" cannot depend on itself`);
543
- }
544
- if (seen.has(dependency)) {
545
- error(`dependencies contains duplicate plugin "${dependency}"`);
546
- }
547
- seen.add(dependency);
548
- }
549
- }
550
- }
551
- for (const field of ['name', 'version', 'description', 'marketplace']) {
552
- if (!manifest[field]) {
553
- error(`Missing required field: ${field}`);
554
- }
555
- }
556
- if (manifest.name && !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(manifest.name)) {
557
- error(`manifest name "${manifest.name}" is not lowercase-hyphen-case`);
558
- }
559
- if (manifest.version) {
560
- const pluginVersion = parseStrictSemVer(manifest.version);
561
- if (!pluginVersion) {
562
- error(`manifest.version must be a strict SemVer 2.0.0 string, got "${manifest.version}"`);
563
- }
564
- else if (pluginVersion.prerelease.length > 0 || pluginVersion.build.length > 0) {
565
- error('manifest.version must be a stable SemVer without prerelease or build metadata');
566
- }
567
- }
568
- if (manifest.marketplace) {
569
- const mp = manifest.marketplace;
570
- if (!mp.category)
571
- error('marketplace.category is required');
572
- if (typeof mp.strict !== 'boolean')
573
- error('marketplace.strict must be a boolean');
574
- if (!mp.policy || !mp.policy.installation)
575
- error('marketplace.policy.installation is required');
576
- else if (!MARKETPLACE_INSTALLATION_POLICIES.has(mp.policy.installation))
577
- error(`marketplace.policy.installation must be one of ${[...MARKETPLACE_INSTALLATION_POLICIES].map((value) => JSON.stringify(value)).join(', ')}`);
578
- if (!mp.policy || !mp.policy.authentication)
579
- error('marketplace.policy.authentication is required');
580
- else if (!MARKETPLACE_AUTHENTICATION_POLICIES.has(mp.policy.authentication))
581
- error('marketplace.policy.authentication must be "ON_INSTALL" or "ON_USE"');
582
- validateManifestPolicyProducts(mp.policy?.products);
583
- }
584
- for (const field of ['skills', 'slashCommands', 'mcpServers', 'apps']) {
585
- if (manifest[field] && !manifest[field].startsWith('./')) {
586
- error(`${field} path must start with "./", got "${manifest[field]}"`);
587
- }
588
- }
589
- const claudeCommands = manifest.buildConfig?.manifestOverrides?.claude?.commands;
590
- if (claudeCommands !== undefined) {
591
- error('buildConfig.manifestOverrides.claude.commands has been removed; use "slashCommands" instead');
592
- }
593
- for (const platform of ['claude', 'codex']) {
594
- const rules = manifest.buildConfig?.fileRules?.[platform];
595
- if (!rules)
596
- continue;
597
- for (const pattern of [...(rules.include ?? []), ...(rules.exclude ?? [])]) {
598
- const normalized = String(pattern).replace(/\\/g, '/').replace(/^\.\//, '');
599
- if (normalized === 'commands' || normalized.startsWith('commands/')) {
600
- error(`buildConfig.fileRules.${platform} no longer accepts legacy "commands/**" source rules; use "slashCommands" instead`);
601
- }
602
- }
603
- }
604
- validateExtensionsLightweight(manifest.extensions);
605
- validatePlatformFieldSupport(manifest);
606
- }
607
- function validatePortableNativeArtifactCapabilityLightweight(manifest) {
608
- if (manifest.distributions?.agentSkills === undefined)
609
- return;
610
- const hasOtherNativeDeclaration = Boolean(manifest.skills
611
- || manifest.slashCommands
612
- || manifest.mcpServers
613
- || manifest.apps
614
- || (manifest.extensions?.instructions?.length ?? 0) > 0
615
- || (manifest.extensions?.permissions?.length ?? 0) > 0
616
- || (manifest.extensions?.hooks?.length ?? 0) > 0
617
- || (manifest.extensions?.nativeHooks?.claude?.length ?? 0) > 0
618
- || (manifest.extensions?.nativeHooks?.codex?.length ?? 0) > 0
619
- || (manifest.extensions?.agents?.length ?? 0) > 0);
620
- const hasPresentNativeArtifact = (manifest.artifacts?.targets ?? []).some((target) => (target?.platform === 'claude' || target?.platform === 'codex')
621
- && Array.isArray(target.states)
622
- && target.states.includes('present'));
623
- if (!hasOtherNativeDeclaration && !hasPresentNativeArtifact) {
624
- const message = 'Invalid plugin manifest: portable-only plugins are not supported. Declare at least one non-empty native capability.';
625
- if (!errors.includes(message))
626
- error(message);
627
- }
628
- }
629
- function normalizeManifestProductToken(value) {
630
- return String(value).trim().toUpperCase().replace(/[\s-]+/g, '_');
631
- }
632
- function resolveSupportedPlatforms(manifest) {
633
- const products = manifest.marketplace?.policy?.products;
634
- if (!Array.isArray(products) || products.length === 0) {
635
- return new Set(['claude', 'codex']);
636
- }
637
- const supported = new Set();
638
- for (const product of products) {
639
- const normalized = normalizeManifestProductToken(product);
640
- if (normalized === 'CLAUDE')
641
- supported.add('claude');
642
- if (normalized === 'CODEX')
643
- supported.add('codex');
644
- }
645
- return supported;
646
- }
647
356
  function supportsManifestPlatform(manifest, platform) {
648
357
  return resolveSupportedPlatforms(manifest).has(platform);
649
358
  }
650
- function formatManifestProductsForError(manifest) {
651
- const products = manifest.marketplace?.policy?.products;
652
- if (!Array.isArray(products) || products.length === 0) {
653
- return 'marketplace.policy.products=[]';
654
- }
655
- const normalized = [...new Set(products.map(normalizeManifestProductToken))];
656
- return `marketplace.policy.products=[${normalized.join(', ')}]`;
657
- }
658
- function platformProductName(platform) {
659
- return platform === 'claude' ? 'CLAUDE' : 'CODEX';
359
+ function formatManifestPlatformsForError(manifest) {
360
+ return `platforms=[${[...resolveSupportedPlatforms(manifest)].join(', ')}]`;
660
361
  }
661
362
  function pluginNameForError(manifest) {
662
363
  return typeof manifest.name === 'string' && manifest.name.trim()
@@ -666,1080 +367,118 @@ function pluginNameForError(manifest) {
666
367
  function assertPlatformFieldSupported(manifest, fieldPath, requiredPlatform) {
667
368
  if (supportsManifestPlatform(manifest, requiredPlatform))
668
369
  return;
669
- error(`Invalid plugin "${pluginNameForError(manifest)}": ${fieldPath} requires ${platformProductName(requiredPlatform)} support, but ${formatManifestProductsForError(manifest)}.`);
370
+ error(`Invalid plugin "${pluginNameForError(manifest)}": ${fieldPath} requires ${requiredPlatform} support, but ${formatManifestPlatformsForError(manifest)}.`);
670
371
  }
671
372
  function hasNonEmptyOverride(value) {
672
373
  return isRecord(value) && Object.keys(value).length > 0;
673
374
  }
674
- function validateManifestPolicyProducts(products) {
675
- if (products === undefined)
676
- return;
677
- if (!Array.isArray(products)) {
678
- error('marketplace.policy.products must be an array');
679
- return;
680
- }
681
- for (const [index, product] of products.entries()) {
682
- const fieldName = `marketplace.policy.products[${index}]`;
683
- if (typeof product !== 'string' || product.trim() === '') {
684
- error(`${fieldName} must be a non-empty string`);
685
- continue;
686
- }
687
- const normalized = normalizeManifestProductToken(product);
688
- if (!MANIFEST_POLICY_PRODUCTS.has(normalized)) {
689
- error(`${fieldName} must be one of "CODEX" or "CLAUDE"`);
690
- }
691
- }
692
- }
693
375
  function validatePlatformFieldSupport(manifest) {
694
- if (manifest.buildConfig?.fileRules?.claude !== undefined) {
695
- assertPlatformFieldSupported(manifest, 'buildConfig.fileRules.claude', 'claude');
696
- }
697
- if (manifest.buildConfig?.fileRules?.codex !== undefined) {
698
- assertPlatformFieldSupported(manifest, 'buildConfig.fileRules.codex', 'codex');
699
- }
700
- if (manifest.buildConfig?.manifestOverrides?.claude !== undefined) {
701
- assertPlatformFieldSupported(manifest, 'buildConfig.manifestOverrides.claude', 'claude');
702
- }
703
- if (manifest.buildConfig?.manifestOverrides?.codex !== undefined) {
704
- assertPlatformFieldSupported(manifest, 'buildConfig.manifestOverrides.codex', 'codex');
705
- }
706
- if (manifest.apps) {
707
- assertPlatformFieldSupported(manifest, 'apps', 'codex');
708
- }
709
- if (Array.isArray(manifest.extensions?.nativeHooks?.claude) && manifest.extensions.nativeHooks.claude.length > 0) {
710
- assertPlatformFieldSupported(manifest, 'extensions.nativeHooks.claude', 'claude');
711
- }
712
- if (Array.isArray(manifest.extensions?.nativeHooks?.codex) && manifest.extensions.nativeHooks.codex.length > 0) {
713
- assertPlatformFieldSupported(manifest, 'extensions.nativeHooks.codex', 'codex');
714
- }
715
- for (const [fieldName, entries] of [
716
- ['extensions.instructions', manifest.extensions?.instructions],
717
- ['extensions.permissions', manifest.extensions?.permissions],
718
- ['extensions.hooks', manifest.extensions?.hooks],
719
- ['extensions.agents', manifest.extensions?.agents],
720
- ]) {
721
- if (!Array.isArray(entries))
722
- continue;
723
- entries.forEach((entry, index) => {
724
- if (!isRecord(entry.agentOverrides))
725
- return;
726
- for (const platform of ['claude', 'codex']) {
727
- if (hasNonEmptyOverride(entry.agentOverrides[platform])) {
728
- assertPlatformFieldSupported(manifest, `${fieldName}[${index}].agentOverrides.${platform}`, platform);
729
- }
730
- }
731
- });
732
- }
733
- if (!Array.isArray(manifest.artifacts?.targets))
734
- return;
735
- manifest.artifacts.targets.forEach((target, index) => {
736
- if (target?.platform === 'claude' || target?.platform === 'codex') {
737
- assertPlatformFieldSupported(manifest, `artifacts.targets[${index}].platform`, target.platform);
738
- }
739
- });
740
- }
741
- function isTemplateAsset(manifest, relativePath) {
742
- return templateIncludesPath(manifest, relativePath);
743
- }
744
- function isRecord(value) {
745
- return value !== null && typeof value === 'object' && !Array.isArray(value);
746
- }
747
- function validateAllowedKeys(record, fieldName, allowedKeys) {
748
- for (const key of Object.keys(record)) {
749
- if (!allowedKeys.includes(key)) {
750
- error(`${fieldName} has unknown field "${key}"`);
751
- }
752
- }
753
- }
754
- function validateManifestString(value, fieldName) {
755
- if (typeof value !== 'string' || value.trim() === '') {
756
- error(`${fieldName} must be a non-empty string`);
757
- return null;
758
- }
759
- return value;
760
- }
761
- function validatePublicHookEvent(value, fieldName) {
762
- const event = validateManifestString(value, fieldName);
763
- if (!event)
764
- return null;
765
- if (event === 'session_stop') {
766
- error(`${fieldName}: public event "session_stop" has been removed; use extensions.nativeHooks.claude[].event = "Stop" or "SessionEnd", or extensions.nativeHooks.codex[].event = "Stop"`);
767
- return null;
768
- }
769
- if (!PUBLIC_HOOK_EVENTS.has(event)) {
770
- error(`${fieldName}: unsupported public hook event "${event}"`);
771
- return null;
772
- }
773
- return event;
774
- }
775
- function normalizePublicSessionStartMatcher(matcher, fieldName) {
776
- if (matcher === undefined)
777
- return PUBLIC_SESSION_START_DEFAULT_MATCHER;
778
- if (typeof matcher !== 'string' || matcher.trim() === '') {
779
- error(`${fieldName} must be a non-empty string`);
780
- return null;
781
- }
782
- const selected = new Set();
783
- for (const part of matcher.split('|')) {
784
- if (!PUBLIC_SESSION_START_SOURCES.has(part)) {
785
- error(`${fieldName}: public session_start only allows startup, resume, clear, or their "|" union`);
786
- return null;
787
- }
788
- selected.add(part);
789
- }
790
- return ['startup', 'resume', 'clear'].filter((part) => selected.has(part)).join('|');
791
- }
792
- function validatePublicHookMatcher(event, matcher, fieldName) {
793
- if (matcher === undefined)
794
- return event === 'session_start' ? PUBLIC_SESSION_START_DEFAULT_MATCHER : undefined;
795
- if (typeof matcher !== 'string' || matcher.trim() === '') {
796
- error(`${fieldName} must be a non-empty string`);
797
- return null;
798
- }
799
- if (event === 'session_start') {
800
- return normalizePublicSessionStartMatcher(matcher, fieldName);
801
- }
802
- return matcher;
803
- }
804
- function validateNativeHookEvent(value, platform, fieldName) {
805
- const event = validateManifestString(value, fieldName);
806
- if (!event)
807
- return null;
808
- if (!NATIVE_HOOK_EVENTS[platform].has(event)) {
809
- error(`${fieldName}: unsupported ${platform} hook event "${event}"`);
810
- return null;
811
- }
812
- return event;
813
- }
814
- function validateNativeHookMatcher(event, platform, matcher, fieldName) {
815
- if (matcher === undefined)
816
- return undefined;
817
- if (typeof matcher !== 'string' || matcher.trim() === '') {
818
- error(`${fieldName} must be a non-empty string`);
819
- return null;
820
- }
821
- if (MATCHERLESS_NATIVE_HOOK_EVENTS[platform].has(event)) {
822
- error(`${fieldName}: ${platform} event "${event}" does not allow matcher`);
823
- return null;
824
- }
825
- return matcher;
826
- }
827
- function validateHookAgentOverrides(value, baseHook, fieldName, duplicateCollector) {
828
- if (value === undefined) {
829
- for (const platform of ['claude', 'codex']) {
830
- duplicateCollector(platform, baseHook);
831
- }
832
- return;
833
- }
834
- const overrides = expectRecord(value, fieldName);
835
- if (!overrides)
836
- return;
837
- validateAllowedKeys(overrides, fieldName, ['claude', 'codex']);
838
- for (const platform of ['claude', 'codex']) {
839
- const override = overrides[platform];
840
- if (override === null)
841
- continue;
842
- if (override === undefined) {
843
- duplicateCollector(platform, baseHook);
844
- continue;
845
- }
846
- const overrideRecord = expectRecord(override, `${fieldName}.${platform}`);
847
- if (!overrideRecord)
848
- continue;
849
- validateAllowedKeys(overrideRecord, `${fieldName}.${platform}`, ['event', 'matcher', 'command']);
850
- const event = overrideRecord.event === undefined
851
- ? baseHook.event
852
- : validatePublicHookEvent(overrideRecord.event, `${fieldName}.${platform}.event`);
853
- const matcherValue = overrideRecord.matcher === undefined
854
- ? baseHook.matcher
855
- : overrideRecord.matcher;
856
- const matcher = event
857
- ? validatePublicHookMatcher(event, matcherValue, `${fieldName}.${platform}.matcher`)
858
- : null;
859
- const command = overrideRecord.command === undefined
860
- ? baseHook.command
861
- : validateManifestString(overrideRecord.command, `${fieldName}.${platform}.command`);
862
- if (event && matcher !== null && command) {
863
- duplicateCollector(platform, { event, matcher, command });
864
- }
865
- }
866
- }
867
- function validateHookEntryLightweight(entry, fieldName, duplicateCollector) {
868
- const input = expectRecord(entry, fieldName);
869
- if (!input)
870
- return;
871
- validateAllowedKeys(input, fieldName, ['event', 'matcher', 'command', 'agentOverrides']);
872
- const event = validatePublicHookEvent(input.event, `${fieldName}.event`);
873
- const matcher = event
874
- ? validatePublicHookMatcher(event, input.matcher, `${fieldName}.matcher`)
875
- : null;
876
- const command = validateManifestString(input.command, `${fieldName}.command`);
877
- if (!event || matcher === null || !command)
878
- return;
879
- validateHookAgentOverrides(input.agentOverrides, { event, matcher, command }, `${fieldName}.agentOverrides`, duplicateCollector);
880
- }
881
- function validateNativeHookEntryLightweight(entry, platform, fieldName, duplicateCollector) {
882
- const input = expectRecord(entry, fieldName);
883
- if (!input)
884
- return;
885
- validateAllowedKeys(input, fieldName, ['event', 'matcher', 'command']);
886
- const event = validateNativeHookEvent(input.event, platform, `${fieldName}.event`);
887
- const matcher = event
888
- ? validateNativeHookMatcher(event, platform, input.matcher, `${fieldName}.matcher`)
889
- : null;
890
- const command = validateManifestString(input.command, `${fieldName}.command`);
891
- if (!event || matcher === null || !command)
892
- return;
893
- duplicateCollector(platform, { event, matcher, command, native: true });
894
- }
895
- function validateExtensionsLightweight(extensions) {
896
- if (extensions === undefined)
897
- return;
898
- const input = expectRecord(extensions, 'extensions');
899
- if (!input)
900
- return;
901
- validateAllowedKeys(input, 'extensions', ['instructions', 'permissions', 'hooks', 'nativeHooks', 'agents']);
902
- const seenHooks = {
903
- claude: new Set(),
904
- codex: new Set(),
905
- };
906
- const collectHook = (platform, hook) => {
907
- const event = hook.native ? hook.event : PUBLIC_HOOK_RENDER_MAP[platform][hook.event];
908
- const matcher = hook.matcher === '*' ? undefined : hook.matcher;
909
- const key = JSON.stringify([event, matcher ?? null, hook.command]);
910
- if (seenHooks[platform].has(key)) {
911
- error(`extensions has duplicate ${platform} hook for event "${event}" and command "${hook.command}"`);
912
- }
913
- seenHooks[platform].add(key);
914
- };
915
- if (input.hooks !== undefined) {
916
- if (!Array.isArray(input.hooks)) {
917
- error('extensions.hooks must be an array');
918
- }
919
- else {
920
- input.hooks.forEach((entry, index) => validateHookEntryLightweight(entry, `extensions.hooks[${index}]`, collectHook));
921
- }
922
- }
923
- if (input.nativeHooks !== undefined) {
924
- const nativeHooks = expectRecord(input.nativeHooks, 'extensions.nativeHooks');
925
- if (nativeHooks) {
926
- validateAllowedKeys(nativeHooks, 'extensions.nativeHooks', ['claude', 'codex']);
927
- for (const platform of ['claude', 'codex']) {
928
- if (nativeHooks[platform] === undefined)
929
- continue;
930
- if (!Array.isArray(nativeHooks[platform])) {
931
- error(`extensions.nativeHooks.${platform} must be an array`);
932
- continue;
933
- }
934
- nativeHooks[platform].forEach((entry, index) => validateNativeHookEntryLightweight(entry, platform, `extensions.nativeHooks.${platform}[${index}]`, collectHook));
935
- }
936
- }
937
- }
938
- }
939
- function expectRecord(value, fieldName) {
940
- if (!isRecord(value)) {
941
- error(`${fieldName} must be an object`);
942
- return null;
943
- }
944
- return value;
945
- }
946
- function validateNonEmptyString(value, fieldName, maxLength) {
947
- if (typeof value !== 'string') {
948
- error(`${fieldName} must be a string`);
949
- return null;
950
- }
951
- const trimmed = value.trim();
952
- if (trimmed.length === 0) {
953
- error(`${fieldName} must not be empty`);
954
- return null;
955
- }
956
- if (maxLength !== undefined && countCharacters(trimmed) > maxLength) {
957
- error(`${fieldName} must be <= ${maxLength} characters`);
958
- }
959
- return trimmed;
960
- }
961
- function isPathInsideOrEqual(root, candidate) {
962
- const relative = path.relative(root, candidate);
963
- return relative === '' || (relative !== '..' &&
964
- !relative.startsWith(`..${path.sep}`) &&
965
- !path.isAbsolute(relative));
966
- }
967
- function validateRealPathBoundary(boundary, candidate, fieldName, boundaryName) {
968
- const canonicalBoundary = fs.realpathSync(boundary);
969
- const canonicalCandidate = fs.realpathSync(candidate);
970
- if (!isPathInsideOrEqual(canonicalBoundary, canonicalCandidate)) {
971
- error(`${fieldName} must stay inside the ${boundaryName}`);
972
- return false;
973
- }
974
- return true;
975
- }
976
- function validateEvalRelativeFile(evalDir, value, fieldName) {
977
- const relativePath = validateNonEmptyString(value, fieldName);
978
- if (!relativePath)
979
- return null;
980
- const normalized = stripDotSlash(relativePath).split('\\').join('/');
981
- if (path.isAbsolute(normalized) || normalized.split('/').includes('..')) {
982
- error(`${fieldName} must stay inside the Skill eval directory`);
983
- return null;
984
- }
985
- const absolutePath = path.resolve(evalDir, normalized);
986
- const relativeToRoot = path.relative(evalDir, absolutePath);
987
- if (relativeToRoot.startsWith('..') || path.isAbsolute(relativeToRoot)) {
988
- error(`${fieldName} must stay inside the Skill eval directory`);
989
- return null;
990
- }
991
- if (!fs.existsSync(absolutePath) || !fs.statSync(absolutePath).isFile()) {
992
- error(`${fieldName} does not exist: ${normalized}`);
993
- return null;
994
- }
995
- if (!validateRealPathBoundary(evalDir, absolutePath, fieldName, 'Skill eval directory')) {
996
- return null;
997
- }
998
- return absolutePath;
999
- }
1000
- function validateEvalWorkspacePath(value, fieldName, options = {}) {
1001
- const raw = validateNonEmptyString(value, fieldName);
1002
- if (!raw)
1003
- return null;
1004
- const treePattern = options.allowTreePattern === true && raw.endsWith('/**');
1005
- const candidate = treePattern ? raw.slice(0, -3) : raw;
1006
- if (candidate === '' ||
1007
- candidate.includes('\0') ||
1008
- candidate.includes('\\') ||
1009
- candidate.includes('*') ||
1010
- candidate.includes('?') ||
1011
- candidate.includes('[') ||
1012
- candidate.includes(']') ||
1013
- path.posix.isAbsolute(candidate) ||
1014
- path.win32.isAbsolute(candidate) ||
1015
- path.posix.normalize(candidate) !== candidate ||
1016
- candidate.split('/').includes('..')) {
1017
- error(`${fieldName} must be a normalized POSIX path inside the eval workspace`);
1018
- return null;
1019
- }
1020
- const firstSegment = candidate.split('/')[0];
1021
- if (firstSegment === '.git' || firstSegment === '.agents' || firstSegment === '.codex') {
1022
- error(`${fieldName} must not target an eval control directory`);
1023
- return null;
1024
- }
1025
- return raw;
1026
- }
1027
- function validateEvalFixtureTree(evalRoot, target, fieldName) {
1028
- const relativePath = path.relative(evalRoot, target);
1029
- let currentPath = evalRoot;
1030
- for (const segment of relativePath.split(path.sep).filter(Boolean)) {
1031
- currentPath = path.join(currentPath, segment);
1032
- const stat = fs.lstatSync(currentPath);
1033
- if (stat.isSymbolicLink()) {
1034
- error(`${fieldName} must not contain symbolic links`);
1035
- return false;
1036
- }
1037
- }
1038
- if (!validateRealPathBoundary(evalRoot, target, fieldName, 'Eval fixture root')) {
1039
- return false;
1040
- }
1041
- const stat = fs.lstatSync(target);
1042
- if (stat.isFile())
1043
- return true;
1044
- if (!stat.isDirectory()) {
1045
- error(`${fieldName} must reference a regular file or directory fixture`);
1046
- return false;
1047
- }
1048
- return fs.readdirSync(target).every((entry) => validateEvalFixtureTree(evalRoot, path.join(target, entry), fieldName));
1049
- }
1050
- function evalWorkspaceTargetsOverlap(left, right) {
1051
- return left === right || left.startsWith(`${right}/`) || right.startsWith(`${left}/`);
1052
- }
1053
- function validateConversationEnvironment(value, fieldName, fixtureRoot, occupiedTargets = new Set()) {
1054
- if (value === undefined)
1055
- return [];
1056
- const environment = expectRecord(value, fieldName);
1057
- if (!environment)
1058
- return [];
1059
- validateAllowedKeys(environment, fieldName, ['pathPrepend']);
1060
- if (!Array.isArray(environment.pathPrepend) || environment.pathPrepend.length === 0) {
1061
- error(`${fieldName}.pathPrepend must be a non-empty array`);
1062
- return [];
1063
- }
1064
- const targets = environment.pathPrepend
1065
- .map((entry, index) => ({
1066
- index,
1067
- relativePath: validateEvalWorkspacePath(entry, `${fieldName}.pathPrepend[${index}]`, {
1068
- allowTreePattern: false,
1069
- }),
1070
- }))
1071
- .filter((entry) => entry.relativePath !== null);
1072
- if (new Set(targets.map((entry) => entry.relativePath)).size !== targets.length) {
1073
- error(`${fieldName}.pathPrepend must not contain duplicates`);
1074
- }
1075
- targets.forEach(({ index, relativePath }) => {
1076
- const target = path.resolve(fixtureRoot, relativePath);
1077
- if (!fs.existsSync(target)) {
1078
- error(`${fieldName}.pathPrepend[${index}] must reference an existing fixture`);
1079
- return;
1080
- }
1081
- validateEvalFixtureTree(fixtureRoot, target, `${fieldName}.pathPrepend[${index}]`);
1082
- if ([...occupiedTargets].some((occupiedTarget) => evalWorkspaceTargetsOverlap(relativePath, occupiedTarget))) {
1083
- error(`${fieldName}.pathPrepend[${index}] conflicts with another PATH fixture target`);
1084
- return;
1085
- }
1086
- occupiedTargets.add(relativePath);
1087
- });
1088
- return targets.map((entry) => entry.relativePath);
1089
- }
1090
- function evalWorkspacePathMatchesPattern(relativePath, pattern) {
1091
- if (pattern.endsWith('/**')) {
1092
- const prefix = pattern.slice(0, -3);
1093
- return relativePath === prefix || relativePath.startsWith(`${prefix}/`);
1094
- }
1095
- return relativePath === pattern;
1096
- }
1097
- function validateConversationCaseCorpus(evalDir, suite, fieldName, suitePathPrepend = []) {
1098
- const casesPath = validateEvalRelativeFile(evalDir, suite.cases, `${fieldName}.cases`);
1099
- if (!casesPath)
1100
- return;
1101
- let document;
1102
- try {
1103
- document = JSON.parse(fs.readFileSync(casesPath, 'utf8'));
1104
- }
1105
- catch (e) {
1106
- error(`${fieldName}.cases is not valid JSON: ${e.message}`);
1107
- return;
1108
- }
1109
- const corpus = expectRecord(document, `${fieldName}.cases document`);
1110
- if (!corpus)
1111
- return;
1112
- const skillName = validateNonEmptyString(corpus.skill_name, `${fieldName}.cases.skill_name`);
1113
- if (skillName && skillName !== suite.skill) {
1114
- error(`${fieldName}.cases.skill_name must match ${JSON.stringify(suite.skill)}`);
1115
- }
1116
- if (!Array.isArray(corpus.evals) || corpus.evals.length === 0) {
1117
- error(`${fieldName}.cases.evals must be a non-empty array`);
1118
- return;
1119
- }
1120
- const ids = new Set();
1121
- corpus.evals.forEach((value, caseIndex) => {
1122
- const caseField = `${fieldName}.cases.evals[${caseIndex}]`;
1123
- const entry = expectRecord(value, caseField);
1124
- if (!entry)
1125
- return;
1126
- const id = validateNonEmptyString(entry.id, `${caseField}.id`);
1127
- if (id && ids.has(id)) {
1128
- error(`${fieldName}.cases has duplicate case id ${JSON.stringify(id)}`);
1129
- }
1130
- else if (id) {
1131
- ids.add(id);
1132
- }
1133
- validateNonEmptyString(entry.prompt, `${caseField}.prompt`);
1134
- const sandbox = entry.sandbox === undefined
1135
- ? 'read-only'
1136
- : validateNonEmptyString(entry.sandbox, `${caseField}.sandbox`);
1137
- if (sandbox && sandbox !== 'read-only' && sandbox !== 'workspace-write') {
1138
- error(`${caseField}.sandbox must be "read-only" or "workspace-write"`);
1139
- }
1140
- if (!Array.isArray(entry.scripted_replies)) {
1141
- error(`${caseField}.scripted_replies must be an array`);
1142
- }
1143
- else {
1144
- entry.scripted_replies.forEach((reply, replyIndex) => {
1145
- const replyField = `${caseField}.scripted_replies[${replyIndex}]`;
1146
- if (typeof reply === 'string')
1147
- return;
1148
- const replyEntry = expectRecord(reply, replyField);
1149
- if (!replyEntry)
1150
- return;
1151
- if (!Array.isArray(replyEntry.answers_by_index) || replyEntry.answers_by_index.some((answer) => typeof answer !== 'string')) {
1152
- error(`${replyField}.answers_by_index must be an array of strings`);
1153
- }
1154
- if (replyEntry.expected_question_count !== undefined &&
1155
- (!Number.isInteger(replyEntry.expected_question_count) ||
1156
- replyEntry.expected_question_count < 0)) {
1157
- error(`${replyField}.expected_question_count must be a non-negative integer`);
1158
- }
1159
- validateNonEmptyString(replyEntry.unexpected_question_answer, `${replyField}.unexpected_question_answer`);
1160
- });
1161
- }
1162
- validateNonEmptyString(entry.expected_output, `${caseField}.expected_output`);
1163
- validateConversationEnvironment(entry.environment, `${caseField}.environment`, path.dirname(casesPath), new Set(suitePathPrepend));
1164
- if (entry.workspace_files !== undefined) {
1165
- const workspaceFiles = expectRecord(entry.workspace_files, `${caseField}.workspace_files`);
1166
- if (workspaceFiles) {
1167
- const workspaceFileEntries = Object.entries(workspaceFiles);
1168
- if (workspaceFileEntries.length === 0) {
1169
- error(`${caseField}.workspace_files must contain at least one file`);
1170
- }
1171
- workspaceFileEntries.forEach(([relativePath, content]) => {
1172
- validateEvalWorkspacePath(relativePath, `${caseField}.workspace_files.${relativePath}`, { allowTreePattern: false });
1173
- validateNonEmptyString(content, `${caseField}.workspace_files.${relativePath}`);
1174
- });
1175
- }
1176
- }
1177
- const review = expectRecord(entry.review, `${caseField}.review`);
1178
- if (review) {
1179
- if (!Array.isArray(review.checks) || review.checks.length === 0 || review.checks.some((check) => typeof check !== 'string' || check.trim() === '')) {
1180
- error(`${caseField}.review.checks must be a non-empty array of strings`);
1181
- }
1182
- if (review.workspace_unchanged !== undefined &&
1183
- typeof review.workspace_unchanged !== 'boolean') {
1184
- error(`${caseField}.review.workspace_unchanged must be boolean`);
1185
- }
1186
- const allowedWorkspaceChanges = [];
1187
- if (review.allowed_workspace_changes !== undefined) {
1188
- if (!Array.isArray(review.allowed_workspace_changes) ||
1189
- review.allowed_workspace_changes.length === 0) {
1190
- error(`${caseField}.review.allowed_workspace_changes must be a non-empty array`);
1191
- }
1192
- else {
1193
- review.allowed_workspace_changes.forEach((pathValue, pathIndex) => {
1194
- const normalized = validateEvalWorkspacePath(pathValue, `${caseField}.review.allowed_workspace_changes[${pathIndex}]`, { allowTreePattern: true });
1195
- if (normalized)
1196
- allowedWorkspaceChanges.push(normalized);
1197
- });
1198
- }
1199
- }
1200
- const artifactPaths = [];
1201
- if (review.artifacts !== undefined) {
1202
- if (!Array.isArray(review.artifacts) || review.artifacts.length === 0) {
1203
- error(`${caseField}.review.artifacts must be a non-empty array`);
1204
- }
1205
- else {
1206
- review.artifacts.forEach((artifactValue, artifactIndex) => {
1207
- const artifactField = `${caseField}.review.artifacts[${artifactIndex}]`;
1208
- const artifact = expectRecord(artifactValue, artifactField);
1209
- if (!artifact)
1210
- return;
1211
- validateAllowedKeys(artifact, artifactField, ['path', 'exists', 'contains', 'not_contains', 'json']);
1212
- const artifactPath = validateEvalWorkspacePath(artifact.path, `${artifactField}.path`);
1213
- if (artifactPath)
1214
- artifactPaths.push(artifactPath);
1215
- if (artifact.exists !== undefined && typeof artifact.exists !== 'boolean') {
1216
- error(`${artifactField}.exists must be boolean`);
1217
- }
1218
- for (const key of ['contains', 'not_contains']) {
1219
- if (artifact[key] !== undefined &&
1220
- (!Array.isArray(artifact[key]) || artifact[key].length === 0 || artifact[key].some((fragment) => typeof fragment !== 'string' || fragment.length === 0))) {
1221
- error(`${artifactField}.${key} must be a non-empty array of strings`);
1222
- }
1223
- }
1224
- if (artifact.json !== undefined && !isRecord(artifact.json)) {
1225
- error(`${artifactField}.json must be an object`);
1226
- }
1227
- });
1228
- }
1229
- }
1230
- if (new Set(artifactPaths).size !== artifactPaths.length) {
1231
- error(`${caseField}.review.artifacts contains duplicate paths`);
1232
- }
1233
- if (sandbox === 'workspace-write') {
1234
- if (review.workspace_unchanged !== false) {
1235
- error(`${caseField} workspace-write requires review.workspace_unchanged=false`);
1236
- }
1237
- if (allowedWorkspaceChanges.length === 0 || artifactPaths.length === 0) {
1238
- error(`${caseField} workspace-write requires allowed changes and artifacts`);
1239
- }
1240
- const unmatchedArtifact = artifactPaths.find((artifactPath) => !allowedWorkspaceChanges.some((pattern) => evalWorkspacePathMatchesPattern(artifactPath, pattern)));
1241
- if (unmatchedArtifact) {
1242
- error(`${caseField} artifact ${JSON.stringify(unmatchedArtifact)} is outside allowed changes`);
1243
- }
1244
- }
1245
- }
1246
- });
1247
- }
1248
- function validateTriggerCaseCorpus(evalDir, suite, fieldName) {
1249
- const casesPath = validateEvalRelativeFile(evalDir, suite.cases, `${fieldName}.cases`);
1250
- if (!casesPath)
1251
- return;
1252
- let document;
1253
- try {
1254
- document = JSON.parse(fs.readFileSync(casesPath, 'utf8'));
1255
- }
1256
- catch (e) {
1257
- error(`${fieldName}.cases is not valid JSON: ${e.message}`);
1258
- return;
1259
- }
1260
- const corpus = expectRecord(document, `${fieldName}.cases document`);
1261
- if (!corpus)
1262
- return;
1263
- if (corpus.schemaVersion !== PLUGIN_EVAL_CASE_SCHEMA_VERSION) {
1264
- error(`${fieldName}.cases.schemaVersion must be ${PLUGIN_EVAL_CASE_SCHEMA_VERSION}`);
1265
- }
1266
- if (corpus.skill !== suite.skill) {
1267
- error(`${fieldName}.cases.skill must match ${JSON.stringify(suite.skill)}`);
1268
- }
1269
- if (!Array.isArray(corpus.cases) || corpus.cases.length === 0) {
1270
- error(`${fieldName}.cases.cases must be a non-empty array`);
1271
- return;
1272
- }
1273
- const ids = new Set();
1274
- const seenSplits = new Set();
1275
- let hasWorkspaceFixture = false;
1276
- corpus.cases.forEach((value, caseIndex) => {
1277
- const caseField = `${fieldName}.cases.cases[${caseIndex}]`;
1278
- const entry = expectRecord(value, caseField);
1279
- if (!entry)
1280
- return;
1281
- const id = validateNonEmptyString(entry.id, `${caseField}.id`);
1282
- if (id && !/^[a-z0-9][a-z0-9_]*$/.test(id)) {
1283
- error(`${caseField}.id must use lowercase snake_case`);
1284
- }
1285
- else if (id && ids.has(id)) {
1286
- error(`${fieldName}.cases has duplicate case id ${JSON.stringify(id)}`);
1287
- }
1288
- else if (id) {
1289
- ids.add(id);
1290
- }
1291
- if (!PLUGIN_EVAL_TRIGGER_CASE_SPLITS.has(entry.split)) {
1292
- error(`${caseField}.split must be train, validation, or sanity`);
1293
- }
1294
- else {
1295
- seenSplits.add(entry.split);
1296
- }
1297
- validateNonEmptyString(entry.query, `${caseField}.query`);
1298
- const usesLegacyExpectation = entry.should_load_skill !== undefined;
1299
- const usesRouteExpectation = entry.expected_loaded_skills !== undefined;
1300
- if (usesLegacyExpectation === usesRouteExpectation) {
1301
- error(`${caseField} must declare exactly one of should_load_skill or expected_loaded_skills`);
1302
- }
1303
- else if (usesLegacyExpectation && typeof entry.should_load_skill !== 'boolean') {
1304
- error(`${caseField}.should_load_skill must be boolean`);
1305
- }
1306
- else if (usesRouteExpectation) {
1307
- if (!Array.isArray(entry.expected_loaded_skills)) {
1308
- error(`${caseField}.expected_loaded_skills must be an array`);
1309
- }
1310
- else {
1311
- const expectedSkills = entry.expected_loaded_skills;
1312
- expectedSkills.forEach((skillName, skillIndex) => {
1313
- if (typeof skillName !== 'string' || skillName.trim() === '') {
1314
- error(`${caseField}.expected_loaded_skills[${skillIndex}] must be a non-empty string`);
1315
- }
1316
- else if (!suite.skills.includes(skillName)) {
1317
- error(`${caseField}.expected_loaded_skills[${skillIndex}] must name a participant Skill`);
1318
- }
1319
- });
1320
- if (new Set(expectedSkills).size !== expectedSkills.length) {
1321
- error(`${caseField}.expected_loaded_skills must not contain duplicates`);
1322
- }
1323
- if (suite.forbidMultipleSkillLoads === true && expectedSkills.length > 1) {
1324
- error(`${caseField} expects multiple Skills but the suite forbids multiple Skill loads`);
1325
- }
1326
- }
1327
- }
1328
- if (suite.observeSpawnAgent === true) {
1329
- if (typeof entry.should_spawn_agent !== 'boolean') {
1330
- error(`${caseField}.should_spawn_agent is required when observeSpawnAgent=true`);
1331
- }
1332
- }
1333
- else if (entry.should_spawn_agent !== undefined) {
1334
- error(`${caseField}.should_spawn_agent requires observeSpawnAgent=true`);
1335
- }
1336
- if (entry.workspace_fixture !== undefined) {
1337
- hasWorkspaceFixture = true;
1338
- validateNonEmptyString(entry.workspace_fixture, `${caseField}.workspace_fixture`);
1339
- }
1340
- if (entry.use_project_rules !== undefined &&
1341
- typeof entry.use_project_rules !== 'boolean') {
1342
- error(`${caseField}.use_project_rules must be boolean`);
1343
- }
1344
- if (entry.tags !== undefined) {
1345
- if (!Array.isArray(entry.tags) || entry.tags.length === 0) {
1346
- error(`${caseField}.tags must be a non-empty array`);
1347
- }
1348
- else {
1349
- entry.tags.forEach((tag, tagIndex) => {
1350
- validateNonEmptyString(tag, `${caseField}.tags[${tagIndex}]`);
1351
- });
1352
- }
1353
- }
1354
- });
1355
- if (hasWorkspaceFixture && suite.fixtureModule === undefined) {
1356
- error(`${fieldName}.fixtureModule is required when cases declare workspace_fixture`);
1357
- }
1358
- if (Array.isArray(suite.releaseSplits)) {
1359
- suite.releaseSplits.forEach((split) => {
1360
- if (split !== 'all' && !seenSplits.has(split)) {
1361
- error(`${fieldName}.cases has no cases for release split ${JSON.stringify(split)}`);
1362
- }
1363
- });
1364
- }
1365
- }
1366
- function resolveEvalProfilePlugin(pluginDir, ownerManifest, pluginName, fieldName) {
1367
- if (pluginName === ownerManifest.name) {
1368
- return { pluginDir, manifest: ownerManifest };
1369
- }
1370
- const companionDir = path.join(path.dirname(pluginDir), pluginName);
1371
- const manifestPath = path.join(companionDir, '.agents-plugin', 'plugin.json');
1372
- if (!fs.existsSync(manifestPath)) {
1373
- error(`${fieldName} must reference repo-local plugin "${pluginName}"`);
1374
- return null;
1375
- }
1376
- let manifest;
1377
- try {
1378
- manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
1379
- }
1380
- catch (e) {
1381
- error(`${fieldName} companion manifest is not valid JSON: ${e.message}`);
1382
- return null;
1383
- }
1384
- if (!isRecord(manifest) || manifest.name !== pluginName) {
1385
- error(`${fieldName} companion source must declare plugin name "${pluginName}"`);
1386
- return null;
1387
- }
1388
- return { pluginDir: companionDir, manifest };
1389
- }
1390
- function validateOnePluginEvalManifest(pluginDir, pluginManifest, evalDir, expectedSkill) {
1391
- const evalManifestPath = path.join(evalDir, 'manifest.json');
1392
- const manifestField = path.relative(pluginDir, evalManifestPath).split(path.sep).join('/');
1393
- let document;
1394
- try {
1395
- document = JSON.parse(fs.readFileSync(evalManifestPath, 'utf8'));
1396
- }
1397
- catch (e) {
1398
- error(`${manifestField} is not valid JSON: ${e.message}`);
1399
- return;
1400
- }
1401
- const manifest = expectRecord(document, manifestField);
1402
- if (!manifest)
1403
- return;
1404
- validateAllowedKeys(manifest, manifestField, ['schemaVersion', 'plugin', 'skill', 'profiles', 'suites']);
1405
- if (manifest.schemaVersion !== PLUGIN_EVAL_SCHEMA_VERSION) {
1406
- error(`${manifestField}.schemaVersion must be ${PLUGIN_EVAL_SCHEMA_VERSION}`);
1407
- }
1408
- if (manifest.plugin !== pluginManifest.name) {
1409
- error(`${manifestField}.plugin must match plugin name ${JSON.stringify(pluginManifest.name)}`);
1410
- }
1411
- const skill = validateNonEmptyString(manifest.skill, `${manifestField}.skill`);
1412
- if (skill && skill !== expectedSkill) {
1413
- error(`${manifestField}.skill must match owning Skill ${JSON.stringify(expectedSkill)}`);
1414
- }
1415
- if (skill && !collectDeclaredSkillNames(pluginDir, pluginManifest).all.has(skill)) {
1416
- error(`${manifestField}.skill must reference a declared static or dynamic skill`);
1417
- }
1418
- if (!Array.isArray(manifest.profiles) || manifest.profiles.length === 0) {
1419
- error(`${manifestField}.profiles must be a non-empty array`);
1420
- return;
1421
- }
1422
- const profilesById = new Map();
1423
- manifest.profiles.forEach((value, index) => {
1424
- const fieldName = `${manifestField}.profiles[${index}]`;
1425
- const profile = expectRecord(value, fieldName);
1426
- if (!profile)
1427
- return;
1428
- validateAllowedKeys(profile, fieldName, ['id', 'scope', 'plugins', 'runModel', 'requiredForRelease']);
1429
- const id = validateNonEmptyString(profile.id, `${fieldName}.id`);
1430
- if (id && !PLUGIN_NAME_PATTERN.test(id)) {
1431
- error(`${fieldName}.id must use lowercase kebab-case`);
1432
- }
1433
- else if (id && profilesById.has(id)) {
1434
- error(`${manifestField} has duplicate profile id ${JSON.stringify(id)}`);
1435
- }
1436
- if (!PLUGIN_EVAL_SCOPES.has(profile.scope)) {
1437
- error(`${fieldName}.scope must be user or project`);
1438
- }
1439
- const skillOwners = new Map();
1440
- const installedPlugins = new Set();
1441
- if (!Array.isArray(profile.plugins) || profile.plugins.length === 0) {
1442
- error(`${fieldName}.plugins must be a non-empty array`);
1443
- }
1444
- else {
1445
- profile.plugins.forEach((value, pluginIndex) => {
1446
- const pluginField = `${fieldName}.plugins[${pluginIndex}]`;
1447
- const installation = expectRecord(value, pluginField);
1448
- if (!installation)
1449
- return;
1450
- validateAllowedKeys(installation, pluginField, ['name', 'config']);
1451
- const pluginName = validateNonEmptyString(installation.name, `${pluginField}.name`);
1452
- if (!pluginName)
1453
- return;
1454
- if (!PLUGIN_NAME_PATTERN.test(pluginName)) {
1455
- error(`${pluginField}.name must use lowercase kebab-case`);
1456
- }
1457
- if (installedPlugins.has(pluginName)) {
1458
- error(`${fieldName}.plugins has duplicate plugin ${JSON.stringify(pluginName)}`);
1459
- return;
1460
- }
1461
- installedPlugins.add(pluginName);
1462
- if (installation.config !== undefined && !isRecord(installation.config)) {
1463
- error(`${pluginField}.config must be an object`);
1464
- }
1465
- const source = resolveEvalProfilePlugin(pluginDir, pluginManifest, pluginName, `${pluginField}.name`);
1466
- if (!source)
1467
- return;
1468
- for (const skillName of collectDeclaredSkillNames(source.pluginDir, source.manifest).all) {
1469
- const existing = skillOwners.get(skillName);
1470
- if (existing && existing !== pluginName) {
1471
- error(`${fieldName} installs duplicate Skill key ${JSON.stringify(skillName)} ` +
1472
- `from plugins ${JSON.stringify(existing)} and ${JSON.stringify(pluginName)}`);
1473
- }
1474
- else {
1475
- skillOwners.set(skillName, pluginName);
1476
- }
1477
- }
1478
- });
1479
- }
1480
- if (!installedPlugins.has(pluginManifest.name)) {
1481
- error(`${fieldName}.plugins must include owner plugin ${JSON.stringify(pluginManifest.name)}`);
1482
- }
1483
- if (typeof profile.runModel !== 'boolean') {
1484
- error(`${fieldName}.runModel must be boolean`);
1485
- }
1486
- if (typeof profile.requiredForRelease !== 'boolean') {
1487
- error(`${fieldName}.requiredForRelease must be boolean`);
1488
- }
1489
- if (profile.scope === 'user' && profile.runModel === true) {
1490
- error(`${fieldName}: eval schema v2 does not allow real model execution for user scope`);
1491
- }
1492
- if (id && PLUGIN_NAME_PATTERN.test(id) && !profilesById.has(id)) {
1493
- profilesById.set(id, { ...profile, skillOwners });
1494
- }
1495
- });
1496
- if (!manifest.profiles.some((profile) => isRecord(profile) && profile.scope === 'project' && profile.runModel === true)) {
1497
- error(`${manifestField} must define at least one project profile with runModel=true`);
1498
- }
1499
- if (!Array.isArray(manifest.suites) || manifest.suites.length === 0) {
1500
- error(`${manifestField}.suites must be a non-empty array`);
1501
- return;
1502
- }
1503
- const suiteIds = new Set();
1504
- manifest.suites.forEach((value, index) => {
1505
- const fieldName = `${manifestField}.suites[${index}]`;
1506
- const suite = expectRecord(value, fieldName);
1507
- if (!suite)
1508
- return;
1509
- const id = validateNonEmptyString(suite.id, `${fieldName}.id`);
1510
- if (id && !PLUGIN_NAME_PATTERN.test(id)) {
1511
- error(`${fieldName}.id must use lowercase kebab-case`);
1512
- }
1513
- else if (id && suiteIds.has(id)) {
1514
- error(`${manifestField} has duplicate suite id ${JSON.stringify(id)}`);
1515
- }
1516
- else if (id) {
1517
- suiteIds.add(id);
1518
- }
1519
- if (suite.kind !== 'command' && suite.kind !== 'conversation' && suite.kind !== 'trigger') {
1520
- error(`${fieldName}.kind must be command, conversation, or trigger`);
1521
- }
1522
- const suiteSkills = new Set();
1523
- if (!Array.isArray(suite.skills) || suite.skills.length === 0) {
1524
- error(`${fieldName}.skills must be a non-empty array`);
1525
- }
1526
- else {
1527
- suite.skills.forEach((skillName, skillIndex) => {
1528
- const skillField = `${fieldName}.skills[${skillIndex}]`;
1529
- const normalized = validateNonEmptyString(skillName, skillField);
1530
- if (!normalized)
1531
- return;
1532
- if (!PLUGIN_NAME_PATTERN.test(normalized)) {
1533
- error(`${skillField} must use lowercase kebab-case`);
1534
- }
1535
- else if (suiteSkills.has(normalized)) {
1536
- error(`${fieldName}.skills has duplicate Skill ${JSON.stringify(normalized)}`);
1537
- }
1538
- else {
1539
- suiteSkills.add(normalized);
1540
- }
1541
- });
376
+ for (const platform of PLATFORM_TARGETS) {
377
+ if (manifest.buildConfig?.fileRules?.[platform] !== undefined) {
378
+ assertPlatformFieldSupported(manifest, `buildConfig.fileRules.${platform}`, platform);
1542
379
  }
1543
- if (skill && !suiteSkills.has(skill)) {
1544
- error(`${fieldName}.skills must include owner Skill ${JSON.stringify(skill)}`);
1545
- }
1546
- if (!Array.isArray(suite.profiles) || suite.profiles.length === 0) {
1547
- error(`${fieldName}.profiles must be a non-empty array`);
1548
- }
1549
- else {
1550
- suite.profiles.forEach((profileId, profileIndex) => {
1551
- const profileField = `${fieldName}.profiles[${profileIndex}]`;
1552
- if (typeof profileId !== 'string' || profileId.trim() === '') {
1553
- error(`${profileField} must be a non-empty string`);
1554
- return;
1555
- }
1556
- const profile = profilesById.get(profileId);
1557
- if (!profile) {
1558
- error(`${fieldName} references unknown profile ${JSON.stringify(profileId)}`);
1559
- }
1560
- else if (profile.runModel !== true) {
1561
- error(`${fieldName} cannot execute materialize-only profile ${JSON.stringify(profileId)}`);
1562
- }
1563
- if (profile) {
1564
- for (const skillName of suiteSkills) {
1565
- if (!profile.skillOwners.has(skillName)) {
1566
- error(`${fieldName} requires Skill ${JSON.stringify(skillName)}, but profile ` +
1567
- `${JSON.stringify(profileId)} does not install a plugin that declares it`);
1568
- }
1569
- }
1570
- }
1571
- });
380
+ if ((manifest.extensions?.nativeHooks?.[platform]?.length ?? 0) > 0) {
381
+ assertPlatformFieldSupported(manifest, `extensions.nativeHooks.${platform}`, platform);
1572
382
  }
1573
- if (!Number.isInteger(suite.defaultRuns) || suite.defaultRuns <= 0) {
1574
- error(`${fieldName}.defaultRuns must be a positive integer`);
1575
- }
1576
- if (!Number.isInteger(suite.perRunTimeoutMs) || suite.perRunTimeoutMs <= 0) {
1577
- error(`${fieldName}.perRunTimeoutMs must be a positive integer`);
1578
- }
1579
- if (typeof suite.requiredForRelease !== 'boolean') {
1580
- error(`${fieldName}.requiredForRelease must be boolean`);
1581
- }
1582
- if (!Array.isArray(suite.releaseSplits)) {
1583
- error(`${fieldName}.releaseSplits must be an array`);
1584
- }
1585
- else {
1586
- suite.releaseSplits.forEach((split, splitIndex) => {
1587
- if (!PLUGIN_EVAL_SPLITS.has(split)) {
1588
- error(`${fieldName}.releaseSplits[${splitIndex}] is unsupported`);
1589
- }
1590
- });
1591
- }
1592
- if (suite.kind === 'command') {
1593
- validateAllowedKeys(suite, fieldName, [
1594
- 'id', 'kind', 'skills', 'entry', 'cases', 'profiles', 'defaultRuns', 'releaseSplits',
1595
- 'requiredForRelease', 'perRunTimeoutMs', 'suiteTimeoutMs', 'supports',
1596
- ]);
1597
- validateEvalRelativeFile(evalDir, suite.entry, `${fieldName}.entry`);
1598
- if (!Number.isInteger(suite.suiteTimeoutMs) || suite.suiteTimeoutMs <= 0) {
1599
- error(`${fieldName}.suiteTimeoutMs must be a positive integer`);
1600
- }
1601
- else if (suite.suiteTimeoutMs < suite.perRunTimeoutMs) {
1602
- error(`${fieldName}.suiteTimeoutMs must be greater than or equal to perRunTimeoutMs`);
1603
- }
1604
- if (!Array.isArray(suite.supports)) {
1605
- error(`${fieldName}.supports must be an array`);
1606
- }
1607
- else {
1608
- suite.supports.forEach((support, supportIndex) => {
1609
- if (!PLUGIN_EVAL_COMMAND_SUPPORTS.has(support)) {
1610
- error(`${fieldName}.supports[${supportIndex}] is unsupported`);
1611
- }
1612
- });
1613
- if (Array.isArray(suite.releaseSplits) &&
1614
- suite.releaseSplits.length > 0 &&
1615
- !suite.supports.includes('split')) {
1616
- error(`${fieldName} declares releaseSplits but does not support split`);
1617
- }
1618
- const supportsCase = suite.supports.includes('case');
1619
- if (supportsCase && suite.cases === undefined) {
1620
- error(`${fieldName}.cases is required when supports includes case`);
1621
- }
1622
- else if (!supportsCase && suite.cases !== undefined) {
1623
- error(`${fieldName}.cases requires supports to include case`);
1624
- }
1625
- if (supportsCase && suite.cases !== undefined) {
1626
- const casesPath = validateEvalRelativeFile(evalDir, suite.cases, `${fieldName}.cases`);
1627
- if (casesPath) {
1628
- try {
1629
- const casesDocument = JSON.parse(fs.readFileSync(casesPath, 'utf8'));
1630
- if (!isRecord(casesDocument) || casesDocument.skill_name !== skill) {
1631
- error(`${fieldName}.cases.skill_name must match ${JSON.stringify(skill)}`);
1632
- }
1633
- else if (!Array.isArray(casesDocument.evals) || casesDocument.evals.length === 0) {
1634
- error(`${fieldName}.cases.evals must be a non-empty array`);
1635
- }
1636
- else {
1637
- const caseIds = new Set();
1638
- casesDocument.evals.forEach((entry, caseIndex) => {
1639
- const caseField = `${fieldName}.cases.evals[${caseIndex}]`;
1640
- if (!isRecord(entry) || typeof entry.id !== 'string' || !/^[a-z0-9_]+$/.test(entry.id)) {
1641
- error(`${caseField}.id must use lowercase snake_case`);
1642
- }
1643
- else if (caseIds.has(entry.id)) {
1644
- error(`${fieldName}.cases has duplicate case id ${JSON.stringify(entry.id)}`);
1645
- }
1646
- else {
1647
- caseIds.add(entry.id);
1648
- }
1649
- });
1650
- }
1651
- }
1652
- catch (cause) {
1653
- error(`${fieldName}.cases is not valid JSON: ${cause.message}`);
1654
- }
1655
- }
1656
- }
1657
- }
1658
- }
1659
- else if (suite.kind === 'conversation' || suite.kind === 'trigger') {
1660
- const normalizedSuite = { ...suite, skill };
1661
- const isolation = suite.isolation ?? 'standard';
1662
- if (isolation !== 'standard' && isolation !== 'strict') {
1663
- error(`${fieldName}.isolation must be standard or strict`);
1664
- }
1665
- if (suite.kind === 'conversation') {
1666
- validateAllowedKeys(suite, fieldName, [
1667
- 'id', 'kind', 'skills', 'cases', 'profiles', 'defaultRuns', 'releaseSplits',
1668
- 'requiredForRelease', 'perRunTimeoutMs', 'isolation', 'environment',
1669
- ]);
1670
- if (Array.isArray(suite.releaseSplits) && suite.releaseSplits.length > 0) {
1671
- error(`${fieldName} cannot declare releaseSplits because conversation cases do not support split filtering`);
1672
- }
1673
- const suitePathPrepend = validateConversationEnvironment(suite.environment, `${fieldName}.environment`, evalDir);
1674
- validateConversationCaseCorpus(evalDir, normalizedSuite, fieldName, suitePathPrepend);
1675
- }
1676
- else {
1677
- validateAllowedKeys(suite, fieldName, [
1678
- 'id', 'kind', 'skills', 'cases', 'fixtureModule', 'observeSpawnAgent', 'isolation',
1679
- 'strictNegativeSplits', 'minimumPassRate', 'forbidMultipleSkillLoads',
1680
- 'profiles', 'defaultRuns', 'releaseSplits',
1681
- 'requiredForRelease', 'perRunTimeoutMs',
1682
- ]);
1683
- if (typeof suite.observeSpawnAgent !== 'boolean') {
1684
- error(`${fieldName}.observeSpawnAgent must be boolean`);
1685
- }
1686
- if (!Array.isArray(suite.strictNegativeSplits)) {
1687
- error(`${fieldName}.strictNegativeSplits must be an array`);
1688
- }
1689
- else {
1690
- suite.strictNegativeSplits.forEach((split, splitIndex) => {
1691
- if (!PLUGIN_EVAL_TRIGGER_CASE_SPLITS.has(split)) {
1692
- error(`${fieldName}.strictNegativeSplits[${splitIndex}] is unsupported`);
1693
- }
1694
- });
1695
- }
1696
- if (suite.minimumPassRate !== undefined &&
1697
- (typeof suite.minimumPassRate !== 'number' ||
1698
- !Number.isFinite(suite.minimumPassRate) ||
1699
- suite.minimumPassRate <= 0 ||
1700
- suite.minimumPassRate > 1)) {
1701
- error(`${fieldName}.minimumPassRate must be greater than 0 and at most 1`);
1702
- }
1703
- if (suite.forbidMultipleSkillLoads !== undefined &&
1704
- typeof suite.forbidMultipleSkillLoads !== 'boolean') {
1705
- error(`${fieldName}.forbidMultipleSkillLoads must be boolean`);
1706
- }
1707
- if (suite.fixtureModule !== undefined) {
1708
- const fixturePath = validateEvalRelativeFile(evalDir, suite.fixtureModule, `${fieldName}.fixtureModule`);
1709
- if (fixturePath && path.extname(fixturePath) !== '.mjs') {
1710
- error(`${fieldName}.fixtureModule must reference an .mjs file`);
1711
- }
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);
1712
387
  }
1713
- validateTriggerCaseCorpus(evalDir, normalizedSuite, fieldName);
1714
388
  }
1715
389
  }
1716
- });
1717
- if (skill
1718
- && collectDeclaredSkillNames(pluginDir, pluginManifest).dynamic.has(skill)
1719
- && !manifest.suites.some((suite) => isRecord(suite) && suite.requiredForRelease === true)) {
1720
- error(`${manifestField}.suites must include at least one release-required suite for dynamic Skill ${JSON.stringify(skill)}`);
1721
390
  }
1722
391
  }
1723
- function validatePluginEvalManifest(pluginDir, pluginManifest) {
392
+ function isTemplateAsset(manifest, relativePath) {
393
+ return templateIncludesPath(manifest, relativePath);
394
+ }
395
+ function isRecord(value) {
396
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
397
+ }
398
+ function validateAllowedKeys(record, fieldName, allowedKeys) {
399
+ for (const key of Object.keys(record)) {
400
+ if (!allowedKeys.includes(key)) {
401
+ error(`${fieldName} has unknown field "${key}"`);
402
+ }
403
+ }
404
+ }
405
+ function validateManifestString(value, fieldName) {
406
+ if (typeof value !== 'string' || value.trim() === '') {
407
+ error(`${fieldName} must be a non-empty string`);
408
+ return null;
409
+ }
410
+ return value.trim();
411
+ }
412
+ function expectRecord(value, fieldName) {
413
+ if (!isRecord(value)) {
414
+ error(`${fieldName} must be an object`);
415
+ return null;
416
+ }
417
+ return value;
418
+ }
419
+ function validateNonEmptyString(value, fieldName, maxLength) {
420
+ if (typeof value !== 'string') {
421
+ error(`${fieldName} must be a string`);
422
+ return null;
423
+ }
424
+ const trimmed = value.trim();
425
+ if (trimmed.length === 0) {
426
+ error(`${fieldName} must not be empty`);
427
+ return null;
428
+ }
429
+ if (maxLength !== undefined && countCharacters(trimmed) > maxLength) {
430
+ error(`${fieldName} must be <= ${maxLength} characters`);
431
+ }
432
+ return trimmed;
433
+ }
434
+ async function loadSkillEvalManifestTools() {
435
+ if (skillEvalManifestTools)
436
+ return skillEvalManifestTools;
437
+ const modulePath = path.join(CLI_PACKAGE_ROOT, 'dist', 'src', 'eval', 'manifest-v1.js');
438
+ try {
439
+ skillEvalManifestTools = await import(pathToFileURL(modulePath).href);
440
+ return skillEvalManifestTools;
441
+ }
442
+ catch {
443
+ return null;
444
+ }
445
+ }
446
+ async function validatePluginEvalManifest(pluginDir, pluginManifest) {
1724
447
  const legacyRoot = path.join(pluginDir, 'evals');
1725
448
  if (fs.existsSync(legacyRoot)) {
1726
449
  error('Plugin-root evals/ is legacy; put evals/ inside its owning static or dynamic Skill directory.');
1727
450
  }
1728
- const skillRoots = [...collectDeclaredSkillNames(pluginDir, pluginManifest).all]
1729
- .sort()
1730
- .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) })) : [];
1731
454
  const seenSkills = new Set();
455
+ let manifestTools = null;
1732
456
  for (const owner of skillRoots) {
1733
457
  const evalDir = path.join(owner.root, 'evals');
1734
458
  const manifestPath = path.join(evalDir, 'manifest.json');
1735
459
  if (!fs.existsSync(manifestPath))
1736
460
  continue;
461
+ const manifestField = path.relative(pluginDir, manifestPath).split(path.sep).join('/');
1737
462
  if (seenSkills.has(owner.skill)) {
1738
463
  error(`Skill ${JSON.stringify(owner.skill)} has more than one evals/manifest.json owner`);
1739
464
  continue;
1740
465
  }
1741
466
  seenSkills.add(owner.skill);
1742
- validateOnePluginEvalManifest(pluginDir, pluginManifest, evalDir, owner.skill);
467
+ manifestTools ??= await loadSkillEvalManifestTools();
468
+ if (typeof manifestTools?.validateAwSkillEvalManifest !== 'function') {
469
+ error('Canonical AwSkillEvalManifest v1 validator is unavailable; run the current built aw CLI.');
470
+ continue;
471
+ }
472
+ const validation = await manifestTools.validateAwSkillEvalManifest({
473
+ plugin: {
474
+ rootDir: pluginDir,
475
+ manifestPath: path.join(pluginDir, '.agents-plugin', 'plugin.json'),
476
+ manifest: pluginManifest,
477
+ },
478
+ skill: owner.skill,
479
+ });
480
+ for (const message of validation.errors)
481
+ error(`${manifestField}: ${message}`);
1743
482
  }
1744
483
  }
1745
484
  function countCharacters(value) {
@@ -2015,7 +754,7 @@ function targetedPlatforms(manifest) {
2015
754
  platforms.push('claude');
2016
755
  if (isCodexTargeted(manifest))
2017
756
  platforms.push('codex');
2018
- return platforms.length > 0 ? platforms : ['claude', 'codex'];
757
+ return platforms;
2019
758
  }
2020
759
  // ---------------------------------------------------------------------------
2021
760
  // Supplemental checks (always run — not covered by CLI validator)
@@ -2035,7 +774,7 @@ function validateNoBuildOutputDirs(pluginDir) {
2035
774
  }
2036
775
  }
2037
776
  function validateDeclaredPathsExist(pluginDir, manifest) {
2038
- for (const field of ['skills', 'slashCommands', 'mcpServers', 'apps']) {
777
+ for (const field of ['skills', 'mcpServers']) {
2039
778
  if (!manifest[field])
2040
779
  continue;
2041
780
  const resolved = path.join(pluginDir, manifest[field]);
@@ -2044,7 +783,7 @@ function validateDeclaredPathsExist(pluginDir, manifest) {
2044
783
  }
2045
784
  }
2046
785
  }
2047
- function validateCanonicalSkillLayout(pluginDir, manifest) {
786
+ async function validateCanonicalSkillLayout(pluginDir, manifest) {
2048
787
  if (manifest.skills && normalizeRelativePath(manifest.skills) !== 'skills') {
2049
788
  error('skills must be "./skills"');
2050
789
  }
@@ -2057,18 +796,8 @@ function validateCanonicalSkillLayout(pluginDir, manifest) {
2057
796
  if (content.trim() === '')
2058
797
  error('Plugin root README.md must not be empty');
2059
798
  }
2060
- const declared = collectDeclaredSkillNames(pluginDir, manifest);
2061
- const sourceBackedDynamicSkills = (Array.isArray(manifest.artifacts?.targets)
2062
- ? manifest.artifacts.targets
2063
- : [])
2064
- .filter((target) => target &&
2065
- typeof target === 'object' &&
2066
- (target.target === 'codex.skill' || target.target === 'claude.skill') &&
2067
- typeof target.skillKey === 'string' &&
2068
- Array.isArray(target.sourceDirs) &&
2069
- target.sourceDirs.length > 0)
2070
- .map((target) => target.skillKey.trim());
2071
- for (const skill of new Set([...declared.static, ...sourceBackedDynamicSkills])) {
799
+ const declared = await collectDeclaredSkillNames(pluginDir, manifest);
800
+ for (const skill of declared.static) {
2072
801
  const skillRoot = path.join(pluginDir, 'skills', skill);
2073
802
  if (!fs.statSync(skillRoot, { throwIfNoEntry: false })?.isDirectory()) {
2074
803
  error(`Skill ${JSON.stringify(skill)} must use source root "./skills/${skill}"`);
@@ -2084,101 +813,36 @@ function validateCanonicalSkillLayout(pluginDir, manifest) {
2084
813
  error(`skills/${skill}/README.md must not be empty`);
2085
814
  }
2086
815
  }
2087
- const portableRoot = manifest.distributions?.agentSkills?.skills;
2088
- for (const skill of declared.portable) {
2089
- const skillRoot = path.join(pluginDir, portableRoot, skill);
2090
- const skillReadme = path.join(skillRoot, 'README.md');
2091
- if (!fs.statSync(skillReadme, { throwIfNoEntry: false })?.isFile()) {
2092
- error(`${normalizeRelativePath(path.join(portableRoot, skill, 'README.md'))} is required`);
2093
- continue;
2094
- }
2095
- if (fs.readFileSync(skillReadme, 'utf8').trim() === '') {
2096
- error(`${normalizeRelativePath(path.join(portableRoot, skill, 'README.md'))} must not be empty`);
2097
- }
2098
- }
2099
816
  }
2100
817
  function validateDeclaredNativeAssets(pluginDir, manifest) {
2101
- const defaults = [
2102
- ['skills', 'skills'],
2103
- [DEFAULT_SLASH_COMMANDS_DIR, 'slashCommands'],
2104
- ['.mcp.json', 'mcpServers'],
2105
- ['.app.json', 'apps'],
2106
- ];
2107
- for (const [filename, field] of defaults) {
818
+ for (const [filename, field] of [['skills', 'skills'], ['.mcp.json', 'mcpServers']]) {
2108
819
  const fullPath = path.join(pluginDir, filename);
2109
- if (fs.existsSync(fullPath) && !manifest[field]) {
2110
- if (field === 'skills') {
2111
- const dynamicSkills = new Set((Array.isArray(manifest.artifacts?.targets) ? manifest.artifacts.targets : [])
2112
- .filter((target) => {
2113
- if (!target ||
2114
- typeof target !== 'object' ||
2115
- (target.target !== 'codex.skill' && target.target !== 'claude.skill') ||
2116
- typeof target.skillKey !== 'string' ||
2117
- !Array.isArray(target.sourceDirs) ||
2118
- target.sourceDirs.length === 0)
2119
- return false;
2120
- return target.sourceDirs.every((sourceDir) => typeof sourceDir === 'string' &&
2121
- (normalizeRelativePath(sourceDir) === `skills/${target.skillKey}` ||
2122
- normalizeRelativePath(sourceDir).startsWith(`skills/${target.skillKey}/`)));
2123
- })
2124
- .map((target) => target.skillKey));
2125
- const entries = fs.readdirSync(fullPath, { withFileTypes: true });
2126
- if (entries.length > 0 &&
2127
- entries.every((entry) => entry.isDirectory() && dynamicSkills.has(entry.name))) {
2128
- continue;
2129
- }
2130
- }
2131
- 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;
2132
827
  }
828
+ error(`"${filename}" exists but manifest does not declare "${field}" or an artifacts.sourceDirs input`);
2133
829
  }
2134
830
  }
2135
- function collectDeclaredSkillNames(pluginDir, manifest) {
2136
- const skillsRoot = typeof manifest.skills === 'string'
2137
- ? path.join(pluginDir, manifest.skills)
2138
- : null;
2139
- const staticSkillNames = skillsRoot && fs.existsSync(skillsRoot)
2140
- ? fs.readdirSync(skillsRoot, { withFileTypes: true })
2141
- .filter((entry) => entry.isDirectory())
2142
- .map((entry) => entry.name)
2143
- .sort()
2144
- : [];
2145
- const staticSkillNameSet = new Set(staticSkillNames);
2146
- const artifactTargets = Array.isArray(manifest.artifacts?.targets)
2147
- ? manifest.artifacts.targets
2148
- : [];
2149
- const dynamicSkillNames = artifactTargets
2150
- .filter((target) => target
2151
- && typeof target === 'object'
2152
- && (target.target === 'codex.skill' || target.target === 'claude.skill')
2153
- && typeof target.skillKey === 'string'
2154
- && target.skillKey.trim() !== '')
2155
- .map((target) => target.skillKey.trim())
2156
- .sort();
2157
- const dynamicSkillNameSet = new Set(dynamicSkillNames);
2158
- const portableRoot = typeof manifest.distributions?.agentSkills?.skills === 'string'
2159
- ? path.join(pluginDir, manifest.distributions.agentSkills.skills)
2160
- : null;
2161
- const portableRootStats = portableRoot
2162
- ? fs.lstatSync(portableRoot, { throwIfNoEntry: false })
2163
- : null;
2164
- const portableSkillNameSet = new Set(portableRootStats?.isDirectory() && !portableRootStats.isSymbolicLink()
2165
- ? fs.readdirSync(portableRoot, { withFileTypes: true })
2166
- .filter((entry) => entry.isDirectory())
2167
- .map((entry) => entry.name)
2168
- : []);
2169
- return {
2170
- static: staticSkillNameSet,
2171
- dynamic: dynamicSkillNameSet,
2172
- portable: portableSkillNameSet,
2173
- all: new Set([...staticSkillNames, ...dynamicSkillNames]),
2174
- };
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) };
2175
842
  }
2176
843
  function isNodeRunnablePath(relativePath) {
2177
844
  return SCRIPT_NODE_EXTENSIONS.has(path.posix.extname(normalizeRelativePath(relativePath)));
2178
845
  }
2179
- function isAutoRunnablePath(relativePath) {
2180
- return SCRIPT_AUTO_EXTENSIONS.has(path.posix.extname(normalizeRelativePath(relativePath)).toLowerCase());
2181
- }
2182
846
  function normalizePluginScriptPath(pluginDir, value, fieldName) {
2183
847
  if (typeof value !== 'string' || value.trim() === '') {
2184
848
  error(`${fieldName} must be a non-empty string`);
@@ -2227,17 +891,11 @@ function validateScriptEntry(pluginDir, value, fieldName, options = {}) {
2227
891
  }
2228
892
  validateAllowedKeys(entry, fieldName, ['runner', 'path', 'args']);
2229
893
  const runner = validateManifestString(entry.runner, `${fieldName}.runner`);
2230
- if (runner && !SCRIPT_RUNNERS.has(runner)) {
2231
- error(`${fieldName}.runner has unsupported runner "${runner}"`);
2232
- }
2233
- if (options.requireNodeRunner && runner !== 'node') {
894
+ if (runner !== 'node') {
2234
895
  error(`${fieldName}.runner must be "node"`);
2235
896
  }
2236
897
  const relativePath = normalizePluginScriptPath(pluginDir, entry.path, `${fieldName}.path`);
2237
898
  validateDeclaredScriptFile(pluginDir, relativePath, `${fieldName}.path`);
2238
- if (runner === 'auto' && relativePath && !isAutoRunnablePath(relativePath)) {
2239
- error(`${fieldName}.path uses runner "auto" but has no supported extension (${[...SCRIPT_AUTO_EXTENSIONS].join(', ')})`);
2240
- }
2241
899
  if (options.requireNodePath && relativePath && !isNodeRunnablePath(relativePath)) {
2242
900
  error(`${fieldName}.path must use a Node runnable extension (.js, .mjs, or .cjs)`);
2243
901
  }
@@ -2255,51 +913,6 @@ function validateScriptEntry(pluginDir, value, fieldName, options = {}) {
2255
913
  }
2256
914
  return runner && relativePath ? { runner, path: relativePath } : null;
2257
915
  }
2258
- function validateLifecycleDefinition(pluginDir, value, fieldName, runtimeEntries) {
2259
- if (typeof value === 'string') {
2260
- const relativePath = normalizePluginScriptPath(pluginDir, value, fieldName);
2261
- validateDeclaredScriptFile(pluginDir, relativePath, fieldName);
2262
- if (relativePath && !isAutoRunnablePath(relativePath)) {
2263
- error(`${fieldName} uses runner "auto" but has no supported extension (${[...SCRIPT_AUTO_EXTENSIONS].join(', ')})`);
2264
- }
2265
- if (relativePath && isNodeRunnablePath(relativePath)) {
2266
- runtimeEntries.push({ path: relativePath, fieldName });
2267
- }
2268
- return { default: relativePath ? { runner: 'auto', path: relativePath } : null };
2269
- }
2270
- const selector = expectRecord(value, fieldName);
2271
- if (!selector)
2272
- return {};
2273
- if ('runner' in selector || 'path' in selector || 'command' in selector) {
2274
- error(`${fieldName} must declare lifecycle scripts under OS selectors`);
2275
- }
2276
- for (const selectorName of Object.keys(selector)) {
2277
- if (!SCRIPT_OS_SELECTORS.has(selectorName)) {
2278
- error(`${fieldName} has unknown OS selector "${selectorName}"`);
2279
- }
2280
- }
2281
- const normalized = {};
2282
- for (const [selectorName, entryValue] of Object.entries(selector)) {
2283
- const entry = validateScriptEntry(pluginDir, entryValue, `${fieldName}.${selectorName}`);
2284
- if (entry) {
2285
- normalized[selectorName] = entry;
2286
- if (entry.runner === 'node' || (entry.runner === 'auto' && isNodeRunnablePath(entry.path))) {
2287
- runtimeEntries.push({ path: entry.path, fieldName: `${fieldName}.${selectorName}.path` });
2288
- }
2289
- }
2290
- }
2291
- const orders = {
2292
- linux: ['linux', 'unix', 'default'],
2293
- darwin: ['darwin', 'unix', 'default'],
2294
- win32: ['win32', 'windows', 'default'],
2295
- };
2296
- for (const [osName, order] of Object.entries(orders)) {
2297
- if (!order.some((selectorName) => normalized[selectorName])) {
2298
- error(`${fieldName} must include an entry that resolves on ${osName}`);
2299
- }
2300
- }
2301
- return normalized;
2302
- }
2303
916
  function isNonRegistryDependencySpecifier(specifier) {
2304
917
  const trimmed = String(specifier).trim();
2305
918
  return (/^(?:workspace|file|link|portal):/i.test(trimmed) ||
@@ -2437,6 +1050,12 @@ function scanNodeImportContract(pluginDir, entryPaths, options) {
2437
1050
  continue;
2438
1051
  }
2439
1052
  if (!resolved.path) {
1053
+ const requested = path.posix.normalize(path.posix.join(path.posix.dirname(relativePath), specifier));
1054
+ if (options.nativeToolReader && requested === options.nativeToolReader)
1055
+ continue;
1056
+ if ((options.runtimeConfigSkillRoots ?? []).some((root) => (relativePath.startsWith(`${root}/`)
1057
+ && requested === path.posix.join(root, AW_RUNTIME_CONFIG_READER_PATH))))
1058
+ continue;
2440
1059
  error(`${options.label}: unable to resolve relative import "${specifier}" from "${relativePath}"`);
2441
1060
  continue;
2442
1061
  }
@@ -2462,613 +1081,79 @@ function scanNodeImportContract(pluginDir, entryPaths, options) {
2462
1081
  if (!options.allowDevDependencies) {
2463
1082
  error(`${options.label}: runtime import "${specifier}" from "${relativePath}" uses dev dependency "${packageName}"`);
2464
1083
  }
2465
- continue;
2466
- }
2467
- error(`${options.label}: import "${specifier}" from "${relativePath}" is not declared in dependencies`);
2468
- }
2469
- }
2470
- }
2471
- function listFilesRecursive(rootDir) {
2472
- const output = [];
2473
- if (!fs.existsSync(rootDir))
2474
- return output;
2475
- const walk = (dir) => {
2476
- for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
2477
- const absolutePath = path.join(dir, entry.name);
2478
- if (entry.isDirectory()) {
2479
- walk(absolutePath);
2480
- }
2481
- else if (entry.isFile()) {
2482
- output.push(normalizeRelativePath(path.relative(rootDir, absolutePath)));
2483
- }
2484
- }
2485
- };
2486
- walk(rootDir);
2487
- return output;
2488
- }
2489
- function validateConfigValueLightweight(field, value, fieldName) {
2490
- if (!isRecord(field) || !CONFIG_FIELD_TYPES.has(field.type))
2491
- return;
2492
- if (field.type === 'string' || field.type === 'file' || field.type === 'directory') {
2493
- validateManifestString(value, fieldName);
2494
- return;
2495
- }
2496
- if (field.type === 'boolean') {
2497
- if (typeof value !== 'boolean') {
2498
- error(`${fieldName} must be a boolean`);
2499
- }
2500
- return;
2501
- }
2502
- if (field.type === 'number') {
2503
- if (typeof value !== 'number' || !Number.isFinite(value)) {
2504
- error(`${fieldName} must be a finite number`);
2505
- return;
2506
- }
2507
- if (typeof field.min === 'number' && value < field.min) {
2508
- error(`${fieldName} must be greater than or equal to ${field.min}`);
2509
- }
2510
- if (typeof field.max === 'number' && value > field.max) {
2511
- error(`${fieldName} must be less than or equal to ${field.max}`);
2512
- }
2513
- return;
2514
- }
2515
- if (field.type === 'enum') {
2516
- if (typeof value !== 'string' || !Array.isArray(field.values) || !field.values.includes(value)) {
2517
- error(`${fieldName} must be one of config schema values`);
2518
- }
2519
- }
2520
- }
2521
- function validateConfigPresentationLightweight(presentation, schema) {
2522
- if (presentation === undefined)
2523
- return;
2524
- const root = expectRecord(presentation, 'config.presentation');
2525
- if (!root)
2526
- return;
2527
- validateAllowedKeys(root, 'config.presentation', ['groups', 'fields', 'presets']);
2528
- const schemaKeys = new Set(Object.keys(schema));
2529
- if (root.groups !== undefined) {
2530
- if (!Array.isArray(root.groups)) {
2531
- error('config.presentation.groups must be an array');
2532
- }
2533
- else {
2534
- const groupIds = new Set();
2535
- const groupedFields = new Set();
2536
- root.groups.forEach((rawGroup, index) => {
2537
- const fieldName = `config.presentation.groups[${index}]`;
2538
- const group = expectRecord(rawGroup, fieldName);
2539
- if (!group)
2540
- return;
2541
- validateAllowedKeys(group, fieldName, ['id', 'title', 'description', 'fields', 'advanced']);
2542
- const validId = validateManifestString(group.id, `${fieldName}.id`);
2543
- const id = validId ? group.id : null;
2544
- if (id && groupIds.has(id)) {
2545
- error(`${fieldName}.id has duplicate group id "${id}"`);
2546
- }
2547
- else if (id) {
2548
- groupIds.add(id);
2549
- }
2550
- validateManifestString(group.title, `${fieldName}.title`);
2551
- if (group.description !== undefined) {
2552
- validateManifestString(group.description, `${fieldName}.description`);
2553
- }
2554
- if (group.advanced !== undefined && typeof group.advanced !== 'boolean') {
2555
- error(`${fieldName}.advanced must be a boolean`);
2556
- }
2557
- if (!Array.isArray(group.fields)) {
2558
- error(`${fieldName}.fields must be an array`);
2559
- return;
2560
- }
2561
- group.fields.forEach((key, fieldIndex) => {
2562
- const keyFieldName = `${fieldName}.fields[${fieldIndex}]`;
2563
- const validKey = validateManifestString(key, keyFieldName);
2564
- if (!validKey)
2565
- return;
2566
- if (!schemaKeys.has(key)) {
2567
- error(`${keyFieldName} references unknown config key "${key}"`);
2568
- }
2569
- if (groupedFields.has(key)) {
2570
- error(`${keyFieldName} assigns config key "${key}" to more than one group`);
2571
- }
2572
- else {
2573
- groupedFields.add(key);
2574
- }
2575
- });
2576
- });
2577
- }
2578
- }
2579
- if (root.fields !== undefined) {
2580
- const fields = expectRecord(root.fields, 'config.presentation.fields');
2581
- if (fields) {
2582
- for (const [key, rawField] of Object.entries(fields)) {
2583
- const fieldName = `config.presentation.fields.${key}`;
2584
- const schemaField = schema[key];
2585
- if (!schemaKeys.has(key)) {
2586
- error(`config.presentation.fields references unknown config key "${key}"`);
2587
- }
2588
- const field = expectRecord(rawField, fieldName);
2589
- if (!field)
2590
- continue;
2591
- validateAllowedKeys(field, fieldName, [
2592
- 'valueLabels',
2593
- 'recommendedValue',
2594
- 'placeholder',
2595
- 'unit',
2596
- 'advanced',
2597
- ]);
2598
- if (field.placeholder !== undefined) {
2599
- validateManifestString(field.placeholder, `${fieldName}.placeholder`);
2600
- }
2601
- if (field.unit !== undefined) {
2602
- validateManifestString(field.unit, `${fieldName}.unit`);
2603
- }
2604
- if (field.advanced !== undefined && typeof field.advanced !== 'boolean') {
2605
- error(`${fieldName}.advanced must be a boolean`);
2606
- }
2607
- if (field.valueLabels !== undefined) {
2608
- const labels = expectRecord(field.valueLabels, `${fieldName}.valueLabels`);
2609
- if (isRecord(schemaField) && schemaField.type !== 'enum') {
2610
- error(`${fieldName}.valueLabels is only supported for enum config`);
2611
- }
2612
- if (labels) {
2613
- for (const [token, label] of Object.entries(labels)) {
2614
- if (!isRecord(schemaField) || !Array.isArray(schemaField.values) || !schemaField.values.includes(token)) {
2615
- error(`${fieldName}.valueLabels references unknown enum token "${token}"`);
2616
- }
2617
- validateManifestString(label, `${fieldName}.valueLabels.${token}`);
2618
- }
2619
- }
2620
- }
2621
- if (field.recommendedValue !== undefined) {
2622
- validateConfigValueLightweight(schemaField, field.recommendedValue, `${fieldName}.recommendedValue`);
2623
- }
2624
- }
2625
- }
2626
- }
2627
- if (root.presets !== undefined) {
2628
- if (!Array.isArray(root.presets)) {
2629
- error('config.presentation.presets must be an array');
2630
- }
2631
- else {
2632
- const presetIds = new Set();
2633
- root.presets.forEach((rawPreset, index) => {
2634
- const fieldName = `config.presentation.presets[${index}]`;
2635
- const preset = expectRecord(rawPreset, fieldName);
2636
- if (!preset)
2637
- return;
2638
- validateAllowedKeys(preset, fieldName, ['id', 'title', 'description', 'values']);
2639
- const validId = validateManifestString(preset.id, `${fieldName}.id`);
2640
- const id = validId ? preset.id : null;
2641
- if (id && presetIds.has(id)) {
2642
- error(`${fieldName}.id has duplicate preset id "${id}"`);
2643
- }
2644
- else if (id) {
2645
- presetIds.add(id);
2646
- }
2647
- validateManifestString(preset.title, `${fieldName}.title`);
2648
- if (preset.description !== undefined) {
2649
- validateManifestString(preset.description, `${fieldName}.description`);
2650
- }
2651
- const values = expectRecord(preset.values, `${fieldName}.values`);
2652
- if (!values)
2653
- return;
2654
- for (const [key, value] of Object.entries(values)) {
2655
- if (!schemaKeys.has(key)) {
2656
- error(`${fieldName}.values references unknown config key "${key}"`);
2657
- continue;
2658
- }
2659
- const schemaField = schema[key];
2660
- if (isRecord(schemaField)
2661
- && (schemaField.sensitive === true
2662
- || schemaField.type === 'file'
2663
- || schemaField.type === 'directory')) {
2664
- error(`${fieldName}.values.${key} cannot contain sensitive, file, or directory config values`);
2665
- continue;
2666
- }
2667
- validateConfigValueLightweight(schemaField, value, `${fieldName}.values.${key}`);
2668
- }
2669
- });
2670
- }
2671
- }
2672
- }
2673
- function validateConfigSchemaLightweight(config) {
2674
- if (config === undefined)
2675
- return;
2676
- const configRoot = expectRecord(config, 'config');
2677
- if (!configRoot)
2678
- return;
2679
- validateAllowedKeys(configRoot, 'config', ['schema', 'presentation']);
2680
- const schema = expectRecord(configRoot.schema, 'config.schema');
2681
- if (!schema)
2682
- return;
2683
- for (const [key, rawField] of Object.entries(schema)) {
2684
- if (!/^[A-Za-z][A-Za-z0-9_]*$/.test(key)) {
2685
- error(`config.schema has invalid key "${key}"`);
2686
- }
2687
- const fieldName = `config.schema.${key}`;
2688
- const field = expectRecord(rawField, fieldName);
2689
- if (!field)
2690
- continue;
2691
- validateAllowedKeys(field, fieldName, [
2692
- 'type',
2693
- 'title',
2694
- 'description',
2695
- 'default',
2696
- 'required',
2697
- 'sensitive',
2698
- 'values',
2699
- 'min',
2700
- 'max',
2701
- ]);
2702
- if (typeof field.type !== 'string' || !CONFIG_FIELD_TYPES.has(field.type)) {
2703
- error(`${fieldName}.type must be string, number, boolean, enum, file, or directory`);
2704
- }
2705
- if (field.required !== undefined && typeof field.required !== 'boolean') {
2706
- error(`${fieldName}.required must be a boolean`);
2707
- }
2708
- if (field.sensitive !== undefined && typeof field.sensitive !== 'boolean') {
2709
- error(`${fieldName}.sensitive must be a boolean`);
2710
- }
2711
- if (field.values !== undefined) {
2712
- if (field.type !== 'enum' || !Array.isArray(field.values) || field.values.length === 0) {
2713
- error(`${fieldName}.values is only supported for enum config and must be non-empty`);
2714
- }
2715
- }
2716
- else if (field.type === 'enum') {
2717
- error(`${fieldName}.values is required for enum config`);
2718
- }
2719
- if (field.type !== 'number' && (field.min !== undefined || field.max !== undefined)) {
2720
- error(`${fieldName}.min/max are only supported for number config`);
2721
- }
2722
- if (field.min !== undefined && typeof field.min !== 'number') {
2723
- error(`${fieldName}.min must be a number`);
2724
- }
2725
- if (field.max !== undefined && typeof field.max !== 'number') {
2726
- error(`${fieldName}.max must be a number`);
2727
- }
2728
- if (typeof field.min === 'number' && typeof field.max === 'number' && field.min > field.max) {
2729
- error(`${fieldName}.min must be less than or equal to max`);
2730
- }
2731
- }
2732
- validateConfigPresentationLightweight(configRoot.presentation, schema);
2733
- }
2734
- function configSchemaKeys(manifest) {
2735
- const schema = manifest.config?.schema;
2736
- return isRecord(schema) ? new Set(Object.keys(schema)) : new Set();
2737
- }
2738
- function configSchemaField(manifest, key) {
2739
- const field = manifest.config?.schema?.[key];
2740
- return isRecord(field) ? field : null;
2741
- }
2742
- function defaultConfigValues(manifest) {
2743
- const schema = manifest.config?.schema;
2744
- const values = {};
2745
- if (!isRecord(schema))
2746
- return values;
2747
- for (const [key, field] of Object.entries(schema)) {
2748
- if (isRecord(field) && Object.prototype.hasOwnProperty.call(field, 'default')) {
2749
- values[key] = field.default;
2750
- }
2751
- }
2752
- return values;
2753
- }
2754
- function validateArtifactId(value, fieldName) {
2755
- const id = validateManifestString(value, fieldName);
2756
- if (!id)
2757
- return null;
2758
- if (!/^[A-Za-z][A-Za-z0-9_.-]*$/.test(id)) {
2759
- error(`${fieldName}: expected a stable id using letters, numbers, ".", "_" or "-"`);
2760
- }
2761
- return id;
2762
- }
2763
- function validateCodexRoleKey(value, fieldName) {
2764
- const roleKey = validateManifestString(value, fieldName);
2765
- if (!roleKey)
2766
- return null;
2767
- if (!/^[A-Za-z][A-Za-z0-9_-]*$/.test(roleKey)) {
2768
- error(`${fieldName}: expected a valid Codex role key`);
2769
- }
2770
- return roleKey;
2771
- }
2772
- function validateCodexSkillKey(value, fieldName) {
2773
- const skillKey = validateManifestString(value, fieldName);
2774
- if (!skillKey)
2775
- return null;
2776
- if (!/^[A-Za-z][A-Za-z0-9_-]*$/.test(skillKey)) {
2777
- error(`${fieldName}: expected a valid Codex skill key`);
2778
- }
2779
- return skillKey;
2780
- }
2781
- function validatePortableSkillKey(value, fieldName) {
2782
- const skillKey = validateManifestString(value, fieldName);
2783
- if (!skillKey)
2784
- return null;
2785
- if (skillKey.length > MAX_SKILL_NAME_LEN || !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(skillKey)) {
2786
- error(`${fieldName}: expected at most 64 ASCII lowercase hyphen-case characters`);
2787
- }
2788
- return skillKey;
2789
- }
2790
- function validateStringArray(value, fieldName, options = {}) {
2791
- if (!Array.isArray(value)) {
2792
- error(`${fieldName} must be an array`);
2793
- return [];
2794
- }
2795
- const output = [];
2796
- for (const [index, entry] of value.entries()) {
2797
- const itemFieldName = `${fieldName}[${index}]`;
2798
- if (typeof entry !== 'string' || entry.trim() === '') {
2799
- error(`${itemFieldName} must be a non-empty string`);
2800
- continue;
2801
- }
2802
- if (options.allowed && !options.allowed.has(entry)) {
2803
- error(`${itemFieldName}: unsupported ${options.label ?? 'value'} "${entry}"`);
2804
- continue;
2805
- }
2806
- if (!output.includes(entry))
2807
- output.push(entry);
2808
- }
2809
- if (options.requireNonEmpty && output.length === 0) {
2810
- error(`${fieldName} must contain at least one value`);
2811
- }
2812
- return output;
2813
- }
2814
- function validateArtifactTargetEntry(entry, index, manifest, seen, pluginDir) {
2815
- const fieldName = `artifacts.targets[${index}]`;
2816
- const target = expectRecord(entry, fieldName);
2817
- if (!target)
2818
- return null;
2819
- validateAllowedKeys(target, fieldName, [
2820
- 'id',
2821
- 'platform',
2822
- 'distribution',
2823
- 'scopes',
2824
- 'target',
2825
- 'kind',
2826
- 'projectManagedKind',
2827
- 'states',
2828
- 'refreshKeys',
2829
- 'requiresCodexProjectConfig',
2830
- 'roleKey',
2831
- 'skillKey',
2832
- 'sourceDirs',
2833
- 'runtimeImports',
2834
- ]);
2835
- const id = validateArtifactId(target.id, `${fieldName}.id`);
2836
- const artifactTarget = validateManifestString(target.target, `${fieldName}.target`);
2837
- if (artifactTarget && !ARTIFACT_TARGETS.has(artifactTarget)) {
2838
- error(`${fieldName}.target: unsupported artifact target "${artifactTarget}"`);
2839
- }
2840
- const portable = artifactTarget === 'agent-skills.skill';
2841
- const platform = portable || target.platform === undefined
2842
- ? undefined
2843
- : validateManifestString(target.platform, `${fieldName}.platform`);
2844
- const distribution = portable || target.distribution !== undefined
2845
- ? validateManifestString(target.distribution, `${fieldName}.distribution`)
2846
- : undefined;
2847
- if (portable) {
2848
- if (distribution !== 'agent-skills') {
2849
- error(`${fieldName}.distribution: expected "agent-skills"`);
2850
- }
2851
- if (target.platform !== undefined) {
2852
- error(`${fieldName}.platform: distribution targets do not support platform`);
2853
- }
2854
- }
2855
- else {
2856
- const expectedPlatform = artifactTarget === 'claude.skill' ? 'claude' : 'codex';
2857
- if (platform && artifactTarget && platform !== expectedPlatform) {
2858
- error(`${fieldName}.platform: target "${artifactTarget}" must use "${expectedPlatform}"`);
2859
- }
2860
- if (target.distribution !== undefined) {
2861
- error(`${fieldName}.distribution: platform targets do not support distribution`);
2862
- }
2863
- }
2864
- const key = id && artifactTarget ? `${id}:${artifactTarget}` : null;
2865
- if (key) {
2866
- if (seen.has(key)) {
2867
- error(`${fieldName}: duplicate artifact id + target "${key}"`);
2868
- }
2869
- seen.add(key);
2870
- }
2871
- const expectedKind = ARTIFACT_KIND_BY_TARGET[artifactTarget];
2872
- const kind = target.kind === undefined
2873
- ? expectedKind
2874
- : validateManifestString(target.kind, `${fieldName}.kind`);
2875
- if (kind && !ARTIFACT_KINDS.has(kind)) {
2876
- error(`${fieldName}.kind: unsupported artifact kind "${kind}"`);
2877
- }
2878
- if (expectedKind && kind && kind !== expectedKind) {
2879
- error(`${fieldName}.kind: target "${artifactTarget}" requires kind "${expectedKind}"`);
2880
- }
2881
- const expectedProjectManagedKind = ARTIFACT_PROJECT_MANAGED_KIND_BY_TARGET[artifactTarget];
2882
- const projectManagedKind = target.projectManagedKind === undefined
2883
- ? expectedProjectManagedKind
2884
- : validateManifestString(target.projectManagedKind, `${fieldName}.projectManagedKind`);
2885
- if (projectManagedKind && !ARTIFACT_PROJECT_MANAGED_KINDS.has(projectManagedKind)) {
2886
- error(`${fieldName}.projectManagedKind: unsupported Codex project managed kind "${projectManagedKind}"`);
2887
- }
2888
- if (expectedProjectManagedKind &&
2889
- projectManagedKind &&
2890
- projectManagedKind !== expectedProjectManagedKind) {
2891
- error(`${fieldName}.projectManagedKind: target "${artifactTarget}" must map to "${expectedProjectManagedKind}"`);
2892
- }
2893
- if (!expectedProjectManagedKind && projectManagedKind) {
2894
- error(`${fieldName}.projectManagedKind: target "${artifactTarget}" does not support projectManagedKind`);
2895
- }
2896
- const scopes = validateStringArray(target.scopes, `${fieldName}.scopes`, {
2897
- allowed: ARTIFACT_SCOPES,
2898
- label: 'artifact scope',
2899
- requireNonEmpty: true,
2900
- });
2901
- const states = validateStringArray(target.states, `${fieldName}.states`, {
2902
- allowed: ARTIFACT_STATES,
2903
- label: 'artifact state',
2904
- requireNonEmpty: true,
2905
- });
2906
- const refreshKeys = validateStringArray(target.refreshKeys, `${fieldName}.refreshKeys`);
2907
- const schemaKeys = configSchemaKeys(manifest);
2908
- for (const [refreshIndex, refreshKey] of refreshKeys.entries()) {
2909
- if (!schemaKeys.has(refreshKey)) {
2910
- error(`${fieldName}.refreshKeys[${refreshIndex}]: unknown config key "${refreshKey}"`);
2911
- continue;
2912
- }
2913
- const field = configSchemaField(manifest, refreshKey);
2914
- if (scopes.includes('project') &&
2915
- (field?.type === 'file' || field?.type === 'directory')) {
2916
- error(`${fieldName}.refreshKeys[${refreshIndex}]: project-scope repo-visible artifacts cannot depend on "${field.type}" config key "${refreshKey}"; use a portable string key or keep the path in user/project local config for lifecycle/helper code.`);
2917
- }
2918
- }
2919
- if (target.requiresCodexProjectConfig !== undefined &&
2920
- typeof target.requiresCodexProjectConfig !== 'boolean') {
2921
- error(`${fieldName}.requiresCodexProjectConfig must be a boolean`);
2922
- }
2923
- if (artifactTarget === 'codex.skill' && target.requiresCodexProjectConfig === true) {
2924
- error(`${fieldName}.requiresCodexProjectConfig: codex.skill writes the skill runtime and must not require Codex project config preflight`);
2925
- }
2926
- if ((platform === 'claude' || portable) && target.requiresCodexProjectConfig !== undefined) {
2927
- error(`${fieldName}.requiresCodexProjectConfig: this target does not support the field`);
2928
- }
2929
- let roleKey;
2930
- let skillKey;
2931
- if (artifactTarget === 'codex.agentRole') {
2932
- roleKey = validateCodexRoleKey(target.roleKey, `${fieldName}.roleKey`);
2933
- if (!roleKey) {
2934
- error(`${fieldName}.roleKey: codex.agentRole targets must declare a static roleKey`);
2935
- }
2936
- }
2937
- else if (target.roleKey !== undefined) {
2938
- error(`${fieldName}.roleKey: roleKey is only supported for codex.agentRole targets`);
2939
- }
2940
- if (artifactTarget === 'codex.skill' || artifactTarget === 'claude.skill' || portable) {
2941
- skillKey = portable
2942
- ? validatePortableSkillKey(target.skillKey, `${fieldName}.skillKey`)
2943
- : validateCodexSkillKey(target.skillKey, `${fieldName}.skillKey`);
2944
- if (!skillKey) {
2945
- error(`${fieldName}.skillKey: ${artifactTarget} targets must declare a static skillKey`);
2946
- }
2947
- }
2948
- else if (target.skillKey !== undefined) {
2949
- error(`${fieldName}.skillKey: skillKey is only supported for skill targets`);
2950
- }
2951
- const normalizedSourceDirs = Array.isArray(target.sourceDirs)
2952
- ? target.sourceDirs
2953
- .filter((sourceDir) => typeof sourceDir === 'string' && sourceDir.trim() !== '')
2954
- .map((sourceDir) => path.posix.normalize(sourceDir))
2955
- : [];
2956
- if (new Set(normalizedSourceDirs).size !== normalizedSourceDirs.length) {
2957
- error(`${fieldName}.sourceDirs must not contain duplicate directories`);
2958
- }
2959
- const sourceDirs = target.sourceDirs === undefined
2960
- ? []
2961
- : validateStringArray(target.sourceDirs, `${fieldName}.sourceDirs`);
2962
- if (sourceDirs.length > 0 && artifactTarget !== 'codex.skill' && artifactTarget !== 'claude.skill' && !portable) {
2963
- error(`${fieldName}.sourceDirs: sourceDirs are only supported for skill targets`);
2964
- }
2965
- for (const [sourceIndex, sourceDir] of sourceDirs.entries()) {
2966
- const sourceField = `${fieldName}.sourceDirs[${sourceIndex}]`;
2967
- if (!sourceDir.startsWith('./') || path.posix.isAbsolute(sourceDir)) {
2968
- error(`${sourceField} must start with "./" and stay inside the plugin root`);
2969
- continue;
2970
- }
2971
- const normalized = path.posix.normalize(sourceDir);
2972
- if (normalized === '.' || normalized === '..' || normalized.startsWith('../')) {
2973
- error(`${sourceField} must stay inside the plugin root`);
2974
- continue;
2975
- }
2976
- const stats = fs.lstatSync(path.join(pluginDir, normalized), { throwIfNoEntry: false });
2977
- if (!stats?.isDirectory() || stats.isSymbolicLink()) {
2978
- error(`${sourceField} must point to an existing directory`);
2979
- }
2980
- if (skillKey && !portable &&
2981
- normalized !== `skills/${skillKey}` &&
2982
- !normalized.startsWith(`skills/${skillKey}/`)) {
2983
- error(`${sourceField} must stay inside "./skills/${skillKey}"`);
2984
- }
2985
- if (skillKey && !portable &&
2986
- isSkillAuthorOnlyPath(path.posix.relative(`skills/${skillKey}`, normalized))) {
2987
- error(`${sourceField} must not point inside an author-only Skill directory`);
1084
+ continue;
1085
+ }
1086
+ error(`${options.label}: import "${specifier}" from "${relativePath}" is not declared in dependencies`);
2988
1087
  }
2989
1088
  }
2990
- if (skillKey && !portable &&
2991
- sourceDirs.length > 0 &&
2992
- !normalizedSourceDirs.includes(`skills/${skillKey}`)) {
2993
- error(`${fieldName}.sourceDirs must include "./skills/${skillKey}" so README.md is published`);
2994
- }
2995
- return {
2996
- id,
2997
- platform,
2998
- distribution,
2999
- scopes,
3000
- target: artifactTarget,
3001
- kind,
3002
- projectManagedKind,
3003
- states,
3004
- refreshKeys,
3005
- roleKey,
3006
- skillKey,
3007
- sourceDirs,
3008
- runtimeImports: Array.isArray(target.runtimeImports) ? target.runtimeImports : [],
3009
- };
3010
1089
  }
3011
- function validateArtifactsConfigLightweight(pluginDir, manifest) {
3012
- if (manifest.artifacts === undefined)
3013
- return [];
3014
- const artifacts = expectRecord(manifest.artifacts, 'artifacts');
3015
- if (!artifacts)
3016
- return [];
3017
- validateAllowedKeys(artifacts, 'artifacts', ['targets']);
3018
- if (artifacts.targets === undefined)
3019
- return [];
3020
- if (!Array.isArray(artifacts.targets)) {
3021
- error('artifacts.targets must be an array');
3022
- return [];
3023
- }
3024
- const seen = new Set();
3025
- const declarations = artifacts.targets
3026
- .map((entry, index) => validateArtifactTargetEntry(entry, index, manifest, seen, pluginDir))
3027
- .filter(Boolean);
3028
- const owners = new Map();
3029
- for (const declaration of declarations) {
3030
- if ((declaration.target !== 'codex.skill' && declaration.target !== 'claude.skill' && declaration.target !== 'agent-skills.skill') ||
3031
- !declaration.skillKey) {
3032
- continue;
3033
- }
3034
- for (const scope of declaration.scopes) {
3035
- const ownerKey = `${declaration.platform ?? declaration.distribution}:${scope}:${declaration.skillKey}`;
3036
- const existing = owners.get(ownerKey);
3037
- if (existing) {
3038
- error(`artifacts.targets has duplicate skill ownership "${ownerKey}" in artifacts "${existing}" and "${declaration.id}"`);
1090
+ function listFilesRecursive(rootDir) {
1091
+ const output = [];
1092
+ if (!fs.existsSync(rootDir))
1093
+ return output;
1094
+ const walk = (dir) => {
1095
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
1096
+ const absolutePath = path.join(dir, entry.name);
1097
+ if (entry.isDirectory()) {
1098
+ walk(absolutePath);
3039
1099
  }
3040
- else {
3041
- owners.set(ownerKey, declaration.id);
1100
+ else if (entry.isFile()) {
1101
+ output.push(normalizeRelativePath(path.relative(rootDir, absolutePath)));
3042
1102
  }
3043
1103
  }
3044
- }
3045
- return declarations;
1104
+ };
1105
+ walk(rootDir);
1106
+ return output;
3046
1107
  }
3047
- function validateArtifactPlanRefreshKeys(refreshKeys, declaration, fieldName) {
3048
- const keys = validateStringArray(refreshKeys, `${fieldName}.refreshKeys`);
3049
- for (const [index, key] of keys.entries()) {
3050
- if (!declaration.refreshKeys.includes(key)) {
3051
- error(`${fieldName}.refreshKeys[${index}]: "${key}" is not declared for artifact "${declaration.id}"`);
3052
- }
1108
+ function validateConfigSchemaLightweight(config, manifest) {
1109
+ if (config === undefined)
1110
+ return;
1111
+ try {
1112
+ normalizePluginConfigDefinition(config, 'config', {
1113
+ plugin: manifest.name, dependencies: manifest.dependencies ?? [],
1114
+ });
3053
1115
  }
3054
- for (const declaredKey of declaration.refreshKeys) {
3055
- if (!keys.includes(declaredKey)) {
3056
- error(`${fieldName}: artifact "${declaration.id}" must preserve declared refresh key "${declaredKey}"`);
1116
+ catch (validationError) {
1117
+ error(validationError instanceof Error ? validationError.message : String(validationError));
1118
+ }
1119
+ }
1120
+ function defaultConfigValues(manifest, platform) {
1121
+ const schema = compilePluginConfigDefinition(manifest.config ?? { fields: {} }, platform).fields;
1122
+ const values = {};
1123
+ if (!isRecord(schema))
1124
+ return values;
1125
+ for (const [key, field] of Object.entries(schema)) {
1126
+ if (isRecord(field) && field.default !== undefined) {
1127
+ values[key] = field.default;
3057
1128
  }
3058
1129
  }
1130
+ return values;
1131
+ }
1132
+ function hasCrossPluginValueRef(value) {
1133
+ if (!isRecord(value))
1134
+ return false;
1135
+ if (isRecord(value.valueRef) && value.valueRef.plugin !== undefined)
1136
+ return true;
1137
+ return Object.values(value).some((child) => Array.isArray(child)
1138
+ ? child.some(hasCrossPluginValueRef) : hasCrossPluginValueRef(child));
3059
1139
  }
3060
- function isValidArtifactFilePath(relativePath) {
3061
- return (relativePath.trim() !== '' &&
3062
- !relativePath.includes('\\') &&
3063
- !relativePath.startsWith('/') &&
3064
- path.posix.normalize(relativePath) === relativePath &&
3065
- !relativePath.split('/').some((segment) => segment === '' || segment === '.' || segment === '..'));
1140
+ function configFieldContainsSensitiveValue(field) {
1141
+ if (!isRecord(field))
1142
+ return false;
1143
+ if (field.sensitive === true)
1144
+ return true;
1145
+ if (field.type !== 'object')
1146
+ return false;
1147
+ return ((isRecord(field.properties)
1148
+ && Object.values(field.properties).some((child) => isRecord(child) && child.sensitive === true))
1149
+ || (isRecord(field.additionalProperties)
1150
+ && field.additionalProperties.sensitive === true));
3066
1151
  }
3067
1152
  function isSkillAuthorOnlyPath(relativePath) {
3068
1153
  const [topLevel] = relativePath.split('/').filter(Boolean);
3069
1154
  return topLevel === 'evals' || topLevel === 'reports';
3070
1155
  }
3071
- function collectArtifactSourceFiles(rootDir, fieldName, files) {
1156
+ function collectArtifactSourceFiles(rootDir, fieldName, files, transform = (_relative, bytes) => bytes) {
3072
1157
  const rootStats = fs.lstatSync(rootDir, { throwIfNoEntry: false });
3073
1158
  if (!rootStats?.isDirectory() || rootStats.isSymbolicLink())
3074
1159
  return;
@@ -3092,39 +1177,21 @@ function collectArtifactSourceFiles(rootDir, fieldName, files) {
3092
1177
  error(`${fieldName} contains unsupported non-regular file "${relativePath}"`);
3093
1178
  continue;
3094
1179
  }
3095
- files.set(relativePath, fs.readFileSync(absolutePath));
1180
+ files.set(relativePath, transform(relativePath, fs.readFileSync(absolutePath)));
3096
1181
  }
3097
1182
  };
3098
1183
  visit(rootDir, '');
3099
1184
  }
3100
- function findArtifactFilePrefixConflict(files) {
3101
- const paths = [...files.keys()].sort();
3102
- for (const [index, relativePath] of paths.entries()) {
3103
- const prefix = paths.slice(0, index).find((candidate) => relativePath.startsWith(`${candidate}/`));
3104
- if (prefix)
3105
- return [prefix, relativePath];
3106
- }
3107
- return null;
3108
- }
3109
- function authorRuntimeImportKey(artifactId, importIndex) {
3110
- return `${artifactId}\0${importIndex}`;
3111
- }
3112
1185
  async function resolveAuthorRuntimeImports(options) {
3113
- const artifactImports = (options.manifest.artifacts?.targets ?? []).flatMap((target) => (target.runtimeImports ?? []).map((reference, importIndex) => ({
3114
- key: authorRuntimeImportKey(target.id, importIndex),
3115
- label: `artifacts target ${JSON.stringify(target.id)} runtime import ${JSON.stringify(reference.name)}`,
3116
- purpose: 'artifact-runtime',
3117
- reference,
3118
- })));
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
+ }));
3119
1191
  const skillRuntimeImports = (options.manifest.buildConfig?.skillRuntimeFiles ?? []).flatMap((entry, importIndex) => {
3120
1192
  if (!isRecord(entry.import))
3121
1193
  return [];
3122
- const platforms = [
3123
- ...(entry.platforms !== undefined || entry.distributions === undefined
3124
- ? (entry.platforms ?? [...resolveSupportedPlatforms(options.manifest)])
3125
- : []),
3126
- ...(entry.distributions?.includes('agent-skills') ? [undefined] : []),
3127
- ];
1194
+ const platforms = entry.platforms?.length ? entry.platforms : [...resolveSupportedPlatforms(options.manifest)];
3128
1195
  return platforms.length > 0 ? [{
3129
1196
  key: importIndex,
3130
1197
  label: `buildConfig.skillRuntimeFiles[${importIndex}].import`,
@@ -3141,25 +1208,28 @@ async function resolveAuthorRuntimeImports(options) {
3141
1208
  || typeof options.cliManifestTools?.readPluginManifest !== 'function'
3142
1209
  || typeof options.cliManifestTools?.discoverPlugins !== 'function'
3143
1210
  || typeof options.cliManifestTools?.createRuntimeResolver !== 'function') {
3144
- 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.');
3145
1212
  return null;
3146
1213
  }
3147
1214
  let consumer;
3148
1215
  let resolver;
1216
+ let referencePlugins;
3149
1217
  try {
3150
1218
  const sourceSet = await options.cliManifestTools.discoverPlugins(options.repoRoot);
3151
1219
  consumer = await options.cliManifestTools.readPluginManifest(options.pluginDir);
3152
1220
  if (!sourceSet.some((candidate) => candidate.manifest.name === consumer.manifest.name)) {
3153
1221
  sourceSet.push(consumer);
3154
1222
  }
1223
+ referencePlugins = sourceSet;
3155
1224
  resolver = options.cliManifestTools.createRuntimeResolver(sourceSet);
3156
1225
  }
3157
1226
  catch {
3158
- 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.');
3159
1228
  return null;
3160
1229
  }
3161
1230
  const resolvedArtifacts = new Map();
3162
1231
  const resolvedSkillRuntimeFiles = new Map();
1232
+ let unresolved = false;
3163
1233
  for (const request of requested) {
3164
1234
  let value;
3165
1235
  try {
@@ -3181,6 +1251,9 @@ async function resolveAuthorRuntimeImports(options) {
3181
1251
  providerVersion: resolution.providerVersion,
3182
1252
  exportName: resolution.name,
3183
1253
  source: resolution.source,
1254
+ requiredCapabilities: resolution.requiredCapabilities,
1255
+ capabilitySetDigest: resolution.capabilitySetDigest,
1256
+ mode: fs.statSync(resolution.sourcePath).mode & 0o111 ? 0o755 : 0o644,
3184
1257
  };
3185
1258
  if (value && (value.digest !== current.digest
3186
1259
  || value.providerPluginId !== current.providerPluginId
@@ -3200,6 +1273,7 @@ async function resolveAuthorRuntimeImports(options) {
3200
1273
  ? JSON.stringify(request.reference.export)
3201
1274
  : '<invalid-export>';
3202
1275
  error(`Cannot resolve ${request.label} from provider ${provider} export ${exportName}.`);
1276
+ unresolved = true;
3203
1277
  continue;
3204
1278
  }
3205
1279
  if (request.purpose === 'artifact-runtime')
@@ -3207,15 +1281,16 @@ async function resolveAuthorRuntimeImports(options) {
3207
1281
  else
3208
1282
  resolvedSkillRuntimeFiles.set(request.key, value);
3209
1283
  }
3210
- return {
1284
+ return unresolved ? null : {
3211
1285
  artifactImports: resolvedArtifacts,
3212
1286
  skillRuntimeImports: resolvedSkillRuntimeFiles,
1287
+ referencePlugins,
3213
1288
  };
3214
1289
  }
3215
- function overlayPortableRuntimeFiles(files, manifest, pluginDir, skillKey, runtimeImports) {
1290
+ function overlayPortableRuntimeFiles(files, manifest, pluginDir, skillKey, runtimeImports, platform) {
3216
1291
  for (const [runtimeIndex, runtimeFile] of (manifest.buildConfig?.skillRuntimeFiles ?? []).entries()) {
3217
1292
  if (runtimeFile.skill !== skillKey
3218
- || !runtimeFile.distributions?.includes('agent-skills'))
1293
+ || (runtimeFile.platforms?.length && !runtimeFile.platforms.includes(platform)))
3219
1294
  continue;
3220
1295
  if (typeof runtimeFile.source === 'string') {
3221
1296
  const sourcePath = path.join(pluginDir, normalizeRelativePath(runtimeFile.source));
@@ -3237,444 +1312,178 @@ function overlayPortableRuntimeFiles(files, manifest, pluginDir, skillKey, runti
3237
1312
  }
3238
1313
  }
3239
1314
  }
3240
- function validateRenderedSkillTree(options) {
3241
- const { entry, declaration, fieldName, pluginDir, manifest, materializedRoot, skillValidationTools, } = options;
3242
- if (entry.state !== 'present' || !isRecord(entry.content) || !isRecord(entry.content.files)) {
3243
- return;
3244
- }
3245
- const files = new Map();
3246
- declaration.sourceDirs.forEach((sourceDir, index) => {
3247
- collectArtifactSourceFiles(path.join(pluginDir, normalizeRelativePath(sourceDir)), `artifacts.targets sourceDirs[${index}] for artifact "${declaration.id}"`, files);
3248
- });
3249
- if (declaration.target === 'agent-skills.skill') {
3250
- overlayPortableRuntimeFiles(files, manifest, pluginDir, declaration.skillKey, options.runtimeImports);
3251
- }
3252
- for (const [relativePath, content] of Object.entries(entry.content.files)) {
3253
- if (isSkillAuthorOnlyPath(relativePath)) {
3254
- error(`${fieldName}.content.files path "${relativePath}" uses an author-only Skill directory`);
3255
- continue;
3256
- }
3257
- if (isValidArtifactFilePath(relativePath) && typeof content === 'string') {
3258
- files.set(relativePath, Buffer.from(content, 'utf8'));
3259
- }
3260
- }
3261
- const conflict = findArtifactFilePrefixConflict(files);
3262
- if (conflict) {
3263
- error(`${fieldName} final file tree path "${conflict[0]}" conflicts with "${conflict[1]}"`);
3264
- return;
3265
- }
3266
- const skillFile = files.get('SKILL.md');
3267
- if (!skillFile || skillFile.toString('utf8').trim() === '') {
3268
- error(`${fieldName} final file tree must contain a non-empty SKILL.md`);
3269
- }
3270
- else if (!skillValidationTools) {
3271
- error(`${fieldName} final SKILL.md cannot be validated because the shared CLI Skill validator is unavailable`);
3272
- }
3273
- else {
3274
- const sourcePath = `${fieldName} final SKILL.md`;
3275
- const parsed = skillValidationTools.parseSkillFrontmatter(skillFile.toString('utf8'), sourcePath);
3276
- for (const diagnostic of parsed.errors) {
3277
- error(`${diagnostic.path} [${diagnostic.code}] ${diagnostic.message}`);
3278
- }
3279
- if (parsed.frontmatter) {
3280
- const diagnostics = skillValidationTools.validateSkillFrontmatter(parsed.frontmatter, {
3281
- profile: declaration.platform === 'claude' ? 'claude-2.1.88' : 'portable-agent-skills',
3282
- expectedName: declaration.skillKey,
3283
- sourcePath,
3284
- });
3285
- for (const diagnostic of diagnostics) {
3286
- error(`${diagnostic.path} [${diagnostic.code}] ${diagnostic.message}`);
3287
- }
3288
- }
3289
- }
3290
- const readme = files.get('README.md');
3291
- if (!readme || readme.toString('utf8').trim() === '') {
3292
- error(`${fieldName} final file tree must contain a non-empty README.md`);
3293
- }
3294
- const sensitiveValues = Object.entries(manifest.config?.schema ?? {})
3295
- .filter(([, field]) => isRecord(field) && field.sensitive === true)
3296
- .map(([key, field]) => Object.prototype.hasOwnProperty.call(field, 'default')
3297
- ? String(field.default)
3298
- : String(defaultConfigValues(manifest)[key] ?? ''))
3299
- .filter(Boolean);
3300
- for (const [relativePath, content] of files) {
3301
- const text = content.toString('utf8');
3302
- if (/\{\{[^{}]+\}\}/u.test(text)) {
3303
- error(`${fieldName} final file tree contains an unresolved template in "${relativePath}"`);
3304
- }
3305
- if (sensitiveValues.some((value) => text.includes(value))) {
3306
- error(`${fieldName} final file tree exposes sensitive config in "${relativePath}"`);
3307
- }
3308
- }
3309
- if (declaration.target === 'codex.skill') {
3310
- const openAiYaml = files.get('agents/openai.yaml');
3311
- if (!openAiYaml || openAiYaml.toString('utf8').trim() === '') {
3312
- error(`${fieldName} final file tree must contain a non-empty agents/openai.yaml`);
3313
- }
3314
- }
3315
- fs.rmSync(materializedRoot, { recursive: true, force: true });
3316
- for (const [relativePath, content] of files) {
3317
- const targetPath = path.join(materializedRoot, ...relativePath.split('/'));
3318
- fs.mkdirSync(path.dirname(targetPath), { recursive: true });
3319
- fs.writeFileSync(targetPath, content);
3320
- }
3321
- if (declaration.target === 'codex.skill' && files.has('agents/openai.yaml')) {
3322
- validateOpenAiYaml(path.join(materializedRoot, 'agents', 'openai.yaml'), declaration.skillKey, true, manifest, materializedRoot, skillValidationTools);
3323
- }
3324
- }
3325
- function validateStaticPortableFinalTrees(pluginDir, manifest, runtimeImports, skillValidationTools) {
3326
- const portableRoot = manifest.distributions?.agentSkills?.skills;
3327
- if (typeof portableRoot !== 'string')
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))
3328
1317
  return;
3329
- const rootDir = path.join(pluginDir, normalizeRelativePath(portableRoot));
3330
- const rootStats = fs.lstatSync(rootDir, { throwIfNoEntry: false });
3331
- if (!rootStats?.isDirectory() || rootStats.isSymbolicLink())
1318
+ if (runtimeImports === null)
3332
1319
  return;
3333
- const dynamicKeys = new Set((manifest.artifacts?.targets ?? [])
3334
- .filter((target) => target.target === 'agent-skills.skill' && typeof target.skillKey === 'string')
3335
- .map((target) => target.skillKey));
3336
- 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();
3337
1322
  try {
3338
- for (const entry of fs.readdirSync(rootDir, { withFileTypes: true })) {
3339
- if (!entry.isDirectory() || dynamicKeys.has(entry.name))
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.
1355
+ for (const platform of resolveSupportedPlatforms(manifest)) {
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))
3340
1365
  continue;
3341
- validateRenderedSkillTree({
3342
- entry: { state: 'present', content: { files: {} } },
3343
- declaration: {
3344
- id: `static:${entry.name}`,
3345
- distribution: 'agent-skills',
3346
- target: 'agent-skills.skill',
3347
- skillKey: entry.name,
3348
- sourceDirs: [`${portableRoot}/${entry.name}`],
3349
- },
3350
- fieldName: `static portable Skill "${entry.name}"`,
3351
- pluginDir,
3352
- manifest,
3353
- runtimeImports,
3354
- materializedRoot: path.join(tempRoot, entry.name),
3355
- skillValidationTools,
3356
- });
3357
- }
3358
- }
3359
- finally {
3360
- fs.rmSync(tempRoot, { recursive: true, force: true });
3361
- }
3362
- }
3363
- function validateRenderedArtifactPlan(plan, declarations, scopeLabel, options) {
3364
- const planField = `scripts.artifacts.render fixture (${scopeLabel})`;
3365
- const root = expectRecord(plan, planField);
3366
- if (!root)
3367
- return;
3368
- validateAllowedKeys(root, planField, ['version', 'artifacts']);
3369
- if (root.version !== 2) {
3370
- error(`${planField}.version must be 2`);
3371
- }
3372
- if (!Array.isArray(root.artifacts)) {
3373
- error(`${planField}.artifacts must be an array`);
3374
- return;
3375
- }
3376
- const byKey = new Map(declarations.map((target) => [`${target.id}:${target.target}`, target]));
3377
- const returned = new Set();
3378
- root.artifacts.forEach((artifact, index) => {
3379
- const fieldName = `${planField}.artifacts[${index}]`;
3380
- const entry = expectRecord(artifact, fieldName);
3381
- if (!entry)
3382
- return;
3383
- validateAllowedKeys(entry, fieldName, [
3384
- 'id',
3385
- 'platform',
3386
- 'distribution',
3387
- 'target',
3388
- 'kind',
3389
- 'state',
3390
- 'refreshKeys',
3391
- 'disabledReason',
3392
- 'roleKey',
3393
- 'skillKey',
3394
- 'content',
3395
- ]);
3396
- const id = validateArtifactId(entry.id, `${fieldName}.id`);
3397
- const target = validateManifestString(entry.target, `${fieldName}.target`);
3398
- const key = id && target ? `${id}:${target}` : null;
3399
- const declaration = key ? byKey.get(key) : null;
3400
- if (!declaration) {
3401
- error(`${fieldName}: artifact "${key ?? '<unknown>'}" is not declared for ${scopeLabel}`);
3402
- return;
3403
- }
3404
- if (returned.has(key)) {
3405
- error(`${fieldName}: duplicate artifact id + target "${key}"`);
3406
- }
3407
- returned.add(key);
3408
- if (declaration.distribution) {
3409
- if (entry.distribution !== declaration.distribution) {
3410
- error(`${fieldName}.distribution: expected "${declaration.distribution}"`);
3411
- }
3412
- if (entry.platform !== undefined) {
3413
- error(`${fieldName}.platform: distribution artifacts do not support platform`);
3414
- }
3415
- }
3416
- else if (entry.platform !== declaration.platform) {
3417
- error(`${fieldName}.platform: expected "${declaration.platform}"`);
3418
- }
3419
- if (entry.kind !== declaration.kind) {
3420
- error(`${fieldName}.kind: expected "${declaration.kind}"`);
3421
- }
3422
- if (!declaration.states.includes(entry.state)) {
3423
- error(`${fieldName}.state: "${entry.state}" is not declared for artifact "${declaration.id}"`);
3424
- }
3425
- validateArtifactPlanRefreshKeys(entry.refreshKeys, declaration, fieldName);
3426
- if (entry.state === 'present' && entry.content === undefined) {
3427
- error(`${fieldName}.content is required when state is "present"`);
3428
- }
3429
- if (entry.disabledReason !== undefined &&
3430
- (typeof entry.disabledReason !== 'string' || entry.disabledReason.trim() === '')) {
3431
- error(`${fieldName}.disabledReason must be a non-empty string`);
3432
- }
3433
- if (declaration.target === 'codex.agentRole') {
3434
- if (entry.roleKey !== declaration.roleKey) {
3435
- error(`${fieldName}.roleKey: expected "${declaration.roleKey}" from static metadata`);
3436
- }
3437
- if (isRecord(entry.content)) {
3438
- const registration = entry.content.registration;
3439
- if (isRecord(registration) && registration.config_file !== undefined) {
3440
- error(`${fieldName}.content.registration.config_file must be generated by AW, not renderer`);
3441
- }
3442
- const roleFile = entry.content.roleFile;
3443
- if (isRecord(roleFile) && roleFile.name !== declaration.roleKey) {
3444
- error(`${fieldName}.content.roleFile.name: expected "${declaration.roleKey}"`);
3445
- }
3446
- }
3447
- }
3448
- else if (entry.roleKey !== undefined) {
3449
- error(`${fieldName}.roleKey is only supported for codex.agentRole artifacts`);
3450
- }
3451
- if (declaration.target === 'codex.skill' || declaration.target === 'claude.skill' || declaration.target === 'agent-skills.skill') {
3452
- if (entry.skillKey !== declaration.skillKey) {
3453
- error(`${fieldName}.skillKey: expected "${declaration.skillKey}" from static metadata`);
3454
- }
3455
- if (entry.state === 'present') {
3456
- if (!isRecord(entry.content)) {
3457
- error(`${fieldName}.content must be an object for dynamic skill artifacts`);
3458
- }
3459
- else {
3460
- validateAllowedKeys(entry.content, `${fieldName}.content`, ['files']);
3461
- const files = expectRecord(entry.content.files, `${fieldName}.content.files`);
3462
- if (files) {
3463
- const filePaths = Object.keys(files).sort();
3464
- for (const [relativePath, content] of Object.entries(files)) {
3465
- if (!isValidArtifactFilePath(relativePath)) {
3466
- error(`${fieldName}.content.files path "${relativePath}" must be a normalized POSIX relative path`);
3467
- }
3468
- if (typeof content !== 'string') {
3469
- error(`${fieldName}.content.files.${relativePath} must be a string`);
3470
- }
1366
+ for (const entry of fs.readdirSync(sourceRoot, { withFileTypes: true })) {
1367
+ if (!entry.isDirectory() || await isAuthorOnlySkillDirectory(path.join(sourceRoot, entry.name)))
1368
+ continue;
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 });
1381
+ }
1382
+ }
1383
+ }
1384
+ for (const platform of resolveSupportedPlatforms(manifest)) {
1385
+ const skillsRoot = path.join(root, platform, 'skills');
1386
+ if (!fs.existsSync(skillsRoot))
1387
+ continue;
1388
+ for (const entry of fs.readdirSync(skillsRoot, { withFileTypes: true })) {
1389
+ if (!entry.isDirectory())
1390
+ continue;
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}`);
3471
1430
  }
3472
- for (const [pathIndex, relativePath] of filePaths.entries()) {
3473
- const conflict = filePaths.slice(0, pathIndex).find((candidate) => relativePath.startsWith(`${candidate}/`));
3474
- if (conflict) {
3475
- error(`${fieldName}.content.files path "${conflict}" conflicts with "${relativePath}"`);
3476
- }
1431
+ }
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)}`);
3477
1435
  }
1436
+ }
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}`);
3478
1443
  }
1444
+ else
1445
+ error(`component profile fixture (${platform}/${scope}): ${cause.message}`);
3479
1446
  }
3480
- validateRenderedSkillTree({
3481
- entry,
3482
- declaration,
3483
- fieldName,
3484
- pluginDir: options.pluginDir,
3485
- manifest: options.manifest,
3486
- runtimeImports: options.runtimeImports,
3487
- materializedRoot: path.join(options.tempRoot, `${declaration.platform ?? declaration.distribution}-${scopeLabel.split('/')[1]}-${index}`),
3488
- skillValidationTools: options.skillValidationTools,
3489
- });
3490
1447
  }
3491
1448
  }
3492
- else if (entry.skillKey !== undefined) {
3493
- error(`${fieldName}.skillKey is only supported for dynamic skill artifacts`);
3494
- }
3495
- });
3496
- for (const declaration of declarations) {
3497
- const key = `${declaration.id}:${declaration.target}`;
3498
- if (!returned.has(key)) {
3499
- error(`${planField}: renderer must return artifact "${declaration.id}" target "${declaration.target}"`);
3500
- }
3501
- }
3502
- }
3503
- function runArtifactRendererFixture(pluginDir, manifest, renderEntry, declarations, resolvedRuntimeImports, skillValidationTools) {
3504
- if (!renderEntry || declarations.length === 0)
3505
- return;
3506
- const surfaceScopes = [...new Set(declarations.flatMap((target) => target.scopes.map((scope) => `${target.platform ?? target.distribution}:${scope}`)))];
3507
- const values = defaultConfigValues(manifest);
3508
- const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'aw-artifact-render-'));
3509
- try {
3510
- for (const surfaceScope of surfaceScopes) {
3511
- const [surface, scope] = surfaceScope.split(':');
3512
- const distribution = surface === 'agent-skills' ? surface : undefined;
3513
- const platform = distribution ? undefined : surface;
3514
- const event = distribution ? 'materialize' : 'install';
3515
- const scopedDeclarations = declarations.filter((target) => (distribution ? target.distribution === distribution : target.platform === platform)
3516
- && target.scopes.includes(scope));
3517
- const contextPath = path.join(tempRoot, `context-${surface}-${scope}.json`);
3518
- const runtimeImports = scopedDeclarations.flatMap((target) => target.runtimeImports.map((runtimeImport, importIndex) => {
3519
- const resolved = resolvedRuntimeImports?.artifactImports.get(authorRuntimeImportKey(target.id, importIndex));
3520
- if (!resolved)
3521
- return null;
3522
- const importPath = path.join(tempRoot, `runtime-${target.id}-${importIndex}`);
3523
- fs.writeFileSync(importPath, resolved.bytes);
3524
- return {
3525
- artifactId: target.id,
3526
- name: runtimeImport.name,
3527
- providerPluginId: resolved.providerPluginId,
3528
- exportName: resolved.exportName,
3529
- path: importPath,
3530
- digest: resolved.digest,
3531
- };
3532
- }).filter(Boolean));
3533
- fs.writeFileSync(contextPath, JSON.stringify({
3534
- event,
3535
- surface: distribution
3536
- ? { kind: 'distribution', name: distribution }
3537
- : { kind: 'platform', name: platform },
3538
- ...(platform ? { platform } : {}),
3539
- ...(distribution ? { distribution } : {}),
3540
- scope,
3541
- plugin: {
3542
- name: manifest.name,
3543
- version: manifest.version,
3544
- rootDir: pluginDir,
3545
- },
3546
- config: {
3547
- mode: 'artifact-render',
3548
- targetScope: scope,
3549
- schema: manifest.config?.schema ?? {},
3550
- values,
3551
- sources: Object.fromEntries(Object.keys(values).map((key) => [key, 'default'])),
3552
- issues: [],
3553
- },
3554
- changedConfigKeys: [],
3555
- previousArtifacts: [],
3556
- artifactSources: scopedDeclarations.map((target) => ({
3557
- id: target.id,
3558
- target: target.target,
3559
- sourceDirs: target.sourceDirs.map((sourceDir) => path.join(pluginDir, normalizeRelativePath(sourceDir))),
3560
- })),
3561
- runtimeImports,
3562
- paths: {
3563
- awHome: path.join(tempRoot, 'aw-home'),
3564
- codexHome: path.join(tempRoot, 'codex-home'),
3565
- claudeHome: path.join(tempRoot, 'claude-home'),
3566
- manifestPath: path.join(pluginDir, '.agents-plugin', 'plugin.json'),
3567
- configStores: {
3568
- user: path.join(tempRoot, 'config-user.json'),
3569
- project: path.join(tempRoot, 'config-project.json'),
3570
- },
3571
- },
3572
- renderer: {
3573
- runner: renderEntry.runner,
3574
- path: renderEntry.path,
3575
- args: renderEntry.args ?? [],
3576
- manifestDigest: 'author-validator-fixture',
3577
- rendererDigest: 'author-validator-fixture',
3578
- },
3579
- }), 'utf8');
3580
- const rendererHome = path.join(tempRoot, 'home');
3581
- const rendererTemp = path.join(tempRoot, 'tmp');
3582
- fs.mkdirSync(rendererHome, { recursive: true });
3583
- fs.mkdirSync(rendererTemp, { recursive: true });
3584
- const rendererEnv = {
3585
- AW_HOME: path.join(tempRoot, 'aw-home'),
3586
- AW_CODEX_HOME: path.join(tempRoot, 'codex-home'),
3587
- AW_CLAUDE_HOME: path.join(tempRoot, 'claude-home'),
3588
- PATH: process.env.PATH ?? process.env.Path ?? '',
3589
- AW_PLUGIN_CONTEXT: contextPath,
3590
- AW_PLUGIN_ROOT: pluginDir,
3591
- AW_PLUGIN_NAME: typeof manifest.name === 'string' ? manifest.name : '',
3592
- AW_PLUGIN_VERSION: typeof manifest.version === 'string' ? manifest.version : '',
3593
- AW_PLUGIN_EVENT: event,
3594
- ...(platform ? { AW_PLUGIN_PLATFORM: platform } : {}),
3595
- ...(distribution ? { AW_PLUGIN_DISTRIBUTION: distribution } : {}),
3596
- AW_PLUGIN_SCOPE: scope,
3597
- };
3598
- if (process.platform === 'win32') {
3599
- rendererEnv.USERPROFILE = rendererHome;
3600
- rendererEnv.TEMP = rendererTemp;
3601
- rendererEnv.TMP = rendererTemp;
3602
- if (process.env.SystemRoot)
3603
- rendererEnv.SystemRoot = process.env.SystemRoot;
3604
- if (process.env.ComSpec)
3605
- rendererEnv.ComSpec = process.env.ComSpec;
3606
- }
3607
- else {
3608
- rendererEnv.HOME = rendererHome;
3609
- rendererEnv.TMPDIR = rendererTemp;
3610
- }
3611
- const result = spawnSync(process.execPath, [path.join(pluginDir, renderEntry.path), ...(renderEntry.args ?? [])], {
3612
- cwd: pluginDir,
3613
- env: rendererEnv,
3614
- encoding: 'utf8',
3615
- timeout: 5000,
3616
- maxBuffer: 1024 * 1024,
3617
- });
3618
- const fieldName = `scripts.artifacts.render fixture (${surface}/${scope})`;
3619
- if (result.error) {
3620
- error(`${fieldName} failed: ${result.error.message}`);
3621
- continue;
3622
- }
3623
- if (result.status !== 0) {
3624
- const stderr = String(result.stderr ?? '').trim().split('\n')[0] ?? '';
3625
- error(`${fieldName} exited with code ${result.status}${stderr ? `: ${stderr}` : ''}`);
3626
- continue;
3627
- }
3628
- let plan;
3629
- try {
3630
- plan = JSON.parse(result.stdout);
3631
- }
3632
- catch (e) {
3633
- error(`${fieldName} stdout must be JSON ArtifactPlan: ${e.message}`);
3634
- continue;
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' }));
3635
1456
  }
3636
- validateRenderedArtifactPlan(plan, scopedDeclarations, `${surface}/${scope}`, {
3637
- pluginDir,
3638
- manifest,
3639
- runtimeImports: resolvedRuntimeImports,
3640
- tempRoot,
3641
- skillValidationTools,
3642
- });
1457
+ await packagePreparationCache.get(key);
3643
1458
  }
3644
1459
  }
1460
+ catch (cause) {
1461
+ error(`author component preparation: ${cause.message}`);
1462
+ }
3645
1463
  finally {
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
+ }
3646
1471
  fs.rmSync(tempRoot, { recursive: true, force: true });
3647
1472
  }
3648
1473
  }
3649
- function validateDynamicArtifactsLightweight(pluginDir, manifest, renderEntry, runtimeImports, skillValidationTools) {
3650
- const declarations = validateArtifactsConfigLightweight(pluginDir, manifest);
3651
- const hasTargets = declarations.length > 0;
3652
- const hasRenderer = Boolean(manifest.scripts?.artifacts?.render);
3653
- if (hasTargets && !hasRenderer) {
3654
- error('artifacts.targets requires scripts.artifacts.render');
3655
- }
3656
- if (hasRenderer && !hasTargets) {
3657
- error('scripts.artifacts.render requires artifacts.targets');
3658
- }
3659
- runArtifactRendererFixture(pluginDir, manifest, renderEntry, declarations, runtimeImports, skillValidationTools);
3660
- }
3661
1474
  function validateScriptsLightweight(pluginDir, manifest) {
3662
- validateConfigSchemaLightweight(manifest.config);
1475
+ validateConfigSchemaLightweight(manifest.config, manifest);
3663
1476
  if (manifest.scripts === undefined)
3664
1477
  return null;
3665
1478
  const scripts = expectRecord(manifest.scripts, 'scripts');
3666
1479
  if (!scripts)
3667
1480
  return null;
3668
- validateAllowedKeys(scripts, 'scripts', ['timeoutMs', 'lifecycle', 'helpers', 'node', 'artifacts', 'tests']);
3669
- if (scripts.timeoutMs !== undefined &&
3670
- (!Number.isInteger(scripts.timeoutMs) ||
3671
- scripts.timeoutMs < SCRIPT_TIMEOUT_MIN_MS ||
3672
- scripts.timeoutMs > SCRIPT_TIMEOUT_MAX_MS)) {
3673
- error(`scripts.timeoutMs must be an integer between ${SCRIPT_TIMEOUT_MIN_MS} and ${SCRIPT_TIMEOUT_MAX_MS}`);
3674
- }
1481
+ validateAllowedKeys(scripts, 'scripts', ['preApply', 'helpers', 'node', 'artifacts', 'tests']);
3675
1482
  const runtimeNodeEntries = [];
3676
1483
  let artifactRenderEntry = null;
3677
1484
  let packageMeta = null;
1485
+ const nativeToolReader = manifest.nativeTools ? normalizeRelativePath(manifest.nativeTools.reader ?? './.aw/native-tool-reader.mjs') : undefined;
1486
+ const runtimeConfigSkillRoots = (manifest.artifacts?.sourceDirs ?? []).map(normalizeRelativePath);
3678
1487
  if (scripts.helpers !== undefined) {
3679
1488
  const helpers = expectRecord(scripts.helpers, 'scripts.helpers');
3680
1489
  if (helpers) {
@@ -3688,17 +1497,21 @@ function validateScriptsLightweight(pluginDir, manifest) {
3688
1497
  runtimeNodeEntries.push({ path: helperPath, fieldName: 'scripts.helpers.config' });
3689
1498
  }
3690
1499
  }
3691
- if (scripts.lifecycle !== undefined) {
3692
- const lifecycle = expectRecord(scripts.lifecycle, 'scripts.lifecycle');
3693
- if (lifecycle) {
3694
- validateAllowedKeys(lifecycle, 'scripts.lifecycle', [...SCRIPT_LIFECYCLE_EVENTS]);
3695
- for (const [eventName, definition] of Object.entries(lifecycle)) {
3696
- if (!SCRIPT_LIFECYCLE_EVENTS.has(eventName)) {
3697
- error(`scripts.lifecycle has unsupported event "${eventName}"`);
3698
- continue;
3699
- }
3700
- validateLifecycleDefinition(pluginDir, definition, `scripts.lifecycle.${eventName}`, runtimeNodeEntries);
1500
+ if (scripts.preApply !== undefined) {
1501
+ const preApply = expectRecord(scripts.preApply, 'scripts.preApply');
1502
+ if (preApply) {
1503
+ validateAllowedKeys(preApply, 'scripts.preApply', ['path', 'timeoutMs']);
1504
+ const preApplyPath = normalizePluginScriptPath(pluginDir, preApply.path, 'scripts.preApply.path');
1505
+ validateDeclaredScriptFile(pluginDir, preApplyPath, 'scripts.preApply.path');
1506
+ if (preApplyPath && !isNodeRunnablePath(preApplyPath)) {
1507
+ error('scripts.preApply.path must use a Node runnable extension (.js, .mjs, or .cjs)');
1508
+ }
1509
+ if (preApply.timeoutMs !== undefined && (!Number.isInteger(preApply.timeoutMs)
1510
+ || preApply.timeoutMs < SCRIPT_TIMEOUT_MIN_MS || preApply.timeoutMs > SCRIPT_TIMEOUT_MAX_MS)) {
1511
+ error(`scripts.preApply.timeoutMs must be an integer between ${SCRIPT_TIMEOUT_MIN_MS} and ${SCRIPT_TIMEOUT_MAX_MS}`);
3701
1512
  }
1513
+ if (preApplyPath)
1514
+ runtimeNodeEntries.push({ path: preApplyPath, fieldName: 'scripts.preApply.path' });
3702
1515
  }
3703
1516
  }
3704
1517
  if (scripts.node !== undefined) {
@@ -3718,6 +1531,8 @@ function validateScriptsLightweight(pluginDir, manifest) {
3718
1531
  label: 'scripts.node.build import contract',
3719
1532
  packageMeta,
3720
1533
  allowDevDependencies: true,
1534
+ runtimeConfigSkillRoots,
1535
+ nativeToolReader,
3721
1536
  });
3722
1537
  }
3723
1538
  }
@@ -3767,6 +1582,8 @@ function validateScriptsLightweight(pluginDir, manifest) {
3767
1582
  label: 'scripts.tests.node import contract',
3768
1583
  packageMeta,
3769
1584
  allowDevDependencies: true,
1585
+ runtimeConfigSkillRoots,
1586
+ nativeToolReader,
3770
1587
  });
3771
1588
  }
3772
1589
  }
@@ -3776,6 +1593,8 @@ function validateScriptsLightweight(pluginDir, manifest) {
3776
1593
  label: 'runtime Node import contract',
3777
1594
  packageMeta,
3778
1595
  allowDevDependencies: false,
1596
+ runtimeConfigSkillRoots,
1597
+ nativeToolReader,
3779
1598
  });
3780
1599
  return artifactRenderEntry;
3781
1600
  }
@@ -3797,55 +1616,6 @@ function validateMcpContent(pluginDir, manifest) {
3797
1616
  error(`${manifest.mcpServers} is not valid JSON: ${e.message}`);
3798
1617
  }
3799
1618
  }
3800
- function validateAppsContent(pluginDir, manifest) {
3801
- if (!manifest.apps)
3802
- return;
3803
- if (isTemplateAsset(manifest, manifest.apps))
3804
- return;
3805
- const appsPath = path.join(pluginDir, manifest.apps);
3806
- if (!fs.existsSync(appsPath))
3807
- return;
3808
- try {
3809
- const content = JSON.parse(fs.readFileSync(appsPath, 'utf8'));
3810
- if (!content.apps || typeof content.apps !== 'object') {
3811
- error(`${manifest.apps} must have an "apps" top-level key`);
3812
- }
3813
- }
3814
- catch (e) {
3815
- error(`${manifest.apps} is not valid JSON: ${e.message}`);
3816
- }
3817
- }
3818
- function hasCodexRepoManagedSurface(manifest) {
3819
- if (manifest.skills || manifest.slashCommands || manifest.mcpServers) {
3820
- return true;
3821
- }
3822
- if ((manifest.artifacts?.targets ?? []).some((target) => target?.platform === 'codex' &&
3823
- Array.isArray(target.scopes) &&
3824
- target.scopes.includes('project') &&
3825
- typeof target.projectManagedKind === 'string')) {
3826
- return true;
3827
- }
3828
- const extensions = manifest.extensions;
3829
- if (!extensions || typeof extensions !== 'object' || Array.isArray(extensions)) {
3830
- return false;
3831
- }
3832
- return ['instructions', 'permissions', 'hooks', 'agents'].some((key) => Array.isArray(extensions[key]) && extensions[key].length > 0) || (extensions.nativeHooks &&
3833
- typeof extensions.nativeHooks === 'object' &&
3834
- !Array.isArray(extensions.nativeHooks) &&
3835
- Array.isArray(extensions.nativeHooks.codex) &&
3836
- extensions.nativeHooks.codex.length > 0);
3837
- }
3838
- function warnCodexProjectScopeLimitations(manifest) {
3839
- if (!isCodexTargeted(manifest)) {
3840
- return;
3841
- }
3842
- if (manifest.apps) {
3843
- warn('Codex project scope does not support apps; users must install this app surface with `aw install <plugin> -p codex -s user` or split the plugin.');
3844
- }
3845
- if (!hasCodexRepoManagedSurface(manifest)) {
3846
- 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.');
3847
- }
3848
- }
3849
1619
  function validateExtensionNameUniqueness(manifest) {
3850
1620
  if (!manifest.extensions)
3851
1621
  return;
@@ -3899,14 +1669,17 @@ function validateOpenAiYaml(openaiYamlPath, skillName, required, manifest, plugi
3899
1669
  error(`${fieldName} shared validation failed: ${e.message}`);
3900
1670
  }
3901
1671
  }
3902
- 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) {
3903
1678
  if (!manifest.skills)
3904
1679
  return;
3905
1680
  const skillsDir = path.join(pluginDir, manifest.skills);
3906
1681
  if (!fs.existsSync(skillsDir))
3907
1682
  return;
3908
- const requiresCodexMetadata = isCodexTargeted(manifest);
3909
- const targetsClaude = isClaudeTargeted(manifest);
3910
1683
  const skillDirs = fs
3911
1684
  .readdirSync(skillsDir, { withFileTypes: true })
3912
1685
  .filter((d) => d.isDirectory());
@@ -3914,6 +1687,12 @@ function validateSkills(pluginDir, manifest, options, skillValidationTools) {
3914
1687
  error('skills directory exists but contains no skill subdirectories');
3915
1688
  }
3916
1689
  for (const dir of skillDirs) {
1690
+ if (await isAuthorOnlySkillDirectory(path.join(skillsDir, dir.name)))
1691
+ continue;
1692
+ const staticPlatforms = [...resolveSupportedPlatforms(manifest)];
1693
+ if (staticPlatforms.length === 0)
1694
+ continue;
1695
+ const requiresCodexMetadata = staticPlatforms.includes('codex');
3917
1696
  const skillPath = path.join(skillsDir, dir.name);
3918
1697
  const skillMdPath = path.join(skillPath, 'SKILL.md');
3919
1698
  const openaiYamlPath = path.join(skillPath, 'agents', 'openai.yaml');
@@ -3927,9 +1706,23 @@ function validateSkills(pluginDir, manifest, options, skillValidationTools) {
3927
1706
  if (lineCount >= MAX_SKILL_LINES) {
3928
1707
  warn(`skills/${dir.name}/SKILL.md has ${lineCount} lines; Agent Skills recommends keeping SKILL.md under ${MAX_SKILL_LINES} lines`);
3929
1708
  }
3930
- const variants = renderedContentVariants(manifest, skillMdRelativePath, content, targetedPlatforms(manifest));
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();
3931
1719
  for (const variant of variants) {
3932
- 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)
3933
1726
  ? `skills/${dir.name}/SKILL.md (${variant.platform} render)`
3934
1727
  : `skills/${dir.name}/SKILL.md`;
3935
1728
  if (!skillValidationTools) {
@@ -3941,11 +1734,8 @@ function validateSkills(pluginDir, manifest, options, skillValidationTools) {
3941
1734
  error(`${entry.path} [${entry.code}] ${entry.message}`);
3942
1735
  }
3943
1736
  if (parsed.frontmatter) {
3944
- const profile = options.strictAgentSkills || !targetsClaude
3945
- ? 'portable-agent-skills'
3946
- : options.claudeSkillProfile === 'current'
3947
- ? 'claude-current'
3948
- : 'claude-2.1.88';
1737
+ // Source metadata preserves requested behavior. Host support is checked
1738
+ // later by the selected component profile, including explicit unmet.
3949
1739
  const diagnostics = skillValidationTools.validateSkillFrontmatter(parsed.frontmatter, {
3950
1740
  profile,
3951
1741
  expectedName: dir.name,
@@ -3963,223 +1753,17 @@ function validateSkills(pluginDir, manifest, options, skillValidationTools) {
3963
1753
  }
3964
1754
  }
3965
1755
  }
3966
- function detectCodexSlashCommandForbiddenSyntax(content) {
3967
- const checks = [
3968
- [/\$ARGUMENTS\b/, '$ARGUMENTS'],
3969
- [/\$\d+\b/, '$1'],
3970
- [/```!/, '```!'],
3971
- [/!`[^`\r\n]+`/, '!`command`'],
3972
- ];
3973
- for (const [pattern, label] of checks) {
3974
- if (pattern.test(content)) {
3975
- return label;
3976
- }
3977
- }
3978
- return null;
3979
- }
3980
- function validateSlashCommandAssetReference(commandRoot, commandRelativePath, value, fieldName) {
3981
- if (value === undefined)
3982
- return;
3983
- validateCodexIconPath({ [fieldName]: value }, fieldName, `${commandRelativePath}.codex.interface`);
3984
- if (typeof value !== 'string' || value.trim().length === 0)
3985
- return;
3986
- const normalized = normalizeRelativePath(stripDotSlash(value));
3987
- const absolutePath = path.join(commandRoot, normalized);
3988
- const stats = fs.statSync(absolutePath, { throwIfNoEntry: false });
3989
- if (!stats) {
3990
- error(`${commandRelativePath}.codex.interface.${fieldName} references missing asset "${value}"`);
3991
- return;
3992
- }
3993
- if (!stats.isFile()) {
3994
- error(`${commandRelativePath}.codex.interface.${fieldName} must reference a file, got "${value}"`);
3995
- }
3996
- }
3997
- function validateSlashCommandFrontmatter(commandRoot, commandRelativePath, frontmatter, platform) {
3998
- const fieldName = `${commandRelativePath} frontmatter`;
3999
- const fm = expectRecord(frontmatter, fieldName);
4000
- if (!fm)
4001
- return;
4002
- for (const key of Object.keys(fm)) {
4003
- if (CLAUDE_SLASH_COMMAND_ONLY_FIELDS.has(key)) {
4004
- error(`${fieldName}: "${key}" must be nested under "claude"`);
4005
- }
4006
- }
4007
- validateAllowedKeys(fm, fieldName, ['description', 'claude', 'codex']);
4008
- validateNonEmptyString(fm.description, `${fieldName}.description`, MAX_SKILL_DESCRIPTION_LEN);
4009
- if (platform === 'claude' && fm.claude !== undefined) {
4010
- const claudeBlock = expectRecord(fm.claude, `${fieldName}.claude`);
4011
- if (claudeBlock) {
4012
- validateAllowedKeys(claudeBlock, `${fieldName}.claude`, [
4013
- 'description',
4014
- 'allowed-tools',
4015
- 'model',
4016
- 'argument-hint',
4017
- 'shell',
4018
- ]);
4019
- if (claudeBlock.description !== undefined) {
4020
- validateNonEmptyString(claudeBlock.description, `${fieldName}.claude.description`, MAX_SKILL_DESCRIPTION_LEN);
4021
- }
4022
- if (claudeBlock['allowed-tools'] !== undefined) {
4023
- validateAllowedTools(claudeBlock['allowed-tools'], `${fieldName}.claude.allowed-tools`, { allowArray: true });
4024
- }
4025
- if (claudeBlock.model !== undefined) {
4026
- validateNonEmptyString(claudeBlock.model, `${fieldName}.claude.model`);
4027
- }
4028
- if (claudeBlock['argument-hint'] !== undefined) {
4029
- validateNonEmptyString(claudeBlock['argument-hint'], `${fieldName}.claude.argument-hint`);
4030
- }
4031
- if (claudeBlock.shell !== undefined) {
4032
- if (typeof claudeBlock.shell !== 'string') {
4033
- error(`${fieldName}.claude.shell must be a string`);
4034
- }
4035
- else if (!CLAUDE_FRONTMATTER_SHELLS.has(claudeBlock.shell.trim().toLowerCase())) {
4036
- error(`${fieldName}.claude.shell must be "bash" or "powershell"`);
4037
- }
4038
- }
4039
- }
4040
- }
4041
- if (platform === 'codex' && fm.codex !== undefined) {
4042
- const codexBlock = expectRecord(fm.codex, `${fieldName}.codex`);
4043
- if (codexBlock) {
4044
- if (codexBlock.policy !== undefined) {
4045
- error(`${fieldName}.codex.policy is not supported; generated slashCommands skills are always manual-only`);
4046
- }
4047
- validateAllowedKeys(codexBlock, `${fieldName}.codex`, ['description', 'interface']);
4048
- if (codexBlock.description !== undefined) {
4049
- validateNonEmptyString(codexBlock.description, `${fieldName}.codex.description`, MAX_SKILL_DESCRIPTION_LEN);
4050
- }
4051
- if (codexBlock.interface !== undefined) {
4052
- const interfaceBlock = expectRecord(codexBlock.interface, `${fieldName}.codex.interface`);
4053
- if (interfaceBlock) {
4054
- validateAllowedKeys(interfaceBlock, `${fieldName}.codex.interface`, [
4055
- 'display_name',
4056
- 'short_description',
4057
- 'icon_small',
4058
- 'icon_large',
4059
- 'brand_color',
4060
- 'default_prompt',
4061
- ]);
4062
- validateCodexMetadataString(interfaceBlock, 'display_name', `${fieldName}.codex.interface`, MAX_OPENAI_INTERFACE_NAME_LEN);
4063
- validateCodexShortDescription(interfaceBlock, `${fieldName}.codex.interface`);
4064
- validateCodexDefaultPrompt(interfaceBlock, 'default_prompt', `${fieldName}.codex.interface`, MAX_OPENAI_DEFAULT_PROMPT_LEN, path.basename(commandRelativePath, path.extname(commandRelativePath)));
4065
- validateCodexBrandColor(interfaceBlock, 'brand_color', `${fieldName}.codex.interface`);
4066
- validateSlashCommandAssetReference(commandRoot, commandRelativePath, interfaceBlock.icon_small, 'icon_small');
4067
- validateSlashCommandAssetReference(commandRoot, commandRelativePath, interfaceBlock.icon_large, 'icon_large');
4068
- }
4069
- }
4070
- }
4071
- }
4072
- }
4073
- function validateSlashCommands(pluginDir, manifest) {
4074
- const defaultSlashCommandsDir = path.join(pluginDir, DEFAULT_SLASH_COMMANDS_DIR);
4075
- if (fs.existsSync(defaultSlashCommandsDir) && !manifest.slashCommands) {
4076
- error(`"${DEFAULT_SLASH_COMMANDS_DIR}" exists but manifest does not declare "slashCommands"`);
4077
- }
4078
- if (!manifest.slashCommands)
4079
- return;
4080
- const targetPlatforms = resolveSupportedPlatforms(manifest);
4081
- const slashCommandsRoot = path.join(pluginDir, manifest.slashCommands);
4082
- const stats = fs.statSync(slashCommandsRoot, { throwIfNoEntry: false });
4083
- if (!stats) {
4084
- error(`slashCommands points to "${manifest.slashCommands}" but path does not exist`);
4085
- return;
4086
- }
4087
- if (!stats.isDirectory()) {
4088
- error(`slashCommands must point to a directory, got "${manifest.slashCommands}"`);
4089
- return;
4090
- }
4091
- const skillNames = new Set();
4092
- if (manifest.skills) {
4093
- const skillsRoot = path.join(pluginDir, manifest.skills);
4094
- if (fs.existsSync(skillsRoot)) {
4095
- for (const entry of fs.readdirSync(skillsRoot, { withFileTypes: true })) {
4096
- if (entry.isDirectory()) {
4097
- skillNames.add(entry.name);
4098
- }
4099
- }
4100
- }
4101
- }
4102
- const seenCommands = new Set();
4103
- const commandFiles = [];
4104
- for (const entry of fs.readdirSync(slashCommandsRoot, { withFileTypes: true })) {
4105
- const relativePath = normalizeRelativePath(path.join(stripDotSlash(manifest.slashCommands), entry.name));
4106
- if (entry.isDirectory()) {
4107
- if (entry.name !== 'assets') {
4108
- error(`slashCommands does not support nested directory "${relativePath}"; only root *.md files and assets/ are allowed`);
4109
- }
4110
- continue;
4111
- }
4112
- if (!entry.isFile()) {
4113
- error(`slashCommands has unsupported entry "${relativePath}"`);
4114
- continue;
4115
- }
4116
- if (path.posix.extname(entry.name) !== '.md') {
4117
- error(`slashCommands only accepts root *.md files; found "${relativePath}"`);
4118
- continue;
4119
- }
4120
- commandFiles.push(entry.name);
4121
- }
4122
- if (commandFiles.length === 0) {
4123
- error(`slashCommands "${manifest.slashCommands}" must contain at least one root *.md command file`);
4124
- return;
4125
- }
4126
- for (const fileName of commandFiles.sort()) {
4127
- const commandName = path.posix.basename(fileName, '.md');
4128
- const commandRelativePath = normalizeRelativePath(path.join(stripDotSlash(manifest.slashCommands), fileName));
4129
- if (commandName.length === 0 ||
4130
- commandName.length > 64 ||
4131
- !SLASH_COMMAND_NAME_PATTERN.test(commandName)) {
4132
- error(`${commandRelativePath} command name must use lowercase hyphen-case and be <= 64 characters`);
4133
- continue;
4134
- }
4135
- if (seenCommands.has(commandName)) {
4136
- error(`slashCommands has duplicate command name "${commandName}"`);
4137
- continue;
4138
- }
4139
- if (skillNames.has(commandName)) {
4140
- error(`slashCommands command "${commandName}" conflicts with source skill "${commandName}"`);
4141
- continue;
4142
- }
4143
- seenCommands.add(commandName);
4144
- const absolutePath = path.join(slashCommandsRoot, fileName);
4145
- const rawContent = fs.readFileSync(absolutePath, 'utf8');
4146
- for (const platform of ['claude', 'codex']) {
4147
- if (!targetPlatforms.has(platform))
4148
- continue;
4149
- const rendered = renderTemplateForPlatform(manifest, commandRelativePath, rawContent, platform);
4150
- if (platform === 'codex') {
4151
- const codexForbiddenSyntax = detectCodexSlashCommandForbiddenSyntax(rendered);
4152
- if (codexForbiddenSyntax) {
4153
- error(`${commandRelativePath} Codex render still contains Claude-only syntax "${codexForbiddenSyntax}"`);
4154
- }
4155
- }
4156
- let frontmatter;
4157
- try {
4158
- frontmatter = parseFrontmatter(rendered, `${commandRelativePath} (${platform} render)`);
4159
- }
4160
- catch (parseError) {
4161
- error(`${commandRelativePath} (${platform} render) has invalid YAML frontmatter: ${parseError.message}`);
4162
- continue;
4163
- }
4164
- if (!frontmatter) {
4165
- error(`${commandRelativePath} (${platform} render) is missing YAML frontmatter`);
4166
- continue;
4167
- }
4168
- validateSlashCommandFrontmatter(slashCommandsRoot, commandRelativePath, frontmatter, platform);
4169
- }
4170
- }
4171
- }
4172
1756
  // ---------------------------------------------------------------------------
4173
1757
  // Main
4174
1758
  // ---------------------------------------------------------------------------
4175
1759
  function printUsage() {
4176
1760
  console.log(`Usage:
4177
- aw plugin validate <plugin-directory> [options]
1761
+ aw dev plugin validate <plugin-directory> [options]
4178
1762
 
4179
1763
  Options:
4180
1764
  --strict-agent-skills Allow only Agent Skills portable core frontmatter.
4181
1765
  --claude-skill-profile <minimum|current>
4182
- 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.
4183
1767
  --version-base <git-ref> Compare the production bundle against this Git base. Default: HEAD.
4184
1768
  --workspace-root <path> Workspace root. Default: current directory.
4185
1769
  --json Emit one machine-readable JSON result to stdout.
@@ -4245,14 +1829,46 @@ async function validatePluginDir(pluginDir, options) {
4245
1829
  }
4246
1830
  }
4247
1831
  const skillValidationTools = await tryLoadCliSkillValidationTools();
1832
+ const sourceConfig = manifest.config;
1833
+ let normalizedManifest;
1834
+ let referenceContext;
1835
+ let referencePlugins;
4248
1836
  try {
4249
- const normalizedManifest = await cliManifestTools.validateSourcePluginManifest(pluginDir, manifest);
1837
+ normalizedManifest = await cliManifestTools.validateSourcePluginManifest(pluginDir, manifest);
1838
+ manifest = normalizedManifest;
1839
+ // The Workspace is the sole source of dependency definitions and defaults.
1840
+ // No installed plugin or user config can complete an author fixture.
1841
+ if (manifest.config) {
1842
+ let plugins = [{ manifest, rootDir: pluginDir }];
1843
+ if (hasCrossPluginValueRef(sourceConfig)) {
1844
+ if (!options.repoRoot)
1845
+ throw new Error('Cross-plugin config validation requires the canonical same-source Workspace.');
1846
+ const workspace = await readCatalogWorkspace(options.repoRoot, {
1847
+ reservedImports: cliManifestTools.reservedImports,
1848
+ });
1849
+ if (!workspace.plugins.some((plugin) => plugin.manifest.name === manifest.name
1850
+ && plugin.rootDir === fs.realpathSync(pluginDir))) {
1851
+ throw new Error('Cross-plugin config validation requires the canonical same-source Workspace plugin.');
1852
+ }
1853
+ plugins = workspace.plugins;
1854
+ }
1855
+ referencePlugins = plugins;
1856
+ referenceContext = {
1857
+ plugin: manifest.name,
1858
+ dependencies: manifest.dependencies ?? [],
1859
+ plugins: Object.fromEntries(plugins.map((plugin) => [plugin.manifest.name, {
1860
+ definition: plugin.manifest.config ?? { fields: {} },
1861
+ dependencies: plugin.manifest.dependencies ?? [],
1862
+ values: defaultConfigValues(plugin.manifest),
1863
+ }])),
1864
+ };
1865
+ assertPluginConfigReferenceSchemas(manifest.config, referenceContext, sourceConfig);
1866
+ }
4250
1867
  const requirements = await cliManifestTools.resolvePluginRequirements({
4251
1868
  pluginRoot: pluginDir,
4252
1869
  manifest: normalizedManifest,
4253
1870
  implementedCapabilities: cliManifestTools.implementedCapabilities,
4254
1871
  });
4255
- const blockingObservations = requirements.observations.filter((observation) => observation.blocking);
4256
1872
  if (requirements.unsupportedByCurrentAw.length > 0) {
4257
1873
  capabilityDiagnostic = {
4258
1874
  errorCode: 'awCapabilityUnsupported',
@@ -4261,35 +1877,35 @@ async function validatePluginDir(pluginDir, options) {
4261
1877
  };
4262
1878
  error(`[awCapabilityUnsupported] missingCapabilities=${JSON.stringify(requirements.unsupportedByCurrentAw)}`);
4263
1879
  }
4264
- for (const observation of blockingObservations) {
4265
- error(`[awCapabilityScanBlocked] ${observation.path}: ${observation.message}`);
1880
+ const satisfiedCapabilities = new Set([...requirements.declared, ...requirements.derived]);
1881
+ const advisoryObservations = requirements.observations.filter((observation) => (observation.code !== 'aw-command-detected'
1882
+ || observation.capability === undefined
1883
+ || !satisfiedCapabilities.has(observation.capability)));
1884
+ for (const observation of advisoryObservations) {
1885
+ warn(`[awCapabilityObservation] ${observation.path}: ${observation.message}`);
4266
1886
  }
4267
1887
  }
4268
1888
  catch (e) {
4269
1889
  error(e.message);
1890
+ return;
4270
1891
  }
4271
1892
  validatePlatformFieldSupport(manifest);
4272
- validatePortableNativeArtifactCapabilityLightweight(manifest);
4273
1893
  validateNameMatchesDirectory(pluginDir, manifest);
4274
1894
  validateNoBuildOutputDirs(pluginDir);
4275
1895
  validateDeclaredNativeAssets(pluginDir, manifest);
4276
- validateCanonicalSkillLayout(pluginDir, manifest);
4277
- validatePluginEvalManifest(pluginDir, manifest);
4278
- const artifactRenderEntry = validateScriptsLightweight(pluginDir, manifest);
1896
+ await validateCanonicalSkillLayout(pluginDir, manifest);
1897
+ await validatePluginEvalManifest(pluginDir, manifest);
1898
+ validateScriptsLightweight(pluginDir, manifest);
4279
1899
  const runtimeImports = await resolveAuthorRuntimeImports({
4280
1900
  pluginDir,
4281
1901
  manifest,
4282
1902
  repoRoot: options.repoRoot,
4283
1903
  cliManifestTools,
4284
1904
  });
4285
- validateStaticPortableFinalTrees(pluginDir, manifest, runtimeImports, skillValidationTools);
4286
- validateDynamicArtifactsLightweight(pluginDir, manifest, artifactRenderEntry, runtimeImports, skillValidationTools);
1905
+ await validateAuthorComponentFixtures(pluginDir, manifest, runtimeImports, cliManifestTools, referenceContext, referencePlugins, skillValidationTools, options);
4287
1906
  validateMcpContent(pluginDir, manifest);
4288
- validateAppsContent(pluginDir, manifest);
4289
- warnCodexProjectScopeLimitations(manifest);
4290
1907
  validateExtensionNameUniqueness(manifest);
4291
- validateSkills(pluginDir, manifest, options, skillValidationTools);
4292
- validateSlashCommands(pluginDir, manifest);
1908
+ await validateSkills(pluginDir, manifest, options, skillValidationTools);
4293
1909
  if (errors.length === 0) {
4294
1910
  const repoRoot = resolveCanonicalRepoRoot(pluginDir, manifest.name ?? '', options.gitRoot);
4295
1911
  if (repoRoot) {
@@ -4325,7 +1941,7 @@ function parseArgs(argv) {
4325
1941
  const options = {
4326
1942
  pluginDir: null,
4327
1943
  strictAgentSkills: false,
4328
- claudeSkillProfile: 'minimum',
1944
+ claudeSkillProfile: 'current',
4329
1945
  versionBase: 'HEAD',
4330
1946
  workspaceRoot: null,
4331
1947
  json: args.includes('--json'),