claude-mem-lite 6.30.14 → 6.30.15

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.14",
12
+ "version": "6.30.15",
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.14",
3
+ "version": "6.30.15",
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.14",
3
+ "version": "6.30.15",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "claude-mem-lite",
9
- "version": "6.30.14",
9
+ "version": "6.30.15",
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.14",
3
+ "version": "6.30.15",
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
@@ -1573,18 +1573,25 @@ function runPatterns(text) {
1573
1573
  // JSON does not know is kept as written) and scrubbed as text, MAX_LITERAL_DEPTH levels deep, and
1574
1574
  // rewritten, as the scrubbed text encoded as JSON, only when that scrub changed it: a literal it
1575
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).
1576
+ // it, and a text that ends inside one has it read to the end. Literals are found by a walk from stop
1577
+ // character to stop character: the regex it replaced pushed a backtrack frame per character of a body,
1578
+ // `(?:[^"\\\r\n]|\\[^\r\n])*`, and threw RangeError on a literal of millions of characters (v6.30.14
1579
+ // review r1).
1579
1580
  //
1580
1581
  // A rewritten literal keeps erased what the patterns erase in its escaped body: their run-on erases
1581
1582
  // the lines after a label up to a space, and the text reading keeps such a line when it has no label
1582
1583
  // 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).
1584
+ // (D#687 differential, 2026-11-02). The patterns then run over the whole text as before. A word is
1585
+ // erased from the rewritten literal when the body holds it and what the patterns leave of the body does
1586
+ // not, in either of two readings, and the rewritten literal is read both ways. As written, a word ends at
1587
+ // every escape. Joined, a run of backslashes followed by `/` or by `u` and four hex digits reads as that
1588
+ // one character: a rewritten literal holds the character itself, so PHP's `\/` and .NET's `\u002B` join
1589
+ // words there that the body split (read only as written, 266-715 of 20,000 generated `.env` texts at one
1590
+ // level kept such a word, v6.30.14 review r2; 220 of 329,366 generated values two and three levels in,
1591
+ // review r3). Read only joined, a word the inner level erased part of was gone and its pieces were new
1592
+ // (194 of 649,498 generated values, v6.30.15 review r1). Decoding literal by literal instead stored values
1593
+ // where the patterns had erased a backslash before a quote and so moved where a literal ends (75 of
1594
+ // 165,125 generated values, 2026-11-03).
1588
1595
  //
1589
1596
  // Bounds: MAX_LITERALS literals are decoded per text and level (real transcripts, 2026-11-02: at most
1590
1597
  // 133 in one text); with no bound, `"\"` repeated over 500,000 characters took 104x the patterns alone
