claude-db 0.2.3 → 0.3.0
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/README.md +16 -4
- package/dist/capture/flush.d.ts +20 -1
- package/dist/capture/flush.js +45 -5
- package/dist/capture/git.d.ts +2 -0
- package/dist/capture/git.js +96 -0
- package/dist/capture/index.d.ts +4 -3
- package/dist/capture/index.js +4 -3
- package/dist/capture/manual.d.ts +9 -0
- package/dist/capture/manual.js +0 -0
- package/dist/capture/transcript.d.ts +8 -0
- package/dist/capture/transcript.js +30 -0
- package/dist/capture/turn-extractor.d.ts +9 -1
- package/dist/capture/turn-extractor.js +74 -13
- package/dist/cli/index.js +383 -27
- package/dist/cli/install.d.ts +8 -0
- package/dist/cli/install.js +24 -0
- package/dist/mcp/render.d.ts +23 -0
- package/dist/mcp/render.js +49 -0
- package/dist/mcp/server.d.ts +1 -7
- package/dist/mcp/server.js +37 -36
- package/dist/store/adapter.d.ts +10 -0
- package/dist/store/adapter.js +8 -0
- package/dist/store/mongo/index.d.ts +1 -0
- package/dist/store/mongo/index.js +34 -3
- package/dist/store/postgres/index.d.ts +15 -0
- package/dist/store/postgres/index.js +89 -4
- package/dist/store/sqlite/index.d.ts +1 -0
- package/dist/store/sqlite/index.js +32 -2
- package/dist/types.d.ts +16 -0
- package/dist/util/snippet.d.ts +28 -0
- package/dist/util/snippet.js +52 -0
- package/package.json +2 -1
- package/skills/cdb-scan/SKILL.md +72 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shaping for the two places a body is shown in part rather than in full.
|
|
3
|
+
*
|
|
4
|
+
* Layer 1 was built on the assumption that a title tells you which row holds
|
|
5
|
+
* the answer. It often does not — "Committed as 30daa92" is a true report of an
|
|
6
|
+
* outcome and says nothing about whether to expand it — so a search returned
|
|
7
|
+
* fifteen rows that all looked alike and the only way to choose was to guess.
|
|
8
|
+
* A snippet costs about sixty characters and saves a whole body per wrong
|
|
9
|
+
* guess, which is the trade the terse index was making in the wrong direction.
|
|
10
|
+
*/
|
|
11
|
+
const SNIPPET_MAX = 110;
|
|
12
|
+
/**
|
|
13
|
+
* One line, whitespace collapsed, clipped at a word boundary.
|
|
14
|
+
*
|
|
15
|
+
* Bodies carry newlines, markdown tables and code, none of which survive being
|
|
16
|
+
* shown on one line of an index; and the search engines wrap matches in their
|
|
17
|
+
* own markers, which are noise once the fragment is already the point.
|
|
18
|
+
*/
|
|
19
|
+
export function toSnippet(text, max = SNIPPET_MAX) {
|
|
20
|
+
if (typeof text !== 'string')
|
|
21
|
+
return undefined;
|
|
22
|
+
// Backticks, pipes and asterisks are markup and only ever noise on one line.
|
|
23
|
+
// Underscores and hashes are left alone: they are far more often part of an
|
|
24
|
+
// identifier than of emphasis, and stripping them turned
|
|
25
|
+
// `aggregation_cursor.js` into two words that match nothing.
|
|
26
|
+
const flat = text
|
|
27
|
+
.replace(/<\/?b>/g, '')
|
|
28
|
+
.replace(/[|`*]+/g, ' ')
|
|
29
|
+
.replace(/\s+/g, ' ')
|
|
30
|
+
.trim();
|
|
31
|
+
if (flat.length === 0)
|
|
32
|
+
return undefined;
|
|
33
|
+
if (flat.length <= max)
|
|
34
|
+
return flat;
|
|
35
|
+
const cut = flat.slice(0, max);
|
|
36
|
+
const word = cut.lastIndexOf(' ');
|
|
37
|
+
return `${cut.slice(0, word > max * 0.6 ? word : max)}…`;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Bounds a full body at layer 3.
|
|
41
|
+
*
|
|
42
|
+
* The cost argument that made the index terse was never applied one layer down,
|
|
43
|
+
* where a single call may ask for twenty-five bodies at once — so the multiplier
|
|
44
|
+
* is far worse there than in the index it was written for. The remainder is
|
|
45
|
+
* counted rather than dropped silently, because a reader who needs the rest has
|
|
46
|
+
* to know it exists.
|
|
47
|
+
*/
|
|
48
|
+
export function clipBody(body, max) {
|
|
49
|
+
if (body.length <= max)
|
|
50
|
+
return body;
|
|
51
|
+
return `${body.slice(0, max)}\n… ${body.length - max} more characters (raise \`chars\` to read them)`;
|
|
52
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-db",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
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",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
18
|
"dist",
|
|
19
|
+
"skills",
|
|
19
20
|
"README.md",
|
|
20
21
|
"LICENSE"
|
|
21
22
|
],
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cdb-scan
|
|
3
|
+
description: Survey this codebase once and store a profile of it in project memory — stack, layout, conventions, workflows. Re-run any time to refresh it in place. Use when memory is newly installed on an existing project, or when the project has changed enough that the stored profile is stale.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Survey this project into memory
|
|
7
|
+
|
|
8
|
+
Everything else in claude-db's memory is testimony: it records what happened,
|
|
9
|
+
turn by turn, as it happened. A fresh install knows none of that, and stays
|
|
10
|
+
useless for weeks while it fills up.
|
|
11
|
+
|
|
12
|
+
This fills the gap from the one source available on day one — the code itself.
|
|
13
|
+
What you write here is **your reading of the codebase, not a record of events**,
|
|
14
|
+
so it is tagged `inferred` and must never be phrased as history.
|
|
15
|
+
|
|
16
|
+
## How to run it
|
|
17
|
+
|
|
18
|
+
Work through the sections below in order. For each one, look at the actual
|
|
19
|
+
files, then call the `remember` MCP tool once with the given `key`.
|
|
20
|
+
|
|
21
|
+
`key` is what makes this re-runnable: writing the same key again replaces that
|
|
22
|
+
note rather than adding a second copy. Use these exact keys, and always pass
|
|
23
|
+
`tags: ["inferred"]` and `kind: "context"`.
|
|
24
|
+
|
|
25
|
+
Before you start, call `search` for `profile` in this project. If notes already
|
|
26
|
+
exist, read them first and update what changed rather than restating it — a
|
|
27
|
+
second run should be an edit, not a rewrite.
|
|
28
|
+
|
|
29
|
+
### 1. `profile:stack`
|
|
30
|
+
|
|
31
|
+
Languages, runtime and version floors, frameworks, package manager, database,
|
|
32
|
+
test runner, build tool. Read the manifest (`package.json`, `pyproject.toml`,
|
|
33
|
+
`go.mod`, `Cargo.toml`) and the lockfile rather than guessing. Name versions
|
|
34
|
+
where a version constrains what can be written.
|
|
35
|
+
|
|
36
|
+
### 2. `profile:layout`
|
|
37
|
+
|
|
38
|
+
The directory map, one line each, and what lives where. Include the entry
|
|
39
|
+
points: the binary, the server, the main export. Skip anything generated.
|
|
40
|
+
|
|
41
|
+
### 3. `profile:conventions`
|
|
42
|
+
|
|
43
|
+
How this codebase is written, taken from the code and not from a style guide:
|
|
44
|
+
module system, import style, error handling, naming, comment density, how
|
|
45
|
+
tests are structured. Note where the project deviates from the language default,
|
|
46
|
+
since that is what someone would otherwise get wrong.
|
|
47
|
+
|
|
48
|
+
### 4. `profile:workflows`
|
|
49
|
+
|
|
50
|
+
The commands that matter — install, build, test, lint, run, release — and
|
|
51
|
+
anything non-obvious about running them: a required service, an environment
|
|
52
|
+
variable, a step that must come first. Take them from the manifest scripts and
|
|
53
|
+
CI config, not from the README's aspirations.
|
|
54
|
+
|
|
55
|
+
### 5. `profile:architecture`
|
|
56
|
+
|
|
57
|
+
Only the parts a newcomer could not infer from the layout: the main
|
|
58
|
+
abstractions and how a request or a command actually flows through them. Two
|
|
59
|
+
paragraphs at most. If the codebase is small enough that the layout says it
|
|
60
|
+
all, skip this section rather than padding it.
|
|
61
|
+
|
|
62
|
+
## Rules
|
|
63
|
+
|
|
64
|
+
- **One `remember` call per section.** Five notes, five stable keys.
|
|
65
|
+
- **Write claims, not headings.** "Storage is one `MemoryStore` interface with
|
|
66
|
+
three adapters, selected by URI scheme" — not "Storage architecture".
|
|
67
|
+
- **Say what you verified.** If something was not read, leave it out. An
|
|
68
|
+
inferred profile that is confidently wrong is worse than a short one.
|
|
69
|
+
- **Never restate `CLAUDE.md`.** That file is already in the system prompt on
|
|
70
|
+
every turn. Memory is for what is not.
|
|
71
|
+
- **Do not record secrets, credentials or personal data**, even if the code
|
|
72
|
+
contains them.
|