mcp-code-context 3.6.2 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/CHANGELOG.md +140 -268
  2. package/INSTRUCTIONS.md +31 -12
  3. package/README.md +223 -107
  4. package/SECURITY.md +55 -21
  5. package/dist/src/core/cacheManager.d.ts +4 -5
  6. package/dist/src/core/cacheManager.js +49 -33
  7. package/dist/src/core/cacheManager.js.map +1 -1
  8. package/dist/src/core/engine.d.ts +1 -1
  9. package/dist/src/core/engine.js +3 -3
  10. package/dist/src/core/engine.js.map +1 -1
  11. package/dist/src/core/indexManager.d.ts +58 -0
  12. package/dist/src/core/indexManager.js +252 -0
  13. package/dist/src/core/indexManager.js.map +1 -0
  14. package/dist/src/core/indexManagerQueries.d.ts +14 -0
  15. package/dist/src/core/indexManagerQueries.js +95 -0
  16. package/dist/src/core/indexManagerQueries.js.map +1 -0
  17. package/dist/src/core/sessionManager.d.ts +117 -0
  18. package/dist/src/core/sessionManager.js +231 -0
  19. package/dist/src/core/sessionManager.js.map +1 -0
  20. package/dist/src/core/validator.d.ts +1 -1
  21. package/dist/src/core/validator.js +18 -10
  22. package/dist/src/core/validator.js.map +1 -1
  23. package/dist/src/index.d.ts +1 -13
  24. package/dist/src/index.js +25 -999
  25. package/dist/src/index.js.map +1 -1
  26. package/dist/src/operations/astTransform.d.ts +38 -0
  27. package/dist/src/operations/astTransform.js +239 -0
  28. package/dist/src/operations/astTransform.js.map +1 -0
  29. package/dist/src/operations/compress.d.ts +5 -3
  30. package/dist/src/operations/compress.js +73 -7
  31. package/dist/src/operations/compress.js.map +1 -1
  32. package/dist/src/operations/confirmationStore.d.ts +35 -8
  33. package/dist/src/operations/confirmationStore.js +112 -14
  34. package/dist/src/operations/confirmationStore.js.map +1 -1
  35. package/dist/src/operations/impactAnalysis.d.ts +9 -0
  36. package/dist/src/operations/impactAnalysis.js +61 -0
  37. package/dist/src/operations/impactAnalysis.js.map +1 -0
  38. package/dist/src/operations/pendingStore.d.ts +51 -0
  39. package/dist/src/operations/pendingStore.js +201 -0
  40. package/dist/src/operations/pendingStore.js.map +1 -0
  41. package/dist/src/operations/pendingStoreInit.d.ts +6 -0
  42. package/dist/src/operations/pendingStoreInit.js +42 -0
  43. package/dist/src/operations/pendingStoreInit.js.map +1 -0
  44. package/dist/src/operations/read.d.ts +6 -92
  45. package/dist/src/operations/read.js +4 -445
  46. package/dist/src/operations/read.js.map +1 -1
  47. package/dist/src/operations/readCore.d.ts +33 -0
  48. package/dist/src/operations/readCore.js +142 -0
  49. package/dist/src/operations/readCore.js.map +1 -0
  50. package/dist/src/operations/rename.d.ts +13 -0
  51. package/dist/src/operations/rename.js +130 -0
  52. package/dist/src/operations/rename.js.map +1 -0
  53. package/dist/src/operations/searchOperation.d.ts +16 -0
  54. package/dist/src/operations/searchOperation.js +113 -0
  55. package/dist/src/operations/searchOperation.js.map +1 -0
  56. package/dist/src/operations/symbolQuery.d.ts +38 -0
  57. package/dist/src/operations/symbolQuery.js +194 -0
  58. package/dist/src/operations/symbolQuery.js.map +1 -0
  59. package/dist/src/operations/write.d.ts +11 -14
  60. package/dist/src/operations/write.js +6 -125
  61. package/dist/src/operations/write.js.map +1 -1
  62. package/dist/src/parsers/base.d.ts +1 -1
  63. package/dist/src/parsers/base.js +1 -1
  64. package/dist/src/parsers/csharp.d.ts +12 -0
  65. package/dist/src/parsers/csharp.js +67 -0
  66. package/dist/src/parsers/csharp.js.map +1 -0
  67. package/dist/src/parsers/dartTreeSitter.d.ts +1 -1
  68. package/dist/src/parsers/dartTreeSitter.js +1 -1
  69. package/dist/src/parsers/go.d.ts +11 -0
  70. package/dist/src/parsers/go.js +74 -0
  71. package/dist/src/parsers/go.js.map +1 -0
  72. package/dist/src/parsers/java.d.ts +12 -0
  73. package/dist/src/parsers/java.js +62 -0
  74. package/dist/src/parsers/java.js.map +1 -0
  75. package/dist/src/parsers/kotlin.d.ts +12 -0
  76. package/dist/src/parsers/kotlin.js +75 -0
  77. package/dist/src/parsers/kotlin.js.map +1 -0
  78. package/dist/src/parsers/php.d.ts +1 -1
  79. package/dist/src/parsers/php.js +1 -1
  80. package/dist/src/parsers/python.d.ts +1 -1
  81. package/dist/src/parsers/python.js +1 -1
  82. package/dist/src/parsers/registry.d.ts +1 -1
  83. package/dist/src/parsers/registry.js +63 -2
  84. package/dist/src/parsers/registry.js.map +1 -1
  85. package/dist/src/parsers/ruby.d.ts +12 -0
  86. package/dist/src/parsers/ruby.js +73 -0
  87. package/dist/src/parsers/ruby.js.map +1 -0
  88. package/dist/src/parsers/rust.d.ts +12 -0
  89. package/dist/src/parsers/rust.js +66 -0
  90. package/dist/src/parsers/rust.js.map +1 -0
  91. package/dist/src/parsers/typescript.d.ts +1 -1
  92. package/dist/src/parsers/typescript.js +28 -38
  93. package/dist/src/parsers/typescript.js.map +1 -1
  94. package/dist/src/tools/adminHandlers.d.ts +67 -0
  95. package/dist/src/tools/adminHandlers.js +129 -0
  96. package/dist/src/tools/adminHandlers.js.map +1 -0
  97. package/dist/src/tools/context.d.ts +9 -0
  98. package/dist/src/tools/context.js +21 -0
  99. package/dist/src/tools/context.js.map +1 -0
  100. package/dist/src/tools/handlers.d.ts +4 -0
  101. package/dist/src/tools/handlers.js +5 -0
  102. package/dist/src/tools/handlers.js.map +1 -0
  103. package/dist/src/tools/pipeline.d.ts +6 -0
  104. package/dist/src/tools/pipeline.js +100 -0
  105. package/dist/src/tools/pipeline.js.map +1 -0
  106. package/dist/src/tools/readHandlers.d.ts +55 -0
  107. package/dist/src/tools/readHandlers.js +220 -0
  108. package/dist/src/tools/readHandlers.js.map +1 -0
  109. package/dist/src/tools/toolDefinitions.d.ts +1037 -0
  110. package/dist/src/tools/toolDefinitions.js +13 -0
  111. package/dist/src/tools/toolDefinitions.js.map +1 -0
  112. package/dist/src/tools/toolDefinitionsAdmin.d.ts +89 -0
  113. package/dist/src/tools/toolDefinitionsAdmin.js +99 -0
  114. package/dist/src/tools/toolDefinitionsAdmin.js.map +1 -0
  115. package/dist/src/tools/toolDefinitionsCore.d.ts +949 -0
  116. package/dist/src/tools/toolDefinitionsCore.js +267 -0
  117. package/dist/src/tools/toolDefinitionsCore.js.map +1 -0
  118. package/dist/src/tools/writeHandlers.d.ts +37 -0
  119. package/dist/src/tools/writeHandlers.js +199 -0
  120. package/dist/src/tools/writeHandlers.js.map +1 -0
  121. package/dist/src/utils/appDir.d.ts +19 -0
  122. package/dist/src/utils/appDir.js +50 -0
  123. package/dist/src/utils/appDir.js.map +1 -0
  124. package/dist/src/utils/auditLogWriter.d.ts +9 -0
  125. package/dist/src/utils/auditLogWriter.js +49 -0
  126. package/dist/src/utils/auditLogWriter.js.map +1 -0
  127. package/dist/src/utils/auditLogger.d.ts +1 -10
  128. package/dist/src/utils/auditLogger.js +14 -109
  129. package/dist/src/utils/auditLogger.js.map +1 -1
  130. package/dist/src/utils/auditQuery.d.ts +23 -0
  131. package/dist/src/utils/auditQuery.js +67 -0
  132. package/dist/src/utils/auditQuery.js.map +1 -0
  133. package/dist/src/utils/backupManager.d.ts +2 -2
  134. package/dist/src/utils/backupManager.js +29 -12
  135. package/dist/src/utils/backupManager.js.map +1 -1
  136. package/dist/src/utils/constants.d.ts +1 -1
  137. package/dist/src/utils/constants.js +8 -1
  138. package/dist/src/utils/constants.js.map +1 -1
  139. package/dist/src/utils/diff.d.ts +12 -1
  140. package/dist/src/utils/diff.js +41 -1
  141. package/dist/src/utils/diff.js.map +1 -1
  142. package/dist/src/utils/fileLock.d.ts +7 -2
  143. package/dist/src/utils/fileLock.js +14 -11
  144. package/dist/src/utils/fileLock.js.map +1 -1
  145. package/dist/src/utils/fileWalker.d.ts +1 -1
  146. package/dist/src/utils/fileWalker.js +1 -1
  147. package/dist/src/utils/fileWatcher.d.ts +1 -1
  148. package/dist/src/utils/fileWatcher.js +1 -1
  149. package/dist/src/utils/fuzzySearch.d.ts +1 -1
  150. package/dist/src/utils/fuzzySearch.js +1 -1
  151. package/dist/src/utils/logger.d.ts +1 -1
  152. package/dist/src/utils/logger.js +2 -2
  153. package/dist/src/utils/logger.js.map +1 -1
  154. package/dist/src/utils/rateLimiter.d.ts +9 -1
  155. package/dist/src/utils/rateLimiter.js +12 -1
  156. package/dist/src/utils/rateLimiter.js.map +1 -1
  157. package/dist/src/utils/regexValidator.d.ts +12 -0
  158. package/dist/src/utils/regexValidator.js +48 -0
  159. package/dist/src/utils/regexValidator.js.map +1 -0
  160. package/dist/src/utils/safeRegex.d.ts +2 -92
  161. package/dist/src/utils/safeRegex.js +41 -222
  162. package/dist/src/utils/safeRegex.js.map +1 -1
  163. package/dist/src/utils/safeRegexApi.d.ts +56 -0
  164. package/dist/src/utils/safeRegexApi.js +99 -0
  165. package/dist/src/utils/safeRegexApi.js.map +1 -0
  166. package/dist/src/utils/safeRegexPool.d.ts +7 -0
  167. package/dist/src/utils/safeRegexPool.js +102 -0
  168. package/dist/src/utils/safeRegexPool.js.map +1 -0
  169. package/dist/src/utils/searchTools.js +6 -6
  170. package/dist/src/utils/searchTools.js.map +1 -1
  171. package/dist/src/utils/streaming.d.ts +4 -3
  172. package/dist/src/utils/streaming.js +1 -1
  173. package/dist/src/utils/streaming.js.map +1 -1
  174. package/dist/src/utils/telemetry.d.ts +1 -1
  175. package/dist/src/utils/telemetry.js +1 -1
  176. package/dist/src/utils/toctou.d.ts +7 -0
  177. package/dist/src/utils/toctou.js +24 -0
  178. package/dist/src/utils/toctou.js.map +1 -0
  179. package/llms.txt +199 -31
  180. package/package.json +2 -2
  181. package/scripts/replace-version.js +0 -59
