@matperez/coderag 0.1.24
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 +154 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/ast-chunking.d.ts +40 -0
- package/dist/ast-chunking.d.ts.map +1 -0
- package/dist/ast-chunking.js +88 -0
- package/dist/ast-chunking.js.map +1 -0
- package/dist/ast-chunking.test.d.ts +5 -0
- package/dist/ast-chunking.test.d.ts.map +1 -0
- package/dist/ast-chunking.test.js +173 -0
- package/dist/ast-chunking.test.js.map +1 -0
- package/dist/code-tokenizer.d.ts +62 -0
- package/dist/code-tokenizer.d.ts.map +1 -0
- package/dist/code-tokenizer.js +129 -0
- package/dist/code-tokenizer.js.map +1 -0
- package/dist/code-tokenizer.test.d.ts +5 -0
- package/dist/code-tokenizer.test.d.ts.map +1 -0
- package/dist/code-tokenizer.test.js +96 -0
- package/dist/code-tokenizer.test.js.map +1 -0
- package/dist/db/client-pg.d.ts +16 -0
- package/dist/db/client-pg.d.ts.map +1 -0
- package/dist/db/client-pg.js +38 -0
- package/dist/db/client-pg.js.map +1 -0
- package/dist/db/client.d.ts +36 -0
- package/dist/db/client.d.ts.map +1 -0
- package/dist/db/client.js +81 -0
- package/dist/db/client.js.map +1 -0
- package/dist/db/migrations-pg.d.ts +6 -0
- package/dist/db/migrations-pg.d.ts.map +1 -0
- package/dist/db/migrations-pg.js +88 -0
- package/dist/db/migrations-pg.js.map +1 -0
- package/dist/db/migrations.d.ts +9 -0
- package/dist/db/migrations.d.ts.map +1 -0
- package/dist/db/migrations.js +164 -0
- package/dist/db/migrations.js.map +1 -0
- package/dist/db/schema-pg.d.ts +611 -0
- package/dist/db/schema-pg.d.ts.map +1 -0
- package/dist/db/schema-pg.js +66 -0
- package/dist/db/schema-pg.js.map +1 -0
- package/dist/db/schema.d.ts +630 -0
- package/dist/db/schema.d.ts.map +1 -0
- package/dist/db/schema.js +85 -0
- package/dist/db/schema.js.map +1 -0
- package/dist/embeddings.d.ts +92 -0
- package/dist/embeddings.d.ts.map +1 -0
- package/dist/embeddings.js +275 -0
- package/dist/embeddings.js.map +1 -0
- package/dist/embeddings.test.d.ts +5 -0
- package/dist/embeddings.test.d.ts.map +1 -0
- package/dist/embeddings.test.js +255 -0
- package/dist/embeddings.test.js.map +1 -0
- package/dist/hybrid-search.d.ts +47 -0
- package/dist/hybrid-search.d.ts.map +1 -0
- package/dist/hybrid-search.js +215 -0
- package/dist/hybrid-search.js.map +1 -0
- package/dist/hybrid-search.test.d.ts +5 -0
- package/dist/hybrid-search.test.d.ts.map +1 -0
- package/dist/hybrid-search.test.js +252 -0
- package/dist/hybrid-search.test.js.map +1 -0
- package/dist/incremental-tfidf.d.ts +77 -0
- package/dist/incremental-tfidf.d.ts.map +1 -0
- package/dist/incremental-tfidf.js +248 -0
- package/dist/incremental-tfidf.js.map +1 -0
- package/dist/incremental-tfidf.test.d.ts +5 -0
- package/dist/incremental-tfidf.test.d.ts.map +1 -0
- package/dist/incremental-tfidf.test.js +276 -0
- package/dist/incremental-tfidf.test.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/indexer.d.ts +205 -0
- package/dist/indexer.d.ts.map +1 -0
- package/dist/indexer.js +1331 -0
- package/dist/indexer.js.map +1 -0
- package/dist/indexer.test.d.ts +12 -0
- package/dist/indexer.test.d.ts.map +1 -0
- package/dist/indexer.test.js +471 -0
- package/dist/indexer.test.js.map +1 -0
- package/dist/language-config.d.ts +54 -0
- package/dist/language-config.d.ts.map +1 -0
- package/dist/language-config.js +75 -0
- package/dist/language-config.js.map +1 -0
- package/dist/search-cache.d.ts +63 -0
- package/dist/search-cache.d.ts.map +1 -0
- package/dist/search-cache.js +118 -0
- package/dist/search-cache.js.map +1 -0
- package/dist/search-cache.test.d.ts +5 -0
- package/dist/search-cache.test.d.ts.map +1 -0
- package/dist/search-cache.test.js +194 -0
- package/dist/search-cache.test.js.map +1 -0
- package/dist/storage-factory.d.ts +11 -0
- package/dist/storage-factory.d.ts.map +1 -0
- package/dist/storage-factory.js +17 -0
- package/dist/storage-factory.js.map +1 -0
- package/dist/storage-persistent-pg.d.ts +75 -0
- package/dist/storage-persistent-pg.d.ts.map +1 -0
- package/dist/storage-persistent-pg.js +579 -0
- package/dist/storage-persistent-pg.js.map +1 -0
- package/dist/storage-persistent-pg.test.d.ts +7 -0
- package/dist/storage-persistent-pg.test.d.ts.map +1 -0
- package/dist/storage-persistent-pg.test.js +90 -0
- package/dist/storage-persistent-pg.test.js.map +1 -0
- package/dist/storage-persistent-types.d.ts +110 -0
- package/dist/storage-persistent-types.d.ts.map +1 -0
- package/dist/storage-persistent-types.js +5 -0
- package/dist/storage-persistent-types.js.map +1 -0
- package/dist/storage-persistent.d.ts +231 -0
- package/dist/storage-persistent.d.ts.map +1 -0
- package/dist/storage-persistent.js +897 -0
- package/dist/storage-persistent.js.map +1 -0
- package/dist/storage-persistent.test.d.ts +5 -0
- package/dist/storage-persistent.test.d.ts.map +1 -0
- package/dist/storage-persistent.test.js +325 -0
- package/dist/storage-persistent.test.js.map +1 -0
- package/dist/storage.d.ts +63 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +67 -0
- package/dist/storage.js.map +1 -0
- package/dist/storage.test.d.ts +5 -0
- package/dist/storage.test.d.ts.map +1 -0
- package/dist/storage.test.js +157 -0
- package/dist/storage.test.js.map +1 -0
- package/dist/tfidf.d.ts +97 -0
- package/dist/tfidf.d.ts.map +1 -0
- package/dist/tfidf.js +308 -0
- package/dist/tfidf.js.map +1 -0
- package/dist/tfidf.test.d.ts +5 -0
- package/dist/tfidf.test.d.ts.map +1 -0
- package/dist/tfidf.test.js +181 -0
- package/dist/tfidf.test.js.map +1 -0
- package/dist/utils.d.ts +61 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +264 -0
- package/dist/utils.js.map +1 -0
- package/dist/utils.test.d.ts +5 -0
- package/dist/utils.test.d.ts.map +1 -0
- package/dist/utils.test.js +94 -0
- package/dist/utils.test.js.map +1 -0
- package/dist/vector-storage.d.ts +120 -0
- package/dist/vector-storage.d.ts.map +1 -0
- package/dist/vector-storage.js +264 -0
- package/dist/vector-storage.js.map +1 -0
- package/dist/vector-storage.test.d.ts +5 -0
- package/dist/vector-storage.test.d.ts.map +1 -0
- package/dist/vector-storage.test.js +345 -0
- package/dist/vector-storage.test.js.map +1 -0
- package/package.json +85 -0
package/README.md
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# @sylphx/coderag
|
|
2
|
+
|
|
3
|
+
Core library for semantic code search using vector embeddings with TF-IDF fallback.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun add @sylphx/coderag
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- 🔍 **Semantic Search** - Vector search with embeddings, TF-IDF fallback
|
|
14
|
+
- 🌳 **AST-based Chunking** - Smart code splitting using Synth parsers
|
|
15
|
+
- 💾 **Persistent Storage** - SQLite-backed index for instant startup
|
|
16
|
+
- ⚡ **Incremental Updates** - Only reindex changed files
|
|
17
|
+
- 👁️ **File Watching** - Auto-update index on file changes
|
|
18
|
+
- 🧠 **Embeddings** - OpenAI embeddings for semantic search
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { CodebaseIndexer, PersistentStorage } from '@sylphx/coderag'
|
|
24
|
+
|
|
25
|
+
// Create indexer with persistent storage
|
|
26
|
+
const storage = new PersistentStorage({ codebaseRoot: './my-project' })
|
|
27
|
+
const indexer = new CodebaseIndexer({
|
|
28
|
+
codebaseRoot: './my-project',
|
|
29
|
+
storage,
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
// Index (instant on subsequent runs)
|
|
33
|
+
await indexer.index({ watch: true })
|
|
34
|
+
|
|
35
|
+
// Search
|
|
36
|
+
const results = await indexer.search('authentication', { limit: 10 })
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## API
|
|
40
|
+
|
|
41
|
+
### `CodebaseIndexer`
|
|
42
|
+
|
|
43
|
+
Main class for indexing and searching.
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
const indexer = new CodebaseIndexer({
|
|
47
|
+
codebaseRoot: string, // Project root path
|
|
48
|
+
storage?: Storage, // Storage backend (default: in-memory)
|
|
49
|
+
maxFileSize?: number, // Max file size in bytes (default: 1MB)
|
|
50
|
+
onFileChange?: (event) => void // File change callback
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
// Methods
|
|
54
|
+
await indexer.index(options) // Index codebase
|
|
55
|
+
await indexer.search(query, options) // Search
|
|
56
|
+
await indexer.startWatch() // Start file watcher
|
|
57
|
+
await indexer.stopWatch() // Stop file watcher
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### `PersistentStorage`
|
|
61
|
+
|
|
62
|
+
SQLite-backed persistent storage.
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
const storage = new PersistentStorage({
|
|
66
|
+
codebaseRoot: string, // Project root (for .coderag/ folder)
|
|
67
|
+
dbPath?: string // Custom database path
|
|
68
|
+
})
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### `buildSearchIndex` / `searchDocuments`
|
|
72
|
+
|
|
73
|
+
Low-level TF-IDF functions.
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
import { buildSearchIndex, searchDocuments } from '@sylphx/coderag'
|
|
77
|
+
|
|
78
|
+
const documents = [
|
|
79
|
+
{ uri: 'file://auth.ts', content: '...' },
|
|
80
|
+
{ uri: 'file://user.ts', content: '...' },
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
const index = buildSearchIndex(documents)
|
|
84
|
+
const results = searchDocuments('auth', index, { limit: 5 })
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### AST Chunking
|
|
88
|
+
|
|
89
|
+
Smart code chunking using Synth parsers.
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
import { chunkCodeByAST } from '@sylphx/coderag'
|
|
93
|
+
|
|
94
|
+
const chunks = await chunkCodeByAST(code, 'typescript', {
|
|
95
|
+
maxChunkSize: 1500,
|
|
96
|
+
minChunkSize: 100,
|
|
97
|
+
})
|
|
98
|
+
// Returns: [{ content, type, startLine, endLine }, ...]
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Supported languages (15+):**
|
|
102
|
+
- **JavaScript**: JS, TS, JSX, TSX
|
|
103
|
+
- **Systems**: Python, Go, Java, C, Rust
|
|
104
|
+
- **Markup**: Markdown, HTML, XML
|
|
105
|
+
- **Data/Config**: JSON, YAML, TOML, INI, Protobuf
|
|
106
|
+
|
|
107
|
+
### Vector Storage
|
|
108
|
+
|
|
109
|
+
For semantic search with embeddings.
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
import { VectorStorage, createEmbeddingProvider } from '@sylphx/coderag'
|
|
113
|
+
|
|
114
|
+
const provider = await createEmbeddingProvider({
|
|
115
|
+
provider: 'openai',
|
|
116
|
+
model: 'text-embedding-3-small',
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
const vectorStorage = new VectorStorage()
|
|
120
|
+
await vectorStorage.addDocument('doc1', embedding, { path: 'auth.ts' })
|
|
121
|
+
|
|
122
|
+
const results = await vectorStorage.search(queryEmbedding, { limit: 5 })
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Search Options
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
interface SearchOptions {
|
|
129
|
+
limit?: number // Max results (default: 10)
|
|
130
|
+
includeContent?: boolean // Include snippets (default: true)
|
|
131
|
+
fileExtensions?: string[] // Filter by extension
|
|
132
|
+
pathFilter?: string // Filter by path pattern
|
|
133
|
+
excludePaths?: string[] // Exclude paths
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Performance
|
|
138
|
+
|
|
139
|
+
| Metric | Value |
|
|
140
|
+
|--------|-------|
|
|
141
|
+
| Indexing speed | ~1000-2000 files/sec |
|
|
142
|
+
| Startup with cache | <100ms |
|
|
143
|
+
| Search latency | <50ms |
|
|
144
|
+
| Memory per 1000 files | ~1-2 MB |
|
|
145
|
+
|
|
146
|
+
## License
|
|
147
|
+
|
|
148
|
+
MIT
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
**Powered by [Sylphx](https://github.com/SylphxAI)**
|
|
153
|
+
|
|
154
|
+
Built with [@sylphx/synth](https://github.com/SylphxAI/synth) parsers (15+ languages)
|