purecontext-mcp 1.1.0 → 1.1.2
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/AGENT_INSTRUCTIONS.md +509 -0
- package/AGENT_INSTRUCTIONS_SHORT.md +97 -0
- package/CHANGELOG.md +212 -0
- package/docs/01-introduction.md +69 -0
- package/docs/02-installation.md +267 -0
- package/docs/03-quick-start.md +135 -0
- package/docs/04-configuration.md +214 -0
- package/docs/05-cli-reference.md +130 -0
- package/docs/06-tools-reference.md +499 -0
- package/docs/07-language-support.md +88 -0
- package/docs/08-framework-adapters.md +324 -0
- package/docs/09-dependency-graph.md +182 -0
- package/docs/10-semantic-search.md +153 -0
- package/docs/11-search-quality.md +110 -0
- package/docs/12-ai-summarization.md +106 -0
- package/docs/13-token-savings.md +110 -0
- package/docs/14-transport-modes.md +167 -0
- package/docs/15-team-setup.md +251 -0
- package/docs/16-docker.md +186 -0
- package/docs/17-web-ui.md +157 -0
- package/docs/18-git-history.md +157 -0
- package/docs/19-cross-repo.md +177 -0
- package/docs/20-architecture-analysis.md +228 -0
- package/docs/21-ecosystem-tools.md +189 -0
- package/docs/22-distribution.md +240 -0
- package/docs/23-performance.md +121 -0
- package/docs/24-security.md +144 -0
- package/docs/25-architecture-overview.md +240 -0
- package/docs/26-troubleshooting.md +234 -0
- package/docs/27-api-stability.md +114 -0
- package/docs/README.md +71 -0
- package/guide/README.md +57 -0
- package/guide/ai-summaries.md +127 -0
- package/guide/code-health.md +190 -0
- package/guide/code-history.md +149 -0
- package/guide/finding-code.md +157 -0
- package/guide/navigating-new-code.md +121 -0
- package/guide/safe-changes.md +156 -0
- package/guide/team-setup.md +191 -0
- package/guide/web-ui.md +154 -0
- package/guide/why-purecontext.md +73 -0
- package/guide/workflow-onboarding.md +114 -0
- package/guide/workflow-pr-review.md +199 -0
- package/guide/workflow-refactoring.md +172 -0
- package/package.json +9 -2
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
# Architecture Overview
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
This section explains PureContext's internal design. Useful for contributors, developers building on top of PureContext, or anyone who wants to understand why it works the way it does.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Three-layer architecture
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
┌──────────────────────────────────────────┐
|
|
12
|
+
│ Framework Adapters (src/adapters/) │ Vue, React, Django, Spring, ...
|
|
13
|
+
└───────────────────┬──────────────────────┘
|
|
14
|
+
│ uses
|
|
15
|
+
┌───────────────────▼──────────────────────┐
|
|
16
|
+
│ Language Handlers (src/handlers/) │ TypeScript, Python, Go, ...
|
|
17
|
+
└───────────────────┬──────────────────────┘
|
|
18
|
+
│ uses
|
|
19
|
+
┌───────────────────▼──────────────────────┐
|
|
20
|
+
│ Core (src/core/) │ Parse, Store, Search, Watch, MCP
|
|
21
|
+
└──────────────────────────────────────────┘
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**The dependency direction is strictly downward: Adapters → Handlers → Core. Never the reverse.**
|
|
25
|
+
|
|
26
|
+
This constraint means:
|
|
27
|
+
- Core knows nothing about specific languages or frameworks
|
|
28
|
+
- Handlers know nothing about frameworks
|
|
29
|
+
- Adding a new language never touches Core
|
|
30
|
+
- Adding a new framework never touches Core or existing Handlers
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Core layer (`src/core/`)
|
|
35
|
+
|
|
36
|
+
The core is language and framework agnostic. Responsibilities:
|
|
37
|
+
|
|
38
|
+
| Module | Responsibility |
|
|
39
|
+
|--------|----------------|
|
|
40
|
+
| `index-manager.ts` | Orchestrates the full indexing pipeline |
|
|
41
|
+
| `file-processor.ts` | Reads files, checks hash cache, dispatches to handlers |
|
|
42
|
+
| `parse-dispatcher.ts` | Routes files to the correct LanguageHandler by extension |
|
|
43
|
+
| `types.ts` | Core type definitions (SymbolRecord, ImportRecord, etc.) |
|
|
44
|
+
| `errors.ts` | Typed error classes extending `PureContextError` |
|
|
45
|
+
| `db/schema.ts` | SQLite table definitions and migrations |
|
|
46
|
+
| `db/symbol-store.ts` | Symbol CRUD — insert, search, retrieve |
|
|
47
|
+
| `db/file-store.ts` | Raw file content cache for `get_file_content` |
|
|
48
|
+
| `db/embedding-store.ts` | HNSW vector index management |
|
|
49
|
+
| `watcher/file-watcher.ts` | Chokidar wrapper with debounce and fast incremental path |
|
|
50
|
+
|
|
51
|
+
The MCP server (`src/server/`) and semantic search (`src/semantic/`) also build on Core.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Language handler layer (`src/handlers/`)
|
|
56
|
+
|
|
57
|
+
Each handler implements `LanguageHandler`:
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
interface LanguageHandler {
|
|
61
|
+
extensions(): string[]; // ['.ts', '.tsx']
|
|
62
|
+
grammarPath(): string; // path to .wasm grammar file
|
|
63
|
+
extractSymbols(tree: Tree, source: Buffer): SymbolRecord[];
|
|
64
|
+
extractImports(tree: Tree, source: Buffer): ImportRecord[];
|
|
65
|
+
extractDocstring(node: SyntaxNode): string | null;
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Handlers know how to:
|
|
70
|
+
- Load their tree-sitter WASM grammar
|
|
71
|
+
- Walk the AST to find symbol-bearing nodes
|
|
72
|
+
- Extract names, byte offsets, signatures, and docstrings
|
|
73
|
+
- Extract import statements and resolve specifiers
|
|
74
|
+
|
|
75
|
+
Handlers know **nothing** about frameworks, adapters, or the database.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Framework adapter layer (`src/adapters/`)
|
|
80
|
+
|
|
81
|
+
Each adapter implements `FrameworkAdapter`:
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
interface FrameworkAdapter {
|
|
85
|
+
name: string;
|
|
86
|
+
detect(projectRoot: string): Promise<boolean>;
|
|
87
|
+
fileFilter(filePath: string): boolean;
|
|
88
|
+
preProcess?(source: Buffer, filePath: string): ProcessedBlock[];
|
|
89
|
+
extractFrameworkSymbols(tree: Tree, source: Buffer, filePath: string): SymbolRecord[];
|
|
90
|
+
enrichMetadata?(symbol: SymbolRecord): SymbolRecord;
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Adapters compose on top of language handlers. Multiple adapters can be active at once. Auto-detection runs at index time by calling `detect()` on every registered adapter.
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Data flow: indexing pipeline
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
index_folder(path)
|
|
102
|
+
↓
|
|
103
|
+
FileDiscovery
|
|
104
|
+
- scan directory recursively
|
|
105
|
+
- apply exclude patterns (node_modules, .git, *.pem, etc.)
|
|
106
|
+
- prioritize by type (source files before config files)
|
|
107
|
+
↓
|
|
108
|
+
FileProcessor (per file, parallel via worker threads)
|
|
109
|
+
- read file content
|
|
110
|
+
- compute SHA-256 hash
|
|
111
|
+
- compare with hash cache → skip if unchanged
|
|
112
|
+
↓
|
|
113
|
+
ParseDispatcher
|
|
114
|
+
- route file to LanguageHandler by extension
|
|
115
|
+
↓
|
|
116
|
+
LanguageHandler.parse(buffer) → tree-sitter AST
|
|
117
|
+
↓
|
|
118
|
+
LanguageHandler.extractSymbols(AST) → SymbolRecord[]
|
|
119
|
+
LanguageHandler.extractImports(AST) → ImportRecord[]
|
|
120
|
+
↓
|
|
121
|
+
FrameworkAdapter.extractFrameworkSymbols(AST) → SymbolRecord[] (if active)
|
|
122
|
+
FrameworkAdapter.enrichMetadata(symbol) → SymbolRecord (if active)
|
|
123
|
+
↓
|
|
124
|
+
AISummarizer (optional)
|
|
125
|
+
- fill in missing summaries via AI API
|
|
126
|
+
↓
|
|
127
|
+
SymbolStore.insertBatch(symbols) → SQLite (symbols table)
|
|
128
|
+
PathResolver.resolve(imports) → DepEdge[]
|
|
129
|
+
DepStore.insertBatch(edges) → SQLite (dep_edges table)
|
|
130
|
+
SemanticIndexer.index(symbols) → HNSW index (if enabled)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Data flow: query pipeline
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
MCP tool call (e.g., search_symbols)
|
|
139
|
+
↓
|
|
140
|
+
Tool handler (src/server/tools/search-symbols.ts)
|
|
141
|
+
- parse and validate input
|
|
142
|
+
↓
|
|
143
|
+
SymbolStore.search(query)
|
|
144
|
+
- FTS5 query → BM25 ranked results
|
|
145
|
+
- RelevanceRanker re-scores and sorts
|
|
146
|
+
↓
|
|
147
|
+
Tool handler
|
|
148
|
+
- compute _tokenEstimate
|
|
149
|
+
- record token savings in savings tracker
|
|
150
|
+
↓
|
|
151
|
+
JSON response → MCP client
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## SQLite schema
|
|
157
|
+
|
|
158
|
+
Four tables:
|
|
159
|
+
|
|
160
|
+
```sql
|
|
161
|
+
CREATE TABLE repos (
|
|
162
|
+
id TEXT PRIMARY KEY, -- SHA-256(absolutePath).slice(0,16)
|
|
163
|
+
root_path TEXT NOT NULL,
|
|
164
|
+
indexed_at INTEGER,
|
|
165
|
+
file_count INTEGER,
|
|
166
|
+
symbol_count INTEGER
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
CREATE TABLE files (
|
|
170
|
+
id TEXT PRIMARY KEY,
|
|
171
|
+
repo_id TEXT NOT NULL,
|
|
172
|
+
file_path TEXT NOT NULL, -- relative to repo root
|
|
173
|
+
content_hash TEXT,
|
|
174
|
+
content BLOB, -- cached raw content
|
|
175
|
+
last_modified INTEGER
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
CREATE TABLE symbols (
|
|
179
|
+
id TEXT PRIMARY KEY, -- SHA-256(filePath:name:kind).slice(0,16)
|
|
180
|
+
repo_id TEXT NOT NULL,
|
|
181
|
+
name TEXT NOT NULL,
|
|
182
|
+
kind TEXT NOT NULL,
|
|
183
|
+
file_path TEXT NOT NULL,
|
|
184
|
+
start_byte INTEGER,
|
|
185
|
+
end_byte INTEGER,
|
|
186
|
+
signature TEXT,
|
|
187
|
+
summary TEXT,
|
|
188
|
+
framework_meta TEXT -- JSON blob
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
CREATE TABLE dep_edges (
|
|
192
|
+
id TEXT PRIMARY KEY,
|
|
193
|
+
repo_id TEXT NOT NULL,
|
|
194
|
+
source_file TEXT NOT NULL,
|
|
195
|
+
target_file TEXT NOT NULL,
|
|
196
|
+
specifier TEXT, -- raw import path
|
|
197
|
+
imported_names TEXT -- JSON array
|
|
198
|
+
);
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
FTS5 virtual table on `symbols(name, summary, signature)` provides full-text search.
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## Deterministic IDs
|
|
206
|
+
|
|
207
|
+
IDs are deterministic and stable across re-indexes:
|
|
208
|
+
|
|
209
|
+
- `repoId = SHA-256(absolutePath).slice(0, 16)`
|
|
210
|
+
- `symbolId = SHA-256(filePath:name:kind).slice(0, 16)`
|
|
211
|
+
|
|
212
|
+
This means the same symbol in the same file always has the same ID. Agents can store symbol IDs in long-term memory and retrieve them reliably on the next session.
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## File watcher
|
|
217
|
+
|
|
218
|
+
`chokidar` watches the indexed directory for file changes. A 2-second debounce (configurable) prevents thrashing on bulk saves.
|
|
219
|
+
|
|
220
|
+
**Fast path for single file changes:**
|
|
221
|
+
1. Re-parse only the changed file
|
|
222
|
+
2. Delete old symbols for that file from SQLite
|
|
223
|
+
3. Insert new symbols
|
|
224
|
+
4. Update dep_edges for that file
|
|
225
|
+
5. Skip full re-scan
|
|
226
|
+
|
|
227
|
+
This makes editor save → symbol update latency typically < 200ms.
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## Storage locations
|
|
232
|
+
|
|
233
|
+
| Path | Contents |
|
|
234
|
+
|------|----------|
|
|
235
|
+
| `~/.purecontext/indexes/` | SQLite databases (one per project) |
|
|
236
|
+
| `~/.purecontext/indexes/{repoId}/hnsw.idx` | HNSW vector index |
|
|
237
|
+
| `~/.purecontext/clones/` | Remote repo clones (via `index_repo`) |
|
|
238
|
+
| `~/.purecontext/config.json` | Configuration file |
|
|
239
|
+
| `~/.purecontext/_savings.json` | Cumulative token savings |
|
|
240
|
+
| `~/.purecontext/telemetry.jsonl` | Local telemetry audit log (if enabled) |
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
# Troubleshooting
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Health check
|
|
7
|
+
|
|
8
|
+
Before investigating any problem, run the health check:
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
purecontext-mcp --health
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
```json
|
|
15
|
+
{
|
|
16
|
+
"status": "ok",
|
|
17
|
+
"version": "1.x.x",
|
|
18
|
+
"uptime": 0,
|
|
19
|
+
"nodeVersion": "20.11.0",
|
|
20
|
+
"platform": "linux",
|
|
21
|
+
"indexDir": "/home/user/.purecontext/indexes",
|
|
22
|
+
"repoCount": 3,
|
|
23
|
+
"grammars": {
|
|
24
|
+
"tree-sitter-typescript.wasm": true,
|
|
25
|
+
"tree-sitter-javascript.wasm": true
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
In HTTP mode:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
curl http://localhost:3000/health
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
A non-zero exit code (CLI) or non-200 response (HTTP) indicates something is wrong.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Debug logging
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
purecontext-mcp --log-level debug
|
|
44
|
+
# or
|
|
45
|
+
LOG_LEVEL=debug purecontext-mcp
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Debug logs show: file-by-file parsing progress, hash cache hits/misses, worker thread activity, query plan details, rate limit decisions.
|
|
49
|
+
|
|
50
|
+
**Use in production only temporarily** — debug logs are verbose and may include file paths.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Common errors
|
|
55
|
+
|
|
56
|
+
### "Repo not indexed" / "Index not found"
|
|
57
|
+
|
|
58
|
+
The repository has not been indexed yet, or the `repoId` belongs to a different installation.
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
Fix: Call index_folder with the correct path.
|
|
62
|
+
Use resolve_repo to check if the path is indexed.
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
### "Grammar file not found"
|
|
68
|
+
|
|
69
|
+
A `.wasm` grammar file is missing from the `grammars/` directory.
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Check which grammars are present:
|
|
73
|
+
purecontext-mcp config --check
|
|
74
|
+
|
|
75
|
+
# Fix: reinstall the package
|
|
76
|
+
npm install -g purecontext-mcp
|
|
77
|
+
# or
|
|
78
|
+
npm rebuild purecontext-mcp
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
### "better-sqlite3 bindings failed to load"
|
|
84
|
+
|
|
85
|
+
The native `better-sqlite3` binary doesn't match your Node.js version or platform.
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
# Fix: rebuild the native module
|
|
89
|
+
cd $(npm root -g)/purecontext-mcp
|
|
90
|
+
npm rebuild better-sqlite3
|
|
91
|
+
|
|
92
|
+
# If that fails, install build tools first:
|
|
93
|
+
# macOS: xcode-select --install
|
|
94
|
+
# Linux: apt install python3 make g++
|
|
95
|
+
# Windows: npm install -g windows-build-tools
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
### Missing symbols after indexing
|
|
101
|
+
|
|
102
|
+
Check this list in order:
|
|
103
|
+
|
|
104
|
+
1. **Is the file excluded?** Check `excludePatterns` and built-in exclusions (node_modules, dist, .env, etc.)
|
|
105
|
+
2. **Is the file too large?** Files > `maxFileSizeBytes` (default 1 MB) are skipped
|
|
106
|
+
3. **Is it a secret file?** `.pem`, `.key`, `credentials.json` etc. are always excluded
|
|
107
|
+
4. **Is it a private symbol?** Go unexported names, C `static` functions, Java/C# `private` members are excluded by design
|
|
108
|
+
5. **Is the language supported?** Check [Language Support](07-language-support.md)
|
|
109
|
+
6. **Did the adapter detect?** Run `purecontext-mcp config --check` — check "Detected adapters" for your project
|
|
110
|
+
|
|
111
|
+
Force a specific adapter if auto-detection fails:
|
|
112
|
+
```json
|
|
113
|
+
{ "adapters": ["vue", "nuxt"] }
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
### Adapter not activating
|
|
119
|
+
|
|
120
|
+
Run `purecontext-mcp config --check` and look at the detected adapters. Common detection requirements:
|
|
121
|
+
|
|
122
|
+
| Framework | Detection file |
|
|
123
|
+
|-----------|---------------|
|
|
124
|
+
| Vue | `vue` in `package.json` dependencies |
|
|
125
|
+
| Nuxt | `nuxt.config.ts` at project root |
|
|
126
|
+
| Django | `manage.py` at project root |
|
|
127
|
+
| Rails | `gem 'rails'` in `Gemfile` |
|
|
128
|
+
| Gin | `github.com/gin-gonic/gin` in `go.mod` |
|
|
129
|
+
| Spring Boot | `spring-boot-starter` in `pom.xml` |
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
### Incremental re-index not triggering
|
|
134
|
+
|
|
135
|
+
The file watcher uses a 2-second debounce. For manual force re-index:
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
Call index_folder again — it skips unchanged files via content hashing.
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
If the watcher seems stuck on Linux:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
# Check inotify limit
|
|
145
|
+
cat /proc/sys/fs/inotify/max_user_watches
|
|
146
|
+
|
|
147
|
+
# Increase if needed
|
|
148
|
+
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf
|
|
149
|
+
sudo sysctl -p
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
### HTTP transport not accessible
|
|
155
|
+
|
|
156
|
+
1. **Check `http.host`** — default is `127.0.0.1` (loopback only). Set to `0.0.0.0` for network access.
|
|
157
|
+
2. **Check CORS** — `http.corsOrigins` must include the browser's origin.
|
|
158
|
+
3. **Check auth** — if `http.auth.enabled: true`, all requests need `Authorization: Bearer <token>`.
|
|
159
|
+
4. **Check firewall** — port 3000 must be open from the client's perspective.
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
### Semantic search not working
|
|
164
|
+
|
|
165
|
+
1. Verify `semantic.enabled: true` in config
|
|
166
|
+
2. Verify a provider is configured: `semantic.provider` is not `"none"`
|
|
167
|
+
3. Check if the repo meets the threshold: lower `semantic.threshold` for small repos
|
|
168
|
+
4. Verify the API key: test it with a direct API call
|
|
169
|
+
5. Re-index — the HNSW index is built during indexing, not at query time
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
### Config validation errors
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
purecontext-mcp config --check
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Reports all schema violations with field names and expected types.
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
### Rate limit errors (HTTP mode)
|
|
184
|
+
|
|
185
|
+
`429 Too Many Requests` — the API key has hit its per-second token limit.
|
|
186
|
+
|
|
187
|
+
Check the `Retry-After` header for when to retry. If limits are too low for your use case, ask the server admin to raise `rateLimit.maxTokens` or `rateLimit.refillRate` for your key.
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
### "git not found" when using `index_repo`
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
# Verify git is installed and on PATH
|
|
195
|
+
git --version
|
|
196
|
+
|
|
197
|
+
# Install if missing:
|
|
198
|
+
# macOS: xcode-select --install
|
|
199
|
+
# Linux: apt install git
|
|
200
|
+
# Windows: https://git-scm.com/download/win
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
### Indexing is slow
|
|
206
|
+
|
|
207
|
+
- First index is always slower — subsequent runs are incremental (hash-based)
|
|
208
|
+
- AI summarization (`allowRemoteAI: true`) adds API latency — disable during testing
|
|
209
|
+
- Semantic indexing adds API latency — disable if not needed
|
|
210
|
+
- For large repos (> 10k files): increase `workerThreads` in config
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## Re-indexing from scratch
|
|
215
|
+
|
|
216
|
+
```
|
|
217
|
+
Use invalidate_cache tool with your repoId, then call index_folder again.
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Or manually:
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
rm ~/.purecontext/indexes/<repoId>.db
|
|
224
|
+
rm -rf ~/.purecontext/indexes/<repoId>/
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
Then call `index_folder` — a clean full index will be built.
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## Getting more help
|
|
232
|
+
|
|
233
|
+
- **GitHub Issues:** Report bugs with version, OS, Node.js version, error log, and approximate repo size
|
|
234
|
+
- **`--log-level debug`** output is the most useful information to include in a bug report
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# API Stability & Changelog
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Versioning policy
|
|
7
|
+
|
|
8
|
+
PureContext follows **semantic versioning (semver)**:
|
|
9
|
+
|
|
10
|
+
| Change type | Version bump |
|
|
11
|
+
|-------------|-------------|
|
|
12
|
+
| Remove or rename a tool | `2.0.0` (major) |
|
|
13
|
+
| Remove or rename a required parameter | `2.0.0` (major) |
|
|
14
|
+
| Remove a top-level response field | `2.0.0` (major) |
|
|
15
|
+
| Change the type or semantics of a stable field | `2.0.0` (major) |
|
|
16
|
+
| Add a new tool | `1.x.0` (minor) |
|
|
17
|
+
| Add an optional parameter | `1.x.0` (minor) |
|
|
18
|
+
| Add a new response field | `1.x.0` (minor) |
|
|
19
|
+
| Bug fix with no API surface change | `1.0.x` (patch) |
|
|
20
|
+
|
|
21
|
+
Agents and integrations built against `v1.x` will not break until `v2.0`.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Public API contract
|
|
26
|
+
|
|
27
|
+
### What is stable in 1.x
|
|
28
|
+
|
|
29
|
+
| Surface | Stable? |
|
|
30
|
+
|---------|---------|
|
|
31
|
+
| MCP tool names | Yes |
|
|
32
|
+
| Required tool parameters | Yes |
|
|
33
|
+
| Top-level response field names and types | Yes |
|
|
34
|
+
| CLI flag names and exit codes | Yes |
|
|
35
|
+
| Symbol ID format (deterministic hash) | Yes |
|
|
36
|
+
| `repoId` format (deterministic hash) | Yes |
|
|
37
|
+
|
|
38
|
+
### What is NOT covered by the stability guarantee
|
|
39
|
+
|
|
40
|
+
| Surface | Notes |
|
|
41
|
+
|---------|-------|
|
|
42
|
+
| Internal module paths (`src/core/...`) | For contributors only, may change freely |
|
|
43
|
+
| SQLite schema column names | Subject to migration with version upgrades |
|
|
44
|
+
| HTTP admin API (`/admin/*`) | Stable at `1.0` but less strictly than MCP tools |
|
|
45
|
+
| `ai.*` config group | May change as AI summarization matures |
|
|
46
|
+
| Response field order | JSON objects — do not rely on ordering |
|
|
47
|
+
|
|
48
|
+
For the full list of stable tools and their exact parameter/response contracts, see [docs/API_STABILITY.md](API_STABILITY.md).
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Stable tools (1.x)
|
|
53
|
+
|
|
54
|
+
All tools listed in [MCP Tools Reference](06-tools-reference.md) are stable in 1.x, with the exception of tools in the experimental list below which are marked `@experimental` until a future stabilization release.
|
|
55
|
+
|
|
56
|
+
**Stable tool list:**
|
|
57
|
+
`index_folder` · `index_repo` · `resolve_repo` · `list_repos` · `search_symbols` · `search_text` · `get_symbol_source` · `get_file_outline` · `get_repo_outline` · `get_file_tree` · `get_context_bundle` · `get_blast_radius` · `find_importers` · `find_dead_code` · `get_savings_stats` · `get_layer_violations`
|
|
58
|
+
|
|
59
|
+
**Experimental:**
|
|
60
|
+
`invalidate_cache` · `get_file_content` · `get_symbols` · `find_references` · `search_semantic` · `search_cross_repo` · `find_similar` · `get_symbol_history` · `get_churn_metrics` · `get_quality_metrics` · `detect_antipatterns` · `get_architecture_doc` · `search_columns`
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Stable symbol kinds
|
|
65
|
+
|
|
66
|
+
The following `SymbolKind` values are stable in 1.x:
|
|
67
|
+
|
|
68
|
+
`function` · `class` · `method` · `const` · `type` · `interface` · `enum` · `component` · `composable` · `hook` · `route` · `decorator` · `middleware`
|
|
69
|
+
|
|
70
|
+
New kinds may be added in minor releases. Clients should handle unknown kinds gracefully (do not throw on unknown kind values).
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Deprecation process
|
|
75
|
+
|
|
76
|
+
Before removing anything in a major version:
|
|
77
|
+
|
|
78
|
+
1. The deprecated item is marked `_deprecated: true` in the response for one minor release cycle
|
|
79
|
+
2. A note is added to `CHANGELOG.md` and the release notes
|
|
80
|
+
3. The deprecated item is removed in the next major version
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Index file compatibility
|
|
85
|
+
|
|
86
|
+
SQLite index files are forward-compatible within a major version. Upgrading from `v1.0` to `v1.5` requires no action — the migrator runs automatically at startup.
|
|
87
|
+
|
|
88
|
+
A `v1.x` → `v2.0` upgrade may require a re-index. The CLI warns at startup if it detects an incompatible index version:
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
Warning: Index at ~/.purecontext/indexes/abc123.db was created by v1.x
|
|
92
|
+
and is not compatible with v2.0. Run index_folder to re-index.
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Changelog
|
|
98
|
+
|
|
99
|
+
See [CHANGELOG.md](../CHANGELOG.md) for the full version history.
|
|
100
|
+
|
|
101
|
+
**Key milestones:**
|
|
102
|
+
|
|
103
|
+
| Version | Highlights |
|
|
104
|
+
|---------|-----------|
|
|
105
|
+
| `1.0.0` | Stable release: prebuilt binaries, 19 languages, 20+ framework adapters, FTS5 search, HNSW semantic search, Web UI, rate limiting, Docker |
|
|
106
|
+
| `1.1.0` | `find_references`, `get_file_content`, `get_symbols`, `invalidate_cache` |
|
|
107
|
+
| `1.2.0` | search debug mode, `context_lines`/`verify`, GitHub API indexing, Gemini Flash |
|
|
108
|
+
| `1.3.0` | context providers, dbt, `search_columns`, OpenAPI, SQL handler |
|
|
109
|
+
| `1.4.0` | 15 new language handlers (34 total) |
|
|
110
|
+
| `1.5.0` | cross-repo search, code similarity, MCP Resources |
|
|
111
|
+
| `1.6.0` | git & history integration |
|
|
112
|
+
| `1.7.0` | AI-powered architecture analysis |
|
|
113
|
+
| `1.8.0` | enhanced Web UI |
|
|
114
|
+
| `1.9.0` | distribution & platform (registry, webhooks, GitHub Actions, VS Code extension) |
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# PureContext MCP — User Manual
|
|
2
|
+
|
|
3
|
+
PureContext MCP indexes your codebase and gives AI agents a way to navigate it without reading entire files. Instead of loading hundreds of lines of code to find one function, Claude (or any other MCP-compatible AI) can search by name, retrieve just the symbol it needs, and understand the dependency chain — all in a fraction of the tokens.
|
|
4
|
+
|
|
5
|
+
This manual covers everything from installation through advanced features. Use the sections below to navigate to what you need, or read in order for a full introduction.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Getting Started
|
|
10
|
+
|
|
11
|
+
These three sections get you from zero to a working setup.
|
|
12
|
+
|
|
13
|
+
- [Introduction](01-introduction.md) — What PureContext is, why token efficiency matters, key concepts
|
|
14
|
+
- [Installation](02-installation.md) — Install via npm, verify your setup, upgrade and uninstall
|
|
15
|
+
- [Quick Start](03-quick-start.md) — Index a project and search your first symbol in minutes
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Reference
|
|
20
|
+
|
|
21
|
+
Complete reference material for configuration, the CLI, and every MCP tool.
|
|
22
|
+
|
|
23
|
+
- [Configuration](04-configuration.md) — Full `config.json` schema, every field explained, environment variable overrides
|
|
24
|
+
- [CLI Reference](05-cli-reference.md) — Every command and flag: `config --init`, `--health`, `--transport`, and more
|
|
25
|
+
- [MCP Tools Reference](06-tools-reference.md) — Every tool with inputs, outputs, and examples — grouped by category
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Language & Framework Support
|
|
30
|
+
|
|
31
|
+
- [Language Support](07-language-support.md) — All 34 supported languages: what gets indexed and known limitations
|
|
32
|
+
- [Framework Adapters](08-framework-adapters.md) — Vue, React, Nuxt, Next.js, Angular, NestJS, Express, Django, Rails, Spring, and 20+ more
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Core Features
|
|
37
|
+
|
|
38
|
+
- [Dependency Graph Tools](09-dependency-graph.md) — Find what a symbol depends on, what depends on it, and what is dead code
|
|
39
|
+
- [Semantic Search](10-semantic-search.md) — Search by meaning rather than name using HNSW vector index
|
|
40
|
+
- [Search Quality & Ranking](11-search-quality.md) — How FTS5, camelCase splitting, and relevance ranking work; search tips
|
|
41
|
+
- [AI Summarization](12-ai-summarization.md) — Auto-generate symbol descriptions with Anthropic, OpenAI, or Gemini
|
|
42
|
+
- [Token Savings Tracker](13-token-savings.md) — See exactly how many tokens (and dollars) PureContext saves per session
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Deployment
|
|
47
|
+
|
|
48
|
+
- [Transport Modes](14-transport-modes.md) — stdio (local) vs HTTP/SSE (team/browser); TLS via reverse proxy
|
|
49
|
+
- [Team Setup & Multi-Tenant](15-team-setup.md) — Shared server, workspaces, API keys, rate limiting
|
|
50
|
+
- [Docker Deployment](16-docker.md) — `docker run`, Docker Compose, volumes, environment variables, health checks
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Advanced Features
|
|
55
|
+
|
|
56
|
+
- [Web UI](17-web-ui.md) — Visual graph viewer, heatmap, symbol timeline, test coverage overlay
|
|
57
|
+
- [Git & History Integration](18-git-history.md) — Symbol-level commit history, churn metrics, PR diff analysis
|
|
58
|
+
- [Cross-Repo Intelligence](19-cross-repo.md) — Search across multiple repos, find similar code, MCP Resources
|
|
59
|
+
- [AI-Powered Architecture Analysis](20-architecture-analysis.md) — Quality metrics, anti-pattern detection, auto-generated architecture docs
|
|
60
|
+
- [Ecosystem & Data Tools](21-ecosystem-tools.md) — dbt integration, OpenAPI/Swagger handler, SQL handler, column search
|
|
61
|
+
- [Distribution & Platform](22-distribution.md) — Index export/import, public registry, webhooks, GitHub Actions, VS Code extension
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Operations & Reference
|
|
66
|
+
|
|
67
|
+
- [Performance & Scalability](23-performance.md) — Worker thread pool, large repo tuning, memory usage
|
|
68
|
+
- [Security](24-security.md) — API key model, workspace isolation, path traversal prevention, hardening checklist
|
|
69
|
+
- [Troubleshooting](26-troubleshooting.md) — Common errors, `--health` output, debug logging, re-indexing from scratch
|
|
70
|
+
- [Architecture Overview](25-architecture-overview.md) — How PureContext works internally: three-layer design, data flow, SQLite schema
|
|
71
|
+
- [API Stability & Changelog](27-api-stability.md) — Semver policy, stable vs experimental tools, version history
|