claude-db 0.5.4 → 0.7.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.
Files changed (45) hide show
  1. package/CHANGELOG.md +145 -0
  2. package/dist/capture/turn-extractor.js +9 -3
  3. package/dist/cli/commands/adoption.d.ts +1 -0
  4. package/dist/cli/commands/adoption.js +88 -0
  5. package/dist/cli/commands/graph.js +14 -2
  6. package/dist/cli/index.js +4 -0
  7. package/dist/cli/install.js +15 -10
  8. package/dist/cli/instructions.js +5 -4
  9. package/dist/cli/usage.js +1 -0
  10. package/dist/graph/index.d.ts +2 -2
  11. package/dist/graph/index.js +2 -2
  12. package/dist/graph/query/format.js +7 -3
  13. package/dist/graph/query/index.d.ts +1 -0
  14. package/dist/graph/query/index.js +1 -0
  15. package/dist/graph/query/lookup.d.ts +1 -0
  16. package/dist/graph/query/lookup.js +6 -0
  17. package/dist/graph/query/suggest.d.ts +5 -0
  18. package/dist/graph/query/suggest.js +65 -0
  19. package/dist/graph/scan/files.d.ts +1 -0
  20. package/dist/graph/scan/files.js +8 -2
  21. package/dist/graph/scan/index.d.ts +1 -1
  22. package/dist/graph/scan/index.js +1 -1
  23. package/dist/hooks/grep-symbols.d.ts +5 -0
  24. package/dist/hooks/grep-symbols.js +31 -0
  25. package/dist/hooks/prefer-usages.d.ts +2 -0
  26. package/dist/hooks/prefer-usages.js +78 -0
  27. package/dist/hooks/session-start.js +19 -0
  28. package/dist/mcp/server.js +6 -170
  29. package/dist/mcp/tools/kinds.d.ts +1 -0
  30. package/dist/mcp/tools/kinds.js +1 -0
  31. package/dist/mcp/tools/memory.d.ts +3 -0
  32. package/dist/mcp/tools/memory.js +46 -0
  33. package/dist/mcp/tools/observations.d.ts +3 -0
  34. package/dist/mcp/tools/observations.js +57 -0
  35. package/dist/mcp/tools/search.d.ts +3 -0
  36. package/dist/mcp/tools/search.js +55 -0
  37. package/dist/mcp/tools/usages.d.ts +3 -0
  38. package/dist/mcp/tools/usages.js +80 -0
  39. package/dist/search/service.js +3 -0
  40. package/dist/search/stopwords.d.ts +2 -0
  41. package/dist/search/stopwords.js +137 -0
  42. package/dist/store/sqlite/filters.js +3 -5
  43. package/dist/usages/find.d.ts +1 -1
  44. package/dist/usages/find.js +5 -3
  45. package/package.json +1 -1
