claude-mem-lite 2.34.3 → 2.34.4

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.
@@ -10,7 +10,7 @@
10
10
  "plugins": [
11
11
  {
12
12
  "name": "claude-mem-lite",
13
- "version": "2.34.3",
13
+ "version": "2.34.4",
14
14
  "source": "./",
15
15
  "description": "Lightweight persistent memory system for Claude Code — FTS5 search, episode batching, error-triggered recall"
16
16
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-mem-lite",
3
- "version": "2.34.3",
3
+ "version": "2.34.4",
4
4
  "description": "Lightweight persistent memory system for Claude Code — FTS5 search, episode batching, error-triggered recall",
5
5
  "author": {
6
6
  "name": "sdsrss"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-mem-lite",
3
- "version": "2.34.3",
3
+ "version": "2.34.4",
4
4
  "description": "Lightweight persistent memory system for Claude Code",
5
5
  "type": "module",
6
6
  "engines": {
@@ -9,12 +9,23 @@ const CONFIRM_RE = /^(y(es)?|no?|ok|done|go|sure|lgtm|thanks?|ty|继续|确认|
9
9
  const SLASH_CMD_RE = /^\//;
10
10
  const PURE_OP_RE = /^(git\s+(commit|push|merge)|npm\s+(publish|deploy))\b/i;
11
11
 
12
+ /**
13
+ * CJK-weighted effective length. CJK characters (CJK Unified Ideographs
14
+ * main + extension A) carry ~3x the semantic token density of Latin
15
+ * characters — a 5-char Chinese phrase like "优化数据库" encodes roughly
16
+ * the same information as a 15-char English equivalent. Used by every
17
+ * length gate downstream of the prompt hook so Latin-calibrated
18
+ * thresholds (8 / 15) don't falsely reject substantive CJK prompts.
19
+ */
20
+ export function computeEffectiveLen(text) {
21
+ if (!text) return 0;
22
+ const cjkCount = (text.match(/[\u4e00-\u9fff\u3400-\u4dbf]/g) || []).length;
23
+ return (text.length - cjkCount) + cjkCount * 3;
24
+ }
25
+
12
26
  export function shouldSkip(text) {
13
27
  if (!text) return true;
14
- // CJK characters carry ~3x semantic weight per char vs Latin
15
- const cjkCount = (text.match(/[\u4e00-\u9fff\u3400-\u4dbf]/g) || []).length;
16
- const effectiveLen = (text.length - cjkCount) + cjkCount * 3;
17
- if (effectiveLen < 8) return true;
28
+ if (computeEffectiveLen(text) < 8) return true;
18
29
  const trimmed = text.trim();
19
30
  if (CONFIRM_RE.test(trimmed)) return true;
20
31
  if (SLASH_CMD_RE.test(trimmed)) return true;
@@ -8,7 +8,7 @@ import { sanitizeFtsQuery, relaxFtsQueryToOr, truncate, typeIcon, inferProject,
8
8
  import { writeFileSync, readFileSync, existsSync, renameSync } from 'fs';
9
9
  import { join } from 'path';
10
10
  import Database from 'better-sqlite3';
11
- import { shouldSkip, detectIntent, shouldSkipByDedup, extractFiles, extractErrorSignature, DEDUP_STALE_MS, matchRegistrySkillName } from './prompt-search-utils.mjs';
11
+ import { shouldSkip, computeEffectiveLen, detectIntent, shouldSkipByDedup, extractFiles, extractErrorSignature, DEDUP_STALE_MS, matchRegistrySkillName } from './prompt-search-utils.mjs';
12
12
 
13
13
  // ─── Constants ──────────────────────────────────────────────────────────────
14
14
 
@@ -29,9 +29,13 @@ const LOOKBACK_MS = 60 * 86400000; // 60 days
29
29
  // is TOP_REL_FLOOR below, which drops the whole FTS set when the best match
30
30
  // is weak.
31
31
  const BM25_MIN_SCORE = Number(process.env.CLAUDE_MEM_UPS_BM25_MIN || 1e-5);
32
- // Raw-character minimum length for the prompt. Additional to the CJK-weighted
33
- // `shouldSkip()` effective-length gate; catches medium-short Latin prompts that
34
- // survive `shouldSkip` but carry too few tokens to justify an FTS lookup.
32
+ // CJK-weighted minimum length for the prompt. Catches medium-short Latin
33
+ // prompts ("run tests", "fix bug now") that survive `shouldSkip`'s weaker 8-unit
34
+ // floor but carry too few tokens to justify an FTS lookup.
35
+ // v2.34.4: applied to `computeEffectiveLen(prompt)`, not raw char count — a
36
+ // 14-char CJK prompt ("优化 hook 性能降低延迟") scores 30 effective units and
37
+ // now reaches FTS, matching shouldSkip's CJK-weighted gate rather than silently
38
+ // failing the raw-char one.
35
39
  const PROMPT_MIN_LENGTH = 15;
36
40
 
37
41
  // v2.33.1: follow-up prompts ("前面那个", "继续 X", "再看看 Y") are short by
@@ -296,7 +300,7 @@ async function main() {
296
300
  // short continuations ("前面那个?", "does it work?") depend on prior context.
297
301
  const followUp = isFollowUpSession();
298
302
  const promptMinLen = followUp ? FOLLOWUP_PROMPT_MIN_LENGTH : PROMPT_MIN_LENGTH;
299
- if (promptText.trim().length < promptMinLen) return;
303
+ if (computeEffectiveLen(promptText.trim()) < promptMinLen) return;
300
304
  const bm25Floor = followUp ? FOLLOWUP_BM25_MIN_SCORE : BM25_MIN_SCORE;
301
305
 
302
306
  let db;