purecontext-mcp 1.2.0 → 1.5.1
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 +110 -784
- package/AGENT_REFERENCE.md +561 -0
- package/BENCHMARKS.md +153 -0
- package/CHANGELOG.md +177 -6
- package/FRAMEWORK-ADAPTERS.md +351 -0
- package/FULL-INSTALLATION-GUIDE.md +341 -0
- package/LANGUAGE-SUPPORT.md +144 -0
- package/README.md +154 -16
- package/USER-GUIDE.md +29 -21
- package/dist/cli/hooks.d.ts +28 -0
- package/dist/cli/hooks.d.ts.map +1 -0
- package/dist/cli/hooks.js +570 -0
- package/dist/cli/hooks.js.map +1 -0
- package/dist/cli/install-detect.d.ts +16 -0
- package/dist/cli/install-detect.d.ts.map +1 -0
- package/dist/cli/install-detect.js +70 -0
- package/dist/cli/install-detect.js.map +1 -0
- package/dist/cli/install-writers.d.ts +59 -0
- package/dist/cli/install-writers.d.ts.map +1 -0
- package/dist/cli/install-writers.js +292 -0
- package/dist/cli/install-writers.js.map +1 -0
- package/dist/cli/install.d.ts +14 -0
- package/dist/cli/install.d.ts.map +1 -0
- package/dist/cli/install.js +150 -0
- package/dist/cli/install.js.map +1 -0
- package/dist/config/config-loader.js +3 -0
- package/dist/config/config-loader.js.map +1 -1
- package/dist/config/config-schema.d.ts +11 -0
- package/dist/config/config-schema.d.ts.map +1 -1
- package/dist/config/config-schema.js +15 -0
- package/dist/config/config-schema.js.map +1 -1
- package/dist/core/db/symbol-store.d.ts +1 -0
- package/dist/core/db/symbol-store.d.ts.map +1 -1
- package/dist/core/db/symbol-store.js +120 -6
- package/dist/core/db/symbol-store.js.map +1 -1
- package/dist/core/file-discovery.d.ts +6 -0
- package/dist/core/file-discovery.d.ts.map +1 -1
- package/dist/core/file-discovery.js +20 -13
- package/dist/core/file-discovery.js.map +1 -1
- package/dist/core/file-processor.d.ts.map +1 -1
- package/dist/core/file-processor.js +26 -1
- package/dist/core/file-processor.js.map +1 -1
- package/dist/core/git-log-reader.d.ts.map +1 -1
- package/dist/core/git-log-reader.js +21 -0
- package/dist/core/git-log-reader.js.map +1 -1
- package/dist/core/index-manager.d.ts.map +1 -1
- package/dist/core/index-manager.js +21 -7
- package/dist/core/index-manager.js.map +1 -1
- package/dist/core/indexing-worker.d.ts.map +1 -1
- package/dist/core/indexing-worker.js +14 -0
- package/dist/core/indexing-worker.js.map +1 -1
- package/dist/core/parse-dispatcher.d.ts.map +1 -1
- package/dist/core/parse-dispatcher.js +20 -5
- package/dist/core/parse-dispatcher.js.map +1 -1
- package/dist/core/search/query-preprocessor.d.ts +69 -3
- package/dist/core/search/query-preprocessor.d.ts.map +1 -1
- package/dist/core/search/query-preprocessor.js +450 -17
- package/dist/core/search/query-preprocessor.js.map +1 -1
- package/dist/core/search/relevance-ranker.d.ts +60 -5
- package/dist/core/search/relevance-ranker.d.ts.map +1 -1
- package/dist/core/search/relevance-ranker.js +931 -33
- package/dist/core/search/relevance-ranker.js.map +1 -1
- package/dist/core/test-mapper.d.ts.map +1 -1
- package/dist/core/test-mapper.js +7 -1
- package/dist/core/test-mapper.js.map +1 -1
- package/dist/core/types.d.ts +28 -1
- package/dist/core/types.d.ts.map +1 -1
- package/dist/handlers/angular-html.d.ts +3 -0
- package/dist/handlers/angular-html.d.ts.map +1 -0
- package/dist/handlers/angular-html.js +215 -0
- package/dist/handlers/angular-html.js.map +1 -0
- package/dist/handlers/c.d.ts.map +1 -1
- package/dist/handlers/c.js +19 -0
- package/dist/handlers/c.js.map +1 -1
- package/dist/handlers/cpp-macro-registry.d.ts +21 -0
- package/dist/handlers/cpp-macro-registry.d.ts.map +1 -0
- package/dist/handlers/cpp-macro-registry.js +44 -0
- package/dist/handlers/cpp-macro-registry.js.map +1 -0
- package/dist/handlers/cpp.d.ts.map +1 -1
- package/dist/handlers/cpp.js +579 -10
- package/dist/handlers/cpp.js.map +1 -1
- package/dist/handlers/csharp.d.ts.map +1 -1
- package/dist/handlers/csharp.js +39 -2
- package/dist/handlers/csharp.js.map +1 -1
- package/dist/handlers/css.d.ts +3 -0
- package/dist/handlers/css.d.ts.map +1 -0
- package/dist/handlers/css.js +154 -0
- package/dist/handlers/css.js.map +1 -0
- package/dist/handlers/erlang.d.ts.map +1 -1
- package/dist/handlers/erlang.js +8 -1
- package/dist/handlers/erlang.js.map +1 -1
- package/dist/handlers/fortran.js +1 -1
- package/dist/handlers/fortran.js.map +1 -1
- package/dist/handlers/go.d.ts.map +1 -1
- package/dist/handlers/go.js +87 -2
- package/dist/handlers/go.js.map +1 -1
- package/dist/handlers/handler-registry.d.ts.map +1 -1
- package/dist/handlers/handler-registry.js +4 -0
- package/dist/handlers/handler-registry.js.map +1 -1
- package/dist/handlers/hcl.d.ts +3 -0
- package/dist/handlers/hcl.d.ts.map +1 -0
- package/dist/handlers/hcl.js +193 -0
- package/dist/handlers/hcl.js.map +1 -0
- package/dist/handlers/java.d.ts.map +1 -1
- package/dist/handlers/java.js +33 -16
- package/dist/handlers/java.js.map +1 -1
- package/dist/handlers/kotlin.d.ts.map +1 -1
- package/dist/handlers/kotlin.js +48 -3
- package/dist/handlers/kotlin.js.map +1 -1
- package/dist/handlers/less.d.ts +3 -0
- package/dist/handlers/less.d.ts.map +1 -0
- package/dist/handlers/less.js +255 -0
- package/dist/handlers/less.js.map +1 -0
- package/dist/handlers/objective-c.d.ts.map +1 -1
- package/dist/handlers/objective-c.js +122 -64
- package/dist/handlers/objective-c.js.map +1 -1
- package/dist/handlers/openapi.d.ts.map +1 -1
- package/dist/handlers/openapi.js +30 -5
- package/dist/handlers/openapi.js.map +1 -1
- package/dist/handlers/php.d.ts.map +1 -1
- package/dist/handlers/php.js +287 -41
- package/dist/handlers/php.js.map +1 -1
- package/dist/handlers/protobuf.d.ts.map +1 -1
- package/dist/handlers/protobuf.js +1 -0
- package/dist/handlers/protobuf.js.map +1 -1
- package/dist/handlers/python.d.ts.map +1 -1
- package/dist/handlers/python.js +1 -3
- package/dist/handlers/python.js.map +1 -1
- package/dist/handlers/ruby-dsl.d.ts +23 -0
- package/dist/handlers/ruby-dsl.d.ts.map +1 -0
- package/dist/handlers/ruby-dsl.js +251 -0
- package/dist/handlers/ruby-dsl.js.map +1 -0
- package/dist/handlers/ruby.d.ts.map +1 -1
- package/dist/handlers/ruby.js +29 -4
- package/dist/handlers/ruby.js.map +1 -1
- package/dist/handlers/rust.d.ts.map +1 -1
- package/dist/handlers/rust.js +98 -2
- package/dist/handlers/rust.js.map +1 -1
- package/dist/handlers/scss.d.ts +3 -0
- package/dist/handlers/scss.d.ts.map +1 -0
- package/dist/handlers/scss.js +290 -0
- package/dist/handlers/scss.js.map +1 -0
- package/dist/handlers/sql.d.ts.map +1 -1
- package/dist/handlers/sql.js +37 -18
- package/dist/handlers/sql.js.map +1 -1
- package/dist/handlers/typescript.d.ts.map +1 -1
- package/dist/handlers/typescript.js +65 -17
- package/dist/handlers/typescript.js.map +1 -1
- package/dist/handlers/xml.d.ts.map +1 -1
- package/dist/handlers/xml.js +35 -2
- package/dist/handlers/xml.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +91 -0
- package/dist/index.js.map +1 -1
- package/dist/server/mcp-server.d.ts.map +1 -1
- package/dist/server/mcp-server.js +10 -0
- package/dist/server/mcp-server.js.map +1 -1
- package/dist/server/tools/detect-antipatterns.d.ts +1 -1
- package/dist/server/tools/get-architecture-snapshot.d.ts +1 -1
- package/dist/server/tools/get-entry-points.d.ts +1 -1
- package/dist/server/tools/get-lexical-scope-matches.d.ts +54 -0
- package/dist/server/tools/get-lexical-scope-matches.d.ts.map +1 -0
- package/dist/server/tools/get-lexical-scope-matches.js +470 -0
- package/dist/server/tools/get-lexical-scope-matches.js.map +1 -0
- package/dist/server/tools/search-symbols.d.ts +10 -0
- package/dist/server/tools/search-symbols.d.ts.map +1 -1
- package/dist/server/tools/search-symbols.js +353 -8
- package/dist/server/tools/search-symbols.js.map +1 -1
- package/dist/server/tools/trace-invocation-chain.d.ts +53 -0
- package/dist/server/tools/trace-invocation-chain.d.ts.map +1 -0
- package/dist/server/tools/trace-invocation-chain.js +280 -0
- package/dist/server/tools/trace-invocation-chain.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/02-installation.md +43 -245
- package/docs/05-cli-reference.md +89 -0
- package/docs/07-language-support.md +73 -50
- package/docs/08-framework-adapters.md +7 -2
- package/docs/15-team-setup.md +70 -200
- package/docs/17-web-ui.md +73 -93
- package/docs/README.md +60 -39
- package/docs/dev/benchmark-findings-eu-za-tebe.md +210 -0
- package/docs/dev/phase-35-coverage-audit.md +469 -0
- package/package.json +6 -3
- package/user-manual.md +0 -2466
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
# Framework Adapters
|
|
2
|
+
|
|
3
|
+
A language handler knows what a function or class looks like. A framework adapter knows that `app.get('/users/:id', ...)` is actually a **route**, that a Vue Single File Component is a **component**, and that a Django `models.Model` subclass is a **model** with a table behind it.
|
|
4
|
+
|
|
5
|
+
PureContext ships with adapters for the frameworks most production codebases are written against. They run automatically — drop the index on a NestJS project and `/users` routes show up as first-class symbols you can search for by path, not just by handler-function name.
|
|
6
|
+
|
|
7
|
+
This page is the user-facing tour. For parameter-level details (exact regex patterns, full `frameworkMeta` shapes), see the [reference manual](docs/08-framework-adapters.md).
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## How adapters change what you see
|
|
12
|
+
|
|
13
|
+
Without an adapter, searching for "user routes" in an Express app returns *function names* — `handleGetUser`, `createUserHandler`, `usersRouter` — and you have to read each one to confirm it's actually a route.
|
|
14
|
+
|
|
15
|
+
With the Express adapter active, the same search returns:
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
search_symbols(query: "users") →
|
|
19
|
+
|
|
20
|
+
GET /users src/routes/users.ts route
|
|
21
|
+
POST /users src/routes/users.ts route
|
|
22
|
+
GET /users/:id src/routes/users.ts route
|
|
23
|
+
DELETE /users/:id src/routes/users.ts route
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
That's the difference. Adapters extract the *intent* of code (a route, a component, an ORM entity) rather than just its syntactic shape.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Auto-detection
|
|
31
|
+
|
|
32
|
+
Adapters are detected from project config — `package.json`, `composer.json`, `Gemfile`, `pubspec.yaml`, `go.mod`, `Cargo.toml`, `pom.xml`, `build.gradle`. If you have `react` in dependencies, the React adapter runs. If `manage.py` sits at the project root, the Django adapter runs.
|
|
33
|
+
|
|
34
|
+
You don't usually need to configure anything. If you do:
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"adapters": "auto" // default
|
|
39
|
+
"adapters": "none" // disable all adapters
|
|
40
|
+
"adapters": ["vue", "nuxt"] // explicit allow-list
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Multiple adapters run side by side. A Vue + Nuxt project activates both. A Nest app that also uses TypeORM gets routes from Nest *and* entities from TypeORM.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## JavaScript and TypeScript
|
|
49
|
+
|
|
50
|
+
### Vue 3
|
|
51
|
+
|
|
52
|
+
Detected by `vue` in `package.json` or any `.vue` file present.
|
|
53
|
+
|
|
54
|
+
Extracts from Single File Components:
|
|
55
|
+
- The component itself (named from `defineComponent` or filename) → `component`
|
|
56
|
+
- Exported `useFoo` functions → `composable`
|
|
57
|
+
|
|
58
|
+
Useful for: jumping to a `<MyButton>` mentioned in a template, or finding every composable that touches the auth store.
|
|
59
|
+
|
|
60
|
+
### Nuxt
|
|
61
|
+
|
|
62
|
+
Detected by `nuxt.config.ts` / `.js` / `.mts` / `.mjs`.
|
|
63
|
+
|
|
64
|
+
Layers Nuxt's conventional routing on top of the Vue adapter:
|
|
65
|
+
- `pages/blog/[slug].vue` → `route /blog/:slug`
|
|
66
|
+
- `server/api/users.get.ts` → `route GET /api/users`
|
|
67
|
+
- `middleware/auth.ts` and `plugins/*` → `middleware`
|
|
68
|
+
- Composables in `composables/` are flagged with `nuxt_auto_import: true`
|
|
69
|
+
|
|
70
|
+
### React
|
|
71
|
+
|
|
72
|
+
Detected by `react` in `package.json`. This adapter doesn't extract new symbols — it *enriches* what the TypeScript handler already found:
|
|
73
|
+
- PascalCase functions that return JSX → `component`
|
|
74
|
+
- `useFoo` functions → `hook`
|
|
75
|
+
|
|
76
|
+
So `MyButton` shows up as a `component` rather than a generic `function`, and `useAuth` shows up as a `hook` rather than a generic `function`.
|
|
77
|
+
|
|
78
|
+
### Next.js
|
|
79
|
+
|
|
80
|
+
Detected by `next.config.*` or `next` in dependencies. Supports both routers:
|
|
81
|
+
|
|
82
|
+
**Pages Router** (`pages/`):
|
|
83
|
+
- `pages/blog/[slug].tsx` → `route /blog/:slug`
|
|
84
|
+
- Detects `getServerSideProps` (SSR) and `getStaticProps` (SSG)
|
|
85
|
+
- API routes from `pages/api/`
|
|
86
|
+
|
|
87
|
+
**App Router** (`app/`):
|
|
88
|
+
- `app/(marketing)/about/page.tsx` → `route /about` (route groups stripped)
|
|
89
|
+
- `'use client'` directive flagged on metadata
|
|
90
|
+
- API routes from `app/**/route.ts` with HTTP method exports
|
|
91
|
+
|
|
92
|
+
**Middleware** (`middleware.ts`) → `middleware` symbol with the matcher config.
|
|
93
|
+
|
|
94
|
+
### Angular
|
|
95
|
+
|
|
96
|
+
Detected by `@angular/core`. Decorated classes become first-class:
|
|
97
|
+
- `@Component` → `component` (with `selector`)
|
|
98
|
+
- `@Injectable` → `class` (service)
|
|
99
|
+
- `@NgModule` → `class` (module)
|
|
100
|
+
- `@Directive` → `component`
|
|
101
|
+
- `@Pipe` → `component` (with the pipe name)
|
|
102
|
+
- `RouterModule.forRoot` / `forChild` configs → `route` symbols
|
|
103
|
+
|
|
104
|
+
### NestJS
|
|
105
|
+
|
|
106
|
+
Detected by `@nestjs/core`. Combines the controller prefix with each method's path:
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
@Controller('users')
|
|
110
|
+
class UsersController {
|
|
111
|
+
@Get(':id') findOne() { ... } // → route GET /users/:id
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
- `@Injectable` → `class` (with `nestjs_provider: true`)
|
|
116
|
+
- `@Module` → `class` (with `nestjs_module: true`)
|
|
117
|
+
- Guards and `CanActivate` implementations → `middleware`
|
|
118
|
+
|
|
119
|
+
### Express
|
|
120
|
+
|
|
121
|
+
Detected by `express`. Extracts string-literal route registrations:
|
|
122
|
+
|
|
123
|
+
```javascript
|
|
124
|
+
app.get('/path', handler) // → route GET /path
|
|
125
|
+
router.post('/path', handler) // → route POST /path
|
|
126
|
+
app.use('/path', middleware) // → middleware /path
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Dynamic paths built from variables or template literals are skipped — there's no reliable way to recover the runtime value from static analysis.
|
|
130
|
+
|
|
131
|
+
### Fastify
|
|
132
|
+
|
|
133
|
+
Detected by `fastify`. Same pattern as Express: `fastify.get(path, handler)` → `route`.
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Python
|
|
138
|
+
|
|
139
|
+
### Django
|
|
140
|
+
|
|
141
|
+
Detected by `manage.py` at the project root, or `django` in requirements.
|
|
142
|
+
|
|
143
|
+
- `models.Model` subclasses → `model` (with field types: `CharField`, `ForeignKey`, etc.)
|
|
144
|
+
- Class-based views (`APIView`, `ViewSet`, etc.) → `view`
|
|
145
|
+
- Function-based views with `@login_required` / `@api_view` → `view`
|
|
146
|
+
- `path(...)` / `re_path(...)` in `urls.py` → `route`
|
|
147
|
+
- `@receiver(post_save)` → `signal`
|
|
148
|
+
|
|
149
|
+
### FastAPI
|
|
150
|
+
|
|
151
|
+
Detected by `fastapi`. Extracts decorated handlers:
|
|
152
|
+
|
|
153
|
+
```python
|
|
154
|
+
@app.get('/items/{id}') # → route GET /items/{id}
|
|
155
|
+
@router.post('/items') # → route POST /items
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
FastAPI's `{param}` path syntax is preserved as-is in the route metadata.
|
|
159
|
+
|
|
160
|
+
### Flask
|
|
161
|
+
|
|
162
|
+
Detected by `Flask`. Extracts:
|
|
163
|
+
- `@app.route('/path')` → `route`
|
|
164
|
+
- `@app.get`, `@app.post`, etc. → `route`
|
|
165
|
+
- Blueprint routes (`@bp.route(...)`) → `route`
|
|
166
|
+
- Class-based views inheriting `MethodView` → `view`
|
|
167
|
+
|
|
168
|
+
Flask's `<int:user_id>` path syntax is preserved.
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## Go
|
|
173
|
+
|
|
174
|
+
### Gin, Echo, Fiber
|
|
175
|
+
|
|
176
|
+
Detected by their respective `go.mod` entries. All three follow the same pattern — `r.GET("/path", handler)` becomes a `route`. Route groups apply their prefix to children.
|
|
177
|
+
|
|
178
|
+
The Fiber adapter handles title-cased methods (`app.Get`, `app.Post`); Gin and Echo use lowercase methods.
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## PHP
|
|
183
|
+
|
|
184
|
+
### Laravel
|
|
185
|
+
|
|
186
|
+
Detected by `laravel/framework` in `composer.json`.
|
|
187
|
+
|
|
188
|
+
- `Route::get('/path', ...)` → `route`
|
|
189
|
+
- `Route::resource('users', Controller::class)` → expands into the seven CRUD routes (index/show/create/store/edit/update/destroy)
|
|
190
|
+
- `Route::group(['prefix' => '/api'], ...)` → prefix applied to children
|
|
191
|
+
- `class User extends Model` → `model`
|
|
192
|
+
- Controller public methods → `view` (action)
|
|
193
|
+
- Middleware classes → `middleware`
|
|
194
|
+
|
|
195
|
+
### Symfony
|
|
196
|
+
|
|
197
|
+
Detected by `symfony/framework-bundle`. Supports both routing styles:
|
|
198
|
+
|
|
199
|
+
```php
|
|
200
|
+
#[Route('/path', methods: ['GET'])] // PHP 8 attributes
|
|
201
|
+
@Route('/path') // docblock annotations
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Both produce `route` symbols.
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## Ruby
|
|
209
|
+
|
|
210
|
+
### Rails
|
|
211
|
+
|
|
212
|
+
Detected by `gem 'rails'` in `Gemfile`.
|
|
213
|
+
|
|
214
|
+
- `ApplicationRecord` subclasses → `model` (with `has_many` associations captured)
|
|
215
|
+
- Controller public methods → `view` (action)
|
|
216
|
+
- `get '/path'`, `resources :users` in `routes.rb` → `route` (resources expand to the seven REST actions)
|
|
217
|
+
|
|
218
|
+
### Sinatra
|
|
219
|
+
|
|
220
|
+
Detected by `gem 'sinatra'` or `require 'sinatra'`. `get '/path' do ... end` → `route`.
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## Kotlin
|
|
225
|
+
|
|
226
|
+
### Ktor
|
|
227
|
+
|
|
228
|
+
Detected by `io.ktor`. Extracts from the routing DSL:
|
|
229
|
+
|
|
230
|
+
```kotlin
|
|
231
|
+
route("/api") {
|
|
232
|
+
get("/users") { ... } // → route /api/users
|
|
233
|
+
}
|
|
234
|
+
authenticate { ... } // → frameworkMeta.authenticated: true
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Spring (Kotlin)
|
|
238
|
+
|
|
239
|
+
Detected by `org.springframework.boot`. Same extraction as Spring Boot below — adapter handles both Java and Kotlin sources.
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
## Rust
|
|
244
|
+
|
|
245
|
+
### Axum
|
|
246
|
+
|
|
247
|
+
Detected by `axum` in `Cargo.toml`. Extracts router chains:
|
|
248
|
+
|
|
249
|
+
```rust
|
|
250
|
+
.route("/users", get(list_users))
|
|
251
|
+
.route("/users/:id", get(get_user))
|
|
252
|
+
.layer(auth_middleware) // → middleware
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Actix-web
|
|
256
|
+
|
|
257
|
+
Detected by `actix-web`. Extracts attribute macros: `#[get("/path")]` → `route`. `.wrap(...)` calls become `middleware`.
|
|
258
|
+
|
|
259
|
+
### Rocket
|
|
260
|
+
|
|
261
|
+
Detected by `rocket`. Extracts `#[get("/path")]` → `route`. `#[catch(404)]` becomes an error catcher, and `Fairing` implementations become middleware.
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## Java
|
|
266
|
+
|
|
267
|
+
### Spring Boot
|
|
268
|
+
|
|
269
|
+
Detected by `spring-boot-starter` in build files.
|
|
270
|
+
|
|
271
|
+
- `@GetMapping` / `@PostMapping` (combined with class-level `@RequestMapping` prefix) → `route`
|
|
272
|
+
- `@Service`, `@Component`, `@Repository` → beans with bean metadata
|
|
273
|
+
- `@Bean` factory methods → tracked as bean producers
|
|
274
|
+
- `@Scheduled` methods → scheduled tasks
|
|
275
|
+
|
|
276
|
+
### Micronaut
|
|
277
|
+
|
|
278
|
+
Detected by `io.micronaut`. `@Get("/path")`, `@Post(...)` → `route`. `@Client` interfaces are captured.
|
|
279
|
+
|
|
280
|
+
### Quarkus
|
|
281
|
+
|
|
282
|
+
Detected by `io.quarkus`. JAX-RS `@GET` + `@Path` combinations → `route`. `@ApplicationScoped` → bean.
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
## ORM adapters
|
|
287
|
+
|
|
288
|
+
ORMs sit slightly off the routing-adapter spine because they don't add routes — they add *entities*, which downstream queries (`find_references`, `get_blast_radius`) treat the same as any other symbol.
|
|
289
|
+
|
|
290
|
+
| Adapter | Detected by | Extracts |
|
|
291
|
+
|---------|-------------|----------|
|
|
292
|
+
| **Hibernate** (Java) | `hibernate-core` / `jakarta.persistence` | `@Entity` classes, table name, columns with types and nullability, `@OneToMany` / `@ManyToOne` relationships, named queries |
|
|
293
|
+
| **SQLAlchemy** (Python) | `sqlalchemy` | `Base` / `DeclarativeBase` subclasses, `__tablename__`, `Column(Type)` fields, `relationship()` associations, `@hybrid_property`. Supports both 1.x and 2.0 (`mapped_column`) styles. |
|
|
294
|
+
| **Django ORM** | `manage.py` | `models.Model` subclasses with field types (`CharField`, `IntegerField`, `ForeignKey`, `ManyToManyField`, etc.) |
|
|
295
|
+
| **Prisma** | `prisma` in `package.json` or `schema.prisma` present | Model definitions and relations from `schema.prisma` |
|
|
296
|
+
| **TypeORM** | `typeorm` in `package.json` | `@Entity` classes and `@Column` / `@Relation` fields |
|
|
297
|
+
|
|
298
|
+
Once entities are first-class symbols, you can ask "what writes to the `users` table?" the same way you'd ask "what calls `validateToken`?".
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
## Mobile
|
|
303
|
+
|
|
304
|
+
### Flutter
|
|
305
|
+
|
|
306
|
+
Detected by `sdk: flutter` in `pubspec.yaml`. Extracts from `.dart` files:
|
|
307
|
+
|
|
308
|
+
- `StatelessWidget` subclasses → `widget`
|
|
309
|
+
- `StatefulWidget` subclasses → `widget` (linked to the State class)
|
|
310
|
+
- `ChangeNotifier` subclasses → `class` with `flutter_notifier: true`
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## Disabling an adapter
|
|
315
|
+
|
|
316
|
+
If an adapter is misclassifying things in your project, turn it off:
|
|
317
|
+
|
|
318
|
+
```json
|
|
319
|
+
{
|
|
320
|
+
"adapters": ["vue", "react"] // explicit list — others stay off
|
|
321
|
+
}
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
Or to disable framework extraction entirely:
|
|
325
|
+
|
|
326
|
+
```json
|
|
327
|
+
{
|
|
328
|
+
"adapters": "none"
|
|
329
|
+
}
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
The language handler still runs — you'll still get functions and classes, you just won't get `route` / `component` / `model` annotations on top.
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
## Adding a new adapter
|
|
337
|
+
|
|
338
|
+
Adapters follow the same three-layer rule as language handlers (Core → Handlers → Adapters; never the reverse). To add one:
|
|
339
|
+
|
|
340
|
+
1. Create a file in `src/adapters/`, implementing `FrameworkAdapter`
|
|
341
|
+
2. `detect(projectRoot)` returns true if the framework is present
|
|
342
|
+
3. `extractFrameworkSymbols(tree, source, filePath)` returns the framework-specific symbols
|
|
343
|
+
4. Optionally `enrichMetadata(symbol)` to add `frameworkMeta` to existing symbols
|
|
344
|
+
5. Add tests against fixture projects in `test/adapters/`
|
|
345
|
+
|
|
346
|
+
See `docs/25-architecture-overview.md` for the architecture rules and `src/adapters/vue.ts` for a good reference implementation.
|
|
347
|
+
|
|
348
|
+
---
|
|
349
|
+
|
|
350
|
+
→ Full parameter-level reference: [docs/08-framework-adapters.md](docs/08-framework-adapters.md)
|
|
351
|
+
→ The language handlers that adapters sit on top of: [LANGUAGE-SUPPORT.md](LANGUAGE-SUPPORT.md)
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
# Installation
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
## Prerequisites
|
|
5
|
+
|
|
6
|
+
| Requirement | Version | Notes |
|
|
7
|
+
|-------------|---------|-------|
|
|
8
|
+
| Node.js | >= 18.0.0 | 18, 20, and 22 are tested |
|
|
9
|
+
| npm | >= 9.0.0 | Ships with Node 18+ |
|
|
10
|
+
| Git | any | Required only for `index_repo` (remote repo cloning) |
|
|
11
|
+
|
|
12
|
+
## Install via npm (recommended)
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install -g purecontext-mcp@latest
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
After this, `purecontext-mcp` is available as a global command.
|
|
19
|
+
|
|
20
|
+
If you prefer not to install globally, use `npx` to run without installing:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npx purecontext-mcp@latest
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
`npx` downloads the package on first use and caches it. This is the recommended approach for most AI client integrations because it picks up new versions automatically without a manual upgrade step.
|
|
27
|
+
|
|
28
|
+
## Prebuilt binaries
|
|
29
|
+
|
|
30
|
+
PureContext uses `better-sqlite3` for SQLite access. Pre-built native binaries are bundled for:
|
|
31
|
+
|
|
32
|
+
| Platform | Node 18 | Node 20 | Node 22 |
|
|
33
|
+
|----------|---------|---------|---------|
|
|
34
|
+
| Windows x64 | ✓ | ✓ | ✓ |
|
|
35
|
+
| macOS x64 | ✓ | ✓ | ✓ |
|
|
36
|
+
| macOS arm64 | ✓ | ✓ | ✓ |
|
|
37
|
+
| Linux x64 | ✓ | ✓ | ✓ |
|
|
38
|
+
| Linux arm64 | ✓ | ✓ | ✓ |
|
|
39
|
+
|
|
40
|
+
When a prebuilt binary matches your platform, `npm install` completes without any native compilation. No Python, no `node-gyp`, no build tools needed.
|
|
41
|
+
|
|
42
|
+
If your platform/Node combination is not in the table above, `npm install` will attempt a native compile. You will need:
|
|
43
|
+
- Python 3.x
|
|
44
|
+
- A C++ compiler (MSVC on Windows, clang/gcc on macOS/Linux)
|
|
45
|
+
- `node-gyp`: `npm install -g node-gyp`
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Connecting to your AI client
|
|
50
|
+
|
|
51
|
+
PureContext works with any MCP-compatible AI client. Choose the setup that matches your environment.
|
|
52
|
+
|
|
53
|
+
### Claude Code (CLI)
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
claude mcp add purecontext-mcp -- npx purecontext-mcp@latest
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Verify:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
claude mcp list
|
|
63
|
+
# purecontext-mcp connected npx purecontext-mcp
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Claude Desktop
|
|
67
|
+
|
|
68
|
+
Edit `~/.claude/claude_desktop_config.json` (create it if it doesn't exist):
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"mcpServers": {
|
|
73
|
+
"purecontext": {
|
|
74
|
+
"command": "npx",
|
|
75
|
+
"args": ["purecontext-mcp@latest"]
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
If you installed globally (`npm install -g purecontext-mcp`), you can use the binary directly:
|
|
82
|
+
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"mcpServers": {
|
|
86
|
+
"purecontext": {
|
|
87
|
+
"command": "purecontext-mcp@latest"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Restart Claude Desktop after saving the file.
|
|
94
|
+
|
|
95
|
+
### Cursor
|
|
96
|
+
|
|
97
|
+
Create or edit `.cursor/mcp.json` in your project directory for a project-scoped connection, or `~/.cursor/mcp.json` for a global one:
|
|
98
|
+
|
|
99
|
+
```json
|
|
100
|
+
{
|
|
101
|
+
"mcpServers": {
|
|
102
|
+
"purecontext": {
|
|
103
|
+
"command": "npx",
|
|
104
|
+
"args": ["purecontext-mcp@latest"]
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Reload the Cursor window after saving (`Ctrl+Shift+P` → "Developer: Reload Window").
|
|
111
|
+
|
|
112
|
+
### Windsurf
|
|
113
|
+
|
|
114
|
+
Open Windsurf Settings and navigate to the MCP section, or edit the MCP configuration file directly:
|
|
115
|
+
|
|
116
|
+
```json
|
|
117
|
+
{
|
|
118
|
+
"mcpServers": {
|
|
119
|
+
"purecontext": {
|
|
120
|
+
"command": "npx",
|
|
121
|
+
"args": ["purecontext-mcp@latest"]
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### VS Code (with MCP support)
|
|
128
|
+
|
|
129
|
+
Create `.vscode/mcp.json` in your project:
|
|
130
|
+
|
|
131
|
+
```json
|
|
132
|
+
{
|
|
133
|
+
"servers": {
|
|
134
|
+
"purecontext": {
|
|
135
|
+
"type": "stdio",
|
|
136
|
+
"command": "npx",
|
|
137
|
+
"args": ["purecontext-mcp@latest"]
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Connecting to a shared team server (HTTP)
|
|
144
|
+
|
|
145
|
+
If your team runs a shared PureContext server, connect with an HTTP transport instead of launching a local process. The config format is the same across all clients — only the transport section changes:
|
|
146
|
+
|
|
147
|
+
**Claude Code CLI:**
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
claude mcp add purecontext-shared \
|
|
151
|
+
--transport http \
|
|
152
|
+
--url https://purecontext.yourcompany.com/mcp/sse \
|
|
153
|
+
--header "Authorization: Bearer pctx_yourpersonalkey"
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**Claude Desktop / Cursor / Windsurf (config file):**
|
|
157
|
+
|
|
158
|
+
```json
|
|
159
|
+
{
|
|
160
|
+
"mcpServers": {
|
|
161
|
+
"purecontext": {
|
|
162
|
+
"transport": "http",
|
|
163
|
+
"url": "https://purecontext.yourcompany.com/mcp/sse",
|
|
164
|
+
"headers": {
|
|
165
|
+
"Authorization": "Bearer pctx_yourpersonalkey"
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Your API key is issued by your team's PureContext administrator. See [Team Setup](15-team-setup.md) for how to deploy and manage a shared server.
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Teaching your AI agent to use PureContext well
|
|
177
|
+
|
|
178
|
+
Installing PureContext gives your AI agent access to the tools. Adding the agent instructions tells it *how* to use them efficiently — which tool to pick for each situation, in what order to call them, and what patterns to avoid.
|
|
179
|
+
|
|
180
|
+
Without them, an AI agent given access to PureContext may default to reading entire files (wasting tokens) rather than using `search_symbols`, or may not know to call `list_repos` first to get the `repoId` required by every tool. The instructions encode the correct workflow: check if indexed → search by name or meaning → retrieve source only for what you'll use.
|
|
181
|
+
|
|
182
|
+
### Recommended: `purecontext-mcp install`
|
|
183
|
+
|
|
184
|
+
PureContext ships with a multi-IDE installer that writes the workflow rules into the conventions file each tool expects. Run it once inside your project root:
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
npx purecontext-mcp install all
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
This auto-detects which AI tools are configured in the project (by looking for marker files such as `.cursor/`, `.windsurfrules`, `CLAUDE.md`, `.continue/`, etc.) and installs the rules for each.
|
|
191
|
+
|
|
192
|
+
When no `--scope` flag is given, the CLI prompts you to choose where to install:
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
Where should PureContext be installed?
|
|
196
|
+
1) Local — this project only
|
|
197
|
+
2) Global — all projects (user-level config)
|
|
198
|
+
3) Both
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Pass `--scope` to skip the prompt:
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
npx purecontext-mcp install all --scope=local # this project only
|
|
205
|
+
npx purecontext-mcp install all --scope=global # user-level, all projects
|
|
206
|
+
npx purecontext-mcp install all --scope=both # both places at once
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
For a single tool:
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
npx purecontext-mcp install cursor --scope=global
|
|
213
|
+
npx purecontext-mcp install windsurf
|
|
214
|
+
npx purecontext-mcp install continue
|
|
215
|
+
# ...etc.
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Useful flags:
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
npx purecontext-mcp install --list # show detection state, write nothing
|
|
222
|
+
npx purecontext-mcp install all --dry-run # preview which writers would run
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### Supported tools
|
|
226
|
+
|
|
227
|
+
| Tool | Local | Global | Notes |
|
|
228
|
+
|------|-------|--------|-------|
|
|
229
|
+
| `claude` | `CLAUDE.md` in project | `~/.claude/CLAUDE.md` + hooks | Global installs PostToolUse re-index, PreCompact snapshot, and edit guard. |
|
|
230
|
+
| `cursor` | `.cursor/rules/purecontext.mdc` | `~/.cursor/rules/purecontext.mdc` | MDC frontmatter with `alwaysApply: true`. |
|
|
231
|
+
| `windsurf` | `.windsurfrules` | `~/.windsurfrules` | Marked block appended or replaced in place. |
|
|
232
|
+
| `continue` | `.continue/config.json` | `~/.continue/config.json` | JSON-aware merge; other fields are preserved. |
|
|
233
|
+
| `cline` | `.clinerules` | local only | No known global config path. |
|
|
234
|
+
| `roo-code` | `.roo/rules-code.md` | local only | No known global config path. |
|
|
235
|
+
| `vscode` | `.github/copilot-instructions.md` | local only | Picked up by GitHub Copilot in VS Code. |
|
|
236
|
+
| `claude-desktop` | always global | always global | Merges MCP server entry; leaves other servers untouched. |
|
|
237
|
+
|
|
238
|
+
### Idempotency
|
|
239
|
+
|
|
240
|
+
Every writer is safe to re-run. The Markdown writers wrap their content in HTML comment markers:
|
|
241
|
+
|
|
242
|
+
```html
|
|
243
|
+
<!-- purecontext-mcp-start -->
|
|
244
|
+
... PureContext workflow rules ...
|
|
245
|
+
<!-- purecontext-mcp-end -->
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
On re-run, the marked block is replaced in place. Anything outside the markers (your own rules, other tools' rules) is preserved. The JSON writers (`continue`, `claude-desktop`) parse and merge structurally rather than re-emitting the whole file.
|
|
249
|
+
|
|
250
|
+
### Manual install (if you'd rather paste)
|
|
251
|
+
|
|
252
|
+
The two source-of-truth files are at the repository root:
|
|
253
|
+
|
|
254
|
+
- **`AGENT_INSTRUCTIONS_SHORT.md`** — Compact (~2 KB). Mandatory first step, tool selection table, core rules, common usage patterns. Use for agents with limited system prompt space.
|
|
255
|
+
- **`AGENT_INSTRUCTIONS.md`** — Full (~15 KB). Adds parameter notes, every usage pattern, known limitations, decision trees, anti-patterns. Use for complex multi-step workflows.
|
|
256
|
+
|
|
257
|
+
To use these manually:
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
# Claude Code
|
|
261
|
+
cat AGENT_INSTRUCTIONS_SHORT.md >> CLAUDE.md
|
|
262
|
+
|
|
263
|
+
# Cursor — paste into .cursorrules or via Cursor Settings → Rules
|
|
264
|
+
# Windsurf — paste into .windsurfrules or workspace memory
|
|
265
|
+
# Anything else — paste into whatever rule/memory config it supports
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## Verifying the installation
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
purecontext-mcp --version
|
|
274
|
+
# 1.x.x
|
|
275
|
+
|
|
276
|
+
purecontext-mcp config --check
|
|
277
|
+
# ✓ Node.js 20.11.0
|
|
278
|
+
# ✓ SQLite (better-sqlite3 9.x)
|
|
279
|
+
# ✓ Grammar: tree-sitter-typescript.wasm
|
|
280
|
+
# ✓ Grammar: tree-sitter-javascript.wasm
|
|
281
|
+
# ... (all 34 grammars)
|
|
282
|
+
# ✓ Config: ~/.purecontext/config.json
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
`config --check` validates the installation, verifies all grammar files are present, and reports the effective configuration.
|
|
286
|
+
|
|
287
|
+
## Upgrading
|
|
288
|
+
|
|
289
|
+
Run the command that matches how you installed PureContext:
|
|
290
|
+
|
|
291
|
+
**Installed with Volta:**
|
|
292
|
+
```bash
|
|
293
|
+
volta install purecontext-mcp
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
**Installed with npm globally:**
|
|
297
|
+
```bash
|
|
298
|
+
npm install -g purecontext-mcp@latest
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
**Running via npx (no global install):** npx may serve a cached older version. Force the latest:
|
|
302
|
+
```bash
|
|
303
|
+
npx purecontext-mcp@latest
|
|
304
|
+
```
|
|
305
|
+
To always get the latest version automatically, use `purecontext-mcp@latest` in your MCP client config instead of the bare package name.
|
|
306
|
+
|
|
307
|
+
**Installed from source:**
|
|
308
|
+
```bash
|
|
309
|
+
cd /path/to/purecontext-mcp
|
|
310
|
+
git pull
|
|
311
|
+
npm install
|
|
312
|
+
npm run build
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
> **Note:** `npm update -g purecontext-mcp` does not work reliably — use `npm install -g purecontext-mcp@latest` instead.
|
|
316
|
+
|
|
317
|
+
Index files (SQLite databases) are forward-compatible within a major version. After upgrading from `1.x` to `1.y`, existing indexes continue to work. A major version upgrade (e.g., `1.x` → `2.0`) may require a re-index — the CLI will warn if it detects an incompatible index version.
|
|
318
|
+
|
|
319
|
+
## Install from source
|
|
320
|
+
|
|
321
|
+
Use this when contributing, testing unreleased features, or running a local build.
|
|
322
|
+
|
|
323
|
+
```bash
|
|
324
|
+
git clone <repository-url> purecontext-mcp
|
|
325
|
+
cd purecontext-mcp
|
|
326
|
+
npm install
|
|
327
|
+
npm run build
|
|
328
|
+
npm link # makes 'purecontext-mcp' available globally from this build
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
## Uninstalling
|
|
332
|
+
|
|
333
|
+
```bash
|
|
334
|
+
npm uninstall -g purecontext-mcp
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
This removes the binaries. Index files and configuration are not removed. To clean everything up:
|
|
338
|
+
|
|
339
|
+
```bash
|
|
340
|
+
rm -rf ~/.purecontext # Removes indexes, config, savings stats
|
|
341
|
+
```
|