@@ -0,0 +1,137 @@
1
+ const STOPWORDS = new Set([
2
+ 'a',
3
+ 'about',
4
+ 'after',
5
+ 'all',
6
+ 'also',
7
+ 'am',
8
+ 'an',
9
+ 'and',
10
+ 'any',
11
+ 'are',
12
+ 'as',
13
+ 'at',
14
+ 'be',
15
+ 'because',
16
+ 'been',
17
+ 'before',
18
+ 'being',
19
+ 'between',
20
+ 'both',
21
+ 'but',
22
+ 'by',
23
+ 'can',
24
+ 'could',
25
+ 'did',
26
+ 'do',
27
+ 'does',
28
+ 'doing',
29
+ 'done',
30
+ 'down',
31
+ 'during',
32
+ 'each',
33
+ 'even',
34
+ 'for',
35
+ 'from',
36
+ 'further',
37
+ 'get',
38
+ 'got',
39
+ 'had',
40
+ 'has',
41
+ 'have',
42
+ 'having',
43
+ 'he',
44
+ 'her',
45
+ 'here',
46
+ 'hers',
47
+ 'him',
48
+ 'his',
49
+ 'how',
50
+ 'however',
51
+ 'i',
52
+ 'if',
53
+ 'in',
54
+ 'into',
55
+ 'is',
56
+ 'it',
57
+ 'its',
58
+ 'itself',
59
+ 'just',
60
+ 'may',
61
+ 'me',
62
+ 'might',
63
+ 'more',
64
+ 'most',
65
+ 'much',
66
+ 'must',
67
+ 'my',
68
+ 'no',
69
+ 'nor',
70
+ 'not',
71
+ 'now',
72
+ 'of',
73
+ 'off',
74
+ 'on',
75
+ 'once',
76
+ 'only',
77
+ 'or',
78
+ 'other',
79
+ 'our',
80
+ 'out',
81
+ 'over',
82
+ 'own',
83
+ 'said',
84
+ 'same',
85
+ 'she',
86
+ 'should',
87
+ 'so',
88
+ 'some',
89
+ 'such',
90
+ 'than',
91
+ 'that',
92
+ 'the',
93
+ 'their',
94
+ 'them',
95
+ 'then',
96
+ 'there',
97
+ 'these',
98
+ 'they',
99
+ 'this',
100
+ 'those',
101
+ 'through',
102
+ 'to',
103
+ 'too',
104
+ 'under',
105
+ 'until',
106
+ 'up',
107
+ 'use',
108
+ 'used',
109
+ 'using',
110
+ 'very',
111
+ 'was',
112
+ 'we',
113
+ 'were',
114
+ 'what',
115
+ 'when',
116
+ 'where',
117
+ 'which',
118
+ 'while',
119
+ 'who',
120
+ 'whom',
121
+ 'why',
122
+ 'will',
123
+ 'with',
124
+ 'would',
125
+ 'you',
126
+ 'your',
127
+ 'yours',
128
+ ]);
129
+ export function isStopword(token) {
130
+ return STOPWORDS.has(token);
131
+ }
132
+ export function meaningfulTokens(text) {
133
+ return text
134
+ .toLowerCase()
135
+ .split(/[^\p{L}\p{N}_]+/u)
136
+ .filter((token) => token.length > 1 && !isStopword(token));
137
+ }
@@ -1,6 +1,7 @@
1
1
  import { partitionIds } from '../../util/shortid.js';
2
2
  import { resolve } from 'node:path';
3
3
  import { scopeToken } from '../../util/scope.js';
4
+ import { meaningfulTokens } from '../../search/stopwords.js';
4
5
  export function removeWhere(filter) {
5
6
  const conditions = [];
6
7
  const params = [];
@@ -58,13 +59,10 @@ export function appendScope(query, conditions, params, prefix) {
58
59
  }
59
60
  }
60
61
  export function toMatchExpression(text, project) {
61
- const tokens = text
62
- .toLowerCase()
63
- .split(/[^\p{L}\p{N}_]+/u)
64
- .filter((token) => token.length > 1);
62
+ const tokens = meaningfulTokens(text);
65
63
  const scope = project ? `scope:${scopeToken(project)}` : null;
66
64
  if (tokens.length === 0)
67
- return scope;
65
+ return null;
68
66
  const terms = tokens.map((token) => `"${token}"`).join(' OR ');
69
67
  return scope ? `${scope} AND (${terms})` : terms;
70
68
  }
@@ -20,4 +20,4 @@ export interface FindUsagesInput {
20
20
  }
21
21
  export declare function findUsages(input: FindUsagesInput): UsagesResult;
22
22
  export declare function repoRootFor(start: string): string;
23
- export declare function formatUsages(result: UsagesResult): string;
23
+ export declare function formatUsages(result: UsagesResult, suggestions?: string[]): string;
@@ -116,9 +116,11 @@ function isDefinitionLike(symbol, text) {
116
116
  `|(?:export\\s+)?(?:const|let|var)\\s+${s}\\s*[:=]` +
117
117
  `|export\\s*\\{[^}]*\\b${s}\\b)`).test(text);
118
118
  }
119
- export function formatUsages(result) {
120
- if (result.matches.length === 0)
121
- return `No usages of that symbol found under ${result.root}.`;
119
+ export function formatUsages(result, suggestions = []) {
120
+ if (result.matches.length === 0) {
121
+ return (`No usages of that symbol found under ${result.root}.` +
122
+ (suggestions.length > 0 ? `\nDid you mean: ${suggestions.join(', ')}` : ''));
123
+ }
122
124
  const rows = result.matches.map((m) => `${m.file}${m.isMatch ? ':' : '-'}${m.line}${m.isDefinition ? ' [definition?]' : ''} ${m.text.trim()}`);
123
125
  const shown = result.matches.filter((m) => m.isMatch).length;
124
126
  const header = result.truncated
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-db",
3
- "version": "0.5.4",
3
+ "version": "0.7.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",