package/CHANGELOG.md CHANGED
@@ -1,268 +1,140 @@
1
- # Changelog
2
-
3
- ## [3.6.2] - 2026-05-01
4
-
5
- ### 🔒 CRITICAL FIXES - Production Stability Release
6
-
7
- **Emergency Update**: Resolved 3 critical production bugs causing data corruption, memory leaks, and race conditions.
8
-
9
- ### Fixed
10
-
11
- #### Critical Bug Fixes
12
- - **FIX #1: Double Cache Instance** — Eliminated duplicate SQLite database instances in `read.ts` causing cache corruption. Cache now properly injected from `index.ts` singleton.
13
- - **FIX #2: Memory Leak (Event Listeners)** — Removed `process.on` listeners from `CacheManager` constructor. Each cache instance was registering global listeners, causing `MaxListenersExceededWarning` and memory exhaustion. Added global shutdown hook in `index.ts` instead.
14
- - **FIX #3: TOCTOU Race Condition** — Added `originalHash` verification in Phase 2 writes. Prevents silent data corruption when files are modified between dry-run (Phase 1) and confirmation (Phase 2).
15
-
16
- ### Added
17
- - **Global Shutdown Hook**: Single `process.on` handler in `index.ts` persists all active caches on exit
18
- - **persistOnExit() Method**: Public synchronous method for safe cache persistence during shutdown
19
- - **originalHash Field**: Added to `WriteResult` interface for TOCTOU protection
20
- - **8 Regression Tests**: Memory leak detection, cache injection validation, TOCTOU protection
21
-
22
- ### Changed
23
- - **BREAKING**: `extractSymbol` now requires `cache` parameter (injected from caller)
24
- - **BREAKING**: `WriteResult` interface includes optional `originalHash` field
25
- - **BREAKING**: `PendingOperation` interface includes optional `originalHash` field
26
-
27
- ### Test Results
28
- - 81/82 tests passing (99% success rate)
29
- - Memory leak test: ✅ PASSED (no listener accumulation)
30
- - TOCTOU protection test: ✅ PASSED (hash verification works)
31
- - Cache injection test: ✅ PASSED (no duplicate instances)
32
- - 1 flaky performance test (timing variance, not a bug)
33
-
34
- ### Security
35
- - ✅ TOCTOU race condition eliminated
36
- - ✅ Memory leak prevention
37
- - ✅ Cache corruption prevention
38
-
39
- ### Migration from v3.6.0
40
- - Update calls to `extractSymbol` to pass `cache` parameter
41
- - No user-facing API changes (internal refactoring only)
42
- - Rebuild recommended: `npm run rebuild`
43
-
44
- ---
45
-
46
- ## [3.6.0] - 2026-04-30
47
-
48
- ### Added
49
-
50
- #### Infrastructure
51
- - **Persistent WASM SQLite Cache** (`sql.js`) — <100ms cache hits, 10× faster on repeated reads. Debounced persistence (5s) prevents event loop blocking. OS temp cleanup recovery built-in.
52
- - **Structured Logging** (`pino`) — JSON to stderr (MCP-safe). Pretty-print in development, JSON in production. All `console.log/error` replaced.
53
- - **File Watcher** (`chokidar`) — Auto-invalidates cache on file changes. Configurable debounce (default 500ms). New MCP tools: `configure_file_watcher`, `get_file_watcher_status`.
54
- - **Fuzzy Search** (`fuse.js`) — Typo-tolerant search. Finds `authenticateUser` when searching `authUser`. Configurable threshold.
55
- - **Pagination** — `search_code_pattern` now defaults to 10 results (was 50) with `startIndex` parameter and result footer.
56
-
57
- #### Testing (74 tests, 100% passing)
58
- - **Vitest** test framework with V8 coverage
59
- - Unit tests: parsers, diff, fileLock, backupManager, phase9 optimization
60
- - Integration tests: full read→write→rollback cycle, multi-process safety
61
- - Performance tests: cache hit <100ms, search <2000ms
62
- - Stress tests: 20 concurrent locks, 10K line files, OOM protection
63
-
64
- #### Security Fixes (3 production stoppers resolved)
65
- - **STOPPER #1**: `sanitizeRegexPattern` UUID bug fixed (`\\$&` replacement)
66
- - **STOPPER #2**: Phase 2 re-acquires file lock before write (race condition eliminated)
67
- - **STOPPER #3**: `SecurityValidator` applied in Phase 2 (defense in depth)
68
-
69
- ### Changed
70
- - **Token Optimization**: Phase 2 confirmation no longer repeats diff (50-80% token reduction)
71
- - **Auto-optimize output**: `get_semantic_repo_map` auto-disables symbols if >100 files or >1000 symbols
72
- - **Filesystem locks**: `proper-lockfile` replaces in-memory locks (multi-process safe)
73
- - **OS temp backups**: Backups moved from project root to `os.tmpdir()` (no hot-reload loops)
74
- - **Myers diff**: `diff-match-patch` replaces custom O(n×m) LCS (no OOM on large files)
75
- - **Centralized `walkDir`**: Extracted to `src/utils/fileWalker.ts` (eliminated 3× duplication)
76
- - **Pinned dependencies**: All `^` ranges replaced with exact versions for reproducible installs
77
-
78
- ### Fixed
79
- - `analyzeImpact` regex patterns now use `safeRegex` (consistent ReDoS protection)
80
- - `BackupManager.getBackupRoot` uses async `fs.mkdir` (no sync blocking)
81
- - `validateRegexPattern` documented as best-effort (worker timeout is the real guarantee)
82
-
83
- ### Performance
84
- - Cache hit: <100ms ✅
85
- - Parse file: <500ms ✅
86
- - Search (20 files): <2000ms ✅
87
- - Token savings: 50-80% ✅
88
-
89
- ### Migration from v3.6.2
90
- - Zero breaking changes
91
- - New optional parameters: `fuzzyMatch`, `fuzzyThreshold`, `startIndex`, `maxDepth`, `includeSymbols`
92
- - New tools: `configure_file_watcher`, `get_file_watcher_status`, `get_cache_stats`, `clear_cache`
93
-
94
- ---
95
-
96
- ## [3.6.2] - 2026-04-24
97
-
98
- ### 🔒 PRODUCTION HARDENING - Security & Infrastructure Complete
99
-
100
- **Major Update**: All utility modules integrated, critical bugs fixed, production-ready
101
-
102
- ### Added
103
- - **Two-Phase Write Workflow**: Dry-run + confirmation tokens for all write operations
104
- - **Rate Limiting**: Token bucket algorithm with per-operation costs
105
- - **File Locking**: Prevents concurrent write conflicts with timeout protection
106
- - **Audit Logging**: JSON-based audit trail with query/stats API
107
- - **Telemetry**: Operation metrics, cache stats, Prometheus export
108
- - **Streaming I/O**: Memory-safe file operations for large files (>5MB)
109
- - **get_server_stats**: New tool exposing telemetry and audit metrics
110
- - **confirm_write**: New tool for two-phase write confirmation
111
-
112
- ### Fixed
113
- - **CRITICAL**: `extractSymbol` API mismatch in read.ts (symbol extraction was 100% broken)
114
- - **CRITICAL**: Path traversal in 4 handlers (readLines, searchPattern, analyzeImpact, renameSymbol)
115
- - **CRITICAL**: ReDoS vulnerability in readLines (raw regex without timeout)
116
- - **CRITICAL**: `forEach(async)` bug in searchPattern (incomplete results)
117
- - **Security**: renameSymbol now uses SecurityValidator + atomic writes
118
- - **Parser**: replaceSymbol moved to BaseParser using AST indices (no more indexOf fragility)
119
- - **Diff**: Added MAX_DIFF_LINES=5000 guard to prevent OOM on large files
120
-
121
- ### Changed
122
- - **BREAKING**: All tools now require `projectRoot` parameter for security
123
- - **Security**: SecurityValidator enforced on all 13 handlers
124
- - **Architecture**: Middleware pipeline (RateLimiter → FileLock → Execute → AuditLog → Telemetry)
125
- - **Parsers**: Removed 300+ lines of duplicated replaceSymbol code
126
- - **Version**: Synchronized all version strings to 3.6.2
127
-
128
- ### Performance
129
- - Streaming I/O for files >5MB (prevents memory exhaustion)
130
- - LCS diff fallback for files >5000 lines (O(n) vs O(n²))
131
- - Rate limiter with configurable operation costs
132
-
133
- ### Security
134
- - ✅ Path traversal protection on all handlers
135
- - ✅ ReDoS protection with regex timeout
136
- - ✅ Atomic writes with .tmp + rename pattern
137
- - ✅ File locking prevents concurrent corruption
138
- - ✅ Audit trail for all operations
139
-
140
- ### Validation
141
- - ✅ 47/47 WASM parser tests passing (100%)
142
- - ✅ All security tests passing
143
- - ✅ All rate limiter tests passing
144
- - ✅ All file lock tests passing
145
- - ✅ All v3.6.2 feature tests passing
146
- - ✅ TypeScript: 0 compilation errors
147
- - ✅ Build: Clean production dist
148
-
149
- ### Migration from v3.1.0
150
- - Add `projectRoot` parameter to all tool calls
151
- - Optional: Use `confirm: false` for dry-run, then `confirm: true` with token
152
- - Optional: Call `get_server_stats` to monitor operations
153
-
154
- ---
155
-
156
- ## [3.1.0] - 2026-04-24
157
-
158
- ### 🚀 FEATURE COMPLETE - All 11 Tools Implemented
159
-
160
- **Major Update**: Added 7 missing tools from v2.6.0 to achieve feature parity
161
-
162
- ### Added
163
- - **get_semantic_repo_map**: Compress entire repositories to structural signatures
164
- - **read_file_surgical**: Extract specific symbols from files
165
- - **analyze_impact**: Find all files that depend on a given file
166
- - **read_file_lines**: Read specific line ranges from files
167
- - **search_code_pattern**: Search for patterns across multiple files
168
- - **rename_symbol**: Rename symbols across entire repository
169
-
170
- ### Summary
171
- - ✅ 11/11 tools from v2.6.0 now implemented
172
- - ✅ 100% WASM portability maintained
173
- - ✅ Zero native dependencies
174
- - ✅ Feature parity with v2.6.0 achieved
175
- - ✅ Tree-sitter WASM for 100% AST accuracy
176
-
177
- ---
178
-
179
- ## [3.0.6] - 2026-04-24
180
-
181
- ### 🚀 COMPLETE REWRITE - Tree-sitter WASM Edition
182
-
183
- **Breaking Changes**: Complete architecture overhaul with 100% WASM portability
184
-
185
- ### Added
186
- - **Tree-sitter WASM Parsers**: 100% AST accuracy for TypeScript/JavaScript/Python/PHP/Dart
187
- - **Zero Native Dependencies**: No Visual Studio, node-gyp, or Python required
188
- - **Cross-Platform Portability**: Works on Windows/Mac/Linux without compilation
189
- - **Dart AST Support**: Full Tree-sitter parsing (no regex fallback)
190
- - **Mandatory Security Boundaries**: projectRoot required for all operations
191
- - **Async-First Architecture**: Zero blocking I/O
192
- - **Simplified Core**: Engine + Registry + Validator pattern
193
- - **Smart WASM Path Resolution**: Finds WASM files in installed module location (not CWD)
194
-
195
- ### Changed
196
- - **CRITICAL**: Migrated from tree-sitter native to web-tree-sitter@0.25.1
197
- - Uses tree-sitter-wasms@0.1.13 for language grammars (ABI v15)
198
- - Parser API: `cursor.currentNode` is now getter (not function call)
199
- - Language loading: `Language.load(buffer)` with fs.readFileSync
200
- - WASM path resolution: Uses `import.meta.url` for module-relative paths
201
- - Replaced ts-morph with tree-sitter WASM
202
- - Replaced php-parser with tree-sitter-php WASM
203
- - Simplified from 9,518 lines to ~600 lines of core code
204
-
205
- ### Removed
206
- - Native tree-sitter bindings (node-gyp dependency)
207
- - Legacy v2.x handlers (readHandlers, writeHandlers, utilHandlers)
208
- - php-parser dependency
209
- - ts-morph dependency
210
- - Regex-based Dart parser fallback
211
-
212
- ### Fixed
213
- - **npx compatibility**: Works with `npx -y mcp-code-context@3.1.0`
214
- - **WASM loading**: Finds WASM files when installed globally or locally
215
- - **Windows support**: Full compatibility with Claude Desktop on Windows
216
-
217
- ### Performance
218
- - 100% accuracy on TypeScript/JavaScript/Python/PHP/Dart parsing
219
- - Zero regex-based parsing
220
- - Cursor-based tree traversal (efficient)
221
- - WASM overhead: ~10-20% slower than native, but portable
222
-
223
- ### Security
224
- - Mandatory project boundary enforcement
225
- - Path traversal protection
226
- - Async file validation
227
- - No native code execution (WASM sandbox)
228
-
229
- ### Validation
230
- - ✅ 47/47 unit tests passing (100%)
231
- - ✅ Dart: 4 symbols detected (class, methods, functions)
232
- - ✅ TypeScript: 4 symbols detected (class, constructor, methods, functions)
233
- - ✅ Python: 12/12 tests passing
234
- - ✅ PHP: 11/11 tests passing
235
- - ✅ Build passes without TypeScript errors
236
- - ✅ No native dependencies in package.json
237
-
238
- ### Migration Guide
239
- v2.x users: This is a ground-up rewrite. v2.x tools are not compatible.
240
- New API focuses on parse_file with Tree-sitter WASM accuracy.
241
-
242
- **Installation**: Just `npm install` - no build tools required!
243
-
244
- ---
245
-
246
- ## [2.6.0] - 2024-01-16
247
-
248
- ### 🚀 Performance & Scalability
249
-
250
- - **Async I/O Migration**: Eliminated all synchronous file operations
251
- - `ignoreManager.walkDirectory()` now fully async
252
- - No event loop blocking on large repositories
253
- - 3x faster on repos with 1000+ files
254
- - Impact: Scalability 4.0 → 9.0 (+5.0)
255
-
256
- - **Fuzzy Match Threshold**: Reduced noise in symbol suggestions
257
- - Added `maxDistance` parameter (default: 3 edits)
258
- - Filters out irrelevant suggestions
259
- - Better UX when symbol not found
260
-
261
- ### 📊 Metrics Improvement
262
- - Scalability: 4.0 → 9.0 (+5.0) ✅
263
- - Overall: 8.1 → 9.3 (+1.2)
264
-
265
- ### Technical
266
- - All 149 tests passing
267
- - Zero breaking changes
268
- - Backward compatible
1
+ # Changelog
2
+
3
+ ## [3.7.0] - 2026-06-18
4
+
5
+ ### 🚀 Production Readiness Release — Adversarial Audit Hardening
6
+
7
+ This release fixes **critical architectural issues** identified through three rounds of adversarial analysis and AST-based code review. All stoppers resolved. Ready for multi-agent production deployments.
8
+
9
+ ### Fixed — Critical (Production Blockers)
10
+
11
+ 1. **Session State Leakage / Memory Leak**
12
+ - Global state (`globalLockManager`, `globalConfirmationStore`, `rateLimiter`) accumulated across client sessions with no cleanup.
13
+ - **Fix**: `SessionManager` per-client state isolation with LRU eviction and 30-min timeout cleanup.
14
+
15
+ 2. **No Phase 1 Crash Recovery**
16
+ - Pending operations stored in memory only. Server crash between Phase 1 → Phase 2 lost all work.
17
+ - **Fix**: SQLite-backed `PendingOperationStore` — operations persist across restarts.
18
+
19
+ 3. **TOCTOU in Multi-File Writes**
20
+ - Phase 2 only verified hash of the primary file, not dependent files in `pendingWrites`.
21
+ - **Fix**: Hash verified on all files in the write set before applying.
22
+
23
+ 4. **Symlink Boundary Escape**
24
+ - `path.resolve()` used for boundary validation — does not follow symlinks.
25
+ - **Fix**: `fs.realpath()` in `SecurityValidator.validateFilePath()`.
26
+
27
+ 5. **`new Promise(async ...)` Anti-pattern in Worker**
28
+ - `runInWorker` used `new Promise(async (resolve) => ...)` — swallowed async errors.
29
+ - **Fix**: Refactored to standard async/await pattern.
30
+
31
+ 6. **`WORKER_FILE` Resolved at Import-Time**
32
+ - Worker path calculated before `dist/` exists — crashes on fresh install.
33
+ - **Fix**: Lazy `getWorkerFile()` evaluated at runtime.
34
+
35
+ 7. **ReDoS in `impactAnalysis`, `rename`, `readCore`**
36
+ - Dynamic `new RegExp()` constructed in main thread without timeout.
37
+ - **Fix**: All operation-level regex routed through `safeRegex` worker pool.
38
+
39
+ 8. **Rate Limiter Shared Globally**
40
+ - Single `'global'` bucket shared across all MCP clients.
41
+ - **Fix**: Per-session `SESSION_ID` (pid-based) rate limiting.
42
+
43
+ 9. **`configure_file_watcher` Without `rootDir` Validation**
44
+ - Watcher path not validated through `SecurityValidator`.
45
+ - **Fix**: Watcher uses only validated `projectRoot`.
46
+
47
+ 10. **Confirmation Token Leak Without Cleanup**
48
+ - Expired tokens accumulated in memory indefinitely.
49
+ - **Fix**: `setInterval` 60s cleanup in `ConfirmationStore`.
50
+
51
+ 11. **Windows Path Case Sensitivity in Boundary Check**
52
+ - `fs.realpath()` returns `C:\` (uppercase), `path.resolve()` returns `c:\` (lowercase).
53
+ - **Fix**: `.toLowerCase()` normalization on both sides before comparison.
54
+
55
+ 12. **`ast_transform` try/catch Indentation Bug**
56
+ - `applyWrapTryCatch` added extra indent on top of existing indentation.
57
+ - **Fix**: Correct base-indent detection using last line of rawBody as closing-indent anchor.
58
+
59
+ ### Added
60
+
61
+ #### 25 Tools (up from 13 in v3.6.x)
62
+
63
+ New tools added in this release:
64
+
65
+ | Tool | Purpose |
66
+ |------|---------|
67
+ | `ast_transform` | Declarative AST transforms: add_parameter, wrap_with_try_catch, add_decorator, change_return_type, extract_variable |
68
+ | `search_symbols` | AST-aware symbol search by name (fuzzy-capable), not text grep |
69
+ | `explain_symbol` | Signature + location + callers in one call |
70
+ | `batch_read` | Read N symbols from N files in 1 round-trip |
71
+ | `get_rate_limit_status` | Token balance + `canAfford` map per operation |
72
+ | `get_session_stats` | Per-session diagnostics (pending ops, locks, tokens) |
73
+ | `clear_session_cache` | Invalidate cache for current session only |
74
+ | `list_pending_operations` | Recovery listing after crash |
75
+
76
+ #### Architecture Improvements
77
+
78
+ - `SessionManager`: Per-client isolated state (locks, confirmations, rate limiter, cache pool)
79
+ - `safeRegexPool.ts` + `safeRegexApi.ts`: Worker pool split from monolithic `safeRegex.ts`
80
+ - `toctou.ts`: TOCTOU hash helpers extracted to own module
81
+ - `pendingStore.ts` + `pendingStoreInit.ts`: SQLite crash-recovery layer
82
+ - `toolDefinitionsAdmin.ts` + `toolDefinitionsCore.ts`: Tool definitions split from 1000-line index
83
+ - All `src/` files under 300 lines (from 1000-line monolith)
84
+
85
+ #### DX / Ergonomics
86
+
87
+ - `diffFormat` param on all write tools: `unified` | `compact` | `summary` | `none`
88
+ - Phase 2 does NOT require re-sending `newContent`/`code` (server stores from Phase 1)
89
+ - `aroundPattern` output includes `"Match found at line N (showing lines X-Y):"`
90
+ - `get_cache_stats` includes `hits`, `misses`, `hitRate`
91
+ - `get_file_watcher_status` includes `paths[]` (capped at 50)
92
+ - `get_server_stats` includes `rateLimiter.tokensAvailable` and `operationCosts`
93
+ - `MAX_FILES_REPO_MAP` = 2000 (was 500)
94
+
95
+ ### Test Results
96
+
97
+ - **83/83 tests passing** (100%)
98
+ - Security tests: ✅
99
+ - File lock tests: ✅
100
+ - Rate limiter tests: ✅
101
+ - WASM parser tests (TS/PHP/Python/Dart): ✅
102
+ - Backup manager, diff, TOCTOU, cache, confirmation store: ✅
103
+ - Multi-process concurrency tests: ✅
104
+ - Performance tests: ✅
105
+
106
+ ### Migration from v3.6.x
107
+
108
+ - **Zero breaking changes** in the public tool API.
109
+ - `parse_file` now returns `startLine`/`endLine` per symbol — additive, no breakage.
110
+ - New tools are purely additive.
111
+ - Session isolation is automatic — no configuration needed.
112
+
113
+ ---
114
+
115
+ ## [3.6.4] - 2026-05-14
116
+
117
+ ### Added
118
+ - Language parsers: C#, Go, Java, Kotlin, Ruby, Rust (Tree-sitter WASM)
119
+ - `parse_file` returns `startLine`/`endLine` per symbol
120
+ - Fuzzy search with `fuzzyMatch` + `fuzzyThreshold` parameters
121
+ - Pagination via `startIndex` on `search_code_pattern`
122
+ - `diffFormat` parameter on write tools
123
+
124
+ ### Fixed
125
+ - `parse_file` symbols missing line numbers
126
+ - CVE in `@modelcontextprotocol/sdk` (updated to 1.29.0)
127
+ - Incorrect TypeScript version `5.7.0` → `5.7.2`
128
+
129
+ ---
130
+
131
+ ## [3.6.1] - 2026-04-28
132
+
133
+ ### Added
134
+ - Persistent WASM SQLite cache (`CacheManager`)
135
+ - Structured logging via pino (stderr-safe for MCP)
136
+ - File watcher via chokidar
137
+ - Multi-process file locking via proper-lockfile
138
+ - Rolling 5-version backup system
139
+ - `rollback_file` and `clean_backups` tools
140
+ - 74 tests (unit + integration + performance + stress)
package/INSTRUCTIONS.md CHANGED
@@ -108,7 +108,7 @@ newContent: "return `Hello, ${name}`;"
108
108
  maxResults: 10
109
109
  ```
