opencode-mem 2.14.0 → 2.14.2

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.
@@ -55,9 +55,9 @@ function getProjectPathFromTag(tag) {
55
55
  export async function handleListTags() {
56
56
  try {
57
57
  // Tags are stored as SQLite metadata; embedding model is not needed.
58
- // Calling warmup() here would block on @huggingface/transformers init in
59
- // the worker thread and hang every read API. Only handlers that compute
60
- // similarity (e.g. handleSearch) should warm up the embedding service.
58
+ // Calling warmup() here would block on local transformer init in the worker
59
+ // thread and hang every read API. Only handlers that compute similarity
60
+ // (e.g. handleSearch) should warm up the embedding service.
61
61
  const projectShards = shardManager.getAllShards("project", "");
62
62
  const tagsMap = new Map();
63
63
  for (const shard of projectShards) {
@@ -1 +1 @@
1
- {"version":3,"file":"embedding.d.ts","sourceRoot":"","sources":["../../src/services/embedding.ts"],"names":[],"mappings":"AAuCA,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,WAAW,CAA8B;IAC1C,UAAU,EAAE,OAAO,CAAS;IACnC,OAAO,CAAC,KAAK,CAAwC;IACrD,OAAO,CAAC,eAAe,CAAuB;IAE9C,MAAM,CAAC,WAAW,IAAI,gBAAgB;IAOhC,MAAM,CAAC,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;YAOzD,eAAe;IAuBvB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAmD1C,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAI3D,UAAU,IAAI,IAAI;CAGnB;AAED,eAAO,MAAM,gBAAgB,kBAAiC,CAAC"}
1
+ {"version":3,"file":"embedding.d.ts","sourceRoot":"","sources":["../../src/services/embedding.ts"],"names":[],"mappings":"AA6CA,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,WAAW,CAA8B;IAC1C,UAAU,EAAE,OAAO,CAAS;IACnC,OAAO,CAAC,KAAK,CAAwC;IACrD,OAAO,CAAC,eAAe,CAAuB;IAE9C,MAAM,CAAC,WAAW,IAAI,gBAAgB;IAOhC,MAAM,CAAC,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;YAOzD,eAAe;IAkBvB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAmD1C,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAI3D,UAAU,IAAI,IAAI;CAGnB;AAED,eAAO,MAAM,gBAAgB,kBAAiC,CAAC"}
@@ -5,16 +5,20 @@ const TIMEOUT_MS = 30000;
5
5
  const GLOBAL_EMBEDDING_KEY = Symbol.for("opencode-mem.embedding.instance");
6
6
  const MAX_CACHE_SIZE = 100;
7
7
  let _transformers = null;
8
+ function getTransformersPackageSpecifier() {
9
+ // Keep this non-literal so OpenCode/Bun plugin-loader bundling does not eagerly
10
+ // traverse @xenova/transformers internals during plugin startup. The package
11
+ // is only needed for the local embedding backend, and should stay lazy.
12
+ return ["@xenova", "transformers"].join("/");
13
+ }
8
14
  async function ensureTransformersLoaded() {
9
15
  if (_transformers !== null)
10
16
  return _transformers;
11
- const mod = await import("@huggingface/transformers");
17
+ const mod = (await import(getTransformersPackageSpecifier()));
12
18
  mod.env.allowLocalModels = true;
13
19
  mod.env.allowRemoteModels = true;
14
20
  mod.env.cacheDir = join(CONFIG.storagePath, ".cache");
15
- // CRITICAL: Disable WASM multi-threading. In Node.js/Bun (no SharedArrayBuffer),
16
- // ONNX runtime hangs indefinitely during pipeline() init when threads > 1.
17
- // See https://github.com/xenova/transformers.js/pull/488
21
+ // Keep ONNX WASM single-threaded for Bun/Node runtimes without SharedArrayBuffer.
18
22
  try {
19
23
  mod.env.backends.onnx.wasm.numThreads = 1;
20
24
  }
@@ -57,14 +61,9 @@ export class EmbeddingService {
57
61
  return;
58
62
  }
59
63
  const { pipeline } = await ensureTransformersLoaded();
60
- const pipelineOptions = {
64
+ this.pipe = await pipeline("feature-extraction", CONFIG.embeddingModel, {
61
65
  progress_callback: progressCallback,
62
- // Force quantized ONNX. Default is fp32 model.onnx which transformers v4
63
- // tries to download from huggingface.co; cache only ships model_quantized.onnx
64
- // and HF is unreachable behind GFW, causing init to fail.
65
- dtype: "q8",
66
- };
67
- this.pipe = await pipeline("feature-extraction", CONFIG.embeddingModel, pipelineOptions);
66
+ });
68
67
  this.isWarmedUp = true;
69
68
  }
70
69
  catch (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"tags.d.ts","sourceRoot":"","sources":["../../src/services/tags.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,WAAW,IAAI,MAAM,GAAG,IAAI,CAU3C;AAED,wBAAgB,UAAU,IAAI,MAAM,GAAG,IAAI,CAU1C;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAW9D;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAwBhE;AAED,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAW/D;AAED,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAYxD;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,M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iB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAa5D;AAED,wBAAgB,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG;IAC1C,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB,CAKA"}
@@ -1,7 +1,7 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { execSync } from "node:child_process";
3
3
  import { CONFIG } from "../config.js";
4
- import { sep, normalize, resolve, isAbsolute, basename, dirname } from "node:path";
4
+ import { normalize, resolve, isAbsolute, basename, dirname } from "node:path";
5
5
  import { realpathSync, existsSync } from "node:fs";
6
6
  function sha256(input) {
7
7
  return createHash("sha256").update(input).digest("hex").slice(0, 16);
@@ -101,9 +101,8 @@ export function getProjectIdentity(directory) {
101
101
  return `path:${normalize(directory)}`;
102
102
  }
103
103
  export function getProjectName(directory) {
104
- // Normalize path to handle both Unix and Windows separators
105
- const normalized = normalize(directory);
106
- const parts = normalized.split(sep).filter((p) => p);
104
+ const normalized = normalize(directory).replace(/\\/g, "/");
105
+ const parts = normalized.split("/").filter((p) => p && p !== ".");
107
106
  return parts[parts.length - 1] || directory;
108
107
  }
109
108
  export function getUserTagInfo() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-mem",
3
- "version": "2.14.0",
3
+ "version": "2.14.2",
4
4
  "description": "OpenCode plugin that gives coding agents persistent memory using local vector database",
5
5
  "type": "module",
6
6
  "main": "dist/plugin.js",
@@ -43,13 +43,13 @@
43
43
  "access": "public"
44
44
  },
45
45
  "dependencies": {
46
- "@huggingface/transformers": "^4.0.1",
47
46
  "@opencode-ai/plugin": "^1.3.0",
48
47
  "@opencode-ai/sdk": "^1.3.0",
49
48
  "franc-min": "^6.2.0",
50
49
  "iso-639-3": "^3.0.1",
51
50
  "usearch": "^2.21.4",
52
- "zod": "^4.3.6"
51
+ "zod": "^4.3.6",
52
+ "@xenova/transformers": "^2.17.2"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/bun": "^1.3.8",