@lesliechan721/aw 0.1.0-beta.3 → 0.1.0-beta.31

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 (529) hide show
  1. package/dist/authoring/assets/aw-config.mjs +100 -501
  2. package/dist/authoring/assets/aw-config.mjs.map +1 -1
  3. package/dist/authoring/scripts/add-skill.mjs +4 -4
  4. package/dist/authoring/scripts/add-skill.mjs.map +1 -1
  5. package/dist/authoring/scripts/init-plugin.mjs +67 -97
  6. package/dist/authoring/scripts/init-plugin.mjs.map +1 -1
  7. package/dist/authoring/scripts/lib/plugin-version-check.d.mts +15 -0
  8. package/dist/authoring/scripts/lib/plugin-version-check.mjs +239 -232
  9. package/dist/authoring/scripts/lib/plugin-version-check.mjs.map +1 -1
  10. package/dist/authoring/scripts/lib/skill-scaffold.d.mts +77 -90
  11. package/dist/authoring/scripts/lib/skill-scaffold.mjs +99 -120
  12. package/dist/authoring/scripts/lib/skill-scaffold.mjs.map +1 -1
  13. package/dist/authoring/scripts/plugin-status.mjs +8 -11
  14. package/dist/authoring/scripts/plugin-status.mjs.map +1 -1
  15. package/dist/authoring/scripts/remove-plugin.mjs +367 -0
  16. package/dist/authoring/scripts/remove-plugin.mjs.map +1 -0
  17. package/dist/authoring/scripts/validate-plugin.mjs +307 -1173
  18. package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
  19. package/dist/scripts/aw-skill-eval-materializer.d.ts +26 -0
  20. package/dist/scripts/aw-skill-eval-materializer.js +306 -0
  21. package/dist/scripts/aw-skill-eval-materializer.js.map +1 -0
  22. package/dist/scripts/bundle-plugins.d.ts +1 -2
  23. package/dist/scripts/bundle-plugins.js +24 -7
  24. package/dist/scripts/bundle-plugins.js.map +1 -1
  25. package/dist/scripts/plugin-staging.d.ts +7 -24
  26. package/dist/scripts/plugin-staging.js +22 -142
  27. package/dist/scripts/plugin-staging.js.map +1 -1
  28. package/dist/scripts/test-plugin-scripts.d.ts +2 -0
  29. package/dist/scripts/test-plugin-scripts.js +27 -75
  30. package/dist/scripts/test-plugin-scripts.js.map +1 -1
  31. package/dist/src/adapters/helpers.js +2 -2
  32. package/dist/src/adapters/helpers.js.map +1 -1
  33. package/dist/src/authoring/workspace-commands.d.ts +26 -2
  34. package/dist/src/authoring/workspace-commands.js +44 -19
  35. package/dist/src/authoring/workspace-commands.js.map +1 -1
  36. package/dist/src/commands/aw-capabilities.d.ts +78 -0
  37. package/dist/src/commands/aw-capabilities.js +256 -0
  38. package/dist/src/commands/aw-capabilities.js.map +1 -0
  39. package/dist/src/commands/catalog-dev-source.d.ts +154 -0
  40. package/dist/src/commands/catalog-dev-source.js +655 -0
  41. package/dist/src/commands/catalog-dev-source.js.map +1 -0
  42. package/dist/src/commands/catalog-generation.d.ts +21 -0
  43. package/dist/src/commands/catalog-generation.js +9 -0
  44. package/dist/src/commands/catalog-generation.js.map +1 -0
  45. package/dist/src/commands/catalog-publication-inspection.d.ts +138 -0
  46. package/dist/src/commands/catalog-publication-inspection.js +757 -0
  47. package/dist/src/commands/catalog-publication-inspection.js.map +1 -0
  48. package/dist/src/commands/catalog-publication-journal.d.ts +68 -0
  49. package/dist/src/commands/catalog-publication-journal.js +292 -0
  50. package/dist/src/commands/catalog-publication-journal.js.map +1 -0
  51. package/dist/src/commands/catalog-publication-target.d.ts +18 -0
  52. package/dist/src/commands/catalog-publication-target.js +95 -0
  53. package/dist/src/commands/catalog-publication-target.js.map +1 -0
  54. package/dist/src/commands/catalog-publish.d.ts +77 -7
  55. package/dist/src/commands/catalog-publish.js +746 -316
  56. package/dist/src/commands/catalog-publish.js.map +1 -1
  57. package/dist/src/commands/catalog-source.d.ts +60 -22
  58. package/dist/src/commands/catalog-source.js +311 -91
  59. package/dist/src/commands/catalog-source.js.map +1 -1
  60. package/dist/src/commands/catalog-status.d.ts +56 -0
  61. package/dist/src/commands/catalog-status.js +217 -0
  62. package/dist/src/commands/catalog-status.js.map +1 -0
  63. package/dist/src/commands/catalog-store.d.ts +104 -0
  64. package/dist/src/commands/catalog-store.js +685 -0
  65. package/dist/src/commands/catalog-store.js.map +1 -0
  66. package/dist/src/commands/catalog-workspace-resolution.d.ts +13 -0
  67. package/dist/src/commands/catalog-workspace-resolution.js +42 -0
  68. package/dist/src/commands/catalog-workspace-resolution.js.map +1 -0
  69. package/dist/src/commands/console.js +28 -17
  70. package/dist/src/commands/console.js.map +1 -1
  71. package/dist/src/commands/dependency-operation-plan.d.ts +52 -15
  72. package/dist/src/commands/dependency-operation-plan.js +289 -7
  73. package/dist/src/commands/dependency-operation-plan.js.map +1 -1
  74. package/dist/src/commands/init.d.ts +5 -11
  75. package/dist/src/commands/init.js +30 -51
  76. package/dist/src/commands/init.js.map +1 -1
  77. package/dist/src/commands/offline-cleanup-evidence.d.ts +67 -0
  78. package/dist/src/commands/offline-cleanup-evidence.js +181 -0
  79. package/dist/src/commands/offline-cleanup-evidence.js.map +1 -0
  80. package/dist/src/commands/operation-plan.d.ts +127 -0
  81. package/dist/src/commands/operation-plan.js +71 -0
  82. package/dist/src/commands/operation-plan.js.map +1 -0
  83. package/dist/src/commands/operation-planner.d.ts +46 -0
  84. package/dist/src/commands/operation-planner.js +141 -0
  85. package/dist/src/commands/operation-planner.js.map +1 -0
  86. package/dist/src/commands/options.d.ts +9 -7
  87. package/dist/src/commands/options.js +83 -21
  88. package/dist/src/commands/options.js.map +1 -1
  89. package/dist/src/commands/plugin-capabilities.d.ts +22 -0
  90. package/dist/src/commands/plugin-capabilities.js +159 -0
  91. package/dist/src/commands/plugin-capabilities.js.map +1 -0
  92. package/dist/src/commands/rebuild-command.d.ts +77 -30
  93. package/dist/src/commands/rebuild-command.js +3993 -711
  94. package/dist/src/commands/rebuild-command.js.map +1 -1
  95. package/dist/src/commands/rebuild-integration.d.ts +120 -21
  96. package/dist/src/commands/rebuild-integration.js +2765 -1326
  97. package/dist/src/commands/rebuild-integration.js.map +1 -1
  98. package/dist/src/commands/rebuild-operations.d.ts +58 -30
  99. package/dist/src/commands/rebuild-operations.js +260 -319
  100. package/dist/src/commands/rebuild-operations.js.map +1 -1
  101. package/dist/src/commands/reconcile-operation-plan.d.ts +28 -0
  102. package/dist/src/commands/reconcile-operation-plan.js +47 -0
  103. package/dist/src/commands/reconcile-operation-plan.js.map +1 -0
  104. package/dist/src/commands/review-inspection.d.ts +228 -0
  105. package/dist/src/commands/review-inspection.js +1341 -0
  106. package/dist/src/commands/review-inspection.js.map +1 -0
  107. package/dist/src/commands/review-preparation.d.ts +49 -0
  108. package/dist/src/commands/review-preparation.js +427 -0
  109. package/dist/src/commands/review-preparation.js.map +1 -0
  110. package/dist/src/commands/runtime.d.ts +1 -5
  111. package/dist/src/commands/runtime.js +24 -50
  112. package/dist/src/commands/runtime.js.map +1 -1
  113. package/dist/src/commands/skill-eval.d.ts +38 -0
  114. package/dist/src/commands/skill-eval.js +388 -0
  115. package/dist/src/commands/skill-eval.js.map +1 -0
  116. package/dist/src/commands/status-v6.d.ts +279 -0
  117. package/dist/src/commands/status-v6.js +2697 -0
  118. package/dist/src/commands/status-v6.js.map +1 -0
  119. package/dist/src/commands/sync-command.d.ts +40 -0
  120. package/dist/src/commands/sync-command.js +250 -0
  121. package/dist/src/commands/sync-command.js.map +1 -0
  122. package/dist/src/commands/wizard.d.ts +3 -4
  123. package/dist/src/commands/wizard.js +2 -2
  124. package/dist/src/commands/wizard.js.map +1 -1
  125. package/dist/src/commands/write-commands.d.ts +9 -3
  126. package/dist/src/commands/write-commands.js +124 -31
  127. package/dist/src/commands/write-commands.js.map +1 -1
  128. package/dist/src/constants.d.ts +7 -1
  129. package/dist/src/constants.js +7 -1
  130. package/dist/src/constants.js.map +1 -1
  131. package/dist/src/eval/manifest-v1.d.ts +71 -0
  132. package/dist/src/eval/manifest-v1.js +370 -0
  133. package/dist/src/eval/manifest-v1.js.map +1 -0
  134. package/dist/src/generators/local-plugin.d.ts +5 -1
  135. package/dist/src/generators/local-plugin.js +225 -104
  136. package/dist/src/generators/local-plugin.js.map +1 -1
  137. package/dist/src/index.d.ts +10 -4
  138. package/dist/src/index.js +1787 -476
  139. package/dist/src/index.js.map +1 -1
  140. package/dist/src/output/command-receipt.d.ts +43 -46
  141. package/dist/src/output/command-receipt.js +256 -80
  142. package/dist/src/output/command-receipt.js.map +1 -1
  143. package/dist/src/output/model.d.ts +3 -44
  144. package/dist/src/output/model.js +1 -144
  145. package/dist/src/output/model.js.map +1 -1
  146. package/dist/src/output/rebuild-progress.js +1 -13
  147. package/dist/src/output/rebuild-progress.js.map +1 -1
  148. package/dist/src/portable/commands.d.ts +46 -7
  149. package/dist/src/portable/commands.js +349 -37
  150. package/dist/src/portable/commands.js.map +1 -1
  151. package/dist/src/portable/materializer.d.ts +17 -4
  152. package/dist/src/portable/materializer.js +160 -38
  153. package/dist/src/portable/materializer.js.map +1 -1
  154. package/dist/src/portable/skills-cli.d.ts +15 -7
  155. package/dist/src/portable/skills-cli.js +66 -19
  156. package/dist/src/portable/skills-cli.js.map +1 -1
  157. package/dist/src/review/eval-source-input.d.ts +43 -0
  158. package/dist/src/review/eval-source-input.js +207 -0
  159. package/dist/src/review/eval-source-input.js.map +1 -0
  160. package/dist/src/review/review-profile.d.ts +17 -0
  161. package/dist/src/review/review-profile.js +177 -0
  162. package/dist/src/review/review-profile.js.map +1 -0
  163. package/dist/src/review/review-selection.d.ts +30 -0
  164. package/dist/src/review/review-selection.js +527 -0
  165. package/dist/src/review/review-selection.js.map +1 -0
  166. package/dist/src/review/review-types.d.ts +68 -0
  167. package/dist/src/review/review-types.js +16 -0
  168. package/dist/src/review/review-types.js.map +1 -0
  169. package/dist/src/review/skill-materialization.d.ts +13 -0
  170. package/dist/src/review/skill-materialization.js +75 -0
  171. package/dist/src/review/skill-materialization.js.map +1 -0
  172. package/dist/src/review/source-binding.d.ts +182 -0
  173. package/dist/src/review/source-binding.js +682 -0
  174. package/dist/src/review/source-binding.js.map +1 -0
  175. package/dist/src/tui/catalog-freshness.d.ts +1 -0
  176. package/dist/src/tui/catalog-freshness.js +2 -0
  177. package/dist/src/tui/catalog-freshness.js.map +1 -0
  178. package/dist/src/tui/catalog-generation.d.ts +21 -0
  179. package/dist/src/tui/catalog-generation.js +156 -0
  180. package/dist/src/tui/catalog-generation.js.map +1 -0
  181. package/dist/src/tui/catalog-sources/projection.d.ts +4 -0
  182. package/dist/src/tui/catalog-sources/projection.js +17 -0
  183. package/dist/src/tui/catalog-sources/projection.js.map +1 -0
  184. package/dist/src/tui/catalog-sources/review.d.ts +3 -0
  185. package/dist/src/tui/catalog-sources/review.js +13 -0
  186. package/dist/src/tui/catalog-sources/review.js.map +1 -0
  187. package/dist/src/tui/catalog-sources/screens.d.ts +12 -0
  188. package/dist/src/tui/catalog-sources/screens.js +40 -0
  189. package/dist/src/tui/catalog-sources/screens.js.map +1 -0
  190. package/dist/src/tui/catalog-sources/session.d.ts +28 -0
  191. package/dist/src/tui/catalog-sources/session.js +295 -0
  192. package/dist/src/tui/catalog-sources/session.js.map +1 -0
  193. package/dist/src/tui/catalog-sources/types.d.ts +53 -0
  194. package/dist/src/tui/catalog-sources/types.js +2 -0
  195. package/dist/src/tui/catalog-sources/types.js.map +1 -0
  196. package/dist/src/tui/catalog-store-task.d.ts +16 -0
  197. package/dist/src/tui/catalog-store-task.js +19 -0
  198. package/dist/src/tui/catalog-store-task.js.map +1 -0
  199. package/dist/src/tui/components.d.ts +128 -0
  200. package/dist/src/tui/components.js +251 -7
  201. package/dist/src/tui/components.js.map +1 -1
  202. package/dist/src/tui/console-app-v4.d.ts +14 -4
  203. package/dist/src/tui/console-app-v4.js +9248 -1461
  204. package/dist/src/tui/console-app-v4.js.map +1 -1
  205. package/dist/src/tui/controller-runtime.d.ts +13 -1
  206. package/dist/src/tui/controller-runtime.js +3338 -410
  207. package/dist/src/tui/controller-runtime.js.map +1 -1
  208. package/dist/src/tui/controller.d.ts +614 -40
  209. package/dist/src/tui/controller.js +3478 -708
  210. package/dist/src/tui/controller.js.map +1 -1
  211. package/dist/src/tui/dependency-graph.d.ts +81 -0
  212. package/dist/src/tui/dependency-graph.js +455 -0
  213. package/dist/src/tui/dependency-graph.js.map +1 -0
  214. package/dist/src/tui/diagnostic-projection.d.ts +23 -0
  215. package/dist/src/tui/diagnostic-projection.js +567 -0
  216. package/dist/src/tui/diagnostic-projection.js.map +1 -0
  217. package/dist/src/tui/diagnostics.d.ts +30 -0
  218. package/dist/src/tui/diagnostics.js +76 -0
  219. package/dist/src/tui/diagnostics.js.map +1 -0
  220. package/dist/src/tui/glossary.d.ts +23 -0
  221. package/dist/src/tui/glossary.js +42 -0
  222. package/dist/src/tui/glossary.js.map +1 -0
  223. package/dist/src/tui/index.d.ts +11 -4
  224. package/dist/src/tui/index.js +8 -2
  225. package/dist/src/tui/index.js.map +1 -1
  226. package/dist/src/tui/input-display.d.ts +8 -0
  227. package/dist/src/tui/input-display.js +36 -0
  228. package/dist/src/tui/input-display.js.map +1 -0
  229. package/dist/src/tui/keys.d.ts +44 -0
  230. package/dist/src/tui/keys.js +43 -15
  231. package/dist/src/tui/keys.js.map +1 -1
  232. package/dist/src/tui/lifecycle-action-view.d.ts +6 -0
  233. package/dist/src/tui/lifecycle-action-view.js +36 -0
  234. package/dist/src/tui/lifecycle-action-view.js.map +1 -0
  235. package/dist/src/tui/model.d.ts +235 -27
  236. package/dist/src/tui/model.js +1652 -304
  237. package/dist/src/tui/model.js.map +1 -1
  238. package/dist/src/tui/operation-diagnostic-screens.d.ts +21 -0
  239. package/dist/src/tui/operation-diagnostic-screens.js +102 -0
  240. package/dist/src/tui/operation-diagnostic-screens.js.map +1 -0
  241. package/dist/src/tui/operation-history.d.ts +81 -0
  242. package/dist/src/tui/operation-history.js +135 -0
  243. package/dist/src/tui/operation-history.js.map +1 -0
  244. package/dist/src/tui/operation-review-planner.d.ts +21 -0
  245. package/dist/src/tui/operation-review-planner.js +1254 -0
  246. package/dist/src/tui/operation-review-planner.js.map +1 -0
  247. package/dist/src/tui/plugin-content.d.ts +23 -0
  248. package/dist/src/tui/plugin-content.js +336 -0
  249. package/dist/src/tui/plugin-content.js.map +1 -0
  250. package/dist/src/tui/plugin-write-task.d.ts +69 -0
  251. package/dist/src/tui/plugin-write-task.js +286 -0
  252. package/dist/src/tui/plugin-write-task.js.map +1 -0
  253. package/dist/src/tui/prompt.js +4 -15
  254. package/dist/src/tui/prompt.js.map +1 -1
  255. package/dist/src/tui/router.d.ts +183 -11
  256. package/dist/src/tui/router.js +352 -29
  257. package/dist/src/tui/router.js.map +1 -1
  258. package/dist/src/tui/screen-registry.d.ts +702 -0
  259. package/dist/src/tui/screen-registry.js +231 -0
  260. package/dist/src/tui/screen-registry.js.map +1 -0
  261. package/dist/src/tui/session-console-app.d.ts +6 -0
  262. package/dist/src/tui/session-console-app.js +13 -0
  263. package/dist/src/tui/session-console-app.js.map +1 -0
  264. package/dist/src/tui/session-host.d.ts +45 -0
  265. package/dist/src/tui/session-host.js +209 -0
  266. package/dist/src/tui/session-host.js.map +1 -0
  267. package/dist/src/tui/source-ref-presets.d.ts +3 -0
  268. package/dist/src/tui/source-ref-presets.js +11 -0
  269. package/dist/src/tui/source-ref-presets.js.map +1 -0
  270. package/dist/src/tui/theme.d.ts +18 -10
  271. package/dist/src/tui/theme.js +18 -10
  272. package/dist/src/tui/theme.js.map +1 -1
  273. package/dist/src/tui/viewport.d.ts +20 -0
  274. package/dist/src/tui/viewport.js +29 -0
  275. package/dist/src/tui/viewport.js.map +1 -0
  276. package/dist/src/tui/views.js +31 -3
  277. package/dist/src/tui/views.js.map +1 -1
  278. package/dist/src/tui/wizard.js +11 -9
  279. package/dist/src/tui/wizard.js.map +1 -1
  280. package/dist/src/types.d.ts +242 -20
  281. package/dist/src/types.js +1 -0
  282. package/dist/src/types.js.map +1 -1
  283. package/dist/src/utils/agent-version.d.ts +7 -1
  284. package/dist/src/utils/agent-version.js +41 -8
  285. package/dist/src/utils/agent-version.js.map +1 -1
  286. package/dist/src/utils/artifact-plan.d.ts +5 -4
  287. package/dist/src/utils/artifact-plan.js +18 -7
  288. package/dist/src/utils/artifact-plan.js.map +1 -1
  289. package/dist/src/utils/artifact-renderer.d.ts +13 -7
  290. package/dist/src/utils/artifact-renderer.js +196 -219
  291. package/dist/src/utils/artifact-renderer.js.map +1 -1
  292. package/dist/src/utils/artifact-request.d.ts +21 -0
  293. package/dist/src/utils/artifact-request.js +82 -0
  294. package/dist/src/utils/artifact-request.js.map +1 -0
  295. package/dist/src/utils/aw-home-mutation-lock.d.ts +1 -0
  296. package/dist/src/utils/aw-home-mutation-lock.js +32 -4
  297. package/dist/src/utils/aw-home-mutation-lock.js.map +1 -1
  298. package/dist/src/utils/bundle-integrity.d.ts +0 -1
  299. package/dist/src/utils/bundle-integrity.js +0 -25
  300. package/dist/src/utils/bundle-integrity.js.map +1 -1
  301. package/dist/src/utils/bundle-layout.js +14 -29
  302. package/dist/src/utils/bundle-layout.js.map +1 -1
  303. package/dist/src/utils/catalog-capability-projection.d.ts +8 -0
  304. package/dist/src/utils/catalog-capability-projection.js +14 -0
  305. package/dist/src/utils/catalog-capability-projection.js.map +1 -0
  306. package/dist/src/utils/catalog-digests.d.ts +10 -0
  307. package/dist/src/utils/catalog-digests.js +50 -2
  308. package/dist/src/utils/catalog-digests.js.map +1 -1
  309. package/dist/src/utils/catalog-generation-control-snapshot.d.ts +11 -0
  310. package/dist/src/utils/catalog-generation-control-snapshot.js +45 -0
  311. package/dist/src/utils/catalog-generation-control-snapshot.js.map +1 -0
  312. package/dist/src/utils/catalog-generation-error.d.ts +16 -0
  313. package/dist/src/utils/catalog-generation-error.js +30 -0
  314. package/dist/src/utils/catalog-generation-error.js.map +1 -0
  315. package/dist/src/utils/catalog-generation-resolver.d.ts +44 -0
  316. package/dist/src/utils/catalog-generation-resolver.js +273 -0
  317. package/dist/src/utils/catalog-generation-resolver.js.map +1 -0
  318. package/dist/src/utils/catalog-generation-service.d.ts +172 -0
  319. package/dist/src/utils/catalog-generation-service.js +1271 -0
  320. package/dist/src/utils/catalog-generation-service.js.map +1 -0
  321. package/dist/src/utils/catalog-generation-state.d.ts +22 -0
  322. package/dist/src/utils/catalog-generation-state.js +192 -0
  323. package/dist/src/utils/catalog-generation-state.js.map +1 -0
  324. package/dist/src/utils/catalog-generation-store.d.ts +58 -0
  325. package/dist/src/utils/catalog-generation-store.js +452 -0
  326. package/dist/src/utils/catalog-generation-store.js.map +1 -0
  327. package/dist/src/utils/catalog-manifest-v7.d.ts +5 -0
  328. package/dist/src/utils/{catalog-manifest-v4.js → catalog-manifest-v7.js} +35 -43
  329. package/dist/src/utils/catalog-manifest-v7.js.map +1 -0
  330. package/dist/src/utils/catalog-operation-context.d.ts +20 -0
  331. package/dist/src/utils/catalog-operation-context.js +142 -0
  332. package/dist/src/utils/catalog-operation-context.js.map +1 -0
  333. package/dist/src/utils/catalog-public-error.d.ts +7 -3
  334. package/dist/src/utils/catalog-public-error.js +28 -8
  335. package/dist/src/utils/catalog-public-error.js.map +1 -1
  336. package/dist/src/utils/catalog-runtime-projection.d.ts +4 -7
  337. package/dist/src/utils/catalog-runtime-projection.js +7 -102
  338. package/dist/src/utils/catalog-runtime-projection.js.map +1 -1
  339. package/dist/src/utils/catalog-snapshot.d.ts +5 -3
  340. package/dist/src/utils/catalog-snapshot.js +11 -3
  341. package/dist/src/utils/catalog-snapshot.js.map +1 -1
  342. package/dist/src/utils/catalog-source-identity.d.ts +1 -0
  343. package/dist/src/utils/catalog-source-identity.js +21 -2
  344. package/dist/src/utils/catalog-source-identity.js.map +1 -1
  345. package/dist/src/utils/catalog-source-impact.d.ts +21 -0
  346. package/dist/src/utils/catalog-source-impact.js +344 -0
  347. package/dist/src/utils/catalog-source-impact.js.map +1 -0
  348. package/dist/src/utils/catalog-source-references.d.ts +3 -2
  349. package/dist/src/utils/catalog-source-references.js +195 -347
  350. package/dist/src/utils/catalog-source-references.js.map +1 -1
  351. package/dist/src/utils/catalog-sources.d.ts +15 -1
  352. package/dist/src/utils/catalog-sources.js +206 -27
  353. package/dist/src/utils/catalog-sources.js.map +1 -1
  354. package/dist/src/utils/codex-config.d.ts +2 -0
  355. package/dist/src/utils/codex-config.js +26 -5
  356. package/dist/src/utils/codex-config.js.map +1 -1
  357. package/dist/src/utils/codex-manager.d.ts +79 -0
  358. package/dist/src/utils/codex-manager.js +745 -0
  359. package/dist/src/utils/codex-manager.js.map +1 -0
  360. package/dist/src/utils/codex-marketplace-path.d.ts +5 -0
  361. package/dist/src/utils/codex-marketplace-path.js +45 -0
  362. package/dist/src/utils/codex-marketplace-path.js.map +1 -0
  363. package/dist/src/utils/codex-native-observation.d.ts +49 -0
  364. package/dist/src/utils/codex-native-observation.js +154 -0
  365. package/dist/src/utils/codex-native-observation.js.map +1 -0
  366. package/dist/src/utils/codex-native-render-receipt.d.ts +40 -0
  367. package/dist/src/utils/codex-native-render-receipt.js +205 -0
  368. package/dist/src/utils/codex-native-render-receipt.js.map +1 -0
  369. package/dist/src/utils/codex-reconciler.d.ts +126 -0
  370. package/dist/src/utils/codex-reconciler.js +298 -0
  371. package/dist/src/utils/codex-reconciler.js.map +1 -0
  372. package/dist/src/utils/codex-shared-native.d.ts +43 -0
  373. package/dist/src/utils/codex-shared-native.js +81 -0
  374. package/dist/src/utils/codex-shared-native.js.map +1 -0
  375. package/dist/src/utils/codex-skill-staging.d.ts +2 -0
  376. package/dist/src/utils/codex-skill-staging.js.map +1 -1
  377. package/dist/src/utils/codex-surface-analysis.d.ts +46 -0
  378. package/dist/src/utils/codex-surface-analysis.js +247 -0
  379. package/dist/src/utils/codex-surface-analysis.js.map +1 -0
  380. package/dist/src/utils/dynamic-skill-tree.d.ts +4 -0
  381. package/dist/src/utils/dynamic-skill-tree.js +36 -6
  382. package/dist/src/utils/dynamic-skill-tree.js.map +1 -1
  383. package/dist/src/utils/git-catalog-provider.d.ts +18 -0
  384. package/dist/src/utils/git-catalog-provider.js +170 -144
  385. package/dist/src/utils/git-catalog-provider.js.map +1 -1
  386. package/dist/src/utils/local-marketplace.d.ts +15 -1
  387. package/dist/src/utils/local-marketplace.js +307 -84
  388. package/dist/src/utils/local-marketplace.js.map +1 -1
  389. package/dist/src/utils/manifest.d.ts +1 -4
  390. package/dist/src/utils/manifest.js +1 -4
  391. package/dist/src/utils/manifest.js.map +1 -1
  392. package/dist/src/utils/multi-source-catalog.d.ts +3 -9
  393. package/dist/src/utils/multi-source-catalog.js +54 -110
  394. package/dist/src/utils/multi-source-catalog.js.map +1 -1
  395. package/dist/src/utils/native-cli.d.ts +55 -7
  396. package/dist/src/utils/native-cli.js +386 -57
  397. package/dist/src/utils/native-cli.js.map +1 -1
  398. package/dist/src/utils/orphan-marketplace-cleanup.js +0 -4
  399. package/dist/src/utils/orphan-marketplace-cleanup.js.map +1 -1
  400. package/dist/src/utils/ownership.d.ts +84 -20
  401. package/dist/src/utils/ownership.js +179 -222
  402. package/dist/src/utils/ownership.js.map +1 -1
  403. package/dist/src/utils/path-catalog-provider.d.ts +1 -1
  404. package/dist/src/utils/path-catalog-provider.js +54 -65
  405. package/dist/src/utils/path-catalog-provider.js.map +1 -1
  406. package/dist/src/utils/paths.d.ts +0 -1
  407. package/dist/src/utils/paths.js +0 -1
  408. package/dist/src/utils/paths.js.map +1 -1
  409. package/dist/src/utils/plugin-config-impact.d.ts +33 -0
  410. package/dist/src/utils/plugin-config-impact.js +298 -0
  411. package/dist/src/utils/plugin-config-impact.js.map +1 -0
  412. package/dist/src/utils/plugin-config-write.d.ts +52 -27
  413. package/dist/src/utils/plugin-config-write.js +990 -298
  414. package/dist/src/utils/plugin-config-write.js.map +1 -1
  415. package/dist/src/utils/plugin-config.d.ts +140 -93
  416. package/dist/src/utils/plugin-config.js +992 -980
  417. package/dist/src/utils/plugin-config.js.map +1 -1
  418. package/dist/src/utils/plugin-intent-state.d.ts +49 -0
  419. package/dist/src/utils/plugin-intent-state.js +320 -0
  420. package/dist/src/utils/plugin-intent-state.js.map +1 -0
  421. package/dist/src/utils/plugin-scripts.d.ts +62 -125
  422. package/dist/src/utils/plugin-scripts.js +468 -525
  423. package/dist/src/utils/plugin-scripts.js.map +1 -1
  424. package/dist/src/utils/process-tree.d.ts +2 -2
  425. package/dist/src/utils/process-tree.js +1 -1
  426. package/dist/src/utils/process-tree.js.map +1 -1
  427. package/dist/src/utils/project-boundary.d.ts +11 -13
  428. package/dist/src/utils/project-boundary.js +28 -34
  429. package/dist/src/utils/project-boundary.js.map +1 -1
  430. package/dist/src/utils/safe-fs.d.ts +21 -0
  431. package/dist/src/utils/safe-fs.js +111 -0
  432. package/dist/src/utils/safe-fs.js.map +1 -0
  433. package/dist/src/utils/safe-operation-diagnostic.d.ts +15 -0
  434. package/dist/src/utils/safe-operation-diagnostic.js +33 -0
  435. package/dist/src/utils/safe-operation-diagnostic.js.map +1 -0
  436. package/dist/src/utils/sensitive-content.d.ts +4 -0
  437. package/dist/src/utils/sensitive-content.js +36 -0
  438. package/dist/src/utils/sensitive-content.js.map +1 -0
  439. package/dist/src/utils/skill-validation.d.ts +1 -1
  440. package/dist/src/utils/skill-validation.js +1 -1
  441. package/dist/src/utils/skill-validation.js.map +1 -1
  442. package/dist/src/utils/state-paths.d.ts +1 -0
  443. package/dist/src/utils/state-paths.js +12 -2
  444. package/dist/src/utils/state-paths.js.map +1 -1
  445. package/dist/src/utils/target-eligibility.d.ts +8 -2
  446. package/dist/src/utils/target-eligibility.js +17 -8
  447. package/dist/src/utils/target-eligibility.js.map +1 -1
  448. package/dist/src/utils/windows-claude-shim.d.ts +9 -0
  449. package/dist/src/utils/windows-claude-shim.js +141 -0
  450. package/dist/src/utils/windows-claude-shim.js.map +1 -0
  451. package/dist/vitest.config.js +91 -10
  452. package/dist/vitest.config.js.map +1 -1
  453. package/package.json +22 -19
  454. package/dist/authoring/scripts/check-plugin-versions.mjs +0 -5
  455. package/dist/authoring/scripts/check-plugin-versions.mjs.map +0 -1
  456. package/dist/scripts/aw-skill-eval-engine.d.ts +0 -13
  457. package/dist/scripts/aw-skill-eval-engine.js +0 -31
  458. package/dist/scripts/aw-skill-eval-engine.js.map +0 -1
  459. package/dist/scripts/codex-eval-app-server.d.ts +0 -89
  460. package/dist/scripts/codex-eval-app-server.js +0 -1228
  461. package/dist/scripts/codex-eval-app-server.js.map +0 -1
  462. package/dist/scripts/codex-eval-isolation.d.ts +0 -61
  463. package/dist/scripts/codex-eval-isolation.js +0 -318
  464. package/dist/scripts/codex-eval-isolation.js.map +0 -1
  465. package/dist/scripts/codex-eval-process-management.d.ts +0 -8
  466. package/dist/scripts/codex-eval-process-management.js +0 -69
  467. package/dist/scripts/codex-eval-process-management.js.map +0 -1
  468. package/dist/scripts/codex-eval-process-tree.d.ts +0 -38
  469. package/dist/scripts/codex-eval-process-tree.js +0 -803
  470. package/dist/scripts/codex-eval-process-tree.js.map +0 -1
  471. package/dist/scripts/codex-eval-runtime-config.d.ts +0 -62
  472. package/dist/scripts/codex-eval-runtime-config.js +0 -843
  473. package/dist/scripts/codex-eval-runtime-config.js.map +0 -1
  474. package/dist/scripts/codex-trigger-eval.d.ts +0 -84
  475. package/dist/scripts/codex-trigger-eval.js +0 -968
  476. package/dist/scripts/codex-trigger-eval.js.map +0 -1
  477. package/dist/scripts/eval-plugin-skills-audited.d.ts +0 -6
  478. package/dist/scripts/eval-plugin-skills-audited.js +0 -261
  479. package/dist/scripts/eval-plugin-skills-audited.js.map +0 -1
  480. package/dist/scripts/eval-plugin-skills.d.ts +0 -45
  481. package/dist/scripts/eval-plugin-skills.js +0 -1586
  482. package/dist/scripts/eval-plugin-skills.js.map +0 -1
  483. package/dist/scripts/eval-run-layout.d.ts +0 -17
  484. package/dist/scripts/eval-run-layout.js +0 -26
  485. package/dist/scripts/eval-run-layout.js.map +0 -1
  486. package/dist/scripts/plugin-eval-contract.d.ts +0 -185
  487. package/dist/scripts/plugin-eval-contract.js +0 -695
  488. package/dist/scripts/plugin-eval-contract.js.map +0 -1
  489. package/dist/scripts/plugin-eval-materializer.d.ts +0 -13
  490. package/dist/scripts/plugin-eval-materializer.js +0 -421
  491. package/dist/scripts/plugin-eval-materializer.js.map +0 -1
  492. package/dist/scripts/skill-reporting.d.ts +0 -212
  493. package/dist/scripts/skill-reporting.js +0 -922
  494. package/dist/scripts/skill-reporting.js.map +0 -1
  495. package/dist/src/commands/status-v4.d.ts +0 -102
  496. package/dist/src/commands/status-v4.js +0 -844
  497. package/dist/src/commands/status-v4.js.map +0 -1
  498. package/dist/src/commands/status.d.ts +0 -93
  499. package/dist/src/commands/status.js +0 -442
  500. package/dist/src/commands/status.js.map +0 -1
  501. package/dist/src/utils/active-marketplace-runtime-lock.d.ts +0 -12
  502. package/dist/src/utils/active-marketplace-runtime-lock.js +0 -133
  503. package/dist/src/utils/active-marketplace-runtime-lock.js.map +0 -1
  504. package/dist/src/utils/catalog-manifest-v3.d.ts +0 -2
  505. package/dist/src/utils/catalog-manifest-v3.js +0 -3
  506. package/dist/src/utils/catalog-manifest-v3.js.map +0 -1
  507. package/dist/src/utils/catalog-manifest-v4.d.ts +0 -5
  508. package/dist/src/utils/catalog-manifest-v4.js.map +0 -1
  509. package/dist/src/utils/catalog-source-cache.d.ts +0 -61
  510. package/dist/src/utils/catalog-source-cache.js +0 -276
  511. package/dist/src/utils/catalog-source-cache.js.map +0 -1
  512. package/dist/src/utils/codex-project-surface.d.ts +0 -3
  513. package/dist/src/utils/codex-project-surface.js +0 -49
  514. package/dist/src/utils/codex-project-surface.js.map +0 -1
  515. package/dist/src/utils/lifecycle-active-store.d.ts +0 -175
  516. package/dist/src/utils/lifecycle-active-store.js +0 -1276
  517. package/dist/src/utils/lifecycle-active-store.js.map +0 -1
  518. package/dist/src/utils/plugin-authoring-capabilities.d.ts +0 -23
  519. package/dist/src/utils/plugin-authoring-capabilities.js +0 -37
  520. package/dist/src/utils/plugin-authoring-capabilities.js.map +0 -1
  521. package/dist/src/utils/plugin-authoring-capabilities.json +0 -92
  522. package/dist/src/utils/plugin-release.d.ts +0 -2
  523. package/dist/src/utils/plugin-release.js +0 -2
  524. package/dist/src/utils/plugin-release.js.map +0 -1
  525. package/dist/src/utils/skill-frontmatter-capabilities.d.ts +0 -201
  526. package/dist/src/utils/skill-frontmatter-capabilities.js +0 -5
  527. package/dist/src/utils/skill-frontmatter-capabilities.js.map +0 -1
  528. package/dist/src/utils/skill-frontmatter-capabilities.json +0 -200
  529. /package/dist/authoring/scripts/{check-plugin-versions.d.mts → remove-plugin.d.mts} +0 -0