110
110
 
111
- ### Fuzzy Search (v3.6.2)
111
+ ### Fuzzy Search
112
112
  ```
113
113
  @mcp-code-context/search_code_pattern
114
114
  rootDir: /project/root
@@ -189,14 +189,14 @@ Rename across entire codebase in one operation:
189
189
  ## ⚠️ Common Mistakes
190
190
 
191
191
  ### ❌ Mistake 1: Forgetting projectRoot
192
- ```
192
+ ```typescript
193
193
  // WRONG
194
194
  @mcp-code-context/read_file_surgical
195
195
  filePath: /path/to/file.ts
196
196
  ```
197
197
 
198
198
  ### ❌ Mistake 2: Skipping Phase 1
199
- ```
199
+ ```typescript
200
200
  // WRONG - No preview
201
201
  @mcp-code-context/write_file_surgical
202
202
  confirm: true
@@ -204,13 +204,13 @@ Rename across entire codebase in one operation:
204
204
  ```
205
205
 
206
206
  ### ❌ Mistake 3: Incomplete Symbol Code
207
- ```
207
+ ```typescript
208
208
  // WRONG - Missing function signature
209
209
  newContent: "{ return 42; }"
210
210
  ```
211
211
 
212
212
  ### ❌ Mistake 4: Not Checking Impact
