smart-context-mcp 1.0.4 → 1.2.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 +196 -586
- package/package.json +11 -7
- package/scripts/init-clients.js +56 -27
- package/scripts/report-metrics.js +5 -0
- package/scripts/report-workflow-metrics.js +255 -0
- package/src/analytics/adoption.js +197 -0
- package/src/cache-warming.js +131 -0
- package/src/context-patterns.js +192 -0
- package/src/cross-project.js +343 -0
- package/src/diff-analysis.js +291 -0
- package/src/git-blame.js +324 -0
- package/src/index.js +54 -5
- package/src/metrics.js +6 -1
- package/src/server.js +199 -13
- package/src/storage/sqlite.js +50 -1
- package/src/streaming.js +152 -0
- package/src/tools/smart-context.js +115 -6
- package/src/tools/smart-metrics.js +7 -0
- package/src/tools/smart-read-batch.js +9 -0
- package/src/tools/smart-read.js +21 -1
- package/src/tools/smart-shell.js +33 -9
- package/src/tools/smart-turn.js +1 -0
- package/src/workflow-tracker-stub.js +53 -0
- package/src/workflow-tracker.js +410 -0
package/README.md
CHANGED
|
@@ -1,710 +1,320 @@
|
|
|
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
|
[](https://www.npmjs.com/package/smart-context-mcp)
|
|
4
6
|
[](https://opensource.org/licenses/MIT)
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Instead of reading entire files and repeating context, this MCP provides 8 focused 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 the original 7 core tools
|
|
19
|
-
- Compression ratios: 3x to 46x depending on tool
|
|
20
|
-
|
|
21
|
-
## Quick Start (2 commands)
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
npm install smart-context-mcp
|
|
25
|
-
npx smart-context-init --target .
|
|
26
|
-
```
|
|
27
|
-
|
|
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
|
|
33
|
-
|
|
34
|
-
Eight focused tools that work automatically:
|
|
35
|
-
|
|
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_turn`: one-call turn orchestration for start/end context recovery and checkpointing
|
|
42
|
-
- `smart_metrics`: inspect saved token metrics and recent usage through MCP
|
|
43
|
-
- `smart_shell`: safe diagnostic shell execution with restricted commands (18x compression)
|
|
44
|
-
- `build_index`: lightweight symbol index for faster lookups and smarter ranking
|
|
45
|
-
|
|
46
|
-
**Strongest in:** Modern web/backend codebases (JS/TS, React, Next.js, Node.js, Python, Go, Rust), infra repos (Terraform, Docker, YAML)
|
|
47
|
-
|
|
48
|
-
## Example: Before vs After
|
|
49
|
-
|
|
50
|
-
### Without this MCP
|
|
51
|
-
```
|
|
52
|
-
Agent: Let me read auth.js...
|
|
53
|
-
[Reads 4,000 tokens of full file]
|
|
54
|
-
|
|
55
|
-
Agent: Let me search for "jwt validation"...
|
|
56
|
-
[Returns 10,000 tokens of grep results]
|
|
57
|
-
|
|
58
|
-
Agent: [Next turn] What were we doing?
|
|
59
|
-
[Repeats 5,000 tokens of context]
|
|
60
|
-
|
|
61
|
-
Total: ~19,000 tokens
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
### With this MCP
|
|
65
|
-
```
|
|
66
|
-
Agent: Let me use smart_read on auth.js...
|
|
67
|
-
[Returns 500 tokens of signatures]
|
|
68
|
-
|
|
69
|
-
Agent: Let me use smart_search for "jwt validation"...
|
|
70
|
-
[Returns 400 tokens of ranked snippets]
|
|
71
|
-
|
|
72
|
-
Agent: [Next turn] Let me get the context...
|
|
73
|
-
[smart_summary returns 100 tokens]
|
|
74
|
-
|
|
75
|
-
Total: ~1,000 tokens (95% reduction)
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
## Quick start
|
|
79
|
-
|
|
80
|
-
```bash
|
|
81
|
-
npm install smart-context-mcp
|
|
82
|
-
npx smart-context-init --target .
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
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.
|
|
86
|
-
If the target is a git repository, `smart-context-init` also installs an idempotent `pre-commit` hook that blocks commits when `.devctx/state.sqlite` is staged, tracked, or not properly ignored.
|
|
87
|
-
For Claude Code, `smart-context-init` also generates `.claude/settings.json` with native hooks so devctx context recovery and turn-end enforcement run automatically.
|
|
88
|
-
|
|
89
|
-
## Binaries
|
|
90
|
-
|
|
91
|
-
The package exposes five binaries:
|
|
92
|
-
|
|
93
|
-
- `smart-context-headless`
|
|
94
|
-
- `smart-context-server`
|
|
95
|
-
- `smart-context-init`
|
|
96
|
-
- `smart-context-report`
|
|
97
|
-
- `smart-context-protect`
|
|
98
|
-
|
|
99
|
-
Start the MCP server against the current project:
|
|
8
|
+
## Installation
|
|
100
9
|
|
|
10
|
+
### Cursor
|
|
101
11
|
```bash
|
|
102
|
-
smart-context-
|
|
12
|
+
npm install -g smart-context-mcp
|
|
13
|
+
npx smart-context-init --target . --clients cursor
|
|
103
14
|
```
|
|
15
|
+
Restart Cursor. Done.
|
|
104
16
|
|
|
105
|
-
|
|
106
|
-
|
|
17
|
+
### Codex CLI
|
|
107
18
|
```bash
|
|
108
|
-
smart-context-
|
|
19
|
+
npm install -g smart-context-mcp
|
|
20
|
+
npx smart-context-init --target . --clients codex
|
|
109
21
|
```
|
|
22
|
+
Restart Codex. Done.
|
|
110
23
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
Generate MCP config files for a target project:
|
|
114
|
-
|
|
24
|
+
### Claude Desktop
|
|
115
25
|
```bash
|
|
116
|
-
smart-context-
|
|
26
|
+
npm install -g smart-context-mcp
|
|
27
|
+
npx smart-context-init --target . --clients claude
|
|
117
28
|
```
|
|
29
|
+
Restart Claude Desktop. Done.
|
|
118
30
|
|
|
119
|
-
|
|
120
|
-
|
|
31
|
+
### Qwen Code
|
|
121
32
|
```bash
|
|
122
|
-
smart-context-
|
|
33
|
+
npm install -g smart-context-mcp
|
|
34
|
+
npx smart-context-init --target . --clients qwen
|
|
123
35
|
```
|
|
36
|
+
Restart Qwen Code. Done.
|
|
124
37
|
|
|
125
|
-
|
|
126
|
-
|
|
38
|
+
### All Clients
|
|
127
39
|
```bash
|
|
128
|
-
smart-context-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
## Metrics
|
|
132
|
-
|
|
133
|
-
Each tool call persists token metrics to the target repo by default in:
|
|
134
|
-
|
|
135
|
-
```bash
|
|
136
|
-
.devctx/state.sqlite
|
|
40
|
+
npm install -g smart-context-mcp
|
|
41
|
+
npx smart-context-init --target .
|
|
137
42
|
```
|
|
43
|
+
Restart your AI client. Done.
|
|
138
44
|
|
|
139
|
-
|
|
45
|
+
## How it Works in Practice
|
|
140
46
|
|
|
141
|
-
|
|
47
|
+
**The reality:** This MCP does not intercept prompts automatically. Here's the actual flow:
|
|
142
48
|
|
|
143
|
-
|
|
49
|
+
1. **You:** "Fix the login bug"
|
|
50
|
+
2. **Agent reads rules:** Sees debugging workflow
|
|
51
|
+
3. **Agent decides:** Uses `smart_search(intent=debug)`
|
|
52
|
+
4. **MCP returns:** Ranked results (errors prioritized)
|
|
53
|
+
5. **Agent continues:** Calls `smart_read(symbol)` for function
|
|
54
|
+
6. **Agent fixes:** Makes changes
|
|
55
|
+
7. **Agent verifies:** Calls `smart_shell('npm test')`
|
|
56
|
+
8. **Agent checkpoints:** Calls `smart_turn(end)`
|
|
144
57
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
58
|
+
**Key points:**
|
|
59
|
+
- ✅ Agent **chooses** to use devctx tools (not forced)
|
|
60
|
+
- ✅ Rules **guide** the agent (not enforce)
|
|
61
|
+
- ✅ Agent can use built-in tools when appropriate
|
|
62
|
+
- ✅ Token savings: 85-90% on complex tasks
|
|
148
63
|
|
|
149
|
-
|
|
64
|
+
Check actual usage:
|
|
65
|
+
- `npm run report:metrics` - Tool-level savings
|
|
66
|
+
- `npm run report:workflows` - Workflow-level savings (requires `DEVCTX_WORKFLOW_TRACKING=true`)
|
|
150
67
|
|
|
151
|
-
|
|
152
|
-
smart-context-report --json
|
|
153
|
-
smart-context-report --file ./.devctx/metrics.jsonl
|
|
154
|
-
```
|
|
68
|
+
## What it does
|
|
155
69
|
|
|
156
|
-
|
|
70
|
+
Provides **two key components**:
|
|
157
71
|
|
|
158
|
-
|
|
159
|
-
devctx metrics report
|
|
72
|
+
### 1. Specialized Tools (12 tools)
|
|
160
73
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
74
|
+
| Tool | Purpose | Savings |
|
|
75
|
+
|------|---------|---------|
|
|
76
|
+
| `smart_read` | Read files in outline/signatures mode | 90% |
|
|
77
|
+
| `smart_read_batch` | Read multiple files in one call | 90% |
|
|
78
|
+
| `smart_search` | Intent-aware code search with ranking | 95% |
|
|
79
|
+
| `smart_context` | One-call context builder | 85% |
|
|
80
|
+
| `smart_summary` | Task checkpoint management | 98% |
|
|
81
|
+
| `smart_turn` | Task recovery orchestration | - |
|
|
82
|
+
| `smart_metrics` | Token usage inspection | - |
|
|
83
|
+
| `smart_shell` | Safe command execution | 94% |
|
|
84
|
+
| `build_index` | Symbol index builder | - |
|
|
85
|
+
| `warm_cache` | File preloading (5x faster cold start) | - |
|
|
86
|
+
| `git_blame` | Function-level code attribution | - |
|
|
87
|
+
| `cross_project` | Multi-project context | - |
|
|
167
88
|
|
|
168
|
-
|
|
169
|
-
smart_context count=42 raw=96,200 final=24,180 saved=72,020 (74.86%)
|
|
170
|
-
smart_read count=71 raw=52,810 final=9,940 saved=42,870 (81.18%)
|
|
171
|
-
smart_search count=35 raw=33,330 final=7,800 saved=25,530 (76.59%)
|
|
172
|
-
```
|
|
89
|
+
### 2. Agent Rules (Task-Specific Guidance)
|
|
173
90
|
|
|
174
|
-
|
|
91
|
+
Installation generates rules that teach agents optimal workflows:
|
|
175
92
|
|
|
176
|
-
|
|
93
|
+
**Debugging:** `smart_search(intent=debug)` → `smart_read(symbol)` → fix (90% savings)
|
|
94
|
+
**Code Review:** `smart_context(diff=true)` → `smart_read(signatures)` → review (87% savings)
|
|
95
|
+
**Refactoring:** `smart_context(entryFile)` → `smart_read(signatures)` → refactor (89% savings)
|
|
96
|
+
**Testing:** `smart_search(intent=tests)` → `smart_read(symbol)` → write test (90% savings)
|
|
97
|
+
**Architecture:** `smart_context(detail=minimal)` → `smart_read(signatures)` → analyze (90% savings)
|
|
177
98
|
|
|
178
|
-
|
|
99
|
+
**Key insight:** The value isn't just in the tools—it's in teaching agents **when** and **how** to use them.
|
|
179
100
|
|
|
180
|
-
|
|
101
|
+
## Real Metrics
|
|
181
102
|
|
|
182
|
-
|
|
103
|
+
Production usage: **14.5M tokens → 1.6M tokens** (89.87% reduction)
|
|
183
104
|
|
|
184
|
-
|
|
105
|
+
## Core Tools
|
|
185
106
|
|
|
186
|
-
|
|
187
|
-
cd /path/to/your-project
|
|
188
|
-
codex
|
|
189
|
-
```
|
|
107
|
+
### smart_read
|
|
190
108
|
|
|
191
|
-
|
|
109
|
+
Read files without full content:
|
|
192
110
|
|
|
193
|
-
|
|
111
|
+
```javascript
|
|
112
|
+
// Outline mode: structure only (~400 tokens vs 4000)
|
|
113
|
+
{ filePath: 'src/server.js', mode: 'outline' }
|
|
194
114
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
claude
|
|
115
|
+
// Extract specific function
|
|
116
|
+
{ filePath: 'src/auth.js', mode: 'symbol', symbol: 'validateToken' }
|
|
198
117
|
```
|
|
199
118
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
### Codex/Qwen headless fallback
|
|
119
|
+
**Modes**: `outline`, `signatures`, `symbol`, `range`, `full`
|
|
203
120
|
|
|
204
|
-
|
|
121
|
+
### smart_search
|
|
205
122
|
|
|
206
|
-
|
|
123
|
+
Intent-aware search with ranking:
|
|
207
124
|
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
|
|
125
|
+
```javascript
|
|
126
|
+
{ query: 'authentication', intent: 'debug' } // Prioritizes errors, logs
|
|
127
|
+
{ query: 'UserModel', intent: 'implementation' } // Prioritizes source
|
|
211
128
|
```
|
|
212
129
|
|
|
213
|
-
|
|
130
|
+
**Intents**: `implementation`, `debug`, `tests`, `config`, `docs`, `explore`
|
|
214
131
|
|
|
215
|
-
###
|
|
132
|
+
### smart_context
|
|
216
133
|
|
|
217
|
-
|
|
134
|
+
Get everything for a task in one call:
|
|
218
135
|
|
|
219
|
-
|
|
136
|
+
```javascript
|
|
137
|
+
{
|
|
138
|
+
task: 'Fix authentication bug',
|
|
139
|
+
detail: 'balanced', // minimal | balanced | deep
|
|
140
|
+
maxTokens: 8000
|
|
141
|
+
}
|
|
142
|
+
```
|
|
220
143
|
|
|
221
|
-
|
|
144
|
+
Returns: relevant files + compressed content + symbol details + graph relationships
|
|
222
145
|
|
|
223
|
-
###
|
|
146
|
+
### smart_summary
|
|
224
147
|
|
|
225
|
-
|
|
148
|
+
Maintain task checkpoint:
|
|
226
149
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
| `implementation` | Source files, changed files | Read outline/signatures → focus on changed symbols |
|
|
231
|
-
| `tests` | Test files, spec files | Find tests → read symbol of function under test |
|
|
232
|
-
| `config` | Config files, env vars, YAML/JSON | Find settings → read full config files |
|
|
233
|
-
| `explore` | Entry points, main modules | Directory structure → outlines of key modules |
|
|
150
|
+
```javascript
|
|
151
|
+
// Save checkpoint
|
|
152
|
+
{ action: 'update', update: { goal: 'Implement OAuth', status: 'in_progress', nextStep: '...' }}
|
|
234
153
|
|
|
235
|
-
|
|
154
|
+
// Resume task
|
|
155
|
+
{ action: 'get' }
|
|
156
|
+
```
|
|
236
157
|
|
|
237
|
-
|
|
238
|
-
- **Codex**: `AGENTS.md` (devctx section with sentinel markers)
|
|
239
|
-
- **Claude Code**: `CLAUDE.md` (devctx section with sentinel markers) and `.claude/settings.json` (native hooks)
|
|
158
|
+
Stores compressed task state (~100 tokens: goal, status, decisions, blockers), not full conversation.
|
|
240
159
|
|
|
241
|
-
|
|
160
|
+
## New Features
|
|
242
161
|
|
|
243
|
-
|
|
162
|
+
### Diff-Aware Context
|
|
244
163
|
|
|
245
|
-
|
|
164
|
+
Analyze git changes intelligently:
|
|
246
165
|
|
|
247
|
-
```
|
|
248
|
-
|
|
166
|
+
```javascript
|
|
167
|
+
{ task: 'Review changes', diff: 'main' }
|
|
249
168
|
```
|
|
250
169
|
|
|
251
|
-
|
|
170
|
+
Returns changed files prioritized by impact + related files (importers, tests).
|
|
252
171
|
|
|
253
|
-
|
|
254
|
-
DEVCTX_PROJECT_ROOT=/path/to/target-repo node ./src/mcp-server.js
|
|
255
|
-
```
|
|
172
|
+
### Context Prediction
|
|
256
173
|
|
|
257
|
-
|
|
174
|
+
Learn from usage and predict needed files:
|
|
258
175
|
|
|
259
|
-
```
|
|
260
|
-
|
|
176
|
+
```javascript
|
|
177
|
+
{ task: 'Implement auth', prefetch: true }
|
|
261
178
|
```
|
|
262
179
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
`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.
|
|
266
|
-
|
|
267
|
-
## What it is good at
|
|
268
|
-
|
|
269
|
-
| Level | Languages / Stack | Use cases |
|
|
270
|
-
|-------|------------------|-----------|
|
|
271
|
-
| **Strong** | JS/TS, React, Next.js, Node.js, Python | Modern web apps, monorepos, backend services, scripts |
|
|
272
|
-
| **Strong** | Terraform, Docker, YAML, shell, SQL | Infra/platform repos, config-heavy codebases |
|
|
273
|
-
| **Good** | Go, Rust, Java, C#/.NET, Kotlin, PHP, Swift | Services, libraries, Android/iOS, Laravel/Symfony |
|
|
274
|
-
| **Partial** | Enterprise Java/C# with heavy frameworks | Generated code, polyglot monorepos needing semantic ranking |
|
|
275
|
-
| **Limited** | Ruby, Elixir, Scala | Deep semantic understanding required, general shell needs |
|
|
276
|
-
|
|
277
|
-
## Tool behavior
|
|
278
|
-
|
|
279
|
-
### `smart_read`
|
|
180
|
+
After 3+ similar tasks: 40-60% fewer round-trips, 15-20% additional savings.
|
|
280
181
|
|
|
281
|
-
|
|
182
|
+
### Cache Warming
|
|
282
183
|
|
|
283
|
-
-
|
|
284
|
-
- `signatures` — exported API surface only
|
|
285
|
-
- `range` — specific line range with line numbers (`startLine`, `endLine`)
|
|
286
|
-
- `symbol` — extract function/class/method by name; accepts a string or an array for batch extraction
|
|
287
|
-
- `full` — file content capped at 12k chars, with truncation marker when needed
|
|
184
|
+
Eliminate cold-start latency:
|
|
288
185
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
Cross-file symbol context:
|
|
292
|
-
|
|
293
|
-
- Pass `context: true` with `symbol` mode to include callers, tests, and referenced types from the dependency graph
|
|
294
|
-
- Callers: files that import the current file and reference the symbol (via graph + ripgrep)
|
|
295
|
-
- Tests: test files related to the current file that mention the symbol
|
|
296
|
-
- Types: type/interface names referenced in the symbol definition that exist in the index
|
|
297
|
-
- Requires `build_index` for graph data; without it, the definition is returned with an empty context and a hint
|
|
298
|
-
- Response includes `context: { callers, tests, types }` with counts, `graphCoverage: { imports, tests }` (`full|partial|none`), and `contextHints` if applicable
|
|
299
|
-
- `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
|
|
300
|
-
|
|
301
|
-
Token budget mode:
|
|
302
|
-
|
|
303
|
-
- Pass `maxTokens` to let the tool auto-select the most detailed mode that fits the budget
|
|
304
|
-
- Cascade order: `full` -> `outline` -> `signatures` -> truncated
|
|
305
|
-
- If the requested mode (or default `outline`) exceeds the budget, the tool falls back to a more compact mode automatically
|
|
306
|
-
- `range` and `symbol` modes do not cascade but will truncate by tokens if needed
|
|
307
|
-
- When the mode changes, the response includes `chosenMode` (the mode actually used) and `budgetApplied: true`
|
|
308
|
-
|
|
309
|
-
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.
|
|
310
|
-
|
|
311
|
-
Every response includes a `confidence` block:
|
|
312
|
-
|
|
313
|
-
```json
|
|
314
|
-
{ "parser": "ast|heuristic|fallback|raw", "truncated": false, "cached": false }
|
|
315
|
-
```
|
|
316
|
-
|
|
317
|
-
Additional metadata: `indexHint` (symbol mode), `chosenMode`/`budgetApplied` (token budget), `graphCoverage` (symbol+context mode).
|
|
318
|
-
|
|
319
|
-
**Example response (outline mode):**
|
|
320
|
-
|
|
321
|
-
```json
|
|
322
|
-
{
|
|
323
|
-
"mode": "outline",
|
|
324
|
-
"parser": "ast",
|
|
325
|
-
"truncated": false,
|
|
326
|
-
"cached": false,
|
|
327
|
-
"tokens": 245,
|
|
328
|
-
"confidence": { "parser": "ast", "truncated": false, "cached": false },
|
|
329
|
-
"content": "import express from 'express';\nexport class AuthMiddleware { ... }\nexport function requireRole(role: string) { ... }"
|
|
330
|
-
}
|
|
186
|
+
```javascript
|
|
187
|
+
{ incremental: true, warmCache: true }
|
|
331
188
|
```
|
|
332
189
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
- First-class (AST): JS, JSX, TS, TSX
|
|
336
|
-
- Heuristic: Python, Go, Rust, Java, C#, Kotlin, PHP, Swift, shell, Terraform, HCL, Dockerfile, SQL, JSON, TOML, YAML
|
|
337
|
-
- Fallback: plain-text structural extraction for unsupported formats
|
|
338
|
-
|
|
339
|
-
### `smart_read_batch`
|
|
340
|
-
|
|
341
|
-
Read multiple files in one MCP call. Reduces round-trip latency for common patterns like "read the outline of these 5 files".
|
|
190
|
+
First query: 250ms → 50ms (5x faster).
|
|
342
191
|
|
|
343
|
-
|
|
192
|
+
### Git Blame
|
|
344
193
|
|
|
345
|
-
-
|
|
346
|
-
- `path` (required) — file path
|
|
347
|
-
- `mode` (optional) — `outline`, `signatures`, `full`, `range`, `symbol`
|
|
348
|
-
- `symbol`, `startLine`, `endLine` (optional) — as in `smart_read`
|
|
349
|
-
- `maxTokens` (optional) — per-file token budget with automatic mode cascade
|
|
350
|
-
- `maxTokens` (optional) — global token budget; stops reading more files once exceeded (at least 1 file is always read)
|
|
194
|
+
Function-level attribution:
|
|
351
195
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
{
|
|
356
|
-
"results": [
|
|
357
|
-
{ "filePath": "...", "mode": "outline", "parser": "ast", "truncated": false, "content": "..." },
|
|
358
|
-
{ "filePath": "...", "mode": "signatures", "parser": "heuristic", "truncated": false, "content": "..." }
|
|
359
|
-
],
|
|
360
|
-
"metrics": { "totalTokens": 450, "filesRead": 2, "filesSkipped": 0, "totalSavingsPct": 88 }
|
|
361
|
-
}
|
|
362
|
-
```
|
|
363
|
-
|
|
364
|
-
### `smart_search`
|
|
365
|
-
|
|
366
|
-
- Uses embedded ripgrep via `@vscode/ripgrep`
|
|
367
|
-
- Falls back to filesystem walking if rg is unavailable or fails
|
|
368
|
-
- Groups matches by file, ranks results to reduce noise
|
|
369
|
-
- Optional `intent` parameter adjusts ranking: `implementation`, `debug`, `tests`, `config`, `docs`, `explore`
|
|
370
|
-
- 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
|
|
371
|
-
- Index is loaded from `projectRoot`, so subdirectory searches still benefit from the project-level index
|
|
372
|
-
- Returns `confidence` block: `{ "level": "high", "indexFreshness": "fresh" }`
|
|
196
|
+
```javascript
|
|
197
|
+
// Who wrote each function?
|
|
198
|
+
{ mode: 'symbol', filePath: 'src/server.js' }
|
|
373
199
|
|
|
374
|
-
|
|
200
|
+
// Find code by author
|
|
201
|
+
{ mode: 'author', authorQuery: 'alice@example.com' }
|
|
375
202
|
|
|
376
|
-
|
|
377
|
-
{
|
|
378
|
-
"engine": "rg",
|
|
379
|
-
"retrievalConfidence": "high",
|
|
380
|
-
"indexFreshness": "fresh",
|
|
381
|
-
"confidence": { "level": "high", "indexFreshness": "fresh" },
|
|
382
|
-
"sourceBreakdown": { "textMatch": 7, "indexBoost": 2, "graphBoost": 1 },
|
|
383
|
-
"results": [
|
|
384
|
-
{ "file": "src/auth/middleware.js", "matches": 3, "rank": 150, "preview": "export class AuthMiddleware { ..." }
|
|
385
|
-
]
|
|
386
|
-
}
|
|
203
|
+
// Recent changes
|
|
204
|
+
{ mode: 'recent', daysBack: 7 }
|
|
387
205
|
```
|
|
388
206
|
|
|
389
|
-
###
|
|
207
|
+
### Cross-Project Context
|
|
390
208
|
|
|
391
|
-
|
|
209
|
+
Work across monorepos:
|
|
392
210
|
|
|
393
|
-
|
|
211
|
+
```javascript
|
|
212
|
+
// Search all projects
|
|
213
|
+
{ mode: 'search', query: 'AuthService' }
|
|
394
214
|
|
|
395
|
-
|
|
396
|
-
|
|
215
|
+
// Find symbol across projects
|
|
216
|
+
{ mode: 'symbol', symbolName: 'validateToken' }
|
|
397
217
|
```
|
|
398
218
|
|
|
399
|
-
|
|
400
|
-
- `task` (required) — natural language description (e.g., `"debug the auth flow in AuthMiddleware"`)
|
|
401
|
-
- `intent` (optional) — override auto-detected intent
|
|
402
|
-
- `detail` (optional) — `minimal` | `balanced` (default) | `deep`
|
|
403
|
-
- `maxTokens` (optional, default 8000) — token budget
|
|
404
|
-
- `entryFile` (optional) — guarantee specific file inclusion
|
|
405
|
-
- `diff` (optional) — `true` (vs HEAD) or git ref (`"main"`) to scope to changed files only
|
|
406
|
-
- `include` (optional) — `["content","graph","hints","symbolDetail"]` to control response fields
|
|
219
|
+
Requires `.devctx-projects.json` config.
|
|
407
220
|
|
|
408
|
-
|
|
221
|
+
## Supported Languages
|
|
409
222
|
|
|
410
|
-
|
|
411
|
-
|------|----------|----------|
|
|
412
|
-
| `minimal` | Index-first: paths, roles, evidence, signatures, symbol previews (no file reads) | Fastest exploration, budget-constrained |
|
|
413
|
-
| `balanced` | Batch read with smart compression (outline/signatures) | Default, most tasks |
|
|
414
|
-
| `deep` | Full content reads | Deep investigation, debugging |
|
|
223
|
+
**AST parsing**: JavaScript, TypeScript, JSX, TSX
|
|
415
224
|
|
|
416
|
-
**
|
|
225
|
+
**Heuristic**: Python, Go, Rust, Java, C#, Kotlin, PHP, Swift
|
|
417
226
|
|
|
418
|
-
|
|
419
|
-
2. **Graph expansion**: Expands top results via relational graph (imports, importedBy, tests, neighbors)
|
|
420
|
-
3. **Read strategy**: Index-first mode (no file reads) OR batch read mode using `smart_read_batch` with role-based compression
|
|
421
|
-
4. **Symbol extraction**: Detects identifiers in task and extracts focused symbol details
|
|
422
|
-
5. **Deduplication**: In `minimal` mode, omits redundant outline when `symbolDetail` covers same file
|
|
423
|
-
6. **Assembly**: Returns curated context with `reasonIncluded` / `evidence` per item, graph summary, hints, and confidence block
|
|
227
|
+
**Structural**: Shell, Terraform, HCL, Dockerfile, SQL, JSON, YAML, TOML
|
|
424
228
|
|
|
425
|
-
|
|
229
|
+
## Client Support
|
|
426
230
|
|
|
427
|
-
|
|
231
|
+
- Cursor (`.cursor/mcp.json`)
|
|
232
|
+
- Codex CLI (`.codex/config.toml`)
|
|
233
|
+
- Claude Code (`.mcp.json` + `.claude/settings.json`)
|
|
234
|
+
- Qwen Code (`.qwen/settings.json`)
|
|
428
235
|
|
|
429
|
-
|
|
430
|
-
{
|
|
431
|
-
"task": "debug AuthMiddleware",
|
|
432
|
-
"intent": "debug",
|
|
433
|
-
"indexFreshness": "fresh",
|
|
434
|
-
"confidence": { "indexFreshness": "fresh", "graphCoverage": { "imports": "full", "tests": "full" } },
|
|
435
|
-
"context": [
|
|
436
|
-
{ "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": "..." },
|
|
437
|
-
{ "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": "..." },
|
|
438
|
-
{ "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": "..." },
|
|
439
|
-
{ "file": "src/auth/middleware.js", "role": "symbolDetail", "readMode": "symbol", "reasonIncluded": "Focused symbol detail: AuthMiddleware", "evidence": [{ "type": "symbolDetail", "symbols": ["AuthMiddleware"] }], "content": "..." }
|
|
440
|
-
],
|
|
441
|
-
"graph": {
|
|
442
|
-
"primaryImports": ["src/utils/jwt.js"],
|
|
443
|
-
"tests": ["tests/auth.test.js"],
|
|
444
|
-
"dependents": [],
|
|
445
|
-
"neighbors": ["src/utils/logger.js"]
|
|
446
|
-
},
|
|
447
|
-
"graphCoverage": { "imports": "full", "tests": "full" },
|
|
448
|
-
"metrics": { "totalTokens": 1200, "filesIncluded": 4, "filesEvaluated": 8, "savingsPct": 82 },
|
|
449
|
-
"hints": ["Inspect symbols with smart_read: verifyJwt, createJwt"]
|
|
450
|
-
}
|
|
451
|
-
```
|
|
236
|
+
## Commands
|
|
452
237
|
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
238
|
+
```bash
|
|
239
|
+
# Start server
|
|
240
|
+
smart-context-server
|
|
456
241
|
|
|
457
|
-
|
|
242
|
+
# Against another repo
|
|
243
|
+
smart-context-server --project-root /path/to/repo
|
|
458
244
|
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
"diffSummary": { "ref": "main", "totalChanged": 5, "included": 3, "skippedDeleted": 1 }
|
|
462
|
-
}
|
|
463
|
-
```
|
|
245
|
+
# Generate configs
|
|
246
|
+
smart-context-init --target /path/to/project
|
|
464
247
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
Maintain compressed conversation state across sessions. Solves the context-loss problem when resuming work after hours or days.
|
|
468
|
-
|
|
469
|
-
**Actions:**
|
|
470
|
-
|
|
471
|
-
| Action | Purpose | Returns |
|
|
472
|
-
|--------|---------|---------|
|
|
473
|
-
| `get` | Retrieve current, explicit, or auto-resolved session | Resume summary (≤500 tokens) + compression metadata |
|
|
474
|
-
| `update` | Create or replace session | New session with compressed state |
|
|
475
|
-
| `append` | Add to existing session | Merged session state |
|
|
476
|
-
| `auto_append` | Add only when something meaningful changed | Merged session state or skipped no-op result |
|
|
477
|
-
| `checkpoint` | Event-driven orchestration for persistence decisions | Persisted update or skipped event with decision metadata |
|
|
478
|
-
| `reset` | Clear session | Confirmation |
|
|
479
|
-
| `list_sessions` | Show all available sessions | Array of sessions with metadata |
|
|
480
|
-
| `compact` | Apply retention/compaction to SQLite state | Counts for pruned sessions, events, and metrics |
|
|
481
|
-
| `cleanup_legacy` | Inspect or remove imported JSON/JSONL artifacts | Dry-run or deletion report |
|
|
482
|
-
|
|
483
|
-
**Parameters:**
|
|
484
|
-
- `action` (required) — one of the actions above
|
|
485
|
-
- `sessionId` (optional) — session identifier; auto-generated from `goal` if omitted. Pass `"auto"` to accept the recommended recent session when multiple candidates exist.
|
|
486
|
-
- `update` (required for update/append/auto_append/checkpoint) — object with:
|
|
487
|
-
- `goal`: primary objective
|
|
488
|
-
- `status`: current state (`planning` | `in_progress` | `blocked` | `completed`)
|
|
489
|
-
- `pinnedContext`: critical context that should survive compression when possible
|
|
490
|
-
- `unresolvedQuestions`: open questions that matter for the next turn
|
|
491
|
-
- `currentFocus`: current work area in one short phrase
|
|
492
|
-
- `whyBlocked`: blocker summary when status is `blocked`
|
|
493
|
-
- `completed`: array of completed steps
|
|
494
|
-
- `decisions`: array of key decisions with rationale
|
|
495
|
-
- `blockers`: array of current blockers
|
|
496
|
-
- `nextStep`: immediate next action
|
|
497
|
-
- `touchedFiles`: array of modified files
|
|
498
|
-
- `maxTokens` (optional, default 500) — hard cap on summary size
|
|
499
|
-
- `event` (optional for `checkpoint`) — one of `manual`, `milestone`, `decision`, `blocker`, `status_change`, `file_change`, `task_switch`, `task_complete`, `session_end`, `read_only`, `heartbeat`
|
|
500
|
-
- `force` (optional, default false) — override a suppressed checkpoint event
|
|
501
|
-
- `retentionDays` (optional, default 30) — used by `compact`
|
|
502
|
-
- `keepLatestEventsPerSession` (optional, default 20) — used by `compact`
|
|
503
|
-
- `keepLatestMetrics` (optional, default 1000) — used by `compact`
|
|
504
|
-
- `vacuum` (optional, default false) — run SQLite `VACUUM` after deletions during `compact`
|
|
505
|
-
- `apply` (optional, default false) — required to actually delete files during `cleanup_legacy`
|
|
506
|
-
|
|
507
|
-
`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. Use `auto_append` when the caller may fire checkpoint saves often and you want the tool to skip no-op updates automatically. Use `checkpoint` when the caller has a meaningful event and wants the tool to decide whether that event deserves persistence.
|
|
508
|
-
|
|
509
|
-
**Storage:**
|
|
510
|
-
- Session state, session events, summary cache, and metrics persist in `.devctx/state.sqlite`
|
|
511
|
-
- Legacy `.devctx/sessions/*.json`, `.devctx/sessions/active.json`, and `.devctx/metrics.jsonl` are imported idempotently when present
|
|
512
|
-
- `compact` enforces retention without deleting the active session
|
|
513
|
-
- `cleanup_legacy` is dry-run by default and only deletes imported legacy artifacts when `apply: true`
|
|
514
|
-
|
|
515
|
-
**Auto-resume behavior:**
|
|
516
|
-
- `get` returns the active session immediately when `active.json` exists
|
|
517
|
-
- If there is no active session, `get` auto-resumes the best saved session when there is a single clear candidate
|
|
518
|
-
- If multiple recent sessions are plausible, `get` returns ordered `candidates` plus `recommendedSessionId`
|
|
519
|
-
- Passing `sessionId: "auto"` accepts that recommendation and restores it as the active session
|
|
520
|
-
|
|
521
|
-
**Resume summary fields:**
|
|
522
|
-
- `status` and `nextStep` are preserved with highest priority
|
|
523
|
-
- `pinnedContext` and `unresolvedQuestions` preserve critical context and open questions
|
|
524
|
-
- `currentFocus` and `whyBlocked` are included when relevant
|
|
525
|
-
- `recentCompleted`, `keyDecisions`, and `hotFiles` are derived from the persisted state
|
|
526
|
-
- `completedCount`, `decisionsCount`, and `touchedFilesCount` preserve activity scale cheaply
|
|
527
|
-
- Empty fields are omitted to save tokens
|
|
528
|
-
|
|
529
|
-
**Response metadata:**
|
|
530
|
-
- `schemaVersion`: persisted session schema version
|
|
531
|
-
- `truncated`: whether the resume summary had to be compressed
|
|
532
|
-
- `compressionLevel`: `none` | `trimmed` | `reduced` | `status_only`
|
|
533
|
-
- `omitted`: fields dropped from the resume summary to fit the token budget
|
|
534
|
-
- `repoSafety`: git hygiene signal for `.devctx/state.sqlite` (`isIgnored`, `isTracked`, `isStaged`, warnings, recommended actions)
|
|
535
|
-
- mutating actions (`update`, `append`, `auto_append`, `checkpoint`, `reset`, `compact`) are blocked at runtime when `.devctx/state.sqlite` is tracked or staged
|
|
536
|
-
|
|
537
|
-
**Compression strategy:**
|
|
538
|
-
- Keeps the persisted session state intact and compresses only the resume summary
|
|
539
|
-
- Prioritizes `nextStep`, `status`, and active blockers over history
|
|
540
|
-
- Deduplicates repeated completed steps, decisions, and touched files
|
|
541
|
-
- Uses token-aware reduction until the summary fits `maxTokens`
|
|
542
|
-
|
|
543
|
-
**Example workflow:**
|
|
248
|
+
# View metrics
|
|
249
|
+
smart-context-report
|
|
544
250
|
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
smart_summary({ action: "get" })
|
|
548
|
-
// → retrieves last active session or auto-resumes the best saved session
|
|
549
|
-
|
|
550
|
-
// After implementing auth middleware
|
|
551
|
-
smart_summary({
|
|
552
|
-
action: "checkpoint",
|
|
553
|
-
event: "milestone",
|
|
554
|
-
update: {
|
|
555
|
-
completed: ["auth middleware"],
|
|
556
|
-
decisions: ["JWT with 1h expiry, refresh tokens in Redis"],
|
|
557
|
-
touchedFiles: ["src/middleware/auth.js"],
|
|
558
|
-
nextStep: "add role-based access control"
|
|
559
|
-
}
|
|
560
|
-
})
|
|
561
|
-
|
|
562
|
-
// Monday after weekend - resume work
|
|
563
|
-
smart_summary({ action: "get" })
|
|
564
|
-
// → full context restored, continue from nextStep
|
|
565
|
-
|
|
566
|
-
// List all sessions
|
|
567
|
-
smart_summary({ action: "list_sessions" })
|
|
568
|
-
// → see all available sessions, pick one to resume
|
|
569
|
-
|
|
570
|
-
// Inspect git safety for project-local state from any smart_summary response
|
|
571
|
-
smart_summary({ action: "get" })
|
|
572
|
-
// → repoSafety warns if .devctx/state.sqlite is tracked or not ignored
|
|
573
|
-
|
|
574
|
-
// Suppress noisy read-only exploration checkpoints
|
|
575
|
-
smart_summary({
|
|
576
|
-
action: "checkpoint",
|
|
577
|
-
event: "read_only",
|
|
578
|
-
update: { currentFocus: "inspect auth flow" }
|
|
579
|
-
})
|
|
580
|
-
// → skipped=true, no event persisted
|
|
581
|
-
|
|
582
|
-
// Compact old SQLite events while keeping recent history
|
|
583
|
-
smart_summary({ action: "compact", retentionDays: 30, keepLatestEventsPerSession: 20, keepLatestMetrics: 1000 })
|
|
584
|
-
|
|
585
|
-
// Inspect what legacy files are safe to remove
|
|
586
|
-
smart_summary({ action: "cleanup_legacy" })
|
|
587
|
-
|
|
588
|
-
// Remove imported legacy JSON/JSONL artifacts explicitly
|
|
589
|
-
smart_summary({ action: "cleanup_legacy", apply: true })
|
|
251
|
+
# Verify features
|
|
252
|
+
npm run verify
|
|
590
253
|
```
|
|
591
254
|
|
|
592
|
-
|
|
255
|
+
## Storage
|
|
593
256
|
|
|
594
|
-
|
|
257
|
+
Data stored in `.devctx/`:
|
|
258
|
+
- `index.json` - Symbol index
|
|
259
|
+
- `state.sqlite` - Task checkpoints, metrics, patterns (Node 22+)
|
|
260
|
+
- `metrics.jsonl` - Legacy fallback (Node 18-20)
|
|
595
261
|
|
|
596
|
-
|
|
597
|
-
- Supports `window`: `24h` | `7d` | `30d` | `all`
|
|
598
|
-
- Supports filtering by `tool`
|
|
599
|
-
- Supports filtering by `sessionId`, including `sessionId: "active"`
|
|
600
|
-
- Includes `latestEntries` so an agent can explain recent savings without parsing storage manually
|
|
601
|
-
- Includes `overheadTokens` and `overheadTools` so hook/wrapper context cost stays measurable against the savings
|
|
602
|
-
- When `.devctx/state.sqlite` is tracked or staged, metric writes are skipped and reads fall back to a temporary read-only snapshot with `sideEffectsSuppressed: true`
|
|
603
|
-
|
|
604
|
-
**Example workflow:**
|
|
605
|
-
|
|
606
|
-
```javascript
|
|
607
|
-
smart_metrics({ window: "7d", sessionId: "active" })
|
|
608
|
-
// → totals and recent entries for the current task/session
|
|
262
|
+
Add to `.gitignore`:
|
|
609
263
|
```
|
|
610
|
-
|
|
611
|
-
### `smart_turn`
|
|
612
|
-
|
|
613
|
-
Orchestrate the start or end of a meaningful agent turn with one MCP call.
|
|
614
|
-
|
|
615
|
-
- `phase: "start"` rehydrates context, classifies whether the current prompt aligns with persisted work, and can auto-create a planning session for a substantial new task
|
|
616
|
-
- `phase: "end"` writes a checkpoint through `smart_summary` and can optionally include compact metrics
|
|
617
|
-
- Designed to make context usage almost mandatory without forcing the agent to chain `smart_summary(get)` and `smart_summary(checkpoint)` manually on every turn
|
|
618
|
-
- Claude Code can invoke this automatically through generated native hooks on `SessionStart`, `UserPromptSubmit`, `PostToolUse`, and `Stop`
|
|
619
|
-
- Non-Claude CLI clients can approximate the same flow with `smart-context-headless`, which wraps one headless agent invocation around `smart_turn(start)` and `smart_turn(end)`
|
|
620
|
-
|
|
621
|
-
**Example workflow:**
|
|
622
|
-
|
|
623
|
-
```javascript
|
|
624
|
-
smart_turn({
|
|
625
|
-
phase: "start",
|
|
626
|
-
prompt: "Finish runtime repo-safety enforcement for smart metrics",
|
|
627
|
-
ensureSession: true
|
|
628
|
-
})
|
|
629
|
-
// → summary + continuity classification + repoSafety
|
|
630
|
-
|
|
631
|
-
smart_turn({
|
|
632
|
-
phase: "end",
|
|
633
|
-
event: "milestone",
|
|
634
|
-
update: {
|
|
635
|
-
completed: ["Finished smart metrics repo-safety enforcement"],
|
|
636
|
-
nextStep: "Update docs and run the full suite"
|
|
637
|
-
}
|
|
638
|
-
})
|
|
639
|
-
// → checkpoint result + optional compact metrics
|
|
264
|
+
.devctx/
|
|
640
265
|
```
|
|
641
266
|
|
|
642
|
-
|
|
267
|
+
## Requirements
|
|
643
268
|
|
|
644
|
-
-
|
|
645
|
-
-
|
|
646
|
-
- Extracts imports/exports and builds a dependency graph with `import` and `testOf` edges
|
|
647
|
-
- Test files are linked to source files via import analysis and naming conventions
|
|
648
|
-
- Index stored per-project in `.devctx/index.json`, invalidated by file mtime
|
|
649
|
-
- 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
|
|
650
|
-
- Accelerates `smart_search` (symbol + graph ranking) and `smart_read` symbol mode (line hints)
|
|
651
|
-
- 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.
|
|
652
|
-
- Incremental response includes `reindexed`, `removed`, `unchanged` counts
|
|
653
|
-
- Run once after checkout or when many files changed; not required but recommended for large projects
|
|
269
|
+
- Node.js 18+ (22+ for SQLite features)
|
|
270
|
+
- Git (for diff and blame features)
|
|
654
271
|
|
|
655
|
-
|
|
272
|
+
## Security
|
|
656
273
|
|
|
657
|
-
|
|
658
|
-
- Executes from the effective project root
|
|
659
|
-
- Blocks shell operators and unsafe commands by design
|
|
274
|
+
This MCP is **secure by default**:
|
|
660
275
|
|
|
661
|
-
|
|
276
|
+
- ✅ **Allowlist-only commands** - Only safe diagnostic commands (`ls`, `git status`, `npm test`, etc.)
|
|
277
|
+
- ✅ **No shell operators** - Blocks `|`, `&`, `;`, `>`, `<`, `` ` ``, `$()`
|
|
278
|
+
- ✅ **Path validation** - Cannot escape project root
|
|
279
|
+
- ✅ **No write access** - Cannot modify your code
|
|
280
|
+
- ✅ **Repository safety** - Prevents accidental commit of local state
|
|
281
|
+
- ✅ **Resource limits** - 15s timeout, 10MB buffer
|
|
662
282
|
|
|
663
|
-
|
|
283
|
+
**Configuration:**
|
|
664
284
|
|
|
665
285
|
```bash
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
npm run eval -- --baseline
|
|
669
|
-
npm run eval:self
|
|
670
|
-
npm run eval:context
|
|
671
|
-
npm run eval:both
|
|
672
|
-
npm run eval:report
|
|
673
|
-
```
|
|
286
|
+
# Disable shell execution entirely
|
|
287
|
+
export DEVCTX_SHELL_DISABLED=true
|
|
674
288
|
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
- `eval:self` — self-eval against the real devctx repo
|
|
679
|
-
- `eval:context` — evaluate smart_context alongside search
|
|
680
|
-
- `eval:both` — search + context evaluation
|
|
681
|
-
- `eval:report` — scorecard with delta vs baseline
|
|
682
|
-
|
|
683
|
-
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.
|
|
289
|
+
# Disable cache warming
|
|
290
|
+
export DEVCTX_CACHE_WARMING=false
|
|
291
|
+
```
|
|
684
292
|
|
|
685
|
-
|
|
293
|
+
See [SECURITY.md](https://github.com/Arrayo/smart-context-mcp/blob/main/SECURITY.md) for complete security documentation.
|
|
686
294
|
|
|
687
|
-
##
|
|
295
|
+
## Documentation
|
|
688
296
|
|
|
689
|
-
|
|
690
|
-
- Persistent context and metrics live in `<projectRoot>/.devctx/state.sqlite`.
|
|
691
|
-
- `DEVCTX_METRICS_FILE` is now an explicit compatibility override for JSONL-based workflows and reports.
|
|
692
|
-
- Symbol index stored in `<projectRoot>/.devctx/index.json` when `build_index` is used.
|
|
693
|
-
- Legacy session JSON files in `<projectRoot>/.devctx/sessions/` are imported idempotently when present.
|
|
694
|
-
- This package is a navigation and diagnostics layer, not a full semantic code intelligence system.
|
|
297
|
+
Full documentation in [GitHub repository](https://github.com/Arrayo/smart-context-mcp):
|
|
695
298
|
|
|
696
|
-
|
|
299
|
+
- [Streaming Progress](https://github.com/Arrayo/smart-context-mcp/blob/main/docs/features/streaming.md) - Progress notifications
|
|
300
|
+
- [Context Prediction](https://github.com/Arrayo/smart-context-mcp/blob/main/docs/features/context-prediction.md) - File prediction
|
|
301
|
+
- [Diff-Aware Context](https://github.com/Arrayo/smart-context-mcp/blob/main/docs/features/diff-aware.md) - Change analysis
|
|
302
|
+
- [Cache Warming](https://github.com/Arrayo/smart-context-mcp/blob/main/docs/features/cache-warming.md) - Cold-start optimization
|
|
303
|
+
- [Git Blame](https://github.com/Arrayo/smart-context-mcp/blob/main/docs/features/git-blame.md) - Code attribution
|
|
304
|
+
- [Cross-Project Context](https://github.com/Arrayo/smart-context-mcp/blob/main/docs/features/cross-project.md) - Multi-project support
|
|
697
305
|
|
|
698
|
-
|
|
306
|
+
## Links
|
|
699
307
|
|
|
700
|
-
- https://github.com/Arrayo/
|
|
308
|
+
- [GitHub](https://github.com/Arrayo/smart-context-mcp)
|
|
309
|
+
- [npm](https://www.npmjs.com/package/smart-context-mcp)
|
|
310
|
+
- [Issues](https://github.com/Arrayo/smart-context-mcp/issues)
|
|
701
311
|
|
|
702
312
|
## Author
|
|
703
313
|
|
|
704
314
|
**Francisco Caballero Portero**
|
|
705
|
-
|
|
706
|
-
|
|
315
|
+
fcp1978@hotmail.com
|
|
316
|
+
[@Arrayo](https://github.com/Arrayo)
|
|
707
317
|
|
|
708
318
|
## License
|
|
709
319
|
|
|
710
|
-
MIT
|
|
320
|
+
MIT
|