@@ -1593,12 +1600,11 @@ function runPatterns(text) {
1593
1600
  // most; with one round, 23-42 of 20,000 generated texts changed on a second call (scrubSecrets is
1594
1601
  // idempotent by contract: import-jsonl's dedup and cmdRestore rely on it). A text the first round
1595
1602
  // leaves as it is is a fixed point already, and is not scrubbed again.
1596
- const ESCAPED_LITERAL_RE = /"(?<=(?:^|[^\\])(?:\\\\)*")((?:[^"\\\r\n]|\\[^\r\n])*)("|$)/g;
1603
+ const LITERAL_STOP_RE = /["\\\r\n]/g;
1597
1604
  const JSON_ESCAPE_RE = /\\(u[0-9a-fA-F]{4}|["\\/bfnrt])/g;
1598
1605
  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
1606
  const VALUE_TOKEN_RE = /[A-Za-z0-9+/=_.-]+/g;
1601
- const ESCAPE_RE = /\\(?:u[0-9a-fA-F]{4}|.)/g;
1607
+ const HEX4_RE = /^[0-9a-fA-F]{4}$/;
1602
1608
  const MAX_LITERAL_DEPTH = 3;
1603
1609
  const MAX_LITERALS = 256;
1604
1610
  const MAX_LITERAL_ROUNDS = 4;
@@ -1613,30 +1619,120 @@ function decodeLiteral(body) {
1613
1619
  }
1614
1620
  }
1615
1621
 
1616
- const maskEscapes = (text) => text.replace(ESCAPE_RE, (e) => ' '.repeat(e.length));
1617
- const valueTokens = (text) => new Set(maskEscapes(text).match(VALUE_TOKEN_RE));
1622
+ /**
1623
+ * text with every escape that decodes to one character, at any depth (a run of backslashes, then `/` or
1624
+ * `u` and four hex digits), read as that character; and where each such escape was: [index in the
1625
+ * reading, start, end in text], flat.
1626
+ */
1627
+ function joinedReading(text) {
1628
+ let read = '';
1629
+ let last = 0;
1630
+ const units = [];
1631
+ for (let i = text.indexOf('\\'); i !== -1;) {
1632
+ let j = i;
1633
+ while (text.charCodeAt(j) === 92) j++;
1634
+ let end = -1;
1635
+ let ch;
1636
+ if (text[j] === '/') {
1637
+ end = j + 1;
1638
+ ch = '/';
1639
+ } else if (text[j] === 'u' && HEX4_RE.test(text.slice(j + 1, j + 5))) {
1640
+ end = j + 5;
1641
+ ch = String.fromCharCode(parseInt(text.slice(j + 1, end), 16));
1642
+ }
1643
+ if (end === -1) {
1644
+ i = text.indexOf('\\', j);
1645
+ continue;
1646
+ }
1647
+ read += text.slice(last, i);
1648
+ units.push(read.length, i, end);
1649
+ read += ch;
1650
+ last = end;
1651
+ i = text.indexOf('\\', end);
1652
+ }
1653
+ return [read + text.slice(last), units];
1654
+ }
1618
1655
 
1619
- function scrubEscapedLiterals(text, depth) {
1656
+ const joinedTokens = (text) => new Set(joinedReading(text)[0].match(VALUE_TOKEN_RE));
1657
+
1658
+ /** text with each value token in `erase`, as joinedReading reads it, replaced by `***`. */
1659
+ function eraseJoined(text, erase) {
1660
+ const [read, units] = joinedReading(text);
1661
+ let u = 0;
1662
+ let shift = 0;
1663
+ const at = (k) => {
1664
+ for (; u < units.length && units[u] < k; u += 3) shift += units[u + 2] - units[u + 1] - 1;
1665
+ return k + shift;
1666
+ };
1667
+ let out = '';
1668
+ let last = 0;
1669
+ for (const { 0: token, index } of read.matchAll(VALUE_TOKEN_RE)) {
1670
+ if (!erase.has(token)) continue;
1671
+ out += text.slice(last, at(index)) + '***';
1672
+ last = at(index + token.length);
1673
+ }
1674
+ return out + text.slice(last);
1675
+ }
1676
+
1677
+ /**
1678
+ * The first literal opening at or after `from`: [start, bodyEnd, end], the body being text[start + 1,
1679
+ * bodyEnd) and the closing quote, if any, text[bodyEnd, end). Null when there is none. A quote whose body
1680
+ * meets a line break, or a backslash before one or at the end of the text, opens no literal.
1681
+ */
1682
+ function nextLiteral(text, from) {
1683
+ const n = text.length;
1684
+ for (let q = text.indexOf('"', from); q !== -1; q = text.indexOf('"', q + 1)) {
1685
+ if (backslashesBefore(text, q, 0) % 2 === 1) continue;
1686
+ let i = q + 1;
1687
+ for (;;) {
1688
+ LITERAL_STOP_RE.lastIndex = i;
1689
+ if (!LITERAL_STOP_RE.test(text)) return [q, n, n];
1690
+ i = LITERAL_STOP_RE.lastIndex - 1;
1691
+ const c = text.charCodeAt(i);
1692
+ if (c === 34) return [q, i, i + 1];
1693
+ if (c !== 92 || i + 1 === n) break;
1694
+ const d = text.charCodeAt(i + 1);
1695
+ if (d === 10 || d === 13) break;
1696
+ i += 2;
1697
+ }
1698
+ }
1699
+ return null;
1700
+ }
1701
+
1702
+ /**
1703
+ * text with the body of each literal it decodes replaced by lit(body): a literal whose body holds an
1704
+ * escape, the first MAX_LITERALS of them, and none at MAX_LITERAL_DEPTH.
1705
+ */
1706
+ function readLiterals(text, depth, lit) {
1620
1707
  if (depth >= MAX_LITERAL_DEPTH || !text.includes('\\')) return text;
1621
1708
  let budget = MAX_LITERALS;
1622
- return text.replace(ESCAPED_LITERAL_RE, (literal, body, close) => {
1623
- if (budget === 0 || !body.includes('\\')) return literal;
1709
+ let out = '';
1710
+ let last = 0;
1711
+ for (let m = nextLiteral(text, 0); m && budget > 0; m = nextLiteral(text, m[2])) {
1712
+ const body = text.slice(m[0] + 1, m[1]);
1713
+ if (!body.includes('\\')) continue;
1624
1714
  budget--;
1715
+ out += text.slice(last, m[0] + 1) + lit(body);
1716
+ last = m[1];
1717
+ }
1718
+ return out + text.slice(last);
1719
+ }
1720
+
1721
+ function scrubEscapedLiterals(text, depth) {
1722
+ return readLiterals(text, depth, (body) => {
1625
1723
  const decoded = decodeLiteral(body);
1626
1724
  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}`;
1725
+ if (scrubbed === decoded) return body;
1726
+ const left = decodeLiteral(runPatterns(body));
1727
+ const erase = new Set();
1728
+ const keptJoined = joinedTokens(left);
1729
+ for (const token of joinedTokens(decoded)) if (!keptJoined.has(token)) erase.add(token);
1730
+ const keptAsWritten = new Set(left.match(VALUE_TOKEN_RE));
1731
+ for (const token of decoded.match(VALUE_TOKEN_RE) ?? []) if (!keptAsWritten.has(token)) erase.add(token);
1732
+ const out = eraseJoined(scrubbed, erase).replace(VALUE_TOKEN_RE, (token) =>
1733
+ erase.has(token) ? '***' : token,
1734
+ );
1735
+ return JSON.stringify(out).slice(1, -1);
1640
1736
  });
1641
1737
  }
1642
1738