@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,720 @@
1
+ import os from 'node:os';
2
+ import path from 'node:path';
3
+ import { createInterface } from 'node:readline/promises';
4
+ import { Writable } from 'node:stream';
5
+ import { createFileDebugLogger } from '../output/debug-log.js';
6
+ import { createIoReporter, createNoopReporter, } from '../output/reporter.js';
7
+ import { NativeCliError, getDefaultNativeCliRunner } from '../utils/native-cli.js';
8
+ import { resolveAwHome } from '../utils/paths.js';
9
+ import { assertTestWritablePath } from '../utils/test-path-fence.js';
10
+ import { createInkPrompt } from '../tui/prompt.js';
11
+ import { createInkTuiRunner } from '../tui/runner.js';
12
+ const reporterRoutes = new WeakMap();
13
+ function createSessionAwareReporter(defaultReporter) {
14
+ const route = { current: defaultReporter };
15
+ const reporter = {
16
+ event: (event) => route.current.event(event),
17
+ notice: (notice) => route.current.notice(notice),
18
+ };
19
+ reporterRoutes.set(reporter, route);
20
+ return reporter;
21
+ }
22
+ export async function withCommandReporterSession(reporter, sessionReporter, task) {
23
+ const route = reporterRoutes.get(reporter);
24
+ if (!route)
25
+ return task();
26
+ const previous = route.current;
27
+ route.current = sessionReporter;
28
+ try {
29
+ return await task();
30
+ }
31
+ finally {
32
+ route.current = previous;
33
+ }
34
+ }
35
+ function createDefaultIo() {
36
+ return {
37
+ stdout: (text) => process.stdout.write(text),
38
+ stderr: (text) => process.stderr.write(text),
39
+ };
40
+ }
41
+ function isTruthy(value) {
42
+ return value === '1' || value === 'true' || value === 'yes';
43
+ }
44
+ function createRunId() {
45
+ return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
46
+ }
47
+ function createTimestampForPath() {
48
+ return new Date().toISOString().replace(/[:.]/g, '-');
49
+ }
50
+ function assertDebugLogPathForTests(logFile, source, commandName) {
51
+ return assertTestWritablePath(logFile, source === 'explicit'
52
+ ? '--log-file'
53
+ : commandName === 'status'
54
+ ? 'AW_DEBUG default status log file'
55
+ : 'AW_DEBUG default log file', source === 'explicit'
56
+ ? '用 createIsolatedTestEnv() 提供安全 cwd/TMPDIR/AW_HOME,或通过 registerWritableStateRoot() 登记 --log-file 目标路径。'
57
+ : '用 createIsolatedTestEnv() 生成默认 TMPDIR/AW_HOME,或通过 registerWritableStateRoot() 登记调试日志目录。');
58
+ }
59
+ function defaultLogFile(commandName, env) {
60
+ const fileName = `aw-${createTimestampForPath()}-${commandName}.log`;
61
+ if (commandName === 'status') {
62
+ return assertDebugLogPathForTests(path.join(os.tmpdir(), 'agent-workflows', fileName), 'default', commandName);
63
+ }
64
+ return assertDebugLogPathForTests(path.join(resolveAwHome(env), 'logs', fileName), 'default', commandName);
65
+ }
66
+ export function createCommandDiagnostics(input = {}, env = process.env) {
67
+ const commandName = input.commandName ?? 'command';
68
+ const envDebug = isTruthy(env.AW_DEBUG);
69
+ const debug = input.debug === true || envDebug;
70
+ const hasLogFile = Boolean(input.logFile || debug);
71
+ return {
72
+ verbose: input.verbose === true || debug,
73
+ debug,
74
+ commandName,
75
+ runId: input.runId ?? createRunId(),
76
+ metadata: input.metadata,
77
+ ...(hasLogFile
78
+ ? {
79
+ logFile: input.logFile
80
+ ? assertDebugLogPathForTests(input.logFile, 'explicit', commandName)
81
+ : defaultLogFile(commandName, env),
82
+ logFileSource: input.logFile ? input.logFileSource ?? 'explicit' : 'default',
83
+ }
84
+ : {}),
85
+ };
86
+ }
87
+ export function validateCliConfigPromptResult(options, result) {
88
+ if (!options.allowedScopes.includes(result.selectedScope)) {
89
+ throw new Error(`Unsupported config scope "${result.selectedScope}". Expected one of: ${options.allowedScopes.join(', ')}.`);
90
+ }
91
+ const schemaKeys = new Set(Object.keys(options.schema));
92
+ const updateKeys = Object.keys(result.updates);
93
+ const removeKeys = result.removeKeys ?? [];
94
+ for (const key of [...result.updatedKeys, ...updateKeys, ...removeKeys]) {
95
+ if (!schemaKeys.has(key)) {
96
+ throw new Error(`Unsupported config key "${key}".`);
97
+ }
98
+ }
99
+ const updatedKeySet = new Set(result.updatedKeys);
100
+ for (const key of updateKeys) {
101
+ if (!updatedKeySet.has(key)) {
102
+ throw new Error(`Config prompt result update "${key}" is missing from updatedKeys.`);
103
+ }
104
+ }
105
+ for (const key of result.updatedKeys) {
106
+ if (!Object.hasOwn(result.updates, key)) {
107
+ throw new Error(`Config prompt result updatedKeys contains "${key}" without an update value.`);
108
+ }
109
+ }
110
+ for (const key of removeKeys) {
111
+ if (Object.hasOwn(result.updates, key)) {
112
+ throw new Error(`Config prompt result cannot update and remove "${key}" in the same submission.`);
113
+ }
114
+ }
115
+ return result;
116
+ }
117
+ function createUnavailablePrompt() {
118
+ const unavailable = async () => {
119
+ throw new Error('Interactive prompt is not available in this runtime.');
120
+ };
121
+ return {
122
+ select: unavailable,
123
+ multiSelect: unavailable,
124
+ confirm: unavailable,
125
+ input: unavailable,
126
+ password: unavailable,
127
+ selectPlatform: unavailable,
128
+ selectScope: unavailable,
129
+ selectPlugins: unavailable,
130
+ configurePlugin: unavailable,
131
+ };
132
+ }
133
+ function formatChoice(choice, index, defaultValues) {
134
+ const marker = defaultValues.has(choice.value) ? ' (默认)' : '';
135
+ const disabled = choice.disabled
136
+ ? ` - ${typeof choice.disabled === 'string' ? choice.disabled : '不可选'}`
137
+ : '';
138
+ return `${index + 1}. ${choice.label}${marker}${disabled}`;
139
+ }
140
+ function parseSelectionInput(answer, choices, defaults, allowMultiple) {
141
+ const trimmed = answer.trim();
142
+ if (!trimmed) {
143
+ return defaults;
144
+ }
145
+ const tokens = allowMultiple
146
+ ? trimmed.split(',').map((entry) => entry.trim()).filter(Boolean)
147
+ : [trimmed];
148
+ const selected = [];
149
+ for (const token of tokens) {
150
+ const numericIndex = Number(token);
151
+ const choice = Number.isInteger(numericIndex)
152
+ ? choices[numericIndex - 1]
153
+ : choices.find((entry) => entry.value === token);
154
+ if (!choice) {
155
+ throw new Error(`无效选择:${token}`);
156
+ }
157
+ if (choice.disabled) {
158
+ throw new Error(`不可选择 ${choice.label}:${typeof choice.disabled === 'string' ? choice.disabled : '已禁用'}`);
159
+ }
160
+ selected.push(choice.value);
161
+ }
162
+ return [...new Set(selected)];
163
+ }
164
+ function createPromptWritable(outputSink) {
165
+ const writable = new Writable({
166
+ write(chunk, _encoding, callback) {
167
+ outputSink.write(typeof chunk === 'string' ? chunk : chunk.toString('utf8'));
168
+ callback();
169
+ },
170
+ });
171
+ writable.isTTY = outputSink.isTTY;
172
+ return writable;
173
+ }
174
+ function createPromptResult(value) {
175
+ return {
176
+ action: 'select',
177
+ cancelled: false,
178
+ value,
179
+ };
180
+ }
181
+ function createPromptActionResult(action) {
182
+ return {
183
+ action,
184
+ cancelled: action === 'cancel',
185
+ };
186
+ }
187
+ function unwrapPromptResult(result, message = 'Interactive prompt cancelled.') {
188
+ if (result.action !== 'select' || result.value === undefined) {
189
+ throw new Error(message);
190
+ }
191
+ return result.value;
192
+ }
193
+ function shouldPromptConfigKey(key, definition, options) {
194
+ const currentValue = options.currentValues?.[key];
195
+ const configured = currentValue !== undefined || options.configuredKeys?.includes(key) === true;
196
+ return Boolean(definition.required ||
197
+ options.requiredKeys?.includes(key) ||
198
+ !configured);
199
+ }
200
+ function formatConfigKeyChoiceLabel(key, definition, options) {
201
+ const label = definition.label ?? key;
202
+ const currentValue = options.currentValues?.[key];
203
+ const configured = currentValue !== undefined || options.configuredKeys?.includes(key) === true;
204
+ if (!configured) {
205
+ return label;
206
+ }
207
+ if (definition.sensitive) {
208
+ return `${label}(当前:已配置)`;
209
+ }
210
+ return `${label}(当前:${String(currentValue)})`;
211
+ }
212
+ function parsePromptedConfigValue(key, definition, answer) {
213
+ const trimmed = answer.trim();
214
+ if (!trimmed) {
215
+ return undefined;
216
+ }
217
+ if (definition.type === 'number') {
218
+ const parsed = Number(trimmed);
219
+ if (!Number.isFinite(parsed)) {
220
+ throw new Error(`配置项 ${key} 需要数字。`);
221
+ }
222
+ return parsed;
223
+ }
224
+ if (definition.type === 'boolean') {
225
+ const normalized = trimmed.toLowerCase();
226
+ if (['true', '1', 'yes', 'y'].includes(normalized)) {
227
+ return true;
228
+ }
229
+ if (['false', '0', 'no', 'n'].includes(normalized)) {
230
+ return false;
231
+ }
232
+ throw new Error(`配置项 ${key} 需要布尔值。`);
233
+ }
234
+ return answer;
235
+ }
236
+ function normalizePromptInput(value) {
237
+ return value.trim();
238
+ }
239
+ function resolveTypedPromptAction(answer, options = {}) {
240
+ const mode = options.mode ?? 'text';
241
+ const normalized = normalizePromptInput(answer);
242
+ if (normalized === '\u0003') {
243
+ return 'exit';
244
+ }
245
+ if (normalized === '\u001B') {
246
+ if (mode === 'menu') {
247
+ return options.allowBack ? 'back' : 'exit';
248
+ }
249
+ return 'cancel';
250
+ }
251
+ if (mode !== 'menu') {
252
+ return null;
253
+ }
254
+ if (options.allowBack && ['b', 'B'].includes(normalized)) {
255
+ return 'back';
256
+ }
257
+ if ((options.allowExit ?? true) && ['q', 'Q'].includes(normalized)) {
258
+ return 'exit';
259
+ }
260
+ return null;
261
+ }
262
+ function resolveChoiceResult(value, choices) {
263
+ const choice = choices.find((entry) => entry.value === value);
264
+ if (choice?.role === 'back') {
265
+ return createPromptActionResult('back');
266
+ }
267
+ if (choice?.role === 'exit') {
268
+ return createPromptActionResult('exit');
269
+ }
270
+ return createPromptResult(value);
271
+ }
272
+ function createMutedOutput(outputSink) {
273
+ const mutedOutput = new Writable({
274
+ write(_chunk, _encoding, callback) {
275
+ callback();
276
+ },
277
+ });
278
+ mutedOutput.isTTY = outputSink.isTTY;
279
+ return mutedOutput;
280
+ }
281
+ export function createReadlinePrompt(options = {}) {
282
+ const input = options.input ?? process.stdin;
283
+ const outputSink = options.outputSink ?? process.stderr;
284
+ const output = createPromptWritable(outputSink);
285
+ async function ask(message, askOptions = {}) {
286
+ const hidden = askOptions.hidden === true;
287
+ if (hidden) {
288
+ outputSink.write(message);
289
+ }
290
+ const rl = createInterface({
291
+ input,
292
+ output: hidden ? createMutedOutput(outputSink) : output,
293
+ terminal: Boolean(input.isTTY && outputSink.isTTY),
294
+ });
295
+ const promptText = hidden ? '' : message;
296
+ try {
297
+ const result = await new Promise((resolve, reject) => {
298
+ const handleSigint = () => {
299
+ resolve(createPromptActionResult('exit'));
300
+ };
301
+ rl.once('SIGINT', handleSigint);
302
+ rl.question(promptText)
303
+ .then((answer) => {
304
+ const action = resolveTypedPromptAction(answer, askOptions);
305
+ resolve(action ? createPromptActionResult(action) : createPromptResult(answer));
306
+ })
307
+ .catch(reject)
308
+ .finally(() => {
309
+ rl.off('SIGINT', handleSigint);
310
+ });
311
+ });
312
+ if (hidden) {
313
+ outputSink.write('\n');
314
+ }
315
+ return result;
316
+ }
317
+ finally {
318
+ rl.close();
319
+ }
320
+ }
321
+ const select = async ({ message, choices, defaultValue }) => {
322
+ const enabledChoices = choices.filter((choice) => !choice.disabled);
323
+ if (enabledChoices.length === 0) {
324
+ throw new Error('没有可选择的候选项。');
325
+ }
326
+ const defaultValues = [defaultValue ?? enabledChoices[0].value];
327
+ const body = choices
328
+ .map((choice, index) => formatChoice(choice, index, new Set(defaultValues)))
329
+ .join('\n');
330
+ const answer = await ask(`${message}\n${body}\n选择编号:`, {
331
+ mode: 'menu',
332
+ allowBack: choices.some((choice) => choice.role === 'back'),
333
+ allowExit: true,
334
+ });
335
+ if (answer.action !== 'select') {
336
+ return answer;
337
+ }
338
+ const selected = parseSelectionInput(answer.value, choices, defaultValues, false);
339
+ return resolveChoiceResult(selected[0], choices);
340
+ };
341
+ const multiSelect = async ({ message, choices, defaultValues, }) => {
342
+ const enabledChoices = choices.filter((choice) => !choice.disabled);
343
+ if (enabledChoices.length === 0) {
344
+ throw new Error('没有可选择的候选项。');
345
+ }
346
+ const defaults = defaultValues && defaultValues.length > 0
347
+ ? defaultValues
348
+ : [enabledChoices[0].value];
349
+ const body = choices
350
+ .map((choice, index) => formatChoice(choice, index, new Set(defaults)))
351
+ .join('\n');
352
+ const answer = await ask(`${message}\n${body}\n选择编号,可用逗号分隔多个:`, {
353
+ mode: 'menu',
354
+ allowBack: choices.some((choice) => choice.role === 'back'),
355
+ allowExit: true,
356
+ });
357
+ if (answer.action !== 'select') {
358
+ return createPromptActionResult(answer.action);
359
+ }
360
+ return createPromptResult(parseSelectionInput(answer.value, choices, defaults, true));
361
+ };
362
+ const confirm = async ({ message, defaultValue = true }) => {
363
+ const suffix = defaultValue ? 'Y/n' : 'y/N';
364
+ const answer = await ask(`${message} [${suffix}] `, { mode: 'confirm' });
365
+ if (answer.action !== 'select') {
366
+ return createPromptActionResult(answer.action);
367
+ }
368
+ const normalized = answer.value.trim().toLowerCase();
369
+ if (!normalized) {
370
+ return createPromptResult(defaultValue);
371
+ }
372
+ return createPromptResult(normalized === 'y' || normalized === 'yes');
373
+ };
374
+ const inputPrompt = async ({ message, defaultValue }) => {
375
+ const answer = await ask(defaultValue === undefined
376
+ ? `${message}: `
377
+ : `${message}(默认:${defaultValue}): `, { mode: 'text' });
378
+ if (answer.action !== 'select') {
379
+ return answer;
380
+ }
381
+ return createPromptResult(answer.value.trim() === '' && defaultValue !== undefined ? defaultValue : answer.value);
382
+ };
383
+ const passwordPrompt = async ({ message }) => {
384
+ const answer = await ask(`${message}: `, { hidden: true, mode: 'text' });
385
+ if (answer.action !== 'select') {
386
+ return answer;
387
+ }
388
+ return createPromptResult(answer.value);
389
+ };
390
+ return {
391
+ select,
392
+ multiSelect,
393
+ confirm,
394
+ input: inputPrompt,
395
+ password: passwordPrompt,
396
+ selectPlatform: async ({ available, defaultValue, message }) => unwrapPromptResult(await select({
397
+ message: message ?? '选择目标平台',
398
+ choices: available.map((value) => ({
399
+ value,
400
+ label: value === 'both' ? '全部支持平台' : value === 'codex' ? 'Codex' : 'Claude Code',
401
+ })),
402
+ defaultValue,
403
+ })),
404
+ selectScope: async ({ defaultValue = 'user' }) => unwrapPromptResult(await select({
405
+ message: '选择安装范围',
406
+ choices: [
407
+ { value: 'user', label: 'user' },
408
+ { value: 'project', label: 'project' },
409
+ ],
410
+ defaultValue,
411
+ })),
412
+ selectPlugins: async ({ command, candidates, defaultValues, allowMultiple }) => {
413
+ const choices = candidates.map((candidate) => ({
414
+ value: candidate.id,
415
+ label: `${candidate.pluginName}${candidate.platform ? ` / ${candidate.platform}` : ''}${candidate.scope ? ` / ${candidate.scope}` : ''}`,
416
+ disabled: candidate.selectable ? undefined : candidate.disabledReason ?? true,
417
+ }));
418
+ return allowMultiple
419
+ ? unwrapPromptResult(await multiSelect({
420
+ message: `选择要${command === 'install' ? '安装' : '卸载'}的插件`,
421
+ choices,
422
+ defaultValues,
423
+ }))
424
+ : [unwrapPromptResult(await select({
425
+ message: `选择要${command === 'install' ? '安装' : '卸载'}的插件`,
426
+ choices,
427
+ defaultValue: defaultValues?.[0],
428
+ }))];
429
+ },
430
+ configurePlugin: async (configOptions) => {
431
+ const selectedScope = configOptions.allowedScopes.length > 1
432
+ ? unwrapPromptResult(await select({
433
+ message: `选择 ${configOptions.pluginName} 配置写入范围`,
434
+ choices: configOptions.allowedScopes.map((value) => ({ value, label: value })),
435
+ defaultValue: configOptions.initialScope,
436
+ }))
437
+ : configOptions.initialScope;
438
+ const updates = {};
439
+ const removeKeys = [];
440
+ const keysToPrompt = new Set();
441
+ const optionalConfiguredChoices = [];
442
+ for (const [key, definition] of Object.entries(configOptions.schema)) {
443
+ if (shouldPromptConfigKey(key, definition, configOptions)) {
444
+ keysToPrompt.add(key);
445
+ continue;
446
+ }
447
+ optionalConfiguredChoices.push({
448
+ value: key,
449
+ label: formatConfigKeyChoiceLabel(key, definition, configOptions),
450
+ });
451
+ }
452
+ if (optionalConfiguredChoices.length > 0) {
453
+ const body = optionalConfiguredChoices
454
+ .map((choice, index) => formatChoice(choice, index, new Set()))
455
+ .join('\n');
456
+ const selectedKeysAnswer = await ask(`选择要更新的 ${configOptions.pluginName} 配置项\n${body}\n选择编号,可用逗号分隔多个,直接回车跳过:`, { mode: 'menu', allowExit: true });
457
+ if (selectedKeysAnswer.action !== 'select') {
458
+ return {
459
+ selectedScope,
460
+ updates: {},
461
+ updatedKeys: [],
462
+ removeKeys: [],
463
+ cancelled: true,
464
+ };
465
+ }
466
+ const selectedKeys = parseSelectionInput(selectedKeysAnswer.value, optionalConfiguredChoices, [], true);
467
+ for (const key of selectedKeys) {
468
+ keysToPrompt.add(key);
469
+ }
470
+ }
471
+ for (const [key, definition] of Object.entries(configOptions.schema)) {
472
+ if (!keysToPrompt.has(key)) {
473
+ continue;
474
+ }
475
+ const label = definition.label ?? key;
476
+ if (definition.enum && definition.enum.length > 0) {
477
+ const selected = unwrapPromptResult(await select({
478
+ message: label,
479
+ choices: definition.enum.map((value) => ({
480
+ value: String(value),
481
+ label: String(value),
482
+ })),
483
+ defaultValue: configOptions.currentValues?.[key] === undefined
484
+ ? undefined
485
+ : String(configOptions.currentValues[key]),
486
+ }));
487
+ updates[key] = definition.enum.find((value) => String(value) === selected);
488
+ continue;
489
+ }
490
+ if (definition.type === 'boolean') {
491
+ updates[key] = await (async () => {
492
+ const current = configOptions.currentValues?.[key];
493
+ return unwrapPromptResult(current === undefined
494
+ ? await confirm({ message: label, defaultValue: Boolean(definition.default) })
495
+ : await confirm({ message: label, defaultValue: Boolean(current) }));
496
+ })();
497
+ continue;
498
+ }
499
+ const current = configOptions.currentValues?.[key];
500
+ const configured = current !== undefined || configOptions.configuredKeys?.includes(key) === true;
501
+ const suffix = !configured || definition.sensitive
502
+ ? definition.sensitive && configured
503
+ ? '(当前:已配置)'
504
+ : ''
505
+ : `(当前:${String(current)})`;
506
+ const answer = await ask(`${label}${suffix}: `, {
507
+ hidden: definition.sensitive && definition.type === 'string',
508
+ mode: 'text',
509
+ });
510
+ if (answer.action !== 'select') {
511
+ return {
512
+ selectedScope,
513
+ updates,
514
+ updatedKeys: Object.keys(updates),
515
+ removeKeys,
516
+ cancelled: true,
517
+ };
518
+ }
519
+ const parsed = parsePromptedConfigValue(key, definition, answer.value);
520
+ if (parsed !== undefined) {
521
+ updates[key] = parsed;
522
+ }
523
+ else if (!definition.required && configured) {
524
+ removeKeys.push(key);
525
+ }
526
+ }
527
+ const result = {
528
+ selectedScope,
529
+ updates,
530
+ updatedKeys: Object.keys(updates),
531
+ removeKeys,
532
+ cancelled: false,
533
+ };
534
+ return validateCliConfigPromptResult(configOptions, result);
535
+ },
536
+ };
537
+ }
538
+ function nativeEventIdentity(invocation) {
539
+ const executable = path.basename(invocation.command).toLowerCase().replace(/\.exe$/u, '');
540
+ const agent = executable === 'codex' || executable === 'claude' || executable === 'skills'
541
+ ? executable
542
+ : 'unknown';
543
+ const args = new Set(invocation.args.map((arg) => arg.toLowerCase()));
544
+ const operation = args.has('--version') || args.has('version')
545
+ ? 'version'
546
+ : args.has('marketplace') ? 'marketplace'
547
+ : args.has('plugin') || args.has('plugins') ? 'plugin'
548
+ : agent === 'skills' ? 'skill'
549
+ : 'other';
550
+ return { agent, operation };
551
+ }
552
+ function serializeNativeError(error) {
553
+ if (error instanceof NativeCliError) {
554
+ return {
555
+ exitCode: error.exitCode,
556
+ reason: error.reason,
557
+ };
558
+ }
559
+ return { reason: 'runnerFailure' };
560
+ }
561
+ function createInstrumentedNativeCliRunner(options) {
562
+ return async (invocation) => {
563
+ const startedAt = Date.now();
564
+ const identity = nativeEventIdentity(invocation);
565
+ await emitRuntimeEvent(options, {
566
+ type: 'native:start',
567
+ commandName: options.diagnostics.commandName,
568
+ data: identity,
569
+ });
570
+ try {
571
+ const result = await options.baseRunner(invocation);
572
+ await emitRuntimeEvent(options, {
573
+ type: 'native:success',
574
+ commandName: options.diagnostics.commandName,
575
+ data: {
576
+ ...identity,
577
+ exitCode: result.exitCode,
578
+ durationMs: Date.now() - startedAt,
579
+ },
580
+ });
581
+ return result;
582
+ }
583
+ catch (error) {
584
+ await emitRuntimeEvent(options, {
585
+ type: 'native:error',
586
+ commandName: options.diagnostics.commandName,
587
+ data: {
588
+ ...identity,
589
+ ...serializeNativeError(error),
590
+ durationMs: Date.now() - startedAt,
591
+ },
592
+ });
593
+ throw error;
594
+ }
595
+ };
596
+ }
597
+ async function emitRuntimeEvent(runtime, event) {
598
+ await Promise.allSettled([
599
+ Promise.resolve().then(() => runtime.reporter.event(event)),
600
+ Promise.resolve().then(() => runtime.debugLogger.log(event)),
601
+ ]);
602
+ }
603
+ export async function emitCommandEvent(context, event) {
604
+ await emitRuntimeEvent(context, {
605
+ commandName: context.diagnostics.commandName,
606
+ ...event,
607
+ });
608
+ }
609
+ export async function emitCommandNotice(context, notice) {
610
+ await Promise.allSettled([
611
+ Promise.resolve().then(() => context.reporter.notice(notice)),
612
+ Promise.resolve().then(() => context.debugLogger.log({
613
+ type: `notice:${notice.level}`,
614
+ commandName: context.diagnostics.commandName,
615
+ message: notice.message,
616
+ data: notice.identity ? { identity: notice.identity } : undefined,
617
+ })),
618
+ ]);
619
+ }
620
+ export function isCommandExecutionContext(input) {
621
+ return Boolean(input &&
622
+ typeof input.env === 'object' &&
623
+ typeof input.nativeCliRunner === 'function' &&
624
+ typeof input.reporter?.event === 'function' &&
625
+ typeof input.debugLogger?.log === 'function' &&
626
+ typeof input.diagnostics?.commandName === 'string');
627
+ }
628
+ export function createCommandExecutionContext(input = {}) {
629
+ if (isCommandExecutionContext(input)) {
630
+ return input;
631
+ }
632
+ const env = input.env ?? process.env;
633
+ const diagnostics = createCommandDiagnostics(input.diagnostics, env);
634
+ const reporter = input.reporter ?? createNoopReporter();
635
+ const debugLogger = input.debugLogger ?? createFileDebugLogger(diagnostics);
636
+ const baseRunner = input.nativeCliRunner ?? getDefaultNativeCliRunner();
637
+ const contextShell = {
638
+ reporter,
639
+ debugLogger,
640
+ };
641
+ return {
642
+ env,
643
+ nativeCliRunner: createInstrumentedNativeCliRunner({
644
+ baseRunner,
645
+ diagnostics,
646
+ ...contextShell,
647
+ }),
648
+ interactive: input.interactive ?? false,
649
+ prompt: input.prompt ?? createUnavailablePrompt(),
650
+ reporter,
651
+ debugLogger,
652
+ diagnostics,
653
+ };
654
+ }
655
+ export function createCliExecutionContext(input = {}) {
656
+ const cwd = input.cwd ?? process.cwd();
657
+ const env = input.env ?? process.env;
658
+ const io = {
659
+ ...createDefaultIo(),
660
+ ...input.io,
661
+ };
662
+ const stdin = input.stdin ?? process.stdin;
663
+ const stdout = input.stdout ?? process.stdout;
664
+ const promptOutputSink = input.promptOutputSink ?? process.stderr;
665
+ const stdinIsTty = Boolean(stdin.isTTY);
666
+ const stdoutIsTty = Boolean(stdout.isTTY);
667
+ const promptOutputIsTty = Boolean(promptOutputSink.isTTY);
668
+ const isTty = stdinIsTty && stdoutIsTty && promptOutputIsTty;
669
+ const isCi = isTruthy(env.CI);
670
+ const hasInjectedPrompt = Boolean(input.prompt);
671
+ const hasInjectedTuiRunner = Boolean(input.tuiRunner);
672
+ const requestedInteractive = input.interactive ?? (hasInjectedPrompt || hasInjectedTuiRunner ? true : isTty);
673
+ const interactive = requestedInteractive
674
+ && !isCi
675
+ && (isTty || hasInjectedPrompt || hasInjectedTuiRunner);
676
+ const diagnostics = createCommandDiagnostics({
677
+ ...input.diagnostics,
678
+ metadata: {
679
+ ...input.diagnostics?.metadata,
680
+ cwd,
681
+ awHome: resolveAwHome(env),
682
+ isTty,
683
+ isCi,
684
+ stdinIsTty,
685
+ stdoutIsTty,
686
+ promptOutputIsTty,
687
+ interactiveRequested: requestedInteractive,
688
+ interactiveEnabled: interactive,
689
+ },
690
+ }, env);
691
+ const reporter = createSessionAwareReporter(input.reporter ?? createIoReporter(io, diagnostics));
692
+ const debugLogger = input.debugLogger ?? createFileDebugLogger(diagnostics);
693
+ const prompt = input.prompt ?? (interactive
694
+ ? createInkPrompt({
695
+ input: stdin,
696
+ outputSink: promptOutputSink,
697
+ })
698
+ : createUnavailablePrompt());
699
+ const tuiRunner = input.tuiRunner ?? createInkTuiRunner();
700
+ const commandContext = createCommandExecutionContext({
701
+ ...input,
702
+ env,
703
+ interactive,
704
+ prompt,
705
+ reporter,
706
+ debugLogger,
707
+ diagnostics,
708
+ });
709
+ return {
710
+ ...commandContext,
711
+ cwd,
712
+ io,
713
+ stdin,
714
+ isTty,
715
+ isCi,
716
+ tuiRunner,
717
+ tuiOutput: promptOutputSink,
718
+ };
719
+ }
720
+ //# sourceMappingURL=runtime.js.map