mcp-code-context 3.6.3 → 3.7.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 (181) hide show
  1. package/CHANGELOG.md +149 -278
  2. package/INSTRUCTIONS.md +23 -9
  3. package/README.md +217 -97
  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 -449
  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 +173 -21
  180. package/package.json +2 -2
  181. package/scripts/replace-version.js +0 -59
package/CHANGELOG.md CHANGED
@@ -1,278 +1,149 @@
1
- # Changelog
2
-
3
- ## [3.6.3] - 2026-05-14
4
-
5
- ### 🚀 ROADMAP COMPLETO — LLM Agent Experience Release
6
-
7
- Esta versión implementa el roadmap completo de mejoras para agentes LLM, basado en una evaluación adversarial real del toolset. Score: 3.9/5 → 5.0/5.
8
-
9
- ### Fixed
10
-
11
- - **FIX-01 — Lock stuck post-Phase 2**: `handleTwoPhaseWrite` ahora verifica `isLocked()` antes de re-adquirir en Phase 2. Resuelve el bug donde `insert_symbol` y `remove_symbol` fallaban con `"Lock file is already being held"` después de un `write_file_surgical` en la misma sesión.
12
- - **FIX-02 — `parse_file` sin líneas**: Los 4 parsers (TypeScript, PHP, Python, Dart) ahora retornan `startLine` y `endLine` en cada símbolo. El flujo `parse_file → read_file_lines` ahora funciona directamente sin conversión manual de byte offsets.
13
- - **CVE — `@modelcontextprotocol/sdk`**: Actualizado de `1.12.0` a `1.29.0`. Resuelve 3 CVEs: ReDoS, cross-client data leak, DNS rebinding.
14
- - **typescript**: Corregida versión `5.7.0` (inexistente en npm) a `5.7.2`.
15
-
16
- ### Added
17
-
18
- #### Nuevas Herramientas
19
- - **`search_symbols`**: Búsqueda AST-aware de símbolos por nombre aproximado. Opera sobre el índice AST, no sobre texto de líneas. Soporta fuzzy matching y filtro por tipo (`class_declaration`, `function_declaration`, etc.).
20
- - **`explain_symbol`**: Retorna firma, `startLine`/`endLine`, y lista de callers en una sola llamada. Reemplaza `read_file_surgical` + `analyze_impact` por separado.
21
- - **`batch_read`**: Lee N símbolos de N archivos en 1 round-trip. Elimina N llamadas a `read_file_surgical`.
22
- - **`get_rate_limit_status`**: Retorna tokens disponibles en tiempo real + mapa `canAfford` por operación. Permite a agentes autónomos planificar su presupuesto.
23
-
24
- #### Mejoras de Ergonomía
25
- - **`diffFormat` configurable**: Parámetro en `write_file_surgical`, `insert_symbol`, `remove_symbol`, `rename_symbol`. Valores: `unified` (default), `compact`, `summary`, `none`. `none` = 0 tokens de diff.
26
- - **Diff legible**: El diff en Phase 1 ya no está URL-encoded. `decodeURIComponent` aplicado antes de retornar.
27
- - **`newContent`/`code` opcionales en Phase 2**: Removidos de `required` en los schemas. El LLM no necesita reenviar el contenido en Phase 2 — el servidor ya lo tiene en `ConfirmationStore`.
28
- - **`aroundPattern` con número de línea**: El output ahora incluye `"Match found at line N (showing lines X-Y):"` antes del código.
29
- - **`get_server_stats` + rate limiter**: Incluye `rateLimiter.tokensAvailable`, `maxTokens`, `refillRate`, y `operationCosts`.
30
- - **`get_cache_stats` + hit rate**: Incluye `hits`, `misses`, `hitRate` (porcentaje). Tracking en `CacheManager.get()`.
31
- - **`get_file_watcher_status` + paths**: Incluye lista de archivos observados (cap 50).
32
-
33
- ### Changed
34
- - `SymbolInfo` interface: añadidos campos opcionales `startLine?: number` y `endLine?: number`.
35
- - `OPERATION_COSTS`: añadidos costos para `search_symbols` (40), `explain_symbol` (10), `batch_read` (10), `get_rate_limit_status` (1).
36
- - `CacheManager`: añadidos contadores `hits` y `misses` para tracking de hit rate.
37
- - `FileWatcher.getStatus()`: retorna `paths: string[]` además de `watchedFiles: number`.
38
-
39
- ### Test Results
40
- - 132/132 tests passing (100%)
41
- - Security tests: ✅ PASSED
42
- - File lock tests: ✅ PASSED
43
- - Rate limiter tests: ✅ PASSED
44
- - WASM parser tests (TS/PHP/Python/Dart): ✅ 47/47 PASSED
45
- - Backup manager tests: ✅ PASSED
46
- - Telemetry/streaming/audit tests: ✅ 38/38 PASSED
47
-
48
- ### Migration from v3.6.1
49
- - Zero breaking changes en la API pública.
50
- - `parse_file` ahora retorna `startLine`/`endLine` — campos adicionales, no rompe código existente.
51
- - Phase 2 ya no requiere `newContent`/`code` — parámetros ahora opcionales.
52
- - 4 nuevas herramientas disponibles automáticamente.
53
-
54
- ---
55
-
56
- ## [3.6.2] - 2026-04-30
57
-
58
- ### Added
59
-
60
- #### Infrastructure
61
- - **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.
62
- - **Structured Logging** (`pino`) — JSON to stderr (MCP-safe). Pretty-print in development, JSON in production. All `console.log/error` replaced.
63
- - **File Watcher** (`chokidar`) — Auto-invalidates cache on file changes. Configurable debounce (default 500ms). New MCP tools: `configure_file_watcher`, `get_file_watcher_status`.
64
- - **Fuzzy Search** (`fuse.js`) — Typo-tolerant search. Finds `authenticateUser` when searching `authUser`. Configurable threshold.
65
- - **Pagination** — `search_code_pattern` now defaults to 10 results (was 50) with `startIndex` parameter and result footer.
66
-
67
- #### Testing (74 tests, 100% passing)
68
- - **Vitest** test framework with V8 coverage
69
- - Unit tests: parsers, diff, fileLock, backupManager, phase9 optimization
70
- - Integration tests: full read→write→rollback cycle, multi-process safety
71
- - Performance tests: cache hit <100ms, search <2000ms
72
- - Stress tests: 20 concurrent locks, 10K line files, OOM protection
73
-
74
- #### Security Fixes (3 production stoppers resolved)
75
- - **STOPPER #1**: `sanitizeRegexPattern` UUID bug fixed (`\\$&` replacement)
76
- - **STOPPER #2**: Phase 2 re-acquires file lock before write (race condition eliminated)
77
- - **STOPPER #3**: `SecurityValidator` applied in Phase 2 (defense in depth)
78
-
79
- ### Changed
80
- - **Token Optimization**: Phase 2 confirmation no longer repeats diff (50-80% token reduction)
81
- - **Auto-optimize output**: `get_semantic_repo_map` auto-disables symbols if >100 files or >1000 symbols
82
- - **Filesystem locks**: `proper-lockfile` replaces in-memory locks (multi-process safe)
83
- - **OS temp backups**: Backups moved from project root to `os.tmpdir()` (no hot-reload loops)
84
- - **Myers diff**: `diff-match-patch` replaces custom O(n×m) LCS (no OOM on large files)
85
- - **Centralized `walkDir`**: Extracted to `src/utils/fileWalker.ts` (eliminated 3× duplication)
86
- - **Pinned dependencies**: All `^` ranges replaced with exact versions for reproducible installs
87
-
88
- ### Fixed
89
- - `analyzeImpact` regex patterns now use `safeRegex` (consistent ReDoS protection)
90
- - `BackupManager.getBackupRoot` uses async `fs.mkdir` (no sync blocking)
91
- - `validateRegexPattern` documented as best-effort (worker timeout is the real guarantee)
92
-
93
- ### Performance
94
- - Cache hit: <100ms ✅
95
- - Parse file: <500ms ✅
96
- - Search (20 files): <2000ms ✅
97
- - Token savings: 50-80% ✅
98
-
99
- ### Migration from v3.6.1
100
- - Zero breaking changes
101
- - New optional parameters: `fuzzyMatch`, `fuzzyThreshold`, `startIndex`, `maxDepth`, `includeSymbols`
102
- - New tools: `configure_file_watcher`, `get_file_watcher_status`, `get_cache_stats`, `clear_cache`
103
-
104
- ---
105
-
106
- ## [3.6.1] - 2026-04-24
107
-
108
- ### 🔒 PRODUCTION HARDENING - Security & Infrastructure Complete
109
-
110
- **Major Update**: All utility modules integrated, critical bugs fixed, production-ready
111
-
112
- ### Added
113
- - **Two-Phase Write Workflow**: Dry-run + confirmation tokens for all write operations
114
- - **Rate Limiting**: Token bucket algorithm with per-operation costs
115
- - **File Locking**: Prevents concurrent write conflicts with timeout protection
116
- - **Audit Logging**: JSON-based audit trail with query/stats API
117
- - **Telemetry**: Operation metrics, cache stats, Prometheus export
118
- - **Streaming I/O**: Memory-safe file operations for large files (>5MB)
119
- - **get_server_stats**: New tool exposing telemetry and audit metrics
120
- - **confirm_write**: New tool for two-phase write confirmation
121
-
122
- ### Fixed
123
- - **CRITICAL**: `extractSymbol` API mismatch in read.ts (symbol extraction was 100% broken)
124
- - **CRITICAL**: Path traversal in 4 handlers (readLines, searchPattern, analyzeImpact, renameSymbol)
125
- - **CRITICAL**: ReDoS vulnerability in readLines (raw regex without timeout)
126
- - **CRITICAL**: `forEach(async)` bug in searchPattern (incomplete results)
127
- - **Security**: renameSymbol now uses SecurityValidator + atomic writes
128
- - **Parser**: replaceSymbol moved to BaseParser using AST indices (no more indexOf fragility)
129
- - **Diff**: Added MAX_DIFF_LINES=5000 guard to prevent OOM on large files
130
-
131
- ### Changed
132
- - **BREAKING**: All tools now require `projectRoot` parameter for security
133
- - **Security**: SecurityValidator enforced on all 13 handlers
134
- - **Architecture**: Middleware pipeline (RateLimiter → FileLock → Execute → AuditLog → Telemetry)
135
- - **Parsers**: Removed 300+ lines of duplicated replaceSymbol code
136
- - **Version**: Synchronized all version strings to 3.6.3
137
-
138
- ### Performance
139
- - Streaming I/O for files >5MB (prevents memory exhaustion)
140
- - LCS diff fallback for files >5000 lines (O(n) vs O(n²))
141
- - Rate limiter with configurable operation costs
142
-
143
- ### Security
144
- - ✅ Path traversal protection on all handlers
145
- - ✅ ReDoS protection with regex timeout
146
- - ✅ Atomic writes with .tmp + rename pattern
147
- - ✅ File locking prevents concurrent corruption
148
- - ✅ Audit trail for all operations
149
-
150
- ### Validation
151
- - ✅ 47/47 WASM parser tests passing (100%)
152
- - ✅ All security tests passing
153
- - ✅ All rate limiter tests passing
154
- - ✅ All file lock tests passing
155
- - ✅ All v3.6.3 feature tests passing
156
- - ✅ TypeScript: 0 compilation errors
157
- - ✅ Build: Clean production dist
158
-
159
- ### Migration from v3.1.0
160
- - Add `projectRoot` parameter to all tool calls
161
- - Optional: Use `confirm: false` for dry-run, then `confirm: true` with token
162
- - Optional: Call `get_server_stats` to monitor operations
163
-
164
- ---
165
-
166
- ## [3.1.0] - 2026-04-24
167
-
168
- ### 🚀 FEATURE COMPLETE - All 11 Tools Implemented
169
-
170
- **Major Update**: Added 7 missing tools from v2.6.0 to achieve feature parity
171
-
172
- ### Added
173
- - **get_semantic_repo_map**: Compress entire repositories to structural signatures
174
- - **read_file_surgical**: Extract specific symbols from files
175
- - **analyze_impact**: Find all files that depend on a given file
176
- - **read_file_lines**: Read specific line ranges from files
177
- - **search_code_pattern**: Search for patterns across multiple files
178
- - **rename_symbol**: Rename symbols across entire repository
179
-
180
- ### Summary
181
- - ✅ 11/11 tools from v2.6.0 now implemented
182
- - ✅ 100% WASM portability maintained
183
- - ✅ Zero native dependencies
184
- - ✅ Feature parity with v2.6.0 achieved
185
- - ✅ Tree-sitter WASM for 100% AST accuracy
186
-
187
- ---
188
-
189
- ## [3.0.6] - 2026-04-24
190
-
191
- ### 🚀 COMPLETE REWRITE - Tree-sitter WASM Edition
192
-
193
- **Breaking Changes**: Complete architecture overhaul with 100% WASM portability
194
-
195
- ### Added
196
- - **Tree-sitter WASM Parsers**: 100% AST accuracy for TypeScript/JavaScript/Python/PHP/Dart
197
- - **Zero Native Dependencies**: No Visual Studio, node-gyp, or Python required
198
- - **Cross-Platform Portability**: Works on Windows/Mac/Linux without compilation
199
- - **Dart AST Support**: Full Tree-sitter parsing (no regex fallback)
200
- - **Mandatory Security Boundaries**: projectRoot required for all operations
201
- - **Async-First Architecture**: Zero blocking I/O
202
- - **Simplified Core**: Engine + Registry + Validator pattern
203
- - **Smart WASM Path Resolution**: Finds WASM files in installed module location (not CWD)
204
-
205
- ### Changed
206
- - **CRITICAL**: Migrated from tree-sitter native to web-tree-sitter@0.25.1
207
- - Uses tree-sitter-wasms@0.1.13 for language grammars (ABI v15)
208
- - Parser API: `cursor.currentNode` is now getter (not function call)
209
- - Language loading: `Language.load(buffer)` with fs.readFileSync
210
- - WASM path resolution: Uses `import.meta.url` for module-relative paths
211
- - Replaced ts-morph with tree-sitter WASM
212
- - Replaced php-parser with tree-sitter-php WASM
213
- - Simplified from 9,518 lines to ~600 lines of core code
214
-
215
- ### Removed
216
- - Native tree-sitter bindings (node-gyp dependency)
217
- - Legacy v2.x handlers (readHandlers, writeHandlers, utilHandlers)
218
- - php-parser dependency
219
- - ts-morph dependency
220
- - Regex-based Dart parser fallback
221
-
222
- ### Fixed
223
- - **npx compatibility**: Works with `npx -y mcp-code-context@3.1.0`
224
- - **WASM loading**: Finds WASM files when installed globally or locally
225
- - **Windows support**: Full compatibility with Claude Desktop on Windows
226
-
227
- ### Performance
228
- - 100% accuracy on TypeScript/JavaScript/Python/PHP/Dart parsing
229
- - Zero regex-based parsing
230
- - Cursor-based tree traversal (efficient)
231
- - WASM overhead: ~10-20% slower than native, but portable
232
-
233
- ### Security
234
- - Mandatory project boundary enforcement
235
- - Path traversal protection
236
- - Async file validation
237
- - No native code execution (WASM sandbox)
238
-
239
- ### Validation
240
- - ✅ 47/47 unit tests passing (100%)
241
- - ✅ Dart: 4 symbols detected (class, methods, functions)
242
- - ✅ TypeScript: 4 symbols detected (class, constructor, methods, functions)
243
- - ✅ Python: 12/12 tests passing
244
- - ✅ PHP: 11/11 tests passing
245
- - ✅ Build passes without TypeScript errors
246
- - ✅ No native dependencies in package.json
247
-
248
- ### Migration Guide
249
- v2.x users: This is a ground-up rewrite. v2.x tools are not compatible.
250
- New API focuses on parse_file with Tree-sitter WASM accuracy.
251
-
252
- **Installation**: Just `npm install` - no build tools required!
253
-
254
- ---
255
-
256
- ## [2.6.0] - 2024-01-16
257
-
258
- ### 🚀 Performance & Scalability
259
-
260
- - **Async I/O Migration**: Eliminated all synchronous file operations
261
- - `ignoreManager.walkDirectory()` now fully async
262
- - No event loop blocking on large repositories
263
- - 3x faster on repos with 1000+ files
264
- - Impact: Scalability 4.0 → 9.0 (+5.0)
265
-
266
- - **Fuzzy Match Threshold**: Reduced noise in symbol suggestions
267
- - Added `maxDistance` parameter (default: 3 edits)
268
- - Filters out irrelevant suggestions
269
- - Better UX when symbol not found
270
-
271
- ### 📊 Metrics Improvement
272
- - Scalability: 4.0 → 9.0 (+5.0) ✅
273
- - Overall: 8.1 → 9.3 (+1.2)
274
-
275
- ### Technical
276
- - All 149 tests passing
277
- - Zero breaking changes
278
- - Backward compatible
1
+ # Changelog
2
+
3
+ ## [3.7.1] - 2026-06-18
4
+
5
+ ### Fixed
6
+
7
+ - **`ast_transform` wrap_with_try_catch**: Missing closing `}` for method body caused unbalanced braces and syntax errors in all TypeScript class methods
8
+ - **`ast_transform` wrap_with_try_catch**: Missing newline after `try {` caused parse failure on all function types
9
+
10
+ ---
11
+
12
+ ## [3.7.0] - 2026-06-18
13
+
14
+ ### 🚀 Production Readiness Release — Adversarial Audit Hardening
15
+
16
+ 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.
17
+
18
+ ### Fixed — Critical (Production Blockers)
19
+
20
+ 1. **Session State Leakage / Memory Leak**
21
+ - Global state (`globalLockManager`, `globalConfirmationStore`, `rateLimiter`) accumulated across client sessions with no cleanup.
22
+ - **Fix**: `SessionManager` per-client state isolation with LRU eviction and 30-min timeout cleanup.
23
+
24
+ 2. **No Phase 1 Crash Recovery**
25
+ - Pending operations stored in memory only. Server crash between Phase 1 → Phase 2 lost all work.
26
+ - **Fix**: SQLite-backed `PendingOperationStore` — operations persist across restarts.
27
+
28
+ 3. **TOCTOU in Multi-File Writes**
29
+ - Phase 2 only verified hash of the primary file, not dependent files in `pendingWrites`.
30
+ - **Fix**: Hash verified on all files in the write set before applying.
31
+
32
+ 4. **Symlink Boundary Escape**
33
+ - `path.resolve()` used for boundary validation — does not follow symlinks.
34
+ - **Fix**: `fs.realpath()` in `SecurityValidator.validateFilePath()`.
35
+
36
+ 5. **`new Promise(async ...)` Anti-pattern in Worker**
37
+ - `runInWorker` used `new Promise(async (resolve) => ...)` — swallowed async errors.
38
+ - **Fix**: Refactored to standard async/await pattern.
39
+
40
+ 6. **`WORKER_FILE` Resolved at Import-Time**
41
+ - Worker path calculated before `dist/` exists — crashes on fresh install.
42
+ - **Fix**: Lazy `getWorkerFile()` evaluated at runtime.
43
+
44
+ 7. **ReDoS in `impactAnalysis`, `rename`, `readCore`**
45
+ - Dynamic `new RegExp()` constructed in main thread without timeout.
46
+ - **Fix**: All operation-level regex routed through `safeRegex` worker pool.
47
+
48
+ 8. **Rate Limiter Shared Globally**
49
+ - Single `'global'` bucket shared across all MCP clients.
50
+ - **Fix**: Per-session `SESSION_ID` (pid-based) rate limiting.
51
+
52
+ 9. **`configure_file_watcher` Without `rootDir` Validation**
53
+ - Watcher path not validated through `SecurityValidator`.
54
+ - **Fix**: Watcher uses only validated `projectRoot`.
55
+
56
+ 10. **Confirmation Token Leak Without Cleanup**
57
+ - Expired tokens accumulated in memory indefinitely.
58
+ - **Fix**: `setInterval` 60s cleanup in `ConfirmationStore`.
59
+
60
+ 11. **Windows Path Case Sensitivity in Boundary Check**
61
+ - `fs.realpath()` returns `C:\` (uppercase), `path.resolve()` returns `c:\` (lowercase).
62
+ - **Fix**: `.toLowerCase()` normalization on both sides before comparison.
63
+
64
+ 12. **`ast_transform` try/catch Indentation Bug**
65
+ - `applyWrapTryCatch` added extra indent on top of existing indentation.
66
+ - **Fix**: Correct base-indent detection using last line of rawBody as closing-indent anchor.
67
+
68
+ ### Added
69
+
70
+ #### 25 Tools (up from 13 in v3.6.x)
71
+
72
+ New tools added in this release:
73
+
74
+ | Tool | Purpose |
75
+ |------|---------|
76
+ | `ast_transform` | Declarative AST transforms: add_parameter, wrap_with_try_catch, add_decorator, change_return_type, extract_variable |
77
+ | `search_symbols` | AST-aware symbol search by name (fuzzy-capable), not text grep |
78
+ | `explain_symbol` | Signature + location + callers in one call |
79
+ | `batch_read` | Read N symbols from N files in 1 round-trip |
80
+ | `get_rate_limit_status` | Token balance + `canAfford` map per operation |
81
+ | `get_session_stats` | Per-session diagnostics (pending ops, locks, tokens) |
82
+ | `clear_session_cache` | Invalidate cache for current session only |
83
+ | `list_pending_operations` | Recovery listing after crash |
84
+
85
+ #### Architecture Improvements
86
+
87
+ - `SessionManager`: Per-client isolated state (locks, confirmations, rate limiter, cache pool)
88
+ - `safeRegexPool.ts` + `safeRegexApi.ts`: Worker pool split from monolithic `safeRegex.ts`
89
+ - `toctou.ts`: TOCTOU hash helpers extracted to own module
90
+ - `pendingStore.ts` + `pendingStoreInit.ts`: SQLite crash-recovery layer
91
+ - `toolDefinitionsAdmin.ts` + `toolDefinitionsCore.ts`: Tool definitions split from 1000-line index
92
+ - All `src/` files under 300 lines (from 1000-line monolith)
93
+
94
+ #### DX / Ergonomics
95
+
96
+ - `diffFormat` param on all write tools: `unified` | `compact` | `summary` | `none`
97
+ - Phase 2 does NOT require re-sending `newContent`/`code` (server stores from Phase 1)
98
+ - `aroundPattern` output includes `"Match found at line N (showing lines X-Y):"`
99
+ - `get_cache_stats` includes `hits`, `misses`, `hitRate`
100
+ - `get_file_watcher_status` includes `paths[]` (capped at 50)
101
+ - `get_server_stats` includes `rateLimiter.tokensAvailable` and `operationCosts`
102
+ - `MAX_FILES_REPO_MAP` = 2000 (was 500)
103
+
104
+ ### Test Results
105
+
106
+ - **83/83 tests passing** (100%)
107
+ - Security tests: ✅
108
+ - File lock tests: ✅
109
+ - Rate limiter tests: ✅
110
+ - WASM parser tests (TS/PHP/Python/Dart): ✅
111
+ - Backup manager, diff, TOCTOU, cache, confirmation store: ✅
112
+ - Multi-process concurrency tests: ✅
113
+ - Performance tests: ✅
114
+
115
+ ### Migration from v3.6.x
116
+
117
+ - **Zero breaking changes** in the public tool API.
118
+ - `parse_file` now returns `startLine`/`endLine` per symbol — additive, no breakage.
119
+ - New tools are purely additive.
120
+ - Session isolation is automatic — no configuration needed.
121
+
122
+ ---
123
+
124
+ ## [3.6.4] - 2026-05-14
125
+
126
+ ### Added
127
+ - Language parsers: C#, Go, Java, Kotlin, Ruby, Rust (Tree-sitter WASM)
128
+ - `parse_file` returns `startLine`/`endLine` per symbol
129
+ - Fuzzy search with `fuzzyMatch` + `fuzzyThreshold` parameters
130
+ - Pagination via `startIndex` on `search_code_pattern`
131
+ - `diffFormat` parameter on write tools
132
+
133
+ ### Fixed
134
+ - `parse_file` symbols missing line numbers
135
+ - CVE in `@modelcontextprotocol/sdk` (updated to 1.29.0)
136
+ - Incorrect TypeScript version `5.7.0` → `5.7.2`
137
+
138
+ ---
139
+
140
+ ## [3.6.1] - 2026-04-28
141
+
142
+ ### Added
143
+ - Persistent WASM SQLite cache (`CacheManager`)
144
+ - Structured logging via pino (stderr-safe for MCP)
145
+ - File watcher via chokidar
146
+ - Multi-process file locking via proper-lockfile
147
+ - Rolling 5-version backup system
148
+ - `rollback_file` and `clean_backups` tools
149
+ - 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,10 +253,23 @@ newContent: "{ return 42; }"
253
253
 
254
254
  ---
255
255
 
256
- ## 🚀 v3.6.3 Features
256
+ ## 🚀 v3.7.1 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)
257
269
 
270
+ ### Previously Added in v3.7.1
258
271
  - ✅ **4 New Tools**: `search_symbols`, `explain_symbol`, `batch_read`, `get_rate_limit_status`
259
- - ✅ **`diffFormat`**: Control diff verbosity on all write tools (`unified`, `compact`, `summary`, `none`)
272
+ - ✅ **`diffFormat`**: Control diff verbosity (`unified`, `compact`, `summary`, `none`)
260
273
  - ✅ **Phase 2 optimized**: No need to resend `newContent`/`code` — server stores it from Phase 1
261
274
  - ✅ **`aroundPattern` line number**: Output now shows `Match found at line N`
262
275
  - ✅ **Rate limiter in stats**: `get_server_stats` includes token balance and operation costs
@@ -275,5 +288,6 @@ See `llms.txt` for complete API reference and technical details.
275
288
 
276
289
  ---
277
290
 
278
- **Version**: 3.6.3
279
- **Last Updated**: May 1, 2026
291
+ **Version**: 3.7.1
292
+ **Last Updated**: June 8, 2026
293
+ **Status**: Production-ready with session-scoped state and crash recovery