claude-db 0.2.1 → 0.2.2

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.
@@ -56,22 +56,51 @@ function buildObservation(turn, sessionId, project, config) {
56
56
  };
57
57
  }
58
58
  /**
59
- * Prefers the agent's own opening sentence over the raw prompt.
59
+ * Sentences that announce work rather than report it.
60
+ *
61
+ * The original rule took the reply's opening sentence, assuming it stated the
62
+ * outcome. Mid-task it almost never does: it says "Now the use command and the
63
+ * top-level handler:" or "Right — let me do that properly". Measured on a real
64
+ * database, about half of all titles were transitions like these, which is fatal
65
+ * because the title is the whole payload of a search result and of the injected
66
+ * block — the body may hold the answer, but nothing ever surfaces it.
67
+ */
68
+ const ANNOUNCEMENT = /^(now|next|then|first|right|ok|okay|good question|great|sure|perfect|let me|let's|i'?ll|here'?s|two|three|four|before|starting|continuing)\b/i;
69
+ function announces(sentence) {
70
+ return sentence.endsWith(':') || ANNOUNCEMENT.test(sentence);
71
+ }
72
+ /**
73
+ * Prefers the first sentence of the reply that reports something.
60
74
  *
61
75
  * The prompt states a request ("can you create one icon"); the reply states
62
76
  * what actually happened ("Built mouse-scroll-icon.tsx, first of the Huge
63
77
  * Tier 1 Gestures batch"). The second is what someone searching their history
64
- * is looking for, and it is written in the vocabulary of the codebase.
78
+ * is looking for, and it is written in the vocabulary of the codebase — but
79
+ * only once the throat-clearing in front of it is skipped.
65
80
  */
66
81
  function buildTitle(turn, files) {
67
- const sentence = firstSentence(stripMarkdown(turn.reasoning));
68
- if (sentence && sentence.length >= 15)
69
- return headline(sentence);
82
+ const prose = stripMarkdown(turn.reasoning);
83
+ // Bounded: past the first few sentences a reply has moved on to detail that
84
+ // no longer summarises the turn.
85
+ for (const sentence of sentences(prose).slice(0, 6)) {
86
+ if (sentence.length >= 15 && !announces(sentence))
87
+ return headline(sentence);
88
+ }
89
+ const opening = firstSentence(prose);
90
+ if (opening && opening.length >= 15)
91
+ return headline(opening);
70
92
  const prompt = firstSentence(turn.prompt);
71
93
  if (prompt)
72
94
  return headline(prompt);
73
95
  return files.length > 0 ? `Changed ${shortPath(files[0] ?? '')}` : 'Session work';
74
96
  }
97
+ /** Split on sentence enders followed by space, so "0.2.1" stays intact. */
98
+ function sentences(text) {
99
+ return text
100
+ .split(/(?<=[.!?])\s+|\n+/)
101
+ .map((sentence) => sentence.trim())
102
+ .filter((sentence) => sentence.length > 0);
103
+ }
75
104
  const TITLE_MAX = 80;
76
105
  /**
77
106
  * Trims a sentence to a scannable headline.
@@ -43,10 +43,14 @@ const INSTRUCTIONS = [
43
43
  'MCP server. Session summaries are injected at startup and the best matching',
44
44
  'observation is injected above each prompt, but that is only ever a slice.',
45
45
  '',
46
- 'Before saying you lack context on this codebase, or asking the user to',
47
- 're-explain a past decision, a failed approach, or why something is the way',
48
- 'it is: call `search` first, then `get_observations` for the ids worth',
49
- 'reading. Treat asking the user as the fallback, not the first move.',
46
+ 'Search it *before* re-deriving something this project already knows. That',
47
+ 'means before grepping or reading git history to reconstruct why something is',
48
+ 'the way it is, before saying you lack context, and before asking the user to',
49
+ 're-explain a past decision or a failed approach: call `search`, then',
50
+ '`get_observations` for the ids worth reading.',
51
+ '',
52
+ 'Verifying against the code afterwards is right — memory records what was',
53
+ 'done, the source shows what is. Starting there is what wastes the memory.',
50
54
  '',
51
55
  'When the user states a standing rule or preference, record it with',
52
56
  '`remember` so it survives this session.',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-db",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Persistent memory for Claude Code. Captures why decisions were made, not just which files changed. Bring your own database: SQLite, MongoDB or Postgres. No cloud, no subscription.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",