codebase-context 1.2.2 → 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.
Files changed (131) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +292 -87
  3. package/dist/analyzers/angular/index.d.ts +1 -1
  4. package/dist/analyzers/angular/index.d.ts.map +1 -1
  5. package/dist/analyzers/angular/index.js +298 -309
  6. package/dist/analyzers/angular/index.js.map +1 -1
  7. package/dist/analyzers/generic/index.d.ts +1 -2
  8. package/dist/analyzers/generic/index.d.ts.map +1 -1
  9. package/dist/analyzers/generic/index.js +93 -60
  10. package/dist/analyzers/generic/index.js.map +1 -1
  11. package/dist/constants/codebase-context.d.ts +8 -0
  12. package/dist/constants/codebase-context.d.ts.map +1 -0
  13. package/dist/constants/codebase-context.js +10 -0
  14. package/dist/constants/codebase-context.js.map +1 -0
  15. package/dist/constants/git-patterns.d.ts +12 -0
  16. package/dist/constants/git-patterns.d.ts.map +1 -0
  17. package/dist/constants/git-patterns.js +11 -0
  18. package/dist/constants/git-patterns.js.map +1 -0
  19. package/dist/core/analyzer-registry.d.ts.map +1 -1
  20. package/dist/core/analyzer-registry.js +8 -8
  21. package/dist/core/analyzer-registry.js.map +1 -1
  22. package/dist/core/indexer.d.ts +11 -1
  23. package/dist/core/indexer.d.ts.map +1 -1
  24. package/dist/core/indexer.js +359 -157
  25. package/dist/core/indexer.js.map +1 -1
  26. package/dist/core/manifest.d.ts +39 -0
  27. package/dist/core/manifest.d.ts.map +1 -0
  28. package/dist/core/manifest.js +86 -0
  29. package/dist/core/manifest.js.map +1 -0
  30. package/dist/core/search-quality.d.ts +10 -0
  31. package/dist/core/search-quality.d.ts.map +1 -0
  32. package/dist/core/search-quality.js +64 -0
  33. package/dist/core/search-quality.js.map +1 -0
  34. package/dist/core/search.d.ts +17 -1
  35. package/dist/core/search.d.ts.map +1 -1
  36. package/dist/core/search.js +303 -104
  37. package/dist/core/search.js.map +1 -1
  38. package/dist/embeddings/openai.d.ts.map +1 -1
  39. package/dist/embeddings/openai.js +2 -2
  40. package/dist/embeddings/openai.js.map +1 -1
  41. package/dist/embeddings/transformers.d.ts +1 -1
  42. package/dist/embeddings/transformers.d.ts.map +1 -1
  43. package/dist/embeddings/transformers.js +19 -15
  44. package/dist/embeddings/transformers.js.map +1 -1
  45. package/dist/embeddings/types.d.ts +1 -1
  46. package/dist/embeddings/types.d.ts.map +1 -1
  47. package/dist/embeddings/types.js +3 -3
  48. package/dist/embeddings/types.js.map +1 -1
  49. package/dist/errors/index.d.ts +8 -0
  50. package/dist/errors/index.d.ts.map +1 -0
  51. package/dist/errors/index.js +11 -0
  52. package/dist/errors/index.js.map +1 -0
  53. package/dist/index.d.ts +7 -29
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/index.js +1125 -362
  56. package/dist/index.js.map +1 -1
  57. package/dist/lib.d.ts +18 -18
  58. package/dist/lib.d.ts.map +1 -1
  59. package/dist/lib.js +23 -23
  60. package/dist/lib.js.map +1 -1
  61. package/dist/memory/git-memory.d.ts +9 -0
  62. package/dist/memory/git-memory.d.ts.map +1 -0
  63. package/dist/memory/git-memory.js +51 -0
  64. package/dist/memory/git-memory.js.map +1 -0
  65. package/dist/memory/store.d.ts +38 -0
  66. package/dist/memory/store.d.ts.map +1 -0
  67. package/dist/memory/store.js +136 -0
  68. package/dist/memory/store.js.map +1 -0
  69. package/dist/patterns/semantics.d.ts +4 -0
  70. package/dist/patterns/semantics.d.ts.map +1 -0
  71. package/dist/patterns/semantics.js +24 -0
  72. package/dist/patterns/semantics.js.map +1 -0
  73. package/dist/preflight/evidence-lock.d.ts +50 -0
  74. package/dist/preflight/evidence-lock.d.ts.map +1 -0
  75. package/dist/preflight/evidence-lock.js +130 -0
  76. package/dist/preflight/evidence-lock.js.map +1 -0
  77. package/dist/preflight/query-scope.d.ts +3 -0
  78. package/dist/preflight/query-scope.d.ts.map +1 -0
  79. package/dist/preflight/query-scope.js +40 -0
  80. package/dist/preflight/query-scope.js.map +1 -0
  81. package/dist/resources/uri.d.ts +5 -0
  82. package/dist/resources/uri.d.ts.map +1 -0
  83. package/dist/resources/uri.js +15 -0
  84. package/dist/resources/uri.js.map +1 -0
  85. package/dist/storage/lancedb.d.ts +1 -0
  86. package/dist/storage/lancedb.d.ts.map +1 -1
  87. package/dist/storage/lancedb.js +51 -34
  88. package/dist/storage/lancedb.js.map +1 -1
  89. package/dist/storage/types.d.ts +5 -0
  90. package/dist/storage/types.d.ts.map +1 -1
  91. package/dist/storage/types.js +2 -1
  92. package/dist/storage/types.js.map +1 -1
  93. package/dist/types/index.d.ts +47 -0
  94. package/dist/types/index.d.ts.map +1 -1
  95. package/dist/types/index.js +1 -0
  96. package/dist/types/index.js.map +1 -1
  97. package/dist/utils/chunking.d.ts.map +1 -1
  98. package/dist/utils/chunking.js +10 -9
  99. package/dist/utils/chunking.js.map +1 -1
  100. package/dist/utils/dependency-detection.d.ts +18 -0
  101. package/dist/utils/dependency-detection.d.ts.map +1 -0
  102. package/dist/utils/dependency-detection.js +102 -0
  103. package/dist/utils/dependency-detection.js.map +1 -0
  104. package/dist/utils/git-dates.d.ts +1 -0
  105. package/dist/utils/git-dates.d.ts.map +1 -1
  106. package/dist/utils/git-dates.js +23 -3
  107. package/dist/utils/git-dates.js.map +1 -1
  108. package/dist/utils/language-detection.d.ts.map +1 -1
  109. package/dist/utils/language-detection.js +69 -17
  110. package/dist/utils/language-detection.js.map +1 -1
  111. package/dist/utils/usage-tracker.d.ts +2 -2
  112. package/dist/utils/usage-tracker.d.ts.map +1 -1
  113. package/dist/utils/usage-tracker.js +67 -38
  114. package/dist/utils/usage-tracker.js.map +1 -1
  115. package/dist/utils/workspace-detection.d.ts +32 -0
  116. package/dist/utils/workspace-detection.d.ts.map +1 -0
  117. package/dist/utils/workspace-detection.js +107 -0
  118. package/dist/utils/workspace-detection.js.map +1 -0
  119. package/package.json +122 -97
  120. package/dist/core/file-watcher.d.ts +0 -63
  121. package/dist/core/file-watcher.d.ts.map +0 -1
  122. package/dist/core/file-watcher.js +0 -210
  123. package/dist/core/file-watcher.js.map +0 -1
  124. package/dist/utils/logger.d.ts +0 -36
  125. package/dist/utils/logger.d.ts.map +0 -1
  126. package/dist/utils/logger.js +0 -111
  127. package/dist/utils/logger.js.map +0 -1
  128. package/dist/utils/pattern-detector.d.ts +0 -41
  129. package/dist/utils/pattern-detector.d.ts.map +0 -1
  130. package/dist/utils/pattern-detector.js +0 -101
  131. package/dist/utils/pattern-detector.js.map +0 -1
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,87 +1,292 @@
1
- # codebase-context
2
-
3
- **AI coding agents don't know your codebase. This MCP fixes that.**
4
-
5
- Your team has internal libraries, naming conventions, and patterns that external AI models have never seen. This MCP server gives AI assistants real-time visibility into your codebase: which libraries your team actually uses, how often, and where to find canonical examples.
6
-
7
- ## Quick Start
8
-
9
- Add this to your MCP client config (Claude Desktop, VS Code, Cursor, etc.).
10
-
11
- ```json
12
- "mcpServers": {
13
- "codebase-context": {
14
- "command": "npx",
15
- "args": ["codebase-context", "/path/to/your/project"]
16
- }
17
- }
18
- ```
19
-
20
- ## What You Get
21
-
22
- - **Internal library discovery** → `@mycompany/ui-toolkit`: 847 uses vs `primeng`: 3 uses
23
- - **Pattern frequencies** → `inject()`: 97%, `constructor()`: 3%
24
- - **Pattern momentum** → `Signals`: Rising (last used 2 days ago) vs `RxJS`: Declining (180+ days)
25
- - **Golden file examples** → Real implementations showing all patterns together
26
- - **Testing conventions** `Jest`: 74%, `Playwright`: 6%
27
- - **Framework patterns** → Angular signals, standalone components, etc.
28
- - **Circular dependency detection** → Find toxic import cycles between files
29
-
30
-
31
- ## How It Works
32
-
33
- When generating code, the agent checks your patterns first:
34
-
35
- | Without MCP | With MCP |
36
- |-------------|----------|
37
- | Uses `constructor(private svc: Service)` | Uses `inject()` (97% team adoption) |
38
- | Suggests `primeng/button` directly | Uses `@codeblue/prime` wrapper |
39
- | Generic Jest setup | Your team's actual test utilities |
40
-
41
- ### Tip: Auto-invoke in your rules
42
-
43
- Add this to your `.cursorrules`, `CLAUDE.md`, or `AGENTS.md`:
44
-
45
- ```
46
- When generating or reviewing code, use codebase-context tools to check team patterns first.
47
- ```
48
-
49
- Now the agent checks patterns automatically instead of waiting for you to ask.
50
-
51
- ## Tools
52
-
53
- | Tool | Purpose |
54
- |------|---------|
55
- | `search_codebase` | Semantic + keyword hybrid search |
56
- | `get_component_usage` | Find where a library/component is used |
57
- | `get_team_patterns` | Pattern frequencies + canonical examples |
58
- | `get_codebase_metadata` | Project structure overview |
59
- | `get_style_guide` | Query style guide rules |
60
- | `detect_circular_dependencies` | Find import cycles between files |
61
- | `refresh_index` | Re-index the codebase |
62
-
63
-
64
- ## Configuration
65
-
66
- | Variable | Default | Description |
67
- |----------|---------|-------------|
68
- | `EMBEDDING_PROVIDER` | `transformers` | `openai` (fast, cloud) or `transformers` (local, private) |
69
- | `OPENAI_API_KEY` | - | Required if provider is `openai` |
70
- | `CODEBASE_CONTEXT_DEBUG` | - | Set to `1` to enable verbose logging (startup messages, analyzer registration) |
71
-
72
- ## Performance Note
73
-
74
- This tool runs **locally** on your machine using your hardware.
75
- - **Initial Indexing**: The first run works hard. It may take several minutes (e.g., ~2-5 mins for 30k files) to compute embeddings for your entire codebase.
76
- - **Caching**: Subsequent queries are instant (milliseconds).
77
- - **Updates**: Currently, `refresh_index` re-scans the codebase. True incremental indexing (processing only changed files) is on the roadmap.
78
-
79
- ## Links
80
-
81
- - 📄 [Motivation](./MOTIVATION.md) — Why this exists, research, learnings
82
- - 📋 [Changelog](./CHANGELOG.md) — Version history
83
- - 🤝 [Contributing](./CONTRIBUTING.md) How to add analyzers
84
-
85
- ## License
86
-
87
- MIT
1
+ # codebase-context
2
+
3
+ [![npm version](https://img.shields.io/npm/v/codebase-context)](https://www.npmjs.com/package/codebase-context) [![license](https://img.shields.io/npm/l/codebase-context)](./LICENSE) [![node](https://img.shields.io/node/v/codebase-context)](./package.json)
4
+
5
+ A second brain for AI coding agents. MCP server that remembers team decisions, tracks pattern evolution, and guides every edit with evidence.
6
+
7
+ ## Quick Start
8
+
9
+ ### Claude Desktop
10
+
11
+ Add to `claude_desktop_config.json`:
12
+
13
+ ```json
14
+ {
15
+ "mcpServers": {
16
+ "codebase-context": {
17
+ "command": "npx",
18
+ "args": ["-y", "codebase-context", "/path/to/your/project"]
19
+ }
20
+ }
21
+ }
22
+ ```
23
+
24
+ ### VS Code (Copilot)
25
+
26
+ Add `.vscode/mcp.json` to your project root:
27
+
28
+ ```json
29
+ {
30
+ "servers": {
31
+ "codebase-context": {
32
+ "command": "npx",
33
+ "args": ["-y", "codebase-context", "${workspaceFolder}"]
34
+ }
35
+ }
36
+ }
37
+ ```
38
+
39
+ ### Cursor
40
+
41
+ Add to `.cursor/mcp.json` in your project:
42
+
43
+ ```json
44
+ {
45
+ "mcpServers": {
46
+ "codebase-context": {
47
+ "command": "npx",
48
+ "args": ["-y", "codebase-context", "/path/to/your/project"]
49
+ }
50
+ }
51
+ }
52
+ ```
53
+
54
+ ### Windsurf
55
+
56
+ Open Settings > MCP and add:
57
+
58
+ ```json
59
+ {
60
+ "mcpServers": {
61
+ "codebase-context": {
62
+ "command": "npx",
63
+ "args": ["-y", "codebase-context", "/path/to/your/project"]
64
+ }
65
+ }
66
+ }
67
+ ```
68
+
69
+ ### Claude Code
70
+
71
+ No config file needed. Add to `.claude/settings.json` or run:
72
+
73
+ ```bash
74
+ claude mcp add codebase-context -- npx -y codebase-context /path/to/your/project
75
+ ```
76
+
77
+ ## What Makes It a Second Brain
78
+
79
+ Other tools help AI find code. This one helps AI make the right decisions — by remembering what your team does, tracking how patterns evolve, and warning before mistakes repeat.
80
+
81
+ ### Remembers
82
+
83
+ Decisions, rationale, and past failures persist across sessions. Not just what the team does — why.
84
+
85
+ - Internal library usage: `@mycompany/ui-toolkit` (847 uses) vs `primeng` (3 uses) — and _why_ the wrapper exists
86
+ - "Tried direct PrimeNG toast, broke event system" — recorded as a failure memory, surfaced before the next agent repeats it
87
+ - Conventions from git history auto-extracted: `refactor:`, `migrate:`, `fix:`, `revert:` commits become memories with zero manual effort
88
+
89
+ ### Reasons
90
+
91
+ Quantified pattern analysis with trend direction. Not "use inject()" — "97% of the team uses inject(), and it's rising."
92
+
93
+ - `inject()`: 97% adoption vs `constructor()`: 3% — with trend direction (rising/declining)
94
+ - `Signals`: rising (last used 2 days ago) vs `RxJS BehaviorSubject`: declining (180+ days)
95
+ - Golden files: real implementations scoring highest on modern pattern density — canonical examples to follow
96
+ - Pattern conflicts detected: when two approaches in the same category both exceed 20% adoption
97
+
98
+ ### Protects
99
+
100
+ Before an edit happens, the agent gets a preflight briefing: what to use, what to avoid, what broke last time.
101
+
102
+ - Preflight card on `search_codebase` with `intent: "edit"` — risk level, preferred/avoid patterns, failure warnings, golden files, impact candidates
103
+ - Failure memories bump risk level and surface as explicit warnings
104
+ - Confidence decay: memories age (90-day or 180-day half-life). Stale guidance gets flagged, not blindly trusted
105
+ - Epistemic stress detection: when evidence is contradictory, stale, or too thin, the preflight card says "insufficient evidence" instead of guessing
106
+ - Search quality transparency: `search_codebase` includes `searchQuality` (`ok`/`low_confidence`, signals, confidence, next steps) so ambiguous retrieval is explicit instead of hidden
107
+
108
+ ### Discovers
109
+
110
+ Hybrid search (BM25 keyword 30% + vector embeddings 70%) with structured filters across 30+ languages:
111
+
112
+ - **Framework**: Angular, React, Vue
113
+ - **Language**: TypeScript, JavaScript, Python, Go, Rust, and 25+ more
114
+ - **Component type**: component, service, directive, guard, interceptor, pipe
115
+ - **Architectural layer**: presentation, business, data, state, core, shared
116
+ - Circular dependency detection, style guide auto-detection, architectural layer classification
117
+
118
+ ## Measured Results
119
+
120
+ Tested against a real enterprise Angular codebase (~30k files):
121
+
122
+ | What was measured | Result |
123
+ | -------------------------- | -------------------------------------------------------- |
124
+ | Internal library detection | 336 uses of `@company/ui-toolkit` vs 3 direct PrimeNG |
125
+ | DI pattern consensus | 98% `inject()` adoption detected, constructor DI flagged |
126
+ | Test framework detection | 74% Jest, 26% Jasmine/Karma, per-module awareness |
127
+ | Wrapper discovery | `ToastEventService`, `DialogComponent` surfaced over raw |
128
+ | Golden file identification | Top 5 files scoring 4-6 modern patterns each |
129
+
130
+ Without this context, AI agents default to generic patterns: raw PrimeNG imports, constructor injection, Jasmine syntax. With the second brain active, generated code matches the existing codebase on first attempt.
131
+
132
+ ## How It Works
133
+
134
+ The difference in practice:
135
+
136
+ | Without second brain | With second brain |
137
+ | ---------------------------------------- | ------------------------------------ |
138
+ | Uses `constructor(private svc: Service)` | Uses `inject()` (97% team adoption) |
139
+ | Suggests `primeng/button` directly | Uses `@mycompany/ui-toolkit` wrapper |
140
+ | Generic Jest setup | Your team's actual test utilities |
141
+
142
+ ### Preflight Card
143
+
144
+ When using `search_codebase` with `intent: "edit"`, `"refactor"`, or `"migrate"`, the response includes a preflight card alongside search results:
145
+
146
+ ```json
147
+ {
148
+ "preflight": {
149
+ "intent": "refactor",
150
+ "riskLevel": "medium",
151
+ "confidence": "fresh",
152
+ "evidenceLock": {
153
+ "mode": "triangulated",
154
+ "status": "pass",
155
+ "readyToEdit": true,
156
+ "score": 100,
157
+ "sources": [
158
+ { "source": "code", "strength": "strong", "count": 5 },
159
+ { "source": "patterns", "strength": "strong", "count": 3 },
160
+ { "source": "memories", "strength": "strong", "count": 2 }
161
+ ]
162
+ },
163
+ "preferredPatterns": [
164
+ { "pattern": "inject() function", "category": "dependencyInjection", "adoption": "98%", "trend": "Rising" }
165
+ ],
166
+ "avoidPatterns": [
167
+ { "pattern": "Constructor injection", "category": "dependencyInjection", "adoption": "2%", "trend": "Declining" }
168
+ ],
169
+ "goldenFiles": [
170
+ { "file": "src/features/auth/auth.service.ts", "score": 6 }
171
+ ],
172
+ "failureWarnings": [
173
+ { "memory": "Direct PrimeNG toast broke event system", "reason": "Must use ToastEventService" }
174
+ ]
175
+ },
176
+ "results": [...]
177
+ }
178
+ ```
179
+
180
+ One call. The second brain composes patterns, memories, failures, and risk into a single response.
181
+
182
+ ### Tip: Auto-invoke in your rules
183
+
184
+ Add this to your `.cursorrules`, `CLAUDE.md`, or `AGENTS.md`:
185
+
186
+ ```
187
+ ## Codebase Context
188
+
189
+ **At start of each task:** Call `get_memory` to load team conventions.
190
+
191
+ **CRITICAL:** When user says "remember this" or "record this":
192
+ - STOP immediately and call `remember` tool FIRST
193
+ - DO NOT proceed with other actions until memory is recorded
194
+ - This is a blocking requirement, not optional
195
+ ```
196
+
197
+ Now the agent checks patterns automatically instead of waiting for you to ask.
198
+
199
+ ## Tools
200
+
201
+ | Tool | Purpose |
202
+ | ------------------------------ | -------------------------------------------------------------------- |
203
+ | `search_codebase` | Hybrid search with filters. Pass `intent: "edit"` for preflight card |
204
+ | `get_component_usage` | Find where a library/component is used |
205
+ | `get_team_patterns` | Pattern frequencies, golden files, conflict detection |
206
+ | `get_codebase_metadata` | Project structure overview |
207
+ | `get_indexing_status` | Indexing progress + last stats |
208
+ | `get_style_guide` | Query style guide rules |
209
+ | `detect_circular_dependencies` | Find import cycles between files |
210
+ | `remember` | Record memory (conventions/decisions/gotchas/failures) |
211
+ | `get_memory` | Query memory with confidence decay scoring |
212
+ | `refresh_index` | Re-index the codebase + extract git memories |
213
+
214
+ ## Language Support
215
+
216
+ The Angular analyzer provides deep framework-specific analysis (signals, standalone components, control flow syntax, lifecycle hooks, DI patterns). A generic analyzer covers 30+ languages and file types as a fallback: JavaScript, TypeScript, Python, Java, Kotlin, C/C++, C#, Go, Rust, PHP, Ruby, Swift, Scala, Shell, and common config/markup formats.
217
+
218
+ ## File Structure
219
+
220
+ The MCP creates the following structure in your project:
221
+
222
+ ```
223
+ .codebase-context/
224
+ ├── memory.json # Team knowledge (commit this)
225
+ ├── intelligence.json # Pattern analysis (generated)
226
+ ├── index.json # Keyword index (generated)
227
+ └── index/ # Vector database (generated)
228
+ ```
229
+
230
+ **Recommended `.gitignore`:** The vector database and generated files can be large. Add this to your `.gitignore` to keep them local while sharing team memory:
231
+
232
+ ```gitignore
233
+ # Codebase Context MCP - ignore generated files, keep memory
234
+ .codebase-context/*
235
+ !.codebase-context/memory.json
236
+ ```
237
+
238
+ ### Memory System
239
+
240
+ Patterns tell you _what_ the team does ("97% use inject"), but not _why_ ("standalone compatibility"). Use `remember` to capture rationale that prevents repeated mistakes:
241
+
242
+ ```typescript
243
+ remember({
244
+ type: 'decision',
245
+ category: 'dependencies',
246
+ memory: 'Use node-linker: hoisted, not isolated',
247
+ reason: "Some packages don't declare transitive deps."
248
+ });
249
+ ```
250
+
251
+ **Memory types:** `convention` (style rules), `decision` (architecture choices), `gotcha` (things that break), `failure` (tried X, failed because Y).
252
+
253
+ **Confidence decay:** Memories age. Conventions never decay. Decisions have a 180-day half-life. Gotchas and failures have a 90-day half-life. Memories below 30% confidence are flagged as stale in `get_memory` responses.
254
+
255
+ **Git auto-extraction:** During indexing, conventional commits (`refactor:`, `migrate:`, `fix:`, `revert:`) from the last 90 days are auto-recorded as memories. Zero manual effort.
256
+
257
+ **Pattern conflicts:** `get_team_patterns` detects when two patterns in the same category are both above 20% adoption with different trends, and surfaces them as conflicts with both sides.
258
+
259
+ Memories surface automatically in `search_codebase` results, `get_team_patterns` responses, and preflight cards.
260
+
261
+ **Known quirks:**
262
+
263
+ - Agents may bundle multiple things into one entry
264
+ - Edit `.codebase-context/memory.json` directly to clean up
265
+ - Be explicit: "Remember this: use X not Y"
266
+
267
+ ## Configuration
268
+
269
+ | Variable | Default | Description |
270
+ | ------------------------ | -------------- | ------------------------------------------------------------------------------ |
271
+ | `EMBEDDING_PROVIDER` | `transformers` | `openai` (fast, cloud) or `transformers` (local, private) |
272
+ | `OPENAI_API_KEY` | - | Required if provider is `openai` |
273
+ | `CODEBASE_ROOT` | - | Project root to index (CLI arg takes precedence) |
274
+ | `CODEBASE_CONTEXT_DEBUG` | - | Set to `1` to enable verbose logging (startup messages, analyzer registration) |
275
+
276
+ ## Performance
277
+
278
+ This tool runs locally on your machine.
279
+
280
+ - **Initial indexing**: First run may take several minutes (e.g., 2-5 min for 30k files) to compute embeddings.
281
+ - **Subsequent queries**: Instant (milliseconds) from cache.
282
+ - **Updates**: `refresh_index` supports full or incremental mode (`incrementalOnly: true`) to process only changed files.
283
+
284
+ ## Links
285
+
286
+ - [Motivation](./MOTIVATION.md) — Research and design rationale
287
+ - [Changelog](./CHANGELOG.md) — Version history
288
+ - [Contributing](./CONTRIBUTING.md) — How to add analyzers
289
+
290
+ ## License
291
+
292
+ MIT
@@ -3,7 +3,7 @@
3
3
  * Understands components, services, directives, pipes, modules, guards, interceptors, etc.
4
4
  * Detects state management patterns, architectural layers, and Angular-specific patterns
5
5
  */
6
- import { FrameworkAnalyzer, AnalysisResult, CodebaseMetadata, CodeChunk } from "../../types/index.js";
6
+ import { FrameworkAnalyzer, AnalysisResult, CodebaseMetadata, CodeChunk } from '../../types/index.js';
7
7
  export declare class AngularAnalyzer implements FrameworkAnalyzer {
8
8
  readonly name = "angular";
9
9
  readonly version = "1.0.0";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/analyzers/angular/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,SAAS,EAOV,MAAM,sBAAsB,CAAC;AAI9B,qBAAa,eAAgB,YAAW,iBAAiB;IACvD,QAAQ,CAAC,IAAI,aAAa;IAC1B,QAAQ,CAAC,OAAO,WAAW;IAC3B,QAAQ,CAAC,mBAAmB,WAQ1B;IACF,QAAQ,CAAC,QAAQ,OAAO;IAExB,OAAO,CAAC,eAAe,CAarB;IAEF,OAAO,CAAC,uBAAuB,CAO7B;IAEF,OAAO,CAAC,qBAA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