213
- ```
213
+ ```typescript
214
214
  // WRONG - Removing without checking dependencies
215
215
  @mcp-code-context/remove_symbol
216
216
  symbolName: importantFunction
@@ -253,14 +253,32 @@ newContent: "{ return 42; }"
253
253
 
254
254
  ---
255
255
 
256
- ## 🚀 v3.6.2 Features
257
-
256
+ ## 🚀 v3.7.0 Features
257
+
258
+ ### New Tools
259
+ - **`get_session_stats`**: Session-scoped stats (pending ops, locks held, rate limiter tokens)
260
+ - **`clear_session_cache`**: Clear cache for current session only (no impact on other clients)
261
+ - **`list_pending_operations`**: List all pending operations (for recovery after crash)
262
+
263
+ ### Improvements
264
+ - ✅ **Session-scoped state**: No state leakage between MCP clients
265
+ - ✅ **Crash recovery**: SQLite-backed pending operations store
266
+ - ✅ **Expanded ReDoS protection**: 15+ patterns (was 6)
267
+ - ✅ **Auto-persist before eviction**: Cache data preserved
268
+ - ✅ **Higher file limits**: MAX_FILES = 2000 (was 500)
269
+
270
+ ### Previously Added in v3.7.0
271
+ - ✅ **4 New Tools**: `search_symbols`, `explain_symbol`, `batch_read`, `get_rate_limit_status`
272
+ - ✅ **`diffFormat`**: Control diff verbosity (`unified`, `compact`, `summary`, `none`)
273
+ - ✅ **Phase 2 optimized**: No need to resend `newContent`/`code` — server stores it from Phase 1
274
+ - ✅ **`aroundPattern` line number**: Output now shows `Match found at line N`
275
+ - ✅ **Rate limiter in stats**: `get_server_stats` includes token balance and operation costs
276
+ - ✅ **Cache hit rate**: `get_cache_stats` includes `hits`, `misses`, `hitRate`
277
+ - ✅ **Watcher paths**: `get_file_watcher_status` includes list of watched files
258
278
  - ✅ **Fuzzy Search**: Find similar patterns with typo tolerance
259
279
  - ✅ **Pagination**: Default 10 results, use `startIndex` for more
260
- - ✅ **Token Optimization**: Phase 2 no longer repeats diff (97% savings)
261
- - ✅ **Auto-Optimize**: Large repos automatically disable symbols
262
- - ✅ **File Watcher**: Auto-invalidate cache on file changes
263
280
  - ✅ **Persistent Cache**: 10x faster with sql.js WASM SQLite
281
+ - ✅ **File Watcher**: Auto-invalidate cache on file changes
264
282
 
265
283
  ---
266
284
 
@@ -270,5 +288,6 @@ See `llms.txt` for complete API reference and technical details.
270
288
 
271
289
  ---
272
290
 
273
- **Version**: 3.6.2
274
- **Last Updated**: May 1, 2026
291
+ **Version**: 3.7.0
292
+ **Last Updated**: June 8, 2026
293
+ **Status**: Production-ready with session-scoped state and crash recovery