blume 2.0.2 → 2.1.0

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 (601) hide show
  1. package/AGENTS.md +1 -0
  2. package/CHANGELOG.md +113 -0
  3. package/README.md +1 -1
  4. package/dist/cli/{chunk-6k4ftwze.js → chunk-0gz36akr.js} +18 -2
  5. package/dist/cli/{chunk-6k4ftwze.js.map → chunk-0gz36akr.js.map} +3 -3
  6. package/dist/cli/{chunk-zp79m0ts.js → chunk-1n228xqb.js} +2 -2
  7. package/dist/cli/{chunk-ddndchfr.js → chunk-2f3ndkpw.js} +57 -29
  8. package/dist/cli/chunk-2f3ndkpw.js.map +14 -0
  9. package/dist/cli/{chunk-fsmrqk8a.js → chunk-2f7n4qzt.js} +8 -2
  10. package/dist/cli/{chunk-fsmrqk8a.js.map → chunk-2f7n4qzt.js.map} +3 -3
  11. package/dist/cli/{chunk-ppzjqwx2.js → chunk-2n4ps1b3.js} +17 -18
  12. package/dist/cli/{chunk-ppzjqwx2.js.map → chunk-2n4ps1b3.js.map} +3 -3
  13. package/dist/cli/{chunk-5r8g91qn.js → chunk-43zcf4gz.js} +398 -159
  14. package/dist/cli/chunk-43zcf4gz.js.map +36 -0
  15. package/dist/cli/chunk-4ejxbzee.js +39 -0
  16. package/dist/cli/chunk-4ejxbzee.js.map +10 -0
  17. package/dist/cli/{chunk-hr8ne106.js → chunk-4h8z9vv5.js} +296 -77
  18. package/dist/cli/chunk-4h8z9vv5.js.map +16 -0
  19. package/dist/cli/{chunk-k7pj68a8.js → chunk-5cg2rzgf.js} +18 -16
  20. package/dist/cli/{chunk-k7pj68a8.js.map → chunk-5cg2rzgf.js.map} +2 -2
  21. package/dist/cli/{chunk-h2ez8dzb.js → chunk-5ffywsmb.js} +4 -4
  22. package/dist/cli/{chunk-g698a744.js → chunk-5wj2qwn2.js} +5 -5
  23. package/dist/cli/chunk-6bm0xpgd.js +18 -0
  24. package/dist/cli/chunk-6bm0xpgd.js.map +10 -0
  25. package/dist/cli/{chunk-3yce002v.js → chunk-713mngdq.js} +15 -8
  26. package/dist/cli/chunk-713mngdq.js.map +14 -0
  27. package/dist/cli/{chunk-91ws1n6j.js → chunk-9geymqns.js} +17 -15
  28. package/dist/cli/{chunk-91ws1n6j.js.map → chunk-9geymqns.js.map} +2 -2
  29. package/dist/cli/{chunk-6dtt0zfn.js → chunk-9xr4dgee.js} +27 -18
  30. package/dist/cli/chunk-9xr4dgee.js.map +10 -0
  31. package/dist/cli/{chunk-sqw4ekg1.js → chunk-amrb6hgh.js} +2 -2
  32. package/dist/cli/chunk-cm89scdv.js +443 -0
  33. package/dist/cli/chunk-cm89scdv.js.map +11 -0
  34. package/dist/cli/{chunk-wdrt2k2v.js → chunk-cmtcnh9f.js} +90 -26
  35. package/dist/cli/chunk-cmtcnh9f.js.map +10 -0
  36. package/dist/cli/chunk-cy5bm0j0.js +104 -0
  37. package/dist/cli/chunk-cy5bm0j0.js.map +11 -0
  38. package/dist/cli/{chunk-7mbqtmgb.js → chunk-e7vvk5ya.js} +21 -12
  39. package/dist/cli/chunk-e7vvk5ya.js.map +10 -0
  40. package/dist/cli/{chunk-qkb5a8sa.js → chunk-g2z9x01v.js} +6 -98
  41. package/dist/cli/chunk-g2z9x01v.js.map +10 -0
  42. package/dist/cli/{chunk-273ygyr4.js → chunk-ga0pf4aj.js} +7 -7
  43. package/dist/cli/{chunk-273ygyr4.js.map → chunk-ga0pf4aj.js.map} +3 -3
  44. package/dist/cli/{chunk-h7k3nq3v.js → chunk-gp84za0h.js} +2 -2
  45. package/dist/cli/{chunk-hqp2ajnh.js → chunk-h2a48yhd.js} +195 -73
  46. package/dist/cli/chunk-h2a48yhd.js.map +36 -0
  47. package/dist/cli/{chunk-pbg5a4s3.js → chunk-jnwj5kjj.js} +71 -47
  48. package/dist/cli/chunk-jnwj5kjj.js.map +19 -0
  49. package/dist/cli/chunk-kwrg63tm.js +31 -0
  50. package/dist/cli/chunk-kwrg63tm.js.map +10 -0
  51. package/dist/cli/{chunk-8g8ytmgx.js → chunk-nd1821sk.js} +21 -19
  52. package/dist/cli/{chunk-8g8ytmgx.js.map → chunk-nd1821sk.js.map} +2 -2
  53. package/dist/cli/{chunk-w4bxdvsa.js → chunk-ntv4qrt7.js} +17 -15
  54. package/dist/cli/{chunk-w4bxdvsa.js.map → chunk-ntv4qrt7.js.map} +2 -2
  55. package/dist/cli/{chunk-bfwp9vp6.js → chunk-p804f3pe.js} +7 -7
  56. package/dist/cli/{chunk-4e9b9ra6.js → chunk-py62fewh.js} +6 -6
  57. package/dist/cli/{chunk-4e9b9ra6.js.map → chunk-py62fewh.js.map} +1 -1
  58. package/dist/cli/chunk-q3wxxq39.js +126 -0
  59. package/dist/cli/chunk-q3wxxq39.js.map +11 -0
  60. package/dist/cli/{chunk-j85scx15.js → chunk-rekqz4qg.js} +142 -46
  61. package/dist/cli/chunk-rekqz4qg.js.map +10 -0
  62. package/dist/cli/{chunk-00gs3wqs.js → chunk-ta27feev.js} +1 -1
  63. package/dist/cli/{chunk-v6ya5kcb.js → chunk-xkz5xbtv.js} +4031 -1132
  64. package/dist/cli/chunk-xkz5xbtv.js.map +213 -0
  65. package/dist/cli/{chunk-bbnwccaz.js → chunk-y4ykbark.js} +2 -2
  66. package/dist/cli/{chunk-n1yg3tj3.js → chunk-y5h4r2y0.js} +6 -6
  67. package/dist/cli/{chunk-n1yg3tj3.js.map → chunk-y5h4r2y0.js.map} +3 -3
  68. package/dist/cli/{chunk-nfcyttvj.js → chunk-yj17vs39.js} +9 -9
  69. package/dist/cli/{chunk-nfcyttvj.js.map → chunk-yj17vs39.js.map} +1 -1
  70. package/dist/cli/{chunk-7vtckvaw.js → chunk-yxmk4pec.js} +16 -14
  71. package/dist/cli/{chunk-7vtckvaw.js.map → chunk-yxmk4pec.js.map} +2 -2
  72. package/dist/cli/{chunk-gs7r695n.js → chunk-zccbjcj0.js} +22 -8
  73. package/dist/cli/{chunk-gs7r695n.js.map → chunk-zccbjcj0.js.map} +3 -3
  74. package/dist/cli/{chunk-xh43dwgw.js → chunk-zf748avv.js} +415 -225
  75. package/dist/cli/chunk-zf748avv.js.map +37 -0
  76. package/dist/cli/{chunk-d1v5rhy0.js → chunk-zhvd6adm.js} +16 -14
  77. package/dist/cli/{chunk-d1v5rhy0.js.map → chunk-zhvd6adm.js.map} +2 -2
  78. package/dist/cli/index.js +28 -20
  79. package/dist/cli/index.js.map +5 -5
  80. package/dist/types/ai/agent-surface.d.ts +8 -7
  81. package/dist/types/ai/ai-catalog.d.ts +7 -0
  82. package/dist/types/ai/ask-context.d.ts +22 -0
  83. package/dist/types/ai/ask.d.ts +271 -58
  84. package/dist/types/ai/index.d.ts +2 -2
  85. package/dist/types/ai/link-headers.d.ts +8 -1
  86. package/dist/types/ai/openapi-components.d.ts +5 -2
  87. package/dist/types/ai/relative-links.d.ts +9 -7
  88. package/dist/types/ai/site-skill.d.ts +26 -0
  89. package/dist/types/ai/skills.d.ts +20 -1
  90. package/dist/types/ai/tar.d.ts +1 -3
  91. package/dist/types/analytics/index.d.ts +2 -0
  92. package/dist/types/analytics/one-dollar-stats.d.ts +48 -0
  93. package/dist/types/analytics/schema.d.ts +14 -0
  94. package/dist/types/astro/integration.d.ts +11 -2
  95. package/dist/types/captcha/hcaptcha.d.ts +27 -0
  96. package/dist/types/captcha/index.d.ts +28 -0
  97. package/dist/types/captcha/schema.d.ts +29 -0
  98. package/dist/types/captcha/turnstile.d.ts +28 -0
  99. package/dist/types/components/content/api-field.d.ts +59 -0
  100. package/dist/types/components/content/api-page.d.ts +95 -0
  101. package/dist/types/components/layout/nav-utils.d.ts +26 -0
  102. package/dist/types/components/openapi/helpers.d.ts +137 -0
  103. package/dist/types/components/openapi/security.d.ts +85 -0
  104. package/dist/types/consent/ethyca.d.ts +48 -0
  105. package/dist/types/consent/index.d.ts +37 -0
  106. package/dist/types/consent/native.d.ts +28 -0
  107. package/dist/types/consent/osano.d.ts +42 -0
  108. package/dist/types/consent/schema.d.ts +110 -0
  109. package/dist/types/core/base-path.d.ts +21 -7
  110. package/dist/types/core/config-input.d.ts +196 -27
  111. package/dist/types/core/data.d.ts +49 -4
  112. package/dist/types/core/directive-diagnostics.d.ts +12 -0
  113. package/dist/types/core/footer.d.ts +8 -0
  114. package/dist/types/core/heading-markers.d.ts +5 -7
  115. package/dist/types/core/i18n-ui.d.ts +86 -0
  116. package/dist/types/core/i18n.d.ts +2 -0
  117. package/dist/types/core/includes.d.ts +8 -2
  118. package/dist/types/core/last-modified.d.ts +10 -0
  119. package/dist/types/core/localizable.d.ts +7 -0
  120. package/dist/types/core/meta.d.ts +8 -0
  121. package/dist/types/core/page-modes.d.ts +29 -0
  122. package/dist/types/core/redirect-patterns.d.ts +144 -0
  123. package/dist/types/core/related.d.ts +40 -0
  124. package/dist/types/core/schema.d.ts +558 -56
  125. package/dist/types/core/sources/lower.d.ts +29 -16
  126. package/dist/types/core/sources/normalize.d.ts +13 -1
  127. package/dist/types/core/sources/read.d.ts +5 -0
  128. package/dist/types/core/sources/watch.d.ts +12 -5
  129. package/dist/types/core/standard-schema.d.ts +5 -0
  130. package/dist/types/core/types.d.ts +1 -1
  131. package/dist/types/core/variables.d.ts +42 -0
  132. package/dist/types/deploy/artifacts.d.ts +6 -4
  133. package/dist/types/deploy/headers.d.ts +5 -0
  134. package/dist/types/deploy/node-headers.d.ts +13 -2
  135. package/dist/types/deploy/platforms/cloudflare.d.ts +5 -0
  136. package/dist/types/deploy/platforms/netlify.d.ts +7 -0
  137. package/dist/types/deploy/platforms/types.d.ts +8 -0
  138. package/dist/types/deploy/platforms/vercel.d.ts +6 -0
  139. package/dist/types/deploy/redirects.d.ts +61 -22
  140. package/dist/types/deploy/vercel-negotiation.d.ts +9 -0
  141. package/dist/types/markdown/code-title.d.ts +17 -0
  142. package/dist/types/markdown/directives.d.ts +62 -0
  143. package/dist/types/markdown/features.d.ts +24 -2
  144. package/dist/types/markdown/mdast.d.ts +63 -0
  145. package/dist/types/narration/build.d.ts +70 -0
  146. package/dist/types/narration/provider.d.ts +26 -0
  147. package/dist/types/narration/script.d.ts +154 -0
  148. package/dist/types/openapi/asyncapi.d.ts +4 -2
  149. package/dist/types/openapi/model.d.ts +12 -6
  150. package/dist/types/openapi/overlay.d.ts +54 -0
  151. package/dist/types/openapi/parse.d.ts +13 -0
  152. package/dist/types/openapi/references.d.ts +14 -4
  153. package/dist/types/ratelimit/cloudflare.d.ts +39 -0
  154. package/dist/types/ratelimit/index.d.ts +27 -0
  155. package/dist/types/ratelimit/memory.d.ts +36 -0
  156. package/dist/types/ratelimit/schema.d.ts +111 -0
  157. package/dist/types/ratelimit/upstash.d.ts +21 -0
  158. package/dist/types/ratelimit/wrangler.d.ts +23 -0
  159. package/dist/types/reference/asyncapi.d.ts +10 -10
  160. package/dist/types/reference/graphql.d.ts +13 -10
  161. package/dist/types/reference/openapi.d.ts +33 -12
  162. package/dist/types/reference/options.d.ts +45 -5
  163. package/dist/types/reference/scalar.d.ts +13 -0
  164. package/dist/types/reference/schema.d.ts +60 -36
  165. package/dist/types/search/documents.d.ts +12 -1
  166. package/dist/types/search/orama-index.d.ts +4 -0
  167. package/dist/types/seo/metatags.d.ts +20 -0
  168. package/docs/02-deployment.mdx +44 -6
  169. package/docs/03-upgrading.mdx +4 -4
  170. package/docs/04-migrating.mdx +1 -1
  171. package/docs/08-faq.mdx +1 -1
  172. package/docs/advanced/changelog.mdx +2 -2
  173. package/docs/advanced/custom-pages.mdx +3 -3
  174. package/docs/advanced/skills.mdx +14 -0
  175. package/docs/cli/audit.mdx +38 -2
  176. package/docs/cli/evals.mdx +3 -3
  177. package/docs/cli/index.mdx +1 -0
  178. package/docs/cli/translate.mdx +3 -3
  179. package/docs/cli/version.mdx +1 -1
  180. package/docs/configuration/analytics.mdx +22 -1
  181. package/docs/configuration/assistant.mdx +188 -36
  182. package/docs/configuration/consent.mdx +100 -0
  183. package/docs/configuration/customization.mdx +6 -4
  184. package/docs/configuration/index.mdx +63 -5
  185. package/docs/configuration/meta.ts +3 -0
  186. package/docs/configuration/narration.mdx +119 -0
  187. package/docs/configuration/rate-limiting.mdx +69 -0
  188. package/docs/configuration/search.mdx +30 -2
  189. package/docs/configuration/theming.mdx +3 -1
  190. package/docs/content/components.mdx +107 -1
  191. package/docs/content/frontmatter.mdx +77 -1
  192. package/docs/content/i18n.mdx +40 -3
  193. package/docs/content/includes.mdx +16 -0
  194. package/docs/content/index.mdx +4 -2
  195. package/docs/content/islands.mdx +1 -1
  196. package/docs/content/meta.mdx +4 -1
  197. package/docs/content/meta.ts +1 -0
  198. package/docs/content/navigation.mdx +28 -6
  199. package/docs/content/sources/contentful.mdx +32 -0
  200. package/docs/content/sources/custom.mdx +39 -0
  201. package/docs/content/sources/github-releases.mdx +31 -0
  202. package/docs/content/sources/index.mdx +91 -0
  203. package/docs/content/sources/meta.ts +16 -0
  204. package/docs/content/sources/notion.mdx +32 -0
  205. package/docs/content/sources/obsidian.mdx +37 -0
  206. package/docs/content/sources/payload.mdx +30 -0
  207. package/docs/content/sources/remote-mdx.mdx +40 -0
  208. package/docs/content/sources/sanity.mdx +29 -0
  209. package/docs/content/sources/strapi.mdx +31 -0
  210. package/docs/content/syntax.mdx +81 -2
  211. package/docs/content/variables.mdx +41 -0
  212. package/docs/content/versioning.mdx +1 -1
  213. package/docs/discoverability/agent-discovery.mdx +30 -3
  214. package/docs/discoverability/index.mdx +3 -2
  215. package/docs/discoverability/llms-txt.mdx +1 -1
  216. package/docs/discoverability/markdown.mdx +2 -2
  217. package/docs/discoverability/metadata.mdx +17 -0
  218. package/docs/discoverability/open-graph.mdx +5 -3
  219. package/docs/discoverability/rss.mdx +1 -1
  220. package/docs/references/api-pages.mdx +74 -0
  221. package/docs/references/asyncapi.mdx +2 -2
  222. package/docs/references/graphql.mdx +3 -3
  223. package/docs/references/meta.ts +1 -1
  224. package/docs/references/openapi.mdx +106 -5
  225. package/docs/references/scalar.mdx +3 -1
  226. package/package.json +36 -1
  227. package/skills/blume/SKILL.md +3 -0
  228. package/skills/blume-migrate/SKILL.md +5 -5
  229. package/skills/blume-migrate/references/docusaurus.md +3 -3
  230. package/skills/blume-migrate/references/fumadocs.md +1 -1
  231. package/skills/blume-migrate/references/mintlify.md +37 -19
  232. package/skills/blume-migrate/references/nextra.md +3 -3
  233. package/skills/blume-migrate/references/starlight.md +2 -1
  234. package/skills/blume-migrate/scripts/mintlify-codemod.mjs +67 -16
  235. package/skills/blume-write-skill/SKILL.md +82 -0
  236. package/src/ai/agent-readability.ts +4 -3
  237. package/src/ai/agent-surface.ts +9 -7
  238. package/src/ai/ai-catalog.ts +12 -5
  239. package/src/ai/api/handlers.ts +2 -2
  240. package/src/ai/api/spec.ts +2 -2
  241. package/src/ai/api-catalog.ts +6 -2
  242. package/src/ai/ask-context.ts +73 -20
  243. package/src/ai/ask-data.ts +6 -0
  244. package/src/ai/ask-tools.ts +142 -0
  245. package/src/ai/ask.ts +354 -76
  246. package/src/ai/changelog-markdown.ts +2 -2
  247. package/src/ai/component-markdown.ts +75 -0
  248. package/src/ai/cors.ts +2 -0
  249. package/src/ai/index.ts +12 -0
  250. package/src/ai/link-headers.ts +14 -5
  251. package/src/ai/llms.ts +24 -9
  252. package/src/ai/markdown.ts +2 -1
  253. package/src/ai/mcp/data.ts +6 -0
  254. package/src/ai/mcp/discovery.ts +2 -2
  255. package/src/ai/mcp/query.ts +2 -2
  256. package/src/ai/mcp/server.ts +2 -2
  257. package/src/ai/openapi-components.ts +31 -9
  258. package/src/ai/relative-links.ts +42 -26
  259. package/src/ai/serializers.ts +2 -1
  260. package/src/ai/site-skill.ts +274 -0
  261. package/src/ai/skills.ts +49 -3
  262. package/src/ai/tar.ts +139 -12
  263. package/src/ai/write-skill.ts +97 -0
  264. package/src/analytics/head.ts +4 -0
  265. package/src/analytics/index.ts +5 -0
  266. package/src/analytics/one-dollar-stats.ts +86 -0
  267. package/src/analytics/schema.ts +2 -0
  268. package/src/astro/generate.ts +133 -19
  269. package/src/astro/include-hmr.ts +31 -12
  270. package/src/astro/include-refresh.ts +19 -8
  271. package/src/astro/index.ts +1 -0
  272. package/src/astro/integration.ts +143 -14
  273. package/src/astro/module-types.ts +6 -0
  274. package/src/astro/runtime-modules.ts +28 -13
  275. package/src/astro/templates.ts +364 -67
  276. package/src/astro/variables.ts +31 -0
  277. package/src/audit/catalog.ts +19 -0
  278. package/src/audit/checks/contrast.ts +183 -0
  279. package/src/audit/checks/i18n.ts +2 -3
  280. package/src/audit/checks/indexability.ts +2 -3
  281. package/src/audit/checks/links.ts +13 -13
  282. package/src/audit/checks/sitemap.ts +2 -3
  283. package/src/audit/graph.ts +3 -1
  284. package/src/audit/redirects.ts +46 -15
  285. package/src/audit/run.ts +14 -9
  286. package/src/audit/snapshot.ts +5 -0
  287. package/src/audit/types.ts +2 -1
  288. package/src/blume-modules.d.ts +7 -0
  289. package/src/captcha/client.ts +152 -0
  290. package/src/captcha/hcaptcha.ts +36 -0
  291. package/src/captcha/index.ts +28 -0
  292. package/src/captcha/schema.ts +32 -0
  293. package/src/captcha/turnstile.ts +38 -0
  294. package/src/captcha/verify.ts +71 -0
  295. package/src/cli/args.ts +32 -0
  296. package/src/cli/command-meta.ts +5 -0
  297. package/src/cli/commands/audit.ts +4 -1
  298. package/src/cli/commands/doctor.ts +25 -17
  299. package/src/cli/commands/eval.ts +19 -11
  300. package/src/cli/commands/skill.ts +96 -0
  301. package/src/cli/commands/translate.ts +9 -12
  302. package/src/cli/commands/validate.ts +3 -1
  303. package/src/cli/dev-lock.ts +157 -37
  304. package/src/cli/index.ts +5 -0
  305. package/src/cli/report-format.ts +11 -6
  306. package/src/cli/required-secrets.ts +71 -29
  307. package/src/components/BlumePage.astro +2 -0
  308. package/src/components/colors.ts +19 -0
  309. package/src/components/content/ApiEndpoint.astro +18 -0
  310. package/src/components/content/ApiField.astro +79 -0
  311. package/src/components/content/ApiPlayground.astro +62 -0
  312. package/src/components/content/ApiRail.astro +19 -0
  313. package/src/components/content/Badge.astro +5 -3
  314. package/src/components/content/Color.astro +1 -0
  315. package/src/components/content/Component.astro +2 -2
  316. package/src/components/content/FileTree.astro +1 -0
  317. package/src/components/content/GithubInfo.astro +1 -0
  318. package/src/components/content/Panel.astro +1 -0
  319. package/src/components/content/ParamField.astro +25 -0
  320. package/src/components/content/RequestExample.astro +17 -0
  321. package/src/components/content/ResponseExample.astro +17 -0
  322. package/src/components/content/ResponseField.astro +32 -0
  323. package/src/components/content/Step.astro +1 -0
  324. package/src/components/content/Tab.astro +0 -1
  325. package/src/components/content/Tabs.astro +4 -0
  326. package/src/components/content/Tile.astro +1 -0
  327. package/src/components/content/Tooltip.astro +1 -0
  328. package/src/components/content/Tree.astro +1 -0
  329. package/src/components/content/TypeTable.astro +4 -1
  330. package/src/components/content/View.astro +21 -0
  331. package/src/components/content/ViewSwitcher.astro +168 -0
  332. package/src/components/content/api-field.ts +100 -0
  333. package/src/components/content/api-page.ts +224 -0
  334. package/src/components/content/badge-color.ts +5 -2
  335. package/src/components/content/base-href.ts +13 -36
  336. package/src/components/content/view-switcher.ts +71 -0
  337. package/src/components/index.ts +2 -0
  338. package/src/components/islands/Assistant.astro +10 -1
  339. package/src/components/islands/assistant.tsx +125 -18
  340. package/src/components/islands/base-path.ts +47 -10
  341. package/src/components/islands/code-question.ts +62 -0
  342. package/src/components/islands/hooks.ts +145 -40
  343. package/src/components/islands/support-link.ts +68 -0
  344. package/src/components/islands/webmcp.ts +4 -2
  345. package/src/components/layout/Analytics.astro +11 -2
  346. package/src/components/layout/Banner.astro +14 -10
  347. package/src/components/layout/Breadcrumbs.astro +11 -4
  348. package/src/components/layout/ConsentBanner.astro +62 -0
  349. package/src/components/layout/ConsentHead.astro +38 -0
  350. package/src/components/layout/Directory.astro +94 -0
  351. package/src/components/layout/DiscoveryLinks.astro +9 -5
  352. package/src/components/layout/DrawerSwitchers.astro +51 -0
  353. package/src/components/layout/Empty.astro +2 -2
  354. package/src/components/layout/Header.astro +124 -82
  355. package/src/components/layout/LanguageSwitcher.astro +50 -17
  356. package/src/components/layout/NarrationPlayer.astro +1085 -0
  357. package/src/components/layout/NavSelector.astro +35 -9
  358. package/src/components/layout/NavTabMenu.astro +3 -3
  359. package/src/components/layout/NavTree.astro +16 -6
  360. package/src/components/layout/PageActions.astro +4 -3
  361. package/src/components/layout/PageFeedback.astro +54 -49
  362. package/src/components/layout/PageLayout.astro +78 -9
  363. package/src/components/layout/Pagination.astro +3 -3
  364. package/src/components/layout/ReferenceLayout.astro +17 -6
  365. package/src/components/layout/RelatedPages.astro +42 -0
  366. package/src/components/layout/RootLayout.astro +313 -50
  367. package/src/components/layout/Search.astro +64 -30
  368. package/src/components/layout/SiteFooter.astro +124 -0
  369. package/src/components/layout/SiteMetatags.astro +16 -0
  370. package/src/components/layout/VersionBanner.astro +2 -2
  371. package/src/components/layout/analytics-client.ts +12 -0
  372. package/src/components/layout/consent/native.ts +79 -0
  373. package/src/components/layout/consent/types.ts +37 -0
  374. package/src/components/layout/footer-links.ts +53 -0
  375. package/src/components/layout/footer-socials.ts +87 -0
  376. package/src/components/layout/locale-redirect.ts +107 -0
  377. package/src/components/layout/nav-utils.ts +83 -0
  378. package/src/components/layout/page-feedback.ts +96 -0
  379. package/src/components/layout/search/analytics.ts +98 -0
  380. package/src/components/layout/search/flexsearch.ts +17 -5
  381. package/src/components/layout/search/orama-cloud.ts +26 -14
  382. package/src/components/layout/search/types.ts +20 -0
  383. package/src/components/layout/search/typesense.ts +5 -1
  384. package/src/components/layout/toc-active.ts +41 -0
  385. package/src/components/layout/toc-element.ts +8 -14
  386. package/src/components/openapi/ApiTagOperations.astro +2 -2
  387. package/src/components/openapi/AsyncApiOperation.astro +7 -4
  388. package/src/components/openapi/GraphqlChip.astro +2 -2
  389. package/src/components/openapi/Operation.astro +163 -13
  390. package/src/components/openapi/Playground.astro +4 -4
  391. package/src/components/openapi/RequestBody.astro +6 -4
  392. package/src/components/openapi/RequestPanel.astro +63 -8
  393. package/src/components/openapi/Responses.astro +6 -4
  394. package/src/components/openapi/SchemaTable.astro +7 -0
  395. package/src/components/openapi/async-snippets.ts +4 -4
  396. package/src/components/openapi/async.ts +38 -6
  397. package/src/components/openapi/code-samples.ts +97 -0
  398. package/src/components/openapi/helpers.ts +19 -9
  399. package/src/components/openapi/message-composer.ts +6 -1
  400. package/src/components/openapi/message.ts +17 -2
  401. package/src/components/openapi/operation-model.ts +81 -11
  402. package/src/components/openapi/panel.ts +4 -2
  403. package/src/components/openapi/param-style.ts +181 -0
  404. package/src/components/openapi/playground-client.ts +73 -16
  405. package/src/components/openapi/request.ts +190 -26
  406. package/src/components/openapi/schema-tree.ts +30 -24
  407. package/src/components/openapi/security.ts +6 -3
  408. package/src/components/openapi/snippets.ts +953 -13
  409. package/src/components/openapi/ws-client.ts +18 -2
  410. package/src/components/props.ts +6 -0
  411. package/src/consent/client.ts +95 -0
  412. package/src/consent/clients.ts +19 -0
  413. package/src/consent/ethyca.ts +71 -0
  414. package/src/consent/head.ts +24 -0
  415. package/src/consent/index.ts +37 -0
  416. package/src/consent/init.ts +29 -0
  417. package/src/consent/native.ts +36 -0
  418. package/src/consent/osano.ts +59 -0
  419. package/src/consent/schema.ts +30 -0
  420. package/src/core/base-path.ts +62 -16
  421. package/src/core/builtin-tags.ts +5 -0
  422. package/src/core/client-address.ts +19 -0
  423. package/src/core/config-input.ts +203 -27
  424. package/src/core/data.ts +44 -4
  425. package/src/core/diagnostics.ts +5 -2
  426. package/src/core/directive-diagnostics.ts +99 -0
  427. package/src/core/footer.ts +26 -0
  428. package/src/core/frontmatter.ts +21 -18
  429. package/src/core/graph.ts +39 -36
  430. package/src/core/heading-markers.ts +5 -18
  431. package/src/core/i18n-ui.ts +82 -2
  432. package/src/core/i18n.ts +31 -3
  433. package/src/core/includes.ts +20 -3
  434. package/src/core/last-modified.ts +25 -3
  435. package/src/core/links.ts +16 -2
  436. package/src/core/locale-links.ts +5 -1
  437. package/src/core/localizable.ts +26 -0
  438. package/src/core/meta.ts +33 -19
  439. package/src/core/navigation.ts +71 -20
  440. package/src/core/page-modes.ts +56 -0
  441. package/src/core/project-graph.ts +138 -10
  442. package/src/core/redirect-patterns.ts +491 -0
  443. package/src/core/related.ts +131 -0
  444. package/src/core/schema.ts +342 -68
  445. package/src/core/sources/contentful-rich-text.ts +27 -20
  446. package/src/core/sources/filesystem.ts +20 -2
  447. package/src/core/sources/github-releases.ts +25 -6
  448. package/src/core/sources/lexical.ts +23 -18
  449. package/src/core/sources/lower.ts +201 -34
  450. package/src/core/sources/mdx-remote.ts +51 -16
  451. package/src/core/sources/normalize.ts +327 -91
  452. package/src/core/sources/notion.ts +52 -25
  453. package/src/core/sources/obsidian.ts +23 -6
  454. package/src/core/sources/portable-text.ts +38 -21
  455. package/src/core/sources/read.ts +8 -3
  456. package/src/core/sources/strapi-blocks.ts +20 -16
  457. package/src/core/sources/watch.ts +20 -7
  458. package/src/core/standard-schema.ts +10 -6
  459. package/src/core/types.ts +1 -1
  460. package/src/core/ui-packs/ar.ts +43 -0
  461. package/src/core/ui-packs/bg.ts +45 -0
  462. package/src/core/ui-packs/bn.ts +43 -0
  463. package/src/core/ui-packs/ca.ts +46 -0
  464. package/src/core/ui-packs/cs.ts +44 -0
  465. package/src/core/ui-packs/da.ts +45 -0
  466. package/src/core/ui-packs/de.ts +46 -0
  467. package/src/core/ui-packs/el.ts +45 -0
  468. package/src/core/ui-packs/es.ts +46 -0
  469. package/src/core/ui-packs/fa.ts +45 -0
  470. package/src/core/ui-packs/fi.ts +45 -0
  471. package/src/core/ui-packs/fr.ts +46 -0
  472. package/src/core/ui-packs/he.ts +43 -0
  473. package/src/core/ui-packs/hi.ts +44 -0
  474. package/src/core/ui-packs/hr.ts +45 -0
  475. package/src/core/ui-packs/hu.ts +44 -0
  476. package/src/core/ui-packs/id.ts +45 -0
  477. package/src/core/ui-packs/it.ts +45 -0
  478. package/src/core/ui-packs/ja.ts +45 -0
  479. package/src/core/ui-packs/ko.ts +44 -0
  480. package/src/core/ui-packs/nl.ts +46 -0
  481. package/src/core/ui-packs/no.ts +44 -0
  482. package/src/core/ui-packs/pl.ts +45 -0
  483. package/src/core/ui-packs/pt-br.ts +46 -0
  484. package/src/core/ui-packs/pt.ts +45 -0
  485. package/src/core/ui-packs/ro.ts +45 -0
  486. package/src/core/ui-packs/ru.ts +45 -0
  487. package/src/core/ui-packs/sk.ts +44 -0
  488. package/src/core/ui-packs/sr.ts +45 -0
  489. package/src/core/ui-packs/sv.ts +44 -0
  490. package/src/core/ui-packs/th.ts +43 -0
  491. package/src/core/ui-packs/tr.ts +45 -0
  492. package/src/core/ui-packs/uk.ts +45 -0
  493. package/src/core/ui-packs/vi.ts +45 -0
  494. package/src/core/ui-packs/zh-tw.ts +43 -0
  495. package/src/core/ui-packs/zh.ts +43 -0
  496. package/src/core/variables.ts +103 -0
  497. package/src/core/version-cut.ts +52 -15
  498. package/src/deploy/artifacts.ts +104 -14
  499. package/src/deploy/cloudflare-negotiation.ts +39 -17
  500. package/src/deploy/headers.ts +10 -5
  501. package/src/deploy/node-headers.ts +64 -10
  502. package/src/deploy/platforms/cloudflare.ts +44 -3
  503. package/src/deploy/platforms/netlify.ts +34 -1
  504. package/src/deploy/platforms/node.ts +1 -0
  505. package/src/deploy/platforms/static.ts +1 -0
  506. package/src/deploy/platforms/types.ts +8 -0
  507. package/src/deploy/platforms/vercel.ts +38 -2
  508. package/src/deploy/redirects.ts +139 -36
  509. package/src/deploy/robots.ts +2 -2
  510. package/src/deploy/rss.ts +4 -3
  511. package/src/deploy/sitemap.ts +7 -5
  512. package/src/deploy/vercel-negotiation.ts +36 -0
  513. package/src/markdown/api-rail.ts +259 -0
  514. package/src/markdown/base-links.ts +34 -36
  515. package/src/markdown/code-title.ts +35 -9
  516. package/src/markdown/directives.ts +242 -36
  517. package/src/markdown/features.ts +20 -2
  518. package/src/markdown/fence-meta.ts +2 -0
  519. package/src/markdown/include.ts +11 -1
  520. package/src/markdown/index.ts +35 -11
  521. package/src/markdown/math.ts +4 -4
  522. package/src/markdown/mdast.ts +5 -2
  523. package/src/markdown/relative-links.ts +12 -4
  524. package/src/markdown/variables.ts +56 -0
  525. package/src/markdown/views.ts +82 -0
  526. package/src/narration/build.ts +412 -0
  527. package/src/narration/player.ts +249 -0
  528. package/src/narration/provider.ts +29 -0
  529. package/src/narration/script.ts +592 -0
  530. package/src/og/card.ts +136 -11
  531. package/src/og/derive.ts +41 -31
  532. package/src/og/index.ts +1 -0
  533. package/src/openapi/asyncapi.ts +4 -2
  534. package/src/openapi/model.ts +77 -36
  535. package/src/openapi/overlay.ts +256 -0
  536. package/src/openapi/parse.ts +55 -2
  537. package/src/openapi/proxy.ts +63 -10
  538. package/src/openapi/references.ts +21 -5
  539. package/src/openapi/render-mdx.ts +46 -3
  540. package/src/openapi/scalar.ts +40 -6
  541. package/src/openapi/source.ts +1 -1
  542. package/src/ratelimit/cloudflare.ts +54 -0
  543. package/src/ratelimit/index.ts +30 -0
  544. package/src/ratelimit/memory.ts +45 -0
  545. package/src/ratelimit/runtime.ts +229 -0
  546. package/src/ratelimit/schema.ts +28 -0
  547. package/src/ratelimit/upstash.ts +30 -0
  548. package/src/ratelimit/wrangler.ts +70 -0
  549. package/src/reference/asyncapi.ts +2 -2
  550. package/src/reference/graphql.ts +5 -2
  551. package/src/reference/openapi.ts +21 -7
  552. package/src/reference/options.ts +51 -7
  553. package/src/reference/scalar.ts +33 -8
  554. package/src/registry/eject.ts +201 -28
  555. package/src/registry/registry.ts +7 -0
  556. package/src/search/adapters/version-scope.ts +30 -0
  557. package/src/search/documents.ts +93 -28
  558. package/src/search/orama-index.ts +28 -3
  559. package/src/search/pagefind-ranking.ts +39 -0
  560. package/src/search/popular.ts +2 -1
  561. package/src/search/sync/algolia.ts +15 -4
  562. package/src/search/sync/orama-cloud.ts +3 -0
  563. package/src/search/sync/typesense.ts +5 -0
  564. package/src/seo/jsonld.ts +7 -3
  565. package/src/seo/metatags.ts +67 -0
  566. package/src/theme/chrome-icons.ts +1 -0
  567. package/src/theme/color.ts +500 -0
  568. package/src/theme/entry.ts +56 -3
  569. package/src/theme/palette.ts +121 -45
  570. package/src/translate/meta.ts +68 -24
  571. package/src/translate/prompts.ts +1 -0
  572. package/src/translate/run.ts +3 -3
  573. package/src/translate/validate.ts +12 -3
  574. package/src/translate/work-list.ts +56 -17
  575. package/src/upgrade/upgrade.ts +4 -171
  576. package/dist/cli/chunk-3yce002v.js.map +0 -14
  577. package/dist/cli/chunk-5r8g91qn.js.map +0 -34
  578. package/dist/cli/chunk-6dtt0zfn.js.map +0 -10
  579. package/dist/cli/chunk-7mbqtmgb.js.map +0 -10
  580. package/dist/cli/chunk-ddndchfr.js.map +0 -14
  581. package/dist/cli/chunk-esh98wmb.js +0 -23
  582. package/dist/cli/chunk-esh98wmb.js.map +0 -10
  583. package/dist/cli/chunk-hqp2ajnh.js.map +0 -35
  584. package/dist/cli/chunk-hr8ne106.js.map +0 -13
  585. package/dist/cli/chunk-j85scx15.js.map +0 -10
  586. package/dist/cli/chunk-mqc662a6.js +0 -75
  587. package/dist/cli/chunk-mqc662a6.js.map +0 -11
  588. package/dist/cli/chunk-pbg5a4s3.js.map +0 -19
  589. package/dist/cli/chunk-qkb5a8sa.js.map +0 -10
  590. package/dist/cli/chunk-v6ya5kcb.js.map +0 -189
  591. package/dist/cli/chunk-wdrt2k2v.js.map +0 -10
  592. package/dist/cli/chunk-xh43dwgw.js.map +0 -36
  593. package/docs/content/sources.mdx +0 -338
  594. /package/dist/cli/{chunk-zp79m0ts.js.map → chunk-1n228xqb.js.map} +0 -0
  595. /package/dist/cli/{chunk-h2ez8dzb.js.map → chunk-5ffywsmb.js.map} +0 -0
  596. /package/dist/cli/{chunk-g698a744.js.map → chunk-5wj2qwn2.js.map} +0 -0
  597. /package/dist/cli/{chunk-sqw4ekg1.js.map → chunk-amrb6hgh.js.map} +0 -0
  598. /package/dist/cli/{chunk-h7k3nq3v.js.map → chunk-gp84za0h.js.map} +0 -0
  599. /package/dist/cli/{chunk-bfwp9vp6.js.map → chunk-p804f3pe.js.map} +0 -0
  600. /package/dist/cli/{chunk-00gs3wqs.js.map → chunk-ta27feev.js.map} +0 -0
  601. /package/dist/cli/{chunk-bbnwccaz.js.map → chunk-y4ykbark.js.map} +0 -0
