claude-memory-layer 1.0.29 → 1.0.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -36,7 +36,7 @@ npx claude-memory-layer status
36
36
  ```
37
37
 
38
38
  - `install`은 **한 번만** 하면 됩니다(Claude Code hooks 등록).
39
- - Linux x64 + CUDA 11 환경에서는 설치 optional embedding backend를 CPU-only ONNX Runtime으로 자동 복구합니다.
39
+ - `@huggingface/transformers`는 일반 dependency라 기본 설치에 포함됩니다. 따라서 정상 설치 embedding runtime 누락으로 `ERR_MODULE_NOT_FOUND`가 나는 것을 방지합니다.
40
40
  - 이후 프로젝트별로 메모리 저장소가 자동 분리됩니다.
41
41
  - `install` / `uninstall`은 `~/.claude/settings.json`을 수정합니다.
42
42
 
@@ -48,27 +48,41 @@ Linux x64 서버에 CUDA 11이 설치되어 있으면 `@huggingface/transformers
48
48
  Error: CUDA 11 binaries are not supported by this script yet.
49
49
  ```
50
50
 
51
- Claude Memory Layer는 설치 Linux x64 + CUDA 11 환경을 감지하면 `@huggingface/transformers`를 optional dependency로 처리한 CPU-only ONNX Runtime 설정으로 자동 복구합니다. 그래서 일반적으로 사용자가 환경변수를 직접 지정할 필요는 없습니다.
52
-
53
- 만약 구버전 패키지를 설치 중이거나 postinstall 복구가 실패하면 아래처럼 수동으로 CUDA 바이너리 다운로드만 건너뛰어 재설치할 수 있습니다.
51
+ Claude Memory Layer는 로컬 semantic/vector embedding에 필요한 `@huggingface/transformers`를 필수 dependency로 설치합니다. 이 선택은 정상 설치 backend 누락을 조용히 넘기지 않기 위한 것입니다. 다만 CUDA 11 환경에서는 하위 의존성 설치가 Claude Memory Layer의 postinstall repair 전에 실패할 있으므로, 아래처럼 CUDA 바이너리 다운로드를 건너뛰고 CPU-only ONNX Runtime으로 재설치하세요.
54
52
 
55
53
  ```bash
56
54
  # 실패한 전역 설치가 일부 남아 있으면 먼저 제거
57
55
  npm uninstall -g claude-memory-layer || true
58
56
 
59
- # 수동 fallback: CPU-only ONNX Runtime으로 재설치
57
+ # CPU-only ONNX Runtime으로 재설치
60
58
  ONNXRUNTIME_NODE_INSTALL_CUDA=skip npm install -g claude-memory-layer@latest
61
59
  claude-memory-layer --version
62
60
  ```
63
61
 
64
- 로컬 checkout 개발 환경에서 구버전 의존성 설치가 같은 오류를 내면 아래처럼 수동 fallback을 사용할 수 있습니다.
62
+ 로컬 checkout 개발 환경에서 같은 오류가 나면 아래처럼 설치합니다.
65
63
 
66
64
  ```bash
67
65
  ONNXRUNTIME_NODE_INSTALL_CUDA=skip npm install
68
66
  ```
69
67
 
68
+ 이미 설치된 패키지 디렉터리에서 backend만 손상/누락된 경우에는 postinstall repair와 런타임 오류 메시지가 동일한 CPU-only 복구 명령을 안내합니다.
69
+
70
70
  `npm warn deprecated ...` 경고는 하위 의존성 경고이며 설치 실패 원인이 아닙니다.
71
71
 
72
+ #### Embedding model
73
+
74
+ 기본 로컬 embedding 모델은 `Xenova/multilingual-e5-small`입니다.
75
+
76
+ - `@huggingface/transformers`/ONNX Runtime CPU에서 동작하므로 CUDA가 필요 없습니다.
77
+ - 원본 `intfloat/multilingual-e5-small`은 multilingual + Korean(`ko`) 지원 모델이고, Xenova variant는 Transformers.js용 ONNX 파일을 제공합니다.
78
+ - 384차원이라 대규모 세션 import에서도 CPU/메모리 부담이 작습니다.
79
+ - 더 높은 품질이 필요하면 `--embedding-model <hf-model>` 또는 `CLAUDE_MEMORY_EMBEDDING_MODEL`로 `onnx-community/Qwen3-Embedding-0.6B-ONNX`, `onnx-community/embeddinggemma-300m-ONNX` 같은 Transformers.js/ONNX 모델을 실험할 수 있습니다. 다만 이들은 다운로드/CPU 비용이 더 크거나 모델/라이선스 성숙도를 별도 검토해야 합니다.
80
+
81
+ ```bash
82
+ claude-memory-layer import --project "$PWD" --embedding-model Xenova/multilingual-e5-small
83
+ CLAUDE_MEMORY_EMBEDDING_MODEL=onnx-community/Qwen3-Embedding-0.6B-ONNX claude-memory-layer process --project "$PWD"
84
+ ```
85
+
72
86
  ### 1) 새 프로젝트에서 초기 메모리 생성
73
87
 
74
88
  ```bash
