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.
package/package.json
CHANGED
|
@@ -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
|
-
|
|
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
|
-
//
|
|
33
|
-
//
|
|
34
|
-
//
|
|
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()
|
|
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;
|