claude-mem-lite 6.30.9 → 6.30.10

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.9",
12
+ "version": "6.30.10",
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.9",
3
+ "version": "6.30.10",
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.9",
3
+ "version": "6.30.10",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "claude-mem-lite",
9
- "version": "6.30.9",
9
+ "version": "6.30.10",
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.9",
3
+ "version": "6.30.10",
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
@@ -560,8 +560,24 @@ function prevLine(text, ls, u, floor) {
560
560
  // text a tab is `\t` and a quote may be `\"`.
561
561
  const PREFIX_GRAMMAR_RE =
562
562
  /^[ \t]*(?:[rRbBuUfF]{0,2}(?:\\*['"`]){1,3})?([ \t]*\d+(?:\t|\\+t)|\d+→|[-+]|(?:>[ \t]?)+|[^\s'"`:\\]+[:-]\d+[:-]|[^\s'"`:\\]+:)/;
563
+ // D#614 A2: a grep column after any path, up to the line's last `:N:` or `-N-` (a number past the path
564
+ // is the grep's; one inside code before the BEGIN is rare): a backslash, a space, a drive letter or
565
+ // another colon, a quote or a backtick in the path, or a leading `-`, `+` or `>`, which the grammar
566
+ // above reads as a diff mark or a quote.
567
+ const GREP_ANY_PATH_RE = /^[ \t]*(\S.*(?::\d+:|-\d+-))/;
563
568
  // A grammar is a few characters; testing more of a long left context costs a pass over it per BEGIN.
564
569
  const PREFIX_GRAMMAR_SCAN = 256;
570
+ // How far escaped text is searched back for the start of a BEGIN's line past single quotes (D#614 A3).
571
+ // It was PREFIX_GRAMMAR_SCAN, and a code line of more than 256 characters before its last quote
572
+ // (keyword arguments, a dict literal) left no grammar, so the key under it was stored. Not unbounded:
573
+ // the walks of BEGINs at one escape depth never overlap (each BEGIN's break ends the next one's
574
+ // walk), but those at different depths cross the same run, judging each quote or backslash in it.
575
+ // One BEGIN per depth (1, 2, 4, 8) after 150k characters of escaped quotes read 18x benign under
576
+ // coverage unbounded, 1.2x at this bound.
577
+ const LINE_START_SCAN = 4096;
578
+ // From a position back over the characters that cannot end a line in escaped text: anything but a
579
+ // break, a double quote or a backslash. A lookbehind is matched backward, so this runs natively.
580
+ const LINE_BACK_RE = /(?<=([^\n\r"\\]*))/y;
565
581
  // A key line (LONG or CUT) starts with a run of 16+ of these, so a stretch without one holds none.
566
582
  const B64_RUN16_RE = /[A-Za-z0-9+/=]{16}/;
567
583
  // The longest gap the D#168 skip tests; past it the reading runs.
@@ -776,52 +792,83 @@ function cutOffKeyEnd(text, b, be, ctx) {
776
792
  // The grammar starts the line. In escaped text the prefix above stops at an unescaped single
777
793
  // quote, which JSON never escapes (`-KEY = '''` in a JSON string leaves ''), so look past single
778
794
  // quotes for the start of the line: a break, or a double quote that ends a string at this depth
779
- // (the string the line is in). At most PREFIX_GRAMMAR_SCAN characters back; past that, no grammar.
795
+ // (the string the line is in), or the start of the text. At most LINE_START_SCAN characters back;
796
+ // past that, no grammar.
780
797
  let gl = ls;
781
798
  if (u > 0 && ls > 0 && text[ls - 1] === "'") {
782
799
  gl = -1;
783
- for (let j = ls - 1, lim = Math.max(0, ls - PREFIX_GRAMMAR_SCAN); j >= lim; j--) {
784
- if (j === 0) {
785
- gl = 0;
800
+ // Native between candidates: a character by character walk was most of the time of a shape
801
+ // that repeats one 300-character line (pemEscapedLongCodeBeforeBegin), and now goes the whole line.
802
+ const lim = Math.max(0, ls - LINE_START_SCAN);
803
+ for (let j = ls - 1; ;) {
804
+ LINE_BACK_RE.lastIndex = j;
805
+ const k = j - LINE_BACK_RE.exec(text)[1].length;
806
+ if (k === 0) {
807
+ if (lim === 0) gl = 0;
786
808
  break;
787
809
  }
788
- const ch = text[j - 1];
789
- if (
790
- ch === '\n' ||
791
- ch === '\r' ||
792
- ((ch === 'n' || ch === 'r') && isEscBreak(backslashesBefore(text, j - 1, 0), u)) ||
793
- (ch === '"' && isStringEnd(backslashesBefore(text, j - 1, 0), u))
794
- ) {
795
- gl = j;
810
+ // text[k - 1] is a break, a double quote or a backslash. A backslash run then `n` or `r` at k
811
+ // is an escaped break at this depth when the run fits it; the line starts after that letter.
812
+ const c = text.charCodeAt(k - 1);
813
+ if (c === 92) {
814
+ const e = text.charCodeAt(k);
815
+ if (k + 1 < lim) break;
816
+ if ((e === 110 || e === 114) && isEscBreak(backslashesBefore(text, k, 0), u)) {
817
+ gl = k + 1;
818
+ break;
819
+ }
820
+ } else if (k < lim) break;
821
+ else if (c === 10 || c === 13 || isStringEnd(backslashesBefore(text, k - 1, 0), u)) {
822
+ gl = k;
796
823
  break;
797
824
  }
825
+ j = k - 1;
798
826
  }
799
827
  }
800
- const g =
801
- gl === -1 ? null : PREFIX_GRAMMAR_RE.exec(text.slice(gl, Math.min(b, gl + PREFIX_GRAMMAR_SCAN)));
828
+ const head = gl === -1 ? '' : text.slice(gl, Math.min(b, gl + PREFIX_GRAMMAR_SCAN));
829
+ const g = gl === -1 ? null : PREFIX_GRAMMAR_RE.exec(head);
802
830
  const gs = g ? gl + g[0].length - g[1].length : -1;
803
831
  let gp = gl;
804
832
  while (gp < b && (text.charCodeAt(gp) === 32 || text.charCodeAt(gp) === 9)) gp++;
833
+ // The lines below read again with the shape of `prefix`, whose first character after blanks is
834
+ // `lead`: where the key they hold ends, or -1.
835
+ const reread = (prefix, lead) => {
836
+ const alt = ctx.shapeOf(prefix);
837
+ if (!alt || ctx.endFollows(be)) return -1;
838
+ const again = readKeyLines(text, next, u, alt, lead, longs, longest, first, end, ctx.memoOf);
839
+ if (!(again.longs > 0 && again.end > found && keyEvidence(again, label, false))) return -1;
840
+ ctx.reread = true;
841
+ return again.end;
842
+ };
805
843
  // Only when the line is more than its grammar before the BEGIN: an opener before it or code after it.
806
844
  if (g && !(gs === gp && gl + g[0].length === b)) {
807
- const alt = ctx.shapeOf(g[1]);
808
- if (alt && !ctx.endFollows(be)) {
809
- let lead = gs;
810
- while (text.charCodeAt(lead) === 32 || text.charCodeAt(lead) === 9) lead++;
811
- const again = readKeyLines(
812
- text,
813
- next,
814
- u,
815
- alt,
816
- text.charCodeAt(lead),
817
- longs,
818
- longest,
819
- first,
820
- end,
821
- ctx.memoOf,
822
- );
823
- if (again.longs > 0 && again.end > found && keyEvidence(again, label, false)) return again.end;
824
- }
845
+ let lead = gs;
846
+ while (text.charCodeAt(lead) === 32 || text.charCodeAt(lead) === 9) lead++;
847
+ const r = reread(g[1], text.charCodeAt(lead));
848
+ if (r !== -1) return r;
849
+ }
850
+ // D#614 A2: a grep column after a path the grammar refuses; not the column the grammar read
851
+ // already, nor the first reading's own prefix. That prefix is the column whenever nothing stands
852
+ // between it and the BEGIN, except in escaped text after a quote in the path (`it's/`), where the
853
+ // prefix starts past the quote.
854
+ const p = gl === -1 ? null : GREP_ANY_PATH_RE.exec(head);
855
+ if (p && !(g && g[1] === p[1]) && p[1] !== left.replace(/^[ \t]+/, '')) {
856
+ const r = reread(p[1], text.charCodeAt(gl + p[0].length - p[1].length));
857
+ if (r !== -1) return r;
858
+ }
859
+ // D#614 A1: a unified diff's context line starts with its space, with code after it or none, and
860
+ // the removed and added lines below it with `-` and `+`, which the line prefix (that space, or the
861
+ // code) never matched. They are read with a diff mark's shape, which takes a context line too.
862
+ // Only when the next line starts with a mark: Read output starts its lines with spaces as well,
863
+ // and a reading there took the next line's number for a key's short last line. Nor when the line
864
+ // holds an escaped break of another depth: it is then several lines, the first one led by a space.
865
+ if (
866
+ text.charCodeAt(gl) === 32 &&
867
+ (text[next] === '-' || text[next] === '+') &&
868
+ !/\\[nr]/.test(text.slice(gl, b))
869
+ ) {
870
+ const r = reread('-', 45);
871
+ if (r !== -1) return r;
825
872
  }
826
873
  }
827
874
  return found;
@@ -981,6 +1028,7 @@ function readKeyLines(text, next, u, shape, shapeLead, longs, longest, first, en
981
1028
  const KEY_BEGIN_SCAN_RE = new RegExp(KEY_BEGIN_RE.source, 'g');
982
1029
  const KEY_END_SCAN_RE = new RegExp(KEY_END_RE.source, 'g');
983
1030
  const KEY_BEGIN_NEXT_RE = new RegExp(KEY_BEGIN_RE.source, 'g');
1031
+ const KEY_BEGIN_INNER_RE = new RegExp(KEY_BEGIN_RE.source, 'g');
984
1032
 
985
1033
  /** Start offsets of every match of the global regex `re` in `text`. */
986
1034
  function matchStarts(re, text) {
@@ -1051,14 +1099,29 @@ function scrubCutOffKeys(text) {
1051
1099
  if (m === undefined) memos.set(id, (m = { blank: new Map(), long: new Map() }));
1052
1100
  return m;
1053
1101
  };
1054
- const ctx = { endFollows, nextBegin, shapeOf, memoOf };
1102
+ const ctx = { endFollows, nextBegin, shapeOf, memoOf, reread: false };
1055
1103
  KEY_BEGIN_RE.lastIndex = 0;
1056
1104
  let out = '';
1057
1105
  let last = 0;
1058
1106
  let m;
1059
1107
  while ((m = KEY_BEGIN_RE.exec(text))) {
1060
- const end = cutOffKeyEnd(text, m.index, m.index + m[0].length, ctx);
1108
+ ctx.reread = false;
1109
+ let end = cutOffKeyEnd(text, m.index, m.index + m[0].length, ctx);
1061
1110
  if (end === -1) continue;
1111
+ // D#614 A4 (D#633): a span read again with a named grammar's shape can take a header line that
1112
+ // holds another private-key BEGIN for an armor header and end where that BEGIN's own reading goes
1113
+ // on (a 15-character line, a line that is only its prefix, another header). The span covered the
1114
+ // BEGIN, which then started no reading, so the lines past the span were stored; 6.30.8, whose
1115
+ // first reading found nothing there, read the inner BEGIN and erased them. Each private-key BEGIN
1116
+ // inside such a span is read too, and the span ends where the farthest of them ends. Only for these
1117
+ // readings: under a BEGIN with nothing before it the same holds in 6.30.8 (a separate defect).
1118
+ if (ctx.reread) {
1119
+ KEY_BEGIN_INNER_RE.lastIndex = m.index + m[0].length;
1120
+ for (let n; (n = KEY_BEGIN_INNER_RE.exec(text)) && n.index < end;) {
1121
+ const e = cutOffKeyEnd(text, n.index, n.index + n[0].length, ctx);
1122
+ if (e > end) end = e;
1123
+ }
1124
+ }
1062
1125
  out += text.slice(last, m.index) + PEM_MARK;
1063
1126
  last = end;
1064
1127
  KEY_BEGIN_RE.lastIndex = end;