codebase-context 1.6.1 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +282 -262
- package/dist/analyzers/angular/index.d.ts +4 -0
- package/dist/analyzers/angular/index.d.ts.map +1 -1
- package/dist/analyzers/angular/index.js +44 -8
- package/dist/analyzers/angular/index.js.map +1 -1
- package/dist/cli.d.ts +6 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +113 -0
- package/dist/cli.js.map +1 -0
- package/dist/core/indexer.d.ts +0 -5
- package/dist/core/indexer.d.ts.map +1 -1
- package/dist/core/indexer.js +12 -46
- package/dist/core/indexer.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +153 -76
- package/dist/index.js.map +1 -1
- package/dist/memory/store.d.ts +3 -0
- package/dist/memory/store.d.ts.map +1 -1
- package/dist/memory/store.js +9 -0
- package/dist/memory/store.js.map +1 -1
- package/dist/patterns/semantics.d.ts +6 -0
- package/dist/patterns/semantics.d.ts.map +1 -1
- package/dist/patterns/semantics.js +22 -6
- package/dist/patterns/semantics.js.map +1 -1
- package/dist/preflight/evidence-lock.d.ts +2 -0
- package/dist/preflight/evidence-lock.d.ts.map +1 -1
- package/dist/preflight/evidence-lock.js +16 -2
- package/dist/preflight/evidence-lock.js.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/dependency-detection.d.ts +2 -1
- package/dist/utils/dependency-detection.d.ts.map +1 -1
- package/dist/utils/dependency-detection.js.map +1 -1
- package/docs/capabilities.md +92 -75
- package/package.json +157 -144
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 PatrickSys
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 PatrickSys
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,262 +1,282 @@
|
|
|
1
|
-
# codebase-context
|
|
2
|
-
|
|
3
|
-
## Local-first second brain for AI Agents working on your codebase
|
|
4
|
-
|
|
5
|
-
[](https://www.npmjs.com/package/codebase-context) [](./LICENSE) [](./package.json)
|
|
6
|
-
|
|
7
|
-
You're tired of AI agents writing code that 'just works' but fits like a square peg in a round hole - not your conventions, not your architecture, not your repo. Even with well-curated instructions. You correct the agent, it doesn't remember. Next session, same mistakes.
|
|
8
|
-
|
|
9
|
-
This MCP gives agents _just enough_ context so they match _how_ your team codes, know _why_, and _remember_ every correction.
|
|
10
|
-
|
|
11
|
-
Here's what codebase-context does:
|
|
12
|
-
|
|
13
|
-
**Finds the right context** - Search that doesn't just return code. Each result comes back with analyzed
|
|
14
|
-
|
|
15
|
-
**Knows your conventions** - Detected from your code, not only from rules you wrote. Seeks team consensus and direction by adoption percentages and trends (rising/declining), golden files.
|
|
16
|
-
|
|
17
|
-
**Remembers across sessions** - Decisions, failures,
|
|
18
|
-
|
|
19
|
-
**Checks before editing** - A preflight card with risk level, patterns to use and avoid, failure warnings, and a `readyToEdit` evidence check. If evidence is thin or contradictory, it says so.
|
|
20
|
-
|
|
21
|
-
One tool call returns all of it. Local-first - your code never leaves your machine.
|
|
22
|
-
|
|
23
|
-
<!-- TODO: Add demo GIF
|
|
24
|
-
<!--  -->
|
|
25
|
-
|
|
26
|
-
## Quick Start
|
|
27
|
-
|
|
28
|
-
Add it to the configuration of your AI Agent of preference:
|
|
29
|
-
|
|
30
|
-
### Claude Code
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
claude mcp add codebase-context -- npx -y codebase-context /path/to/your/project
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
### Claude Desktop
|
|
37
|
-
|
|
38
|
-
Add to `claude_desktop_config.json`:
|
|
39
|
-
|
|
40
|
-
```json
|
|
41
|
-
{
|
|
42
|
-
"mcpServers": {
|
|
43
|
-
"codebase-context": {
|
|
44
|
-
"command": "npx",
|
|
45
|
-
"args": ["-y", "codebase-context", "/path/to/your/project"]
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
### VS Code (Copilot)
|
|
52
|
-
|
|
53
|
-
Add `.vscode/mcp.json` to your project root:
|
|
54
|
-
|
|
55
|
-
```json
|
|
56
|
-
{
|
|
57
|
-
"servers": {
|
|
58
|
-
"codebase-context": {
|
|
59
|
-
"command": "npx",
|
|
60
|
-
"args": ["-y", "codebase-context", "/path/to/your/project"] // Or "${workspaceFolder}"if your workspace is one project only
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
### Cursor
|
|
67
|
-
|
|
68
|
-
Add to `.cursor/mcp.json` in your project:
|
|
69
|
-
|
|
70
|
-
```json
|
|
71
|
-
{
|
|
72
|
-
"mcpServers": {
|
|
73
|
-
"codebase-context": {
|
|
74
|
-
"command": "npx",
|
|
75
|
-
"args": ["-y", "codebase-context", "/path/to/your/project"]
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### Windsurf
|
|
82
|
-
|
|
83
|
-
Open Settings > MCP and add:
|
|
84
|
-
|
|
85
|
-
```json
|
|
86
|
-
{
|
|
87
|
-
"mcpServers": {
|
|
88
|
-
"codebase-context": {
|
|
89
|
-
"command": "npx",
|
|
90
|
-
"args": ["-y", "codebase-context", "/path/to/your/project"]
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
## Codex
|
|
97
|
-
|
|
98
|
-
Run codex mcp add codebase-context npx -y codebase-context "/path/to/your/project"
|
|
99
|
-
|
|
100
|
-
## What It Actually Does
|
|
101
|
-
|
|
102
|
-
Other tools help AI find code. This one helps AI make the right decisions - by knowing what your team does, tracking where codebases are heading, and warning before mistakes happen.
|
|
103
|
-
|
|
104
|
-
### The Difference
|
|
105
|
-
|
|
106
|
-
| Without codebase-context | With codebase-context |
|
|
107
|
-
| ------------------------------------------------------- | --------------------------------------------------- |
|
|
108
|
-
| Generates code using whatever matches or "sounds" right | Generates code following your team conventions |
|
|
109
|
-
| Copies any example that fits | Follows your best implementations (golden files) |
|
|
110
|
-
| Repeats mistakes you already corrected | Surfaces failure memories right before trying again |
|
|
111
|
-
| You re-explain the same things every session | Remembers conventions and decisions automatically |
|
|
112
|
-
| Edits confidently even when context is weak | Flags high-risk changes when evidence is thin |
|
|
113
|
-
| Sees what the current code does and assumes | Sees how your code has evolved and why |
|
|
114
|
-
|
|
115
|
-
### The Search Tool (`search_codebase`)
|
|
116
|
-
|
|
117
|
-
This is where it all comes together. One call returns:
|
|
118
|
-
|
|
119
|
-
- **Code results** with `
|
|
120
|
-
- **
|
|
121
|
-
- **
|
|
122
|
-
- **
|
|
123
|
-
- **
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
"
|
|
136
|
-
"
|
|
137
|
-
"score":
|
|
138
|
-
"
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
|
175
|
-
|
|
|
176
|
-
| `
|
|
177
|
-
| `
|
|
178
|
-
| `
|
|
179
|
-
| `
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
- **
|
|
192
|
-
- **
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
##
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
1
|
+
# codebase-context
|
|
2
|
+
|
|
3
|
+
## Local-first second brain for AI Agents working on your codebase
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/codebase-context) [](./LICENSE) [](./package.json)
|
|
6
|
+
|
|
7
|
+
You're tired of AI agents writing code that 'just works' but fits like a square peg in a round hole - not your conventions, not your architecture, not your repo. Even with well-curated instructions. You correct the agent, it doesn't remember. Next session, same mistakes.
|
|
8
|
+
|
|
9
|
+
This MCP gives agents _just enough_ context so they match _how_ your team codes, know _why_, and _remember_ every correction.
|
|
10
|
+
|
|
11
|
+
Here's what codebase-context does:
|
|
12
|
+
|
|
13
|
+
**Finds the right context** - Search that doesn't just return code. Each result comes back with analyzed and quantified coding patterns and conventions, related team memories, file relationships, and quality indicators. It knows whether you're looking for a specific file, a concept, or how things wire together - and filters out the noise (test files, configs, old utilities) before the agent sees them. The agent gets curated context, not raw hits.
|
|
14
|
+
|
|
15
|
+
**Knows your conventions** - Detected from your code and git history, not only from rules you wrote. Seeks team consensus and direction by adoption percentages and trends (rising/declining), golden files. Tells the difference between code that's _common_ and code that's _current_ - what patterns the team is moving toward and what's being left behind.
|
|
16
|
+
|
|
17
|
+
**Remembers across sessions** - Decisions, failures, workarounds that look wrong but exist for a reason - the battle scars that aren't in the comments. Recorded once, surfaced automatically so the agent doesn't "clean up" something you spent a week getting right. Conventional git commits (`refactor:`, `migrate:`, `fix:`) auto-extract into memory with zero effort. Stale memories decay and get flagged instead of blindly trusted.
|
|
18
|
+
|
|
19
|
+
**Checks before editing** - A preflight card with risk level, patterns to use and avoid, failure warnings, and a `readyToEdit` evidence check. Catches the "confidently wrong" problem: when code, team memories, and patterns contradict each other, it tells the agent to ask instead of guess. If evidence is thin or contradictory, it says so.
|
|
20
|
+
|
|
21
|
+
One tool call returns all of it. Local-first - your code never leaves your machine.
|
|
22
|
+
|
|
23
|
+
<!-- TODO: Add demo GIF: search_codebase("How does this app attach the auth token to outgoing API calls?") → AuthInterceptor top result + preflight + agent proceeds or asks -->
|
|
24
|
+
<!--  -->
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
27
|
+
|
|
28
|
+
Add it to the configuration of your AI Agent of preference:
|
|
29
|
+
|
|
30
|
+
### Claude Code
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
claude mcp add codebase-context -- npx -y codebase-context /path/to/your/project
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Claude Desktop
|
|
37
|
+
|
|
38
|
+
Add to `claude_desktop_config.json`:
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"mcpServers": {
|
|
43
|
+
"codebase-context": {
|
|
44
|
+
"command": "npx",
|
|
45
|
+
"args": ["-y", "codebase-context", "/path/to/your/project"]
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### VS Code (Copilot)
|
|
52
|
+
|
|
53
|
+
Add `.vscode/mcp.json` to your project root:
|
|
54
|
+
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"servers": {
|
|
58
|
+
"codebase-context": {
|
|
59
|
+
"command": "npx",
|
|
60
|
+
"args": ["-y", "codebase-context", "/path/to/your/project"] // Or "${workspaceFolder}"if your workspace is one project only
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Cursor
|
|
67
|
+
|
|
68
|
+
Add to `.cursor/mcp.json` in your project:
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"mcpServers": {
|
|
73
|
+
"codebase-context": {
|
|
74
|
+
"command": "npx",
|
|
75
|
+
"args": ["-y", "codebase-context", "/path/to/your/project"]
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Windsurf
|
|
82
|
+
|
|
83
|
+
Open Settings > MCP and add:
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"mcpServers": {
|
|
88
|
+
"codebase-context": {
|
|
89
|
+
"command": "npx",
|
|
90
|
+
"args": ["-y", "codebase-context", "/path/to/your/project"]
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Codex
|
|
97
|
+
|
|
98
|
+
Run codex mcp add codebase-context npx -y codebase-context "/path/to/your/project"
|
|
99
|
+
|
|
100
|
+
## What It Actually Does
|
|
101
|
+
|
|
102
|
+
Other tools help AI find code. This one helps AI make the right decisions - by knowing what your team does, tracking where codebases are heading, and warning before mistakes happen.
|
|
103
|
+
|
|
104
|
+
### The Difference
|
|
105
|
+
|
|
106
|
+
| Without codebase-context | With codebase-context |
|
|
107
|
+
| ------------------------------------------------------- | --------------------------------------------------- |
|
|
108
|
+
| Generates code using whatever matches or "sounds" right | Generates code following your team conventions |
|
|
109
|
+
| Copies any example that fits | Follows your best implementations (golden files) |
|
|
110
|
+
| Repeats mistakes you already corrected | Surfaces failure memories right before trying again |
|
|
111
|
+
| You re-explain the same things every session | Remembers conventions and decisions automatically |
|
|
112
|
+
| Edits confidently even when context is weak | Flags high-risk changes when evidence is thin |
|
|
113
|
+
| Sees what the current code does and assumes | Sees how your code has evolved and why |
|
|
114
|
+
|
|
115
|
+
### The Search Tool (`search_codebase`)
|
|
116
|
+
|
|
117
|
+
This is where it all comes together. One call returns:
|
|
118
|
+
|
|
119
|
+
- **Code results** with `file` (path + line range), `summary`, `score`
|
|
120
|
+
- **Type** per result: compact `componentType:layer` (e.g., `service:data`) — helps agents orient
|
|
121
|
+
- **Pattern signals** per result: `trend` (Rising/Declining — Stable is omitted) and `patternWarning` when using legacy code
|
|
122
|
+
- **Relationships** per result: `importedByCount` and `hasTests` (condensed)
|
|
123
|
+
- **Related memories**: up to 3 team decisions, gotchas, and failures matched to the query
|
|
124
|
+
- **Search quality**: `ok` or `low_confidence` with confidence score and `hint` when low
|
|
125
|
+
- **Preflight**: `ready` (boolean) + `reason` when evidence is thin. Pass `intent="edit"` to get the full preflight card. If search quality is low, `ready` is always `false`.
|
|
126
|
+
|
|
127
|
+
Snippets are opt-in (`includeSnippets: true`). Default output is lean — if the agent wants code, it calls `read_file`.
|
|
128
|
+
|
|
129
|
+
```json
|
|
130
|
+
{
|
|
131
|
+
"searchQuality": { "status": "ok", "confidence": 0.72 },
|
|
132
|
+
"preflight": { "ready": true },
|
|
133
|
+
"results": [
|
|
134
|
+
{
|
|
135
|
+
"file": "src/auth/auth.interceptor.ts:1-20",
|
|
136
|
+
"summary": "HTTP interceptor that attaches auth token to outgoing requests",
|
|
137
|
+
"score": 0.72,
|
|
138
|
+
"type": "service:core",
|
|
139
|
+
"trend": "Rising",
|
|
140
|
+
"relationships": { "importedByCount": 4, "hasTests": true }
|
|
141
|
+
}
|
|
142
|
+
],
|
|
143
|
+
"relatedMemories": ["Always use HttpInterceptorFn (0.97)"]
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Lean enough to fit on one screen. If search quality is low, preflight blocks edits instead of faking confidence.
|
|
148
|
+
|
|
149
|
+
### Patterns & Conventions (`get_team_patterns`)
|
|
150
|
+
|
|
151
|
+
Detects what your team actually does by analyzing the codebase:
|
|
152
|
+
|
|
153
|
+
- Adoption percentages for dependency injection, state management, testing, libraries
|
|
154
|
+
- Patterns/conventions trend direction (Rising / Stable / Declining) based on git recency
|
|
155
|
+
- Golden files - your best implementations ranked by modern pattern density
|
|
156
|
+
- Conflicts - when the team hasn't converged (both approaches above 20% adoption)
|
|
157
|
+
|
|
158
|
+
### Team Memory (`remember` + `get_memory`)
|
|
159
|
+
|
|
160
|
+
Record a decision once. It surfaces automatically in search results and preflight cards from then on. **Your git commits also become memories** - conventional commits like `refactor:`, `migrate:`, `fix:`, `revert:` from the last 90 days are auto-extracted during indexing.
|
|
161
|
+
|
|
162
|
+
- **Types**: conventions (style rules), decisions (architecture choices), gotchas (things that break), failures (we tried X, it broke because Y)
|
|
163
|
+
- **Confidence decay**: decisions age over 180 days, gotchas and failures over 90 days. Stale memories get flagged instead of blindly trusted.
|
|
164
|
+
- **Zero-config git extraction**: runs automatically during `refresh_index`. No setup, no manual work.
|
|
165
|
+
|
|
166
|
+
### All Tools
|
|
167
|
+
|
|
168
|
+
| Tool | What it does |
|
|
169
|
+
| ------------------------------ | -------------------------------------------------------------------------------- |
|
|
170
|
+
| `search_codebase` | Hybrid search with enrichment + preflight. Pass `intent="edit"` for edit readiness check. |
|
|
171
|
+
| `get_team_patterns` | Pattern frequencies, golden files, conflict detection |
|
|
172
|
+
| `get_component_usage` | "Find Usages" - where a library or component is imported |
|
|
173
|
+
| `remember` | Record a convention, decision, gotcha, or failure |
|
|
174
|
+
| `get_memory` | Query team memory with confidence decay scoring |
|
|
175
|
+
| `get_codebase_metadata` | Project structure, frameworks, dependencies |
|
|
176
|
+
| `get_style_guide` | Style guide rules for the current project |
|
|
177
|
+
| `detect_circular_dependencies` | Import cycles between files |
|
|
178
|
+
| `refresh_index` | Re-index (full or incremental) + extract git memories |
|
|
179
|
+
| `get_indexing_status` | Progress and stats for the current index |
|
|
180
|
+
|
|
181
|
+
## How the Search Works
|
|
182
|
+
|
|
183
|
+
The retrieval pipeline is designed around one goal: give the agent the right context, not just any file that matches.
|
|
184
|
+
|
|
185
|
+
- **Intent classification** - knows whether "AuthService" is a name lookup or "how does auth work" is conceptual. Adjusts keyword/semantic weights accordingly.
|
|
186
|
+
- **Hybrid fusion (RRF)** - combines keyword and semantic search using Reciprocal Rank Fusion instead of brittle score averaging.
|
|
187
|
+
- **Query expansion** - conceptual queries automatically expand with domain-relevant terms (auth → login, token, session, guard).
|
|
188
|
+
- **Contamination control** - test files are filtered/demoted for non-test queries.
|
|
189
|
+
- **Import centrality** - files that are imported more often rank higher.
|
|
190
|
+
- **Cross-encoder reranking** - a stage-2 reranker triggers only when top scores are ambiguous. CPU-only, bounded to top-K.
|
|
191
|
+
- **Incremental indexing** - only re-indexes files that changed since last run (SHA-256 manifest diffing).
|
|
192
|
+
- **Auto-heal** - if the index corrupts, search triggers a full re-index automatically.
|
|
193
|
+
|
|
194
|
+
## Language Support
|
|
195
|
+
|
|
196
|
+
Over **30+ languages** are supported: TypeScript, JavaScript, Python, Java, Kotlin, C/C++, C#, Go, Rust, PHP, Ruby, Swift, Scala, Shell, and common config/markup formats.
|
|
197
|
+
However right now only **Angular** has a specific analyzer for enriched context (signals, standalone components, control flow, DI patterns).
|
|
198
|
+
If you need enriched context from any language or framework, please file an issue - or even better, contribute with a new analyzer
|
|
199
|
+
|
|
200
|
+
Structured filters available: `framework`, `language`, `componentType`, `layer` (presentation, business, data, state, core, shared).
|
|
201
|
+
|
|
202
|
+
## Configuration
|
|
203
|
+
|
|
204
|
+
| Variable | Default | Description |
|
|
205
|
+
| ------------------------ | -------------- | --------------------------------------------------------- |
|
|
206
|
+
| `EMBEDDING_PROVIDER` | `transformers` | `openai` (fast, cloud) or `transformers` (local, private) |
|
|
207
|
+
| `OPENAI_API_KEY` | - | Required only if using `openai` provider |
|
|
208
|
+
| `CODEBASE_ROOT` | - | Project root (CLI arg takes precedence) |
|
|
209
|
+
| `CODEBASE_CONTEXT_DEBUG` | - | Set to `1` for verbose logging |
|
|
210
|
+
|
|
211
|
+
## Performance
|
|
212
|
+
|
|
213
|
+
- **First indexing**: 2-5 minutes for ~30k files (embedding computation).
|
|
214
|
+
- **Subsequent queries**: milliseconds from cache.
|
|
215
|
+
- **Incremental updates**: `refresh_index` with `incrementalOnly: true` processes only changed files (SHA-256 manifest diffing).
|
|
216
|
+
|
|
217
|
+
## File Structure
|
|
218
|
+
|
|
219
|
+
```
|
|
220
|
+
.codebase-context/
|
|
221
|
+
memory.json # Team knowledge (should be persisted in git)
|
|
222
|
+
intelligence.json # Pattern analysis (generated)
|
|
223
|
+
index.json # Keyword index (generated)
|
|
224
|
+
index/ # Vector database (generated)
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
**Recommended `.gitignore`:**
|
|
228
|
+
|
|
229
|
+
```gitignore
|
|
230
|
+
# Codebase Context - ignore generated files, keep memory
|
|
231
|
+
.codebase-context/*
|
|
232
|
+
!.codebase-context/memory.json
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## CLI Access (Vendor-Neutral)
|
|
236
|
+
|
|
237
|
+
You can manage team memory directly from the terminal without any AI agent:
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
# List all memories
|
|
241
|
+
npx codebase-context memory list
|
|
242
|
+
|
|
243
|
+
# Filter by category or type
|
|
244
|
+
npx codebase-context memory list --category conventions --type convention
|
|
245
|
+
|
|
246
|
+
# Search memories
|
|
247
|
+
npx codebase-context memory list --query "auth"
|
|
248
|
+
|
|
249
|
+
# Add a memory
|
|
250
|
+
npx codebase-context memory add --type convention --category tooling --memory "Use pnpm, not npm" --reason "Workspace support and speed"
|
|
251
|
+
|
|
252
|
+
# Remove a memory
|
|
253
|
+
npx codebase-context memory remove <id>
|
|
254
|
+
|
|
255
|
+
# JSON output for scripting
|
|
256
|
+
npx codebase-context memory list --json
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
Set `CODEBASE_ROOT` to point to your project, or run from the project directory.
|
|
260
|
+
|
|
261
|
+
## Tip: Ensuring your AI Agent recalls memory:
|
|
262
|
+
|
|
263
|
+
Add this to `.cursorrules`, `CLAUDE.md`, or `AGENTS.md`:
|
|
264
|
+
|
|
265
|
+
```
|
|
266
|
+
## Codebase Context
|
|
267
|
+
|
|
268
|
+
**At start of each task:** Call `get_memory` to load team conventions.
|
|
269
|
+
|
|
270
|
+
**When user says "remember this" or "record this":**
|
|
271
|
+
- Call `remember` tool IMMEDIATELY before doing anything else.
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
## Links
|
|
275
|
+
|
|
276
|
+
- [Motivation](./MOTIVATION.md) - Research and design rationale
|
|
277
|
+
- [Changelog](./CHANGELOG.md) - Version history
|
|
278
|
+
- [Contributing](./CONTRIBUTING.md) - How to add analyzers
|
|
279
|
+
|
|
280
|
+
## License
|
|
281
|
+
|
|
282
|
+
MIT
|
|
@@ -9,6 +9,7 @@ export declare class AngularAnalyzer implements FrameworkAnalyzer {
|
|
|
9
9
|
readonly version = "1.0.0";
|
|
10
10
|
readonly supportedExtensions: string[];
|
|
11
11
|
readonly priority = 100;
|
|
12
|
+
constructor();
|
|
12
13
|
private angularPatterns;
|
|
13
14
|
private stateManagementPatterns;
|
|
14
15
|
private modernAngularPatterns;
|
|
@@ -40,5 +41,8 @@ export declare class AngularAnalyzer implements FrameworkAnalyzer {
|
|
|
40
41
|
private detectGuardType;
|
|
41
42
|
private extractFirstComment;
|
|
42
43
|
private extractFirstLine;
|
|
44
|
+
/** Angular-specific regex patterns for extracting code snippets per detected pattern */
|
|
45
|
+
private static readonly SNIPPET_PATTERNS;
|
|
46
|
+
getSnippetPattern(category: string, name: string): RegExp | null;
|
|
43
47
|
}
|
|
44
48
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/analyzers/angular/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,SAAS,EAKV,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/analyzers/angular/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,SAAS,EAKV,MAAM,sBAAsB,CAAC;AAS9B,qBAAa,eAAgB,YAAW,iBAAiB;IACvD,QAAQ,CAAC,IAAI,aAAa;IAC1B,QAAQ,CAAC,OAAO,WAAW;IAC3B,QAAQ,CAAC,mBAAmB,WAA8D;IAC1F,QAAQ,CAAC,QAAQ,OAAO;;IAQxB,OAAO,CAAC,eAAe,CAYrB;IAEF,OAAO,CAAC,uBAAuB,CAM7B;IAEF,OAAO,CAAC,qBAAqB,CAa3B;IAEF,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO;IAqBjD,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;YA0B3D,qBAAqB;IAuNnC;;OAEG;IACH,OAAO,CAAC,2BAA2B;YAYrB,uBAAuB;IAmHrC,OAAO,CAAC,wBAAwB;IAgChC,OAAO,CAAC,qBAAqB;IA2B7B,OAAO,CAAC,uBAAuB;IAqB/B,OAAO,CAAC,aAAa;IA4CrB,OAAO,CAAC,cAAc;YAyCR,mBAAmB;YAiCnB,gBAAgB;IAwB9B,OAAO,CAAC,qBAAqB;IAS7B,OAAO,CAAC,cAAc;IA0DtB,OAAO,CAAC,oBAAoB;IA2BtB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAwJzE;;OAEG;IACH,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM;IA2FnC,OAAO,CAAC,uBAAuB;IAY/B,OAAO,CAAC,oBAAoB;IAU5B,OAAO,CAAC,eAAe;IAQvB,OAAO,CAAC,mBAAmB;IAK3B,OAAO,CAAC,gBAAgB;IAOxB,wFAAwF;IACxF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAqBtC;IAEF,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;CAGjE"}
|