@clarify-labs/cli 0.11.0 → 0.11.1

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 (31) hide show
  1. package/output/cli/commands/mcp.d.ts +27 -0
  2. package/output/cli/mcp/orama-loader.d.ts +56 -0
  3. package/output/cli/mcp/search-server.d.ts +34 -0
  4. package/output/cli/program.d.ts +0 -1
  5. package/output/cli.cjs +294 -13
  6. package/output/cli.cjs.map +1 -1
  7. package/output/cli.js +295 -14
  8. package/output/cli.js.map +1 -1
  9. package/output/core/config/config-schema.d.ts +6 -220
  10. package/output/core/plugin/hooks.d.ts +0 -1
  11. package/output/core/runtime/html-template.d.ts +0 -6
  12. package/output/core/runtime/virtual-modules.d.ts +0 -4
  13. package/output/{engine-BfkoyVNo.cjs → engine-Cbn_coqg.cjs} +380 -28
  14. package/output/engine-Cbn_coqg.cjs.map +1 -0
  15. package/output/{engine-DfF5RJjC.js → engine-CxnKEKv8.js} +369 -29
  16. package/output/engine-CxnKEKv8.js.map +1 -0
  17. package/output/index.cjs +1 -1
  18. package/output/index.js +1 -1
  19. package/output/parsers/routes/routes.d.ts +1 -5
  20. package/output/plugins/content-artifacts/artifacts.d.ts +0 -2
  21. package/output/plugins/mcp-search/index.d.ts +15 -0
  22. package/output/plugins/mcp-search/mcp-config.d.ts +72 -0
  23. package/output/plugins/mcp-search/orama-index.d.ts +153 -0
  24. package/output/plugins/openapi/virtual-modules.d.ts +0 -1
  25. package/output/plugins/page-search/index.d.ts +2 -0
  26. package/output/types.d.ts +3 -2
  27. package/package.json +6 -4
  28. package/output/engine-BfkoyVNo.cjs.map +0 -1
  29. package/output/engine-DfF5RJjC.js.map +0 -1
  30. package/output/plugins/search-index/index.d.ts +0 -2
  31. /package/output/plugins/{search-index → page-search}/search-language.d.ts +0 -0
@@ -18,6 +18,8 @@ import { createReadStream, existsSync, mkdirSync, mkdtempSync, readFileSync, rea
18
18
  import { build, loadConfigFromFile } from "vite";
19
19
  import { z } from "zod";
20
20
  import { stringify } from "yaml";
21
+ import { decode, encode } from "@msgpack/msgpack";
22
+ import { create, insertMultiple, load, save, search } from "@orama/orama";
21
23
  import { fileURLToPath, pathToFileURL } from "node:url";
22
24
  import SwaggerParser from "@apidevtools/swagger-parser";
23
25
  import { tmpdir } from "node:os";
@@ -968,7 +970,7 @@ function featureSchema(shape, defaults) {
968
970
  } : value);
969
971
  }