package/dist/cli/index.js CHANGED
@@ -1533,12 +1533,14 @@ import * as fs5 from "fs";
1533
1533
  import * as path4 from "path";
1534
1534
 
1535
1535
  // src/extensions/vector/embedder.ts
1536
+ var DEFAULT_EMBEDDING_MODEL = "Xenova/multilingual-e5-small";
1537
+ var DEFAULT_EMBEDDING_FALLBACK_MODEL = "intfloat/multilingual-e5-small";
1536
1538
  var Embedder = class _Embedder {
1537
1539
  pipeline = null;
1538
1540
  modelName;
1539
1541
  activeModelName;
1540
1542
  initialized = false;
1541
- constructor(modelName = "jinaai/jina-embeddings-v5-text-nano-text-matching") {
1543
+ constructor(modelName = DEFAULT_EMBEDDING_MODEL) {
1542
1544
  this.modelName = modelName;
1543
1545
  this.activeModelName = modelName;
1544
1546
  }
@@ -1548,14 +1550,23 @@ var Embedder = class _Embedder {
1548
1550
  async initialize() {
1549
1551
  if (this.initialized)
1550
1552
  return;
1551
- const pipeline = await withSuppressedKnownTransformersWarnings(() => loadTransformersPipeline());
1553
+ const pipeline = await withSuppressedKnownTransformersWarnings(async () => {
1554
+ try {
1555
+ return await loadTransformersPipeline();
1556
+ } catch (error) {
1557
+ if (isMissingTransformersDependencyError(error)) {
1558
+ throw createEmbeddingBackendUnavailableError(error);
1559
+ }
1560
+ throw error;
1561
+ }
1562
+ });
1552
1563
  try {
1553
1564
  this.pipeline = await withSuppressedKnownTransformersWarnings(() => pipeline("feature-extraction", this.modelName));
1554
1565
  this.activeModelName = this.modelName;
1555
1566
  this.initialized = true;
1556
1567
  return;
1557
1568
  } catch (primaryError) {
1558
- const fallbackModel = process.env.CLAUDE_MEMORY_EMBEDDING_FALLBACK_MODEL || "onnx-community/embeddinggemma-300m-ONNX";
1569
+ const fallbackModel = process.env.CLAUDE_MEMORY_EMBEDDING_FALLBACK_MODEL || DEFAULT_EMBEDDING_FALLBACK_MODEL;
1559
1570
  if (fallbackModel === this.modelName) {
1560
1571
  throw primaryError;
1561
1572
  }
@@ -1674,6 +1685,28 @@ async function withSuppressedKnownTransformersWarnings(fn) {
1674
1685
  function isKnownBenignTransformersWarning(message) {
1675
1686
  return message.includes('Unknown model class "eurobert"') || message.includes('dtype not specified for "model"');
1676
1687
  }
1688
+ function isMissingTransformersDependencyError(error) {
1689
+ const maybeError = error;
1690
+ const message = typeof maybeError?.message === "string" ? maybeError.message : "";
1691
+ return maybeError?.code === "ERR_MODULE_NOT_FOUND" && message.includes("@huggingface/transformers");
1692
+ }
1693
+ function createEmbeddingBackendUnavailableError(cause) {
1694
+ const error = new Error(
1695
+ [
1696
+ "Required embedding backend is not installed.",
1697
+ "",
1698
+ "Claude Memory Layer requires @huggingface/transformers for local semantic/vector embeddings.",
1699
+ "The backend runs on CPU-only ONNX Runtime; CUDA is not required.",
1700
+ "Reinstall globally with:",
1701
+ " ONNXRUNTIME_NODE_INSTALL_CUDA=skip npm install -g claude-memory-layer@latest",
1702
+ "",
1703
+ "If you are inside a local checkout or package directory, repair only the backend with:",
1704
+ " ONNXRUNTIME_NODE_INSTALL_CUDA=skip npm install --no-save --no-package-lock --omit=dev @huggingface/transformers@3.8.1"
1705
+ ].join("\n")
1706
+ );
1707
+ error.cause = cause;
1708
+ return error;
1709
+ }
1677
1710
  async function loadTransformersPipeline() {
1678
1711
  const dynamicImport = new Function("specifier", "return import(specifier)");
1679
1712
  const transformers = await dynamicImport("@huggingface/transformers");
@@ -12904,7 +12937,7 @@ async function runMarketContextCommand(options) {
12904
12937
  }
12905
12938
  }
12906
12939
  var program = new Command();
12907
- program.name("claude-memory-layer").description("Claude Code Memory Plugin CLI").version("1.0.29");
12940
+ program.name("claude-memory-layer").description("Claude Code Memory Plugin CLI").version("1.0.31");
12908
12941
  program.command("market-context").description("Fetch read-only DART/FRED/Finnhub context with structured MarketContextSnapshot bull/bear/risk/catalyst analysis").option("--company <name>", "Company name for DART fallback search and report subject").option("--dart-corp-code <code>", "Exact DART corp_code for issuer-specific filings").option("--symbol <ticker>", "Listed ticker for Finnhub company profile").option("--providers <list>", "Comma-separated providers: dart,fred,finnhub").option("--fred-series <list>", "Comma-separated FRED series IDs").option("--json", "Print structured JSON including analysis.marketSnapshot").option("--no-snapshot", "Disable MarketContextSnapshot and DART company snapshot analysis").action(async (options) => {
12909
12942
  try {
12910
12943
  await runMarketContextCommand(options);
@@ -13435,7 +13468,7 @@ program.command("organize-import [sourceDir]").description("Import existing mark
13435
13468
  process.exit(1);
13436
13469
  }
13437
13470
  });
13438
- program.command("import").description("Import existing Claude Code conversation history").option("-p, --project <path>", "Import from specific project path").option("-s, --session <file>", "Import specific session file (JSONL)").option("-a, --all", "Import all sessions from all projects").option("-l, --limit <number>", "Limit messages per session").option("--session-limit <number>", "Limit recent matching sessions to import").option("-f, --force", "Force reimport: delete existing events and reimport with turn_id grouping").option("--embedding-model <name>", "Embedding model override (default: jinaai/jina-embeddings-v5-text-nano-text-matching, or env CLAUDE_MEMORY_EMBEDDING_MODEL; fallback env: CLAUDE_MEMORY_EMBEDDING_FALLBACK_MODEL)").option("-v, --verbose", "Show detailed progress").action(async (options) => {
13471
+ program.command("import").description("Import existing Claude Code conversation history").option("-p, --project <path>", "Import from specific project path").option("-s, --session <file>", "Import specific session file (JSONL)").option("-a, --all", "Import all sessions from all projects").option("-l, --limit <number>", "Limit messages per session").option("--session-limit <number>", "Limit recent matching sessions to import").option("-f, --force", "Force reimport: delete existing events and reimport with turn_id grouping").option("--embedding-model <name>", `Embedding model override (default: ${DEFAULT_EMBEDDING_MODEL}, or env CLAUDE_MEMORY_EMBEDDING_MODEL; fallback: ${DEFAULT_EMBEDDING_FALLBACK_MODEL} or env CLAUDE_MEMORY_EMBEDDING_FALLBACK_MODEL)`).option("-v, --verbose", "Show detailed progress").action(async (options) => {
13439
13472
  const startTime = Date.now();
13440
13473
  const targetProjectPath = options.project || process.cwd();
13441
13474
  if (options.embeddingModel) {