claude-db 0.5.1 → 0.5.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.
- package/CHANGELOG.md +27 -0
- package/LICENSE +1 -1
- package/dist/capture/transcript.js +1 -1
- package/dist/capture/turn-extractor.js +16 -6
- package/dist/cli/usage.js +4 -2
- package/dist/hooks/relevance.d.ts +0 -1
- package/dist/hooks/relevance.js +0 -72
- package/dist/hooks/user-prompt.js +2 -1
- package/dist/util/prompt.d.ts +1 -0
- package/dist/util/prompt.js +72 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.5.2
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **A turn that answered a question was never stored.** Capture kept a turn only
|
|
8
|
+
if it edited a file or ran a command, so an entire session spent explaining a
|
|
9
|
+
design, weighing an approach, or answering "why is it like this" left nothing
|
|
10
|
+
behind — the reasoning most worth recalling was the reasoning most reliably
|
|
11
|
+
dropped. A turn with no files and no commands is now kept when the question
|
|
12
|
+
was a real one and the answer reports something concrete. Re-reading this
|
|
13
|
+
project's own transcripts recovers 66 observations that were silently
|
|
14
|
+
discarded; `claude-db flush` backfills them, since ids are content-derived and
|
|
15
|
+
a re-read rewrites rather than duplicates.
|
|
16
|
+
- **A compaction summary was read as your prompt.** When a session is compacted,
|
|
17
|
+
Claude Code writes an 18,000-character recap into the transcript as a user
|
|
18
|
+
entry. Capture treated it as a real prompt, so every turn after a compaction
|
|
19
|
+
was filed under `Asked: This session is being continued from a previous
|
|
20
|
+
conversation…` and that recap was indexed as if it were a memory. Those
|
|
21
|
+
entries are now skipped by the flag the transcript already carries.
|
|
22
|
+
- **`scan` was missing from `claude-db --help`.** The command shipped in 0.5.0
|
|
23
|
+
and worked, but nothing in the help text mentioned it, and the `usages` line
|
|
24
|
+
still described the old grep-only behaviour with no sign of `--mode`.
|
|
25
|
+
- **Underscores were stripped out of titles.** Title generation treated `_` as
|
|
26
|
+
markdown emphasis, so `find_usages` was stored as `findusages` and every other
|
|
27
|
+
snake_case identifier was mangled. Snippets stopped doing this in 0.3.0;
|
|
28
|
+
titles now match.
|
|
29
|
+
|
|
3
30
|
## 0.5.1
|
|
4
31
|
|
|
5
32
|
### Fixed
|
package/LICENSE
CHANGED
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
same "printed page" as the copyright notice for easier
|
|
187
187
|
identification within third-party archives.
|
|
188
188
|
|
|
189
|
-
Copyright 2026
|
|
189
|
+
Copyright 2026 Avijit Dey
|
|
190
190
|
|
|
191
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
192
|
you may not use this file except in compliance with the License.
|
|
@@ -46,7 +46,7 @@ function groupIntoTurns(entries) {
|
|
|
46
46
|
const timestamp = Date.parse(entry.timestamp ?? '') || Date.now();
|
|
47
47
|
if (entry.type === 'user') {
|
|
48
48
|
const text = extractText(entry.message?.content);
|
|
49
|
-
if (!text || isSyntheticPrompt(text))
|
|
49
|
+
if (!text || entry.isCompactSummary || isSyntheticPrompt(text))
|
|
50
50
|
continue;
|
|
51
51
|
if (current)
|
|
52
52
|
turns.push(current);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { classifyCommand } from './command.js';
|
|
2
|
+
import { isSearchable } from '../util/prompt.js';
|
|
2
3
|
import { currentAuthor, observationId } from './identity.js';
|
|
3
4
|
export function observationsFromTurns(turns, sessionId, project, config) {
|
|
4
5
|
return turns
|
|
@@ -8,7 +9,13 @@ export function observationsFromTurns(turns, sessionId, project, config) {
|
|
|
8
9
|
function isSubstantive(turn, config) {
|
|
9
10
|
const files = turn.files.filter((file) => !isExcluded(file, config.capture.exclude));
|
|
10
11
|
const commands = turn.commands.filter((command) => classifyCommand(command) !== null);
|
|
11
|
-
|
|
12
|
+
if (files.length > 0 || commands.length > 0)
|
|
13
|
+
return true;
|
|
14
|
+
return isSearchable(turn.prompt) && answers(turn.reasoning);
|
|
15
|
+
}
|
|
16
|
+
function answers(reasoning) {
|
|
17
|
+
const scored = scoreSentences(stripMarkdown(redact(reasoning)));
|
|
18
|
+
return scored.length >= 2 && scored.some(([, score]) => score > 0);
|
|
12
19
|
}
|
|
13
20
|
function buildObservation(turn, sessionId, project, config) {
|
|
14
21
|
const files = [...new Set(turn.files.filter((f) => !isExcluded(f, config.capture.exclude)))];
|
|
@@ -61,10 +68,7 @@ function reports(sentence) {
|
|
|
61
68
|
}
|
|
62
69
|
function buildTitle(turn, files) {
|
|
63
70
|
const prose = stripMarkdown(redact(turn.reasoning));
|
|
64
|
-
const scored =
|
|
65
|
-
.slice(0, 6)
|
|
66
|
-
.filter((sentence) => sentence.length >= 15)
|
|
67
|
-
.map((sentence) => [sentence, reports(sentence)]);
|
|
71
|
+
const scored = scoreSentences(prose);
|
|
68
72
|
const best = scored.find(([, score]) => score > 0) ?? scored.find(([, score]) => score === 0);
|
|
69
73
|
if (best)
|
|
70
74
|
return headline(best[0]);
|
|
@@ -76,6 +80,12 @@ function buildTitle(turn, files) {
|
|
|
76
80
|
return headline(opening);
|
|
77
81
|
return files.length > 0 ? `Changed ${shortPath(files[0] ?? '')}` : 'Session work';
|
|
78
82
|
}
|
|
83
|
+
function scoreSentences(prose) {
|
|
84
|
+
return sentences(prose)
|
|
85
|
+
.slice(0, 6)
|
|
86
|
+
.filter((sentence) => sentence.length >= 15)
|
|
87
|
+
.map((sentence) => [sentence, reports(sentence)]);
|
|
88
|
+
}
|
|
79
89
|
function sentences(text) {
|
|
80
90
|
return text
|
|
81
91
|
.split(/(?<=[.!?])\s+|\n+/)
|
|
@@ -131,7 +141,7 @@ function firstSentence(text) {
|
|
|
131
141
|
function stripMarkdown(text) {
|
|
132
142
|
return text
|
|
133
143
|
.replace(/\[([^\]]+)\]\([^)]*\)/g, '$1')
|
|
134
|
-
.replace(/[
|
|
144
|
+
.replace(/[*`#]/g, '')
|
|
135
145
|
.trim();
|
|
136
146
|
}
|
|
137
147
|
function shortPath(path) {
|
package/dist/cli/usage.js
CHANGED
|
@@ -17,8 +17,10 @@ export function usage() {
|
|
|
17
17
|
stats What this project's memory is made of
|
|
18
18
|
flush Re-ingest every transcript for this project
|
|
19
19
|
seed --from-git [--limit n] Fill a cold memory from this repo's history
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
scan [--force] Map this repo's symbols and how they connect
|
|
21
|
+
usages [--mode m] <symbol> Who uses a symbol; --mode usages|explain|path
|
|
22
|
+
[--target <symbol>] ...the second symbol, for --mode path
|
|
23
|
+
[--regex] [--context n] [--path <dir>] [--limit n]
|
|
22
24
|
export [--all] > out.jsonl Dump memory as JSONL, for backup or migration
|
|
23
25
|
import <file.jsonl> Load a dump back in (safe to repeat)
|
|
24
26
|
sync <url> [--yes] Two-way merge with another database
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import type { Observation, ObservationIndexEntry } from '../types.js';
|
|
2
|
-
export declare function isSearchable(prompt: string): boolean;
|
|
3
2
|
export declare function renderPromptContext(entries: ObservationIndexEntry[], maxChars: number, expanded?: Observation[], expandMaxChars?: number): string | null;
|
package/dist/hooks/relevance.js
CHANGED
|
@@ -1,76 +1,4 @@
|
|
|
1
1
|
import { toShortId } from '../util/shortid.js';
|
|
2
|
-
const TRIVIAL = new Set([
|
|
3
|
-
'ok',
|
|
4
|
-
'okay',
|
|
5
|
-
'yes',
|
|
6
|
-
'no',
|
|
7
|
-
'yep',
|
|
8
|
-
'nope',
|
|
9
|
-
'sure',
|
|
10
|
-
'thanks',
|
|
11
|
-
'thank you',
|
|
12
|
-
'continue',
|
|
13
|
-
'go on',
|
|
14
|
-
'go ahead',
|
|
15
|
-
'next',
|
|
16
|
-
'stop',
|
|
17
|
-
'wait',
|
|
18
|
-
'done',
|
|
19
|
-
'good',
|
|
20
|
-
'nice',
|
|
21
|
-
'perfect',
|
|
22
|
-
'great',
|
|
23
|
-
'do it',
|
|
24
|
-
'proceed',
|
|
25
|
-
'retry',
|
|
26
|
-
'again',
|
|
27
|
-
'fix it',
|
|
28
|
-
]);
|
|
29
|
-
const NOISE = new Set([
|
|
30
|
-
'the',
|
|
31
|
-
'and',
|
|
32
|
-
'for',
|
|
33
|
-
'this',
|
|
34
|
-
'that',
|
|
35
|
-
'with',
|
|
36
|
-
'you',
|
|
37
|
-
'can',
|
|
38
|
-
'please',
|
|
39
|
-
'now',
|
|
40
|
-
'what',
|
|
41
|
-
'why',
|
|
42
|
-
'how',
|
|
43
|
-
'when',
|
|
44
|
-
'where',
|
|
45
|
-
'are',
|
|
46
|
-
'was',
|
|
47
|
-
'were',
|
|
48
|
-
'have',
|
|
49
|
-
'has',
|
|
50
|
-
'not',
|
|
51
|
-
'let',
|
|
52
|
-
'make',
|
|
53
|
-
'get',
|
|
54
|
-
'add',
|
|
55
|
-
'use',
|
|
56
|
-
'need',
|
|
57
|
-
'want',
|
|
58
|
-
'should',
|
|
59
|
-
]);
|
|
60
|
-
const DENSE_SCRIPT = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/gu;
|
|
61
|
-
export function isSearchable(prompt) {
|
|
62
|
-
const normalized = prompt.trim().toLowerCase();
|
|
63
|
-
if (TRIVIAL.has(normalized.replace(/[.!?]+$/, '')))
|
|
64
|
-
return false;
|
|
65
|
-
if ((normalized.match(DENSE_SCRIPT)?.length ?? 0) >= 4)
|
|
66
|
-
return true;
|
|
67
|
-
if (normalized.length < 8)
|
|
68
|
-
return false;
|
|
69
|
-
const content = normalized
|
|
70
|
-
.split(/[^\p{L}\p{N}_]+/u)
|
|
71
|
-
.filter((word) => word.length > 2 && !NOISE.has(word));
|
|
72
|
-
return content.length >= 2;
|
|
73
|
-
}
|
|
74
2
|
export function renderPromptContext(entries, maxChars, expanded = [], expandMaxChars = 900) {
|
|
75
3
|
if (entries.length === 0)
|
|
76
4
|
return null;
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import { flushSession } from '../capture/index.js';
|
|
3
3
|
import { createContext } from '../context.js';
|
|
4
4
|
import { emitContext, readPayload, runHook } from './payload.js';
|
|
5
|
-
import {
|
|
5
|
+
import { renderPromptContext } from './relevance.js';
|
|
6
|
+
import { isSearchable } from '../util/prompt.js';
|
|
6
7
|
import { resolveProject } from '../util/project.js';
|
|
7
8
|
import { silenceSqliteWarning } from '../util/warnings.js';
|
|
8
9
|
silenceSqliteWarning();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isSearchable(prompt: string): boolean;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
const TRIVIAL = new Set([
|
|
2
|
+
'ok',
|
|
3
|
+
'okay',
|
|
4
|
+
'yes',
|
|
5
|
+
'no',
|
|
6
|
+
'yep',
|
|
7
|
+
'nope',
|
|
8
|
+
'sure',
|
|
9
|
+
'thanks',
|
|
10
|
+
'thank you',
|
|
11
|
+
'continue',
|
|
12
|
+
'go on',
|
|
13
|
+
'go ahead',
|
|
14
|
+
'next',
|
|
15
|
+
'stop',
|
|
16
|
+
'wait',
|
|
17
|
+
'done',
|
|
18
|
+
'good',
|
|
19
|
+
'nice',
|
|
20
|
+
'perfect',
|
|
21
|
+
'great',
|
|
22
|
+
'do it',
|
|
23
|
+
'proceed',
|
|
24
|
+
'retry',
|
|
25
|
+
'again',
|
|
26
|
+
'fix it',
|
|
27
|
+
]);
|
|
28
|
+
const NOISE = new Set([
|
|
29
|
+
'the',
|
|
30
|
+
'and',
|
|
31
|
+
'for',
|
|
32
|
+
'this',
|
|
33
|
+
'that',
|
|
34
|
+
'with',
|
|
35
|
+
'you',
|
|
36
|
+
'can',
|
|
37
|
+
'please',
|
|
38
|
+
'now',
|
|
39
|
+
'what',
|
|
40
|
+
'why',
|
|
41
|
+
'how',
|
|
42
|
+
'when',
|
|
43
|
+
'where',
|
|
44
|
+
'are',
|
|
45
|
+
'was',
|
|
46
|
+
'were',
|
|
47
|
+
'have',
|
|
48
|
+
'has',
|
|
49
|
+
'not',
|
|
50
|
+
'let',
|
|
51
|
+
'make',
|
|
52
|
+
'get',
|
|
53
|
+
'add',
|
|
54
|
+
'use',
|
|
55
|
+
'need',
|
|
56
|
+
'want',
|
|
57
|
+
'should',
|
|
58
|
+
]);
|
|
59
|
+
const DENSE_SCRIPT = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/gu;
|
|
60
|
+
export function isSearchable(prompt) {
|
|
61
|
+
const normalized = prompt.trim().toLowerCase();
|
|
62
|
+
if (TRIVIAL.has(normalized.replace(/[.!?]+$/, '')))
|
|
63
|
+
return false;
|
|
64
|
+
if ((normalized.match(DENSE_SCRIPT)?.length ?? 0) >= 4)
|
|
65
|
+
return true;
|
|
66
|
+
if (normalized.length < 8)
|
|
67
|
+
return false;
|
|
68
|
+
const content = normalized
|
|
69
|
+
.split(/[^\p{L}\p{N}_]+/u)
|
|
70
|
+
.filter((word) => word.length > 2 && !NOISE.has(word));
|
|
71
|
+
return content.length >= 2;
|
|
72
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-db",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.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",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"url": "https://github.com/Avijit07x/claude-db/issues"
|
|
102
102
|
},
|
|
103
103
|
"homepage": "https://github.com/Avijit07x/claude-db#readme",
|
|
104
|
-
"author": "
|
|
104
|
+
"author": "Avijit Dey",
|
|
105
105
|
"publishConfig": {
|
|
106
106
|
"access": "public"
|
|
107
107
|
}
|