@lesliechan721/aw 0.1.0-beta.10

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 (508) hide show
  1. package/dist/authoring/assets/aw-config.d.mts +51 -0
  2. package/dist/authoring/assets/aw-config.mjs +1025 -0
  3. package/dist/authoring/assets/aw-config.mjs.map +1 -0
  4. package/dist/authoring/scripts/add-skill.d.mts +2 -0
  5. package/dist/authoring/scripts/add-skill.mjs +355 -0
  6. package/dist/authoring/scripts/add-skill.mjs.map +1 -0
  7. package/dist/authoring/scripts/init-plugin.d.mts +2 -0
  8. package/dist/authoring/scripts/init-plugin.mjs +487 -0
  9. package/dist/authoring/scripts/init-plugin.mjs.map +1 -0
  10. package/dist/authoring/scripts/lib/javascript-import-scanner.d.mts +4 -0
  11. package/dist/authoring/scripts/lib/javascript-import-scanner.mjs +261 -0
  12. package/dist/authoring/scripts/lib/javascript-import-scanner.mjs.map +1 -0
  13. package/dist/authoring/scripts/lib/plugin-root.d.mts +26 -0
  14. package/dist/authoring/scripts/lib/plugin-root.mjs +125 -0
  15. package/dist/authoring/scripts/lib/plugin-root.mjs.map +1 -0
  16. package/dist/authoring/scripts/lib/plugin-version-check.d.mts +69 -0
  17. package/dist/authoring/scripts/lib/plugin-version-check.mjs +563 -0
  18. package/dist/authoring/scripts/lib/plugin-version-check.mjs.map +1 -0
  19. package/dist/authoring/scripts/lib/semver.d.mts +9 -0
  20. package/dist/authoring/scripts/lib/semver.mjs +63 -0
  21. package/dist/authoring/scripts/lib/semver.mjs.map +1 -0
  22. package/dist/authoring/scripts/lib/skill-scaffold.d.mts +111 -0
  23. package/dist/authoring/scripts/lib/skill-scaffold.mjs +353 -0
  24. package/dist/authoring/scripts/lib/skill-scaffold.mjs.map +1 -0
  25. package/dist/authoring/scripts/plugin-status.d.mts +2 -0
  26. package/dist/authoring/scripts/plugin-status.mjs +93 -0
  27. package/dist/authoring/scripts/plugin-status.mjs.map +1 -0
  28. package/dist/authoring/scripts/remove-plugin.d.mts +2 -0
  29. package/dist/authoring/scripts/remove-plugin.mjs +367 -0
  30. package/dist/authoring/scripts/remove-plugin.mjs.map +1 -0
  31. package/dist/authoring/scripts/validate-plugin.d.mts +2 -0
  32. package/dist/authoring/scripts/validate-plugin.mjs +3465 -0
  33. package/dist/authoring/scripts/validate-plugin.mjs.map +1 -0
  34. package/dist/authoring/scripts/validate-skill.d.mts +2 -0
  35. package/dist/authoring/scripts/validate-skill.mjs +126 -0
  36. package/dist/authoring/scripts/validate-skill.mjs.map +1 -0
  37. package/dist/authoring/templates/aw-config-runtime.d.mts +2 -0
  38. package/dist/authoring/templates/aw-config-runtime.mjs +407 -0
  39. package/dist/authoring/templates/aw-config-runtime.mjs.map +1 -0
  40. package/dist/index.d.ts +2 -0
  41. package/dist/index.js +8 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/scripts/aw-skill-eval-materializer.d.ts +24 -0
  44. package/dist/scripts/aw-skill-eval-materializer.js +309 -0
  45. package/dist/scripts/aw-skill-eval-materializer.js.map +1 -0
  46. package/dist/scripts/bundle-plugins.d.ts +17 -0
  47. package/dist/scripts/bundle-plugins.js +126 -0
  48. package/dist/scripts/bundle-plugins.js.map +1 -0
  49. package/dist/scripts/plugin-staging.d.ts +26 -0
  50. package/dist/scripts/plugin-staging.js +76 -0
  51. package/dist/scripts/plugin-staging.js.map +1 -0
  52. package/dist/scripts/test-plugin-scripts.d.ts +7 -0
  53. package/dist/scripts/test-plugin-scripts.js +610 -0
  54. package/dist/scripts/test-plugin-scripts.js.map +1 -0
  55. package/dist/src/adapters/helpers.d.ts +44 -0
  56. package/dist/src/adapters/helpers.js +95 -0
  57. package/dist/src/adapters/helpers.js.map +1 -0
  58. package/dist/src/authoring/workspace-commands.d.ts +70 -0
  59. package/dist/src/authoring/workspace-commands.js +158 -0
  60. package/dist/src/authoring/workspace-commands.js.map +1 -0
  61. package/dist/src/commands/aw-capabilities.d.ts +78 -0
  62. package/dist/src/commands/aw-capabilities.js +254 -0
  63. package/dist/src/commands/aw-capabilities.js.map +1 -0
  64. package/dist/src/commands/catalog-dev-source.d.ts +120 -0
  65. package/dist/src/commands/catalog-dev-source.js +434 -0
  66. package/dist/src/commands/catalog-dev-source.js.map +1 -0
  67. package/dist/src/commands/catalog-generation.d.ts +16 -0
  68. package/dist/src/commands/catalog-generation.js +9 -0
  69. package/dist/src/commands/catalog-generation.js.map +1 -0
  70. package/dist/src/commands/catalog-publication-inspection.d.ts +138 -0
  71. package/dist/src/commands/catalog-publication-inspection.js +711 -0
  72. package/dist/src/commands/catalog-publication-inspection.js.map +1 -0
  73. package/dist/src/commands/catalog-publication-journal.d.ts +56 -0
  74. package/dist/src/commands/catalog-publication-journal.js +215 -0
  75. package/dist/src/commands/catalog-publication-journal.js.map +1 -0
  76. package/dist/src/commands/catalog-publication-target.d.ts +18 -0
  77. package/dist/src/commands/catalog-publication-target.js +95 -0
  78. package/dist/src/commands/catalog-publication-target.js.map +1 -0
  79. package/dist/src/commands/catalog-publish.d.ts +103 -0
  80. package/dist/src/commands/catalog-publish.js +804 -0
  81. package/dist/src/commands/catalog-publish.js.map +1 -0
  82. package/dist/src/commands/catalog-source.d.ts +134 -0
  83. package/dist/src/commands/catalog-source.js +377 -0
  84. package/dist/src/commands/catalog-source.js.map +1 -0
  85. package/dist/src/commands/catalog-status.d.ts +56 -0
  86. package/dist/src/commands/catalog-status.js +217 -0
  87. package/dist/src/commands/catalog-status.js.map +1 -0
  88. package/dist/src/commands/catalog-store.d.ts +80 -0
  89. package/dist/src/commands/catalog-store.js +348 -0
  90. package/dist/src/commands/catalog-store.js.map +1 -0
  91. package/dist/src/commands/catalog-workspace-resolution.d.ts +13 -0
  92. package/dist/src/commands/catalog-workspace-resolution.js +42 -0
  93. package/dist/src/commands/catalog-workspace-resolution.js.map +1 -0
  94. package/dist/src/commands/console.d.ts +3 -0
  95. package/dist/src/commands/console.js +44 -0
  96. package/dist/src/commands/console.js.map +1 -0
  97. package/dist/src/commands/dependency-operation-plan.d.ts +58 -0
  98. package/dist/src/commands/dependency-operation-plan.js +261 -0
  99. package/dist/src/commands/dependency-operation-plan.js.map +1 -0
  100. package/dist/src/commands/init.d.ts +25 -0
  101. package/dist/src/commands/init.js +42 -0
  102. package/dist/src/commands/init.js.map +1 -0
  103. package/dist/src/commands/offline-cleanup-evidence.d.ts +59 -0
  104. package/dist/src/commands/offline-cleanup-evidence.js +163 -0
  105. package/dist/src/commands/offline-cleanup-evidence.js.map +1 -0
  106. package/dist/src/commands/operation-plan.d.ts +126 -0
  107. package/dist/src/commands/operation-plan.js +47 -0
  108. package/dist/src/commands/operation-plan.js.map +1 -0
  109. package/dist/src/commands/operation-planner.d.ts +46 -0
  110. package/dist/src/commands/operation-planner.js +139 -0
  111. package/dist/src/commands/operation-planner.js.map +1 -0
  112. package/dist/src/commands/options.d.ts +70 -0
  113. package/dist/src/commands/options.js +194 -0
  114. package/dist/src/commands/options.js.map +1 -0
  115. package/dist/src/commands/plugin-capabilities.d.ts +22 -0
  116. package/dist/src/commands/plugin-capabilities.js +159 -0
  117. package/dist/src/commands/plugin-capabilities.js.map +1 -0
  118. package/dist/src/commands/rebuild-command.d.ts +88 -0
  119. package/dist/src/commands/rebuild-command.js +3626 -0
  120. package/dist/src/commands/rebuild-command.js.map +1 -0
  121. package/dist/src/commands/rebuild-integration.d.ts +190 -0
  122. package/dist/src/commands/rebuild-integration.js +4439 -0
  123. package/dist/src/commands/rebuild-integration.js.map +1 -0
  124. package/dist/src/commands/rebuild-operations.d.ts +100 -0
  125. package/dist/src/commands/rebuild-operations.js +625 -0
  126. package/dist/src/commands/rebuild-operations.js.map +1 -0
  127. package/dist/src/commands/reconcile-operation-plan.d.ts +26 -0
  128. package/dist/src/commands/reconcile-operation-plan.js +28 -0
  129. package/dist/src/commands/reconcile-operation-plan.js.map +1 -0
  130. package/dist/src/commands/review-publication.d.ts +99 -0
  131. package/dist/src/commands/review-publication.js +904 -0
  132. package/dist/src/commands/review-publication.js.map +1 -0
  133. package/dist/src/commands/runtime.d.ts +172 -0
  134. package/dist/src/commands/runtime.js +720 -0
  135. package/dist/src/commands/runtime.js.map +1 -0
  136. package/dist/src/commands/skill-eval.d.ts +33 -0
  137. package/dist/src/commands/skill-eval.js +363 -0
  138. package/dist/src/commands/skill-eval.js.map +1 -0
  139. package/dist/src/commands/status-v6.d.ts +206 -0
  140. package/dist/src/commands/status-v6.js +2175 -0
  141. package/dist/src/commands/status-v6.js.map +1 -0
  142. package/dist/src/commands/sync-command.d.ts +23 -0
  143. package/dist/src/commands/sync-command.js +242 -0
  144. package/dist/src/commands/sync-command.js.map +1 -0
  145. package/dist/src/commands/wizard.d.ts +56 -0
  146. package/dist/src/commands/wizard.js +58 -0
  147. package/dist/src/commands/wizard.js.map +1 -0
  148. package/dist/src/commands/write-commands.d.ts +7 -0
  149. package/dist/src/commands/write-commands.js +190 -0
  150. package/dist/src/commands/write-commands.js.map +1 -0
  151. package/dist/src/constants.d.ts +31 -0
  152. package/dist/src/constants.js +32 -0
  153. package/dist/src/constants.js.map +1 -0
  154. package/dist/src/eval/manifest-v1.d.ts +67 -0
  155. package/dist/src/eval/manifest-v1.js +347 -0
  156. package/dist/src/eval/manifest-v1.js.map +1 -0
  157. package/dist/src/generators/agents.d.ts +3 -0
  158. package/dist/src/generators/agents.js +46 -0
  159. package/dist/src/generators/agents.js.map +1 -0
  160. package/dist/src/generators/hooks.d.ts +15 -0
  161. package/dist/src/generators/hooks.js +76 -0
  162. package/dist/src/generators/hooks.js.map +1 -0
  163. package/dist/src/generators/instructions.d.ts +13 -0
  164. package/dist/src/generators/instructions.js +66 -0
  165. package/dist/src/generators/instructions.js.map +1 -0
  166. package/dist/src/generators/local-plugin.d.ts +56 -0
  167. package/dist/src/generators/local-plugin.js +1373 -0
  168. package/dist/src/generators/local-plugin.js.map +1 -0
  169. package/dist/src/generators/permissions.d.ts +10 -0
  170. package/dist/src/generators/permissions.js +37 -0
  171. package/dist/src/generators/permissions.js.map +1 -0
  172. package/dist/src/generators/shared.d.ts +2 -0
  173. package/dist/src/generators/shared.js +15 -0
  174. package/dist/src/generators/shared.js.map +1 -0
  175. package/dist/src/index.d.ts +41 -0
  176. package/dist/src/index.js +3327 -0
  177. package/dist/src/index.js.map +1 -0
  178. package/dist/src/output/command-receipt.d.ts +87 -0
  179. package/dist/src/output/command-receipt.js +302 -0
  180. package/dist/src/output/command-receipt.js.map +1 -0
  181. package/dist/src/output/debug-log.d.ts +4 -0
  182. package/dist/src/output/debug-log.js +97 -0
  183. package/dist/src/output/debug-log.js.map +1 -0
  184. package/dist/src/output/equivalent-command.d.ts +9 -0
  185. package/dist/src/output/equivalent-command.js +39 -0
  186. package/dist/src/output/equivalent-command.js.map +1 -0
  187. package/dist/src/output/model.d.ts +76 -0
  188. package/dist/src/output/model.js +2 -0
  189. package/dist/src/output/model.js.map +1 -0
  190. package/dist/src/output/rebuild-progress.d.ts +21 -0
  191. package/dist/src/output/rebuild-progress.js +128 -0
  192. package/dist/src/output/rebuild-progress.js.map +1 -0
  193. package/dist/src/output/redact.d.ts +3 -0
  194. package/dist/src/output/redact.js +39 -0
  195. package/dist/src/output/redact.js.map +1 -0
  196. package/dist/src/output/reporter.d.ts +9 -0
  197. package/dist/src/output/reporter.js +133 -0
  198. package/dist/src/output/reporter.js.map +1 -0
  199. package/dist/src/portable/commands.d.ts +124 -0
  200. package/dist/src/portable/commands.js +557 -0
  201. package/dist/src/portable/commands.js.map +1 -0
  202. package/dist/src/portable/materializer.d.ts +50 -0
  203. package/dist/src/portable/materializer.js +462 -0
  204. package/dist/src/portable/materializer.js.map +1 -0
  205. package/dist/src/portable/skills-cli.d.ts +43 -0
  206. package/dist/src/portable/skills-cli.js +148 -0
  207. package/dist/src/portable/skills-cli.js.map +1 -0
  208. package/dist/src/tui/catalog-freshness.d.ts +1 -0
  209. package/dist/src/tui/catalog-freshness.js +2 -0
  210. package/dist/src/tui/catalog-freshness.js.map +1 -0
  211. package/dist/src/tui/catalog-generation.d.ts +21 -0
  212. package/dist/src/tui/catalog-generation.js +116 -0
  213. package/dist/src/tui/catalog-generation.js.map +1 -0
  214. package/dist/src/tui/catalog-sources/projection.d.ts +4 -0
  215. package/dist/src/tui/catalog-sources/projection.js +17 -0
  216. package/dist/src/tui/catalog-sources/projection.js.map +1 -0
  217. package/dist/src/tui/catalog-sources/review.d.ts +3 -0
  218. package/dist/src/tui/catalog-sources/review.js +13 -0
  219. package/dist/src/tui/catalog-sources/review.js.map +1 -0
  220. package/dist/src/tui/catalog-sources/screens.d.ts +12 -0
  221. package/dist/src/tui/catalog-sources/screens.js +33 -0
  222. package/dist/src/tui/catalog-sources/screens.js.map +1 -0
  223. package/dist/src/tui/catalog-sources/session.d.ts +22 -0
  224. package/dist/src/tui/catalog-sources/session.js +225 -0
  225. package/dist/src/tui/catalog-sources/session.js.map +1 -0
  226. package/dist/src/tui/catalog-sources/types.d.ts +41 -0
  227. package/dist/src/tui/catalog-sources/types.js +2 -0
  228. package/dist/src/tui/catalog-sources/types.js.map +1 -0
  229. package/dist/src/tui/components.d.ts +102 -0
  230. package/dist/src/tui/components.js +184 -0
  231. package/dist/src/tui/components.js.map +1 -0
  232. package/dist/src/tui/console-app-v4.d.ts +20 -0
  233. package/dist/src/tui/console-app-v4.js +5066 -0
  234. package/dist/src/tui/console-app-v4.js.map +1 -0
  235. package/dist/src/tui/controller-runtime.d.ts +23 -0
  236. package/dist/src/tui/controller-runtime.js +2011 -0
  237. package/dist/src/tui/controller-runtime.js.map +1 -0
  238. package/dist/src/tui/controller.d.ts +557 -0
  239. package/dist/src/tui/controller.js +2120 -0
  240. package/dist/src/tui/controller.js.map +1 -0
  241. package/dist/src/tui/diagnostics.d.ts +30 -0
  242. package/dist/src/tui/diagnostics.js +71 -0
  243. package/dist/src/tui/diagnostics.js.map +1 -0
  244. package/dist/src/tui/index.d.ts +17 -0
  245. package/dist/src/tui/index.js +17 -0
  246. package/dist/src/tui/index.js.map +1 -0
  247. package/dist/src/tui/input-display.d.ts +8 -0
  248. package/dist/src/tui/input-display.js +36 -0
  249. package/dist/src/tui/input-display.js.map +1 -0
  250. package/dist/src/tui/keys.d.ts +12 -0
  251. package/dist/src/tui/keys.js +22 -0
  252. package/dist/src/tui/keys.js.map +1 -0
  253. package/dist/src/tui/layout.d.ts +12 -0
  254. package/dist/src/tui/layout.js +19 -0
  255. package/dist/src/tui/layout.js.map +1 -0
  256. package/dist/src/tui/model.d.ts +424 -0
  257. package/dist/src/tui/model.js +1493 -0
  258. package/dist/src/tui/model.js.map +1 -0
  259. package/dist/src/tui/operation-review-planner.d.ts +21 -0
  260. package/dist/src/tui/operation-review-planner.js +622 -0
  261. package/dist/src/tui/operation-review-planner.js.map +1 -0
  262. package/dist/src/tui/prompt.d.ts +8 -0
  263. package/dist/src/tui/prompt.js +231 -0
  264. package/dist/src/tui/prompt.js.map +1 -0
  265. package/dist/src/tui/router.d.ts +206 -0
  266. package/dist/src/tui/router.js +137 -0
  267. package/dist/src/tui/router.js.map +1 -0
  268. package/dist/src/tui/runner.d.ts +11 -0
  269. package/dist/src/tui/runner.js +71 -0
  270. package/dist/src/tui/runner.js.map +1 -0
  271. package/dist/src/tui/source-ref-presets.d.ts +3 -0
  272. package/dist/src/tui/source-ref-presets.js +11 -0
  273. package/dist/src/tui/source-ref-presets.js.map +1 -0
  274. package/dist/src/tui/theme.d.ts +26 -0
  275. package/dist/src/tui/theme.js +28 -0
  276. package/dist/src/tui/theme.js.map +1 -0
  277. package/dist/src/tui/viewport.d.ts +20 -0
  278. package/dist/src/tui/viewport.js +29 -0
  279. package/dist/src/tui/viewport.js.map +1 -0
  280. package/dist/src/tui/views.d.ts +57 -0
  281. package/dist/src/tui/views.js +201 -0
  282. package/dist/src/tui/views.js.map +1 -0
  283. package/dist/src/tui/wizard.d.ts +11 -0
  284. package/dist/src/tui/wizard.js +323 -0
  285. package/dist/src/tui/wizard.js.map +1 -0
  286. package/dist/src/types.d.ts +474 -0
  287. package/dist/src/types.js +34 -0
  288. package/dist/src/types.js.map +1 -0
  289. package/dist/src/utils/agent-version.d.ts +19 -0
  290. package/dist/src/utils/agent-version.js +205 -0
  291. package/dist/src/utils/agent-version.js.map +1 -0
  292. package/dist/src/utils/artifact-plan.d.ts +27 -0
  293. package/dist/src/utils/artifact-plan.js +453 -0
  294. package/dist/src/utils/artifact-plan.js.map +1 -0
  295. package/dist/src/utils/artifact-renderer.d.ts +129 -0
  296. package/dist/src/utils/artifact-renderer.js +400 -0
  297. package/dist/src/utils/artifact-renderer.js.map +1 -0
  298. package/dist/src/utils/artifact-request.d.ts +16 -0
  299. package/dist/src/utils/artifact-request.js +42 -0
  300. package/dist/src/utils/artifact-request.js.map +1 -0
  301. package/dist/src/utils/artifact-sources.d.ts +8 -0
  302. package/dist/src/utils/artifact-sources.js +10 -0
  303. package/dist/src/utils/artifact-sources.js.map +1 -0
  304. package/dist/src/utils/aw-home-mutation-lock.d.ts +11 -0
  305. package/dist/src/utils/aw-home-mutation-lock.js +83 -0
  306. package/dist/src/utils/aw-home-mutation-lock.js.map +1 -0
  307. package/dist/src/utils/bundle-integrity.d.ts +2 -0
  308. package/dist/src/utils/bundle-integrity.js +63 -0
  309. package/dist/src/utils/bundle-integrity.js.map +1 -0
  310. package/dist/src/utils/bundle-layout.d.ts +4 -0
  311. package/dist/src/utils/bundle-layout.js +531 -0
  312. package/dist/src/utils/bundle-layout.js.map +1 -0
  313. package/dist/src/utils/catalog-digests.d.ts +18 -0
  314. package/dist/src/utils/catalog-digests.js +156 -0
  315. package/dist/src/utils/catalog-digests.js.map +1 -0
  316. package/dist/src/utils/catalog-generation-control-snapshot.d.ts +11 -0
  317. package/dist/src/utils/catalog-generation-control-snapshot.js +45 -0
  318. package/dist/src/utils/catalog-generation-control-snapshot.js.map +1 -0
  319. package/dist/src/utils/catalog-generation-error.d.ts +16 -0
  320. package/dist/src/utils/catalog-generation-error.js +30 -0
  321. package/dist/src/utils/catalog-generation-error.js.map +1 -0
  322. package/dist/src/utils/catalog-generation-resolver.d.ts +32 -0
  323. package/dist/src/utils/catalog-generation-resolver.js +251 -0
  324. package/dist/src/utils/catalog-generation-resolver.js.map +1 -0
  325. package/dist/src/utils/catalog-generation-service.d.ts +161 -0
  326. package/dist/src/utils/catalog-generation-service.js +1237 -0
  327. package/dist/src/utils/catalog-generation-service.js.map +1 -0
  328. package/dist/src/utils/catalog-generation-state.d.ts +22 -0
  329. package/dist/src/utils/catalog-generation-state.js +192 -0
  330. package/dist/src/utils/catalog-generation-state.js.map +1 -0
  331. package/dist/src/utils/catalog-generation-store.d.ts +57 -0
  332. package/dist/src/utils/catalog-generation-store.js +397 -0
  333. package/dist/src/utils/catalog-generation-store.js.map +1 -0
  334. package/dist/src/utils/catalog-manifest-v7.d.ts +5 -0
  335. package/dist/src/utils/catalog-manifest-v7.js +98 -0
  336. package/dist/src/utils/catalog-manifest-v7.js.map +1 -0
  337. package/dist/src/utils/catalog-operation-context.d.ts +20 -0
  338. package/dist/src/utils/catalog-operation-context.js +141 -0
  339. package/dist/src/utils/catalog-operation-context.js.map +1 -0
  340. package/dist/src/utils/catalog-public-error.d.ts +19 -0
  341. package/dist/src/utils/catalog-public-error.js +100 -0
  342. package/dist/src/utils/catalog-public-error.js.map +1 -0
  343. package/dist/src/utils/catalog-runtime-projection.d.ts +33 -0
  344. package/dist/src/utils/catalog-runtime-projection.js +77 -0
  345. package/dist/src/utils/catalog-runtime-projection.js.map +1 -0
  346. package/dist/src/utils/catalog-snapshot.d.ts +10 -0
  347. package/dist/src/utils/catalog-snapshot.js +20 -0
  348. package/dist/src/utils/catalog-snapshot.js.map +1 -0
  349. package/dist/src/utils/catalog-source-identity.d.ts +5 -0
  350. package/dist/src/utils/catalog-source-identity.js +137 -0
  351. package/dist/src/utils/catalog-source-identity.js.map +1 -0
  352. package/dist/src/utils/catalog-source-impact.d.ts +20 -0
  353. package/dist/src/utils/catalog-source-impact.js +222 -0
  354. package/dist/src/utils/catalog-source-impact.js.map +1 -0
  355. package/dist/src/utils/catalog-source-presentation.d.ts +1 -0
  356. package/dist/src/utils/catalog-source-presentation.js +32 -0
  357. package/dist/src/utils/catalog-source-presentation.js.map +1 -0
  358. package/dist/src/utils/catalog-source-references.d.ts +66 -0
  359. package/dist/src/utils/catalog-source-references.js +1180 -0
  360. package/dist/src/utils/catalog-source-references.js.map +1 -0
  361. package/dist/src/utils/catalog-sources.d.ts +53 -0
  362. package/dist/src/utils/catalog-sources.js +456 -0
  363. package/dist/src/utils/catalog-sources.js.map +1 -0
  364. package/dist/src/utils/codex-config.d.ts +126 -0
  365. package/dist/src/utils/codex-config.js +1032 -0
  366. package/dist/src/utils/codex-config.js.map +1 -0
  367. package/dist/src/utils/codex-manager.d.ts +81 -0
  368. package/dist/src/utils/codex-manager.js +810 -0
  369. package/dist/src/utils/codex-manager.js.map +1 -0
  370. package/dist/src/utils/codex-marketplace-path.d.ts +5 -0
  371. package/dist/src/utils/codex-marketplace-path.js +45 -0
  372. package/dist/src/utils/codex-marketplace-path.js.map +1 -0
  373. package/dist/src/utils/codex-native-observation.d.ts +16 -0
  374. package/dist/src/utils/codex-native-observation.js +22 -0
  375. package/dist/src/utils/codex-native-observation.js.map +1 -0
  376. package/dist/src/utils/codex-native-render-receipt.d.ts +40 -0
  377. package/dist/src/utils/codex-native-render-receipt.js +205 -0
  378. package/dist/src/utils/codex-native-render-receipt.js.map +1 -0
  379. package/dist/src/utils/codex-reconciler.d.ts +128 -0
  380. package/dist/src/utils/codex-reconciler.js +294 -0
  381. package/dist/src/utils/codex-reconciler.js.map +1 -0
  382. package/dist/src/utils/codex-roles.d.ts +71 -0
  383. package/dist/src/utils/codex-roles.js +257 -0
  384. package/dist/src/utils/codex-roles.js.map +1 -0
  385. package/dist/src/utils/codex-shared-native.d.ts +63 -0
  386. package/dist/src/utils/codex-shared-native.js +142 -0
  387. package/dist/src/utils/codex-shared-native.js.map +1 -0
  388. package/dist/src/utils/codex-skill-staging.d.ts +11 -0
  389. package/dist/src/utils/codex-skill-staging.js +8 -0
  390. package/dist/src/utils/codex-skill-staging.js.map +1 -0
  391. package/dist/src/utils/codex-surface-analysis.d.ts +45 -0
  392. package/dist/src/utils/codex-surface-analysis.js +245 -0
  393. package/dist/src/utils/codex-surface-analysis.js.map +1 -0
  394. package/dist/src/utils/config-value.d.ts +3 -0
  395. package/dist/src/utils/config-value.js +23 -0
  396. package/dist/src/utils/config-value.js.map +1 -0
  397. package/dist/src/utils/dynamic-skill-tree.d.ts +36 -0
  398. package/dist/src/utils/dynamic-skill-tree.js +466 -0
  399. package/dist/src/utils/dynamic-skill-tree.js.map +1 -0
  400. package/dist/src/utils/file-rules.d.ts +1 -0
  401. package/dist/src/utils/file-rules.js +2 -0
  402. package/dist/src/utils/file-rules.js.map +1 -0
  403. package/dist/src/utils/git-catalog-provider.d.ts +22 -0
  404. package/dist/src/utils/git-catalog-provider.js +497 -0
  405. package/dist/src/utils/git-catalog-provider.js.map +1 -0
  406. package/dist/src/utils/hooks-contract.d.ts +1 -0
  407. package/dist/src/utils/hooks-contract.js +2 -0
  408. package/dist/src/utils/hooks-contract.js.map +1 -0
  409. package/dist/src/utils/json.d.ts +4 -0
  410. package/dist/src/utils/json.js +29 -0
  411. package/dist/src/utils/json.js.map +1 -0
  412. package/dist/src/utils/local-marketplace.d.ts +41 -0
  413. package/dist/src/utils/local-marketplace.js +316 -0
  414. package/dist/src/utils/local-marketplace.js.map +1 -0
  415. package/dist/src/utils/manifest.d.ts +11 -0
  416. package/dist/src/utils/manifest.js +33 -0
  417. package/dist/src/utils/manifest.js.map +1 -0
  418. package/dist/src/utils/marketplace.d.ts +3 -0
  419. package/dist/src/utils/marketplace.js +76 -0
  420. package/dist/src/utils/marketplace.js.map +1 -0
  421. package/dist/src/utils/multi-source-catalog.d.ts +66 -0
  422. package/dist/src/utils/multi-source-catalog.js +345 -0
  423. package/dist/src/utils/multi-source-catalog.js.map +1 -0
  424. package/dist/src/utils/native-cli.d.ts +118 -0
  425. package/dist/src/utils/native-cli.js +518 -0
  426. package/dist/src/utils/native-cli.js.map +1 -0
  427. package/dist/src/utils/orphan-marketplace-cleanup.d.ts +18 -0
  428. package/dist/src/utils/orphan-marketplace-cleanup.js +198 -0
  429. package/dist/src/utils/orphan-marketplace-cleanup.js.map +1 -0
  430. package/dist/src/utils/ownership.d.ts +194 -0
  431. package/dist/src/utils/ownership.js +723 -0
  432. package/dist/src/utils/ownership.js.map +1 -0
  433. package/dist/src/utils/path-catalog-provider.d.ts +7 -0
  434. package/dist/src/utils/path-catalog-provider.js +74 -0
  435. package/dist/src/utils/path-catalog-provider.js.map +1 -0
  436. package/dist/src/utils/paths.d.ts +40 -0
  437. package/dist/src/utils/paths.js +137 -0
  438. package/dist/src/utils/paths.js.map +1 -0
  439. package/dist/src/utils/platform-entries.d.ts +1 -0
  440. package/dist/src/utils/platform-entries.js +2 -0
  441. package/dist/src/utils/platform-entries.js.map +1 -0
  442. package/dist/src/utils/platform-support.d.ts +1 -0
  443. package/dist/src/utils/platform-support.js +2 -0
  444. package/dist/src/utils/platform-support.js.map +1 -0
  445. package/dist/src/utils/plugin-config-write.d.ts +110 -0
  446. package/dist/src/utils/plugin-config-write.js +773 -0
  447. package/dist/src/utils/plugin-config-write.js.map +1 -0
  448. package/dist/src/utils/plugin-config.d.ts +389 -0
  449. package/dist/src/utils/plugin-config.js +1642 -0
  450. package/dist/src/utils/plugin-config.js.map +1 -0
  451. package/dist/src/utils/plugin-dependencies.d.ts +12 -0
  452. package/dist/src/utils/plugin-dependencies.js +162 -0
  453. package/dist/src/utils/plugin-dependencies.js.map +1 -0
  454. package/dist/src/utils/plugin-intent-state.d.ts +34 -0
  455. package/dist/src/utils/plugin-intent-state.js +289 -0
  456. package/dist/src/utils/plugin-intent-state.js.map +1 -0
  457. package/dist/src/utils/plugin-script-contract.d.ts +1 -0
  458. package/dist/src/utils/plugin-script-contract.js +2 -0
  459. package/dist/src/utils/plugin-script-contract.js.map +1 -0
  460. package/dist/src/utils/plugin-scripts.d.ts +101 -0
  461. package/dist/src/utils/plugin-scripts.js +253 -0
  462. package/dist/src/utils/plugin-scripts.js.map +1 -0
  463. package/dist/src/utils/process-lock.d.ts +47 -0
  464. package/dist/src/utils/process-lock.js +532 -0
  465. package/dist/src/utils/process-lock.js.map +1 -0
  466. package/dist/src/utils/process-tree.d.ts +2 -0
  467. package/dist/src/utils/process-tree.js +2 -0
  468. package/dist/src/utils/process-tree.js.map +1 -0
  469. package/dist/src/utils/project-boundary.d.ts +9 -0
  470. package/dist/src/utils/project-boundary.js +67 -0
  471. package/dist/src/utils/project-boundary.js.map +1 -0
  472. package/dist/src/utils/rendered-contract.d.ts +8 -0
  473. package/dist/src/utils/rendered-contract.js +134 -0
  474. package/dist/src/utils/rendered-contract.js.map +1 -0
  475. package/dist/src/utils/runtime-skill-closure.d.ts +13 -0
  476. package/dist/src/utils/runtime-skill-closure.js +863 -0
  477. package/dist/src/utils/runtime-skill-closure.js.map +1 -0
  478. package/dist/src/utils/safe-fs.d.ts +21 -0
  479. package/dist/src/utils/safe-fs.js +111 -0
  480. package/dist/src/utils/safe-fs.js.map +1 -0
  481. package/dist/src/utils/skill-authoring.d.ts +1 -0
  482. package/dist/src/utils/skill-authoring.js +2 -0
  483. package/dist/src/utils/skill-authoring.js.map +1 -0
  484. package/dist/src/utils/skill-validation.d.ts +37 -0
  485. package/dist/src/utils/skill-validation.js +326 -0
  486. package/dist/src/utils/skill-validation.js.map +1 -0
  487. package/dist/src/utils/slash-commands.d.ts +1 -0
  488. package/dist/src/utils/slash-commands.js +2 -0
  489. package/dist/src/utils/slash-commands.js.map +1 -0
  490. package/dist/src/utils/state-paths.d.ts +14 -0
  491. package/dist/src/utils/state-paths.js +139 -0
  492. package/dist/src/utils/state-paths.js.map +1 -0
  493. package/dist/src/utils/target-eligibility.d.ts +13 -0
  494. package/dist/src/utils/target-eligibility.js +35 -0
  495. package/dist/src/utils/target-eligibility.js.map +1 -0
  496. package/dist/src/utils/target-order.d.ts +7 -0
  497. package/dist/src/utils/target-order.js +10 -0
  498. package/dist/src/utils/target-order.js.map +1 -0
  499. package/dist/src/utils/template-engine.d.ts +1 -0
  500. package/dist/src/utils/template-engine.js +2 -0
  501. package/dist/src/utils/template-engine.js.map +1 -0
  502. package/dist/src/utils/test-path-fence.d.ts +12 -0
  503. package/dist/src/utils/test-path-fence.js +31 -0
  504. package/dist/src/utils/test-path-fence.js.map +1 -0
  505. package/dist/vitest.config.d.ts +2 -0
  506. package/dist/vitest.config.js +16 -0
  507. package/dist/vitest.config.js.map +1 -0
  508. package/package.json +64 -0
