smart-context-mcp 1.0.3 → 1.1.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.
package/README.md CHANGED
@@ -1,597 +1,230 @@
1
1
  # smart-context-mcp
2
2
 
3
+ MCP server that reduces AI agent token usage by 90% with intelligent context compression.
4
+
3
5
  [![npm version](https://badge.fury.io/js/smart-context-mcp.svg)](https://www.npmjs.com/package/smart-context-mcp)
4
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
7
 
6
- **MCP server that reduces AI agent token usage by 90% and improves response quality.**
7
-
8
- Instead of reading entire files and repeating context, this MCP provides 7 smart tools that compress, rank, and maintain context efficiently.
9
-
10
- ## Why use this?
11
-
12
- **Problem:** AI agents waste tokens reading full files, repeating context, and searching inefficiently.
13
-
14
- **Solution:** This MCP reduces token usage by **~90%** in real projects while improving response quality.
15
-
16
- **Real metrics from production use:**
17
- - 14.5M tokens → 1.6M tokens (89.87% reduction)
18
- - 3,666 successful calls across 7 tools
19
- - Compression ratios: 3x to 46x depending on tool
20
-
21
- ## Quick Start (2 commands)
8
+ ## Installation
22
9
 
23
10
  ```bash
24
11
  npm install smart-context-mcp
25
12
  npx smart-context-init --target .
26
13
  ```
27
14
 
28
- That's it. Restart your AI client (Cursor, Codex, Claude Desktop) and the tools are available.
29
-
30
- **Important:** The init command automatically sets the correct project-root env var in the generated configs, so the MCP server runs from your project root. This works for standalone projects, monorepos, and nested workspaces.
31
-
32
- ## What you get
15
+ Restart your AI client. Tools are immediately available.
33
16
 
34
- Seven focused tools that work automatically:
17
+ ## What it does
35
18
 
36
- - `smart_read`: compact file summaries instead of full file dumps (3x compression)
37
- - `smart_read_batch`: read multiple files in one call — reduces round-trip latency
38
- - `smart_search`: ripgrep-first code search with intent-aware ranking (21x compression)
39
- - `smart_context`: one-call context planner — search + read + graph expansion
40
- - `smart_summary`: maintain compressed conversation state across sessions (46x compression)
41
- - `smart_shell`: safe diagnostic shell execution with restricted commands (18x compression)
42
- - `build_index`: lightweight symbol index for faster lookups and smarter ranking
19
+ Replaces inefficient file reading and searching with 12 specialized tools:
43
20
 
44
- **Strongest in:** Modern web/backend codebases (JS/TS, React, Next.js, Node.js, Python, Go, Rust), infra repos (Terraform, Docker, YAML)
21
+ | Tool | Purpose | Savings |
22
+ |------|---------|---------|
23
+ | `smart_read` | Read files in outline/signatures mode | 90% |
24
+ | `smart_read_batch` | Read multiple files in one call | 90% |
25
+ | `smart_search` | Intent-aware code search with ranking | 95% |
26
+ | `smart_context` | One-call context builder | 85% |
27
+ | `smart_summary` | Session state management | 98% |
28
+ | `smart_turn` | Turn orchestration | - |
29
+ | `smart_metrics` | Token usage inspection | - |
30
+ | `smart_shell` | Safe command execution | 94% |
31
+ | `build_index` | Symbol index builder | - |
32
+ | `warm_cache` | File preloading (5x faster cold start) | - |
33
+ | `git_blame` | Function-level code attribution | - |
34
+ | `cross_project` | Multi-project context | - |
45
35
 
46
- ## Example: Before vs After
36
+ ## Real Metrics
47
37
 
48
- ### Without this MCP
49
- ```
50
- Agent: Let me read auth.js...
51
- [Reads 4,000 tokens of full file]
52
-
53
- Agent: Let me search for "jwt validation"...
54
- [Returns 10,000 tokens of grep results]
38
+ Production usage: **14.5M tokens → 1.6M tokens** (89.87% reduction)
55
39
 
56
- Agent: [Next turn] What were we doing?
57
- [Repeats 5,000 tokens of context]
40
+ ## Core Tools
58
41
 
59
- Total: ~19,000 tokens
60
- ```
61
-
62
- ### With this MCP
63
- ```
64
- Agent: Let me use smart_read on auth.js...
65
- [Returns 500 tokens of signatures]
66
-
67
- Agent: Let me use smart_search for "jwt validation"...
68
- [Returns 400 tokens of ranked snippets]
69
-
70
- Agent: [Next turn] Let me get the context...
71
- [smart_summary returns 100 tokens]
72
-
73
- Total: ~1,000 tokens (95% reduction)
74
- ```
42
+ ### smart_read
75
43
 
76
- ## Quick start
44
+ Read files without full content:
77
45
 
78
- ```bash
79
- npm install smart-context-mcp
80
- npx smart-context-init --target .
81
- ```
82
-
83
- This installs the MCP server and generates client configs for Cursor, Codex, Qwen, and Claude Code. Open the project with your IDE/agent and the server starts automatically.
84
-
85
- ## Binaries
86
-
87
- The package exposes three binaries:
88
-
89
- - `smart-context-server`
90
- - `smart-context-init`
91
- - `smart-context-report`
92
-
93
- Start the MCP server against the current project:
94
-
95
- ```bash
96
- smart-context-server
97
- ```
98
-
99
- Start it against another repository:
100
-
101
- ```bash
102
- smart-context-server --project-root /path/to/target-repo
103
- ```
104
-
105
- ## Generate client configs
106
-
107
- Generate MCP config files for a target project:
46
+ ```javascript
47
+ // Outline mode: structure only (~400 tokens vs 4000)
48
+ { filePath: 'src/server.js', mode: 'outline' }
108
49
 
109
- ```bash
110
- smart-context-init --target /path/to/project
50
+ // Extract specific function
51
+ { filePath: 'src/auth.js', mode: 'symbol', symbol: 'validateToken' }
111
52
  ```
112
53
 
113
- Limit the generated clients if needed:
54
+ **Modes**: `outline`, `signatures`, `symbol`, `range`, `full`
114
55
 
115
- ```bash
116
- smart-context-init --target /path/to/project --clients cursor,codex,qwen,claude
117
- ```
56
+ ### smart_search
118
57
 
119
- Override the command used in generated configs:
58
+ Intent-aware search with ranking:
120
59
 
121
- ```bash
122
- smart-context-init --target /path/to/project --command node --args '["./tools/devctx/src/mcp-server.js"]'
60
+ ```javascript
61
+ { query: 'authentication', intent: 'debug' } // Prioritizes errors, logs
62
+ { query: 'UserModel', intent: 'implementation' } // Prioritizes source
123
63
  ```
124
64
 
125
- ## Metrics
65
+ **Intents**: `implementation`, `debug`, `tests`, `config`, `docs`, `explore`
126
66
 
127
- Each tool call persists token metrics to the target repo by default in:
67
+ ### smart_context
128
68
 
129
- ```bash
130
- .devctx/metrics.jsonl
131
- ```
132
-
133
- This makes per-repo usage visible without digging into `node_modules`. Running `smart-context-init` also adds `.devctx/` to the target repo's `.gitignore` idempotently.
134
-
135
- Show a quick report:
69
+ Get everything for a task in one call:
136
70
 
137
- ```bash
138
- smart-context-report
71
+ ```javascript
72
+ {
73
+ task: 'Fix authentication bug',
74
+ detail: 'balanced', // minimal | balanced | deep
75
+ maxTokens: 8000
76
+ }
139
77
  ```
140
78
 
141
- Show JSON output or a custom file:
79
+ Returns: relevant files + compressed content + symbol details + graph relationships
142
80
 
143
- ```bash
144
- smart-context-report --json
145
- smart-context-report --file ./.devctx/metrics.jsonl
146
- ```
81
+ ### smart_summary
147
82
 
148
- Example output:
83
+ Maintain session state:
149
84
 
150
- ```text
151
- devctx metrics report
152
-
153
- File: /path/to/repo/.devctx/metrics.jsonl
154
- Source: default
155
- Entries: 148
156
- Raw tokens: 182,340
157
- Final tokens: 41,920
158
- Saved tokens: 140,420 (77.01%)
85
+ ```javascript
86
+ // Start
87
+ { action: 'update', update: { goal: 'Implement OAuth', status: 'in_progress' }}
159
88
 
160
- By tool:
161
- smart_context count=42 raw=96,200 final=24,180 saved=72,020 (74.86%)
162
- smart_read count=71 raw=52,810 final=9,940 saved=42,870 (81.18%)
163
- smart_search count=35 raw=33,330 final=7,800 saved=25,530 (76.59%)
89
+ // Resume
90
+ { action: 'get' }
164
91
  ```
165
92
 
166
- If you want to override the location entirely, set `DEVCTX_METRICS_FILE`.
93
+ ## New Features
167
94
 
168
- ## Usage per client
95
+ ### Diff-Aware Context
169
96
 
170
- After installing and running `smart-context-init`, each client picks up the server automatically:
97
+ Analyze git changes intelligently:
171
98
 
172
- ### Cursor
173
-
174
- Open the project in Cursor. The MCP server starts automatically. Enable it in **Cursor Settings > MCP** if needed. All seven tools are available in Agent mode.
175
-
176
- ### Codex CLI
177
-
178
- ```bash
179
- cd /path/to/your-project
180
- codex
181
- ```
182
-
183
- Codex reads `.codex/config.toml` and starts the MCP server on launch.
184
-
185
- ### Claude Code
186
-
187
- ```bash
188
- cd /path/to/your-project
189
- claude
99
+ ```javascript
100
+ { task: 'Review changes', diff: 'main' }
190
101
  ```
191
102
 
192
- Claude Code reads `.mcp.json` from the project root.
193
-
194
- ### Qwen Code
195
-
196
- Open the project in Qwen Code. The MCP server starts from `.qwen/settings.json`.
103
+ Returns changed files prioritized by impact + related files (importers, tests).
197
104
 
198
- ## Agent rules
105
+ ### Context Prediction
199
106
 
200
- `smart-context-init` generates agent rules that instruct AI agents to prefer devctx tools over their built-in equivalents. This is what makes agents use `smart_read` in outline/signatures mode instead of reading full files.
107
+ Learn from usage and predict needed files:
201
108
 
202
- ### Intent-based workflows
203
-
204
- The `intent` parameter in `smart_search` and `smart_context` adjusts ranking and suggests optimal workflows:
205
-
206
- | Intent | Ranking priority | Suggested workflow |
207
- |--------|-----------------|-------------------|
208
- | `debug` | Error messages, stack traces, logs | Search error → read signatures → inspect symbol → smart_shell |
209
- | `implementation` | Source files, changed files | Read outline/signatures → focus on changed symbols |
210
- | `tests` | Test files, spec files | Find tests → read symbol of function under test |
211
- | `config` | Config files, env vars, YAML/JSON | Find settings → read full config files |
212
- | `explore` | Entry points, main modules | Directory structure → outlines of key modules |
213
-
214
- ### Generated files per client
215
-
216
- - **Cursor**: `.cursor/rules/devctx.mdc` (always-apply rule)
217
- - **Codex**: `AGENTS.md` (devctx section with sentinel markers)
218
- - **Claude Code**: `CLAUDE.md` (devctx section with sentinel markers)
219
-
220
- The rules are idempotent — running `smart-context-init` again updates the section without duplicating it. Existing content in `AGENTS.md` and `CLAUDE.md` is preserved.
221
-
222
- ## Use against another repo
223
-
224
- By default, `devctx` works against the repo where it is installed. You can point it at another repo without modifying that target project:
225
-
226
- ```bash
227
- node ./src/mcp-server.js --project-root /path/to/target-repo
109
+ ```javascript
110
+ { task: 'Implement auth', prefetch: true }
228
111
  ```
229
112
 
230
- or:
113
+ After 3+ similar tasks: 40-60% fewer round-trips, 15-20% additional savings.
231
114
 
232
- ```bash
233
- DEVCTX_PROJECT_ROOT=/path/to/target-repo node ./src/mcp-server.js
234
- ```
115
+ ### Cache Warming
235
116
 
236
- or (recommended for MCP clients and generated configs):
117
+ Eliminate cold-start latency:
237
118
 
238
- ```bash
239
- DEVCTX_PROJECT_ROOT=/path/to/target-repo node ./src/mcp-server.js
119
+ ```javascript
120
+ { incremental: true, warmCache: true }
240
121
  ```
241
122
 
242
- Legacy configs that still set `MCP_PROJECT_ROOT` remain supported for backward compatibility.
243
-
244
- `smart-context-init` automatically sets `DEVCTX_PROJECT_ROOT` in the generated client configs (`.cursor/mcp.json`, `.codex/config.toml`, `.mcp.json`, `.qwen/settings.json`), so the MCP server always launches from the correct project context, even in monorepos or when installed globally.
245
-
246
- ## What it is good at
247
-
248
- | Level | Languages / Stack | Use cases |
249
- |-------|------------------|-----------|
250
- | **Strong** | JS/TS, React, Next.js, Node.js, Python | Modern web apps, monorepos, backend services, scripts |
251
- | **Strong** | Terraform, Docker, YAML, shell, SQL | Infra/platform repos, config-heavy codebases |
252
- | **Good** | Go, Rust, Java, C#/.NET, Kotlin, PHP, Swift | Services, libraries, Android/iOS, Laravel/Symfony |
253
- | **Partial** | Enterprise Java/C# with heavy frameworks | Generated code, polyglot monorepos needing semantic ranking |
254
- | **Limited** | Ruby, Elixir, Scala | Deep semantic understanding required, general shell needs |
123
+ First query: 250ms 50ms (5x faster).
255
124
 
256
- ## Tool behavior
125
+ ### Git Blame
257
126
 
258
- ### `smart_read`
127
+ Function-level attribution:
259
128
 
260
- Modes:
261
-
262
- - `outline` compact structural summary (~90% token savings)
263
- - `signatures` — exported API surface only
264
- - `range` — specific line range with line numbers (`startLine`, `endLine`)
265
- - `symbol` — extract function/class/method by name; accepts a string or an array for batch extraction
266
- - `full` — file content capped at 12k chars, with truncation marker when needed
267
-
268
- The `symbol` mode supports nested methods (class methods, object methods), interface signatures, and multiline function signatures across all supported languages.
269
-
270
- Cross-file symbol context:
271
-
272
- - Pass `context: true` with `symbol` mode to include callers, tests, and referenced types from the dependency graph
273
- - Callers: files that import the current file and reference the symbol (via graph + ripgrep)
274
- - Tests: test files related to the current file that mention the symbol
275
- - Types: type/interface names referenced in the symbol definition that exist in the index
276
- - Requires `build_index` for graph data; without it, the definition is returned with an empty context and a hint
277
- - Response includes `context: { callers, tests, types }` with counts, `graphCoverage: { imports, tests }` (`full|partial|none`), and `contextHints` if applicable
278
- - `graphCoverage` indicates how reliable cross-file context is: `full` for JS/TS/Python/Go (imports resolved), `partial` for C#/Kotlin/PHP/Swift (imports extracted but namespace-based), `none` for other languages
279
-
280
- Token budget mode:
281
-
282
- - Pass `maxTokens` to let the tool auto-select the most detailed mode that fits the budget
283
- - Cascade order: `full` -> `outline` -> `signatures` -> truncated
284
- - If the requested mode (or default `outline`) exceeds the budget, the tool falls back to a more compact mode automatically
285
- - `range` and `symbol` modes do not cascade but will truncate by tokens if needed
286
- - When the mode changes, the response includes `chosenMode` (the mode actually used) and `budgetApplied: true`
287
-
288
- Responses are cached in memory per session. If the same file+mode is requested again and the file's `mtime` has not changed, the cached result is returned without re-parsing. The response includes `cached: true` when served from cache.
289
-
290
- Every response includes a `confidence` block:
291
-
292
- ```json
293
- { "parser": "ast|heuristic|fallback|raw", "truncated": false, "cached": false }
294
- ```
295
-
296
- Additional metadata: `indexHint` (symbol mode), `chosenMode`/`budgetApplied` (token budget), `graphCoverage` (symbol+context mode).
129
+ ```javascript
130
+ // Who wrote each function?
131
+ { mode: 'symbol', filePath: 'src/server.js' }
297
132
 
298
- **Example response (outline mode):**
133
+ // Find code by author
134
+ { mode: 'author', authorQuery: 'alice@example.com' }
299
135
 
300
- ```json
301
- {
302
- "mode": "outline",
303
- "parser": "ast",
304
- "truncated": false,
305
- "cached": false,
306
- "tokens": 245,
307
- "confidence": { "parser": "ast", "truncated": false, "cached": false },
308
- "content": "import express from 'express';\nexport class AuthMiddleware { ... }\nexport function requireRole(role: string) { ... }"
309
- }
136
+ // Recent changes
137
+ { mode: 'recent', daysBack: 7 }
310
138
  ```
311
139
 
312
- Current support:
313
-
314
- - First-class (AST): JS, JSX, TS, TSX
315
- - Heuristic: Python, Go, Rust, Java, C#, Kotlin, PHP, Swift, shell, Terraform, HCL, Dockerfile, SQL, JSON, TOML, YAML
316
- - Fallback: plain-text structural extraction for unsupported formats
317
-
318
- ### `smart_read_batch`
319
-
320
- Read multiple files in one MCP call. Reduces round-trip latency for common patterns like "read the outline of these 5 files".
140
+ ### Cross-Project Context
321
141
 
322
- Parameters:
142
+ Work across monorepos:
323
143
 
324
- - `files` (required, max 20) — array of items, each with:
325
- - `path` (required) — file path
326
- - `mode` (optional) `outline`, `signatures`, `full`, `range`, `symbol`
327
- - `symbol`, `startLine`, `endLine` (optional) — as in `smart_read`
328
- - `maxTokens` (optional) — per-file token budget with automatic mode cascade
329
- - `maxTokens` (optional) — global token budget; stops reading more files once exceeded (at least 1 file is always read)
330
-
331
- Response:
144
+ ```javascript
145
+ // Search all projects
146
+ { mode: 'search', query: 'AuthService' }
332
147
 
333
- ```json
334
- {
335
- "results": [
336
- { "filePath": "...", "mode": "outline", "parser": "ast", "truncated": false, "content": "..." },
337
- { "filePath": "...", "mode": "signatures", "parser": "heuristic", "truncated": false, "content": "..." }
338
- ],
339
- "metrics": { "totalTokens": 450, "filesRead": 2, "filesSkipped": 0, "totalSavingsPct": 88 }
340
- }
148
+ // Find symbol across projects
149
+ { mode: 'symbol', symbolName: 'validateToken' }
341
150
  ```
342
151
 
343
- ### `smart_search`
152
+ Requires `.devctx-projects.json` config.
344
153
 
345
- - Uses embedded ripgrep via `@vscode/ripgrep`
346
- - Falls back to filesystem walking if rg is unavailable or fails
347
- - Groups matches by file, ranks results to reduce noise
348
- - Optional `intent` parameter adjusts ranking: `implementation`, `debug`, `tests`, `config`, `docs`, `explore`
349
- - When a symbol index exists (via `build_index`), files with matching definitions get +50 ranking bonus, and related files (importers, tests, neighbors) get +25 graph boost
350
- - Index is loaded from `projectRoot`, so subdirectory searches still benefit from the project-level index
351
- - Returns `confidence` block: `{ "level": "high", "indexFreshness": "fresh" }`
154
+ ## Supported Languages
352
155
 
353
- **Example response:**
156
+ **AST parsing**: JavaScript, TypeScript, JSX, TSX
354
157
 
355
- ```json
356
- {
357
- "engine": "rg",
358
- "retrievalConfidence": "high",
359
- "indexFreshness": "fresh",
360
- "confidence": { "level": "high", "indexFreshness": "fresh" },
361
- "sourceBreakdown": { "textMatch": 7, "indexBoost": 2, "graphBoost": 1 },
362
- "results": [
363
- { "file": "src/auth/middleware.js", "matches": 3, "rank": 150, "preview": "export class AuthMiddleware { ..." }
364
- ]
365
- }
366
- ```
158
+ **Heuristic**: Python, Go, Rust, Java, C#, Kotlin, PHP, Swift
367
159
 
368
- ### `smart_context`
160
+ **Structural**: Shell, Terraform, HCL, Dockerfile, SQL, JSON, YAML, TOML
369
161
 
370
- One-call context planner. Instead of the manual cycle of `smart_search` → `smart_read` → `smart_read` → ..., `smart_context` receives a task description and returns curated context in a single response.
162
+ ## Client Support
371
163
 
372
- **Pipeline:**
164
+ - Cursor (`.cursor/mcp.json`)
165
+ - Codex CLI (`.codex/config.toml`)
166
+ - Claude Code (`.mcp.json` + `.claude/settings.json`)
167
+ - Qwen Code (`.qwen/settings.json`)
373
168
 
374
- ```
375
- task input → intent detection → search/diff → graph expansion → smart_read_batch → symbol extraction → response
376
- ```
169
+ ## Commands
377
170
 
378
- **Parameters:**
379
- - `task` (required) — natural language description (e.g., `"debug the auth flow in AuthMiddleware"`)
380
- - `intent` (optional) — override auto-detected intent
381
- - `detail` (optional) — `minimal` | `balanced` (default) | `deep`
382
- - `maxTokens` (optional, default 8000) — token budget
383
- - `entryFile` (optional) — guarantee specific file inclusion
384
- - `diff` (optional) — `true` (vs HEAD) or git ref (`"main"`) to scope to changed files only
385
- - `include` (optional) — `["content","graph","hints","symbolDetail"]` to control response fields
386
-
387
- **Detail modes:**
388
-
389
- | Mode | Behavior | Use when |
390
- |------|----------|----------|
391
- | `minimal` | Index-first: paths, roles, evidence, signatures, symbol previews (no file reads) | Fastest exploration, budget-constrained |
392
- | `balanced` | Batch read with smart compression (outline/signatures) | Default, most tasks |
393
- | `deep` | Full content reads | Deep investigation, debugging |
394
-
395
- **How it works:**
171
+ ```bash
172
+ # Start server
173
+ smart-context-server
396
174
 
397
- 1. **Search or diff**: Extracts queries from task and runs `smart_search`, OR runs `git diff` when `diff` parameter provided
398
- 2. **Graph expansion**: Expands top results via relational graph (imports, importedBy, tests, neighbors)
399
- 3. **Read strategy**: Index-first mode (no file reads) OR batch read mode using `smart_read_batch` with role-based compression
400
- 4. **Symbol extraction**: Detects identifiers in task and extracts focused symbol details
401
- 5. **Deduplication**: In `minimal` mode, omits redundant outline when `symbolDetail` covers same file
402
- 6. **Assembly**: Returns curated context with `reasonIncluded` / `evidence` per item, graph summary, hints, and confidence block
175
+ # Against another repo
176
+ smart-context-server --project-root /path/to/repo
403
177
 
404
- Diff mode is ideal for PR review and debugging recent changes — reads only changed files plus their tests and dependencies.
178
+ # Generate configs
179
+ smart-context-init --target /path/to/project
405
180
 
406
- Example response:
181
+ # View metrics
182
+ smart-context-report
407
183
 
408
- ```json
409
- {
410
- "task": "debug AuthMiddleware",
411
- "intent": "debug",
412
- "indexFreshness": "fresh",
413
- "confidence": { "indexFreshness": "fresh", "graphCoverage": { "imports": "full", "tests": "full" } },
414
- "context": [
415
- { "file": "src/auth/middleware.js", "role": "primary", "readMode": "outline", "reasonIncluded": "Matched task search: AuthMiddleware", "evidence": [{ "type": "searchHit", "query": "AuthMiddleware", "rank": 1 }, { "type": "symbolMatch", "symbols": ["AuthMiddleware"] }], "symbols": ["AuthMiddleware", "requireRole"], "symbolPreviews": [{ "name": "AuthMiddleware", "kind": "class", "signature": "export class AuthMiddleware", "snippet": "export class AuthMiddleware { ..." }], "content": "..." },
416
- { "file": "tests/auth.test.js", "role": "test", "readMode": "signatures", "reasonIncluded": "Test for src/auth/middleware.js", "evidence": [{ "type": "testOf", "via": "src/auth/middleware.js" }], "content": "..." },
417
- { "file": "src/utils/jwt.js", "role": "dependency", "readMode": "signatures", "reasonIncluded": "Imported by src/auth/middleware.js", "evidence": [{ "type": "dependencyOf", "via": "src/auth/middleware.js" }], "content": "..." },
418
- { "file": "src/auth/middleware.js", "role": "symbolDetail", "readMode": "symbol", "reasonIncluded": "Focused symbol detail: AuthMiddleware", "evidence": [{ "type": "symbolDetail", "symbols": ["AuthMiddleware"] }], "content": "..." }
419
- ],
420
- "graph": {
421
- "primaryImports": ["src/utils/jwt.js"],
422
- "tests": ["tests/auth.test.js"],
423
- "dependents": [],
424
- "neighbors": ["src/utils/logger.js"]
425
- },
426
- "graphCoverage": { "imports": "full", "tests": "full" },
427
- "metrics": { "totalTokens": 1200, "filesIncluded": 4, "filesEvaluated": 8, "savingsPct": 82 },
428
- "hints": ["Inspect symbols with smart_read: verifyJwt, createJwt"]
429
- }
184
+ # Verify features
185
+ npm run verify
430
186
  ```
431
187
 
432
- `graphCoverage` indicates how complete the relational context is: `full` for JS/TS/Python/Go (imports resolved to local files), `partial` for C#/Kotlin/PHP/Swift (imports extracted but namespace-based), `none` for other languages. When files from multiple languages are included, the level reflects the weakest coverage.
433
-
434
- File roles: `primary` (search hits or changed files), `test` (related test files), `dependency` (imports), `dependent` (importedBy), `symbolDetail` (extracted symbol bodies). Each item also includes `reasonIncluded` and structured `evidence` so the agent knows why it was selected.
188
+ ## Storage
435
189
 
436
- When using diff mode, the response includes a `diffSummary`:
190
+ Data stored in `.devctx/`:
191
+ - `index.json` - Symbol index
192
+ - `state.sqlite` - Sessions, metrics, patterns
193
+ - `metrics.jsonl` - Legacy fallback
437
194
 
438
- ```json
439
- {
440
- "diffSummary": { "ref": "main", "totalChanged": 5, "included": 3, "skippedDeleted": 1 }
441
- }
195
+ Add to `.gitignore`:
442
196
  ```
443
-
444
- ### `smart_summary`
445
-
446
- Maintain compressed conversation state across sessions. Solves the context-loss problem when resuming work after hours or days.
447
-
448
- **Actions:**
449
-
450
- | Action | Purpose | Returns |
451
- |--------|---------|---------|
452
- | `get` | Retrieve current or specified session | Resume summary (≤500 tokens) + compression metadata |
453
- | `update` | Create or replace session | New session with compressed state |
454
- | `append` | Add to existing session | Merged session state |
455
- | `reset` | Clear session | Confirmation |
456
- | `list_sessions` | Show all available sessions | Array of sessions with metadata |
457
-
458
- **Parameters:**
459
- - `action` (required) — one of the actions above
460
- - `sessionId` (optional) — session identifier; auto-generated from `goal` if omitted
461
- - `update` (required for update/append) — object with:
462
- - `goal`: primary objective
463
- - `status`: current state (`planning` | `in_progress` | `blocked` | `completed`)
464
- - `pinnedContext`: critical context that should survive compression when possible
465
- - `unresolvedQuestions`: open questions that matter for the next turn
466
- - `currentFocus`: current work area in one short phrase
467
- - `whyBlocked`: blocker summary when status is `blocked`
468
- - `completed`: array of completed steps
469
- - `decisions`: array of key decisions with rationale
470
- - `blockers`: array of current blockers
471
- - `nextStep`: immediate next action
472
- - `touchedFiles`: array of modified files
473
- - `maxTokens` (optional, default 500) — hard cap on summary size
474
-
475
- `update` replaces the stored session state for that `sessionId`, so omitted fields are cleared. Use `append` when you want to keep existing state and add progress incrementally.
476
-
477
- **Storage:**
478
- - Sessions persist in `.devctx/sessions/<sessionId>.json`
479
- - Active session tracked in `.devctx/sessions/active.json`
480
- - 30-day retention for inactive sessions
481
- - No expiration for active sessions
482
-
483
- **Resume summary fields:**
484
- - `status` and `nextStep` are preserved with highest priority
485
- - `pinnedContext` and `unresolvedQuestions` preserve critical context and open questions
486
- - `currentFocus` and `whyBlocked` are included when relevant
487
- - `recentCompleted`, `keyDecisions`, and `hotFiles` are derived from the persisted state
488
- - `completedCount`, `decisionsCount`, and `touchedFilesCount` preserve activity scale cheaply
489
- - Empty fields are omitted to save tokens
490
-
491
- **Response metadata:**
492
- - `schemaVersion`: persisted session schema version
493
- - `truncated`: whether the resume summary had to be compressed
494
- - `compressionLevel`: `none` | `trimmed` | `reduced` | `status_only`
495
- - `omitted`: fields dropped from the resume summary to fit the token budget
496
-
497
- **Compression strategy:**
498
- - Keeps the persisted session state intact and compresses only the resume summary
499
- - Prioritizes `nextStep`, `status`, and active blockers over history
500
- - Deduplicates repeated completed steps, decisions, and touched files
501
- - Uses token-aware reduction until the summary fits `maxTokens`
502
-
503
- **Example workflow:**
504
-
505
- ```javascript
506
- // Start of work session
507
- smart_summary({ action: "get" })
508
- // → retrieves last active session or returns "not found"
509
-
510
- // After implementing auth middleware
511
- smart_summary({
512
- action: "append",
513
- update: {
514
- completed: ["auth middleware"],
515
- decisions: ["JWT with 1h expiry, refresh tokens in Redis"],
516
- touchedFiles: ["src/middleware/auth.js"],
517
- nextStep: "add role-based access control"
518
- }
519
- })
520
-
521
- // Monday after weekend - resume work
522
- smart_summary({ action: "get" })
523
- // → full context restored, continue from nextStep
524
-
525
- // List all sessions
526
- smart_summary({ action: "list_sessions" })
527
- // → see all available sessions, pick one to resume
197
+ .devctx/
528
198
  ```
529
199
 
530
- ### `build_index`
531
-
532
- - Builds a lightweight symbol index for the project (functions, classes, methods, types, etc.)
533
- - Supports JS/TS (via TypeScript AST), Python, Go, Rust, Java, C#, Kotlin, PHP, Swift
534
- - Extracts imports/exports and builds a dependency graph with `import` and `testOf` edges
535
- - Test files are linked to source files via import analysis and naming conventions
536
- - Index stored per-project in `.devctx/index.json`, invalidated by file mtime
537
- - Each symbol includes a condensed `signature` (one line, max 200 chars) and a short `snippet` preview so agents can inspect likely definitions without opening files
538
- - Accelerates `smart_search` (symbol + graph ranking) and `smart_read` symbol mode (line hints)
539
- - Pass `incremental=true` to only reindex files with changed mtime — much faster for large repos (10k+ files). Falls back to full rebuild if no prior index exists.
540
- - Incremental response includes `reindexed`, `removed`, `unchanged` counts
541
- - Run once after checkout or when many files changed; not required but recommended for large projects
542
-
543
- ### `smart_shell`
544
-
545
- - Runs only allowlisted diagnostic commands
546
- - Executes from the effective project root
547
- - Blocks shell operators and unsafe commands by design
548
-
549
- ## Evaluations (repo development only)
550
-
551
- The eval harness and corpora are available in the [source repository](https://github.com/Arrayo/devctx-mcp-mvp) but are **not included in the npm package**. Clone the repo to run evaluations.
552
-
553
- ```bash
554
- cd tools/devctx
555
- npm run eval
556
- npm run eval -- --baseline
557
- npm run eval:self
558
- npm run eval:context
559
- npm run eval:both
560
- npm run eval:report
561
- ```
562
-
563
- Commands:
564
- - `eval` — synthetic corpus with index + intent
565
- - `eval -- --baseline` — baseline without index/intent
566
- - `eval:self` — self-eval against the real devctx repo
567
- - `eval:context` — evaluate smart_context alongside search
568
- - `eval:both` — search + context evaluation
569
- - `eval:report` — scorecard with delta vs baseline
570
-
571
- The harness supports `--root=` and `--corpus=` for evaluating against any repo with custom task corpora. Use `--tool=search|context|both` to control which tools are evaluated. When `--tool=context`, pass/fail is determined by `smart_context` precision; when `--tool=both`, both search and context must pass.
200
+ ## Requirements
572
201
 
573
- Metrics include: P@5, P@10, Recall, wrong-file rate, retrieval honesty, follow-up reads, tokens-to-success, latency p50/p95, confidence calibration (accuracy, over-confident rate, under-confident rate), and smart_context metrics when applicable. smart_context reporting now includes precision, explanation coverage (`reasonIncluded` + `evidence`), preview coverage (`symbolPreviews`), and preview symbol recall. Token metrics (`totalTokens`) reflect the full JSON payload, not just content blocks.
202
+ - Node.js 18+ (22+ for SQLite features)
203
+ - Git (for diff and blame features)
574
204
 
575
- ## Notes
205
+ ## Documentation
576
206
 
577
- - `@vscode/ripgrep` provides a bundled `rg` binary, so a system install is not required.
578
- - Metrics are written to `<projectRoot>/.devctx/metrics.jsonl` (override with `DEVCTX_METRICS_FILE` env var).
579
- - Symbol index stored in `<projectRoot>/.devctx/index.json` when `build_index` is used.
580
- - Conversation sessions stored in `<projectRoot>/.devctx/sessions/` when `smart_summary` is used.
581
- - This package is a navigation and diagnostics layer, not a full semantic code intelligence system.
207
+ Full documentation in [GitHub repository](https://github.com/Arrayo/devctx-mcp-mvp):
582
208
 
583
- ## Repository
209
+ - [STREAMING.md](https://github.com/Arrayo/devctx-mcp-mvp/blob/main/STREAMING.md) - Progress notifications
210
+ - [CONTEXT-PREDICTION.md](https://github.com/Arrayo/devctx-mcp-mvp/blob/main/CONTEXT-PREDICTION.md) - File prediction
211
+ - [DIFF-AWARE.md](https://github.com/Arrayo/devctx-mcp-mvp/blob/main/DIFF-AWARE.md) - Change analysis
212
+ - [CACHE-WARMING.md](https://github.com/Arrayo/devctx-mcp-mvp/blob/main/CACHE-WARMING.md) - Cold-start optimization
213
+ - [GIT-BLAME.md](https://github.com/Arrayo/devctx-mcp-mvp/blob/main/GIT-BLAME.md) - Code attribution
214
+ - [CROSS-PROJECT.md](https://github.com/Arrayo/devctx-mcp-mvp/blob/main/CROSS-PROJECT.md) - Multi-project support
584
215
 
585
- Source repository and full project documentation:
216
+ ## Links
586
217
 
587
- - https://github.com/Arrayo/devctx-mcp-mvp
218
+ - [GitHub](https://github.com/Arrayo/devctx-mcp-mvp)
219
+ - [npm](https://www.npmjs.com/package/smart-context-mcp)
220
+ - [Issues](https://github.com/Arrayo/devctx-mcp-mvp/issues)
588
221
 
589
222
  ## Author
590
223
 
591
224
  **Francisco Caballero Portero**
592
- Email: fcp1978@hotmail.com
593
- GitHub: [@Arrayo](https://github.com/Arrayo)
225
+ fcp1978@hotmail.com
226
+ [@Arrayo](https://github.com/Arrayo)
594
227
 
595
228
  ## License
596
229
 
597
- MIT License - see [LICENSE](LICENSE) file for details.
230
+ MIT