@@ -1,10 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/registry/eject.ts"],
4
- "sourcesContent": [
5
- "import { existsSync } from \"node:fs\";\nimport { cp, mkdir, readFile, rm, writeFile } from \"node:fs/promises\";\n\nimport { join, relative } from \"pathe\";\n\nimport { buildAskData } from \"../ai/ask-data.ts\";\nimport { resolveAskBackend } from \"../ai/ask.ts\";\nimport { buildRawMarkdown } from \"../ai/markdown.ts\";\nimport { buildMcpData } from \"../ai/mcp/data.ts\";\nimport { buildMcpDiscovery, buildMcpServerCard } from \"../ai/mcp/discovery.ts\";\nimport { planComponentSlots } from \"../astro/component-slots.ts\";\nimport {\n EXAMPLE_SCAN_GLOB,\n discoverExamples,\n exampleMarkdownLookup,\n exampleScanRoots,\n} from \"../astro/examples.ts\";\nimport {\n analyzeComponentsFile,\n buildRuntimeData,\n clientFeaturesFor,\n collectStaged,\n detectNeedsReact,\n detectUsesMath,\n languageIconCssFor,\n PLAYGROUND_PROXY_ENTRY,\n playgroundProxyPattern,\n proxyAllowlistWarnings,\n specOrigins,\n} from \"../astro/generate.ts\";\nimport { discoverIslands } from \"../astro/islands.ts\";\nimport { customOgRoutes, discoverPages, routeIsTaken } from \"../astro/pages.ts\";\nimport {\n askComponentTemplate,\n askEndpointTemplate,\n astroConfigTemplate,\n catchAllPageTemplate,\n changelogIndexTemplate,\n contentAssetsEndpointTemplate,\n contentConfigTemplate,\n exampleMapTemplate,\n exampleSlug,\n examplesPageTemplate,\n exampleWrapperTemplate,\n featuresTemplate,\n mcpEndpointTemplate,\n mcpPageFile,\n mixedbreadSearchEndpointTemplate,\n notFoundPageTemplate,\n ogEndpointTemplate,\n playgroundProxyTemplate,\n rawMarkdownEndpointTemplate,\n rssEndpointTemplate,\n runtimeDependencies,\n runtimeTsconfigTemplate,\n searchClientTemplate,\n searchEndpointTemplate,\n staticJsonEndpointTemplate,\n} from \"../astro/templates.ts\";\nimport { collectContentAssets } from \"../core/content-assets.ts\";\nimport { buildIncludeGraph } from \"../core/includes.ts\";\nimport { packageRoot } from \"../core/package-root.ts\";\nimport { scanProject } from \"../core/project-graph.ts\";\nimport type { BlumeProject } from \"../core/project-graph.ts\";\nimport {\n resolveDocsCollection,\n sourcesOfKind,\n} from \"../core/sources/collection.ts\";\nimport type { ProjectContext } from \"../core/types.ts\";\nimport { buildRssFeeds, renderRssFeed } from \"../deploy/rss.ts\";\nimport type { OpenApiData } from \"../openapi/model.ts\";\nimport {\n hasScalarReferences,\n needsPlaygroundProxy,\n} from \"../openapi/references.ts\";\nimport { buildReferenceFiles } from \"../openapi/scalar.ts\";\nimport { isOpenApiSource } from \"../openapi/source.ts\";\nimport { buildSearchDocuments } from \"../search/documents.ts\";\nimport {\n examplesEntryTemplate,\n tailwindEntryTemplate,\n} from \"../theme/entry.ts\";\nimport { buildThemeCss } from \"../theme/palette.ts\";\nimport { rebaseSourceDirectives } from \"../theme/sources.ts\";\nimport { twoslashCss } from \"../theme/twoslash.ts\";\n\nconst toPosix = (path: string): string => path.split(\"\\\\\").join(\"/\");\n\n/** The portable `@source` guess: blume in the project's own node_modules. */\nconst LOCAL_BLUME_SOURCE = \"../../node_modules/blume/src/**/*.{astro,ts,tsx}\";\n\n/**\n * The `@source` glob pointing Tailwind at Blume's own source, relative to the\n * ejected `src/generated/app.css`. The project-local `node_modules/blume` is\n * preferred (portable, and under pnpm the symlink survives version bumps), but\n * hoisted installs (npm/yarn workspaces lift blume into the workspace root's\n * node_modules) would make that guess match nothing and silently drop utility\n * classes — so fall back to the package's real installed location, and when\n * even that fails, warn instead of failing silently.\n *\n * Exported for testing.\n */\nexport const blumeSourceGlob = (\n root: string,\n genDir: string,\n resolveBlumeRoot: () => string = packageRoot\n): string => {\n if (existsSync(join(root, \"node_modules\", \"blume\"))) {\n return LOCAL_BLUME_SOURCE;\n }\n try {\n const src = join(resolveBlumeRoot(), \"src\");\n return `${toPosix(relative(genDir, src))}/**/*.{astro,ts,tsx}`;\n } catch {\n console.warn(\n 'blume: could not locate the installed blume package; src/generated/app.css keeps its default `@source \"../../node_modules/blume/...\"` glob. If blume is hoisted elsewhere, point that glob at its install location or Blume\\'s utility classes will be missing.'\n );\n return LOCAL_BLUME_SOURCE;\n }\n};\n\n/** The `blume:openapi` payload for the ejected app (`{}` when none). */\nconst ejectOpenApiData = (project: BlumeProject): OpenApiData => {\n const source = project.sources.find(isOpenApiSource);\n return source ? source.openApiData() : {};\n};\n\n/**\n * The assistant endpoint plus, unless the backend runs its own retrieval (Inkeep),\n * its grounding snapshot. Empty when the assistant is disabled.\n */\nconst askFiles = async (\n project: BlumeProject,\n srcDir: string,\n genDir: string\n): Promise<{ content: string; path: string }[]> => {\n const { assistant } = project.config.ai;\n if (!(assistant?.enabled && !assistant.endpoint)) {\n const endpointPath = join(srcDir, \"pages\", \"api\", \"ask.ts\");\n if (existsSync(endpointPath)) {\n const content = await readFile(endpointPath, \"utf-8\");\n if (content.startsWith(\"// Generated by Blume. Do not edit.\")) {\n await rm(endpointPath, { force: true });\n }\n }\n await rm(join(genDir, \"ask-data.json\"), { force: true });\n return [];\n }\n const backend = resolveAskBackend(assistant.provider);\n const files = [\n {\n content: askEndpointTemplate(backend, {\n cors: assistant.cors,\n instructions: assistant.instructions,\n retrieval: assistant.retrieval,\n }),\n path: join(srcDir, \"pages\", \"api\", \"ask.ts\"),\n },\n ];\n if (backend.grounded) {\n files.push({\n content: `${JSON.stringify(await buildAskData(project))}\\n`,\n path: join(genDir, \"ask-data.json\"),\n });\n }\n return files;\n};\n\n/** Whether the ejected app hosts the MCP server (enabled and route free). */\nconst hostsMcp = (\n project: BlumeProject,\n userPages: { pattern: string }[]\n): boolean =>\n project.config.agents.mcp.enabled &&\n !routeIsTaken(\n userPages,\n project.graph.pages,\n project.config.agents.mcp.route\n );\n\n/**\n * The `.well-known` MCP discovery routes, injected as prerendered pages\n * alongside the user's own so the ejected Astro config wires them in. Empty\n * when the server is disabled or its route is already owned by a page.\n */\nconst mcpDiscoveryPages = (\n project: BlumeProject,\n userPages: { pattern: string }[]\n): { entrypoint: string; pattern: string }[] =>\n hostsMcp(project, userPages)\n ? [\n {\n entrypoint: \"src/blume-mcp/discovery.ts\",\n pattern: \"/.well-known/mcp.json\",\n },\n {\n entrypoint: \"src/blume-mcp/server-card.ts\",\n pattern: \"/.well-known/mcp/server-card.json\",\n },\n ]\n : [];\n\n/**\n * The playground's built-in CORS proxy route (`playground: { proxy: true }`),\n * mirroring `planPlaygroundProxy` in generate.ts: injected like the MCP\n * discovery routes, because Astro treats a `_`-prefixed page file as private,\n * and mounted under `basePath` at the URL the playground sends to. Empty when\n * no reference routes its playground through it.\n */\nconst playgroundProxyPages = (\n config: BlumeProject[\"config\"]\n): { entrypoint: string; pattern: string }[] =>\n needsPlaygroundProxy(config)\n ? [\n {\n entrypoint: toPosix(join(\"src\", PLAYGROUND_PROXY_ENTRY)),\n pattern: playgroundProxyPattern(config),\n },\n ]\n : [];\n\n/**\n * The proxy endpoint behind {@link playgroundProxyPages}, with the origin\n * allowlist baked in from the same parsed specs the reference pages render.\n */\nconst playgroundProxyFiles = (\n config: BlumeProject[\"config\"],\n openApiData: OpenApiData,\n srcDir: string\n): { content: string; path: string }[] =>\n needsPlaygroundProxy(config)\n ? [\n {\n content: playgroundProxyTemplate(specOrigins(openApiData)),\n path: join(srcDir, PLAYGROUND_PROXY_ENTRY),\n },\n ]\n : [];\n\n/**\n * The MCP data snapshot, server endpoint, and `.well-known` discovery\n * documents, mirroring `writeMcpFiles` in generate.ts. Empty when the server\n * is disabled or its route is already owned by a page.\n */\nconst mcpFiles = async (\n project: BlumeProject,\n userPages: { pattern: string }[],\n srcDir: string,\n genDir: string\n): Promise<{ content: string; path: string }[]> => {\n if (!hostsMcp(project, userPages)) {\n return [];\n }\n const { route } = project.config.agents.mcp;\n const data = await buildMcpData(project);\n const discoveryInput = {\n base: data.base,\n name: data.name,\n route,\n site: data.site,\n version: data.version,\n };\n return [\n {\n content: `${JSON.stringify(data)}\\n`,\n path: join(genDir, \"mcp-data.json\"),\n },\n {\n content: mcpEndpointTemplate(),\n path: join(srcDir, \"pages\", mcpPageFile(route)),\n },\n {\n content: staticJsonEndpointTemplate(buildMcpDiscovery(discoveryInput)),\n path: join(srcDir, \"blume-mcp\", \"discovery.ts\"),\n },\n {\n content: staticJsonEndpointTemplate(buildMcpServerCard(discoveryInput)),\n path: join(srcDir, \"blume-mcp\", \"server-card.ts\"),\n },\n ];\n};\n\n/**\n * The `/changelog` index page, mirroring `shouldGenerateChangelog` in\n * generate.ts: emitted when `type: changelog` entries or a release-backed\n * changelog source exist, unless a user page already owns the route.\n */\nconst changelogFiles = (\n project: BlumeProject,\n userPages: { pattern: string }[],\n srcDir: string,\n options: Parameters<typeof changelogIndexTemplate>[0]\n): { content: string; path: string }[] => {\n const hasChangelog = project.graph.pages.some(\n (page) =>\n page.contentType === \"changelog\" &&\n !(page.meta.draft || page.meta.sidebar.hidden)\n );\n const hasChangelogSource =\n sourcesOfKind(project.config, \"github-releases\").length > 0;\n if (\n !(hasChangelog || hasChangelogSource) ||\n routeIsTaken(userPages, project.graph.pages, \"/changelog\")\n ) {\n return [];\n }\n return [\n {\n content: changelogIndexTemplate(options),\n path: join(srcDir, \"pages\", \"changelog.astro\"),\n },\n ];\n};\n\n/**\n * The colocated-image map and the `/blume-assets/[...asset]` endpoint that\n * serves it, mirroring generate.ts: the ejected raw Markdown points\n * `![x](./diagram.png)` at `/blume-assets/content/…`, and the config aliases\n * `blume:content-assets` to the map. Each original's path is written relative\n * to the project root (the directory `astro dev`/`astro build` run from), so\n * the ejected app builds from any checkout. Remote-source images need no\n * endpoint: eject copies them into the project's own `public/blume-assets`.\n */\nconst contentAssetFiles = async (\n project: BlumeProject,\n root: string,\n srcDir: string,\n genDir: string\n): Promise<{ content: string; path: string }[]> => {\n const assets = await collectContentAssets(project);\n const portable = Object.fromEntries(\n Object.entries(assets).map(([param, abs]) => [\n param,\n toPosix(relative(root, abs)),\n ])\n );\n return [\n {\n content: `${JSON.stringify(portable)}\\n`,\n path: join(genDir, \"content-assets.json\"),\n },\n {\n content: contentAssetsEndpointTemplate(null),\n path: join(srcDir, \"pages\", \"blume-assets\", \"[...asset].ts\"),\n },\n ];\n};\n\n/** Contents of the configured `examples.css`, or `\"\"` when unset/absent. */\n/**\n * Read a user stylesheet that eject inlines into a generated entry under\n * `genDir`, re-rooting its relative `@source` paths from the user's file.\n * Resolves to an empty string when the file is unset or absent.\n */\nconst readUserCss = async (\n file: string | null,\n genDir: string\n): Promise<string> => {\n if (!(file && existsSync(file))) {\n return \"\";\n }\n const css = await readFile(file, \"utf-8\");\n return rebaseSourceDirectives(css, { from: file, to: genDir });\n};\n\n/**\n * The per-example preview route `<Component />` iframes embed, nested under\n * `basePath` so it stays reachable behind a proxy that only forwards the\n * base. Empty when the project has no examples.\n */\nconst examplesPreviewFiles = (\n srcDir: string,\n basePath: string,\n hasExamples: boolean\n): { content: string; path: string }[] =>\n hasExamples\n ? [\n {\n content: examplesPageTemplate(),\n path: join(\n srcDir,\n \"pages\",\n ...basePath.split(\"/\").filter(Boolean),\n \"blume-examples\",\n \"[...path].astro\"\n ),\n },\n ]\n : [];\n\n/**\n * The packages the ejected app imports by bare name: Astro, Tailwind's Vite\n * plugin, Tailwind and its typography plugin (which the generated `app.css`\n * and `examples.css` import by name), `blume` itself, the integrations the\n * config wires in, whatever the configured adapters declare, and React when\n * islands, examples, or the assistant render with it (Blume ships React, so\n * projects rarely list it). They have to be the project's own dependencies\n * after eject — under a strict linker such as pnpm nothing else makes them\n * resolvable, and `astro build` fails. The hidden runtime reaches the same\n * packages through its `node_modules` junction into Blume's own, so only\n * eject declares the ones its generated files import directly: the AI SDK the\n * assistant route streams through (unless `ai.assistant.endpoint` points\n * elsewhere, when no route is written) and the EPUB generator's browser bundle\n * `features.ts` loads (only named there when `export.epub` is on).\n */\nconst ejectDependencies = (\n options: Parameters<typeof runtimeDependencies>[0]\n): string[] => {\n const { assistant } = options.config.ai;\n return [\n ...new Set([\n \"astro\",\n \"@tailwindcss/vite\",\n \"tailwindcss\",\n \"@tailwindcss/typography\",\n \"blume\",\n ...runtimeDependencies(options),\n ...(options.needsReact ? [\"react\", \"react-dom\"] : []),\n ...(assistant?.enabled && !assistant.endpoint ? [\"ai\"] : []),\n ...(options.config.export.epub ? [\"epub-gen-memory\"] : []),\n ]),\n ];\n};\n\nconst ejectIntegrationBridge = (\n config: BlumeProject[\"config\"],\n root: string,\n configFile: string | null\n): Parameters<typeof astroConfigTemplate>[0][\"integrationBridge\"] =>\n config.integrations.length > 0 && configFile\n ? { configFile: toPosix(relative(root, configFile)) }\n : undefined;\n\n/**\n * Promote the generated runtime into the project as an owned Astro app. After\n * eject the project has a normal `astro.config.mjs` and `src/`, the `blume` CLI\n * is no longer required, and the `blume` package remains importable.\n *\n * Returns the written files plus non-fatal warnings, mirroring the generated\n * runtime (e.g. a Scalar reference spec that wasn't found, or a reference\n * route colliding with a content page), and the packages the ejected app\n * imports by bare name, for the caller to add to package.json.\n */\nexport const eject = async (\n root: string\n): Promise<{ dependencies: string[]; files: string[]; warnings: string[] }> => {\n const project = await scanProject(root, { mode: \"build\" });\n const { context, config } = project;\n\n const srcDir = join(root, \"src\");\n const genDir = join(srcDir, \"generated\");\n const assistantEnabled = config.ai.assistant?.enabled ?? false;\n const exportPdf = config.export.pdf;\n const exportEpub = config.export.epub;\n\n // Discover examples first and expose them on the project, so the agent-facing\n // Markdown built below (raw `.md`, MCP) downlevels `<Component>` to its source.\n const examples = await discoverExamples(root, config.examples.source);\n project.examples = exampleMarkdownLookup(examples.examples);\n\n const [\n pages,\n needsReactRaw,\n usesMath,\n userTheme,\n userExamplesCss,\n rawMarkdown,\n islands,\n overrideAnalysis,\n ] = await Promise.all([\n context.pagesRoot ? discoverPages(context.pagesRoot) : Promise.resolve([]),\n detectNeedsReact(root),\n detectUsesMath(root),\n readUserCss(context.themeFile, genDir),\n readUserCss(\n config.examples.css ? join(root, config.examples.css) : null,\n genDir\n ),\n buildRawMarkdown(project),\n discoverIslands(root),\n analyzeComponentsFile(context.componentsFile),\n ]);\n // The `islands/` convention and `components.ts` share the same static plan\n // the CLI uses, with every import written relative to its generated file so\n // the ejected app builds from any checkout (like the example wrappers below).\n const slotPlan = planComponentSlots(islands.islands, overrideAnalysis, {\n relativeTo: genDir,\n });\n // Island/example/override frameworks drive which Astro renderers the ejected\n // config wires in; React also switches on for project `.tsx`/`.jsx` and the assistant.\n const frameworks = new Set<string>([\n ...islands.islands.map((island) => island.framework),\n ...examples.examples.map((example) => example.framework),\n ...slotPlan.frameworks,\n ]);\n const needsReact =\n needsReactRaw || assistantEnabled || frameworks.has(\"react\");\n const needsVue = frameworks.has(\"vue\");\n const needsSvelte = frameworks.has(\"svelte\");\n\n // A project-relative context so generated files use portable paths.\n const relContext: ProjectContext = {\n ...context,\n contentRoot: toPosix(relative(root, context.contentRoot)),\n distDir: \"./dist\",\n outDir: \".\",\n pagesRoot: context.pagesRoot\n ? `./${toPosix(relative(root, context.pagesRoot))}`\n : null,\n root: \".\",\n };\n // The `docs` collection resolves its base against the real project root and\n // is then relativized like everything else, so the ejected content config\n // never bakes in the absolute path `eject` happened to run from.\n const docsCollection = resolveDocsCollection(config, root);\n const relCollection = {\n ...docsCollection,\n base: toPosix(relative(root, docsCollection.base)),\n };\n\n const relPages = [\n ...pages.map((page) => ({\n entrypoint: toPosix(relative(root, page.entrypoint)),\n pattern: page.pattern,\n })),\n ...mcpDiscoveryPages(project, pages),\n ...playgroundProxyPages(config),\n ];\n const openApiData = ejectOpenApiData(project);\n\n // Non-filesystem sources eject their materialized MDX into `<root>/blume-staged`\n // (a dedicated dir so it never clashes with a content root literally named\n // `content`; the relative `staged` collection points there).\n const staged = collectStaged(project);\n const hasStaged = staged.size > 0;\n const stagedDir = \"blume-staged\";\n const features = await clientFeaturesFor(project);\n const languageIcons = await languageIconCssFor(project);\n\n const files: {\n path: string;\n content: string;\n /** Don't overwrite a file the user already owns (e.g. a tuned tsconfig). */\n skipIfExists?: boolean;\n }[] = [\n {\n content: astroConfigTemplate({\n askPath: \"./src/generated/Ask.astro\",\n config,\n contentRoot: relContext.contentRoot,\n contentRoutes: project.manifest.routes.map((route) => route.path),\n context: relContext,\n examplesPath: \"./src/generated/examples.ts\",\n examplesThemePath: \"./src/generated/examples.css\",\n features,\n featuresPath: \"./src/generated/features.ts\",\n // No CLI publishes the runtime data modules in memory after eject, so\n // the config aliases each to the JSON snapshot written below.\n generatedModulesDir: \"./src/generated\",\n integrationBridge: ejectIntegrationBridge(\n config,\n root,\n context.configFile\n ),\n needsReact,\n needsSvelte,\n needsVue,\n pages: relPages,\n searchClientPath: \"./src/generated/search-client.ts\",\n themePath: \"./src/generated/app.css\",\n }),\n path: join(root, \"astro.config.mjs\"),\n },\n {\n content: runtimeTsconfigTemplate(),\n path: join(root, \"tsconfig.json\"),\n // Never clobber a hand-tuned tsconfig; only write ours if none exists.\n skipIfExists: true,\n },\n {\n content: contentConfigTemplate({\n collection: relCollection,\n config,\n context: relContext,\n staged: hasStaged,\n stagedBase: stagedDir,\n }),\n path: join(srcDir, \"content.config.ts\"),\n },\n {\n content: catchAllPageTemplate({\n exportEpub,\n exportPdf,\n mathEnabled: usesMath,\n needsReact,\n }),\n path: join(srcDir, \"pages\", \"[...slug].astro\"),\n },\n {\n content: slotPlan.module,\n path: join(genDir, \"components.ts\"),\n },\n // The example map the catch-all imports; written even when empty so the\n // `blume:examples` alias always resolves.\n {\n content: exampleMapTemplate(examples.examples, config.basePath),\n path: join(genDir, \"examples.ts\"),\n },\n {\n // The isolated Tailwind entry for `<Component />` preview frames.\n // Relative sources keep the ejected app portable.\n content: examplesEntryTemplate({\n configTokens: buildThemeCss(config.theme),\n sources: exampleScanRoots(root, examples.dir).map(\n (dir) => `${relative(genDir, dir)}/${EXAMPLE_SCAN_GLOB}`\n ),\n userCss: userExamplesCss,\n }),\n path: join(genDir, \"examples.css\"),\n },\n {\n content: tailwindEntryTemplate({\n configTokens: buildThemeCss(config.theme),\n languageIcons,\n // Relative paths from src/generated/app.css keep the ejected app\n // portable; the blume glob resolves the real install location when\n // the package is hoisted out of the project's own node_modules.\n sources: [\n blumeSourceGlob(root, genDir),\n \"../../**/*.{astro,mdx,ts,tsx}\",\n ],\n twoslashCss: twoslashCss(),\n userTheme,\n }),\n path: join(genDir, \"app.css\"),\n },\n { content: buildRuntimeData(project), path: join(genDir, \"data.json\") },\n // The header's Ask trigger behind the `blume:ask` alias. Always written — it\n // renders nothing when Ask is off — so the alias always resolves.\n {\n content: askComponentTemplate(assistantEnabled),\n path: join(genDir, \"Ask.astro\"),\n },\n {\n content: `${JSON.stringify(openApiData)}\\n`,\n path: join(genDir, \"openapi.json\"),\n },\n {\n content: `${JSON.stringify(rawMarkdown)}\\n`,\n path: join(genDir, \"raw-markdown.json\"),\n },\n {\n // The partial → including-pages map behind `includeHmrPlugin`, which the\n // ejected astro.config wires at this exact path — without the file every\n // hot update's read would silently no-op and partial edits would serve\n // stale pages. A snapshot like the rest of `src/generated`: the ejected\n // app owns (and may regenerate or prune) it.\n content: `${JSON.stringify(buildIncludeGraph(project.graph.pages))}\\n`,\n path: join(genDir, \"includes.json\"),\n },\n {\n content: rawMarkdownEndpointTemplate(\"md\"),\n path: join(srcDir, \"pages\", \"[...slug].md.ts\"),\n },\n {\n content: rawMarkdownEndpointTemplate(\"mdx\"),\n path: join(srcDir, \"pages\", \"[...slug].mdx.ts\"),\n },\n ];\n\n files.push(...(await contentAssetFiles(project, root, srcDir, genDir)));\n\n if (assistantEnabled) {\n files.push(...(await askFiles(project, srcDir, genDir)));\n }\n\n // The `/changelog` index, mirrored from the generated runtime (`[]` when\n // the project has no changelog). The OG endpoint below adds its card.\n const changelog = changelogFiles(project, pages, srcDir, {\n exportEpub,\n exportPdf,\n needsReact,\n staged: hasStaged,\n });\n\n if (config.seo.og.enabled) {\n files.push({\n content: ogEndpointTemplate(\n customOgRoutes(pages, config.title, config.seo.og.titles),\n { pageDescriptions: config.seo.og.description !== false },\n changelog.length > 0\n ),\n path: join(srcDir, \"pages\", \"og\", \"[...slug].png.ts\"),\n });\n }\n\n // The hosted MCP server and the playground's built-in proxy, mirrored from\n // the generated runtime (`[]` when each is off).\n files.push(\n ...(await mcpFiles(project, pages, srcDir, genDir)),\n ...changelog,\n ...playgroundProxyFiles(config, openApiData, srcDir)\n );\n\n // Default 404 page, unless the project already owns `/404` (a custom\n // `pages/404.astro` or a `404.md` content page). The ejected project owns the\n // file afterwards and can edit or remove it.\n if (!routeIsTaken(pages, project.graph.pages, \"/404\")) {\n files.push({\n content: notFoundPageTemplate(),\n path: join(srcDir, \"pages\", \"404.astro\"),\n });\n }\n\n // The client-feature loaders behind the `blume:features` alias, and the\n // provider-specific client loader behind `blume:search-client`.\n files.push(\n {\n content: featuresTemplate(features),\n path: join(genDir, \"features.ts\"),\n },\n {\n content: searchClientTemplate(config),\n path: join(genDir, \"search-client.ts\"),\n }\n );\n\n const searchAdapter = config.search.provider;\n if (searchAdapter.mode === \"static\") {\n const documents = await buildSearchDocuments(project);\n files.push(\n {\n content: `${JSON.stringify(documents)}\\n`,\n path: join(genDir, \"search.json\"),\n },\n {\n content: searchEndpointTemplate(),\n path: join(srcDir, \"pages\", \"blume-search.json.ts\"),\n }\n );\n }\n\n if (searchAdapter.kind === \"mixedbread\") {\n files.push({\n content: mixedbreadSearchEndpointTemplate(searchAdapter.options),\n path: join(srcDir, \"pages\", \"api\", \"search.ts\"),\n });\n }\n\n const feeds = buildRssFeeds(project);\n if (feeds.length > 0) {\n const feedXml = Object.fromEntries(\n feeds.map((feed) => [feed.type, renderRssFeed(feed)])\n );\n files.push(\n {\n content: `${JSON.stringify(feedXml)}\\n`,\n path: join(genDir, \"rss.json\"),\n },\n {\n content: rssEndpointTemplate(),\n path: join(srcDir, \"pages\", \"[section]\", \"rss.xml.ts\"),\n }\n );\n }\n\n // Scalar API/AsyncAPI reference pages, mirrored from the generated runtime so\n // the ejected app keeps its reference routes — including the warnings (a\n // missing spec file, a route collision), which the caller surfaces exactly\n // like the generated-runtime path does.\n // A proxied spec with no origin to allow gets the generated runtime's\n // diagnostic too.\n const warnings: string[] = proxyAllowlistWarnings(config, openApiData);\n if (hasScalarReferences(config)) {\n const references = await buildReferenceFiles({\n config,\n contentRoutes: new Set(project.graph.pages.map((page) => page.route)),\n root,\n });\n warnings.push(...references.warnings);\n for (const file of references.files) {\n files.push({\n content: file.content,\n path: join(srcDir, \"pages\", file.pagePath),\n });\n }\n }\n\n // Per-override and per-example live wrappers referenced by the maps above.\n files.push(\n ...slotPlan.wrappers.map((wrapper) => ({\n content: wrapper.content,\n path: join(genDir, \"component-slots\", `${wrapper.name}.astro`),\n })),\n ...examples.examples.map((example) => ({\n content: exampleWrapperTemplate(example, join(genDir, \"examples\")),\n path: join(genDir, \"examples\", `${exampleSlug(example.path)}.astro`),\n })),\n ...examplesPreviewFiles(\n srcDir,\n config.basePath,\n examples.examples.length > 0\n )\n );\n\n // Materialize staged source bodies under `<root>/blume-staged/<source>/<ref>`,\n // matching the relative `staged` collection base in the ejected config.\n for (const [entryId, content] of staged) {\n files.push({ content, path: join(root, stagedDir, entryId) });\n }\n\n const written = files.filter(\n (file) => !(file.skipIfExists && existsSync(file.path))\n );\n await Promise.all(\n written.map(async (file) => {\n await mkdir(join(file.path, \"..\"), { recursive: true });\n await writeFile(file.path, file.content, \"utf-8\");\n })\n );\n\n // Materialized source assets (e.g. downloaded Notion images) live under the\n // hidden runtime's public dir; copy them into the owned project's `public/`\n // so the staged content's `/blume-assets/…` references still resolve.\n const assetsSrc = join(context.outDir, \"public\", \"blume-assets\");\n if (existsSync(assetsSrc)) {\n await cp(assetsSrc, join(root, \"public\", \"blume-assets\"), {\n recursive: true,\n });\n }\n\n // The hidden runtime is no longer the source of truth.\n await rm(context.outDir, { force: true, recursive: true });\n\n return {\n dependencies: ejectDependencies({\n config,\n needsRe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EAEzD,OAAO;AAAA,IACL,cAAc,kBAAkB;AAAA,MAC9B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACD,OAAO,QAAQ,IAAI,CAAC,SAAS,KAAK,IAAI;AAAA,IACtC;AAAA,EACF;AAAA;",
8
- "debugId": "C71F2E51356BFBB664756E2164756E21",
9
- "names": []
10
- }
@@ -1,75 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- needsPlaygroundProxy,
4
- resolveAskBackend
5
- } from "./chunk-v6ya5kcb.js";
6
-
7
- // src/core/server-features.ts
8
- var serverFeatures = (config) => {
9
- const features = [];
10
- if (config.ai.assistant?.enabled && !config.ai.assistant.endpoint) {
11
- features.push("Assistant");
12
- }
13
- if (config.agents.mcp.enabled) {
14
- features.push("MCP server");
15
- }
16
- if (needsPlaygroundProxy(config)) {
17
- features.push("API playground proxy");
18
- }
19
- if (config.search.provider.mode === "server") {
20
- features.push(`Search (${config.search.provider.kind})`);
21
- }
22
- return features;
23
- };
24
-
25
- // src/cli/required-secrets.ts
26
- var checkRequiredSecrets = (config) => {
27
- const diagnostics = [];
28
- const requireSecret = (feature, env, note) => {
29
- if (process.env[env]) {
30
- return;
31
- }
32
- const noteSuffix = note ? ` (${note})` : "";
33
- diagnostics.push({
34
- code: "BLUME_MISSING_SECRET",
35
- message: `${feature} is enabled but ${env} is not set${noteSuffix}.`,
36
- severity: "warning",
37
- suggestion: `Set ${env} in .env.local for local dev, or in your host's environment for production.`
38
- });
39
- };
40
- if (config.ai.assistant?.enabled && !config.ai.assistant.endpoint) {
41
- const { provider } = config.ai.assistant;
42
- const backend = resolveAskBackend(provider);
43
- for (const env of provider.requiredSecrets) {
44
- requireSecret(`Assistant (${backend.label})`, env, backend.secretNote);
45
- }
46
- }
47
- const { provider } = config.search;
48
- for (const env of provider.requiredSecrets) {
49
- requireSecret(`Search (${provider.kind})`, env);
50
- }
51
- for (const adapter of config.analytics) {
52
- for (const env of adapter.requiredSecrets) {
53
- requireSecret(`Analytics (${adapter.kind})`, env);
54
- }
55
- }
56
- for (const source of config.content.sources) {
57
- for (const env of source.requiredSecrets) {
58
- requireSecret(`Content source (${source.kind})`, env);
59
- }
60
- }
61
- for (const adapter of config.reference) {
62
- for (const env of adapter.requiredSecrets) {
63
- requireSecret(`API reference (${adapter.kind})`, env);
64
- }
65
- }
66
- for (const env of config.deployment.requiredSecrets) {
67
- requireSecret(`Deployment (${config.deployment.kind})`, env);
68
- }
69
- return diagnostics;
70
- };
71
-
72
- export { serverFeatures, checkRequiredSecrets };
73
-
74
- //# debugId=26CFBC953FC234CC64756E2164756E21
75
- //# sourceMappingURL=chunk-mqc662a6.js.map
@@ -1,11 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/core/server-features.ts", "../src/cli/required-secrets.ts"],
4
- "sourcesContent": [
5
- "import { needsPlaygroundProxy } from \"../openapi/references.ts\";\nimport type { ResolvedConfig } from \"./schema.ts\";\n\n/**\n * List the enabled features that require Astro server output. Static builds\n * fail clearly when any of these are enabled.\n */\nexport const serverFeatures = (config: ResolvedConfig): string[] => {\n const features: string[] = [];\n if (config.ai.assistant?.enabled && !config.ai.assistant.endpoint) {\n features.push(\"Assistant\");\n }\n // The hosted MCP server is a live JSON-RPC endpoint, so it needs a runtime.\n if (config.agents.mcp.enabled) {\n features.push(\"MCP server\");\n }\n // The built-in playground proxy (`playground.proxy: true` on an `openapi()`\n // or `graphql()` adapter) is a live fetch endpoint at `/_api-proxy`; an\n // external proxy URL (string) or a proxy-less playground stays fully static.\n if (needsPlaygroundProxy(config)) {\n features.push(\"API playground proxy\");\n }\n // A `server` adapter (Mixedbread) proxies queries through a secret server\n // endpoint, so it can't run on a static build.\n if (config.search.provider.mode === \"server\") {\n features.push(`Search (${config.search.provider.kind})`);\n }\n return features;\n};\n",
6
- "import { resolveAskBackend } from \"../ai/ask.ts\";\nimport type { ResolvedConfig } from \"../core/schema.ts\";\nimport type { Diagnostic } from \"../core/types.ts\";\n\n/**\n * Warn early when an enabled feature needs a secret env var that isn't set, so\n * the failure surfaces at `blume dev`/`build` instead of at the first request in\n * production. These are runtime secrets (the endpoint reads them on the server),\n * so this warns rather than hard-fails — the value may live only in the deploy\n * environment. Build-time secrets (search-index sync) already warn during sync.\n */\nexport const checkRequiredSecrets = (config: ResolvedConfig): Diagnostic[] => {\n const diagnostics: Diagnostic[] = [];\n const requireSecret = (feature: string, env: string, note?: string): void => {\n if (process.env[env]) {\n return;\n }\n const noteSuffix = note ? ` (${note})` : \"\";\n diagnostics.push({\n code: \"BLUME_MISSING_SECRET\",\n message: `${feature} is enabled but ${env} is not set${noteSuffix}.`,\n severity: \"warning\",\n suggestion: `Set ${env} in .env.local for local dev, or in your host's environment for production.`,\n });\n };\n\n if (config.ai.assistant?.enabled && !config.ai.assistant.endpoint) {\n // The adapter descriptor names the env vars its route reads.\n const { provider } = config.ai.assistant;\n const backend = resolveAskBackend(provider);\n for (const env of provider.requiredSecrets) {\n requireSecret(`Assistant (${backend.label})`, env, backend.secretNote);\n }\n }\n\n // Each search adapter declares the secrets its generated runtime reads.\n const { provider } = config.search;\n for (const env of provider.requiredSecrets) {\n requireSecret(`Search (${provider.kind})`, env);\n }\n\n // Adapters name their own secrets; the built-in analytics adapters ship\n // public tokens in the page and declare none.\n for (const adapter of config.analytics) {\n for (const env of adapter.requiredSecrets) {\n requireSecret(`Analytics (${adapter.kind})`, env);\n }\n }\n\n // Each content source adapter declares the env vars its fetch reads.\n for (const source of config.content.sources) {\n for (const env of source.requiredSecrets) {\n requireSecret(`Content source (${source.kind})`, env);\n }\n }\n\n // Adapters name their own secrets; the built-in reference adapters read\n // public specs and declare none.\n for (const adapter of config.reference) {\n for (const env of adapter.requiredSecrets) {\n requireSecret(`API reference (${adapter.kind})`, env);\n }\n }\n\n // The deployment adapter names its own secrets; the built-in host adapters\n // read platform-injected env and declare none.\n for (const env of config.deployment.requiredSecrets) {\n requireSecret(`Deployment (${config.deployment.kind})`, env);\n }\n\n return diagnost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BAAiB;AAAA,IAC1C,cAAc,WAAW,SAAS,SAAS,GAAG;AAAA,EAChD;AAAA,EAIA,WAAW,WAAW,OAAO,WAAW;AAAA,IACtC,WAAW,OAAO,QAAQ,iBAAiB;AAAA,MACzC,cAAc,cAAc,QAAQ,SAAS,GAAG;AAAA,IAClD;AAAA,EACF;AAAA,EAGA,WAAW,UAAU,OAAO,QAAQ,SAAS;AAAA,IAC3C,WAAW,OAAO,OAAO,iBAAiB;AAAA,MACxC,cAAc,mBAAmB,OAAO,SAAS,GAAG;AAAA,IACtD;AAAA,EACF;AAAA,EAIA,WAAW,WAAW,OAAO,WAAW;AAAA,IACtC,WAAW,OAAO,QAAQ,iBAAiB;AAAA,MACzC,cAAc,kBAAkB,QAAQ,SAAS,GAAG;AAAA,IACtD;AAAA,EACF;AAAA,EAIA,WAAW,OAAO,OAAO,WAAW,iBAAiB;AAAA,IACnD,cAAc,eAAe,OAAO,WAAW,SAAS,GAAG;AAAA,EAC7D;AAAA,EAEA,OAAO;AAAA;",
9
- "debugId": "26CFBC953FC234CC64756E2164756E21",
10
- "names": []
11
- }
@@ -1,19 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/cli/commands/translate.ts", "../src/translate/agents.ts", "../src/translate/ledger.ts", "../src/translate/report.ts", "../src/translate/run.ts", "../src/translate/meta.ts", "../src/translate/prompts.ts", "../src/translate/anchors.ts", "../src/translate/validate.ts", "../src/translate/work-list.ts"],
4
- "sourcesContent": [
5
- "import { defineCommand } from \"citty\";\n\nimport { AGENTS } from \"../../audit/agent.ts\";\nimport type { AgentKind } from \"../../audit/agent.ts\";\nimport { BlumeError } from \"../../core/diagnostics.ts\";\nimport { i18nEnabled, localeCodes } from \"../../core/i18n.ts\";\nimport type { ResolvedI18nConfig } from \"../../core/schema.ts\";\nimport { DEFAULT_TRANSLATE_TIMEOUT_MS } from \"../../translate/agents.ts\";\nimport {\n pruneLedger,\n readLedger,\n stampLedger,\n writeLedger,\n} from \"../../translate/ledger.ts\";\nimport {\n checkLines,\n checkReportJson,\n checkSummaryLine,\n createProgressRenderer,\n diagnosticLines,\n hasDrift,\n translateHeaderLine,\n translateReportJson,\n translateSummaryLine,\n} from \"../../translate/report.ts\";\nimport { runTranslate } from \"../../translate/run.ts\";\nimport {\n computeWorkList,\n scanForTranslation,\n} from \"../../translate/work-list.ts\";\nimport { commandMeta } from \"../command-meta.ts\";\nimport { reportInternalError } from \"../internal-error.ts\";\nimport { flushStdout, logger, reportDiagnostics } from \"../log.ts\";\n\n/** Wall-clock ceiling per file, in seconds. */\nconst DEFAULT_TIMEOUT_S = DEFAULT_TRANSLATE_TIMEOUT_MS / 1000;\n\n/** Parallel agent sessions per run; each one is a full agent process. */\nconst DEFAULT_CONCURRENCY = 4;\nconst MAX_CONCURRENCY = 16;\n\ninterface TranslateFlags {\n check?: boolean;\n claude?: boolean;\n codex?: boolean;\n concurrency?: string;\n force?: boolean;\n json?: boolean;\n locale?: string;\n timeout?: string;\n}\n\n/** The validated flag surface `parseFlags` hands the command body. */\ninterface ParsedTranslateFlags {\n agent: AgentKind | undefined;\n concurrency: number;\n timeoutS: number;\n}\n\n/** Validate the flag surface, exiting with a message on the first offense. */\nconst parseFlags = (args: TranslateFlags): ParsedTranslateFlags => {\n // SAFETY: Object.keys of the AGENTS table returns exactly its declared\n // AgentKind keys.\n const agents = (Object.keys(AGENTS) as AgentKind[]).filter(\n (kind) => args[kind]\n );\n if (agents.length > 1) {\n logger.error(\"Pass exactly one of --codex or --claude.\");\n process.exit(1);\n }\n if (args.check && agents.length > 0) {\n logger.error(\n \"--check is read-only and never runs an agent; drop --codex/--claude.\"\n );\n process.exit(1);\n }\n if (!args.check && agents.length === 0) {\n logger.error(\n \"Pass --codex or --claude to choose the agent CLI that translates.\"\n );\n process.exit(1);\n }\n const timeoutS =\n args.timeout === undefined ? DEFAULT_TIMEOUT_S : Number(args.timeout);\n if (!Number.isInteger(timeoutS) || timeoutS <= 0) {\n logger.error(`Invalid --timeout \"${args.timeout}\" (whole seconds).`);\n process.exit(1);\n }\n const concurrency =\n args.concurrency === undefined\n ? DEFAULT_CONCURRENCY\n : Number(args.concurrency);\n if (\n !Number.isInteger(concurrency) ||\n concurrency < 1 ||\n concurrency > MAX_CONCURRENCY\n ) {\n logger.error(\n `Invalid --concurrency \"${args.concurrency}\" (use 1..${MAX_CONCURRENCY}).`\n );\n process.exit(1);\n }\n return { agent: agents[0], concurrency, timeoutS };\n};\n\n/**\n * Resolve `--locale` against the configured locales: comma-separated,\n * case-insensitive, adopting the configured casing. Unknown codes and the\n * default locale (the translation source) are errors.\n */\nconst parseLocales = (\n value: string | undefined,\n i18n: ResolvedI18nConfig\n): string[] | undefined => {\n if (value === undefined) {\n return;\n }\n const configured = new Map(\n i18n.locales.map((locale) => [locale.code.toLowerCase(), locale.code])\n );\n const resolved: string[] = [];\n for (const part of value.split(\",\")) {\n const code = configured.get(part.trim().toLowerCase());\n if (code === undefined) {\n logger.error(\n `Unknown --locale \"${part.trim()}\" (configured: ${localeCodes(i18n).join(\", \")}).`\n );\n process.exit(1);\n }\n if (code === i18n.defaultLocale) {\n logger.error(\n `--locale \"${code}\" is the default locale — it is the translation source, not a target.`\n );\n process.exit(1);\n }\n resolved.push(code);\n }\n return resolved;\n};\n\nconst notInstalled = (agent: AgentKind): never => {\n const cli = AGENTS[agent];\n logger.error(\n `${cli.name} (\\`${cli.bin}\\`) was not found on PATH. Install it with \\`${cli.install}\\`.`\n );\n return process.exit(1);\n};\n\nexport const translateCommand = defineCommand({\n args: {\n check: {\n description:\n \"Report missing/stale translations without writing anything; exits 1 on drift (for CI).\",\n type: \"boolean\",\n },\n claude: {\n description: \"Translate with Claude Code.\",\n type: \"boolean\",\n },\n codex: {\n description: \"Translate with Codex.\",\n type: \"boolean\",\n },\n concurrency: {\n description: `Parallel agent sessions. Defaults to ${DEFAULT_CONCURRENCY}, max ${MAX_CONCURRENCY}.`,\n type: \"string\",\n },\n force: {\n description:\n \"Retranslate everything, up-to-date and hand-authored files included.\",\n type: \"boolean\",\n },\n json: {\n description: \"Emit the report as JSON on stdout (for CI/editors).\",\n type: \"boolean\",\n },\n locale: {\n description:\n \"Comma-separated target locale codes; defaults to every non-default locale.\",\n type: \"string\",\n },\n timeout: {\n description: `Agent time limit per file, in seconds. Defaults to ${DEFAULT_TIMEOUT_S}.`,\n type: \"string\",\n },\n },\n meta: commandMeta.translate,\n async run({ args }) {\n const root = process.cwd();\n const { agent, concurrency, timeoutS } = parseFlags(args);\n\n try {\n // A scan, not `prepareProject`: translation reads the content tree and\n // writes source files, never `.blume/`, so it doesn't contend with a\n // running dev server. Same reasoning as `blume audit`/`eval`. Drafts\n // are included (see `scanForTranslation`).\n const project = await scanForTranslation(root);\n if (!i18nEnabled(project.config)) {\n logger.error(\n \"i18n is not configured — add `i18n.locales` to blume.config to use `blume translate`.\"\n );\n process.exit(1);\n }\n const { i18n } = project.config;\n if (localeCodes(i18n).every((code) => code === i18n.defaultLocale)) {\n logger.error(\n \"i18n.locales has no locale besides the default — nothing to translate into.\"\n );\n process.exit(1);\n }\n const locales = parseLocales(args.locale, i18n);\n const ledger = await readLedger(root);\n const workList = await computeWorkList(project, ledger, {\n force: !args.check && Boolean(args.force),\n locales,\n });\n\n if (args.check) {\n const lines = [\n ...diagnosticLines(workList.diagnostics),\n ...checkLines(workList),\n \"\",\n ` ${checkSummaryLine(workList)}`,\n \"\",\n ];\n process.stderr.write(`${lines.join(\"\\n\")}\\n`);\n if (args.json) {\n process.stdout.write(checkReportJson(workList));\n }\n if (hasDrift(workList)) {\n await flushStdout();\n process.exit(1);\n }\n return;\n }\n\n // SAFETY: parseFlags exits unless --check was passed or exactly one\n // agent flag was; on this non-check path the agent is therefore set.\n const kind = agent as AgentKind;\n process.stderr.write(\n `${translateHeaderLine(workList.items.length, workList.targetLocales.length, kind)}\\n\\n`\n );\n\n // Adopt pre-existing hand-authored translations (stamp, never rewrite)\n // and persist BEFORE the agents run, so adoption survives an interrupt.\n for (const entry of workList.untracked) {\n stampLedger(ledger, entry.sourceRel, entry.locale, entry.hash);\n }\n await writeLedger(root, ledger);\n\n const renderer = createProgressRenderer({\n isTTY: process.stderr.isTTY === true,\n write: (chunk) => process.stderr.write(chunk),\n });\n const result = await runTranslate({\n agent: kind,\n concurrency,\n ledger,\n onProgress: (event) => renderer.onProgress(event),\n // Flush after every finished item, so stopping a long run mid-way\n // keeps everything already translated out of the next work list.\n persistLedger: () => writeLedger(root, ledger),\n project,\n timeoutMs: timeoutS * 1000,\n workList,\n });\n renderer.stop();\n\n // Prune entries whose source or locale no longer exists. Pruning spans\n // ALL non-default locales — a `--locale fr` run must not drop the other\n // locales' stamps.\n const knownLocales = new Set(\n localeCodes(i18n).filter((code) => code !== i18n.defaultLocale)\n );\n await writeLedger(\n root,\n pruneLedger(ledger, workList.knownSources, knownLocales)\n );\n\n const tail = [\n \"\",\n ...diagnosticLines(workList.diagnostics),\n ` ${translateSummaryLine(result, workList)}`,\n \"\",\n ];\n process.stderr.write(tail.join(\"\\n\"));\n\n if (args.json) {\n process.stdout.write(translateReportJson(result, workList));\n }\n if (result.counts.failed > 0 || result.counts.partial > 0) {\n // The ledger write above already persisted every success, so a failed\n // rerun only retries what actually failed.\n await flushStdout();\n process.exit(1);\n }\n } catch (error) {\n if (error instanceof BlumeError) {\n reportDiagnostics([error.diagnostic], root);\n process.exit(1);\n }\n // SAFETY: an ENOENT from spawning the agent CLI is an ErrnoException;\n // any other thrown shape reads `code` as undefined and falls through.\n if ((error as NodeJS.ErrnoException)?.code === \"ENOENT\" && agent) {\n notInstalled(agent);\n }\n reportInternalError(error);\n process.exit(1);\n }\n },\n});\n",
6
- "import type { AgentKind } from \"../audit/agent.ts\";\nimport { CODEX_LOCKDOWN, DISALLOWED_TOOLS } from \"../eval/agents.ts\";\n\n/**\n * argv builders for the translator role. The subprocess machinery\n * (`runAgentHeadless`, `readAgentOutput`, the `HeadlessRunner` test seam) is\n * shared with `blume eval` — only the argument surface differs: a translator\n * is a pure text→text call with no MCP servers and no tools at all, so the\n * agent can neither read the repo nor write files (Blume owns every write).\n */\n\n/**\n * Wall-clock ceiling per file. Generous by design: translating a large page\n * means regenerating the whole file token by token, and a 20KB+ reference\n * page comfortably exceeds the eval reader's 3-minute precedent. The ceiling\n * exists to catch hung agents, not to police slow-but-progressing ones.\n */\nexport const DEFAULT_TRANSLATE_TIMEOUT_MS = 600_000;\n\nconst claudeArgs = (): string[] => [\n \"-p\",\n \"--output-format\",\n \"json\",\n \"--strict-mcp-config\",\n \"--disallowedTools\",\n DISALLOWED_TOOLS.join(\",\"),\n \"--max-turns\",\n \"1\",\n];\n\n// `--sandbox read-only` alone still lets codex's shell read any file the user\n// can, and the source page being translated is untrusted input (a remote\n// contributor's prose), so the translator gets the same lockdown as an eval\n// run: no shell, exec, or local-image tool, and no inherited environment.\nconst codexArgs = (lastMessagePath: string): string[] => [\n \"exec\",\n \"--skip-git-repo-check\",\n \"--ignore-user-config\",\n \"--ephemeral\",\n \"--sandbox\",\n \"read-only\",\n ...CODEX_LOCKDOWN,\n \"--output-last-message\",\n lastMessagePath,\n \"-\",\n];\n\n/**\n * Build the argv for one headless translation call. `lastMessagePath` is where\n * codex writes its final message (its stdout interleaves progress); claude\n * ignores it and answers as JSON on stdout.\n */\nexport const translateAgentArgs = (\n kind: AgentKind,\n lastMessagePath: string\n): string[] => (kind === \"claude\" ? claudeArgs() : codexArgs(lastMessagePath));\n",
7
- "import { createHash } from \"node:crypto\";\nimport { readFile } from \"node:fs/promises\";\n\nimport { join } from \"pathe\";\nimport { z } from \"zod\";\n\nimport { BlumeError } from \"../core/diagnostics.ts\";\nimport { writeTextAtomic } from \"../core/fs-atomic.ts\";\n\n/**\n * The committed translation ledger: which source files have been translated\n * into which locales, and at what source content. Named \"ledger\" to avoid\n * colliding with the route manifest (`core/manifest.ts`). It lives at the\n * project root — never inside `.blume/` (init gitignores that dir wholesale,\n * and the whole point is that the ledger is committed alongside the docs).\n */\nexport const LEDGER_FILE = \"blume.translations.json\";\n\n/**\n * `files` maps a POSIX root-relative source path to, per locale, the hash of\n * the raw source text at the moment that locale's translation was written.\n */\nexport interface TranslationLedger {\n version: 1;\n files: Record<string, Record<string, string>>;\n}\n\nconst ledgerSchema = z.object({\n files: z.record(z.string(), z.record(z.string(), z.string())),\n version: z.literal(1),\n});\n\nexport const emptyLedger = (): TranslationLedger => ({\n files: {},\n version: 1,\n});\n\n/**\n * Hash the raw source text (frontmatter included), so any edit invalidates\n * every locale's stamp. sha256-16 like the audit snapshot's content hash.\n * Kept as its own function rather than sharing core's `hashText`: ledger\n * stamps persist in user repos, so this hash must never change shape when an\n * ephemeral cache hash does. CRLF line endings are normalized to LF first, so\n * a Windows checkout (`core.autocrlf`) hashes the same as everyone else's —\n * LF text hashes exactly as it always has.\n */\nexport const hashSource = (text: string): string =>\n createHash(\"sha256\")\n .update(text.replaceAll(\"\\r\\n\", \"\\n\"))\n .digest(\"hex\")\n .slice(0, 16);\n\n/** A git merge-conflict marker line: `<<<<<<< ours`, `=======`, `>>>>>>> theirs`. */\nconst CONFLICT_MARKER = /^(?:<{7}|={7}|>{7})(?:[ \\r]|$)/mu;\n\n/**\n * Read the ledger at `root`, tolerantly: a missing file, unparseable JSON, or\n * an unknown shape/version all resolve to an empty ledger rather than an error\n * (same posture as the dev lock's `parseLock`) — the worst outcome of a\n * corrupt ledger is retranslating files that were already up to date.\n *\n * Unresolved merge-conflict markers are the exception, and an error: read as\n * empty, every existing translation would be adopted as current, so\n * `--check` would pass over translations that are out of date.\n */\nexport const readLedger = async (root: string): Promise<TranslationLedger> => {\n const path = join(root, LEDGER_FILE);\n let raw: string;\n try {\n raw = await readFile(path, \"utf-8\");\n } catch {\n return emptyLedger();\n }\n let data: unknown;\n try {\n data = JSON.parse(raw);\n } catch {\n if (CONFLICT_MARKER.test(raw)) {\n throw new BlumeError({\n code: \"BLUME_TRANSLATE_LEDGER_CONFLICT\",\n file: path,\n message: `${LEDGER_FILE} has unresolved merge-conflict markers, so it can't say which translations are current.`,\n severity: \"error\",\n suggestion: `Resolve the merge conflict in ${LEDGER_FILE}, then rerun.`,\n });\n }\n return emptyLedger();\n }\n const parsed = ledgerSchema.safeParse(data);\n return parsed.success ? parsed.data : emptyLedger();\n};\n\n/** Deterministic serialization: keys sorted at both levels, 2-space indent. */\nexport const serializeLedger = (ledger: TranslationLedger): string => {\n const files: Record<string, Record<string, string>> = {};\n for (const source of Object.keys(ledger.files).toSorted()) {\n const locales = ledger.files[source] ?? {};\n files[source] = Object.fromEntries(\n Object.keys(locales)\n .toSorted()\n .map((locale) => [locale, locales[locale] ?? \"\"])\n );\n }\n return `${JSON.stringify({ files, version: ledger.version }, null, 2)}\\n`;\n};\n\n/**\n * Write the ledger at `root`, returning whether anything changed on disk. A\n * byte-identical ledger is left untouched (no mtime churn, no git noise);\n * a changed one lands via temp-file-plus-rename so a concurrent reader never\n * observes a half-written file.\n */\nexport const writeLedger = async (\n root: string,\n ledger: TranslationLedger\n): Promise<boolean> => {\n const path = join(root, LEDGER_FILE);\n const content = serializeLedger(ledger);\n let existing: string | null = null;\n try {\n existing = await readFile(path, \"utf-8\");\n } catch {\n existing = null;\n }\n if (existing === content) {\n return false;\n }\n await writeTextAtomic(path, content);\n return true;\n};\n\n/** Record that `sourceRel` is translated into `locale` at source hash `hash`. */\nexport const stampLedger = (\n ledger: TranslationLedger,\n sourceRel: string,\n locale: string,\n hash: string\n): void => {\n const locales = ledger.files[sourceRel] ?? {};\n locales[locale] = hash;\n ledger.files[sourceRel] = locales;\n};\n\n/**\n * Drop entries for sources that no longer exist and locales that are no longer\n * configured, so deleted pages and removed locales don't linger in the ledger\n * forever. Returns a new ledger.\n */\nexport const pruneLedger = (\n ledger: TranslationLedger,\n knownSources: ReadonlySet<string>,\n knownLocales: ReadonlySet<string>\n): TranslationLedger => {\n const files: Record<string, Record<string, string>> = {};\n for (const [source, locales] of Object.entries(ledger.files)) {\n if (!knownSources.has(source)) {\n continue;\n }\n const kept = Object.fromEntries(\n Object.entries(locales).filter(([locale]) => knownLocales.has(locale))\n );\n if (Object.keys(kept).length > 0) {\n files[source] = kept;\n }\n }\n return { files, version: ledger.version };\n};\n",
8
- "import { colors } from \"consola/utils\";\nimport type { ColorFunction } from \"consola/utils\";\n\nimport { AGENTS } from \"../audit/agent.ts\";\nimport type { AgentKind } from \"../audit/agent.ts\";\nimport { duration, money, seconds } from \"../cli/report-format.ts\";\nimport { countBySeverity } from \"../core/diagnostics.ts\";\nimport type { Diagnostic } from \"../core/types.ts\";\nimport type {\n TranslateItemResult,\n TranslateItemStatus,\n TranslateResult,\n} from \"./run.ts\";\nimport type {\n MetaWorkEntry,\n TranslateWorkList,\n WorkItem,\n WorkStatus,\n} from \"./work-list.ts\";\n\n/**\n * The live progress UI, colored via consola's `colors` (which honors\n * NO_COLOR/FORCE_COLOR and TTY detection), matching the eval report's palette.\n * Render functions are pure; the renderer takes an injectable `write`/`now` so\n * tests never touch a real TTY or clock. The command sends everything here to\n * stderr via the raw `write` — never `logger.info`, which consola drops in\n * test and CI environments.\n */\n\nconst ESC = String.fromCodePoint(27);\n\nconst GLYPH = {\n failed: \"✖\",\n partial: \"!\",\n translated: \"✔\",\n} satisfies Record<TranslateItemStatus, string>;\n\nconst STATUS_COLOR = {\n failed: colors.red,\n partial: colors.yellow,\n translated: colors.green,\n} satisfies Record<TranslateItemStatus, ColorFunction>;\n\nexport const SPINNER_FRAMES = [\n \"⠋\",\n \"⠙\",\n \"⠹\",\n \"⠸\",\n \"⠼\",\n \"⠴\",\n \"⠦\",\n \"⠧\",\n \"⠇\",\n \"⠏\",\n];\n\n/** How often the TTY spinner advances (one frame per interval). */\nexport const SPINNER_INTERVAL_MS = 80;\n\n/** The clear-to-start-of-line prefix every TTY rewrite uses. */\nconst REWRITE = `\\r${ESC}[K`;\n\n/** `docs/guides/install.mdx → fr`, or the batched meta call's label. */\nexport const itemLabel = (item: WorkItem): string =>\n item.kind === \"page\"\n ? `${item.sourceRel} → ${item.locale}`\n : `meta title${item.entries.length === 1 ? \"\" : \"s\"} (${item.entries.length}) → ${item.locale}`;\n\n/**\n * The in-flight spinner line a TTY rewrites in place: the oldest active\n * item's label, how many more lanes are running, and the run's progress.\n */\nexport const spinnerLine = (\n active: WorkItem[],\n done: number,\n total: number,\n frame: number\n): string => {\n // SAFETY: the renderer only paints while at least one item is active, so the\n // oldest active entry exists.\n const first = active[0] as WorkItem;\n const more = active.length > 1 ? ` (+${active.length - 1} more)` : \"\";\n // SAFETY: `frame % SPINNER_FRAMES.length` is always an index into the\n // non-empty frames array.\n return ` ${colors.cyan(SPINNER_FRAMES[frame % SPINNER_FRAMES.length] as string)} ${itemLabel(first)}${more} ${colors.dim(`${done}/${total}`)}`;\n};\n\n/** The permanent line printed when an item finishes. */\nexport const itemEndLine = (result: TranslateItemResult): string => {\n const color = STATUS_COLOR[result.status];\n const glyph = color(GLYPH[result.status]);\n const label = itemLabel(result.item);\n if (result.status === \"translated\") {\n const cells = [seconds(result.durationMs), money(result.costUsd)]\n .filter((cell) => cell !== \"\")\n .join(\" \");\n return ` ${glyph} ${label} ${colors.dim(cells)}`;\n }\n const word = result.status === \"partial\" ? \"partial\" : \"failed\";\n return ` ${glyph} ${label} ${color(word)}${\n result.detail ? colors.dim(`: ${result.detail}`) : \"\"\n }`;\n};\n\n/** The header line the command prints before the first item runs. */\nexport const translateHeaderLine = (\n itemCount: number,\n localeCount: number,\n agent: AgentKind\n): string =>\n `${colors.bold(\"blume translate\")} ${itemCount} item(s) · ${localeCount} locale(s) · ${AGENTS[agent].name}`;\n\n/**\n * `Translated 11 files into 2 locales · 1 failed · 2 adopted · 8 already up to\n * date · 4m 12s · $0.41` (cost only when the agent reports one).\n */\nexport const translateSummaryLine = (\n result: TranslateResult,\n workList: TranslateWorkList\n): string => {\n const { counts } = result;\n const parts = [\n `Translated ${counts.translated} file${counts.translated === 1 ? \"\" : \"s\"} into ${workList.targetLocales.length} locale${workList.targetLocales.length === 1 ? \"\" : \"s\"}`,\n counts.failed > 0 ? `${counts.failed} failed` : \"\",\n counts.partial > 0 ? `${counts.partial} partial` : \"\",\n workList.untracked.length > 0 ? `${workList.untracked.length} adopted` : \"\",\n workList.upToDate > 0 ? `${workList.upToDate} already up to date` : \"\",\n duration(result.durationMs),\n money(result.costUsd),\n ].filter((part) => part !== \"\");\n return parts.join(\" · \");\n};\n\n/** Dim warnings for work-list diagnostics (e.g. a factory-form meta file). */\nexport const diagnosticLines = (diagnostics: Diagnostic[]): string[] =>\n diagnostics.map(\n (diagnostic) => ` ${colors.yellow(\"⚠\")} ${colors.dim(diagnostic.message)}`\n );\n\n/** One (source, locale) pair a `--check` run flags. */\ninterface DriftRow {\n /** Absolute path of the default-locale source. */\n file: string;\n locale: string;\n sourceRel: string;\n status: WorkStatus;\n}\n\n/** Every (source, locale, status) drift row in a work list, pages then meta. */\nconst driftRows = (workList: TranslateWorkList): DriftRow[] =>\n workList.items.flatMap((item) =>\n item.kind === \"page\"\n ? [\n {\n file: item.sourcePath,\n locale: item.locale,\n sourceRel: item.sourceRel,\n status: item.status,\n },\n ]\n : item.entries.map((entry: MetaWorkEntry) => ({\n file: entry.meta.file,\n locale: item.locale,\n sourceRel: entry.meta.sourceRel,\n status: entry.status,\n }))\n );\n\n/**\n * Each missing or stale translation as an error diagnostic, so the `--check`\n * JSON's `summary` counts the drift that fails the gate — the exit-code\n * contract `blume validate/audit/eval --json` keep, where a non-zero exit\n * always shows as a non-zero `summary.error`.\n */\nconst driftDiagnostics = (workList: TranslateWorkList): Diagnostic[] =>\n driftRows(workList).map((row) => ({\n code:\n row.status === \"missing\"\n ? \"BLUME_TRANSLATE_MISSING\"\n : \"BLUME_TRANSLATE_STALE\",\n file: row.file,\n message:\n row.status === \"missing\"\n ? `${row.sourceRel} has no \"${row.locale}\" translation.`\n : `The \"${row.locale}\" translation of ${row.sourceRel} is stale: its source changed since it was translated.`,\n severity: \"error\",\n suggestion:\n \"Run `blume translate --codex` (or `--claude`) to bring the translations up to date.\",\n }));\n\n/** One line per missing/stale pair, plus dim lines for untracked adoptions. */\nexport const checkLines = (workList: TranslateWorkList): string[] => [\n ...driftRows(workList).map(\n (row) =>\n ` ${colors.red(\"✖\")} ${row.sourceRel} → ${row.locale} ${colors.dim(row.status)}`\n ),\n ...workList.untracked.map(\n (entry) =>\n ` ${colors.dim(`⊘ ${entry.sourceRel} → ${entry.locale} untracked (adopted by the next translate run)`)}`\n ),\n];\n\n/** The `--check` totals: `2 missing · 1 stale · 1 untracked · 14 up to date`. */\nexport const checkSummaryLine = (workList: TranslateWorkList): string => {\n const rows = driftRows(workList);\n const missing = rows.filter((row) => row.status === \"missing\").length;\n const stale = rows.filter((row) => row.status === \"stale\").length;\n const parts = [\n missing > 0 ? `${missing} missing` : \"\",\n stale > 0 ? `${stale} stale` : \"\",\n workList.untracked.length > 0\n ? `${workList.untracked.length} untracked`\n : \"\",\n `${workList.upToDate} up to date`,\n ].filter((part) => part !== \"\");\n return parts.join(\" · \");\n};\n\n/** Whether a work list fails the `--check` gate (untracked never does). */\nexport const hasDrift = (workList: TranslateWorkList): boolean =>\n workList.items.length > 0;\n\n/**\n * The machine-readable `--check` report. The `diagnostics` + `summary` shape\n * matches `blume validate/audit/eval --json` exactly — every missing or stale\n * translation is an error diagnostic there, so `summary.error` agrees with the\n * exit code — with the drift report grouped by locale under `translate`.\n */\nexport const checkReportJson = (workList: TranslateWorkList): string => {\n const diagnostics = [...workList.diagnostics, ...driftDiagnostics(workList)];\n const locales: Record<\n string,\n { missing: string[]; stale: string[]; untracked: string[] }\n > = {};\n for (const locale of workList.targetLocales) {\n locales[locale] = { missing: [], stale: [], untracked: [] };\n }\n for (const row of driftRows(workList)) {\n locales[row.locale]?.[row.status].push(row.sourceRel);\n }\n for (const entry of workList.untracked) {\n locales[entry.locale]?.untracked.push(entry.sourceRel);\n }\n return `${JSON.stringify(\n {\n diagnostics,\n summary: countBySeverity(diagnostics),\n translate: { locales, upToDate: workList.upToDate },\n },\n null,\n 2\n )}\\n`;\n};\n\n/** One run result lowered to JSON-friendly, root-relative fields. */\nconst resultJson = (result: TranslateItemResult) => ({\n costUsd: result.costUsd,\n detail: result.detail,\n durationMs: result.durationMs,\n kind: result.item.kind,\n locale: result.item.locale,\n status: result.status,\n ...(result.item.kind === \"page\"\n ? { source: result.item.sourceRel, target: result.item.targetRel }\n : {\n sources: result.item.entries.map((entry) => entry.meta.sourceRel),\n }),\n});\n\n/** The machine-readable report for a translation run (`--json`). */\nexport const translateReportJson = (\n result: TranslateResult,\n workList: TranslateWorkList\n): string => {\n const diagnostics = [...workList.diagnostics, ...result.diagnostics];\n return `${JSON.stringify(\n {\n diagnostics,\n summary: countBySeverity(diagnostics),\n translate: {\n adopted: workList.untracked.length,\n agent: result.agent,\n costUsd: result.costUsd,\n counts: result.counts,\n durationMs: result.durationMs,\n results: result.results.map(resultJson),\n upToDate: workList.upToDate,\n },\n },\n null,\n 2\n )}\\n`;\n};\n\nexport interface ProgressRenderer {\n onProgress: (\n event:\n | {\n kind: \"item-end\";\n index: number;\n result: TranslateItemResult;\n total: number;\n }\n | { kind: \"item-start\"; index: number; item: WorkItem; total: number }\n ) => void;\n stop: () => void;\n}\n\n/**\n * Live progress: on a TTY the in-flight items render as one spinner line\n * rewritten in place (`\\r\\x1B[K`) — a concurrent run shows the oldest active\n * item plus a `(+n more)` count — and each completion prints its permanent\n * line above it; off-TTY (CI) there is no interval and only the permanent\n * per-item lines print.\n */\nexport const createProgressRenderer = (options: {\n isTTY: boolean;\n write: (chunk: string) => void;\n now?: () => number;\n}): ProgressRenderer => {\n const now = options.now ?? (() => performance.now());\n let timer: ReturnType<typeof setInterval> | undefined;\n const active = new Map<number, WorkItem>();\n let done = 0;\n let total = 0;\n let startedAt = 0;\n\n const paint = (): void => {\n if (active.size > 0) {\n const frame = Math.floor((now() - startedAt) / SPINNER_INTERVAL_MS);\n options.write(\n `${REWRITE}${spinnerLine([...active.values()], done, total, frame)}`\n );\n }\n };\n const clearTimer = (): void => {\n if (timer) {\n clearInterval(timer);\n timer = undefined;\n }\n };\n\n return {\n onProgress(event) {\n ({ total } = event);\n if (event.kind === \"item-start\") {\n active.set(event.index, event.item);\n if (!options.isTTY) {\n return;\n }\n if (!timer) {\n startedAt = now();\n timer = setInterval(paint, SPINNER_INTERVAL_MS);\n timer.unref?.();\n }\n paint();\n return;\n }\n active.delete(event.index);\n done += 1;\n const line = itemEndLine(event.result);\n if (!options.isTTY) {\n options.write(`${line}\\n`);\n return;\n }\n options.write(`${REWRITE}${line}\\n`);\n if (active.size > 0) {\n paint();\n } else {\n clearTimer();\n }\n },\n stop() {\n clearTimer();\n active.clear();\n },\n };\n};\n",
9
- "import { existsSync } from \"node:fs\";\nimport { mkdtemp, readFile } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\n\nimport pLimit from \"p-limit\";\nimport pMap from \"p-map\";\nimport { dirname, join } from \"pathe\";\n\nimport { AGENTS } from \"../audit/agent.ts\";\nimport type { AgentKind } from \"../audit/agent.ts\";\nimport { writeTextAtomic } from \"../core/fs-atomic.ts\";\nimport type { BlumeProject } from \"../core/project-graph.ts\";\nimport type { LocaleConfig } from \"../core/schema.ts\";\nimport type { Diagnostic } from \"../core/types.ts\";\nimport { readAgentOutput, runAgentHeadless } from \"../eval/agents.ts\";\nimport type { AgentOutput, HeadlessRunner } from \"../eval/agents.ts\";\nimport { DEFAULT_TRANSLATE_TIMEOUT_MS, translateAgentArgs } from \"./agents.ts\";\nimport { hashSource, stampLedger } from \"./ledger.ts\";\nimport type { TranslationLedger } from \"./ledger.ts\";\nimport { generateMetaModule } from \"./meta.ts\";\nimport type { TranslatableMeta } from \"./meta.ts\";\nimport { metaPrompt, pagePrompt } from \"./prompts.ts\";\nimport { parseMetaTitles, validateTranslation } from \"./validate.ts\";\nimport type {\n MetaWorkItem,\n PageWorkItem,\n TranslateWorkList,\n WorkItem,\n} from \"./work-list.ts\";\n\nexport type TranslateItemStatus = \"failed\" | \"partial\" | \"translated\";\n\nexport interface TranslateItemResult {\n costUsd?: number;\n /** Why the item failed (agent error, validation failure, missing titles). */\n detail?: string;\n durationMs: number;\n item: WorkItem;\n status: TranslateItemStatus;\n}\n\nexport type TranslateProgress =\n | {\n kind: \"item-end\";\n index: number;\n result: TranslateItemResult;\n total: number;\n }\n | { kind: \"item-start\"; index: number; item: WorkItem; total: number };\n\nexport interface TranslateRunOptions {\n agent: AgentKind;\n /** Parallel agent sessions. Defaults to 1 (serial). */\n concurrency?: number;\n /** Mutated in place: every validated write stamps its entry immediately. */\n ledger: TranslationLedger;\n onProgress?: (event: TranslateProgress) => void;\n /**\n * Called after each finished item to flush the ledger to disk, so an\n * interrupted run keeps everything already translated. Calls are serialized\n * here — concurrent workers finishing together never race the same file.\n * The flush's result (`writeLedger`'s wrote-or-not boolean) is ignored.\n */\n persistLedger?: () => Promise<boolean | undefined>;\n project: BlumeProject;\n /** The spawn function — injectable so tests never launch a real agent. */\n run?: HeadlessRunner;\n timeoutMs?: number;\n workList: TranslateWorkList;\n}\n\nexport interface TranslateResult {\n agent: AgentKind;\n /** Total spend, when the agent CLI reports it (claude does, codex doesn't). */\n costUsd?: number;\n counts: Record<TranslateItemStatus, number>;\n diagnostics: Diagnostic[];\n durationMs: number;\n results: TranslateItemResult[];\n}\n\ninterface RunContext {\n bin: string;\n dir: string;\n kind: AgentKind;\n run: HeadlessRunner;\n source: LocaleConfig;\n targets: Map<string, LocaleConfig>;\n timeoutMs: number;\n}\n\n/**\n * A meta file's key in a meta-titles prompt: its directory relative to the\n * project root. The content-root-relative `dir` isn't unique — two\n * filesystem sources can both have a `guides/` folder — and colliding keys\n * would hand both folders one translation.\n */\nconst metaKey = (meta: TranslatableMeta): string => dirname(meta.sourceRel);\n\n/**\n * One headless agent call. A missing executable rejects with ENOENT on every\n * platform (the runner spawns without a shell), which the command layer turns\n * into an install hint.\n */\nconst invokeAgent = async (\n context: RunContext,\n prompt: string,\n index: number\n): Promise<AgentOutput> => {\n const messagePath = join(context.dir, `message-${index}.txt`);\n const result = await context.run(\n context.bin,\n translateAgentArgs(context.kind, messagePath),\n { cwd: context.dir, prompt, timeoutMs: context.timeoutMs }\n );\n return await readAgentOutput(context.kind, result, messagePath);\n};\n\nconst runPageItem = async (\n item: PageWorkItem,\n index: number,\n context: RunContext,\n ledger: TranslationLedger\n): Promise<TranslateItemResult> => {\n const started = performance.now();\n const done = (\n status: TranslateItemStatus,\n detail?: string,\n costUsd?: number\n ): TranslateItemResult => ({\n costUsd,\n detail,\n durationMs: Math.round(performance.now() - started),\n item,\n status,\n });\n\n const sourceText = await readFile(item.sourcePath, \"utf-8\");\n if (item.verbatim) {\n // A non-markdown include partial (code embed) has no prose to translate;\n // it's copied unchanged so the locale tree's relative includes resolve.\n await writeTextAtomic(item.targetPath, sourceText);\n stampLedger(ledger, item.sourceRel, item.locale, hashSource(sourceText));\n return done(\"translated\");\n }\n // SAFETY: `targets` maps every configured locale, and work items only carry\n // configured locale codes.\n const target = context.targets.get(item.locale) as LocaleConfig;\n // A hand-authored translation can live at a non-canonical name (see\n // WorkStatus); the disk probe finds only canonical targets, and a miss just\n // means the prompt goes out without a style precedent.\n const previousTranslation = existsSync(item.targetPath)\n ? await readFile(item.targetPath, \"utf-8\")\n : undefined;\n const output = await invokeAgent(\n context,\n pagePrompt(sourceText, target, context.source, previousTranslation),\n index\n );\n if (output.isError) {\n return done(\"failed\", output.detail ?? \"agent failed\", output.costUsd);\n }\n const validated = validateTranslation(sourceText, output.text);\n if (!validated.ok) {\n return done(\"failed\", validated.reason, output.costUsd);\n }\n await writeTextAtomic(item.targetPath, validated.text);\n stampLedger(ledger, item.sourceRel, item.locale, hashSource(sourceText));\n return done(\"translated\", undefined, output.costUsd);\n};\n\nconst runMetaItem = async (\n item: MetaWorkItem,\n index: number,\n context: RunContext,\n ledger: TranslationLedger\n): Promise<TranslateItemResult> => {\n const started = performance.now();\n const done = (\n status: TranslateItemStatus,\n detail?: string,\n costUsd?: number\n ): TranslateItemResult => ({\n costUsd,\n detail,\n durationMs: Math.round(performance.now() - started),\n item,\n status,\n });\n\n const titles = Object.fromEntries(\n item.entries.map((entry) => [metaKey(entry.meta), entry.meta.title])\n );\n // SAFETY: `targets` maps every configured locale, and work items only carry\n // configured locale codes.\n const target = context.targets.get(item.locale) as LocaleConfig;\n const output = await invokeAgent(\n context,\n metaPrompt(titles, target, context.source),\n index\n );\n if (output.isError) {\n return done(\"failed\", output.detail ?? \"agent failed\", output.costUsd);\n }\n\n const parsed = parseMetaTitles(output.text, Object.keys(titles));\n for (const entry of item.entries) {\n const translated = parsed.titles[metaKey(entry.meta)];\n if (translated === undefined) {\n continue;\n }\n // Each entry writes and stamps independently, so a partially usable reply\n // still lands the titles it did translate.\n // oxlint-disable-next-line no-await-in-loop\n await writeTextAtomic(\n entry.targetPath,\n generateMetaModule(entry.meta.data, translated)\n );\n stampLedger(\n ledger,\n entry.meta.sourceRel,\n item.locale,\n hashSource(entry.meta.raw)\n );\n }\n\n if (parsed.missing.length === item.entries.length) {\n return done(\"failed\", \"reply contained no usable titles\", output.costUsd);\n }\n if (parsed.missing.length > 0) {\n return done(\n \"partial\",\n `no translation for: ${parsed.missing.join(\", \")}`,\n output.costUsd\n );\n }\n return done(\"translated\", undefined, output.costUsd);\n};\n\nconst itemDiagnostic = (result: TranslateItemResult): Diagnostic => {\n const { item } = result;\n const site =\n item.kind === \"page\"\n ? { file: item.sourcePath, subject: item.sourceRel }\n : {\n file: item.entries[0]?.meta.file,\n subject: `meta titles (${item.entries.length})`,\n };\n return {\n code:\n result.status === \"partial\"\n ? \"BLUME_TRANSLATE_META_PARTIAL\"\n : \"BLUME_TRANSLATE_FAILED\",\n file: site.file,\n message: `Translating ${site.subject} into \"${item.locale}\" ${\n result.status === \"partial\" ? \"partially failed\" : \"failed\"\n }: ${result.detail ?? \"unknown error\"}.`,\n severity: result.status === \"partial\" ? \"warning\" : \"error\",\n };\n};\n\n/**\n * Run every work item through the agent, `concurrency` at a time: each worker\n * is a serial lane pulling the next unclaimed item, so results stay indexed\n * by item and progress events interleave but never duplicate. A failed item\n * never writes or stamps; its lane continues. After every finished item the\n * ledger is flushed via `persistLedger` (serialized across lanes), so an\n * interrupted run resumes from what already landed instead of from scratch.\n */\nexport const runTranslate = async (\n options: TranslateRunOptions\n): Promise<TranslateResult> => {\n const started = performance.now();\n const { i18n } = options.project.config;\n if (!i18n) {\n throw new Error(\"blume translate requires i18n to be configured\");\n }\n // SAFETY: the config schema requires `defaultLocale` to be one of `locales`.\n const source = i18n.locales.find(\n (locale) => locale.code === i18n.defaultLocale\n ) as LocaleConfig;\n\n const context: RunContext = {\n bin: AGENTS[options.agent].bin,\n dir: await mkdtemp(join(tmpdir(), \"blume-translate-\")),\n kind: options.agent,\n run: options.run ?? runAgentHeadless,\n source,\n targets: new Map(i18n.locales.map((locale) => [locale.code, locale])),\n timeoutMs: options.timeoutMs ?? DEFAULT_TRANSLATE_TIMEOUT_MS,\n };\n\n const { items } = options.workList;\n const concurrency = Math.max(\n 1,\n Math.min(options.concurrency ?? 1, items.length || 1)\n );\n\n // The persist mutex: ledger flushes from concurrent lanes are serialized so\n // two lanes never write the ledger file at the same time.\n const persistLimit = pLimit(1);\n const persist = (): Promise<boolean | undefined> =>\n persistLimit(() => options.persistLedger?.());\n\n const results = await pMap(\n items,\n async (item: WorkItem, index): Promise<TranslateItemResult> => {\n options.onProgress?.({\n index,\n item,\n kind: \"item-start\",\n total: items.length,\n });\n const result = await (item.kind === \"page\"\n ? runPageItem(item, index, context, options.ledger)\n : runMetaItem(item, index, context, options.ledger));\n // Flush this item's stamps before the slot frees for the next item, so\n // a kill loses at most the in-flight items.\n await persist();\n options.onProgress?.({\n index,\n kind: \"item-end\",\n result,\n total: items.length,\n });\n return result;\n },\n { concurrency }\n );\n\n const diagnostics: Diagnostic[] = [];\n for (const result of results) {\n if (result.status !== \"translated\") {\n diagnostics.push(itemDiagnostic(result));\n }\n }\n\n const counts = {\n failed: 0,\n partial: 0,\n translated: 0,\n } satisfies Record<TranslateItemStatus, number>;\n for (const result of results) {\n counts[result.status] += 1;\n }\n const costs = results.flatMap((result) =>\n result.costUsd === undefined ? [] : [result.costUsd]\n );\n\n return {\n agent: options.agent,\n costUsd:\n costs.length > 0\n ? costs.reduce((total, cost) => total + cost, 0)\n : undefined,\n counts,\n diagnostics,\n durationMs: Math.round(performance.now() - started),\n results,\n };\n};\n",
10
- "import { readFile } from \"node:fs/promises\";\n\nimport { dirname, join, relative } from \"pathe\";\nimport { glob } from \"tinyglobby\";\n\nimport { createModuleLoader } from \"../core/load-module.ts\";\nimport type { BlumeProject } from \"../core/project-graph.ts\";\nimport { folderMetaSchema } from \"../core/schema.ts\";\nimport type { FolderMeta } from \"../core/schema.ts\";\nimport type { Diagnostic } from \"../core/types.ts\";\n\n/**\n * Folder-nav `meta.ts` titles are translatable under the `dir` parser ONLY:\n * per-locale meta is a whole-file replacement, not a merge (`applyFolderMeta`\n * looks up `<locale>/<group>` and falls back to shared meta, never to the\n * default locale's file), and the `dot` parser has no per-locale meta\n * mechanism at all. So the generated module must copy EVERY source key\n * (order/pages/icon/collapsed) with only the title translated — otherwise the\n * locale's navigation loses its ordering.\n */\n\n/** One default-locale meta file whose title can be translated. */\nexport interface TranslatableMeta {\n /** The parsed meta module; copied wholesale into the generated module. */\n data: FolderMeta;\n /** Directory relative to the owning source's content root (`\"\"` = root). */\n dir: string;\n /** Absolute path of the source meta file. */\n file: string;\n /** The owning source's content root (locale directories live under it). */\n contentRoot: string;\n /** Raw source text at discovery time — what the ledger hashes. */\n raw: string;\n /** POSIX root-relative path of the source meta file — the ledger key. */\n sourceRel: string;\n /** The source title to translate. */\n title: string;\n}\n\nconst META_FILES = [\"**/meta.ts\", \"**/meta.js\", \"**/meta.mjs\"];\n\n/**\n * Whether a loaded meta module default-exports a factory function. Generic so\n * it can decode the loader's untyped module value at this boundary.\n */\nconst isFactoryModule = <T>(\n value: T\n): value is T & ((...args: never[]) => FolderMeta) =>\n typeof value === \"function\";\n\n/** Where a locale's generated meta module lives (always written as `meta.ts`). */\nexport const metaTargetPath = (\n meta: TranslatableMeta,\n locale: string\n): string => join(meta.contentRoot, locale, meta.dir, \"meta.ts\");\n\n/**\n * Discover the default-locale `meta.{ts,js,mjs}` files whose titles a\n * translation run covers. Skips (in order): non-`dir` i18n projects entirely,\n * files inside a configured locale directory (those ARE translations), files\n * inside an archived-version snapshot (frozen, with their own translations —\n * the same folders the navigation's meta lookup hoists as versions),\n * factory-form modules (a warning — the generator can't re-emit a function),\n * modules that fail meta validation (the scan already errors on those), and\n * modules with no `title` (nothing to translate).\n */\nexport const discoverTranslatableMeta = async (\n project: BlumeProject\n): Promise<{ metas: TranslatableMeta[]; diagnostics: Diagnostic[] }> => {\n const { i18n } = project.config;\n if (!i18n || i18n.parser !== \"dir\") {\n return { diagnostics: [], metas: [] };\n }\n const localeDirs = new Set(\n i18n.locales.flatMap((locale) =>\n locale.code === i18n.defaultLocale ? [] : [locale.code.toLowerCase()]\n )\n );\n const versionDirs = new Set(\n project.config.versions?.archived.map((version) => version.id)\n );\n\n const load = createModuleLoader();\n const metas: TranslatableMeta[] = [];\n const diagnostics: Diagnostic[] = [];\n\n const roots = project.sources.flatMap((source) =>\n source.staged || !source.contentRoot ? [] : [source.contentRoot]\n );\n for (const contentRoot of roots) {\n // oxlint-disable-next-line no-await-in-loop -- a project has O(1) sources\n const files = await glob(META_FILES, {\n absolute: true,\n cwd: contentRoot,\n ignore: [\"**/node_modules/**\", \"**/.blume/**\", \"**/dist/**\"],\n onlyFiles: true,\n });\n for (const file of files.toSorted()) {\n const dir = relative(contentRoot, dirname(file));\n const [head] = dir.split(\"/\");\n if (\n head &&\n (localeDirs.has(head.toLowerCase()) || versionDirs.has(head))\n ) {\n continue;\n }\n // oxlint-disable-next-line no-await-in-loop -- sequential, ordered discovery\n const [raw, mod] = await Promise.all([\n readFile(file, \"utf-8\"),\n load(file),\n ]);\n if (isFactoryModule(mod)) {\n diagnostics.push({\n code: \"BLUME_TRANSLATE_META_FACTORY\",\n file,\n message:\n \"This meta file default-exports a function, so `blume translate` cannot generate per-locale copies of it.\",\n severity: \"warning\",\n suggestion:\n \"Export a plain object, or author the locale's meta file by hand.\",\n });\n continue;\n }\n const parsed = folderMetaSchema.safeParse(mod);\n if (!parsed.success || parsed.data.title === undefined) {\n continue;\n }\n metas.push({\n contentRoot,\n data: parsed.data,\n dir: dir === \".\" ? \"\" : dir,\n file,\n raw,\n sourceRel: relative(project.context.root, file),\n title: parsed.data.title,\n });\n }\n }\n return { diagnostics, metas };\n};\n\n/**\n * Emit the per-locale meta module: every source key copied verbatim, only the\n * title swapped for its translation. Keys alphabetical, values as JSON.\n */\nexport const generateMetaModule = (\n meta: FolderMeta,\n translatedTitle: string\n): string => {\n const data = {\n ...meta,\n title: translatedTitle,\n };\n const lines = Object.entries(data)\n .toSorted(([a], [b]) => (a < b ? -1 : 1))\n .filter(([, value]) => value !== undefined)\n .map(([key, value]) => ` ${key}: ${JSON.stringify(value)},`);\n return [\n \"// Generated by `blume translate` — edit the default locale's meta file\",\n \"// and rerun the translation instead of editing this copy.\",\n \"export default {\",\n ...lines,\n \"};\",\n \"\",\n ].join(\"\\n\");\n};\n",
11
- "import type { LocaleConfig } from \"../core/schema.ts\";\n\n/**\n * The frontmatter key paths whose *values* an agent may translate. Everything\n * else in the frontmatter is copied from the source verbatim by the validator,\n * so this list is both the prompt's instruction and the reconciliation\n * contract in `validate.ts`.\n */\nexport const TRANSLATABLE_KEY_PATHS: readonly (readonly string[])[] = [\n [\"title\"],\n [\"description\"],\n [\"sidebar\", \"label\"],\n [\"sidebar\", \"badge\"],\n [\"seo\", \"title\"],\n [\"seo\", \"description\"],\n];\n\n/** \"French (fr)\" — the configured display label plus the code. */\nconst localeName = (locale: LocaleConfig): string =>\n `${locale.label} (${locale.code})`;\n\nconst KEY_LIST = TRANSLATABLE_KEY_PATHS.map((path) => path.join(\".\")).join(\n \", \"\n);\n\n/**\n * The page-translation prompt. Delivered over stdin (no argv limits), so the\n * full source file rides along inline. When the page was translated before,\n * the previous translation rides along too: without it, every retranslation\n * is a from-scratch rewrite in which the agent re-decides register, dialect,\n * and terminology (du vs Sie, pt-BR vs pt-PT) and churns the whole page for\n * a one-paragraph source edit.\n */\nexport const pagePrompt = (\n sourceText: string,\n target: LocaleConfig,\n source: LocaleConfig,\n previousTranslation?: string\n): string => {\n const styleRule =\n target.style === undefined\n ? \"\"\n : `\n- Write the translation in this style: ${target.style}`;\n const previousRule =\n previousTranslation === undefined\n ? \"\"\n : `\n- A translation of an earlier revision of this page is included below. Match its register, formality, dialect, and terminology exactly; re-translate only what the changed source requires and keep everything else word-for-word identical.${\n target.style === undefined\n ? \"\"\n : \" Where the previous translation disagrees with the style rule above, the style rule wins.\"\n }`;\n const previousSection =\n previousTranslation === undefined\n ? \"\"\n : `\nThe previous translation begins after this line and ends at the \"page source\" marker.\n${previousTranslation}`;\n return `Translate the following documentation page from ${localeName(\n source\n )} into ${localeName(target)}.\n\nRules:\n- Translate the prose: headings, paragraphs, list items, table cells, admonitions, and image alt text.\n- In the YAML frontmatter, translate ONLY the values of these keys: ${KEY_LIST}. Copy every other frontmatter key and value exactly as written.\n- Never translate or alter: code blocks, inline code, import/export statements, JSX/MDX component names and their attributes, URLs, link targets, HTML tags, or frontmatter keys.\n- A heading may end with anchor markers: \\`[#some-id]\\`, \\`{#some-id}\\` (also written \\`\\\\{#some-id\\\\}\\`), \\`[!toc]\\`, or \\`[toc]\\`. Copy every marker exactly as written, in the same position at the end of the translated heading — never translate, reorder, or drop a marker, and never change the id inside \\`[#...]\\` or \\`{#...}\\` (anchors must stay identical across languages).\n\n- Preserve the document structure exactly: the same headings, the same lists and tables, and the same number of code fences.${styleRule}${previousRule}\n- Output ONLY the complete translated file. Do not wrap it in a code fence. Do not add commentary before or after it.\n${previousSection}\nThe page source begins after this line.\n${sourceText}`;\n};\n\n/**\n * The sidebar-titles prompt: a JSON object of `{directory: title}` in, the\n * same keys with translated values out.\n */\nexport const metaPrompt = (\n titles: Record<string, string>,\n target: LocaleConfig,\n source: LocaleConfig\n): string => `Translate the following documentation sidebar section titles from ${localeName(\n source\n)} into ${localeName(target)}.\n\nThe input is a JSON object mapping a directory path to its title. Reply with ONLY a JSON object that has exactly the same keys, where each value is the title translated into ${localeName(\n target\n)}. Do not translate the keys. Do not add commentary.${\n target.style === undefined\n ? \"\"\n : `\\nWrite the titles in this style: ${target.style}`\n}\n\n${JSON.stringify(titles, null, 2)}`;\n",
12
- "import { scanBody } from \"../core/sources/normalize.ts\";\n\n/**\n * Keep heading anchors identical across languages. A translated heading slugs\n * to a different id (`## Ordering` → `#ordering`, `## Reihenfolge` →\n * `#reihenfolge`), so a `/guide#ordering` link — which the runtime keeps\n * inside the reader's locale — would land at the top of the translated page.\n * After a translation validates, every heading whose rendered id would differ\n * from its source counterpart gets the source id pinned as a trailing\n * `[#id]` marker, so the anchor index (and every `#fragment` link) agrees in\n * every locale. Headings the translation already pins are left alone: the\n * agent is told to copy markers verbatim, and a hand-authored pin is the\n * translator's choice.\n *\n * Headings pair positionally, so the translation must mirror the source's\n * heading structure (the prompt demands exactly that); when it doesn't, no\n * pins are added and the text is returned unchanged with a reason.\n */\n\nexport interface PinResult {\n /** Number of headings that received a pin. */\n pinned: number;\n /** Why no pins were added, when the structures don't line up. */\n skipped?: string;\n text: string;\n}\n\n/** An ATX heading's optional closing hash run, which a marker must precede. */\nconst ATX_CLOSE = /\\s+#+$/u;\n\nconst structureOf = (headings: readonly { depth: number }[]): string =>\n headings.map((heading) => heading.depth).join(\",\");\n\n/** Append `[#id]` to a heading line, ahead of any closing `##` and line end. */\nconst pinLine = (line: string, id: string): string => {\n const eol = line.endsWith(\"\\r\") ? \"\\r\" : \"\";\n const body = line.slice(0, line.length - eol.length).trimEnd();\n const close = body.match(ATX_CLOSE)?.[0] ?? \"\";\n const head = body.slice(0, body.length - close.length);\n return `${head} [#${id}]${close}${eol}`;\n};\n\nexport const pinHeadingAnchors = (\n sourceText: string,\n translatedText: string\n): PinResult => {\n const source = scanBody(sourceText);\n const translated = scanBody(translatedText);\n if (structureOf(source.headings) !== structureOf(translated.headings)) {\n return {\n pinned: 0,\n skipped: `heading structure differs (source has ${source.headings.length} headings, translation has ${translated.headings.length})`,\n text: translatedText,\n };\n }\n\n const lines = translatedText.split(\"\\n\");\n let pinned = 0;\n for (const [index, heading] of translated.headings.entries()) {\n const site = translated.sites[index];\n const sourceId = source.headings[index]?.slug;\n if (\n !site ||\n site.pinned ||\n sourceId === undefined ||\n heading.slug === sourceId\n ) {\n continue;\n }\n lines[site.line - 1] = pinLine(lines[site.line - 1] ?? \"\", sourceId);\n pinned += 1;\n }\n if (pinned === 0) {\n return { pinned, text: translatedText };\n }\n\n // The pins must reproduce the source ids exactly once rendered; anything\n // else (a heading the line-based rewrite couldn't reach) keeps the text as\n // the agent wrote it rather than shipping a half-pinned page.\n const text = lines.join(\"\\n\");\n const rendered = scanBody(text).headings.map((heading) => heading.slug);\n const expected = source.headings.map((heading) => heading.slug);\n if (rendered.join(\"\\n\") !== expected.join(\"\\n\")) {\n return {\n pinned: 0,\n skipped: \"pinned anchors did not reproduce the source heading ids\",\n text: translatedText,\n };\n }\n return { pinned, text };\n};\n",
13
- "import matter from \"../core/frontmatter.ts\";\nimport { pinHeadingAnchors } from \"./anchors.ts\";\nimport { TRANSLATABLE_KEY_PATHS } from \"./prompts.ts\";\n\n/**\n * Structural validation of agent output. The agent is never trusted for\n * structure: the final frontmatter is *reconstructed* from the source (clone\n * the source data, overlay only the translatable string values), so invented\n * keys are dropped, deleted keys are restored, and slugs/icons/orders/dates\n * stay source-verbatim by construction. Only then is the file written.\n */\n\nexport type ValidationResult =\n | { ok: true; text: string }\n | { ok: false; reason: string };\n\n/**\n * A parsed YAML frontmatter value (agent meta replies parse from JSON into the\n * same shape). js-yaml can also mint Dates and other rich scalars; the\n * traversal below only ever distinguishes \"keyed object\" from \"string\", so\n * they ride along as the object arm.\n */\ntype FrontmatterValue =\n | string\n | number\n | boolean\n | null\n | FrontmatterValue[]\n | FrontmatterData;\n\ninterface FrontmatterData {\n [key: string]: FrontmatterValue;\n}\n\nconst FRONTMATTER_OPEN = /^---\\r?\\n/u;\nconst FENCE_LINE = /^\\s*(?:```|~~~)/u;\n\n/**\n * Strip exactly one symmetric outer code fence (any info string) — the one\n * wrapper agents add despite being told not to. Anything else (no fence, or a\n * fence that isn't the entire output) is returned trimmed and untouched.\n */\nexport const stripOuterFence = (text: string): string => {\n const trimmed = text.trim();\n const match = trimmed.match(\n /^(?<fence>`{3,}|~{3,})[^\\n]*\\n(?<inner>[\\s\\S]*?)\\n\\k<fence>\\s*$/u\n );\n return match?.groups?.inner ?? trimmed;\n};\n\n/** Lines opening or closing a code fence; their count must survive translation. */\nconst countFenceLines = (text: string): number =>\n text.split(\"\\n\").filter((line) => FENCE_LINE.test(line)).length;\n\nconst isKeyedObject = (\n value: FrontmatterValue | undefined\n): value is FrontmatterData => typeof value === \"object\" && value !== null;\n\nconst isString = (value: FrontmatterValue | undefined): value is string =>\n typeof value === \"string\";\n\nconst getPath = (\n data: FrontmatterValue,\n path: readonly string[]\n): FrontmatterValue | undefined => {\n let value: FrontmatterValue | undefined = data;\n for (const key of path) {\n if (!isKeyedObject(value)) {\n return;\n }\n value = value[key];\n }\n return value;\n};\n\n/** Set `path` on `data`; only called for paths whose parents exist in `data`. */\nconst setPath = (\n data: FrontmatterData,\n path: readonly string[],\n value: string\n): void => {\n let parent = data;\n for (const key of path.slice(0, -1)) {\n // SAFETY: callers only set paths that getPath already resolved to a string\n // on this same (cloned) data, so every intermediate step is a keyed object.\n parent = parent[key] as FrontmatterData;\n }\n // SAFETY: every TRANSLATABLE_KEY_PATHS entry is a non-empty tuple, so the\n // path always has a final key.\n parent[path.at(-1) as string] = value;\n};\n\nconst ensureTrailingNewline = (text: string): string =>\n text.endsWith(\"\\n\") ? text : `${text}\\n`;\n\n/**\n * Validate one translated page against its source and reassemble the file to\n * write. Fails (no write happens) on empty output, unparseable or missing\n * frontmatter, an empty body, or a changed code-fence count.\n */\nexport const validateTranslation = (\n sourceText: string,\n agentText: string\n): ValidationResult => {\n // Only a fence the agent added is stripped. A source that is itself one\n // code block (a frontmatter-less partial holding a single bash block)\n // starts and ends with its own fence, which the translation must keep — so\n // for such a source the reply loses its outer fence only when it has more\n // fence lines than the source.\n const sourceIsFenced = stripOuterFence(sourceText) !== sourceText.trim();\n const candidate =\n sourceIsFenced && countFenceLines(agentText) <= countFenceLines(sourceText)\n ? agentText.trim()\n : stripOuterFence(agentText);\n if (candidate === \"\") {\n return { ok: false, reason: \"agent returned empty output\" };\n }\n\n const sourceHasFrontmatter = FRONTMATTER_OPEN.test(sourceText);\n const source = matter(sourceText);\n\n if (sourceHasFrontmatter && !FRONTMATTER_OPEN.test(candidate)) {\n return {\n ok: false,\n reason: \"translation dropped the frontmatter (must start with ---)\",\n };\n }\n\n let parsed: { content: string; data: FrontmatterData };\n try {\n parsed = matter(candidate);\n } catch {\n return { ok: false, reason: \"frontmatter does not parse as YAML\" };\n }\n\n const rawBody = ensureTrailingNewline(parsed.content.replace(/^\\r?\\n/u, \"\"));\n if (rawBody.trim() === \"\") {\n return { ok: false, reason: \"translation has an empty body\" };\n }\n\n const sourceFences = countFenceLines(source.content);\n const candidateFences = countFenceLines(rawBody);\n if (sourceFences !== candidateFences) {\n return {\n ok: false,\n reason: `code fence count changed (source has ${sourceFences}, translation has ${candidateFences})`,\n };\n }\n\n // Anchors stay identical across languages: each translated heading is\n // pinned to its source heading's id (see `anchors.ts`).\n const body = pinHeadingAnchors(source.content, rawBody).text;\n\n if (!sourceHasFrontmatter) {\n // A frontmatter-less source writes the body alone; any frontmatter the\n // agent invented is dropped with it.\n return { ok: true, text: body };\n }\n\n // Reconciliation by reconstruction: start from the SOURCE data and overlay\n // only the translatable key paths where both sides hold a string and the\n // translation is non-empty.\n const data: FrontmatterData = structuredClone(source.data);\n for (const path of TRANSLATABLE_KEY_PATHS) {\n const original = getPath(source.data, path);\n const translated = getPath(parsed.data, path);\n if (\n isString(original) &&\n isString(translated) &&\n translated.trim() !== \"\"\n ) {\n setPath(data, path, translated);\n }\n }\n\n return {\n ok: true,\n text: ensureTrailingNewline(matter.stringify(body, data)),\n };\n};\n\n/** A meta-batch parse: recovered titles by key, plus the keys still missing. */\nexport interface MetaTitlesResult {\n titles: Record<string, string>;\n missing: string[];\n}\n\n/**\n * Extract translated sidebar titles from a meta reply: tolerant first-`{`\n * to-last-`}` extraction (the eval `parseVerdict` idiom). Keys missing or\n * non-string in the reply land in `missing`, so a batch can partially succeed.\n */\nexport const parseMetaTitles = (\n agentText: string,\n expectedKeys: readonly string[]\n): MetaTitlesResult => {\n const start = agentText.indexOf(\"{\");\n const end = agentText.lastIndexOf(\"}\");\n let parsed: FrontmatterValue | undefined;\n if (start !== -1 && end > start) {\n try {\n parsed = JSON.parse(agentText.slice(start, end + 1));\n } catch {\n parsed = undefined;\n }\n }\n const record: FrontmatterData = isKeyedObject(parsed) ? parsed : {};\n\n const titles: Record<string, string> = {};\n const missing: string[] = [];\n for (const key of expectedKeys) {\n const value = record[key];\n if (isString(value) && value.trim() !== \"\") {\n titles[key] = value;\n } else {\n missing.push(key);\n }\n }\n return { missing, titles };\n};\n",
14
- "import { existsSync, readdirSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\n\nimport { dirname, extname, join, relative } from \"pathe\";\n\nimport { localeCodes, localeTargetPath } from \"../core/i18n.ts\";\nimport { scanProject } from \"../core/project-graph.ts\";\nimport type { BlumeProject } from \"../core/project-graph.ts\";\nimport type { Diagnostic, PageRecord } from \"../core/types.ts\";\nimport { hashSource } from \"./ledger.ts\";\nimport type { TranslationLedger } from \"./ledger.ts\";\nimport { discoverTranslatableMeta, metaTargetPath } from \"./meta.ts\";\nimport type { TranslatableMeta } from \"./meta.ts\";\n\n/**\n * Classification of every (source, target locale) pair:\n * - `missing` — no non-fallback page record for (translationKey, locale).\n * Existence is the graph record, never a disk probe, so a hand-authored\n * translation at a non-canonical name still counts as existing.\n * - `stale` — a record exists, but the ledger hash differs from the current\n * source hash (the source changed since its last translation).\n * - up-to-date — hashes match (counted, not itemized).\n * - untracked — a record exists with no ledger entry: a pre-existing human\n * translation. Adopted (stamped at the current hash), never overwritten;\n * only `--force` retranslates it.\n */\nexport type WorkStatus = \"missing\" | \"stale\";\n\nexport interface PageWorkItem {\n kind: \"page\";\n /** Target locale code (configured casing). */\n locale: string;\n /** Absolute path of the default-locale source file. */\n sourcePath: string;\n /** POSIX root-relative source path — the ledger key. */\n sourceRel: string;\n status: WorkStatus;\n /** Absolute canonical target path (`localeTargetPath`). */\n targetPath: string;\n /** POSIX root-relative target path, for display. */\n targetRel: string;\n /** Copy the file unchanged instead of translating it — a non-markdown\n * include partial (code embed) has no prose, but must still exist in each\n * locale tree so the translated pages' relative includes resolve. */\n verbatim?: boolean;\n}\n\n/** One meta file needing its title in one locale, inside a `MetaWorkItem`. */\nexport interface MetaWorkEntry {\n meta: TranslatableMeta;\n status: WorkStatus;\n /** Absolute path of the generated per-locale `meta.ts`. */\n targetPath: string;\n}\n\n/** All of one locale's needed meta titles — a single agent call. */\nexport interface MetaWorkItem {\n kind: \"meta\";\n entries: MetaWorkEntry[];\n locale: string;\n}\n\nexport type WorkItem = MetaWorkItem | PageWorkItem;\n\n/** A pre-existing translation with no ledger entry, to adopt (stamp) as-is. */\nexport interface UntrackedEntry {\n /** The current source hash to stamp. */\n hash: string;\n kind: \"meta\" | \"page\";\n locale: string;\n sourceRel: string;\n}\n\nexport interface TranslateWorkList {\n diagnostics: Diagnostic[];\n items: WorkItem[];\n /** Every ledger key in the current universe (for pruning). */\n knownSources: Set<string>;\n /** The locales this run targets (configured casing, default excluded). */\n targetLocales: string[];\n untracked: UntrackedEntry[];\n /** Count of (source, locale) pairs already translated and current. */\n upToDate: number;\n}\n\nconst PAGE_EXTENSIONS = new Set([\".md\", \".mdx\"]);\n\n/**\n * The names in each content root, read once per root: a locale folder authored\n * in another casing (`pt-br/` for `pt-BR`) is where `localeTargetPath` puts\n * that locale's translations.\n */\nconst rootFolders = (): ((contentRoot: string) => string[]) => {\n const read = new Map<string, string[]>();\n return (contentRoot) => {\n const cached = read.get(contentRoot);\n if (cached) {\n return cached;\n }\n const names = readdirSync(contentRoot);\n read.set(contentRoot, names);\n return names;\n };\n};\n\n/**\n * Scan the project for a translation run: drafts included. A production\n * (`build`) scan drops them, so a hand-written translation marked\n * `draft: true` would look missing and be overwritten, and a source page\n * drafted for a while would lose its ledger stamps — its outdated\n * translations then reading as current once it's published again. A dev scan\n * keeps drafts and differs only in reusing cached remote content, which\n * translation never reads.\n */\nexport const scanForTranslation = (root: string): Promise<BlumeProject> =>\n scanProject(root, { mode: \"dev\" });\n\n/**\n * The translatable page universe: filesystem-backed default-locale pages.\n * Remote/staged sources have no writable path; fallback records are padding;\n * a `.$.` shared file already materializes into every locale.\n */\nconst translatablePages = (\n project: BlumeProject,\n i18n: NonNullable<BlumeProject[\"config\"][\"i18n\"]>\n): {\n page: PageRecord;\n contentRoot: string;\n ext: string;\n sourcePath: string;\n}[] => {\n const rootsByName = new Map(\n project.sources.flatMap((source) =>\n source.staged || !source.contentRoot\n ? []\n : [[source.name, source.contentRoot] as const]\n )\n );\n const seen = new Set<string>();\n const universe: {\n page: PageRecord;\n contentRoot: string;\n ext: string;\n sourcePath: string;\n }[] = [];\n for (const page of project.graph.pages) {\n if (\n page.locale !== i18n.defaultLocale ||\n page.fallback ||\n !page.sourcePath ||\n seen.has(page.sourcePath) ||\n // Archived snapshots are frozen and carry their own translations —\n // they are never (re)translated. (`localeTargetPath` would also compute\n // `fr/v1.0/…` where the snapshot's translation lives at `v1.0/fr/…`.)\n page.version !== \"\"\n ) {\n continue;\n }\n const ext = extname(page.sourcePath);\n const base = page.sourcePath.slice(0, page.sourcePath.length - ext.length);\n const contentRoot = rootsByName.get(page.source.name);\n if (!PAGE_EXTENSIONS.has(ext) || base.endsWith(\".$\") || !contentRoot) {\n continue;\n }\n seen.add(page.sourcePath);\n universe.push({ contentRoot, ext, page, sourcePath: page.sourcePath });\n }\n return universe;\n};\n\n/** Outcome of classifying one (source, locale) pair against the ledger:\n * a work status, an existing translation to adopt, or already current. */\ntype PairOutcome = WorkStatus | \"current\" | \"untracked\";\n\n/** The shared pair classifier — see the WorkStatus doc for the taxonomy. */\nconst classifyPair = (\n exists: boolean,\n stamp: string | undefined,\n hash: string,\n force: boolean\n): PairOutcome => {\n if (!exists) {\n return \"missing\";\n }\n if (stamp === undefined) {\n return force ? \"stale\" : \"untracked\";\n }\n return stamp !== hash || force ? \"stale\" : \"current\";\n};\n\n/** The classified work for the include partials the pages reference. */\ninterface PartialWork {\n items: PageWorkItem[];\n /** Ledger keys to add to the run's known-source universe. */\n sources: string[];\n untracked: UntrackedEntry[];\n upToDate: number;\n}\n\n/**\n * Work for the include partials referenced by the translatable pages. Under\n * the `dir` parser each locale is its own tree, so a translated page's\n * relative `<include>` resolves *inside the locale tree* — the partial must\n * exist there too, or the next build fails with BLUME_INCLUDE_NOT_FOUND on\n * every locale. (Under `dot` the translated file sits beside its source and\n * the shared partial already resolves; nothing to do.) Markdown partials are\n * translated like pages; anything else (code embeds) is copied verbatim. A\n * partial that is itself a page is skipped — its own translation already\n * lands at the mirrored path. Existence is a disk probe: partials have no\n * page records to consult.\n */\nconst partialWorkItems = async (\n universe: ReturnType<typeof translatablePages>,\n project: BlumeProject,\n i18n: NonNullable<BlumeProject[\"config\"][\"i18n\"]>,\n ledger: TranslationLedger,\n targetLocales: string[],\n force: boolean\n): Promise<PartialWork> => {\n const work: PartialWork = {\n items: [],\n sources: [],\n untracked: [],\n upToDate: 0,\n };\n if (i18n.parser !== \"dir\") {\n return work;\n }\n const { root } = project.context;\n const pagePaths = new Set(\n project.graph.pages.flatMap((page) =>\n page.sourcePath ? [page.sourcePath] : []\n )\n );\n const folders = rootFolders();\n const partials = new Map<string, string>();\n for (const { page, contentRoot } of universe) {\n for (const partial of page.includes ?? []) {\n if (!(pagePaths.has(partial) || partials.has(partial))) {\n partials.set(partial, contentRoot);\n }\n }\n }\n for (const [partialPath, contentRoot] of partials) {\n const sourceRel = relative(root, partialPath);\n work.sources.push(sourceRel);\n // oxlint-disable-next-line no-await-in-loop -- one read per partial\n const hash = hashSource(await readFile(partialPath, \"utf-8\"));\n const ext = extname(partialPath);\n const verbatim = !PAGE_EXTENSIONS.has(ext.toLowerCase());\n const contentRel = relative(contentRoot, partialPath);\n for (const locale of targetLocales) {\n const targetPath = join(\n contentRoot,\n localeTargetPath(contentRel, ext, locale, i18n, folders(contentRoot))\n );\n const item = (status: WorkStatus): PageWorkItem => {\n const partialItem: PageWorkItem = {\n kind: \"page\",\n locale,\n sourcePath: partialPath,\n sourceRel,\n status,\n targetPath,\n targetRel: relative(root, targetPath),\n };\n if (verbatim) {\n partialItem.verbatim = true;\n }\n return partialItem;\n };\n const stamp = ledger.files[sourceRel]?.[locale];\n const outcome = classifyPair(existsSync(targetPath), stamp, hash, force);\n if (outcome === \"untracked\") {\n work.untracked.push({ hash, kind: \"page\", locale, sourceRel });\n } else if (outcome === \"current\") {\n work.upToDate += 1;\n } else {\n work.items.push(item(outcome));\n }\n }\n }\n return work;\n};\n\n/**\n * Compute the run's work: which (source, locale) pairs are missing or stale,\n * which existing translations to adopt, and what's already up to date.\n * `force` promotes every pair to work; `locales` narrows the targets.\n */\nexport const computeWorkList = async (\n project: BlumeProject,\n ledger: TranslationLedger,\n options: { force?: boolean; locales?: string[] } = {}\n): Promise<TranslateWorkList> => {\n const { i18n } = project.config;\n if (!i18n) {\n return {\n diagnostics: [],\n items: [],\n knownSources: new Set(),\n targetLocales: [],\n untracked: [],\n upToDate: 0,\n };\n }\n const targetLocales = localeCodes(i18n).filter(\n (code) =>\n code !== i18n.defaultLocale &&\n (options.locales === undefined || options.locales.includes(code))\n );\n\n const translated = new Set(\n project.graph.pages.flatMap((page) =>\n page.fallback ? [] : [`${page.translationKey}\u0000${page.locale}`]\n )\n );\n\n const { root } = project.context;\n const knownSources = new Set<string>();\n const untracked: UntrackedEntry[] = [];\n const pageItems: PageWorkItem[] = [];\n let upToDate = 0;\n\n const universe = translatablePages(project, i18n);\n const folders = rootFolders();\n\n for (const { page, contentRoot, ext, sourcePath } of universe) {\n const sourceRel = relative(root, sourcePath);\n knownSources.add(sourceRel);\n // oxlint-disable-next-line no-await-in-loop -- one read per source file\n const hash = hashSource(await readFile(sourcePath, \"utf-8\"));\n const contentRel = relative(contentRoot, sourcePath);\n\n for (const locale of targetLocales) {\n const targetPath = join(\n contentRoot,\n localeTargetPath(contentRel, ext, locale, i18n, folders(contentRoot))\n );\n const item = (status: WorkStatus): PageWorkItem => ({\n kind: \"page\",\n locale,\n sourcePath,\n sourceRel,\n status,\n targetPath,\n targetRel: relative(root, targetPath),\n });\n const exists = translated.has(`${page.translationKey}\u0000${locale}`);\n const stamp = ledger.files[sourceRel]?.[locale];\n const outcome = classifyPair(exists, stamp, hash, options.force === true);\n if (outcome === \"untracked\") {\n untracked.push({ hash, kind: \"page\", locale, sourceRel });\n } else if (outcome === \"current\") {\n upToDate += 1;\n } else {\n pageItems.push(item(outcome));\n }\n }\n }\n\n const partialWork = await partialWorkItems(\n universe,\n project,\n i18n,\n ledger,\n targetLocales,\n options.force ?? false\n );\n for (const rel of partialWork.sources) {\n knownSources.add(rel);\n }\n pageItems.push(...partialWork.items);\n untracked.push(...partialWork.untracked);\n upToDate += partialWork.upToDate;\n\n const meta = await discoverTranslatableMeta(project);\n const metaItems: MetaWorkItem[] = [];\n for (const locale of targetLocales) {\n const entries: MetaWorkEntry[] = [];\n for (const source of meta.metas) {\n knownSources.add(source.sourceRel);\n const targetDir = dirname(metaTargetPath(source, locale));\n const exists = [\"meta.ts\", \"meta.js\", \"meta.mjs\"].some((name) =>\n existsSync(join(targetDir, name))\n );\n const hash = hashSource(source.raw);\n const stamp = ledger.files[source.sourceRel]?.[locale];\n const entry = (status: WorkStatus): MetaWorkEntry => ({\n meta: source,\n status,\n targetPath: metaTargetPath(source, locale),\n });\n const outcome = classifyPair(exists, stamp, hash, options.force === true);\n if (outcome === \"untracked\") {\n untracked.push({\n hash,\n kind: \"meta\",\n locale,\n sourceRel: source.sourceRel,\n });\n } else if (outcome === \"current\") {\n upToDate += 1;\n } else {\n entries.push(entry(outcome));\n }\n }\n if (entries.length > 0) {\n metaItems.push({ entries, kind: \"meta\", locale });\n }\n }\n\n pageItems.sort((a, b) =>\n a.sourceRel === b.sourceRel\n ? a.locale.localeCompare(b.locale)\n : a.sourceRel.localeCompare(b.sourceRel)\n );\n metaItems.sort((a, b) => a.locale.localeCompare(b.locale));\n\n return {\n diagnostics: meta.diagnostics,\n items: [...pageItems, ...metaItems],\n knownSources,\n targetLocales,\n untracked,\n upToDate,\n };\n};\n"
15
- ],
16
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;ACiBO,IAAM,+BAA+B;AAE5C,IAAM,aAAa,MAAgB;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,iBAAiB,KAAK,GAAG;AAAA,EACzB;AAAA,EACA;AACF;AAMA,IAAM,YAAY,CAAC,oBAAsC;AAAA,EACvD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AAAA,EACH;AAAA,EACA;AAAA,EACA;AACF;AAOO,IAAM,qBAAqB,CAChC,MACA,oBACc,SAAS,WAAW,WAAW,IAAI,UAAU,eAAe;;;ACvD5E;AACA;AAEA;AACA;AAYO,IAAM,cAAc;AAW3B,IAAM,eAAe,EAAE,OAAO;AAAA,EAC5B,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC;AAAA,EAC5D,SAAS,EAAE,QAAQ,CAAC;AACtB,CAAC;AAEM,IAAM,cAAc,OAA0B;AAAA,EACnD,OAAO,CAAC;AAAA,EACR,SAAS;AACX;AAWO,IAAM,aAAa,CAAC,SACzB,WAAW,QAAQ,EAChB,OAAO,KAAK,WAAW;AAAA,GAAQ;AAAA,CAAI,CAAC,EACpC,OAAO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,WAAW,KAAK;AAAA,QAGhD,eAAe,MAAM,YAAY,MAAM,MAAM;AAAA,QAC7C;AAAA,QACA,WAAW,WAAW;AAAA,QACtB;AAAA,MACF,CAAC;AAAA,MACD,SAAS,KAAK;AAAA,MAKd,MAAM,eAAe,IAAI,IACvB,YAAY,IAAI,EAAE,OAAO,CAAC,SAAS,SAAS,KAAK,aAAa,CAChE;AAAA,MACA,MAAM,YACJ,MACA,YAAY,QAAQ,SAAS,cAAc,YAAY,CACzD;AAAA,MAEA,MAAM,OAAO;AAAA,QACX;AAAA,QACA,GAAG,gBAAgB,SAAS,WAAW;AAAA,QACvC,KAAK,qBAAqB,QAAQ,QAAQ;AAAA,QAC1C;AAAA,MACF;AAAA,MACA,QAAQ,OAAO,MAAM,KAAK,KAAK;AAAA,CAAI,CAAC;AAAA,MAEpC,IAAI,KAAK,MAAM;AAAA,QACb,QAAQ,OAAO,MAAM,oBAAoB,QAAQ,QAAQ,CAAC;AAAA,MAC5D;AAAA,MACA,IAAI,OAAO,OAAO,SAAS,KAAK,OAAO,OAAO,UAAU,GAAG;AAAA,QAGzD,MAAM,YAAY;AAAA,QAClB,QAAQ,KAAK,CAAC;AAAA,MAChB;AAAA,MACA,OAAO,OAAO;AAAA,MACd,IAAI,iBAAiB,YAAY;AAAA,QAC/B,kBAAkB,CAAC,MAAM,UAAU,GAAG,IAAI;AAAA,QAC1C,QAAQ,KAAK,CAAC;AAAA,MAChB;AAAA,MAGA,IAAK,OAAiC,SAAS,YAAY,OAAO;AAAA,QAChE,aAAa,KAAK;AAAA,MACpB;AAAA,MACA,oBAAoB,KAAK;AAAA,MACzB,QAAQ,KAAK,CAAC;AAAA;AAAA;AAGpB,CAAC;",
17
- "debugId": "85D111C5AFB273C164756E2164756E21",
18
- "names": []
19
- }
@@ -1,10 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/upgrade/upgrade.ts"],
4
- "sourcesContent": [
5
- "import { existsSync } from \"node:fs\";\nimport { readFile, writeFile } from \"node:fs/promises\";\n\nimport { join, relative, resolve } from \"pathe\";\nimport { glob } from \"tinyglobby\";\nimport { z } from \"zod\";\n\nimport {\n analyzeComponentOverrides,\n ComponentOverridesError,\n} from \"../core/component-overrides.ts\";\nimport { ConfigValidationError, loadConfig } from \"../core/config.ts\";\nimport { BlumeError, locateFrontmatterKey } from \"../core/diagnostics.ts\";\nimport matter from \"../core/frontmatter.ts\";\nimport { createModuleLoader } from \"../core/load-module.ts\";\nimport { findComponentsFile, findConfigFile } from \"../core/project.ts\";\nimport { pageMetaSchema } from \"../core/schema.ts\";\nimport { baselineScanIgnore } from \"../core/sources/watch.ts\";\nimport type { Diagnostic } from \"../core/types.ts\";\nimport {\n DEFAULT_CONTENT_EXCLUDE,\n DEFAULT_CONTENT_INCLUDE,\n} from \"../sources/filesystem.ts\";\n\n/**\n * `blume upgrade`'s logic, kept out of the command module so it runs (and is\n * covered) in-process: bump the `blume` dependency to the running CLI's major,\n * then check the project against it — the config through the same loader\n * every command uses, which names each removed or renamed field and its\n * replacement, `components.ts` through the same static planner the build\n * runs, and each page's front matter for fields the schema removed. The\n * command prints the findings or hands them to a coding agent.\n */\n\n/** The upgrade guide's route on the Blume docs site. */\nexport const UPGRADE_GUIDE_URL = \"https://useblume.dev/docs/upgrading\";\n\n/** The upgrade guide's file inside the published package's bundled docs. */\nexport const UPGRADE_GUIDE_FILE = join(\"docs\", \"03-upgrading.mdx\");\n\n/** What `bumpBlumeDependency` did to `package.json`. */\nexport type DependencyBump =\n | {\n field: DependencyField;\n from: string;\n status: \"bumped\";\n to: string;\n }\n | { range: string; status: \"current\" }\n | { range: string; status: \"manual\" }\n | { status: \"missing\" };\n\ntype DependencyField = \"dependencies\" | \"devDependencies\";\n\nconst DEPENDENCY_FIELDS: DependencyField[] = [\n \"dependencies\",\n \"devDependencies\",\n];\n\n/** The slice of `package.json` the bump reads and rewrites. */\ninterface PackageJson {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n}\n\n// Leading comparators and a `v` may precede the major (`^1.7.3`, `>=1 <2`,\n// `v1`); a protocol (`workspace:`, `file:`, `npm:`) or a tag (`latest`) names\n// no major at all, and those ranges are left to the user.\nconst RANGE_MAJOR = /^[\\s<=>^~v]*(?<major>\\d+)/u;\n\n/** The major version a dependency range pins, or null when it names none. */\nexport const rangeMajor = (range: string): number | null => {\n const major = RANGE_MAJOR.exec(range)?.groups?.major;\n return major === undefined ? null : Number(major);\n};\n\n// Ranges whose version lives somewhere the bump doesn't rewrite: a pnpm\n// catalog in pnpm-workspace.yaml, or the `range` of an `npm:name@range` alias.\nconst CATALOG_RANGE = /^catalog:(?<name>.*)$/u;\nconst NPM_ALIAS = /^npm:.+@(?<range>[^@]*)$/u;\n\n/**\n * What to change by hand for a `blume` range the bump can't rewrite (a\n * `manual` {@link DependencyBump}): the pnpm catalog entry it points at, or\n * the version inside its `npm:` alias.\n */\nexport const manualBumpAdvice = (range: string, version: string): string => {\n const catalog = CATALOG_RANGE.exec(range)?.groups?.name;\n if (catalog === undefined) {\n return `package.json installs blume through the alias \\`${range}\\`, which \\`blume upgrade\\` doesn't rewrite: set the alias's version to ^${version}, then reinstall.`;\n }\n const entry =\n catalog === \"\" || catalog === \"default\"\n ? \"`catalog`\"\n : `\\`catalogs.${catalog}\\``;\n return `package.json takes blume from the pnpm catalog (\\`${range}\\`), which \\`blume upgrade\\` can't bump: set blume to ^${version} under ${entry} in pnpm-workspace.yaml if it isn't already, then reinstall.`;\n};\n\n// The file's own indentation (two spaces, four, or a tab), so a fallback\n// rewrite doesn't reformat a package.json the user keeps differently.\nconst INDENT = /^(?<indent>[ \\t]+)\"/mu;\n\nconst REGEXP_SPECIAL = /[$()*+.?[\\\\\\]^{|}]/gu;\nconst escapeRegExp = (value: string): string =>\n value.replaceAll(REGEXP_SPECIAL, String.raw`\\$&`);\n\n/**\n * `text` with the `blume` range under `field` replaced in place, so the file\n * keeps its own formatting, key order, and inline objects; null when the entry\n * isn't written the plain way (an escaped key or value).\n */\nconst replaceRange = (\n text: string,\n field: DependencyField,\n from: string,\n to: string\n): string | null => {\n const value = JSON.stringify(from);\n const entry = new RegExp(`\"blume\"\\\\s*:\\\\s*${escapeRegExp(value)}`, \"gu\");\n entry.lastIndex = Math.max(text.indexOf(JSON.stringify(field)), 0);\n const match = entry.exec(text);\n if (!match) {\n return null;\n }\n const end = match.index + match[0].length;\n return `${text.slice(0, end - value.length)}${JSON.stringify(to)}${text.slice(end)}`;\n};\n\n/**\n * Point `package.json`'s `blume` dependency at `^version` when it pins an\n * older major. A range already on this major, or one that names no version\n * (`workspace:*`, `latest`), is reported as current and left alone; one whose\n * version lives elsewhere (`catalog:`, an `npm:` alias of an older major) is\n * `manual`, for the user to change; a project with no `package.json`, or none\n * that lists `blume`, is `missing`. Only the range changes: the rest of the\n * file is kept byte for byte.\n */\nexport const bumpBlumeDependency = async (\n root: string,\n version: string\n): Promise<DependencyBump> => {\n const path = join(root, \"package.json\");\n if (!existsSync(path)) {\n return { status: \"missing\" };\n }\n const text = await readFile(path, \"utf-8\");\n // SAFETY: package.json is a JSON object; only its dependency maps, which\n // map package names to range strings, are read.\n const pkg = JSON.parse(text) as PackageJson;\n const field = DEPENDENCY_FIELDS.find(\n (name) => pkg[name]?.blume !== undefined\n );\n const from = field ? pkg[field]?.blume : undefined;\n if (!(field && from)) {\n return { status: \"missing\" };\n }\n if (CATALOG_RANGE.test(from)) {\n return { range: from, status: \"manual\" };\n }\n const aliased = NPM_ALIAS.exec(from)?.groups?.range;\n const current = rangeMajor(aliased ?? from);\n const target = rangeMajor(version);\n if (current === null || target === null || current >= target) {\n return { range: from, status: \"current\" };\n }\n if (aliased !== undefined) {\n return { range: from, status: \"manual\" };\n }\n const to = `^${version}`;\n const indent = INDENT.exec(text)?.groups?.indent ?? \" \";\n const updated = { ...pkg, [field]: { ...pkg[field], blume: to } };\n await writeFile(\n path,\n replaceRange(text, field, from, to) ??\n `${JSON.stringify(updated, null, indent)}\\n`\n );\n return { field, from, status: \"bumped\", to };\n};\n\n/**\n * Whether `root` is no Blume project at all: no config file and no `blume`\n * dependency, so the upgrade would only check the defaults and report the\n * folder ready. A zero-config project still lists `blume`.\n */\nexport const isOutsideBlumeProject = (\n root: string,\n bump: DependencyBump\n): boolean => bump.status === \"missing\" && findConfigFile(root) === null;\n\n// ---------------------------------------------------------------------------\n// Removed `blume build` flags\n// ---------------------------------------------------------------------------\n\n/** A `blume build` flag Blume 2 removed, bare or with an `=value`. */\nconst REMOVED_BUILD_FLAG = /^--(?<flag>adapter|base|output)(?:=|$)/u;\n\n/** The removed `blume build` flags among `args`, in order, each once. */\nexport const removedBuildFlags = (args: readonly string[]): string[] => [\n ...new Set(\n args.flatMap((arg) => {\n const flag = REMOVED_BUILD_FLAG.exec(arg)?.groups?.flag;\n return flag ? [flag] : [];\n })\n ),\n];\n\n/** The flags as the reader typed them: `--adapter, --output`. */\nexport const flagList = (flags: string[]): string =>\n flags.map((flag) => `--${flag}`).join(\", \");\n\n/** What replaces each removed flag: the `deployment` config. */\nexport const removedBuildFlagsAdvice = (flags: string[]): string => {\n const advice: string[] = [];\n if (flags.includes(\"adapter\") || flags.includes(\"output\")) {\n advice.push(\n 'name the host in blume.config.ts with `deployment: vercel()` (or `netlify()`, `cloudflare()`, `node()`) from \"blume/deploy\" — a host adapter builds for the server, and `output: \"static\"` keeps it static'\n );\n }\n if (flags.includes(\"base\")) {\n advice.push(\n 'set the subpath with `deployment: { base: \"/docs\" }`, or the host adapter\\'s `base` option'\n );\n }\n return `Drop ${flagList(flags)} and ${advice.join(\"; \")}.`;\n};\n\n// A command that runs the Blume CLI: the bare bin, a versioned package\n// (`blume@2`), or a path to it (`./node_modules/.bin/blume`).\nconst BLUME_BIN = /(?:^|[/\\\\])blume(?:@\\S+)?$/u;\nconst COMMAND_SEPARATOR = /&&|\\|\\||[;|]/u;\nconst WHITESPACE = /\\s+/u;\n\n/** The arguments each `blume build` in a script passes, flattened. */\nconst buildArgs = (script: string): string[] =>\n script.split(COMMAND_SEPARATOR).flatMap((command) => {\n const words = command.trim().split(WHITESPACE);\n const at = words.findIndex(\n (word, index) => BLUME_BIN.test(word) && words[index + 1] === \"build\"\n );\n return at === -1 ? [] : words.slice(at + 2);\n });\n\n/** The slice of package.json the script check reads. */\nconst scriptsSchema = z.looseObject({\n scripts: z.record(z.string(), z.string()).default({}),\n});\n\nconst lineOf = (text: string, index: number): number =>\n text.slice(0, index).split(\"\\n\").length;\n\n/**\n * A finding for each package.json script that still passes a removed flag to\n * `blume build` — it would otherwise build a static site without a word.\n */\nconst scriptFindings = async (root: string): Promise<Diagnostic[]> => {\n const path = join(root, \"package.json\");\n if (!existsSync(path)) {\n return [];\n }\n const text = await readFile(path, \"utf-8\");\n const pkg = scriptsSchema.safeParse(JSON.parse(text));\n const scripts = pkg.success ? pkg.data.scripts : {};\n const scriptsAt = text.indexOf('\"scripts\"');\n return Object.entries(scripts).flatMap(([name, script]) => {\n const flags = removedBuildFlags(buildArgs(script));\n if (flags.length === 0) {\n return [];\n }\n const at = text.indexOf(JSON.stringify(name), scriptsAt);\n return [\n {\n code: \"BLUME_BUILD_FLAG_REMOVED\",\n file: path,\n line: at === -1 ? undefined : lineOf(text, at),\n message: `The \"${name}\" script passes ${flagList(flags)} to \\`blume build\\`, which Blume 2 removed.`,\n severity: \"error\",\n suggestion: removedBuildFlagsAdvice(flags),\n } satisfies Diagnostic,\n ];\n });\n};\n\n// ---------------------------------------------------------------------------\n// Removed front matter fields\n// ---------------------------------------------------------------------------\n\n/** Where a project's local content lives, as its config names it. */\ninterface ContentGlobs {\n exclude: string[];\n include: string[];\n root: string;\n}\n\nconst globFields = {\n exclude: z.array(z.string()).optional(),\n include: z.array(z.string()).optional(),\n root: z.string().optional(),\n};\n\n/**\n * A filesystem source in either form a config being upgraded may hold: the\n * `filesystem()` descriptor, or Blume 1's `{ type: \"filesystem\" }` object.\n */\nconst rawFilesystemSourceSchema = z.union([\n z\n .looseObject({\n kind: z.literal(\"filesystem\"),\n options: z.looseObject(globFields).default({}),\n })\n .transform((source) => source.options),\n z.looseObject({ type: z.literal(\"filesystem\"), ...globFields }),\n]);\n\n/** The `content` slice of a config as written, before validation. */\nconst rawContentSchema = z.looseObject({\n content: z\n .looseObject({ ...globFields, sources: z.array(z.unknown()).optional() })\n .optional(),\n});\n\n/**\n * The content roots to scan, read from the config as written rather than the\n * validated config: the upgrade runs on configs that don't validate yet. Its\n * filesystem sources when it lists any, else the `content.root` shorthand,\n * else the zero-config `docs` folder.\n */\nexport const contentGlobs = ({\n content,\n}: z.infer<typeof rawContentSchema>): ContentGlobs[] => {\n const sources = (content?.sources ?? []).flatMap((source) => {\n const filesystem = rawFilesystemSourceSchema.safeParse(source);\n return filesystem.success ? [filesystem.data] : [];\n });\n return (sources.length > 0 ? sources : [content ?? {}]).map((globs) => ({\n exclude: globs.exclude ?? DEFAULT_CONTENT_EXCLUDE,\n include: globs.include ?? DEFAULT_CONTENT_INCLUDE,\n root: globs.root ?? \"docs\",\n }));\n};\n\n/** The content roots the project's config names, loaded as written. */\nconst configContentGlobs = async (root: string): Promise<ContentGlobs[]> => {\n const file = findConfigFile(root);\n let raw: z.infer<typeof rawContentSchema> = {};\n if (file) {\n try {\n const parsed = rawContentSchema.safeParse(\n await createModuleLoader()(file)\n );\n raw = parsed.success ? parsed.data : {};\n } catch {\n // A config that won't load is already reported by the config check;\n // its content still gets the zero-config scan.\n }\n }\n return contentGlobs(raw);\n};\n\nconst isPathKey = (segment: PropertyKey): segment is number | string =>\n typeof segment !== \"symbol\";\n\n// Zod's own wording for an unknown key; a removed field's hint replaces it.\nconst PLAIN_UNKNOWN_KEY = \"Unrecognized key\";\n\n/**\n * The removed fields among one page's front matter issues, each at its own\n * line. Only issues the page schema words as a removed-field hint count: a\n * key a project declares through `frontmatter.extend` is unknown to the bare\n * schema, and any other invalid value was already an error on Blume 1.\n */\nconst removedFieldFindings = (\n file: string,\n text: string,\n issues: readonly z.core.$ZodIssue[]\n): Diagnostic[] =>\n issues.flatMap((issue) => {\n if (\n issue.code !== \"unrecognized_keys\" ||\n issue.message.startsWith(PLAIN_UNKNOWN_KEY)\n ) {\n return [];\n }\n const path = issue.path.filter(isPathKey);\n const position =\n locateFrontmatterKey(text, [...path, ...issue.keys.slice(0, 1)]) ??\n locateFrontmatterKey(text, path);\n return [\n {\n code: \"BLUME_FRONTMATTER_INVALID\",\n column: position?.column,\n file,\n line: position?.line,\n message: issue.message,\n severity: \"error\",\n } satisfies Diagnostic,\n ];\n });\n\n/** The removed front matter fields in one page, or none it can't parse. */\nconst pageFindings = async (file: string): Promise<Diagnostic[]> => {\n const text = await readFile(file, \"utf-8\");\n let parsed: ReturnType<typeof pageMetaSchema.safeParse>;\n try {\n parsed = pageMetaSchema.safeParse(matter(text).data);\n } catch {\n // Unparseable front matter fails the build with its own diagnostic.\n return [];\n }\n return parsed.success\n ? []\n : removedFieldFindings(file, text, parsed.error.issues);\n};\n\n/**\n * A finding for each front matter field Blume 2 removed, across the project's\n * local content. A page with one fails validation and drops out of the build,\n * which the config and components checks alone would report as ready.\n */\nconst frontmatterFindings = async (root: string): Promise<Diagnostic[]> => {\n const roots = await configContentGlobs(root);\n const matches = await Promise.all(\n roots.map((globs) => {\n const cwd = resolve(root, globs.root);\n return existsSync(cwd)\n ? glob(globs.include, {\n absolute: true,\n cwd,\n ignore: [...globs.exclude, ...baselineScanIgnore()],\n onlyFiles: true,\n })\n : [];\n })\n );\n // Two sources can share a folder; each page is checked once.\n const files = [...new Set(matches.flat())].toSorted();\n const findings = await Promise.all(files.map(pageFindings));\n return findings.flat();\n};\n\n/**\n * Run one check, turning the {@link BlumeError} it throws into its findings:\n * each config issue or `components.ts` entry on its own, or the one diagnostic\n * any other check has.\n */\nconst findingsOf = async (\n check: () => Promise<void>\n): Promise<Diagnostic[]> => {\n try {\n await check();\n return [];\n } catch (error) {\n if (\n error instanceof ConfigValidationError ||\n error instanceof ComponentOverridesError\n ) {\n return error.issues;\n }\n if (error instanceof BlumeError) {\n return [error.diagnostic];\n }\n throw error;\n }\n};\n\n/**\n * Check a project against this version of Blume: its config through the\n * loader (every invalid field, each with its line and replacement), its\n * `components.ts` through the static override planner (each entry at its\n * line), its pages' front matter for removed fields, and its package.json\n * scripts for `blume build` flags that no longer exist. Returns the failures;\n * an empty list means the project is ready.\n */\nexport const collectUpgradeFindings = async (\n root: string\n): Promise<Diagnostic[]> => {\n const componentsFile = findComponentsFile(root);\n return [\n ...(await findingsOf(async () => {\n await loadConfig(root);\n })),\n ...(componentsFile\n ? await findingsOf(async () => {\n analyzeComponentOverrides(\n await readFile(componentsFile, \"utf-8\"),\n componentsFile\n );\n })\n : []),\n ...(await frontmatterFindings(root)),\n ...(await scriptFindings(root)),\n ];\n};\n\n/** A finding as plain text for the agent: where, what, and the fix. */\nconst plainFinding = (finding: Diagnostic, root: string): string => {\n const where = finding.file\n ? `${relative(root, finding.file)}${finding.line === undefined ? \"\" : `:${finding.line}`}`\n : \"blume.config.ts\";\n const fix = finding.suggestion ? `\\n Fix: ${finding.suggestion}` : \"\";\n return `- ${where} (${finding.code})\\n ${finding.message.replaceAll(\"\\n\", \"\\n \")}${fix}`;\n};\n\n/**\n * The handoff prompt: the findings inline (they're few, and each already\n * names its replacement), where the guide is, and the ground rules — change\n * the config's shape, never the site's behavior, and verify with the site's\n * own checks, run through the project's package runner (`npx`, `pnpm exec`),\n * since a local install puts no `blume` on PATH.\n */\nexport const upgradePrompt = (options: {\n findings: Diagnostic[];\n guidePath: string;\n root: string;\n runner: string;\n version: string;\n}): string =>\n `Upgrade this Blume project to Blume ${options.version}. \\`blume upgrade\\` has bumped the \\`blume\\` dependency in package.json where it could; what's left is the config.\n\nThe upgrade guide is at ${options.guidePath} (online at ${UPGRADE_GUIDE_URL}). It covers every change between Blume 1 and 2 with before-and-after examples: search, deployment, content sources, API references, analytics, and the assistant's model provider become adapters imported from \\`blume/*\\` subpaths; the machine-readable settings move from \\`ai\\` to \\`agents\\`; Ask AI is renamed the assistant, so \\`ai.ask\\` becomes \\`ai.assistant\\`; and \\`components.ts\\` entries must be one of the static forms.\n\n\\`blume upgrade\\` found:\n\n${options.findings.map((finding) => plainFinding(finding, options.root)).join(\"\\n\\n\")}\n\nWork through every finding:\n1. Read the guide section for each change before editing.\n2. Rewrite the config to the Blume 2 form, adding the adapter imports it needs. Keep the site's behavior the same: the same content, routes, search backend, deployment target, analytics, and credentials (keep reading secrets from the same environment variables).\n3. The config loader reports every invalid field at once, but some changes only surface once earlier ones are fixed, so rerun \\`${options.runner} blume doctor\\` after each round of edits.\n4. Never delete content, or remove a setting only to silence an error; if something needs a human decision, leave it and say so in your summary.\n\nWhen \\`${options.runner} blume doctor\\` reports no errors, run \\`${options.runner} blume build\\` and fix anything it reports until it succeeds.`;\n"
6
- ],
7
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAEA;AACA;AACA;AA8BO,IAAM,oBAAoB;AAG1B,IAAM,qBAAqB,KAAK,QAAQ,kBAAkB;AAgBjE,IAAM,oBAAuC;AAAA,EAC3C;AAAA,EACA;AACF;AAWA,IAAM,cAAc;AAGb,IAAM,aAAa,CAAC,UAAiC;AAAA,EAC1D,MAAM,QAAQ,YAAY,KAAK,KAAK,GAAG,QAAQ;AAAA,EAC/C,OAAO,UAAU,YAAY,OAAO,OAAO,KAAK;AAAA;AAKlD,IAAM,gBAAgB;AACtB,IAAM,YAAY;AAOX,IAAM,mBAAmB,CAAC,OAAe,YAA4B;AAAA,EAC1E,MAAM,UAAU,cAAc,KAAK,KAAK,GAAG,QAAQ;AAAA,EACnD,IAAI,YAAY,WAAW;AAAA,IACzB,OAAO,mDAAmD,iFAAiF;AAAA,EAC7I;AAAA,EACA,MAAM,QACJ,YAAY,MAAM,YAAY,YAC1B,cACA,cAAc;AAAA,EACpB,OAAO,qDAAqD,+DAA+D,iBAAiB;AAAA;AAK9I,IAAM,SAAS;AAEf,IAAM,iBAAiB;AACvB,IAAM,eAAe,CAAC,UACpB,MAAM,WAAW,gBAAgB,OAAO,QAAQ;AAOlD,I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