claude-eidetic 0.1.4 → 2026.304.1730
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 +81 -24
- package/dist/build-info.d.ts +3 -0
- package/dist/build-info.js +4 -0
- package/dist/config.d.ts +15 -0
- package/dist/config.js +10 -4
- package/dist/core/global-concepts.d.ts +8 -0
- package/dist/core/global-concepts.js +38 -0
- package/dist/core/indexer.js +13 -1
- package/dist/core/raptor-cache.d.ts +6 -0
- package/dist/core/raptor-cache.js +45 -0
- package/dist/core/raptor.d.ts +31 -0
- package/dist/core/raptor.js +209 -0
- package/dist/core/snapshot-io.d.ts +4 -0
- package/dist/core/snapshot-io.js +81 -23
- package/dist/core/sync.js +3 -4
- package/dist/embedding/openai.js +7 -3
- package/dist/errors.d.ts +2 -0
- package/dist/errors.js +2 -0
- package/dist/format.js +18 -11
- package/dist/hooks/hook-output.d.ts +56 -0
- package/dist/hooks/hook-output.js +21 -0
- package/dist/hooks/post-tool-extract.d.ts +12 -0
- package/dist/hooks/post-tool-extract.js +218 -0
- package/dist/hooks/post-tool-use.js +8 -2
- package/dist/hooks/stop-hook.js +15 -2
- package/dist/hooks/targeted-runner.js +16 -1
- package/dist/hooks/user-prompt-inject.d.ts +9 -0
- package/dist/hooks/user-prompt-inject.js +121 -0
- package/dist/index.js +37 -7
- package/dist/infra/qdrant-bootstrap.d.ts +5 -1
- package/dist/infra/qdrant-bootstrap.js +4 -2
- package/dist/memory/buffer-consolidator.d.ts +7 -0
- package/dist/memory/buffer-consolidator.js +142 -0
- package/dist/memory/buffer-runner.d.ts +14 -0
- package/dist/memory/buffer-runner.js +90 -0
- package/dist/memory/buffer.d.ts +22 -0
- package/dist/memory/buffer.js +92 -0
- package/dist/memory/graph.d.ts +37 -0
- package/dist/memory/graph.js +270 -0
- package/dist/memory/migration.d.ts +10 -0
- package/dist/memory/migration.js +76 -0
- package/dist/memory/query-classifier.d.ts +8 -0
- package/dist/memory/query-classifier.js +52 -0
- package/dist/memory/reconciler.d.ts +2 -1
- package/dist/memory/reconciler.js +7 -2
- package/dist/memory/store.d.ts +17 -6
- package/dist/memory/store.js +323 -77
- package/dist/memory/types.d.ts +99 -4
- package/dist/paths.d.ts +5 -0
- package/dist/paths.js +15 -0
- package/dist/precompact/hook.js +84 -7
- package/dist/precompact/index-runner.js +1 -1
- package/dist/precompact/memory-extractor.d.ts +17 -0
- package/dist/precompact/memory-extractor.js +86 -0
- package/dist/precompact/memory-inject.js +8 -7
- package/dist/setup-message.d.ts +1 -0
- package/dist/setup-message.js +35 -5
- package/dist/state/registry.d.ts +1 -0
- package/dist/state/registry.js +13 -0
- package/dist/state/snapshot.d.ts +1 -0
- package/dist/state/snapshot.js +27 -12
- package/dist/tool-schemas.d.ts +50 -13
- package/dist/tool-schemas.js +52 -38
- package/dist/tools.d.ts +8 -0
- package/dist/tools.js +80 -7
- package/dist/vectordb/milvus.d.ts +6 -0
- package/dist/vectordb/milvus.js +38 -0
- package/dist/vectordb/qdrant.d.ts +6 -0
- package/dist/vectordb/qdrant.js +46 -0
- package/dist/vectordb/types.d.ts +6 -0
- package/messages.yaml +33 -13
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
```
|
|
2
|
+
┌─────────────────────────────────────────────┐
|
|
3
|
+
│ ╔═╗╦╔╦╗╔═╗╔╦╗╦╔═╗ │
|
|
4
|
+
│ ║╣ ║ ║║║╣ ║ ║║ semantic code search │
|
|
5
|
+
│ ╚═╝╩═╩╝╚═╝ ╩ ╩╚═╝ for Claude Code │
|
|
6
|
+
└─────────────────────────────────────────────┘
|
|
7
|
+
```
|
|
3
8
|
|
|
4
9
|
[](https://github.com/eidetics/claude-eidetic/actions/workflows/ci.yml)
|
|
5
10
|
[](https://www.npmjs.com/package/claude-eidetic)
|
|
@@ -9,7 +14,7 @@ Semantic code search, persistent memory, and session continuity for Claude Code.
|
|
|
9
14
|
|
|
10
15
|
---
|
|
11
16
|
|
|
12
|
-
##
|
|
17
|
+
## Quick Start
|
|
13
18
|
|
|
14
19
|
```bash
|
|
15
20
|
claude plugin install eidetics/claude-eidetic
|
|
@@ -28,9 +33,9 @@ search_code("how does authentication work")
|
|
|
28
33
|
|
|
29
34
|
---
|
|
30
35
|
|
|
31
|
-
##
|
|
36
|
+
## Features
|
|
32
37
|
|
|
33
|
-
###
|
|
38
|
+
### Semantic Code Search
|
|
34
39
|
|
|
35
40
|
**Find code by meaning, not keywords.** Search across your entire codebase with natural language, returning the most relevant functions and classes, not a list of files to read.
|
|
36
41
|
|
|
@@ -40,7 +45,7 @@ search_code("authentication middleware", extensionFilter=[".ts"])
|
|
|
40
45
|
search_code(project="backend", query="auth flow")
|
|
41
46
|
```
|
|
42
47
|
|
|
43
|
-
###
|
|
48
|
+
### Architecture at a Glance
|
|
44
49
|
|
|
45
50
|
**Get every class, function, and method in one call.** `browse_structure` returns a condensed map of your codebase with signatures, grouped by file, replacing a Glob + Read cascade with a single tool call.
|
|
46
51
|
|
|
@@ -49,7 +54,7 @@ browse_structure(path="/my/project", kind="class")
|
|
|
49
54
|
list_symbols(path="/my/project", nameFilter="handle")
|
|
50
55
|
```
|
|
51
56
|
|
|
52
|
-
###
|
|
57
|
+
### Documentation Cache
|
|
53
58
|
|
|
54
59
|
**Fetch docs once, search them forever.** Cache external documentation as searchable embeddings. Retrieve relevant passages instantly, far cheaper than re-fetching the same page each session.
|
|
55
60
|
|
|
@@ -58,7 +63,7 @@ index_document(content=..., library="react", topic="hooks", source="https://..."
|
|
|
58
63
|
search_documents("React useCallback dependencies", library="react")
|
|
59
64
|
```
|
|
60
65
|
|
|
61
|
-
###
|
|
66
|
+
### Persistent Memory
|
|
62
67
|
|
|
63
68
|
**Claude remembers your preferences between sessions.** `add_memory` uses an LLM to extract structured facts from conversation text (coding style, architecture decisions, debugging insights) and deduplicates them semantically. Not a static config file you forget to update.
|
|
64
69
|
|
|
@@ -67,11 +72,11 @@ add_memory("Always use absolute imports, never relative")
|
|
|
67
72
|
search_memory("how does this team handle errors")
|
|
68
73
|
```
|
|
69
74
|
|
|
70
|
-
###
|
|
75
|
+
### Session Continuity
|
|
71
76
|
|
|
72
77
|
**Every session picks up where the last one left off.** When a session ends (or context compacts mid-session), Eidetic automatically writes a structured note capturing files changed, tasks, commands, and decisions. `/catchup` at the start of a new session reconstructs exactly where you were. No user action required.
|
|
73
78
|
|
|
74
|
-
###
|
|
79
|
+
### Invisible Optimizations
|
|
75
80
|
|
|
76
81
|
Eight hook events fire automatically, nudging toward cheaper tools, redirecting file reads for 15-20% token savings, tracking changed files, and saving session state on exit.
|
|
77
82
|
|
|
@@ -93,7 +98,7 @@ Eight hook events fire automatically, nudging toward cheaper tools, redirecting
|
|
|
93
98
|
|
|
94
99
|
---
|
|
95
100
|
|
|
96
|
-
##
|
|
101
|
+
## When to Use What
|
|
97
102
|
|
|
98
103
|
| Need | Use | Notes |
|
|
99
104
|
|---|---|---|
|
|
@@ -107,7 +112,7 @@ Eight hook events fire automatically, nudging toward cheaper tools, redirecting
|
|
|
107
112
|
|
|
108
113
|
---
|
|
109
114
|
|
|
110
|
-
##
|
|
115
|
+
## Skills Reference
|
|
111
116
|
|
|
112
117
|
| Skill | What it does |
|
|
113
118
|
|---|---|
|
|
@@ -120,7 +125,7 @@ Eight hook events fire automatically, nudging toward cheaper tools, redirecting
|
|
|
120
125
|
---
|
|
121
126
|
|
|
122
127
|
<details>
|
|
123
|
-
<summary><strong
|
|
128
|
+
<summary><strong>Why does this exist? (The Problem)</strong></summary>
|
|
124
129
|
|
|
125
130
|
Every new Claude Code session starts cold. You re-explain the architecture. You re-fetch the same docs. Claude reads the same files repeatedly, burning tokens just to get back to where you were.
|
|
126
131
|
|
|
@@ -135,7 +140,7 @@ Every new Claude Code session starts cold. You re-explain the architecture. You
|
|
|
135
140
|
|
|
136
141
|
---
|
|
137
142
|
|
|
138
|
-
##
|
|
143
|
+
## Installation
|
|
139
144
|
|
|
140
145
|
### Plugin (recommended)
|
|
141
146
|
|
|
@@ -145,6 +150,9 @@ claude plugin install eidetics/claude-eidetic
|
|
|
145
150
|
|
|
146
151
|
The plugin auto-starts the MCP server, installs skills, and configures hooks.
|
|
147
152
|
|
|
153
|
+
<details>
|
|
154
|
+
<summary><strong>Alternative installation methods</strong></summary>
|
|
155
|
+
|
|
148
156
|
### npx (manual MCP config)
|
|
149
157
|
|
|
150
158
|
Add to your `.mcp.json`:
|
|
@@ -177,6 +185,8 @@ cd claude-eidetic
|
|
|
177
185
|
npm install && npx tsc && npm start
|
|
178
186
|
```
|
|
179
187
|
|
|
188
|
+
</details>
|
|
189
|
+
|
|
180
190
|
### Requirements
|
|
181
191
|
|
|
182
192
|
- Node.js >= 20.0.0
|
|
@@ -186,7 +196,7 @@ npm install && npx tsc && npm start
|
|
|
186
196
|
|
|
187
197
|
---
|
|
188
198
|
|
|
189
|
-
##
|
|
199
|
+
## Configuration
|
|
190
200
|
|
|
191
201
|
All configuration is via environment variables. No config files.
|
|
192
202
|
|
|
@@ -223,10 +233,57 @@ export MEMORY_LLM_PROVIDER=ollama
|
|
|
223
233
|
|
|
224
234
|
---
|
|
225
235
|
|
|
236
|
+
## Troubleshooting
|
|
237
|
+
|
|
238
|
+
### `OPENAI_API_KEY` not set
|
|
239
|
+
|
|
240
|
+
Eidetic needs an embedding API key. Set it in your shell profile:
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
export OPENAI_API_KEY=sk-... # macOS/Linux
|
|
244
|
+
setx OPENAI_API_KEY sk-... # Windows
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Or use Ollama for free local embeddings: `export EMBEDDING_PROVIDER=ollama`
|
|
248
|
+
|
|
249
|
+
### Docker not installed (Qdrant can't auto-provision)
|
|
250
|
+
|
|
251
|
+
Eidetic auto-provisions Qdrant via Docker. If Docker isn't installed:
|
|
252
|
+
- **Option A:** Install [Docker Desktop](https://www.docker.com/products/docker-desktop/) and retry
|
|
253
|
+
- **Option B:** Run Qdrant manually and set `QDRANT_URL` to point to it
|
|
254
|
+
|
|
255
|
+
### Qdrant unreachable at custom URL
|
|
256
|
+
|
|
257
|
+
If you set `QDRANT_URL` to a remote instance, verify it's reachable:
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
curl http://your-qdrant-host:6333/healthz
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### Tree-sitter native build fails on Windows
|
|
264
|
+
|
|
265
|
+
Tree-sitter requires C/C++ build tools. Install them:
|
|
266
|
+
|
|
267
|
+
```bash
|
|
268
|
+
npm install -g windows-build-tools # or install Visual Studio Build Tools
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
If the build still fails, Eidetic falls back to line-based chunking (works, but less precise).
|
|
272
|
+
|
|
273
|
+
### Ollama model not pulled
|
|
274
|
+
|
|
275
|
+
If using `EMBEDDING_PROVIDER=ollama`, ensure the model is available:
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
ollama pull nomic-embed-text
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
226
283
|
<details>
|
|
227
|
-
<summary><strong
|
|
284
|
+
<summary><strong>Tool Reference</strong></summary>
|
|
228
285
|
|
|
229
|
-
###
|
|
286
|
+
### Code Search
|
|
230
287
|
|
|
231
288
|
| Tool | Description |
|
|
232
289
|
|---|---|
|
|
@@ -239,20 +296,20 @@ export MEMORY_LLM_PROVIDER=ollama
|
|
|
239
296
|
| `browse_structure` | Condensed structural map: classes, functions, methods with signatures, grouped by file. |
|
|
240
297
|
| `list_symbols` | Compact symbol table with name/kind/file/line. Supports name, kind, and path filters. |
|
|
241
298
|
|
|
242
|
-
###
|
|
299
|
+
### File Reading
|
|
243
300
|
|
|
244
301
|
| Tool | Description |
|
|
245
302
|
|---|---|
|
|
246
303
|
| `read_file` | Read file without line-number overhead. Cheaper than built-in Read for code files. |
|
|
247
304
|
|
|
248
|
-
###
|
|
305
|
+
### Documentation Cache
|
|
249
306
|
|
|
250
307
|
| Tool | Description |
|
|
251
308
|
|---|---|
|
|
252
309
|
| `index_document` | Cache external documentation for semantic search. Supports TTL for staleness tracking. |
|
|
253
310
|
| `search_documents` | Search cached docs. Far cheaper than re-fetching the same page. |
|
|
254
311
|
|
|
255
|
-
###
|
|
312
|
+
### Memory
|
|
256
313
|
|
|
257
314
|
| Tool | Description |
|
|
258
315
|
|---|---|
|
|
@@ -266,7 +323,7 @@ export MEMORY_LLM_PROVIDER=ollama
|
|
|
266
323
|
|
|
267
324
|
---
|
|
268
325
|
|
|
269
|
-
##
|
|
326
|
+
## Supported Languages
|
|
270
327
|
|
|
271
328
|
**AST-aware** (functions and classes chunked intact):
|
|
272
329
|
|
|
@@ -298,7 +355,7 @@ export MEMORY_LLM_PROVIDER=ollama
|
|
|
298
355
|
|
|
299
356
|
---
|
|
300
357
|
|
|
301
|
-
##
|
|
358
|
+
## Development
|
|
302
359
|
|
|
303
360
|
```bash
|
|
304
361
|
npm install && npx tsc # install and build
|
|
@@ -313,12 +370,12 @@ Scopes: `embedding`, `vectordb`, `splitter`, `indexer`, `mcp`, `infra`, `config`
|
|
|
313
370
|
|
|
314
371
|
---
|
|
315
372
|
|
|
316
|
-
##
|
|
373
|
+
## Acknowledgements
|
|
317
374
|
|
|
318
375
|
Heavily inspired by [mem0](https://github.com/mem0ai/mem0), [claude-mem](https://github.com/thedotmack/claude-mem), and [claude-context](https://github.com/zilliztech/claude-context). Documentation retrieval powered by [context7](https://github.com/upstash/context7).
|
|
319
376
|
|
|
320
377
|
---
|
|
321
378
|
|
|
322
|
-
##
|
|
379
|
+
## License
|
|
323
380
|
|
|
324
381
|
MIT
|
package/dist/config.d.ts
CHANGED
|
@@ -15,6 +15,9 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
15
15
|
eideticDataDir: z.ZodDefault<z.ZodString>;
|
|
16
16
|
customExtensions: z.ZodEffects<z.ZodDefault<z.ZodArray<z.ZodString, "many">>, string[], unknown>;
|
|
17
17
|
customIgnorePatterns: z.ZodEffects<z.ZodDefault<z.ZodArray<z.ZodString, "many">>, string[], unknown>;
|
|
18
|
+
raptorEnabled: z.ZodEffects<z.ZodDefault<z.ZodBoolean>, boolean, unknown>;
|
|
19
|
+
raptorTimeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
20
|
+
raptorLlmModel: z.ZodDefault<z.ZodString>;
|
|
18
21
|
}, "strip", z.ZodTypeAny, {
|
|
19
22
|
embeddingProvider: "openai" | "ollama" | "local";
|
|
20
23
|
openaiApiKey: string;
|
|
@@ -27,6 +30,9 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
27
30
|
eideticDataDir: string;
|
|
28
31
|
customExtensions: string[];
|
|
29
32
|
customIgnorePatterns: string[];
|
|
33
|
+
raptorEnabled: boolean;
|
|
34
|
+
raptorTimeoutMs: number;
|
|
35
|
+
raptorLlmModel: string;
|
|
30
36
|
openaiBaseUrl?: string | undefined;
|
|
31
37
|
embeddingModel?: string | undefined;
|
|
32
38
|
qdrantApiKey?: string | undefined;
|
|
@@ -47,6 +53,9 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
47
53
|
eideticDataDir?: string | undefined;
|
|
48
54
|
customExtensions?: unknown;
|
|
49
55
|
customIgnorePatterns?: unknown;
|
|
56
|
+
raptorEnabled?: unknown;
|
|
57
|
+
raptorTimeoutMs?: number | undefined;
|
|
58
|
+
raptorLlmModel?: string | undefined;
|
|
50
59
|
}>, {
|
|
51
60
|
embeddingModel: string;
|
|
52
61
|
embeddingProvider: "openai" | "ollama" | "local";
|
|
@@ -60,6 +69,9 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
60
69
|
eideticDataDir: string;
|
|
61
70
|
customExtensions: string[];
|
|
62
71
|
customIgnorePatterns: string[];
|
|
72
|
+
raptorEnabled: boolean;
|
|
73
|
+
raptorTimeoutMs: number;
|
|
74
|
+
raptorLlmModel: string;
|
|
63
75
|
openaiBaseUrl?: string | undefined;
|
|
64
76
|
qdrantApiKey?: string | undefined;
|
|
65
77
|
milvusToken?: string | undefined;
|
|
@@ -79,6 +91,9 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
79
91
|
eideticDataDir?: string | undefined;
|
|
80
92
|
customExtensions?: unknown;
|
|
81
93
|
customIgnorePatterns?: unknown;
|
|
94
|
+
raptorEnabled?: unknown;
|
|
95
|
+
raptorTimeoutMs?: number | undefined;
|
|
96
|
+
raptorLlmModel?: string | undefined;
|
|
82
97
|
}>;
|
|
83
98
|
export type Config = z.infer<typeof configSchema>;
|
|
84
99
|
export declare function loadConfig(): Config;
|
package/dist/config.js
CHANGED
|
@@ -19,6 +19,9 @@ const configSchema = z
|
|
|
19
19
|
eideticDataDir: z.string().default(path.join(os.homedir(), '.eidetic')),
|
|
20
20
|
customExtensions: z.preprocess((val) => (typeof val === 'string' ? JSON.parse(val) : val), z.array(z.string()).default([])),
|
|
21
21
|
customIgnorePatterns: z.preprocess((val) => (typeof val === 'string' ? JSON.parse(val) : val), z.array(z.string()).default([])),
|
|
22
|
+
raptorEnabled: z.preprocess((val) => (val === 'false' ? false : val === 'true' ? true : val), z.boolean().default(true)),
|
|
23
|
+
raptorTimeoutMs: z.coerce.number().int().min(1000).default(60000),
|
|
24
|
+
raptorLlmModel: z.string().default('gpt-4o-mini'),
|
|
22
25
|
})
|
|
23
26
|
.transform((cfg) => ({
|
|
24
27
|
...cfg,
|
|
@@ -31,19 +34,22 @@ export function loadConfig() {
|
|
|
31
34
|
const raw = {
|
|
32
35
|
embeddingProvider: process.env.EMBEDDING_PROVIDER,
|
|
33
36
|
openaiApiKey: (process.env.OPENAI_API_KEY ?? '').trim().replace(/^["']|["']$/g, ''),
|
|
34
|
-
openaiBaseUrl: process.env.OPENAI_BASE_URL
|
|
37
|
+
openaiBaseUrl: process.env.OPENAI_BASE_URL?.trim() ?? undefined,
|
|
35
38
|
ollamaBaseUrl: process.env.OLLAMA_BASE_URL,
|
|
36
|
-
embeddingModel: process.env.EMBEDDING_MODEL
|
|
39
|
+
embeddingModel: process.env.EMBEDDING_MODEL?.trim() ?? undefined,
|
|
37
40
|
embeddingBatchSize: process.env.EMBEDDING_BATCH_SIZE,
|
|
38
41
|
indexingConcurrency: process.env.INDEXING_CONCURRENCY,
|
|
39
42
|
qdrantUrl: process.env.QDRANT_URL,
|
|
40
|
-
qdrantApiKey: process.env.QDRANT_API_KEY?.trim().replace(/^["']|["']$/g, '')
|
|
43
|
+
qdrantApiKey: process.env.QDRANT_API_KEY?.trim().replace(/^["']|["']$/g, '') ?? undefined,
|
|
41
44
|
vectordbProvider: process.env.VECTORDB_PROVIDER,
|
|
42
45
|
milvusAddress: process.env.MILVUS_ADDRESS,
|
|
43
|
-
milvusToken: process.env.MILVUS_TOKEN?.trim().replace(/^["']|["']$/g, '')
|
|
46
|
+
milvusToken: process.env.MILVUS_TOKEN?.trim().replace(/^["']|["']$/g, '') ?? undefined,
|
|
44
47
|
eideticDataDir: process.env.EIDETIC_DATA_DIR,
|
|
45
48
|
customExtensions: process.env.CUSTOM_EXTENSIONS,
|
|
46
49
|
customIgnorePatterns: process.env.CUSTOM_IGNORE_PATTERNS,
|
|
50
|
+
raptorEnabled: process.env.RAPTOR_ENABLED,
|
|
51
|
+
raptorTimeoutMs: process.env.RAPTOR_TIMEOUT_MS,
|
|
52
|
+
raptorLlmModel: process.env.RAPTOR_LLM_MODEL,
|
|
47
53
|
};
|
|
48
54
|
const result = configSchema.safeParse(raw);
|
|
49
55
|
if (!result.success) {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Embedding } from '../embedding/types.js';
|
|
2
|
+
import type { VectorDB } from '../vectordb/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Replicate knowledge summaries from a project's knowledge collection
|
|
5
|
+
* to the global concepts collection, tagged with the project name.
|
|
6
|
+
*/
|
|
7
|
+
export declare function replicateToGlobalConcepts(project: string, knowledgeCollectionName: string, embedding: Embedding, vectordb: VectorDB): Promise<number>;
|
|
8
|
+
//# sourceMappingURL=global-concepts.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { globalConceptsCollectionName } from '../paths.js';
|
|
3
|
+
/**
|
|
4
|
+
* Replicate knowledge summaries from a project's knowledge collection
|
|
5
|
+
* to the global concepts collection, tagged with the project name.
|
|
6
|
+
*/
|
|
7
|
+
export async function replicateToGlobalConcepts(project, knowledgeCollectionName, embedding, vectordb) {
|
|
8
|
+
const globalCol = globalConceptsCollectionName();
|
|
9
|
+
// Ensure global collection exists
|
|
10
|
+
if (!(await vectordb.hasCollection(globalCol))) {
|
|
11
|
+
await vectordb.createCollection(globalCol, embedding.dimension);
|
|
12
|
+
}
|
|
13
|
+
// Scroll all knowledge points
|
|
14
|
+
const points = await vectordb.scrollAll(knowledgeCollectionName);
|
|
15
|
+
if (points.length === 0)
|
|
16
|
+
return 0;
|
|
17
|
+
// Clean up stale entries for this project
|
|
18
|
+
await vectordb.deleteByFilter(globalCol, { project });
|
|
19
|
+
// Upsert knowledge points into global collection
|
|
20
|
+
let replicated = 0;
|
|
21
|
+
for (const point of points) {
|
|
22
|
+
const id = randomUUID();
|
|
23
|
+
await vectordb.updatePoint(globalCol, id, point.vector, {
|
|
24
|
+
...point.payload,
|
|
25
|
+
content: typeof point.payload.content === 'string' ? point.payload.content : '',
|
|
26
|
+
relativePath: id,
|
|
27
|
+
startLine: 0,
|
|
28
|
+
endLine: 0,
|
|
29
|
+
fileExtension: 'knowledge',
|
|
30
|
+
language: 'summary',
|
|
31
|
+
project,
|
|
32
|
+
source: 'raptor',
|
|
33
|
+
});
|
|
34
|
+
replicated++;
|
|
35
|
+
}
|
|
36
|
+
return replicated;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=global-concepts.js.map
|
package/dist/core/indexer.js
CHANGED
|
@@ -158,8 +158,20 @@ export async function indexCodebase(rootPath, embedding, vectordb, force = false
|
|
|
158
158
|
await vectordb.insert(collectionName, documents);
|
|
159
159
|
processedChunks += batch.length;
|
|
160
160
|
}
|
|
161
|
-
onProgress?.(
|
|
161
|
+
onProgress?.(95, 'Saving snapshot...');
|
|
162
162
|
saveSnapshot(normalizedPath, currentSnapshot);
|
|
163
|
+
// Run RAPTOR knowledge generation (non-fatal)
|
|
164
|
+
if (config.raptorEnabled) {
|
|
165
|
+
try {
|
|
166
|
+
onProgress?.(97, 'Generating knowledge summaries...');
|
|
167
|
+
const projectName = path.basename(normalizedPath);
|
|
168
|
+
const { runRaptor } = await import('./raptor.js');
|
|
169
|
+
await runRaptor(projectName, collectionName, embedding, vectordb);
|
|
170
|
+
}
|
|
171
|
+
catch (err) {
|
|
172
|
+
console.warn(`RAPTOR knowledge generation failed (non-fatal): ${String(err)}`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
163
175
|
onProgress?.(100, 'Done');
|
|
164
176
|
return {
|
|
165
177
|
totalFiles: filePaths.length,
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function getCachedSummary(clusterHash: string): string | null;
|
|
2
|
+
export declare function setCachedSummary(clusterHash: string, summary: string, project: string, level?: number): void;
|
|
3
|
+
export declare function clearProjectCache(project: string): void;
|
|
4
|
+
/** Reset the module-level DB connection (for testing). */
|
|
5
|
+
export declare function _resetDb(): void;
|
|
6
|
+
//# sourceMappingURL=raptor-cache.d.ts.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import Database from 'better-sqlite3';
|
|
2
|
+
import { mkdirSync } from 'node:fs';
|
|
3
|
+
import { dirname } from 'node:path';
|
|
4
|
+
import { getRaptorDbPath } from '../paths.js';
|
|
5
|
+
let db = null;
|
|
6
|
+
function getDb() {
|
|
7
|
+
if (db)
|
|
8
|
+
return db;
|
|
9
|
+
const dbPath = getRaptorDbPath();
|
|
10
|
+
mkdirSync(dirname(dbPath), { recursive: true });
|
|
11
|
+
db = new Database(dbPath);
|
|
12
|
+
db.pragma('journal_mode = WAL');
|
|
13
|
+
db.exec(`
|
|
14
|
+
CREATE TABLE IF NOT EXISTS raptor_clusters (
|
|
15
|
+
cluster_hash TEXT PRIMARY KEY,
|
|
16
|
+
summary TEXT NOT NULL,
|
|
17
|
+
project TEXT NOT NULL,
|
|
18
|
+
level INTEGER NOT NULL DEFAULT 0,
|
|
19
|
+
updated_at TEXT NOT NULL
|
|
20
|
+
)
|
|
21
|
+
`);
|
|
22
|
+
return db;
|
|
23
|
+
}
|
|
24
|
+
export function getCachedSummary(clusterHash) {
|
|
25
|
+
const row = getDb()
|
|
26
|
+
.prepare('SELECT summary FROM raptor_clusters WHERE cluster_hash = ?')
|
|
27
|
+
.get(clusterHash);
|
|
28
|
+
return row?.summary ?? null;
|
|
29
|
+
}
|
|
30
|
+
export function setCachedSummary(clusterHash, summary, project, level = 0) {
|
|
31
|
+
getDb()
|
|
32
|
+
.prepare('INSERT OR REPLACE INTO raptor_clusters (cluster_hash, summary, project, level, updated_at) VALUES (?, ?, ?, ?, ?)')
|
|
33
|
+
.run(clusterHash, summary, project, level, new Date().toISOString());
|
|
34
|
+
}
|
|
35
|
+
export function clearProjectCache(project) {
|
|
36
|
+
getDb().prepare('DELETE FROM raptor_clusters WHERE project = ?').run(project);
|
|
37
|
+
}
|
|
38
|
+
/** Reset the module-level DB connection (for testing). */
|
|
39
|
+
export function _resetDb() {
|
|
40
|
+
if (db) {
|
|
41
|
+
db.close();
|
|
42
|
+
db = null;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=raptor-cache.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Embedding } from '../embedding/types.js';
|
|
2
|
+
import type { VectorDB } from '../vectordb/types.js';
|
|
3
|
+
export interface RaptorResult {
|
|
4
|
+
clustersProcessed: number;
|
|
5
|
+
summariesGenerated: number;
|
|
6
|
+
cached: number;
|
|
7
|
+
timedOut: boolean;
|
|
8
|
+
}
|
|
9
|
+
interface Point {
|
|
10
|
+
id: string | number;
|
|
11
|
+
vector: number[];
|
|
12
|
+
content: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Run RAPTOR knowledge generation: cluster code chunks, summarize each cluster,
|
|
16
|
+
* store summaries in the knowledge collection.
|
|
17
|
+
*/
|
|
18
|
+
export declare function runRaptor(project: string, codeCollectionName: string, embedding: Embedding, vectordb: VectorDB, options?: {
|
|
19
|
+
timeoutMs?: number;
|
|
20
|
+
llmModel?: string;
|
|
21
|
+
summarize?: LlmSummarizer;
|
|
22
|
+
}): Promise<RaptorResult>;
|
|
23
|
+
export type LlmSummarizer = (content: string, model: string, apiKey: string) => Promise<string>;
|
|
24
|
+
/**
|
|
25
|
+
* K-means clustering (Lloyd's algorithm).
|
|
26
|
+
* Returns an array of clusters, each containing the points assigned to it.
|
|
27
|
+
*/
|
|
28
|
+
export declare function kMeans(points: Point[], k: number, maxIter?: number): Point[][];
|
|
29
|
+
export declare function clusterHash(memberIds: string[]): string;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=raptor.d.ts.map
|