@clarify-labs/cli 0.11.2 → 0.11.3

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.
@@ -19,6 +19,7 @@ import { build, loadConfigFromFile } from "vite";
19
19
  import { z } from "zod";
20
20
  import { stringify } from "yaml";
21
21
  import { createHash } from "node:crypto";
22
+ import { brotliCompressSync, brotliDecompressSync, constants } from "node:zlib";
22
23
  import { decode, encode } from "@msgpack/msgpack";
23
24
  import { create, insertMultiple, load, save, search } from "@orama/orama";
24
25
  import { fileURLToPath, pathToFileURL } from "node:url";
@@ -1557,7 +1558,7 @@ function createViteAdapter(engine) {
1557
1558
  }
1558
1559
  var cliPackageVersion = {
1559
1560
  name: "@clarify-labs/cli",
1560
- version: "0.11.2",
1561
+ version: "0.11.3",
1561
1562
  license: "AGPL-3.0-only",
1562
1563
  type: "module",
1563
1564
  repository: {
@@ -1939,6 +1940,22 @@ function createMcpSiteConfig(projectConfig, options) {
1939
1940
  }
1940
1941
  //#endregion
1941
1942
  //#region source/plugins/mcp-search/orama-index.ts
1943
+ var MSP_MAGIC = new Uint8Array([
1944
+ 67,
1945
+ 76,
1946
+ 65,
1947
+ 82,
1948
+ 73,
1949
+ 70,
1950
+ 89,
1951
+ 77,
1952
+ 83,
1953
+ 80,
1954
+ 1
1955
+ ]);
1956
+ function hasMspMagic(buffer) {
1957
+ return buffer.byteLength >= MSP_MAGIC.byteLength && MSP_MAGIC.every((byte, index) => buffer[index] === byte);
1958
+ }
1942
1959
  /**
1943
1960
  * Orama schema for the MCP search index.
1944
1961
  *
@@ -2177,17 +2194,22 @@ function guessTitleFromPath(path) {
2177
2194
  return segments[segments.length - 1].replace(/\.(md|mdx|html)$/, "").replace(/[-_]/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
2178
2195
  }
2179
2196
  /**
2180
- * Serialize an Orama index to a msgpack binary buffer.
2197
+ * Serialize an Orama index to a versioned, Brotli-compressed binary buffer.
2181
2198
  *
2182
- * Uses `save()` to extract the raw index data, then msgpack-encodes it for a
2183
- * compact binary representation. The same schema + tokenizer must be supplied
2184
- * when loading so query-time tokenization matches indexing-time tokenization.
2199
+ * Uses `save()` to extract the raw index data, MessagePack-encodes it, then
2200
+ * compresses the payload so source documents are not embedded as contiguous
2201
+ * plaintext. The leading magic bytes identify the container and its version.
2185
2202
  */
2186
2203
  function serializeSearchIndex(db) {
2187
- return encode(save(db));
2204
+ const compressed = brotliCompressSync(encode(save(db)), { params: { [constants.BROTLI_PARAM_QUALITY]: 9 } });
2205
+ const buffer = new Uint8Array(MSP_MAGIC.byteLength + compressed.byteLength);
2206
+ buffer.set(MSP_MAGIC);
2207
+ buffer.set(compressed, MSP_MAGIC.byteLength);
2208
+ return buffer;
2188
2209
  }
2189
2210
  /**
2190
- * Deserialize a msgpack binary buffer into a ready-to-search Orama index.
2211
+ * Deserialize a current compressed container or legacy MessagePack buffer
2212
+ * into a ready-to-search Orama index.
2191
2213
  *
2192
2214
  * The caller must supply the same `defaultLocale` used when the index was
2193
2215
  * built, so the tokenizer matches. A mismatch would not corrupt data but
@@ -2195,7 +2217,7 @@ function serializeSearchIndex(db) {
2195
2217
  * as a single token instead of split into "文" + "档").
2196
2218
  */
2197
2219
  function deserializeSearchIndex(buffer, defaultLocale) {
2198
- const raw = decode(buffer);
2220
+ const raw = decode(hasMspMagic(buffer) ? brotliDecompressSync(buffer.subarray(MSP_MAGIC.byteLength)) : buffer);
2199
2221
  const db = createMcpSearchIndex(defaultLocale);
2200
2222
  load(db, raw);
2201
2223
  return db;
@@ -3766,4 +3788,4 @@ function createClarifyEngine(options = {}) {
3766
3788
  //#endregion
3767
3789
  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 };
3768
3790
 
3769
- //# sourceMappingURL=engine-DI8Nd3v0.js.map
3791
+ //# sourceMappingURL=engine-CrYRJRZT.js.map