claude-mem-lite 6.30.13 → 6.30.14

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.
@@ -9,7 +9,7 @@
9
9
  "plugins": [
10
10
  {
11
11
  "name": "claude-mem-lite",
12
- "version": "6.30.13",
12
+ "version": "6.30.14",
13
13
  "source": "./",
14
14
  "homepage": "https://github.com/sdsrss/claude-mem-lite",
15
15
  "description": "Persistent long-term memory for Claude Code via MCP — captures coding decisions, bugfixes, and context across sessions. FTS5 BM25 keyword search with episode batching. Single SQLite DB, no external services. A lighter, lower-cost alternative to claude-mem (episode batching + a smaller model; cost savings are an internal estimate, not a measured benchmark)."
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-mem-lite",
3
- "version": "6.30.13",
3
+ "version": "6.30.14",
4
4
  "description": "Persistent long-term memory for Claude Code via MCP — captures coding decisions, bugfixes, and context across sessions. FTS5 BM25 keyword search with episode batching. Single SQLite DB, no external services. A lighter, lower-cost alternative to claude-mem (episode batching + a smaller model; cost savings are an internal estimate, not a measured benchmark).",
5
5
  "author": {
6
6
  "name": "sdsrss"
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "claude-mem-lite",
3
- "version": "6.30.13",
3
+ "version": "6.30.14",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "claude-mem-lite",
9
- "version": "6.30.13",
9
+ "version": "6.30.14",
10
10
  "os": [
11
11
  "darwin",
12
12
  "linux",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-mem-lite",
3
- "version": "6.30.13",
3
+ "version": "6.30.14",
4
4
  "description": "Persistent long-term memory for Claude Code via MCP — captures coding decisions, bugfixes, and context across sessions. FTS5 BM25 keyword search with episode batching. Single SQLite DB, no external services. A lighter, lower-cost alternative to claude-mem (episode batching + a smaller model; cost savings are an internal estimate, not a measured benchmark).",
5
5
  "type": "module",
6
6
  "packageManager": "npm@10.9.2",
package/secret-scrub.mjs CHANGED
@@ -1546,9 +1546,8 @@ function scrubKeyTails(text) {
1546
1546
  // this repo has twice decided the text matters more.
1547
1547
  const MAX_SCRUB_PASSES = 32;
1548
1548
 
1549
- export function scrubSecrets(text) {
1550
- if (!text || typeof text !== 'string') return text || '';
1551
- let result = stripPrivate(text);
1549
+ function runPatterns(text) {
1550
+ let result = text;
1552
1551
  for (let pass = 1; ; pass++) {
1553
1552
  const before = result;
1554
1553
  for (const [pattern, replacement] of SECRET_PATTERNS) {
@@ -1558,3 +1557,101 @@ export function scrubSecrets(text) {
1558
1557
  }
1559
1558
  return result;
1560
1559
  }
1560
+
1561
+ // ─── Escaped string literals (D#687, D#693, D#685) ────────────────────────
1562
+ //
1563
+ // A JSON string literal holds its text one escape level deep: a key's quotes are `\"` and a line break
1564
+ // is the two characters `\n`. The patterns above are written for text, so inside a literal a JSON key
1565
+ // never closes on a bare quote, a label never starts a line, and a label's value runs on over the
1566
+ // escaped breaks into the next line's label. What `aws secretsmanager get-secret-value --query
1567
+ // SecretString` prints (`"{\"password\":\"…\"}"`), a `.env` that `kubectl … | jq -c .data` prints as one
1568
+ // string, an escaped JSON literal in a source file or a `.env` value: all were stored. Two attempts that
1569
+ // taught the patterns about escaped line starts (D#663, D#668) were withdrawn at review: a pattern
1570
+ // that starts in a new place carries its value's run-on there.
1571
+ //
1572
+ // So each double-quoted literal on one line whose body holds an escape is decoded (as JSON; an escape
1573
+ // JSON does not know is kept as written) and scrubbed as text, MAX_LITERAL_DEPTH levels deep, and
1574
+ // rewritten, as the scrubbed text encoded as JSON, only when that scrub changed it: a literal it
1575
+ // leaves alone keeps every byte. A literal opens at a quote with an even number of backslashes before
1576
+ // it, and a text that ends inside one has it read to the end. The quote is matched before that count
1577
+ // is checked: Node 22 runs a leading lookbehind at every position, which read a 200,000-character run
1578
+ // of backslashes back from each one (5,108 ms; 0 on Node 26).
1579
+ //
1580
+ // A rewritten literal keeps erased what the patterns erase in its escaped body: their run-on erases
1581
+ // the lines after a label up to a space, and the text reading keeps such a line when it has no label
1582
+ // of its own. Without that, 5-8 values in 20,000 generated texts that v6.30.13 erased were stored
1583
+ // (D#687 differential, 2026-11-02). The patterns then run over the whole text as before. The words
1584
+ // of the body, and of what the patterns leave of it, are read decoded and encoded again: an escape
1585
+ // that decodes to a value-token character (`\/` from PHP's json_encode, `+` from .NET) joins
1586
+ // words in the rewritten literal, and read from the escaped body such a word was new and kept
1587
+ // (266-715 of 20,000 generated `.env` texts, v6.30.14 review r2).
1588
+ //
1589
+ // Bounds: MAX_LITERALS literals are decoded per text and level (real transcripts, 2026-11-02: at most
1590
+ // 133 in one text); with no bound, `"\"` repeated over 500,000 characters took 104x the patterns alone
1591
+ // (415 ms against 4). A rewritten literal can give the patterns a reading they did not have, so a text
1592
+ // that holds a backslash is scrubbed again until it no longer changes, MAX_LITERAL_ROUNDS times at
1593
+ // most; with one round, 23-42 of 20,000 generated texts changed on a second call (scrubSecrets is
1594
+ // idempotent by contract: import-jsonl's dedup and cmdRestore rely on it). A text the first round
1595
+ // leaves as it is is a fixed point already, and is not scrubbed again.
1596
+ const ESCAPED_LITERAL_RE = /"(?<=(?:^|[^\\])(?:\\\\)*")((?:[^"\\\r\n]|\\[^\r\n])*)("|$)/g;
1597
+ const JSON_ESCAPE_RE = /\\(u[0-9a-fA-F]{4}|["\\/bfnrt])/g;
1598
+ const JSON_ESCAPES = { '"': '"', '\\': '\\', '/': '/', b: '\b', f: '\f', n: '\n', r: '\r', t: '\t' };
1599
+ // A value token, and an escape, which is no part of one: `\nAPI_KEY` holds the token `API_KEY`.
1600
+ const VALUE_TOKEN_RE = /[A-Za-z0-9+/=_.-]+/g;
1601
+ const ESCAPE_RE = /\\(?:u[0-9a-fA-F]{4}|.)/g;
1602
+ const MAX_LITERAL_DEPTH = 3;
1603
+ const MAX_LITERALS = 256;
1604
+ const MAX_LITERAL_ROUNDS = 4;
1605
+
1606
+ function decodeLiteral(body) {
1607
+ try {
1608
+ return JSON.parse(`"${body}"`);
1609
+ } catch {
1610
+ return body.replace(JSON_ESCAPE_RE, (_m, e) =>
1611
+ e[0] === 'u' ? String.fromCharCode(parseInt(e.slice(1), 16)) : JSON_ESCAPES[e],
1612
+ );
1613
+ }
1614
+ }
1615
+
1616
+ const maskEscapes = (text) => text.replace(ESCAPE_RE, (e) => ' '.repeat(e.length));
1617
+ const valueTokens = (text) => new Set(maskEscapes(text).match(VALUE_TOKEN_RE));
1618
+
1619
+ function scrubEscapedLiterals(text, depth) {
1620
+ if (depth >= MAX_LITERAL_DEPTH || !text.includes('\\')) return text;
1621
+ let budget = MAX_LITERALS;
1622
+ return text.replace(ESCAPED_LITERAL_RE, (literal, body, close) => {
1623
+ if (budget === 0 || !body.includes('\\')) return literal;
1624
+ budget--;
1625
+ const decoded = decodeLiteral(body);
1626
+ const scrubbed = scrubText(decoded, depth + 1);
1627
+ if (scrubbed === decoded) return literal;
1628
+ const encoded = JSON.stringify(scrubbed).slice(1, -1);
1629
+ const reencode = (s) => JSON.stringify(s).slice(1, -1);
1630
+ const keptByPatterns = valueTokens(reencode(decodeLiteral(runPatterns(body))));
1631
+ const inBody = valueTokens(reencode(decoded));
1632
+ let out = '';
1633
+ let last = 0;
1634
+ for (const { 0: token, index } of maskEscapes(encoded).matchAll(VALUE_TOKEN_RE)) {
1635
+ if (keptByPatterns.has(token) || !inBody.has(token)) continue;
1636
+ out += encoded.slice(last, index) + '***';
1637
+ last = index + token.length;
1638
+ }
1639
+ return `"${out}${encoded.slice(last)}${close}`;
1640
+ });
1641
+ }
1642
+
1643
+ function scrubText(text, depth) {
1644
+ return runPatterns(scrubEscapedLiterals(stripPrivate(text), depth));
1645
+ }
1646
+
1647
+ export function scrubSecrets(text) {
1648
+ if (!text || typeof text !== 'string') return text || '';
1649
+ let result = scrubText(text, 0);
1650
+ if (result === text) return result;
1651
+ for (let round = 1; round < MAX_LITERAL_ROUNDS && result.includes('\\'); round++) {
1652
+ const next = scrubText(result, 0);
1653
+ if (next === result) break;
1654
+ result = next;
1655
+ }
1656
+ return result;
1657
+ }