claude-db 0.4.0 → 0.4.1
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/dist/cli/install.js +7 -6
- package/dist/mcp/server.js +4 -2
- package/dist/usages/find.js +20 -4
- package/package.json +1 -1
package/dist/cli/install.js
CHANGED
|
@@ -74,12 +74,13 @@ const INSTRUCTIONS = [
|
|
|
74
74
|
'Verifying against the code afterwards is right — memory records what was',
|
|
75
75
|
'done, the source shows what is. Starting there is what wastes the memory.',
|
|
76
76
|
'',
|
|
77
|
-
'`search` covers *why*: past decisions, bugs, reasoning.
|
|
78
|
-
'
|
|
79
|
-
'
|
|
80
|
-
'
|
|
81
|
-
'
|
|
82
|
-
'
|
|
77
|
+
'`search` covers *why*: past decisions, bugs, reasoning. `find_usages` is',
|
|
78
|
+
'the default the moment a question is about a symbol or identifier — before',
|
|
79
|
+
'editing or removing a shared or exported name, or to look one up at all —',
|
|
80
|
+
'since it tags the likely definition and re-derives the answer from the',
|
|
81
|
+
'current source on every call, so it is never stale. grep still wins for',
|
|
82
|
+
'everything that is not a code identifier: plain text, log files, comments,',
|
|
83
|
+
'strings, and scoping with grep flags `find_usages` does not expose.',
|
|
83
84
|
'',
|
|
84
85
|
'When the user states a standing rule or preference, record it with',
|
|
85
86
|
'`remember` so it survives this session.',
|
package/dist/mcp/server.js
CHANGED
|
@@ -140,8 +140,10 @@ server.tool('find_usages', 'Find real usages of a symbol or component name via `
|
|
|
140
140
|
path: z
|
|
141
141
|
.string()
|
|
142
142
|
.optional()
|
|
143
|
-
.describe('
|
|
144
|
-
'
|
|
143
|
+
.describe('A file or directory to narrow the search to; omit to search the whole ' +
|
|
144
|
+
'repository (never narrows on its own — a blast-radius check that quietly ' +
|
|
145
|
+
'skipped part of the repo would be worse than no check). Must be inside a ' +
|
|
146
|
+
'git working tree. Different from the memory tools’ project param, which ' +
|
|
145
147
|
'can point at a folder pooling several repos rather than being one itself'),
|
|
146
148
|
regex: z
|
|
147
149
|
.boolean()
|
package/dist/usages/find.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { execFileSync } from 'node:child_process';
|
|
2
|
-
import {
|
|
2
|
+
import { realpathSync } from 'node:fs';
|
|
3
|
+
import { relative, resolve } from 'node:path';
|
|
3
4
|
// A hit here means the term is too generic to be a symbol lookup at all; the
|
|
4
5
|
// fix is a narrower query, not a bigger buffer.
|
|
5
6
|
const MAX_BUFFER = 16 * 1024 * 1024;
|
|
@@ -12,8 +13,24 @@ const MAX_BUFFER = 16 * 1024 * 1024;
|
|
|
12
13
|
* nothing to invalidate.
|
|
13
14
|
*/
|
|
14
15
|
export function findUsages(input) {
|
|
15
|
-
|
|
16
|
+
// realpath'd up front: git's own --show-toplevel always resolves symlinks
|
|
17
|
+
// (on macOS, tmpdir()'s /var/folders/... is itself a symlink to
|
|
18
|
+
// /private/var/folders/...), so comparing an un-resolved `start` against it
|
|
19
|
+
// below would produce a bogus, always-".."-prefixed relative path and
|
|
20
|
+
// silently disable scoping rather than apply it.
|
|
21
|
+
const start = realpathSync(resolve(input.path ?? process.cwd()));
|
|
22
|
+
const root = repoRootFor(start);
|
|
16
23
|
const args = buildArgs(input);
|
|
24
|
+
// An explicit path narrows the search to that subtree; omitting it searches
|
|
25
|
+
// the whole repository. Defaulting to cwd's subtree would silently hide a
|
|
26
|
+
// usage that lives elsewhere in the repo — exactly the case this tool
|
|
27
|
+
// exists to catch — so only a caller who deliberately asked to narrow gets
|
|
28
|
+
// narrowed. git accepts a file or a directory here equally.
|
|
29
|
+
if (input.path) {
|
|
30
|
+
const scope = relative(root, start);
|
|
31
|
+
if (scope && !scope.startsWith('..'))
|
|
32
|
+
args.push('--', scope);
|
|
33
|
+
}
|
|
17
34
|
let raw;
|
|
18
35
|
try {
|
|
19
36
|
raw = execFileSync('git', args, { cwd: root, encoding: 'utf8', maxBuffer: MAX_BUFFER });
|
|
@@ -48,8 +65,7 @@ export function findUsages(input) {
|
|
|
48
65
|
* this in sync with whatever repo git itself would act on (worktrees,
|
|
49
66
|
* submodules, symlinks included) without a second implementation of the walk.
|
|
50
67
|
*/
|
|
51
|
-
function repoRootFor(
|
|
52
|
-
const start = resolve(path ?? process.cwd());
|
|
68
|
+
function repoRootFor(start) {
|
|
53
69
|
try {
|
|
54
70
|
return execFileSync('git', ['-C', start, 'rev-parse', '--show-toplevel'], {
|
|
55
71
|
encoding: 'utf8',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-db",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
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",
|