@@ -0,0 +1,757 @@
1
+ import crypto from 'node:crypto';
2
+ import { execFile } from 'node:child_process';
3
+ import os from 'node:os';
4
+ import path from 'node:path';
5
+ import { promisify } from 'node:util';
6
+ import fs from 'fs-extra';
7
+ import { CATALOG_MANIFEST_FILENAME, GENERATED_OUTPUT_MARKER_FILENAME, preparePublishedCatalogWorkspace, readCatalogWorkspaceMarker, readCatalogWorkspace, validatePublishedCatalogSnapshot, validatePublishedCatalogSnapshotMetadata, } from '@lesliechan721/aw-plugin-core';
8
+ import { bundleLocalPlugin, createCatalogRuntimeImportResolver } from '../../scripts/plugin-staging.js';
9
+ import { redactString } from '../output/redact.js';
10
+ import { sanitizeCatalogSourceErrorMessage } from '../utils/catalog-public-error.js';
11
+ import { CLI_RESERVED_IMPORTS } from '../utils/manifest.js';
12
+ import { resolveCliPackageRoot } from '../utils/paths.js';
13
+ const execFileAsync = promisify(execFile);
14
+ const INHERITED_GIT_AUTH_ENV = new Set([
15
+ 'GIT_ASKPASS',
16
+ 'GIT_HTTP_USER_AGENT',
17
+ 'GIT_SSH',
18
+ 'GIT_SSH_COMMAND',
19
+ 'GIT_SSH_VARIANT',
20
+ 'GIT_SSL_CAINFO',
21
+ 'GIT_SSL_NO_VERIFY',
22
+ 'GIT_TERMINAL_PROMPT',
23
+ ]);
24
+ export class CatalogPublicationInspectionError extends Error {
25
+ code;
26
+ constructor(code, message, options) {
27
+ super(message, options);
28
+ this.name = 'CatalogPublicationInspectionError';
29
+ this.code = code;
30
+ }
31
+ }
32
+ function digest(value) {
33
+ return `sha256:${crypto.createHash('sha256').update(value).digest('hex')}`;
34
+ }
35
+ export function sanitizedGitEnvironment(source) {
36
+ return Object.fromEntries(Object.entries(source).filter(([key]) => !key.startsWith('GIT_') || INHERITED_GIT_AUTH_ENV.has(key)));
37
+ }
38
+ function directRemoteGitEnvironment(source) {
39
+ return {
40
+ ...sanitizedGitEnvironment(source),
41
+ GIT_CONFIG_NOSYSTEM: '1',
42
+ GIT_CONFIG_GLOBAL: os.devNull,
43
+ GIT_ATTR_NOSYSTEM: '1',
44
+ GIT_TERMINAL_PROMPT: '0',
45
+ };
46
+ }
47
+ export function safeRemoteIdentity(value) {
48
+ if (/^[a-z][a-z\d+.-]*:\/\//iu.test(value)) {
49
+ try {
50
+ const url = new URL(value);
51
+ url.username = '';
52
+ url.password = '';
53
+ url.search = '';
54
+ url.hash = '';
55
+ return url.toString();
56
+ }
57
+ catch {
58
+ // Fall through to conservative display sanitization for malformed URLs.
59
+ }
60
+ }
61
+ const withoutQuery = value.split(/[?#]/u, 1)[0];
62
+ return withoutQuery
63
+ .replace(/^([^/@\s:]+):([^/@\s]+)@/u, '')
64
+ .replace(/^[^@\s]+@(?=[^:/\s]+[/:])/u, '');
65
+ }
66
+ function sanitizeCatalogPublicationMessage(message, env, sensitiveRoots, sensitiveValues = []) {
67
+ const normalized = redactString(message.replace(/[\p{Cc}\p{Cf}]+/gu, ' '));
68
+ const withoutSensitiveValues = [...sensitiveValues]
69
+ .filter((value) => value.length >= 4)
70
+ .sort((left, right) => right.length - left.length)
71
+ .reduce((output, value) => output.replaceAll(value, '[remote]'), normalized);
72
+ const withoutRemotes = withoutSensitiveValues
73
+ .replace(/[a-z][a-z\d+.-]*:\/\/[^\s"'<>]+/giu, '[remote]')
74
+ .replace(/[^\s"'<>@]+@[^\s"'<>:/]+[:/][^\s"'<>]+/gu, '[remote]');
75
+ const withoutKnownRoots = sanitizeCatalogSourceErrorMessage(withoutRemotes, env, sensitiveRoots);
76
+ return redactString(withoutKnownRoots).replace(/(?<![A-Za-z0-9._-])(?:[A-Za-z]:[\\/]|\/)(?:[^\s"'<>:]+[\\/])*[^\s"'<>:]*/gu, '[private-path]');
77
+ }
78
+ function remoteSensitiveValues(value) {
79
+ const values = new Set([value]);
80
+ if (/^[a-z][a-z\d+.-]*:\/\//iu.test(value)) {
81
+ try {
82
+ const url = new URL(value);
83
+ for (const part of [url.username, url.password, url.hostname, url.pathname, url.pathname.slice(1)]) {
84
+ if (part.length >= 4)
85
+ values.add(part);
86
+ }
87
+ }
88
+ catch {
89
+ // The remote value is validated separately.
90
+ }
91
+ }
92
+ else {
93
+ const match = /^(?:([^@:/]+)@)?([^:/]+)[:/](.+)$/u.exec(value);
94
+ for (const part of match?.slice(1) ?? []) {
95
+ if (part && part.length >= 4)
96
+ values.add(part);
97
+ }
98
+ }
99
+ return [...values];
100
+ }
101
+ export function catalogPublicationFailure(options) {
102
+ const original = options.error instanceof Error
103
+ ? options.error.message
104
+ : String(options.error);
105
+ const message = sanitizeCatalogPublicationMessage(original, options.env, options.sensitiveRoots);
106
+ return {
107
+ ok: false,
108
+ code: options.error instanceof CatalogPublicationInspectionError
109
+ ? options.error.code
110
+ : 'catalogPublicationFailed',
111
+ message,
112
+ };
113
+ }
114
+ function assertSafeRemoteUrl(value, options = {}) {
115
+ if (value.trim() === '' || value !== value.trim() || /[\s\p{Cc}]/u.test(value) || value.startsWith('-')) {
116
+ throw new CatalogPublicationInspectionError('remoteInvalid', 'Catalog remote URL is unsafe.');
117
+ }
118
+ if (!options.allowCredentials && /^[a-z][a-z\d+.-]*:\/\/[^/\s?#]*@/iu.test(value)) {
119
+ throw new CatalogPublicationInspectionError('remoteInvalid', 'Catalog remote URL must not contain embedded credentials.');
120
+ }
121
+ return value;
122
+ }
123
+ function assertSafeRemoteName(value) {
124
+ if (value === '' || value !== value.trim() || value.startsWith('-') || /[\s\p{Cc}]/u.test(value)) {
125
+ throw new CatalogPublicationInspectionError('remoteInvalid', 'Catalog remote name is unsafe.');
126
+ }
127
+ return value;
128
+ }
129
+ function assertSafeBranchValue(value) {
130
+ if (!/^[A-Za-z0-9][A-Za-z0-9._/-]*$/u.test(value)) {
131
+ throw new CatalogPublicationInspectionError('branchInvalid', 'Invalid Catalog publication branch name.');
132
+ }
133
+ return value;
134
+ }
135
+ export async function publicationGit(cwd, args, env, code, label, sensitiveValues = []) {
136
+ try {
137
+ const result = await execFileAsync('git', ['-c', `core.hooksPath=${os.devNull}`, ...args], {
138
+ cwd,
139
+ env,
140
+ encoding: 'utf8',
141
+ maxBuffer: 16 * 1024 * 1024,
142
+ });
143
+ return result.stdout.trim();
144
+ }
145
+ catch (error) {
146
+ const failure = error;
147
+ const status = typeof failure.code === 'number' && Number.isSafeInteger(failure.code)
148
+ ? `exited with code ${failure.code}`
149
+ : typeof failure.code === 'string' && /^[A-Z0-9_]+$/u.test(failure.code)
150
+ ? `failed with code ${failure.code}`
151
+ : 'failed';
152
+ const rawDetails = typeof failure.stderr === 'string' && failure.stderr.trim() !== ''
153
+ ? failure.stderr
154
+ : typeof failure.message === 'string'
155
+ ? failure.message
156
+ : '';
157
+ const details = sanitizeCatalogPublicationMessage(rawDetails, env, [cwd], sensitiveValues)
158
+ .replace(/\s+/gu, ' ')
159
+ .trim();
160
+ throw new CatalogPublicationInspectionError(code, `${label} Git ${status}${details ? `: ${details.slice(0, 2_000)}` : '.'}`, { cause: error });
161
+ }
162
+ }
163
+ export async function publicationGitExit(cwd, args, env) {
164
+ try {
165
+ await execFileAsync('git', ['-c', `core.hooksPath=${os.devNull}`, ...args], {
166
+ cwd,
167
+ env,
168
+ encoding: 'utf8',
169
+ });
170
+ return true;
171
+ }
172
+ catch {
173
+ return false;
174
+ }
175
+ }
176
+ export function parseRemoteRefs(output) {
177
+ return new Map(output.split('\n').filter(Boolean).map((line) => {
178
+ const [objectId, ref] = line.split(/\s+/u);
179
+ return [ref, objectId];
180
+ }));
181
+ }
182
+ export async function materializeSourceHead(options) {
183
+ const archivePath = path.join(options.temporaryRoot, 'source-head.tar');
184
+ await fs.ensureDir(options.outputRoot);
185
+ await publicationGit(options.repoRoot, [
186
+ 'archive', '--format=tar', `--output=${archivePath}`, options.sourceHead,
187
+ ], options.env, 'sourceArchiveFailed', 'Could not archive the committed source HEAD.');
188
+ const tarEnv = { ...options.env };
189
+ delete tarEnv.TAR_OPTIONS;
190
+ try {
191
+ await execFileAsync('tar', ['-xf', archivePath, '-C', options.outputRoot], {
192
+ env: tarEnv,
193
+ encoding: 'utf8',
194
+ maxBuffer: 16 * 1024 * 1024,
195
+ });
196
+ }
197
+ catch (error) {
198
+ throw new CatalogPublicationInspectionError('sourceArchiveFailed', 'Could not materialize the committed source HEAD.', { cause: error });
199
+ }
200
+ finally {
201
+ await fs.remove(archivePath);
202
+ }
203
+ }
204
+ export async function validateCatalogPublicationPlugins(catalogWorkspace, env) {
205
+ const validator = path.join(resolveCliPackageRoot(), 'dist', 'authoring', 'scripts', 'validate-plugin.mjs');
206
+ for (const plugin of catalogWorkspace.plugins) {
207
+ try {
208
+ await execFileAsync(process.execPath, [
209
+ validator,
210
+ plugin.rootDir,
211
+ '--workspace-root', catalogWorkspace.workspaceRoot,
212
+ '--json',
213
+ ], {
214
+ cwd: catalogWorkspace.workspaceRoot,
215
+ env,
216
+ encoding: 'utf8',
217
+ maxBuffer: 16 * 1024 * 1024,
218
+ });
219
+ }
220
+ catch (error) {
221
+ let details = '';
222
+ if (typeof error === 'object' && error !== null && 'stdout' in error && typeof error.stdout === 'string') {
223
+ try {
224
+ const result = JSON.parse(error.stdout);
225
+ details = (result.errors ?? [])
226
+ .map((entry) => typeof entry.message === 'string' ? entry.message : '')
227
+ .filter(Boolean)
228
+ .join('; ');
229
+ }
230
+ catch {
231
+ // Keep the public validator failure bounded to its plugin identity.
232
+ }
233
+ }
234
+ throw new CatalogPublicationInspectionError('pluginValidationFailed', `Plugin ${plugin.manifest.name} failed public source validation before Catalog publication${details ? `: ${details}` : '.'}`);
235
+ }
236
+ }
237
+ }
238
+ const publicationBuildAdapter = {
239
+ async build(options) {
240
+ await bundleLocalPlugin(options.plugin, options.outputRoot, {
241
+ buildMode: 'staging',
242
+ runtimeResolver: createCatalogRuntimeImportResolver(options.plugins),
243
+ });
244
+ },
245
+ };
246
+ function inspectionError(code, error) {
247
+ if (error instanceof CatalogPublicationInspectionError)
248
+ return error;
249
+ return new CatalogPublicationInspectionError(code, error instanceof Error ? error.message : String(error), {
250
+ cause: error,
251
+ });
252
+ }
253
+ async function validatePublishedCatalogSnapshotForWorkspace(snapshotRoot, workspaceIdentity) {
254
+ try {
255
+ const validation = await validatePublishedCatalogSnapshot(snapshotRoot);
256
+ const markerPath = path.join(snapshotRoot, GENERATED_OUTPUT_MARKER_FILENAME);
257
+ const markerStats = await fs.lstat(markerPath).catch((error) => {
258
+ if (error.code === 'ENOENT')
259
+ return null;
260
+ throw error;
261
+ });
262
+ if (!markerStats?.isFile() || markerStats.isSymbolicLink()) {
263
+ throw new Error('Published Catalog snapshot marker must be a regular local file.');
264
+ }
265
+ const marker = await fs.readJson(markerPath);
266
+ if (marker.workspaceIdentity !== workspaceIdentity) {
267
+ throw new Error('Published Catalog snapshot belongs to a different Workspace identity.');
268
+ }
269
+ return validation;
270
+ }
271
+ catch (error) {
272
+ throw inspectionError('remoteSnapshotInvalid', error);
273
+ }
274
+ }
275
+ async function materializePublishedCatalogMetadata(options) {
276
+ await fs.remove(options.outputRoot);
277
+ await fs.ensureDir(options.outputRoot);
278
+ for (const relative of [GENERATED_OUTPUT_MARKER_FILENAME, CATALOG_MANIFEST_FILENAME]) {
279
+ const record = await publicationGit(options.repositoryRoot, [
280
+ 'ls-tree', options.commit, '--', relative,
281
+ ], options.env, 'remoteBranchInvalid', 'Could not inspect published Catalog history.');
282
+ const match = /^(100644|100755) blob ([0-9a-f]+)\t(.+)$/u.exec(record);
283
+ if (!match || match[3] !== relative) {
284
+ throw new CatalogPublicationInspectionError('remoteSnapshotInvalid', 'Published Catalog history metadata must contain regular files.');
285
+ }
286
+ const content = await publicationGit(options.repositoryRoot, [
287
+ 'cat-file', 'blob', match[2],
288
+ ], options.env, 'remoteBranchInvalid', 'Could not read published Catalog history.');
289
+ await fs.writeFile(path.join(options.outputRoot, relative), `${content}\n`);
290
+ }
291
+ }
292
+ async function findPreviousPluginEntriesInFirstParentHistory(options) {
293
+ const missing = new Set(options.pluginNames);
294
+ const found = new Map();
295
+ const historyRoot = path.join(options.temporaryRoot, 'history-metadata');
296
+ let commit = options.tipCommit;
297
+ while (missing.size > 0) {
298
+ const parents = (await publicationGit(options.repositoryRoot, [
299
+ 'show', '-s', '--format=%P', commit,
300
+ ], options.env, 'remoteBranchInvalid', 'Could not inspect published Catalog history.'))
301
+ .split(/\s+/u)
302
+ .filter(Boolean);
303
+ const firstParent = parents[0];
304
+ if (!firstParent)
305
+ break;
306
+ commit = firstParent;
307
+ await materializePublishedCatalogMetadata({
308
+ repositoryRoot: options.repositoryRoot,
309
+ commit,
310
+ outputRoot: historyRoot,
311
+ env: options.env,
312
+ });
313
+ let metadata;
314
+ try {
315
+ metadata = await validatePublishedCatalogSnapshotMetadata(historyRoot);
316
+ if (metadata.workspaceIdentity !== options.workspaceIdentity) {
317
+ throw new Error('Published Catalog snapshot belongs to a different Workspace identity.');
318
+ }
319
+ }
320
+ catch (error) {
321
+ throw inspectionError('remoteSnapshotInvalid', error);
322
+ }
323
+ for (const entry of metadata.manifest.entries) {
324
+ if (!missing.delete(entry.name))
325
+ continue;
326
+ found.set(entry.name, entry);
327
+ }
328
+ }
329
+ return options.pluginNames.flatMap((name) => {
330
+ const entry = found.get(name);
331
+ return entry ? [entry] : [];
332
+ });
333
+ }
334
+ export async function prepareCatalogPublicationInspection(options) {
335
+ if (options.remote !== undefined && options.remoteUrl !== undefined) {
336
+ throw new CatalogPublicationInspectionError('remoteInvalid', 'Catalog publication accepts a configured remote name or a direct remote URL, not both.');
337
+ }
338
+ const remote = options.remoteUrl === undefined
339
+ ? assertSafeRemoteName(options.remote ?? 'origin')
340
+ : 'direct';
341
+ const branch = assertSafeBranchValue(options.branch ?? 'catalog');
342
+ const env = options.remoteUrl === undefined
343
+ ? sanitizedGitEnvironment(options.env)
344
+ : directRemoteGitEnvironment(options.env);
345
+ let temporaryRoot = '';
346
+ let fetchUrl = '';
347
+ let pushUrl = '';
348
+ let safeFetchUrl = '';
349
+ let safePushUrl = '';
350
+ try {
351
+ const catalogWorkspaceRoot = await fs.realpath(path.resolve(options.workspaceRoot));
352
+ const repoRoot = await publicationGit(catalogWorkspaceRoot, ['rev-parse', '--show-toplevel'], env, 'gitWorkspaceInvalid', 'Catalog Workspace must be inside a real Git worktree.');
353
+ await publicationGit(repoRoot, ['check-ref-format', '--branch', branch], env, 'branchInvalid', 'Invalid Catalog publication branch name.');
354
+ if (options.remoteUrl !== undefined) {
355
+ fetchUrl = assertSafeRemoteUrl(options.remoteUrl);
356
+ pushUrl = fetchUrl;
357
+ }
358
+ else {
359
+ const configuredRemotes = (await publicationGit(repoRoot, ['remote'], env, 'remoteMissing', 'Could not inspect configured Git remotes.')).split('\n').filter(Boolean);
360
+ if (!configuredRemotes.includes(remote)) {
361
+ throw new CatalogPublicationInspectionError('remoteInvalid', `Git remote ${JSON.stringify(remote)} is not configured.`);
362
+ }
363
+ fetchUrl = assertSafeRemoteUrl(await publicationGit(repoRoot, ['remote', 'get-url', remote], env, 'remoteMissing', `Git remote ${JSON.stringify(remote)} is not configured.`), { allowCredentials: true });
364
+ pushUrl = assertSafeRemoteUrl(await publicationGit(repoRoot, ['remote', 'get-url', '--push', remote], env, 'remoteMissing', `Git remote ${JSON.stringify(remote)} has no push URL.`), { allowCredentials: true });
365
+ }
366
+ safeFetchUrl = safeRemoteIdentity(fetchUrl);
367
+ safePushUrl = safeRemoteIdentity(pushUrl);
368
+ const sourceHead = await publicationGit(repoRoot, ['rev-parse', '--verify', 'HEAD'], env, 'sourceHeadMissing', 'Catalog Workspace Git HEAD must be committed and not unborn.');
369
+ const status = await publicationGit(repoRoot, [
370
+ 'status', '--porcelain=v1', '--untracked-files=all', '--ignore-submodules=none',
371
+ ], env, 'sourceStatusFailed', 'Could not inspect the source worktree.');
372
+ if (status !== '') {
373
+ throw new CatalogPublicationInspectionError('sourceDirty', 'Catalog publish requires the complete source Git worktree to be clean.');
374
+ }
375
+ temporaryRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'aw-public-catalog-'));
376
+ const sourceRoot = path.join(temporaryRoot, 'source');
377
+ await materializeSourceHead({ repoRoot, sourceHead, outputRoot: sourceRoot, temporaryRoot, env });
378
+ const catalogWorkspaceRelative = path.relative(repoRoot, catalogWorkspaceRoot);
379
+ if (catalogWorkspaceRelative === '..'
380
+ || catalogWorkspaceRelative.startsWith(`..${path.sep}`)
381
+ || path.isAbsolute(catalogWorkspaceRelative)) {
382
+ throw new CatalogPublicationInspectionError('workspaceOutsideRepository', 'Catalog Workspace must stay inside its Git worktree root.');
383
+ }
384
+ const archivedCatalogWorkspaceRoot = path.join(sourceRoot, catalogWorkspaceRelative);
385
+ let catalogWorkspace;
386
+ try {
387
+ catalogWorkspace = await readCatalogWorkspace(archivedCatalogWorkspaceRoot, { reservedImports: CLI_RESERVED_IMPORTS });
388
+ }
389
+ catch (error) {
390
+ throw inspectionError('workspaceInvalid', error);
391
+ }
392
+ const ownerUrl = catalogWorkspace.metadata.owner.url;
393
+ if (URL.canParse(ownerUrl) && new URL(ownerUrl).hostname === 'example.invalid') {
394
+ throw new CatalogPublicationInspectionError('catalogMetadataIncomplete', 'Catalog owner URL still uses the example.invalid placeholder. Set plugins/marketplace-source.json owner.url before publication.');
395
+ }
396
+ await validateCatalogPublicationPlugins(catalogWorkspace, env);
397
+ const catalogVersion = catalogWorkspace.metadata.catalog.version;
398
+ const tag = `catalog-v${catalogVersion}`;
399
+ await publicationGit(repoRoot, ['check-ref-format', `refs/tags/${tag}`], env, 'tagInvalid', 'Invalid Catalog publication tag.');
400
+ const remoteIdentityDigest = digest(JSON.stringify({ fetchUrl, pushUrl }));
401
+ const branchRef = `refs/heads/${branch}`;
402
+ const tagRef = `refs/tags/${tag}`;
403
+ const repositoryRoot = path.join(temporaryRoot, 'repository');
404
+ await fs.ensureDir(repositoryRoot);
405
+ await publicationGit(repositoryRoot, ['init', '--quiet'], env, 'temporaryRepositoryFailed', 'Could not create the isolated publication repository.');
406
+ await publicationGit(repositoryRoot, ['config', 'core.hooksPath', os.devNull], env, 'temporaryRepositoryFailed', 'Could not disable publication hooks.');
407
+ await publicationGit(repositoryRoot, ['config', 'core.symlinks', 'true'], env, 'temporaryRepositoryFailed', 'Could not configure the isolated publication repository.');
408
+ await publicationGit(repositoryRoot, ['remote', 'add', 'publish', pushUrl], env, 'temporaryRepositoryFailed', 'Could not configure the publication remote.');
409
+ const initialRefs = parseRemoteRefs(await publicationGit(repositoryRoot, [
410
+ 'ls-remote', 'publish', branchRef, tagRef, `${tagRef}^{}`,
411
+ ], env, 'remoteReadFailed', 'Could not inspect the Catalog publication remote.'));
412
+ const tagAvailable = !initialRefs.has(tagRef) && !initialRefs.has(`${tagRef}^{}`);
413
+ const parent = initialRefs.get(branchRef) ?? null;
414
+ let previousSnapshotRoot;
415
+ let historicalPluginEntries = [];
416
+ if (parent) {
417
+ await publicationGit(repositoryRoot, [
418
+ 'fetch', '--quiet', '--no-tags', 'publish', `${branchRef}:refs/aw/catalog-parent`,
419
+ ], env, 'remoteBranchInvalid', 'Could not fetch the published Catalog branch.');
420
+ previousSnapshotRoot = path.join(temporaryRoot, 'previous');
421
+ await fs.ensureDir(previousSnapshotRoot);
422
+ await publicationGit(repositoryRoot, [
423
+ '--work-tree', previousSnapshotRoot, 'checkout', '--quiet', 'refs/aw/catalog-parent', '--', '.',
424
+ ], env, 'remoteBranchInvalid', 'Could not read the published Catalog snapshot.');
425
+ const previous = await validatePublishedCatalogSnapshotForWorkspace(previousSnapshotRoot, catalogWorkspace.workspaceIdentity);
426
+ const previousPluginNames = new Set(previous.manifest.entries.map((entry) => entry.name));
427
+ const missingPluginNames = catalogWorkspace.plugins
428
+ .map((plugin) => plugin.manifest.name)
429
+ .filter((name) => !previousPluginNames.has(name));
430
+ if (missingPluginNames.length > 0) {
431
+ historicalPluginEntries = await findPreviousPluginEntriesInFirstParentHistory({
432
+ repositoryRoot,
433
+ tipCommit: parent,
434
+ pluginNames: missingPluginNames,
435
+ workspaceIdentity: catalogWorkspace.workspaceIdentity,
436
+ temporaryRoot,
437
+ env,
438
+ });
439
+ }
440
+ }
441
+ let prepared;
442
+ try {
443
+ prepared = await preparePublishedCatalogWorkspace({
444
+ workspaceRoot: archivedCatalogWorkspaceRoot,
445
+ sourceHead,
446
+ previousSnapshotRoot,
447
+ historicalPluginEntries,
448
+ adapter: publicationBuildAdapter,
449
+ reservedImports: CLI_RESERVED_IMPORTS,
450
+ });
451
+ }
452
+ catch (error) {
453
+ throw inspectionError('catalogPreparationFailed', error);
454
+ }
455
+ const preparedHead = await publicationGit(repoRoot, ['rev-parse', '--verify', 'HEAD'], env, 'sourceDrift', 'Could not recheck the source Git HEAD.');
456
+ const preparedStatus = await publicationGit(repoRoot, [
457
+ 'status', '--porcelain=v1', '--untracked-files=all', '--ignore-submodules=none',
458
+ ], env, 'sourceDrift', 'Could not recheck the source worktree.');
459
+ if (preparedHead !== sourceHead || preparedStatus !== '') {
460
+ throw new CatalogPublicationInspectionError('sourceDrift', 'Source HEAD or worktree changed during Catalog preparation. Commit or clean it before publishing.');
461
+ }
462
+ const finalRefs = parseRemoteRefs(await publicationGit(repositoryRoot, [
463
+ 'ls-remote', 'publish', branchRef, tagRef, `${tagRef}^{}`,
464
+ ], env, 'remoteDrift', 'Could not recheck the Catalog publication remote.'));
465
+ if ((finalRefs.get(branchRef) ?? null) !== parent
466
+ || finalRefs.has(tagRef) !== initialRefs.has(tagRef)
467
+ || finalRefs.has(`${tagRef}^{}`) !== initialRefs.has(`${tagRef}^{}`)) {
468
+ throw new CatalogPublicationInspectionError('remoteDrift', 'Catalog remote changed during preparation. Increase the Catalog version before publishing again.');
469
+ }
470
+ await validatePublishedCatalogSnapshot(prepared.outputRoot);
471
+ const descriptor = {
472
+ schemaVersion: 1,
473
+ workspaceIdentity: catalogWorkspace.workspaceIdentity,
474
+ sourceHead,
475
+ remote: {
476
+ name: options.remoteUrl === undefined ? remote : null,
477
+ identityDigest: remoteIdentityDigest,
478
+ },
479
+ branch,
480
+ parent,
481
+ tag,
482
+ snapshotDigest: prepared.snapshotDigest,
483
+ };
484
+ return {
485
+ temporaryRoot,
486
+ repositoryRoot,
487
+ archivedCatalogWorkspaceRoot,
488
+ catalogWorkspaceRoot,
489
+ repoRoot,
490
+ sourceHead,
491
+ remote,
492
+ branch,
493
+ branchRef,
494
+ tag,
495
+ tagRef,
496
+ fetchUrl,
497
+ pushUrl,
498
+ safeFetchUrl,
499
+ safePushUrl,
500
+ remoteIdentityDigest,
501
+ parent,
502
+ tagAvailable,
503
+ catalogWorkspace,
504
+ prepared,
505
+ descriptor,
506
+ env,
507
+ };
508
+ }
509
+ catch (error) {
510
+ if (temporaryRoot)
511
+ await fs.remove(temporaryRoot);
512
+ let safeMessage = error instanceof Error ? error.message : String(error);
513
+ if (temporaryRoot)
514
+ safeMessage = safeMessage.replaceAll(temporaryRoot, '<temporary Catalog state>');
515
+ if (fetchUrl)
516
+ safeMessage = safeMessage.replaceAll(fetchUrl, safeFetchUrl);
517
+ if (pushUrl)
518
+ safeMessage = safeMessage.replaceAll(pushUrl, safePushUrl);
519
+ if (error instanceof CatalogPublicationInspectionError) {
520
+ throw new CatalogPublicationInspectionError(error.code, safeMessage, { cause: error.cause });
521
+ }
522
+ throw new CatalogPublicationInspectionError('catalogPreflightFailed', safeMessage, { cause: error });
523
+ }
524
+ }
525
+ export async function inspectCatalogPublicationLiveContext(options) {
526
+ if (options.remote !== undefined && options.remoteUrl !== undefined) {
527
+ throw new CatalogPublicationInspectionError('remoteInvalid', 'Catalog publication accepts a configured remote name or a direct remote URL, not both.');
528
+ }
529
+ const remote = options.remoteUrl === undefined
530
+ ? assertSafeRemoteName(options.remote ?? 'origin')
531
+ : 'direct';
532
+ const remoteName = options.remoteUrl === undefined ? remote : null;
533
+ const branch = assertSafeBranchValue(options.branch ?? 'catalog');
534
+ const env = options.remoteUrl === undefined
535
+ ? sanitizedGitEnvironment(options.env)
536
+ : directRemoteGitEnvironment(options.env);
537
+ let fetchUrl = '';
538
+ let pushUrl = '';
539
+ let safeFetchUrl = '';
540
+ let safePushUrl = '';
541
+ try {
542
+ const catalogWorkspaceRoot = await fs.realpath(path.resolve(options.workspaceRoot));
543
+ const repoRoot = await publicationGit(catalogWorkspaceRoot, ['rev-parse', '--show-toplevel'], env, 'gitWorkspaceInvalid', 'Catalog Workspace must be inside a real Git worktree.');
544
+ await publicationGit(repoRoot, ['check-ref-format', '--branch', branch], env, 'branchInvalid', 'Invalid Catalog publication branch name.');
545
+ const sourceHead = await publicationGit(repoRoot, ['rev-parse', '--verify', 'HEAD'], env, 'sourceHeadMissing', 'Catalog Workspace Git HEAD must be committed and not unborn.');
546
+ const status = await publicationGit(repoRoot, [
547
+ 'status', '--porcelain=v1', '--untracked-files=all', '--ignore-submodules=none',
548
+ ], env, 'sourceStatusFailed', 'Could not inspect the source worktree.');
549
+ if (status !== '') {
550
+ throw new CatalogPublicationInspectionError('sourceDirty', 'Catalog publish requires the complete source Git worktree to be clean.');
551
+ }
552
+ const catalogWorkspaceRelative = path.relative(repoRoot, catalogWorkspaceRoot);
553
+ if (catalogWorkspaceRelative === '..'
554
+ || catalogWorkspaceRelative.startsWith(`..${path.sep}`)
555
+ || path.isAbsolute(catalogWorkspaceRelative)) {
556
+ throw new CatalogPublicationInspectionError('workspaceOutsideRepository', 'Catalog Workspace must stay inside its Git worktree root.');
557
+ }
558
+ const catalogWorkspace = await readCatalogWorkspace(catalogWorkspaceRoot, {
559
+ reservedImports: CLI_RESERVED_IMPORTS,
560
+ });
561
+ const ownerUrl = catalogWorkspace.metadata.owner.url;
562
+ if (URL.canParse(ownerUrl) && new URL(ownerUrl).hostname === 'example.invalid') {
563
+ throw new CatalogPublicationInspectionError('catalogMetadataIncomplete', 'Catalog owner URL still uses the example.invalid placeholder. Set plugins/marketplace-source.json owner.url before publication.');
564
+ }
565
+ if (options.remoteUrl !== undefined) {
566
+ fetchUrl = assertSafeRemoteUrl(options.remoteUrl);
567
+ pushUrl = fetchUrl;
568
+ }
569
+ else {
570
+ const configuredRemotes = (await publicationGit(repoRoot, ['remote'], env, 'remoteMissing', 'Could not inspect configured Git remotes.')).split('\n').filter(Boolean);
571
+ if (!configuredRemotes.includes(remote)) {
572
+ throw new CatalogPublicationInspectionError('remoteInvalid', `Git remote ${JSON.stringify(remote)} is not configured.`);
573
+ }
574
+ fetchUrl = assertSafeRemoteUrl(await publicationGit(repoRoot, ['remote', 'get-url', remote], env, 'remoteMissing', `Git remote ${JSON.stringify(remote)} is not configured.`), { allowCredentials: true });
575
+ pushUrl = assertSafeRemoteUrl(await publicationGit(repoRoot, ['remote', 'get-url', '--push', remote], env, 'remoteMissing', `Git remote ${JSON.stringify(remote)} has no push URL.`), { allowCredentials: true });
576
+ }
577
+ safeFetchUrl = safeRemoteIdentity(fetchUrl);
578
+ safePushUrl = safeRemoteIdentity(pushUrl);
579
+ const catalogVersion = catalogWorkspace.metadata.catalog.version;
580
+ const tag = `catalog-v${catalogVersion}`;
581
+ await publicationGit(repoRoot, ['check-ref-format', `refs/tags/${tag}`], env, 'tagInvalid', 'Invalid Catalog publication tag.');
582
+ return {
583
+ catalogWorkspaceRoot,
584
+ repoRoot,
585
+ workspaceIdentity: catalogWorkspace.workspaceIdentity,
586
+ catalogVersion,
587
+ sourceHead,
588
+ remote,
589
+ remoteName,
590
+ branch,
591
+ branchRef: `refs/heads/${branch}`,
592
+ tag,
593
+ tagRef: `refs/tags/${tag}`,
594
+ fetchUrl,
595
+ pushUrl,
596
+ safeFetchUrl,
597
+ safePushUrl,
598
+ remoteIdentityDigest: digest(JSON.stringify({ fetchUrl, pushUrl })),
599
+ env,
600
+ };
601
+ }
602
+ catch (error) {
603
+ let safeMessage = error instanceof Error ? error.message : String(error);
604
+ if (fetchUrl)
605
+ safeMessage = safeMessage.replaceAll(fetchUrl, safeFetchUrl);
606
+ if (pushUrl)
607
+ safeMessage = safeMessage.replaceAll(pushUrl, safePushUrl);
608
+ if (error instanceof CatalogPublicationInspectionError) {
609
+ throw new CatalogPublicationInspectionError(error.code, safeMessage, { cause: error.cause });
610
+ }
611
+ throw new CatalogPublicationInspectionError('catalogInspectionFailed', safeMessage, { cause: error });
612
+ }
613
+ }
614
+ export async function inspectCatalogPublicationApplyContext(options) {
615
+ if (options.remote !== undefined && options.remoteUrl !== undefined) {
616
+ throw new CatalogPublicationInspectionError('remoteInvalid', 'Catalog publication accepts a configured remote name or a direct remote URL, not both.');
617
+ }
618
+ const remote = options.remoteUrl === undefined
619
+ ? assertSafeRemoteName(options.remote ?? 'origin')
620
+ : 'direct';
621
+ const branch = assertSafeBranchValue(options.branch ?? 'catalog');
622
+ const env = options.remoteUrl === undefined
623
+ ? sanitizedGitEnvironment(options.env)
624
+ : directRemoteGitEnvironment(options.env);
625
+ let fetchUrl = '';
626
+ let pushUrl = '';
627
+ let safeFetchUrl = '';
628
+ let safePushUrl = '';
629
+ try {
630
+ const catalogWorkspaceRoot = await fs.realpath(path.resolve(options.workspaceRoot));
631
+ const marker = await readCatalogWorkspaceMarker(catalogWorkspaceRoot);
632
+ const repoRoot = await publicationGit(catalogWorkspaceRoot, ['rev-parse', '--show-toplevel'], env, 'gitWorkspaceInvalid', 'Catalog Workspace must be inside a real Git worktree.');
633
+ const catalogWorkspaceRelative = path.relative(repoRoot, catalogWorkspaceRoot);
634
+ if (catalogWorkspaceRelative === '..'
635
+ || catalogWorkspaceRelative.startsWith(`..${path.sep}`)
636
+ || path.isAbsolute(catalogWorkspaceRelative)) {
637
+ throw new CatalogPublicationInspectionError('workspaceOutsideRepository', 'Catalog Workspace must stay inside its Git worktree root.');
638
+ }
639
+ await publicationGit(repoRoot, ['check-ref-format', '--branch', branch], env, 'branchInvalid', 'Invalid Catalog publication branch name.');
640
+ if (options.remoteUrl !== undefined) {
641
+ fetchUrl = assertSafeRemoteUrl(options.remoteUrl);
642
+ pushUrl = fetchUrl;
643
+ }
644
+ else {
645
+ const configuredRemotes = (await publicationGit(repoRoot, ['remote'], env, 'remoteMissing', 'Could not inspect configured Git remotes.')).split('\n').filter(Boolean);
646
+ if (!configuredRemotes.includes(remote)) {
647
+ throw new CatalogPublicationInspectionError('remoteInvalid', `Git remote ${JSON.stringify(remote)} is not configured.`);
648
+ }
649
+ fetchUrl = assertSafeRemoteUrl(await publicationGit(repoRoot, ['remote', 'get-url', remote], env, 'remoteMissing', `Git remote ${JSON.stringify(remote)} is not configured.`), { allowCredentials: true });
650
+ pushUrl = assertSafeRemoteUrl(await publicationGit(repoRoot, ['remote', 'get-url', '--push', remote], env, 'remoteMissing', `Git remote ${JSON.stringify(remote)} has no push URL.`), { allowCredentials: true });
651
+ }
652
+ safeFetchUrl = safeRemoteIdentity(fetchUrl);
653
+ safePushUrl = safeRemoteIdentity(pushUrl);
654
+ return {
655
+ catalogWorkspaceRoot,
656
+ repoRoot,
657
+ workspaceIdentity: marker.workspaceIdentity,
658
+ remote,
659
+ branch,
660
+ branchRef: `refs/heads/${branch}`,
661
+ fetchUrl,
662
+ pushUrl,
663
+ safeFetchUrl,
664
+ safePushUrl,
665
+ remoteIdentityDigest: digest(JSON.stringify({ fetchUrl, pushUrl })),
666
+ env,
667
+ };
668
+ }
669
+ catch (error) {
670
+ let safeMessage = error instanceof Error ? error.message : String(error);
671
+ if (fetchUrl)
672
+ safeMessage = safeMessage.replaceAll(fetchUrl, safeFetchUrl);
673
+ if (pushUrl)
674
+ safeMessage = safeMessage.replaceAll(pushUrl, safePushUrl);
675
+ if (error instanceof CatalogPublicationInspectionError) {
676
+ throw new CatalogPublicationInspectionError(error.code, safeMessage, { cause: error.cause });
677
+ }
678
+ throw new CatalogPublicationInspectionError('catalogInspectionFailed', safeMessage, { cause: error });
679
+ }
680
+ }
681
+ async function resolveRemoteUrlForInspection(options) {
682
+ if (options.remote !== undefined && options.remoteUrl !== undefined) {
683
+ throw new CatalogPublicationInspectionError('remoteInvalid', 'Catalog publication accepts a configured remote name or a direct remote URL, not both.');
684
+ }
685
+ const env = options.remoteUrl === undefined
686
+ ? sanitizedGitEnvironment(options.env)
687
+ : directRemoteGitEnvironment(options.env);
688
+ if (options.remoteUrl !== undefined) {
689
+ return { remoteUrl: assertSafeRemoteUrl(options.remoteUrl), env };
690
+ }
691
+ const remote = assertSafeRemoteName(options.remote ?? 'origin');
692
+ return {
693
+ remoteUrl: assertSafeRemoteUrl(await publicationGit(options.workspaceRoot, ['remote', 'get-url', '--push', remote], env, 'remoteMissing', `Git remote ${JSON.stringify(remote)} has no push URL.`), { allowCredentials: true }),
694
+ env,
695
+ };
696
+ }
697
+ export async function listCatalogPublicationVersions(options) {
698
+ const resolved = await resolveRemoteUrlForInspection(options);
699
+ const sensitiveValues = remoteSensitiveValues(resolved.remoteUrl);
700
+ const temporaryRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'aw-catalog-remote-read-'));
701
+ try {
702
+ await publicationGit(temporaryRoot, ['init', '--quiet'], resolved.env, 'temporaryRepositoryFailed', 'Could not create the Catalog inspection repository.');
703
+ await publicationGit(temporaryRoot, ['remote', 'add', 'publish', resolved.remoteUrl], resolved.env, 'temporaryRepositoryFailed', 'Could not configure the Catalog inspection remote.');
704
+ const refs = parseRemoteRefs(await publicationGit(temporaryRoot, [
705
+ 'ls-remote', '--refs', 'publish', 'refs/tags/catalog-v*',
706
+ ], resolved.env, 'remoteReadFailed', 'Could not inspect Catalog publication versions.', sensitiveValues));
707
+ return [...refs.keys()]
708
+ .filter((ref) => ref.startsWith('refs/tags/catalog-v'))
709
+ .map((ref) => ref.slice('refs/tags/catalog-v'.length));
710
+ }
711
+ finally {
712
+ await fs.remove(temporaryRoot);
713
+ }
714
+ }
715
+ export async function readCatalogPublicationBranchState(options) {
716
+ assertSafeBranchValue(options.branch);
717
+ const marker = await readCatalogWorkspaceMarker(options.workspaceRoot);
718
+ const resolved = await resolveRemoteUrlForInspection(options);
719
+ const temporaryRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'aw-catalog-remote-read-'));
720
+ try {
721
+ await publicationGit(options.workspaceRoot, [
722
+ 'check-ref-format', '--branch', options.branch,
723
+ ], resolved.env, 'branchInvalid', 'Invalid Catalog publication branch name.');
724
+ const branchRef = `refs/heads/${options.branch}`;
725
+ await publicationGit(temporaryRoot, ['init', '--quiet'], resolved.env, 'temporaryRepositoryFailed', 'Could not create the Catalog inspection repository.');
726
+ await publicationGit(temporaryRoot, ['config', 'core.symlinks', 'true'], resolved.env, 'temporaryRepositoryFailed', 'Could not configure the Catalog inspection repository.');
727
+ await publicationGit(temporaryRoot, ['remote', 'add', 'publish', resolved.remoteUrl], resolved.env, 'temporaryRepositoryFailed', 'Could not configure the Catalog inspection remote.');
728
+ const refs = parseRemoteRefs(await publicationGit(temporaryRoot, [
729
+ 'ls-remote', 'publish', branchRef,
730
+ ], resolved.env, 'remoteReadFailed', 'Could not inspect the Catalog publication branch.'));
731
+ const commit = refs.get(branchRef);
732
+ if (!commit)
733
+ return null;
734
+ await publicationGit(temporaryRoot, [
735
+ 'fetch', '--quiet', '--no-tags', 'publish', `${branchRef}:refs/aw/catalog-parent`,
736
+ ], resolved.env, 'remoteBranchInvalid', 'Could not fetch the published Catalog branch.');
737
+ const snapshotRoot = path.join(temporaryRoot, 'snapshot');
738
+ await fs.ensureDir(snapshotRoot);
739
+ await publicationGit(temporaryRoot, [
740
+ '--work-tree', snapshotRoot, 'checkout', '--quiet', 'refs/aw/catalog-parent', '--', '.',
741
+ ], resolved.env, 'remoteBranchInvalid', 'Could not read the published Catalog snapshot.');
742
+ const validation = await validatePublishedCatalogSnapshotForWorkspace(snapshotRoot, marker.workspaceIdentity);
743
+ return {
744
+ commit,
745
+ version: validation.manifest.catalogVersion,
746
+ manifest: validation.manifest,
747
+ snapshotDigest: validation.snapshotDigest,
748
+ };
749
+ }
750
+ finally {
751
+ await fs.remove(temporaryRoot);
752
+ }
753
+ }
754
+ export async function disposeCatalogPublicationInspection(preparation) {
755
+ await fs.remove(preparation.temporaryRoot);
756
+ }
757
+ //# sourceMappingURL=catalog-publication-inspection.js.map