@@ -0,0 +1,1025 @@
1
+ #!/usr/bin/env node
2
+ import fs from 'node:fs';
3
+ import os from 'node:os';
4
+ import path from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
6
+ /* Generated validator contract from packages/plugin-core/src/plugin-config.ts. */
7
+ const CONFIG_KEY_PATTERN = /^[A-Za-z][A-Za-z0-9_]*$/u;
8
+ const IDENTIFIER_PATTERN = /^[A-Za-z][A-Za-z0-9_]*$/u;
9
+ const SLUG_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u;
10
+ const SEMVER_PATTERN = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|(?:[0-9A-Za-z-]*[A-Za-z-][0-9A-Za-z-]*))(?:\.(?:0|[1-9]\d*|(?:[0-9A-Za-z-]*[A-Za-z-][0-9A-Za-z-]*)))*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/u;
11
+ const HOSTNAME_PATTERN = /^(?=.{1,253}$)(?:[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)(?:\.(?:[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?))*$/u;
12
+ const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/u;
13
+ const STRING_FORMATS = new Set([
14
+ 'identifier',
15
+ 'slug',
16
+ 'semver',
17
+ 'url',
18
+ 'hostname',
19
+ 'email',
20
+ ]);
21
+ const MAX_OBJECT_PROPERTIES = 32;
22
+ const DANGEROUS_CONFIG_KEYS = new Set(['__proto__', 'constructor', 'prototype']);
23
+ function createPropertyMap() {
24
+ return Object.create(null);
25
+ }
26
+ function ownProperty(value, property) {
27
+ return value !== undefined && Object.hasOwn(value, property) ? value[property] : undefined;
28
+ }
29
+ function isDangerousConfigKey(value) {
30
+ return DANGEROUS_CONFIG_KEYS.has(value);
31
+ }
32
+ function asObject(value, path) {
33
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
34
+ throw new Error(`Invalid ${path}: expected an object.`);
35
+ }
36
+ return value;
37
+ }
38
+ function assertAllowedKeys(value, path, allowed) {
39
+ for (const key of Object.keys(value)) {
40
+ if (!allowed.includes(key)) {
41
+ throw new Error(`Invalid ${path}: unknown field "${key}".`);
42
+ }
43
+ }
44
+ }
45
+ function nonEmptyString(value, path) {
46
+ if (typeof value !== 'string' || value.trim() === '') {
47
+ throw new Error(`Invalid ${path}: expected a non-empty string.`);
48
+ }
49
+ return value;
50
+ }
51
+ function optionalText(value, path) {
52
+ return value === undefined ? undefined : nonEmptyString(value, path);
53
+ }
54
+ function optionalBoolean(value, path) {
55
+ if (value === undefined)
56
+ return undefined;
57
+ if (typeof value !== 'boolean') {
58
+ throw new Error(`Invalid ${path}: expected a boolean.`);
59
+ }
60
+ return value;
61
+ }
62
+ function finiteNumber(value, path) {
63
+ if (typeof value !== 'number' || !Number.isFinite(value)) {
64
+ throw new Error(`Invalid ${path}: expected a finite number.`);
65
+ }
66
+ return value;
67
+ }
68
+ function nonNegativeInteger(value, path) {
69
+ const result = finiteNumber(value, path);
70
+ if (!Number.isInteger(result) || result < 0) {
71
+ throw new Error(`Invalid ${path}: expected a non-negative integer.`);
72
+ }
73
+ return result;
74
+ }
75
+ function normalizeStringValidation(value, path) {
76
+ const input = asObject(value, path);
77
+ assertAllowedKeys(input, path, ['minLength', 'maxLength', 'pattern', 'format']);
78
+ const minLength = input.minLength === undefined
79
+ ? undefined
80
+ : nonNegativeInteger(input.minLength, `${path}.minLength`);
81
+ const maxLength = input.maxLength === undefined
82
+ ? undefined
83
+ : nonNegativeInteger(input.maxLength, `${path}.maxLength`);
84
+ if (minLength !== undefined && maxLength !== undefined && minLength > maxLength) {
85
+ throw new Error(`Invalid ${path}: minLength must be less than or equal to maxLength.`);
86
+ }
87
+ if (input.pattern !== undefined && typeof input.pattern !== 'string') {
88
+ throw new Error(`Invalid ${path}.pattern: expected a string.`);
89
+ }
90
+ const pattern = input.pattern;
91
+ if (pattern !== undefined) {
92
+ try {
93
+ new RegExp(pattern, 'u');
94
+ }
95
+ catch {
96
+ throw new Error(`Invalid ${path}.pattern: expected a valid regular expression.`);
97
+ }
98
+ }
99
+ const format = input.format === undefined
100
+ ? undefined
101
+ : nonEmptyString(input.format, `${path}.format`);
102
+ if (format !== undefined && !STRING_FORMATS.has(format)) {
103
+ throw new Error(`Invalid ${path}.format: unsupported string format "${format}".`);
104
+ }
105
+ return { minLength, maxLength, pattern, format };
106
+ }
107
+ function normalizeNumberValidation(value, path) {
108
+ const input = asObject(value, path);
109
+ assertAllowedKeys(input, path, ['integer', 'minimum', 'maximum', 'multipleOf']);
110
+ const integer = optionalBoolean(input.integer, `${path}.integer`);
111
+ const minimum = input.minimum === undefined
112
+ ? undefined
113
+ : finiteNumber(input.minimum, `${path}.minimum`);
114
+ const maximum = input.maximum === undefined
115
+ ? undefined
116
+ : finiteNumber(input.maximum, `${path}.maximum`);
117
+ const multipleOf = input.multipleOf === undefined
118
+ ? undefined
119
+ : finiteNumber(input.multipleOf, `${path}.multipleOf`);
120
+ if (minimum !== undefined && maximum !== undefined && minimum > maximum) {
121
+ throw new Error(`Invalid ${path}: minimum must be less than or equal to maximum.`);
122
+ }
123
+ if (multipleOf !== undefined && multipleOf <= 0) {
124
+ throw new Error(`Invalid ${path}.multipleOf: expected a number greater than zero.`);
125
+ }
126
+ return { integer, minimum, maximum, multipleOf };
127
+ }
128
+ function createIssue(code, field, message, property) {
129
+ return {
130
+ code,
131
+ path: property === undefined ? { field } : { field, property },
132
+ message,
133
+ recoverable: true,
134
+ };
135
+ }
136
+ function stringFormatMatches(value, format) {
137
+ if (format === 'identifier')
138
+ return IDENTIFIER_PATTERN.test(value);
139
+ if (format === 'slug')
140
+ return SLUG_PATTERN.test(value);
141
+ if (format === 'semver')
142
+ return SEMVER_PATTERN.test(value);
143
+ if (format === 'hostname')
144
+ return HOSTNAME_PATTERN.test(value);
145
+ if (format === 'email')
146
+ return EMAIL_PATTERN.test(value);
147
+ try {
148
+ const url = new URL(value);
149
+ return url.protocol.length > 1;
150
+ }
151
+ catch {
152
+ return false;
153
+ }
154
+ }
155
+ function validateString(value, validation, field, property) {
156
+ if (typeof value !== 'string') {
157
+ return [createIssue('type', field, 'Expected a string.', property)];
158
+ }
159
+ const issues = [];
160
+ if (validation?.minLength !== undefined && [...value].length < validation.minLength) {
161
+ issues.push(createIssue('minLength', field, `Expected at least ${validation.minLength} characters.`, property));
162
+ }
163
+ if (validation?.maxLength !== undefined && [...value].length > validation.maxLength) {
164
+ issues.push(createIssue('maxLength', field, `Expected at most ${validation.maxLength} characters.`, property));
165
+ }
166
+ if (validation?.pattern !== undefined && !new RegExp(validation.pattern, 'u').test(value)) {
167
+ issues.push(createIssue('pattern', field, `Expected a value that matches ${validation.pattern}.`, property));
168
+ }
169
+ if (validation?.format !== undefined && !stringFormatMatches(value, validation.format)) {
170
+ issues.push(createIssue('format', field, `Expected ${validation.format} format.`, property));
171
+ }
172
+ return issues;
173
+ }
174
+ function validateNumber(value, validation, field, property) {
175
+ if (typeof value !== 'number' || !Number.isFinite(value)) {
176
+ return [createIssue('type', field, 'Expected a finite number.', property)];
177
+ }
178
+ const issues = [];
179
+ if (validation?.integer === true && !Number.isInteger(value)) {
180
+ issues.push(createIssue('integer', field, 'Expected an integer.', property));
181
+ }
182
+ if (validation?.minimum !== undefined && value < validation.minimum) {
183
+ issues.push(createIssue('minimum', field, `Expected a number greater than or equal to ${validation.minimum}.`, property));
184
+ }
185
+ if (validation?.maximum !== undefined && value > validation.maximum) {
186
+ issues.push(createIssue('maximum', field, `Expected a number less than or equal to ${validation.maximum}.`, property));
187
+ }
188
+ if (validation?.multipleOf !== undefined
189
+ && Math.abs(value / validation.multipleOf - Math.round(value / validation.multipleOf)) > 1e-9) {
190
+ issues.push(createIssue('multipleOf', field, `Expected a multiple of ${validation.multipleOf}.`, property));
191
+ }
192
+ return issues;
193
+ }
194
+ function validateScalarField(fieldDefinition, value, field, property, checkChoices = true) {
195
+ const issues = fieldDefinition.type === 'string'
196
+ ? validateString(value, fieldDefinition.validation, field, property)
197
+ : fieldDefinition.type === 'number'
198
+ ? validateNumber(value, fieldDefinition.validation, field, property)
199
+ : typeof value === 'boolean'
200
+ ? []
201
+ : [createIssue('type', field, 'Expected a boolean.', property)];
202
+ if (checkChoices
203
+ && issues.length === 0
204
+ && fieldDefinition.choices?.allowCustom === false
205
+ && matchPluginConfigPreset(fieldDefinition, value) === undefined) {
206
+ issues.push(createIssue('choice', field, 'Expected a declared preset value.', property));
207
+ }
208
+ return issues;
209
+ }
210
+ function validateObjectField(fieldDefinition, value, field, checkChoices = true) {
211
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
212
+ return [createIssue('type', field, 'Expected an object.')];
213
+ }
214
+ const input = value;
215
+ const keys = Object.keys(input);
216
+ const issues = [];
217
+ if (keys.length > MAX_OBJECT_PROPERTIES) {
218
+ issues.push(createIssue('maxProperties', field, `Expected at most ${MAX_OBJECT_PROPERTIES} properties.`));
219
+ }
220
+ if (fieldDefinition.validation?.minProperties !== undefined
221
+ && keys.length < fieldDefinition.validation.minProperties) {
222
+ issues.push(createIssue('minProperties', field, `Expected at least ${fieldDefinition.validation.minProperties} properties.`));
223
+ }
224
+ if (fieldDefinition.validation?.maxProperties !== undefined
225
+ && keys.length > fieldDefinition.validation.maxProperties) {
226
+ issues.push(createIssue('maxProperties', field, `Expected at most ${fieldDefinition.validation.maxProperties} properties.`));
227
+ }
228
+ for (const [property, child] of Object.entries(fieldDefinition.properties ?? {})) {
229
+ if (child.required === true && !Object.hasOwn(input, property)) {
230
+ issues.push(createIssue('required', field, 'Required property is missing.', property));
231
+ }
232
+ }
233
+ for (const [property, childValue] of Object.entries(input)) {
234
+ if (isDangerousConfigKey(property)) {
235
+ issues.push(createIssue('dangerousKey', field, 'Dangerous config key is not allowed.', property));
236
+ continue;
237
+ }
238
+ const child = ownProperty(fieldDefinition.properties, property);
239
+ if (child !== undefined) {
240
+ issues.push(...validateScalarField(child, childValue, field, property));
241
+ continue;
242
+ }
243
+ const dynamicChild = fieldDefinition.additionalProperties;
244
+ if (dynamicChild === undefined || dynamicChild === false) {
245
+ issues.push(createIssue('additionalProperty', field, 'Additional property is not allowed.', property));
246
+ continue;
247
+ }
248
+ if (fieldDefinition.validation?.key !== undefined) {
249
+ issues.push(...validateString(property, fieldDefinition.validation.key, field, property));
250
+ }
251
+ issues.push(...validateScalarField(dynamicChild, childValue, field, property));
252
+ }
253
+ if (checkChoices
254
+ && issues.length === 0
255
+ && fieldDefinition.choices?.allowCustom === false
256
+ && matchPluginConfigPreset(fieldDefinition, input) === undefined) {
257
+ issues.push(createIssue('choice', field, 'Expected a declared preset value.'));
258
+ }
259
+ return issues;
260
+ }
261
+ function resolveValueArguments(first, second, third) {
262
+ if (typeof first === 'string') {
263
+ return {
264
+ field: first,
265
+ definition: second,
266
+ value: third,
267
+ };
268
+ }
269
+ return {
270
+ definition: first,
271
+ value: second,
272
+ field: typeof third === 'string' ? third : 'value',
273
+ };
274
+ }
275
+ export function validatePluginConfigValue(first, second, third) {
276
+ const resolved = resolveValueArguments(first, second, third);
277
+ return resolved.definition.type === 'object'
278
+ ? validateObjectField(resolved.definition, resolved.value, resolved.field)
279
+ : validateScalarField(resolved.definition, resolved.value, resolved.field);
280
+ }
281
+ export function validatePluginConfigDocument(definition, value) {
282
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
283
+ return [createIssue('type', '$document', 'Expected a config object.')];
284
+ }
285
+ const input = value;
286
+ const issues = [];
287
+ for (const [field, fieldDefinition] of Object.entries(definition.fields)) {
288
+ if (!Object.hasOwn(input, field)) {
289
+ if (fieldDefinition.required === true) {
290
+ issues.push(createIssue('required', field, 'Required field is missing.'));
291
+ }
292
+ continue;
293
+ }
294
+ issues.push(...validatePluginConfigValue(fieldDefinition, input[field], field));
295
+ }
296
+ for (const field of Object.keys(input)) {
297
+ if (isDangerousConfigKey(field)) {
298
+ issues.push(createIssue('dangerousKey', field, 'Dangerous config key is not allowed.'));
299
+ continue;
300
+ }
301
+ if (!Object.hasOwn(definition.fields, field)) {
302
+ issues.push(createIssue('unknownField', field, 'Unknown config field.'));
303
+ }
304
+ }
305
+ return issues;
306
+ }
307
+ export function canonicalizePluginConfigValue(value) {
308
+ if (typeof value !== 'object')
309
+ return value;
310
+ return Object.fromEntries(Object.entries(value).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0));
311
+ }
312
+ export function canonicalizePluginConfigValues(values) {
313
+ return Object.fromEntries(Object.entries(values)
314
+ .sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0)
315
+ .map(([key, value]) => [key, canonicalizePluginConfigValue(value)]));
316
+ }
317
+ export function stablePluginConfigStringify(value) {
318
+ return JSON.stringify(canonicalizePluginConfigValue(value));
319
+ }
320
+ export function matchPluginConfigPreset(definition, value) {
321
+ return definition.choices?.presets.find((preset) => stablePluginConfigStringify(preset.value) === stablePluginConfigStringify(value));
322
+ }
323
+ export function validatePluginConfigPreset(definition, preset, field = 'value') {
324
+ return definition.type === 'object'
325
+ ? validateObjectField(definition, preset.value, field, false)
326
+ : validateScalarField(definition, preset.value, field, undefined, false);
327
+ }
328
+ export function redactPluginConfigValue(definition, value) {
329
+ if (definition.sensitive === true)
330
+ return '[redacted]';
331
+ if (definition.type !== 'object' || typeof value !== 'object')
332
+ return value;
333
+ const redacted = createPropertyMap();
334
+ for (const [property, childValue] of Object.entries(value)) {
335
+ const child = ownProperty(definition.properties, property) ?? (definition.additionalProperties === false ? undefined : definition.additionalProperties);
336
+ redacted[property] = child?.sensitive === true ? '[redacted]' : childValue;
337
+ }
338
+ return redacted;
339
+ }
340
+ export function formatPluginConfigIssue(issue) {
341
+ const path = issue.path.property === undefined
342
+ ? issue.path.field
343
+ : `${issue.path.field}.${issue.path.property}`;
344
+ return `${path}: ${issue.message}`;
345
+ }
346
+ function normalizePreset(value, path) {
347
+ const input = asObject(value, path);
348
+ assertAllowedKeys(input, path, ['id', 'title', 'description', 'value', 'recommended']);
349
+ if (!Object.hasOwn(input, 'value')) {
350
+ throw new Error(`Invalid ${path}.value: value is required.`);
351
+ }
352
+ if (input.recommended !== undefined && input.recommended !== true) {
353
+ throw new Error(`Invalid ${path}.recommended: expected true.`);
354
+ }
355
+ return {
356
+ id: nonEmptyString(input.id, `${path}.id`),
357
+ title: nonEmptyString(input.title, `${path}.title`),
358
+ description: optionalText(input.description, `${path}.description`),
359
+ value: input.value,
360
+ recommended: input.recommended,
361
+ };
362
+ }
363
+ function normalizeChoices(value, path) {
364
+ const input = asObject(value, path);
365
+ assertAllowedKeys(input, path, ['allowCustom', 'presets']);
366
+ if (typeof input.allowCustom !== 'boolean') {
367
+ throw new Error(`Invalid ${path}.allowCustom: expected a boolean.`);
368
+ }
369
+ if (!Array.isArray(input.presets)) {
370
+ throw new Error(`Invalid ${path}.presets: expected an array.`);
371
+ }
372
+ return {
373
+ allowCustom: input.allowCustom,
374
+ presets: input.presets.map((preset, index) => normalizePreset(preset, `${path}.presets[${index}]`)),
375
+ };
376
+ }
377
+ function normalizeScalarField(value, path, options) {
378
+ const input = asObject(value, path);
379
+ const type = nonEmptyString(input.type, `${path}.type`);
380
+ if (type !== 'string' && type !== 'number' && type !== 'boolean') {
381
+ throw new Error(`Invalid ${path}.type: expected string, number, or boolean.`);
382
+ }
383
+ const allowed = ['type', 'title', 'description', 'sensitive'];
384
+ if (options.allowDefault)
385
+ allowed.push('default');
386
+ if (options.allowRequired)
387
+ allowed.push('required');
388
+ allowed.push('choices');
389
+ if (type !== 'boolean')
390
+ allowed.push('validation');
391
+ assertAllowedKeys(input, path, allowed);
392
+ const common = {
393
+ title: optionalText(input.title, `${path}.title`),
394
+ description: optionalText(input.description, `${path}.description`),
395
+ required: options.allowRequired ? optionalBoolean(input.required, `${path}.required`) : undefined,
396
+ sensitive: optionalBoolean(input.sensitive, `${path}.sensitive`),
397
+ };
398
+ const defaultValue = options.allowDefault && input.default !== undefined
399
+ ? input.default
400
+ : undefined;
401
+ if (type === 'string') {
402
+ return {
403
+ type,
404
+ ...common,
405
+ default: defaultValue,
406
+ choices: input.choices === undefined
407
+ ? undefined
408
+ : normalizeChoices(input.choices, `${path}.choices`),
409
+ validation: input.validation === undefined
410
+ ? undefined
411
+ : normalizeStringValidation(input.validation, `${path}.validation`),
412
+ };
413
+ }
414
+ if (type === 'number') {
415
+ return {
416
+ type,
417
+ ...common,
418
+ default: defaultValue,
419
+ choices: input.choices === undefined
420
+ ? undefined
421
+ : normalizeChoices(input.choices, `${path}.choices`),
422
+ validation: input.validation === undefined
423
+ ? undefined
424
+ : normalizeNumberValidation(input.validation, `${path}.validation`),
425
+ };
426
+ }
427
+ return {
428
+ type,
429
+ ...common,
430
+ default: defaultValue,
431
+ choices: input.choices === undefined
432
+ ? undefined
433
+ : normalizeChoices(input.choices, `${path}.choices`),
434
+ };
435
+ }
436
+ function assertChoices(definition, path) {
437
+ if (definition.choices === undefined)
438
+ return;
439
+ if (definition.choices.allowCustom === false && definition.choices.presets.length === 0) {
440
+ throw new Error(`Invalid ${path}.choices.presets: expected at least one preset when allowCustom is false.`);
441
+ }
442
+ const ids = new Set();
443
+ const values = new Set();
444
+ let recommendedCount = 0;
445
+ for (const [index, preset] of definition.choices.presets.entries()) {
446
+ if (ids.has(preset.id)) {
447
+ throw new Error(`Invalid ${path}.choices.presets[${index}].id: duplicate preset id "${preset.id}".`);
448
+ }
449
+ ids.add(preset.id);
450
+ const canonicalValue = stablePluginConfigStringify(preset.value);
451
+ if (values.has(canonicalValue)) {
452
+ throw new Error(`Invalid ${path}.choices.presets[${index}].value: duplicate preset value.`);
453
+ }
454
+ values.add(canonicalValue);
455
+ if (preset.recommended === true)
456
+ recommendedCount += 1;
457
+ const issues = validatePluginConfigPreset(definition, preset, path);
458
+ if (issues.length > 0) {
459
+ throw new Error(`Invalid ${path}.choices.presets[${index}].value: ${formatPluginConfigIssue(issues[0])}`);
460
+ }
461
+ }
462
+ if (recommendedCount > 1) {
463
+ throw new Error(`Invalid ${path}.choices: expected at most one recommended preset.`);
464
+ }
465
+ }
466
+ function normalizeObjectField(value, path) {
467
+ const input = asObject(value, path);
468
+ assertAllowedKeys(input, path, [
469
+ 'type',
470
+ 'title',
471
+ 'description',
472
+ 'default',
473
+ 'required',
474
+ 'sensitive',
475
+ 'choices',
476
+ 'properties',
477
+ 'additionalProperties',
478
+ 'validation',
479
+ ]);
480
+ if (input.properties === undefined && (input.additionalProperties === undefined || input.additionalProperties === false)) {
481
+ throw new Error(`Invalid ${path}: key-value object config requires a scalar additionalProperties field.`);
482
+ }
483
+ if (input.properties !== undefined && input.additionalProperties !== undefined && input.additionalProperties !== false) {
484
+ throw new Error(`Invalid ${path}: fixed and key-value object config modes cannot be mixed.`);
485
+ }
486
+ let properties;
487
+ if (input.properties !== undefined) {
488
+ const propertiesInput = asObject(input.properties, `${path}.properties`);
489
+ if (Object.keys(propertiesInput).length > MAX_OBJECT_PROPERTIES) {
490
+ throw new Error(`Invalid ${path}.properties: expected at most ${MAX_OBJECT_PROPERTIES} properties.`);
491
+ }
492
+ properties = createPropertyMap();
493
+ for (const [property, child] of Object.entries(propertiesInput)) {
494
+ if (isDangerousConfigKey(property)) {
495
+ throw new Error(`Invalid ${path}.properties: dangerous config key "${property}" is not allowed.`);
496
+ }
497
+ properties[property] = normalizeScalarField(child, `${path}.properties.${property}`, {
498
+ allowDefault: false,
499
+ allowRequired: true,
500
+ });
501
+ assertChoices(properties[property], `${path}.properties.${property}`);
502
+ }
503
+ }
504
+ let additionalProperties;
505
+ if (input.additionalProperties === undefined || input.additionalProperties === false) {
506
+ additionalProperties = false;
507
+ }
508
+ else {
509
+ additionalProperties = normalizeScalarField(input.additionalProperties, `${path}.additionalProperties`, { allowDefault: false, allowRequired: false });
510
+ assertChoices(additionalProperties, `${path}.additionalProperties`);
511
+ }
512
+ let validation;
513
+ if (input.validation !== undefined) {
514
+ const validationInput = asObject(input.validation, `${path}.validation`);
515
+ assertAllowedKeys(validationInput, `${path}.validation`, ['minProperties', 'maxProperties', 'key']);
516
+ const minProperties = validationInput.minProperties === undefined
517
+ ? undefined
518
+ : nonNegativeInteger(validationInput.minProperties, `${path}.validation.minProperties`);
519
+ const maxProperties = validationInput.maxProperties === undefined
520
+ ? undefined
521
+ : nonNegativeInteger(validationInput.maxProperties, `${path}.validation.maxProperties`);
522
+ if (minProperties !== undefined && minProperties > MAX_OBJECT_PROPERTIES) {
523
+ throw new Error(`Invalid ${path}.validation.minProperties: expected at most ${MAX_OBJECT_PROPERTIES}.`);
524
+ }
525
+ if (maxProperties !== undefined && maxProperties > MAX_OBJECT_PROPERTIES) {
526
+ throw new Error(`Invalid ${path}.validation.maxProperties: expected at most ${MAX_OBJECT_PROPERTIES}.`);
527
+ }
528
+ if (minProperties !== undefined && maxProperties !== undefined && minProperties > maxProperties) {
529
+ throw new Error(`Invalid ${path}.validation: minProperties must be less than or equal to maxProperties.`);
530
+ }
531
+ validation = {
532
+ minProperties,
533
+ maxProperties,
534
+ key: validationInput.key === undefined
535
+ ? undefined
536
+ : normalizeStringValidation(validationInput.key, `${path}.validation.key`),
537
+ };
538
+ }
539
+ return {
540
+ type: 'object',
541
+ title: optionalText(input.title, `${path}.title`),
542
+ description: optionalText(input.description, `${path}.description`),
543
+ default: input.default,
544
+ required: optionalBoolean(input.required, `${path}.required`),
545
+ sensitive: optionalBoolean(input.sensitive, `${path}.sensitive`),
546
+ choices: input.choices === undefined
547
+ ? undefined
548
+ : normalizeChoices(input.choices, `${path}.choices`),
549
+ ...(properties === undefined
550
+ ? { additionalProperties: additionalProperties }
551
+ : { properties, additionalProperties: false }),
552
+ validation,
553
+ };
554
+ }
555
+ export function normalizePluginConfigDefinition(value, path = 'config') {
556
+ const input = asObject(value, path);
557
+ assertAllowedKeys(input, path, ['fields', 'presentation']);
558
+ const fieldsInput = asObject(input.fields, `${path}.fields`);
559
+ const fields = createPropertyMap();
560
+ for (const [field, rawDefinition] of Object.entries(fieldsInput)) {
561
+ if (!CONFIG_KEY_PATTERN.test(field) || isDangerousConfigKey(field)) {
562
+ throw new Error(`Invalid ${path}.fields: config key "${field}" is not valid.`);
563
+ }
564
+ const rawField = asObject(rawDefinition, `${path}.fields.${field}`);
565
+ const definition = rawField.type === 'object'
566
+ ? normalizeObjectField(rawField, `${path}.fields.${field}`)
567
+ : normalizeScalarField(rawField, `${path}.fields.${field}`, {
568
+ allowDefault: true,
569
+ allowRequired: true,
570
+ });
571
+ assertChoices(definition, `${path}.fields.${field}`);
572
+ if (definition.default !== undefined) {
573
+ const issues = validatePluginConfigValue(definition, definition.default, field);
574
+ if (issues.length > 0) {
575
+ throw new Error(`Invalid ${path}.fields.${field}.default: ${formatPluginConfigIssue(issues[0])}`);
576
+ }
577
+ }
578
+ fields[field] = definition;
579
+ }
580
+ let presentation;
581
+ if (input.presentation !== undefined) {
582
+ const presentationInput = asObject(input.presentation, `${path}.presentation`);
583
+ assertAllowedKeys(presentationInput, `${path}.presentation`, ['groups']);
584
+ if (presentationInput.groups !== undefined && !Array.isArray(presentationInput.groups)) {
585
+ throw new Error(`Invalid ${path}.presentation.groups: expected an array.`);
586
+ }
587
+ const groupIds = new Set();
588
+ const groupedFields = new Set();
589
+ presentation = {
590
+ groups: presentationInput.groups?.map((rawGroup, index) => {
591
+ const groupPath = `${path}.presentation.groups[${index}]`;
592
+ const group = asObject(rawGroup, groupPath);
593
+ assertAllowedKeys(group, groupPath, ['id', 'title', 'description', 'fields', 'advanced']);
594
+ const id = nonEmptyString(group.id, `${groupPath}.id`);
595
+ if (groupIds.has(id)) {
596
+ throw new Error(`Invalid ${groupPath}.id: duplicate group id "${id}".`);
597
+ }
598
+ groupIds.add(id);
599
+ if (!Array.isArray(group.fields)) {
600
+ throw new Error(`Invalid ${groupPath}.fields: expected an array.`);
601
+ }
602
+ const groupFields = group.fields.map((entry, fieldIndex) => {
603
+ const field = nonEmptyString(entry, `${groupPath}.fields[${fieldIndex}]`);
604
+ if (!Object.hasOwn(fields, field)) {
605
+ throw new Error(`Invalid ${groupPath}.fields[${fieldIndex}]: unknown config key "${field}".`);
606
+ }
607
+ if (groupedFields.has(field)) {
608
+ throw new Error(`Invalid ${groupPath}.fields[${fieldIndex}]: config key "${field}" is assigned to more than one group.`);
609
+ }
610
+ groupedFields.add(field);
611
+ return field;
612
+ });
613
+ return {
614
+ id,
615
+ title: nonEmptyString(group.title, `${groupPath}.title`),
616
+ description: optionalText(group.description, `${groupPath}.description`),
617
+ fields: groupFields,
618
+ advanced: optionalBoolean(group.advanced, `${groupPath}.advanced`),
619
+ };
620
+ }),
621
+ };
622
+ }
623
+ return { fields, presentation };
624
+ }
625
+ const CONFIG_DIR = 'plugin-config';
626
+ const CONFIG_FILE = 'config.json';
627
+ const SOURCE_IDENTITY_PATTERN = /^sha256:[0-9a-f]{64}$/;
628
+ function isRecord(value) {
629
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
630
+ }
631
+ function fail(message) {
632
+ throw new Error(message);
633
+ }
634
+ function readJsonFile(filePath, label) {
635
+ let content;
636
+ try {
637
+ content = fs.readFileSync(filePath, 'utf8');
638
+ }
639
+ catch {
640
+ fail(`Unable to read ${label}.`);
641
+ }
642
+ try {
643
+ return JSON.parse(content);
644
+ }
645
+ catch {
646
+ fail(`invalidJson: Unable to parse ${label} as JSON.`);
647
+ }
648
+ }
649
+ function safeSegment(value) {
650
+ if (typeof value !== 'string' || value.trim() === '')
651
+ fail('Invalid plugin config segment.');
652
+ if (value !== value.trim()
653
+ || value === '.'
654
+ || value === '..'
655
+ || value.includes('/')
656
+ || value.includes('\\')
657
+ || path.posix.isAbsolute(value)
658
+ || path.win32.isAbsolute(value)
659
+ || /^[A-Za-z][A-Za-z0-9+.-]*:/.test(value))
660
+ fail('Invalid plugin config segment.');
661
+ return value;
662
+ }
663
+ function normalizeSchema(rawSchema) {
664
+ try {
665
+ return normalizePluginConfigDefinition({ fields: rawSchema }).fields;
666
+ }
667
+ catch (error) {
668
+ fail(error instanceof Error ? error.message : 'Invalid AW config schema.');
669
+ }
670
+ }
671
+ function validateManifest(rawManifest) {
672
+ if (!isRecord(rawManifest))
673
+ fail('Bundle manifest is not a JSON object.');
674
+ const pluginName = safeSegment(rawManifest.name);
675
+ if (!isRecord(rawManifest.config) || !isRecord(rawManifest.config.fields)) {
676
+ fail(`Plugin "${pluginName}" does not declare an AW config schema.`);
677
+ }
678
+ return { pluginName, schema: normalizeSchema(rawManifest.config.fields) };
679
+ }
680
+ function locateBundleManifest() {
681
+ let currentDir = path.dirname(fileURLToPath(import.meta.url));
682
+ while (true) {
683
+ const manifestPath = path.join(currentDir, '.agents-plugin', 'plugin.json');
684
+ if (fs.existsSync(manifestPath))
685
+ return { bundleRoot: currentDir, manifestPath };
686
+ const parentDir = path.dirname(currentDir);
687
+ if (parentDir === currentDir)
688
+ fail('Unable to locate bundle .agents-plugin/plugin.json.');
689
+ currentDir = parentDir;
690
+ }
691
+ }
692
+ function resolveProjectRoot(cwd) {
693
+ let currentDir = path.resolve(cwd);
694
+ while (true) {
695
+ if (fs.existsSync(path.join(currentDir, '.git')) || fs.existsSync(path.join(currentDir, 'pnpm-workspace.yaml'))) {
696
+ return currentDir;
697
+ }
698
+ const parentDir = path.dirname(currentDir);
699
+ if (parentDir === currentDir)
700
+ return path.resolve(cwd);
701
+ currentDir = parentDir;
702
+ }
703
+ }
704
+ function resolveAwHome() {
705
+ return process.env.AW_HOME || path.join(os.homedir(), '.aw');
706
+ }
707
+ function resolveStorePath(sourceId, pluginName, scope, cwd) {
708
+ const root = scope === 'user'
709
+ ? resolveAwHome()
710
+ : path.join(resolveProjectRoot(cwd), '.agent-workflows');
711
+ return path.join(root, CONFIG_DIR, sourceId, pluginName, CONFIG_FILE);
712
+ }
713
+ function supportedValue(value) {
714
+ if (typeof value === 'string' || typeof value === 'boolean')
715
+ return true;
716
+ if (typeof value === 'number')
717
+ return Number.isFinite(value);
718
+ return isRecord(value) && Object.values(value).every((child) => typeof child === 'string'
719
+ || typeof child === 'boolean'
720
+ || (typeof child === 'number' && Number.isFinite(child)));
721
+ }
722
+ function validateValues(values, schema) {
723
+ if (!isRecord(values))
724
+ fail('invalidValues: Store values must be an object.');
725
+ for (const [key, value] of Object.entries(values)) {
726
+ if (isDangerousConfigKey(key)) {
727
+ fail(`dangerousKey: Config "${key}" is not allowed.`);
728
+ }
729
+ if (!supportedValue(value))
730
+ fail(`invalidValues: Config "${key}" has an unsupported value.`);
731
+ const field = Object.hasOwn(schema, key) ? schema[key] : undefined;
732
+ if (!field)
733
+ continue;
734
+ const issues = validatePluginConfigValue(field, value, key);
735
+ if (issues.length > 0)
736
+ fail(`invalidValues: ${formatPluginConfigIssue(issues[0])}`);
737
+ }
738
+ return values;
739
+ }
740
+ function missingStore(filePath) {
741
+ return { path: filePath, state: 'missing', exists: false, values: {} };
742
+ }
743
+ function readStore(filePath, identity, schema) {
744
+ if (!fs.existsSync(filePath))
745
+ return missingStore(filePath);
746
+ const envelope = readJsonFile(filePath, 'plugin config store');
747
+ if (!isRecord(envelope) || envelope.schemaVersion !== 3) {
748
+ fail('schemaVersionUnsupported: Only plugin config store schemaVersion 3 is supported.');
749
+ }
750
+ if (envelope.sourceId !== identity.sourceId
751
+ || envelope.sourceIdentity !== identity.sourceIdentity
752
+ || envelope.pluginName !== identity.pluginName)
753
+ fail('identityMismatch: Plugin config store identity does not match its path.');
754
+ return {
755
+ path: filePath,
756
+ state: 'ready',
757
+ exists: true,
758
+ values: validateValues(envelope.values, schema),
759
+ };
760
+ }
761
+ function createState(schema) {
762
+ return {
763
+ values: Object.create(null),
764
+ redactedValues: Object.create(null),
765
+ sources: Object.fromEntries(Object.keys(schema).map((key) => [key, 'missing'])),
766
+ ignoredUnknownKeys: [],
767
+ issues: [],
768
+ };
769
+ }
770
+ function applyLayer(state, schema, entries, source) {
771
+ validateValues(entries, schema);
772
+ for (const [key, field] of Object.entries(schema)) {
773
+ if (!Object.hasOwn(entries, key))
774
+ continue;
775
+ const value = entries[key];
776
+ state.values[key] = value;
777
+ state.redactedValues[key] = redactPluginConfigValue(field, value);
778
+ state.sources[key] = source;
779
+ }
780
+ }
781
+ function collectUnknownKeys(state, schema, store, scope) {
782
+ for (const key of Object.keys(store.values)) {
783
+ if (!Object.hasOwn(schema, key))
784
+ state.ignoredUnknownKeys.push({ scope, key });
785
+ }
786
+ }
787
+ function addRequiredIssues(state, schema) {
788
+ for (const [key, field] of Object.entries(schema)) {
789
+ if (field.required === true && !Object.hasOwn(state.values, key)) {
790
+ state.issues.push({
791
+ type: 'missing-required',
792
+ key,
793
+ source: state.sources[key],
794
+ message: `Config "${key}" is required.`,
795
+ });
796
+ }
797
+ }
798
+ }
799
+ function resolveFromStores({ identity, schema, scope, stores }) {
800
+ const state = createState(schema);
801
+ if (scope === 'effective') {
802
+ for (const [key, field] of Object.entries(schema)) {
803
+ if (field.default !== undefined)
804
+ applyLayer(state, { [key]: field }, { [key]: field.default }, 'default');
805
+ }
806
+ for (const [storeKey, source] of [['user', 'user'], ['project', 'project']]) {
807
+ collectUnknownKeys(state, schema, stores[storeKey], source);
808
+ applyLayer(state, schema, stores[storeKey].values, source);
809
+ }
810
+ addRequiredIssues(state, schema);
811
+ }
812
+ else {
813
+ collectUnknownKeys(state, schema, stores[scope], scope);
814
+ applyLayer(state, schema, stores[scope].values, scope);
815
+ }
816
+ return {
817
+ pluginName: identity.pluginName,
818
+ sourceId: identity.sourceId,
819
+ sourceIdentity: identity.sourceIdentity,
820
+ pluginId: `${identity.sourceId}/${identity.pluginName}`,
821
+ scope,
822
+ values: state.values,
823
+ redactedValues: state.redactedValues,
824
+ sources: state.sources,
825
+ schema,
826
+ diagnostics: { issues: state.issues, ignoredUnknownKeys: state.ignoredUnknownKeys },
827
+ paths: { configStores: { user: stores.user.path, project: stores.project.path } },
828
+ };
829
+ }
830
+ function contextIdentity(context, pluginName) {
831
+ const sourceId = context.plugin?.sourceId;
832
+ const sourceIdentity = context.plugin?.sourceIdentity;
833
+ if ((sourceId === undefined) !== (sourceIdentity === undefined)) {
834
+ fail('AW_PLUGIN_CONTEXT contains an incomplete source identity.');
835
+ }
836
+ if (sourceId === undefined)
837
+ return null;
838
+ if (typeof sourceIdentity !== 'string' || !SOURCE_IDENTITY_PATTERN.test(sourceIdentity)) {
839
+ fail('AW_PLUGIN_CONTEXT contains an invalid source identity.');
840
+ }
841
+ return { pluginName, sourceId: safeSegment(sourceId), sourceIdentity };
842
+ }
843
+ function resolveFromContext(scope) {
844
+ const contextPath = process.env.AW_PLUGIN_CONTEXT;
845
+ if (!contextPath)
846
+ return null;
847
+ const context = readJsonFile(contextPath, 'AW_PLUGIN_CONTEXT');
848
+ if (!isRecord(context) || !isRecord(context.config))
849
+ fail('AW_PLUGIN_CONTEXT does not contain config data.');
850
+ const schema = normalizeSchema(context.config.schema);
851
+ const pluginName = safeSegment(context.plugin?.name || context.pluginName || context.config.pluginName || 'plugin');
852
+ const identity = contextIdentity(context, pluginName);
853
+ if (scope === 'effective') {
854
+ const state = createState(schema);
855
+ const values = validateValues(context.config.values, schema);
856
+ applyLayer(state, schema, values, 'missing');
857
+ for (const [key, source] of Object.entries(isRecord(context.config.sources) ? context.config.sources : {})) {
858
+ if (Object.hasOwn(schema, key)
859
+ && ['default', 'user', 'project', 'missing'].includes(source))
860
+ state.sources[key] = source;
861
+ }
862
+ const contextStorePaths = isRecord(context.paths?.configStores)
863
+ ? context.paths.configStores
864
+ : {};
865
+ return {
866
+ pluginName,
867
+ ...(identity ? {
868
+ sourceId: identity.sourceId,
869
+ sourceIdentity: identity.sourceIdentity,
870
+ pluginId: `${identity.sourceId}/${pluginName}`,
871
+ } : {}),
872
+ scope,
873
+ values: state.values,
874
+ redactedValues: state.redactedValues,
875
+ sources: state.sources,
876
+ schema,
877
+ diagnostics: {
878
+ issues: Array.isArray(context.config.issues) ? context.config.issues : [],
879
+ ignoredUnknownKeys: Array.isArray(context.config.ignoredUnknownKeys)
880
+ ? context.config.ignoredUnknownKeys : [],
881
+ },
882
+ paths: {
883
+ configStores: {
884
+ ...(typeof contextStorePaths.user === 'string' ? { user: contextStorePaths.user } : {}),
885
+ ...(typeof contextStorePaths.project === 'string' ? { project: contextStorePaths.project } : {}),
886
+ },
887
+ },
888
+ };
889
+ }
890
+ if (!identity)
891
+ fail('AW_PLUGIN_CONTEXT must provide a source identity for scoped config reads.');
892
+ const storePath = context.paths?.configStores?.[scope];
893
+ if (typeof storePath !== 'string' || storePath.trim() === '') {
894
+ fail(`AW_PLUGIN_CONTEXT does not provide a ${scope} config store path.`);
895
+ }
896
+ const store = readStore(storePath, identity, schema);
897
+ return resolveFromStores({
898
+ identity,
899
+ schema,
900
+ scope,
901
+ stores: {
902
+ user: scope === 'user' ? store : missingStore(''),
903
+ project: scope === 'project' ? store : missingStore(''),
904
+ },
905
+ });
906
+ }
907
+ function resolveFallback(scope) {
908
+ const { bundleRoot, manifestPath } = locateBundleManifest();
909
+ const { pluginName, schema } = validateManifest(readJsonFile(manifestPath, 'bundle manifest'));
910
+ const pluginsRoot = path.dirname(bundleRoot);
911
+ const marketplaceRoot = path.dirname(pluginsRoot);
912
+ if (path.basename(pluginsRoot) !== 'plugins' || path.basename(bundleRoot) !== pluginName) {
913
+ fail('Bundle manifest is not inside a namespaced local marketplace.');
914
+ }
915
+ const marketplace = readJsonFile(path.join(marketplaceRoot, 'config.json'), 'marketplace config');
916
+ const sourceId = safeSegment(marketplace.sourceId);
917
+ const sourceIdentity = marketplace.sourceIdentity;
918
+ if (marketplace.schemaVersion !== 2
919
+ || sourceId !== path.basename(marketplaceRoot)
920
+ || typeof sourceIdentity !== 'string'
921
+ || !SOURCE_IDENTITY_PATTERN.test(sourceIdentity)
922
+ || !['aw', `aw-${sourceId}`].includes(marketplace.marketplaceName))
923
+ fail('Marketplace config does not contain a canonical schema 2 source identity.');
924
+ const identity = { sourceId, sourceIdentity, pluginName };
925
+ const cwd = process.cwd();
926
+ const projectRoot = resolveProjectRoot(cwd);
927
+ for (const legacyPath of [
928
+ path.join(resolveAwHome(), CONFIG_DIR, pluginName, CONFIG_FILE),
929
+ path.join(projectRoot, '.agent-workflows', CONFIG_DIR, pluginName, CONFIG_FILE),
930
+ ]) {
931
+ if (fs.existsSync(legacyPath))
932
+ fail('Legacy non-namespaced plugin config is not supported.');
933
+ }
934
+ const stores = {
935
+ user: scope === 'project'
936
+ ? missingStore('')
937
+ : readStore(resolveStorePath(sourceId, pluginName, 'user', cwd), identity, schema),
938
+ project: scope === 'user'
939
+ ? missingStore('')
940
+ : readStore(resolveStorePath(sourceId, pluginName, 'project', cwd), identity, schema),
941
+ };
942
+ return resolveFromStores({ identity, schema, scope, stores });
943
+ }
944
+ function printUsage() {
945
+ process.stdout.write(`Usage:
946
+ node aw-config.mjs get <key> [--scope effective|user|project]
947
+ node aw-config.mjs json [--scope effective|user|project]
948
+
949
+ Options:
950
+ --scope <scope> Read effective, user, or project config. Default: effective.
951
+ -h, --help Show this help message.
952
+ `);
953
+ }
954
+ function parseArgs(argv) {
955
+ const args = argv.slice(2);
956
+ const command = args.shift();
957
+ if (command === '-h' || command === '--help')
958
+ return { help: true };
959
+ let scope = 'effective';
960
+ const positional = [];
961
+ for (let index = 0; index < args.length; index += 1) {
962
+ const arg = args[index];
963
+ if (arg === '--scope') {
964
+ const value = args[index + 1];
965
+ if (!value || value.startsWith('--'))
966
+ fail('--scope requires a value.');
967
+ scope = value;
968
+ index += 1;
969
+ }
970
+ else if (arg.startsWith('--scope=')) {
971
+ scope = arg.slice('--scope='.length);
972
+ }
973
+ else {
974
+ positional.push(arg);
975
+ }
976
+ }
977
+ if (!['effective', 'user', 'project'].includes(scope))
978
+ fail('--scope must be effective, user, or project.');
979
+ if (command !== 'get' && command !== 'json')
980
+ fail('Usage: node aw-config.mjs get <key> | json');
981
+ if (command === 'get' && positional.length !== 1)
982
+ fail('Usage: node aw-config.mjs get <key>');
983
+ if (command === 'json' && positional.length !== 0)
984
+ fail('Usage: node aw-config.mjs json');
985
+ return { command, key: positional[0], scope };
986
+ }
987
+ function main() {
988
+ const args = parseArgs(process.argv);
989
+ if (args.help) {
990
+ printUsage();
991
+ return;
992
+ }
993
+ const result = resolveFromContext(args.scope) || resolveFallback(args.scope);
994
+ if (args.command === 'get') {
995
+ if (!Object.hasOwn(result.schema, args.key))
996
+ fail(`Unknown config key "${args.key}".`);
997
+ if (!Object.hasOwn(result.values, args.key))
998
+ fail(`Config key "${args.key}" is not set.`);
999
+ const value = result.redactedValues[args.key];
1000
+ process.stdout.write(typeof value === 'string' ? `${value}\n` : `${JSON.stringify(value)}\n`);
1001
+ }
1002
+ else {
1003
+ process.stdout.write(`${JSON.stringify({ ...result, values: result.redactedValues }, null, 2)}\n`);
1004
+ }
1005
+ }
1006
+ function isDirectExecution() {
1007
+ if (!process.argv[1])
1008
+ return false;
1009
+ try {
1010
+ return fs.realpathSync(fileURLToPath(import.meta.url)) === fs.realpathSync(process.argv[1]);
1011
+ }
1012
+ catch {
1013
+ return fileURLToPath(import.meta.url) === path.resolve(process.argv[1]);
1014
+ }
1015
+ }
1016
+ if (isDirectExecution()) {
1017
+ try {
1018
+ main();
1019
+ }
1020
+ catch (error) {
1021
+ process.stderr.write(`[aw-config] ${error instanceof Error ? error.message : String(error)}\n`);
1022
+ process.exitCode = 1;
1023
+ }
1024
+ }
1025
+ //# sourceMappingURL=aw-config.mjs.map