970
972
  var clarifyFeaturesConfigSchema = z.object({
971
- search: featureSchema({ provider: z.literal("pagefind").default("pagefind") }, { provider: "pagefind" }),
973
+ search: featureSchema({ mcp: z.boolean().default(true) }, { mcp: true }),
972
974
  repository: featureSchema(clarifyRepositoryConfigSchema.shape, {}),
973
975
  themeEditor: featureSchema({}, {}),
974
976
  openapi: featureSchema({ playground: z.boolean().default(true) }, { playground: true })
@@ -1554,7 +1556,7 @@ function createViteAdapter(engine) {
1554
1556
  }
1555
1557
  var cliPackageVersion = {
1556
1558
  name: "@clarify-labs/cli",
1557
- version: "0.11.0",
1559
+ version: "0.11.1",
1558
1560
  license: "AGPL-3.0-only",
1559
1561
  type: "module",
1560
1562
  repository: {
@@ -1595,6 +1597,9 @@ var cliPackageVersion = {
1595
1597
  "@clarify-labs/templates": "workspace:*",
1596
1598
  "@mdx-js/mdx": "^3.1.1",
1597
1599
  "@mdx-js/rollup": "^3.1.1",
1600
+ "@modelcontextprotocol/sdk": "^1.29.0",
1601
+ "@msgpack/msgpack": "^3.1.3",
1602
+ "@orama/orama": "^3.1.18",
1598
1603
  "@shikijs/rehype": "^4.3.0",
1599
1604
  "@tailwindcss/vite": "^4.3.2",
1600
1605
  "@vitejs/plugin-react": "^6.0.3",
@@ -1613,7 +1618,6 @@ var cliPackageVersion = {
1613
1618
  "rehype-raw": "^7.0.0",
1614
1619
  "rehype-slug": "^6.0.0",
1615
1620
  "remark": "^15.0.1",
1616
- "remark-gfm": "^4.0.1",
1617
1621
  "shiki": "4.3.0",
1618
1622
  "unist-util-visit": "^5.1.0",
1619
1623
  "vite": "^8.1.4",
@@ -1894,6 +1898,347 @@ function createHtmlShellPlugin() {
1894
1898
  };
1895
1899
  }
1896
1900
  //#endregion
1901
+ //#region source/plugins/mcp-search/mcp-config.ts
1902
+ /**
1903
+ * Normalize a route prefix into a root-relative path segment.
1904
+ *
1905
+ * `'/'` -> `''`, `'/docs'` -> `'/docs'`, `'docs/'` -> `'/docs'`.
1906
+ */
1907
+ function normalizePrefix(routePrefix) {
1908
+ if (!routePrefix || routePrefix === "/") return "";
1909
+ return `/${routePrefix.replace(/^\/+|\/+$/g, "")}`;
1910
+ }
1911
+ /**
1912
+ * Assemble the MCP site config from build-time metadata.
1913
+ *
1914
+ * Unlike the previous pagefind-based descriptor, this no longer reads an
1915
+ * entry JSON file - the Orama index is a single binary blob, so the caller
1916
+ * supplies the document count and locale list directly from the build step
1917
+ * that produced the index.
1918
+ */
1919
+ function createMcpSiteConfig(projectConfig, options) {
1920
+ const prefix = normalizePrefix(projectConfig.routePrefix);
1921
+ return {
1922
+ version: 3,
1923
+ site: {
1924
+ title: projectConfig.title,
1925
+ description: projectConfig.description,
1926
+ url: projectConfig.siteUrl,
1927
+ routePrefix: projectConfig.routePrefix ?? "/"
1928
+ },
1929
+ capabilities: { search: {
1930
+ type: "search",
1931
+ indexPath: `${prefix}/mcp-search.msp`,
1932
+ defaultLocale: projectConfig.locales?.default,
1933
+ documentCount: options.documentCount,
1934
+ locales: options.locales
1935
+ } }
1936
+ };
1937
+ }
1938
+ //#endregion
1939
+ //#region source/plugins/mcp-search/orama-index.ts
1940
+ /**
1941
+ * Orama schema for the MCP search index.
1942
+ *
1943
+ * - `path`, `title`, `description`, `content` are full-text searchable strings.
1944
+ * - `locale` is an `enum` so we can use `where: { locale: { eq } }` filters at
1945
+ * query time. (`string` fields cannot be filtered in Orama.)
1946
+ * - `keywords` is a `string[]` also indexed for full-text matching.
1947
+ */
1948
+ var mcpSearchSchema = {
1949
+ path: "string",
1950
+ title: "string",
1951
+ description: "string",
1952
+ locale: "enum",
1953
+ content: "string",
1954
+ keywords: "string[]"
1955
+ };
1956
+ /**
1957
+ * Intl.Segmenter cache keyed by BCP 47 tag. Segmenter construction is not
1958
+ * cheap, and the MCP server issues many queries against the same locale, so
1959
+ * we reuse instances. The cache is module-scoped: build and runtime share it
1960
+ * in the same process, and separate processes get their own - which is fine.
1961
+ */
1962
+ var segmenterCache = /* @__PURE__ */ new Map();
1963
+ function getSegmenter(locale) {
1964
+ let seg = segmenterCache.get(locale);
1965
+ if (!seg) {
1966
+ seg = new Intl.Segmenter(locale, { granularity: "word" });
1967
+ segmenterCache.set(locale, seg);
1968
+ }
1969
+ return seg;
1970
+ }
1971
+ /**
1972
+ * Map a Clarify locale code (e.g. `zh-CN`, `en-US`, `ja-JP`) to a BCP 47 tag
1973
+ * suitable for `Intl.Segmenter`. Returns `null` for locales we intentionally
1974
+ * want to tokenize with the Latin/whitespace fallback (faster, and avoids
1975
+ * forcing CJK-style word segmentation on Latin scripts).
1976
+ */
1977
+ function segmenterLocale(locale) {
1978
+ if (!locale) return null;
1979
+ const lower = locale.toLowerCase();
1980
+ if (lower.startsWith("zh")) return "zh-CN";
1981
+ if (lower.startsWith("ja")) return "ja-JP";
1982
+ if (lower.startsWith("ko")) return "ko-KR";
1983
+ return null;
1984
+ }
1985
+ /**
1986
+ * Tokenize text for Orama indexing and querying.
1987
+ *
1988
+ * CJK locales use `Intl.Segmenter` (word granularity), which splits
1989
+ * spaceless scripts into words and individual characters. Latin/whitespace
1990
+ * locales fall back to a Unicode-aware split on spaces and punctuation.
1991
+ *
1992
+ * All tokens are lowercased so queries match regardless of case.
1993
+ */
1994
+ function tokenizeForSearch(text, locale) {
1995
+ if (!text) return [];
1996
+ const segLocale = segmenterLocale(locale);
1997
+ if (segLocale) {
1998
+ const seg = getSegmenter(segLocale);
1999
+ return Array.from(seg.segment(text)).filter((s) => s.isWordLike).map((s) => s.segment.toLowerCase());
2000
+ }
2001
+ return text.toLowerCase().split(/[\s\p{P}]+/u).filter(Boolean);
2002
+ }
2003
+ /**
2004
+ * Build an Orama tokenizer component bound to a specific default locale.
2005
+ *
2006
+ * The tokenizer receives the raw field value and the per-field language hint
2007
+ * from Orama (which we don't set per-field, so it falls back to the default
2008
+ * language). We resolve the segmenter locale from the default locale at
2009
+ * construction time so the same tokenizer handles all documents in a
2010
+ * predominantly single-locale index.
2011
+ *
2012
+ * For multi-locale indexes, the tokenizer is also used at query time. Since
2013
+ * the query locale is not known to Orama's tokenizer callback, we use the
2014
+ * index's default locale - this is acceptable because:
2015
+ * - CJK queries get CJK segmentation (correct)
2016
+ * - Latin queries against a CJK-default index still work because Latin
2017
+ * text has no word boundaries for CJK segmenters to mis-split; the
2018
+ * segmenter passes through Latin words as-is.
2019
+ */
2020
+ function createMcpTokenizer(defaultLocale) {
2021
+ return {
2022
+ language: defaultLocale ?? "en",
2023
+ normalizationCache: /* @__PURE__ */ new Map(),
2024
+ tokenize(raw, language) {
2025
+ return tokenizeForSearch(typeof raw === "string" ? raw : String(raw ?? ""), language ?? defaultLocale);
2026
+ }
2027
+ };
2028
+ }
2029
+ /**
2030
+ * Compose the searchable text for a route. Shared between the Pagefind
2031
+ * (browser) and Orama (MCP) indexing paths so both backends see the same
2032
+ * field order and content.
2033
+ */
2034
+ function routeSearchContent(route) {
2035
+ return [
2036
+ route.meta.title,
2037
+ route.meta.description,
2038
+ route.meta.keywords?.join(" "),
2039
+ route.meta.sections?.map((section) => section.title).join(" "),
2040
+ route.source.content
2041
+ ].filter(Boolean).join("\n\n");
2042
+ }
2043
+ /**
2044
+ * Convert a `ContentRoute` into the document shape stored in the Orama index.
2045
+ */
2046
+ function routeToSearchDocument(route, defaultLocale) {
2047
+ if (route.isBareAlias) return null;
2048
+ const content = routeSearchContent(route);
2049
+ if (!content.trim()) return null;
2050
+ return {
2051
+ path: route.path,
2052
+ title: route.meta.title ?? "",
2053
+ description: route.meta.description ?? "",
2054
+ locale: route.locale ?? defaultLocale ?? "en",
2055
+ content,
2056
+ keywords: route.meta.keywords ?? []
2057
+ };
2058
+ }
2059
+ /**
2060
+ * Create an Orama index pre-configured with the MCP schema and CJK-aware
2061
+ * tokenizer. Both the build step and the runtime loader use this so the
2062
+ * tokenizer is guaranteed to match between indexing and querying.
2063
+ *
2064
+ * Annotated as `AnyOrama` (Orama's exported base type) rather than inferred
2065
+ * via `ReturnType<typeof create>` because the inference would pull in
2066
+ * Orama's internal component types (`DocumentsStore`, `Index`, `Sorter`)
2067
+ * which are not exported and break `.d.ts` generation (TS2883).
2068
+ */
2069
+ function createMcpSearchIndex(defaultLocale) {
2070
+ return create({
2071
+ schema: mcpSearchSchema,
2072
+ components: { tokenizer: createMcpTokenizer(defaultLocale) }
2073
+ });
2074
+ }
2075
+ /**
2076
+ * Insert search documents into an Orama index.
2077
+ */
2078
+ function indexSearchDocuments(db, documents) {
2079
+ if (documents.length === 0) return;
2080
+ insertMultiple(db, documents);
2081
+ }
2082
+ /**
2083
+ * Build a ready-to-search Orama index from content routes.
2084
+ *
2085
+ * Filters out bare aliases and empty routes. Returns the populated db.
2086
+ */
2087
+ function buildSearchIndex(routes, defaultLocale) {
2088
+ const db = createMcpSearchIndex(defaultLocale);
2089
+ const documents = [];
2090
+ for (const route of routes) {
2091
+ const doc = routeToSearchDocument(route, defaultLocale);
2092
+ if (doc) documents.push(doc);
2093
+ }
2094
+ indexSearchDocuments(db, documents);
2095
+ return {
2096
+ db,
2097
+ documentCount: documents.length
2098
+ };
2099
+ }
2100
+ /**
2101
+ * Collect the distinct locale codes that will be present in the Orama index,
2102
+ * in stable insertion order. Bare aliases are skipped (they duplicate the
2103
+ * default-locale route). Locales with no code fall back to the project
2104
+ * default so single-locale sites still surface one locale.
2105
+ */
2106
+ function collectIndexedLocales(routes, defaultLocale) {
2107
+ const seen = /* @__PURE__ */ new Set();
2108
+ const locales = [];
2109
+ for (const route of routes) {
2110
+ if (route.isBareAlias) continue;
2111
+ const code = route.locale ?? defaultLocale ?? "en";
2112
+ if (!seen.has(code)) {
2113
+ seen.add(code);
2114
+ locales.push(code);
2115
+ }
2116
+ }
2117
+ return locales;
2118
+ }
2119
+ /**
2120
+ * Search an Orama MCP index.
2121
+ *
2122
+ * Applies an optional locale filter (via the `enum` field) and returns a
2123
+ * compact, LLM-friendly hit shape. Excerpts are derived from the matched
2124
+ * content: Orama does not return highlighted excerpts, so we synthesize a
2125
+ * short window around the first query term occurrence.
2126
+ */
2127
+ function searchMcpIndex(db, params) {
2128
+ const limit = Math.max(1, Math.min(50, params.limit ?? 10));
2129
+ const result = search(db, {
2130
+ term: params.query,
2131
+ limit,
2132
+ where: params.locale ? { locale: { eq: params.locale } } : void 0
2133
+ });
2134
+ return {
2135
+ hits: result.hits.map((hit) => {
2136
+ const doc = hit.document;
2137
+ return {
2138
+ path: doc.path,
2139
+ title: doc.title || guessTitleFromPath(doc.path),
2140
+ description: doc.description,
2141
+ locale: doc.locale,
2142
+ score: hit.score,
2143
+ excerpt: makeExcerpt(doc.content, params.query),
2144
+ keywords: doc.keywords
2145
+ };
2146
+ }),
2147
+ count: result.count
2148
+ };
2149
+ }
2150
+ /**
2151
+ * Build a short excerpt around the first occurrence of any query term in the
2152
+ * content. Falls back to the beginning of the content if no term is found.
2153
+ */
2154
+ function makeExcerpt(content, query, maxLen = 240) {
2155
+ if (!content) return "";
2156
+ const terms = query.toLowerCase().split(/[\s\p{P}]+/u).filter(Boolean);
2157
+ const lower = content.toLowerCase();
2158
+ let pos = -1;
2159
+ for (const term of terms) {
2160
+ const i = lower.indexOf(term);
2161
+ if (i >= 0 && (pos < 0 || i < pos)) pos = i;
2162
+ }
2163
+ if (pos < 0) pos = 0;
2164
+ const half = Math.floor(maxLen / 2);
2165
+ const start = Math.max(0, pos - half);
2166
+ const end = Math.min(content.length, start + maxLen);
2167
+ const prefix = start > 0 ? "…" : "";
2168
+ const suffix = end < content.length ? "…" : "";
2169
+ return `${prefix}${content.slice(start, end).trim()}${suffix}`;
2170
+ }
2171
+ function guessTitleFromPath(path) {
2172
+ if (!path) return "(untitled)";
2173
+ const segments = path.split("/").filter(Boolean);
2174
+ if (segments.length === 0) return "Home";
2175
+ return segments[segments.length - 1].replace(/\.(md|mdx|html)$/, "").replace(/[-_]/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
2176
+ }
2177
+ /**
2178
+ * Serialize an Orama index to a msgpack binary buffer.
2179
+ *
2180
+ * Uses `save()` to extract the raw index data, then msgpack-encodes it for a
2181
+ * compact binary representation. The same schema + tokenizer must be supplied
2182
+ * when loading so query-time tokenization matches indexing-time tokenization.
2183
+ */
2184
+ function serializeSearchIndex(db) {
2185
+ return encode(save(db));
2186
+ }
2187
+ /**
2188
+ * Deserialize a msgpack binary buffer into a ready-to-search Orama index.
2189
+ *
2190
+ * The caller must supply the same `defaultLocale` used when the index was
2191
+ * built, so the tokenizer matches. A mismatch would not corrupt data but
2192
+ * would cause CJK query terms to be tokenized incorrectly (e.g. "文档" left
2193
+ * as a single token instead of split into "文" + "档").
2194
+ */
2195
+ function deserializeSearchIndex(buffer, defaultLocale) {
2196
+ const raw = decode(buffer);
2197
+ const db = createMcpSearchIndex(defaultLocale);
2198
+ load(db, raw);
2199
+ return db;
2200
+ }
2201
+ //#endregion
2202
+ //#region source/plugins/mcp-search/index.ts
2203
+ /**
2204
+ * MCP search index plugin.
2205
+ *
2206
+ * Generates the Orama binary index (`mcp-search.msp`) and the MCP site
2207
+ * descriptor (`mcp.json`) as build assets consumed by the `clarify mcp`
2208
+ * command to serve documentation search to MCP-aware clients (e.g. AI coding
2209
+ * assistants).
2210
+ *
2211
+ * This plugin is independent of `clarify:page-search` (Pagefind), which
2212
+ * powers in-browser search. The MCP server runs in Node and needs a
2213
+ * self-contained, compact index with CJK-aware tokenization that doesn't
2214
+ * depend on the browser-only Pagefind runtime.
2215
+ */
2216
+ function createMcpSearchPlugin() {
2217
+ return {
2218
+ name: "clarify:mcp-search",
2219
+ hooks: { "build:assets"(ctx) {
2220
+ const searchConfig = ctx.projectConfig.features.search;
2221
+ if (!searchConfig.enabled || !searchConfig.mcp) return [];
2222
+ const defaultLocale = ctx.projectConfig.locales?.default;
2223
+ const { db, documentCount } = buildSearchIndex(ctx.routes, defaultLocale);
2224
+ const locales = collectIndexedLocales(ctx.routes, defaultLocale);
2225
+ const mcpConfig = createMcpSiteConfig(ctx.projectConfig, {
2226
+ documentCount,
2227
+ locales
2228
+ });
2229
+ const assets = [{
2230
+ fileName: `${mcpConfig.capabilities.search?.indexPath.replace(/\/mcp-search\.msp$/, "") ?? ""}/mcp-search.msp`.replace(/^\//, ""),
2231
+ source: serializeSearchIndex(db)
2232
+ }, {
2233
+ fileName: "mcp.json",
2234
+ source: `${JSON.stringify(mcpConfig, null, 2)}\n`
2235
+ }];
2236
+ console.log(`[clarify] MCP search index (${documentCount} docs, ${locales.length} locales) written to mcp-search.msp.`);
2237
+ return assets;
2238
+ } }
2239
+ };
2240
+ }
2241
+ //#endregion
1897
2242
  //#region source/plugins/openapi/parser.ts
1898
2243
  var OPENAPI_HTTP_METHODS = [
1899
2244
  "get",
@@ -2316,12 +2661,12 @@ function removeClarifyTempDir(path) {
2316
2661
  });
2317
2662
  }
2318
2663
  //#endregion
2319
- //#region source/plugins/search-index/search-language.ts
2664
+ //#region source/plugins/page-search/search-language.ts
2320
2665
  function toPagefindLanguage(locale) {
2321
2666
  return locale?.trim().replace(/_/g, "-").split("-").filter(Boolean).join("-").toLowerCase() || "en";
2322
2667
  }
2323
2668
  //#endregion
2324
- //#region source/plugins/search-index/index.ts
2669
+ //#region source/plugins/page-search/index.ts
2325
2670
  var pagefindContentTypes = {
2326
2671
  ".css": "text/css; charset=utf-8",
2327
2672
  ".js": "text/javascript; charset=utf-8",
@@ -2361,15 +2706,6 @@ async function generatePagefindIndex(options, pagefind) {
2361
2706
  if (!pagefind) await runtime.close();
2362
2707
  }
2363
2708
  }
2364
- function routeSearchContent(route) {
2365
- return [
2366
- route.meta.title,
2367
- route.meta.description,
2368
- route.meta.keywords?.join(" "),
2369
- route.meta.sections?.map((section) => section.title).join(" "),
2370
- route.source.content
2371
- ].filter(Boolean).join("\n\n");
2372
- }
2373
2709
  async function generateDevSearchIndex(ctx, root, pagefind) {
2374
2710
  const { errors, index } = await pagefind.createIndex({
2375
2711
  includeCharacters: "._-/#:@",
@@ -2426,9 +2762,9 @@ function serveDevPagefind(server, getRoot, ctx) {
2426
2762
  createReadStream(filePath).pipe(res);
2427
2763
  });
2428
2764
  }
2429
- function createSearchIndexPlugin() {
2765
+ function createPageSearchPlugin() {
2430
2766
  return {
2431
- name: "clarify:search-index",
2767
+ name: "clarify:page-search",
2432
2768
  hooks: {
2433
2769
  async "dev:configureServer"(server, ctx) {
2434
2770
  if (!ctx.projectConfig.features.search.enabled) return;
@@ -2475,7 +2811,7 @@ function createSearchIndexPlugin() {
2475
2811
  const outputDirectory = ctx.generateOptions.outputDirectory;
2476
2812
  if (!outputDirectory) return;
2477
2813
  const pageCount = await generatePagefindIndex({ outputRoot: resolve(ctx.generateOptions.projectRoot, outputDirectory) });
2478
- console.log(`[clarify] Search index generated for ${pageCount} pages.`);
2814
+ console.log(`[clarify] Page search index generated for ${pageCount} pages.`);
2479
2815
  }
2480
2816
  }
2481
2817
  };
@@ -2624,7 +2960,8 @@ function createBuiltinPlugins(options = {}) {
2624
2960
  createSourceLinksPlugin(),
2625
2961
  createContentArtifactsPlugin(),
2626
2962
  createSeoPlugin(),
2627
- createSearchIndexPlugin()
2963
+ createPageSearchPlugin(),
2964
+ createMcpSearchPlugin()
2628
2965
  ];
2629
2966
  if (options.htmlShell ?? true) plugins.push(createHtmlShellPlugin());
2630
2967
  return plugins;
@@ -2971,16 +3308,19 @@ async function renderSSGRoutes(routes, contextOrConfig, outputDirectory, ssrBund
2971
3308
  const { render } = await import(pathToFileURL(ssrBundlePath).href);
2972
3309
  const template = readIndexHtml(outputDirectory);
2973
3310
  if (!template) throw new Error(`[clarify] index.html not found in outputDirectory "${outputDirectory}". Make sure Vite build produces it.`);
2974
- for (const route of routes) try {
2975
- const finalHtml = injectSSRIntoTemplate(template, await render(route.path), contextOrConfig, route);
2976
- for (const outFile of routeOutputFiles(outputDirectory, route)) {
2977
- mkdirSync(dirname(outFile), { recursive: true });
2978
- writeFileSync(outFile, finalHtml, "utf-8");
3311
+ await Promise.all(routes.map(async (route) => {
3312
+ try {
3313
+ const appHtml = await render(route.path);
3314
+ const finalHtml = injectSSRIntoTemplate(template, appHtml, contextOrConfig, route);
3315
+ for (const outFile of routeOutputFiles(outputDirectory, route)) {
3316
+ mkdirSync(dirname(outFile), { recursive: true });
3317
+ writeFileSync(outFile, finalHtml, "utf-8");
3318
+ }
3319
+ } catch (err) {
3320
+ console.error(`[clarify] Failed to render route "${route.path}":`, err);
3321
+ throw err;
2979
3322
  }
2980
- } catch (err) {
2981
- console.error(`[clarify] Failed to render route "${route.path}":`, err);
2982
- throw err;
2983
- }
3323
+ }));
2984
3324
  }
2985
3325
  //#endregion
2986
3326
  //#region source/core/runtime/startup.ts
@@ -3419,6 +3759,6 @@ function createClarifyEngine(options = {}) {
3419
3759
  return new ClarifyEngine(options);
3420
3760
  }
3421
3761
  //#endregion
3422
- export { cliPackageVersion as a, defineConfig as c, createClarifyTempDir as i, createClarifyEngine as n, cliPackageVersionWithCaret as o, createClarifyRuntimeAliases as r, createViteAdapter as s, ClarifyEngine as t };
3762
+ export { deserializeSearchIndex as a, cliPackageVersionWithCaret as c, createClarifyTempDir as i, createViteAdapter as l, createClarifyEngine as n, searchMcpIndex as o, createClarifyRuntimeAliases as r, cliPackageVersion as s, ClarifyEngine as t, defineConfig as u };
3423
3763
 
3424
- //# sourceMappingURL=engine-DfF5RJjC.js.map
3764
+ //# sourceMappingURL=engine-CxnKEKv8.js.map