mcp-code-context 2.5.1 → 3.0.4

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 (129) hide show
  1. package/CHANGELOG.md +92 -236
  2. package/README.md +304 -298
  3. package/dist/src/core/engine.d.ts +21 -0
  4. package/dist/src/core/engine.js +68 -0
  5. package/dist/src/core/engine.js.map +1 -0
  6. package/dist/src/core/validator.d.ts +15 -0
  7. package/dist/src/core/validator.js +44 -0
  8. package/dist/src/core/validator.js.map +1 -0
  9. package/dist/src/index.d.ts +7 -11
  10. package/dist/src/index.js +182 -397
  11. package/dist/src/index.js.map +1 -1
  12. package/dist/src/operations/write.d.ts +51 -0
  13. package/dist/src/operations/write.js +169 -0
  14. package/dist/src/operations/write.js.map +1 -0
  15. package/dist/src/parsers/base.d.ts +28 -0
  16. package/dist/src/parsers/base.js +27 -0
  17. package/dist/src/parsers/base.js.map +1 -0
  18. package/dist/src/parsers/dartTreeSitter.d.ts +13 -0
  19. package/dist/src/parsers/dartTreeSitter.js +91 -0
  20. package/dist/src/parsers/dartTreeSitter.js.map +1 -0
  21. package/dist/src/parsers/php.d.ts +12 -0
  22. package/dist/src/parsers/php.js +86 -0
  23. package/dist/src/parsers/php.js.map +1 -0
  24. package/dist/src/parsers/python.d.ts +12 -0
  25. package/dist/src/parsers/python.js +86 -0
  26. package/dist/src/parsers/python.js.map +1 -0
  27. package/dist/src/parsers/registry.d.ts +15 -0
  28. package/dist/src/parsers/registry.js +70 -0
  29. package/dist/src/parsers/registry.js.map +1 -0
  30. package/dist/src/parsers/typescript.d.ts +13 -0
  31. package/dist/src/parsers/typescript.js +98 -0
  32. package/dist/src/parsers/typescript.js.map +1 -0
  33. package/llms.txt +246 -234
  34. package/mcp-code-context-3.0.2.tgz +0 -0
  35. package/package.json +59 -57
  36. package/tsconfig.tests.json +27 -0
  37. package/.io/RULES.md +0 -12
  38. package/CONTRIBUTING.md +0 -243
  39. package/PLAN_v2.5.0.md +0 -407
  40. package/TROUBLESHOOTING.md +0 -38
  41. package/dist/src/ast/dartCompressor.d.ts +0 -27
  42. package/dist/src/ast/dartCompressor.js +0 -859
  43. package/dist/src/ast/dartCompressor.js.map +0 -1
  44. package/dist/src/ast/phpCompressor.d.ts +0 -24
  45. package/dist/src/ast/phpCompressor.js +0 -634
  46. package/dist/src/ast/phpCompressor.js.map +0 -1
  47. package/dist/src/ast/semanticCompressor.d.ts +0 -22
  48. package/dist/src/ast/semanticCompressor.js +0 -677
  49. package/dist/src/ast/semanticCompressor.js.map +0 -1
  50. package/dist/src/ast/writers/dartWriter.d.ts +0 -37
  51. package/dist/src/ast/writers/dartWriter.js +0 -544
  52. package/dist/src/ast/writers/dartWriter.js.map +0 -1
  53. package/dist/src/ast/writers/phpWriter.d.ts +0 -37
  54. package/dist/src/ast/writers/phpWriter.js +0 -411
  55. package/dist/src/ast/writers/phpWriter.js.map +0 -1
  56. package/dist/src/ast/writers/pyWriter.d.ts +0 -37
  57. package/dist/src/ast/writers/pyWriter.js +0 -355
  58. package/dist/src/ast/writers/pyWriter.js.map +0 -1
  59. package/dist/src/ast/writers/safeRename.d.ts +0 -14
  60. package/dist/src/ast/writers/safeRename.js +0 -258
  61. package/dist/src/ast/writers/safeRename.js.map +0 -1
  62. package/dist/src/ast/writers/symbolWriter.d.ts +0 -64
  63. package/dist/src/ast/writers/symbolWriter.js +0 -174
  64. package/dist/src/ast/writers/symbolWriter.js.map +0 -1
  65. package/dist/src/ast/writers/tsWriter.d.ts +0 -38
  66. package/dist/src/ast/writers/tsWriter.js +0 -344
  67. package/dist/src/ast/writers/tsWriter.js.map +0 -1
  68. package/dist/src/cache/astCache.d.ts +0 -39
  69. package/dist/src/cache/astCache.js +0 -169
  70. package/dist/src/cache/astCache.js.map +0 -1
  71. package/dist/src/handlers/readHandlers.d.ts +0 -70
  72. package/dist/src/handlers/readHandlers.js +0 -455
  73. package/dist/src/handlers/readHandlers.js.map +0 -1
  74. package/dist/src/handlers/utilHandlers.d.ts +0 -31
  75. package/dist/src/handlers/utilHandlers.js +0 -69
  76. package/dist/src/handlers/utilHandlers.js.map +0 -1
  77. package/dist/src/handlers/writeHandlers.d.ts +0 -57
  78. package/dist/src/handlers/writeHandlers.js +0 -499
  79. package/dist/src/handlers/writeHandlers.js.map +0 -1
  80. package/dist/src/tools/readFileLines.d.ts +0 -26
  81. package/dist/src/tools/readFileLines.js +0 -77
  82. package/dist/src/tools/readFileLines.js.map +0 -1
  83. package/dist/src/tools/searchCodePattern.d.ts +0 -37
  84. package/dist/src/tools/searchCodePattern.js +0 -144
  85. package/dist/src/tools/searchCodePattern.js.map +0 -1
  86. package/dist/src/utils/arrayUtils.d.ts +0 -12
  87. package/dist/src/utils/arrayUtils.js +0 -27
  88. package/dist/src/utils/arrayUtils.js.map +0 -1
  89. package/dist/src/utils/backupManager.d.ts +0 -31
  90. package/dist/src/utils/backupManager.js +0 -124
  91. package/dist/src/utils/backupManager.js.map +0 -1
  92. package/dist/src/utils/confirmationCache.d.ts +0 -16
  93. package/dist/src/utils/confirmationCache.js +0 -40
  94. package/dist/src/utils/confirmationCache.js.map +0 -1
  95. package/dist/src/utils/constants.d.ts +0 -46
  96. package/dist/src/utils/constants.js +0 -112
  97. package/dist/src/utils/constants.js.map +0 -1
  98. package/dist/src/utils/dependencyChecker.d.ts +0 -1
  99. package/dist/src/utils/dependencyChecker.js +0 -55
  100. package/dist/src/utils/dependencyChecker.js.map +0 -1
  101. package/dist/src/utils/diffEngine.d.ts +0 -21
  102. package/dist/src/utils/diffEngine.js +0 -163
  103. package/dist/src/utils/diffEngine.js.map +0 -1
  104. package/dist/src/utils/fuzzyMatch.d.ts +0 -8
  105. package/dist/src/utils/fuzzyMatch.js +0 -69
  106. package/dist/src/utils/fuzzyMatch.js.map +0 -1
  107. package/dist/src/utils/ignoreManager.d.ts +0 -30
  108. package/dist/src/utils/ignoreManager.js +0 -186
  109. package/dist/src/utils/ignoreManager.js.map +0 -1
  110. package/dist/src/utils/normalization.d.ts +0 -49
  111. package/dist/src/utils/normalization.js +0 -173
  112. package/dist/src/utils/normalization.js.map +0 -1
  113. package/dist/src/utils/projectRoot.d.ts +0 -17
  114. package/dist/src/utils/projectRoot.js +0 -42
  115. package/dist/src/utils/projectRoot.js.map +0 -1
  116. package/dist/src/utils/secureValidation.d.ts +0 -15
  117. package/dist/src/utils/secureValidation.js +0 -41
  118. package/dist/src/utils/secureValidation.js.map +0 -1
  119. package/dist/src/utils/syntaxValidator.d.ts +0 -15
  120. package/dist/src/utils/syntaxValidator.js +0 -218
  121. package/dist/src/utils/syntaxValidator.js.map +0 -1
  122. package/dist/src/utils/transactionManager.d.ts +0 -46
  123. package/dist/src/utils/transactionManager.js +0 -123
  124. package/dist/src/utils/transactionManager.js.map +0 -1
  125. package/dist/src/utils/validation.d.ts +0 -87
  126. package/dist/src/utils/validation.js +0 -231
  127. package/dist/src/utils/validation.js.map +0 -1
  128. package/docs/ARCHITECTURE.md +0 -300
  129. package/docs/architecture/ADR-001-modular-handlers.md +0 -119
@@ -0,0 +1,27 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "Node16",
5
+ "moduleResolution": "Node16",
6
+ "outDir": "./dist-tests",
7
+ "rootDir": ".",
8
+ "strict": true,
9
+ "esModuleInterop": true,
10
+ "skipLibCheck": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "resolveJsonModule": true,
13
+ "declaration": true,
14
+ "sourceMap": true,
15
+ "baseUrl": ".",
16
+ "paths": {
17
+ "web-tree-sitter": ["node_modules/web-tree-sitter/web-tree-sitter.d.ts"]
18
+ }
19
+ },
20
+ "include": [
21
+ "tests/test-wasm-parsers.ts",
22
+ "tests/manual/**/*"
23
+ ],
24
+ "exclude": [
25
+ "node_modules"
26
+ ]
27
+ }
package/.io/RULES.md DELETED
@@ -1,12 +0,0 @@
1
- # AURA RULES - antigravity-mcp-context
2
-
3
- ## Project Principles
4
- - **Surgical Precision**: Never replace more code than necessary.
5
- - **Safety First**: Always use the Two-Phase Write Workflow.
6
- - **AST Over Regex**: Prefer AST parsing for code modification.
7
- - **Atomic Transactions**: Multi-file changes must be atomic or reversible.
8
-
9
- ## Operational Constraints
10
- - Max file size for processing: 10MB.
11
- - Max files for repo map: 500.
12
- - All writes must generate a backup in `.mcp-backups/`.
package/CONTRIBUTING.md DELETED
@@ -1,243 +0,0 @@
1
- # Contributing to mcp-code-context
2
-
3
- Thank you for your interest in contributing! This document provides guidelines and instructions for contributing to this project.
4
-
5
- ## 🌟 Ways to Contribute
6
-
7
- - **Bug Reports**: Found a bug? Open an issue with detailed reproduction steps
8
- - **Feature Requests**: Have an idea? Describe the use case and expected behavior
9
- - **Code Contributions**: Submit pull requests for bug fixes or new features
10
- - **Documentation**: Improve README, add examples, fix typos
11
- - **Testing**: Add test cases, report edge cases
12
-
13
- ## 🚀 Getting Started
14
-
15
- ### Prerequisites
16
-
17
- - Node.js >= 18
18
- - npm or yarn
19
- - Git
20
-
21
- ### Setup Development Environment
22
-
23
- ```bash
24
- # Clone the repository
25
- git clone https://github.com/achatainga/mcp-code-context.git
26
- cd mcp-code-context
27
-
28
- # Install dependencies
29
- npm install
30
-
31
- # Build the project
32
- npm run build
33
-
34
- # Run tests
35
- npm test
36
- ```
37
-
38
- ## 📝 Development Workflow
39
-
40
- ### 1. Create a Branch
41
-
42
- ```bash
43
- git checkout -b feature/your-feature-name
44
- # or
45
- git checkout -b fix/your-bug-fix
46
- ```
47
-
48
- ### 2. Make Changes
49
-
50
- - Write clean, readable code
51
- - Follow existing code style
52
- - Add comments for complex logic
53
- - Update documentation if needed
54
-
55
- ### 3. Test Your Changes
56
-
57
- ```bash
58
- # Build
59
- npm run build
60
-
61
- # Run existing tests
62
- npm test
63
-
64
- # Test manually with MCP client
65
- node dist/src/index.js
66
- ```
67
-
68
- ### 4. Commit Your Changes
69
-
70
- Use conventional commit messages:
71
-
72
- ```bash
73
- git commit -m "feat: add new feature"
74
- git commit -m "fix: resolve bug in symbol extraction"
75
- git commit -m "docs: update README with examples"
76
- git commit -m "test: add tests for new tool"
77
- ```
78
-
79
- **Commit Types:**
80
- - `feat`: New feature
81
- - `fix`: Bug fix
82
- - `docs`: Documentation changes
83
- - `test`: Adding or updating tests
84
- - `refactor`: Code refactoring
85
- - `perf`: Performance improvements
86
- - `chore`: Maintenance tasks
87
-
88
- ### 5. Push and Create Pull Request
89
-
90
- ```bash
91
- git push origin feature/your-feature-name
92
- ```
93
-
94
- Then create a Pull Request on GitHub with:
95
- - Clear title and description
96
- - Reference any related issues
97
- - Screenshots/examples if applicable
98
-
99
- ## 🧪 Testing Guidelines
100
-
101
- ### Writing Tests
102
-
103
- Add tests in the `tests/` directory:
104
-
105
- ```typescript
106
- // tests/test-your-feature.ts
107
- import { yourFunction } from "../src/your-module.js";
108
-
109
- console.log("🧪 Testing your feature...\n");
110
-
111
- const result = yourFunction({ /* test input */ });
112
-
113
- if (result.success) {
114
- console.log("✅ PASS: Test description");
115
- } else {
116
- console.error("❌ FAIL: Test description");
117
- }
118
- ```
119
-
120
- ### Running Tests
121
-
122
- ```bash
123
- # Run all tests
124
- npm test
125
-
126
- # Run specific test
127
- npm run build && node dist/tests/test-your-feature.js
128
- ```
129
-
130
- ## 📚 Code Style
131
-
132
- ### TypeScript
133
-
134
- - Use TypeScript for all new code
135
- - Define interfaces for complex types
136
- - Use `const` over `let` when possible
137
- - Prefer explicit return types
138
-
139
- ### Naming Conventions
140
-
141
- - **Files**: `camelCase.ts` or `kebab-case.ts`
142
- - **Functions**: `camelCase`
143
- - **Classes**: `PascalCase`
144
- - **Constants**: `UPPER_SNAKE_CASE`
145
- - **Interfaces**: `PascalCase` (no `I` prefix)
146
-
147
- ### Comments
148
-
149
- ```typescript
150
- /**
151
- * Brief description of function
152
- *
153
- * @param param1 - Description
154
- * @param param2 - Description
155
- * @returns Description of return value
156
- */
157
- export function myFunction(param1: string, param2: number): Result {
158
- // Implementation
159
- }
160
- ```
161
-
162
- ## 🏗️ Project Structure
163
-
164
- ```
165
- mcp-code-context/
166
- ├── src/
167
- │ ├── index.ts # Main MCP server
168
- │ ├── ast/ # AST parsers and compressors
169
- │ │ ├── semanticCompressor.ts
170
- │ │ ├── dartCompressor.ts
171
- │ │ ├── phpCompressor.ts
172
- │ │ └── writers/ # Write tools
173
- │ ├── tools/ # New tools (read_file_lines, etc.)
174
- │ └── utils/ # Utilities
175
- ├── tests/ # Test files
176
- ├── dist/ # Compiled output (gitignored)
177
- └── docs/ # Documentation
178
- ```
179
-
180
- ## 🐛 Reporting Bugs
181
-
182
- When reporting bugs, include:
183
-
184
- 1. **Description**: Clear description of the issue
185
- 2. **Steps to Reproduce**: Minimal steps to reproduce
186
- 3. **Expected Behavior**: What should happen
187
- 4. **Actual Behavior**: What actually happens
188
- 5. **Environment**:
189
- - OS (Windows/macOS/Linux)
190
- - Node.js version
191
- - mcp-code-context version
192
- 6. **Code Sample**: Minimal reproducible example
193
- 7. **Error Messages**: Full error output
194
-
195
- ## 💡 Feature Requests
196
-
197
- When requesting features, include:
198
-
199
- 1. **Use Case**: Why is this feature needed?
200
- 2. **Proposed Solution**: How should it work?
201
- 3. **Alternatives**: Other approaches considered
202
- 4. **Examples**: Code examples of desired behavior
203
-
204
- ## 🔍 Code Review Process
205
-
206
- All contributions go through code review:
207
-
208
- 1. **Automated Checks**: Tests must pass
209
- 2. **Code Quality**: Follows style guidelines
210
- 3. **Documentation**: Updated if needed
211
- 4. **Testing**: Adequate test coverage
212
- 5. **Approval**: At least one maintainer approval
213
-
214
- ## 📄 License
215
-
216
- By contributing, you agree that your contributions will be licensed under the MIT License.
217
-
218
- ## 🙏 Recognition
219
-
220
- Contributors will be recognized in:
221
- - GitHub contributors page
222
- - Release notes (for significant contributions)
223
- - CHANGELOG.md
224
-
225
- ## 📞 Questions?
226
-
227
- - Open a GitHub Discussion
228
- - Comment on related issues
229
- - Reach out to maintainers
230
-
231
- ## 🎯 Priority Areas
232
-
233
- Current priority areas for contributions:
234
-
235
- 1. **Language Support**: Add support for more languages (Ruby, Go, Rust, etc.)
236
- 2. **Performance**: Optimize large repository scanning
237
- 3. **Testing**: Increase test coverage
238
- 4. **Documentation**: More examples and use cases
239
- 5. **Error Handling**: Improve error messages
240
-
241
- ---
242
-
243
- Thank you for contributing to mcp-code-context! 🚀
package/PLAN_v2.5.0.md DELETED
@@ -1,407 +0,0 @@
1
- # 🎯 PLAN MAESTRO v2.5.0 - Quick Wins
2
-
3
- **Estado:** EN PROGRESO
4
- **Inicio:** 2024-01-15
5
- **Estimado:** 1-2 semanas (30h)
6
- **Versión Base:** v2.4.1
7
-
8
- ---
9
-
10
- ## ✅ FASE 1: SYNTAX VALIDATION (COMPLETADA)
11
-
12
- **Tiempo:** 2h
13
- **Archivos creados:**
14
- - `src/utils/syntaxValidator.ts` ✅
15
- - `tests/test-syntax-validation.ts` ✅
16
-
17
- **Archivos modificados:**
18
- - `src/utils/transactionManager.ts` ✅ (agregado Phase 2: Syntax validation)
19
-
20
- **Tests:** 8/8 pasando ✅
21
-
22
- **Funcionalidad:**
23
- - Valida sintaxis antes de commit
24
- - Rollback automático si hay errores
25
- - Soporta: TS, JS, PHP, Dart, Python
26
-
27
- ---
28
-
29
- ## ✅ FASE 2: CACHE MEMORY LIMITS (COMPLETADA)
30
-
31
- **Tiempo:** 1h
32
- **Archivos modificados:**
33
- - `src/cache/astCache.ts` ✅
34
-
35
- **Archivos creados:**
36
- - `tests/test-cache-limits.ts` ✅
37
-
38
- **Tests:** 3/3 pasando ✅
39
-
40
- **Funcionalidad:**
41
- - Límite real en bytes (100MB default)
42
- - Eviction por bytes y entries
43
- - Tracking de memoria real
44
-
45
- ### Archivos a modificar:
46
- 1. `src/cache/astCache.ts`
47
-
48
- ### Cambios necesarios:
49
-
50
- ```typescript
51
- // ANTES (línea 25-30)
52
- export class LRUCache<K, V> {
53
- private cache: Map<K, CacheEntry<V>>;
54
- private maxSize: number;
55
- private currentSize: number;
56
-
57
- constructor(maxSize: number = 100) {
58
- this.cache = new Map();
59
- this.maxSize = maxSize;
60
- this.currentSize = 0;
61
- }
62
- }
63
-
64
- // DESPUÉS
65
- export class LRUCache<K, V> {
66
- private cache: Map<K, CacheEntry<V>>;
67
- private maxEntries: number;
68
- private maxBytes: number;
69
- private currentEntries: number;
70
- private currentBytes: number;
71
-
72
- constructor(maxEntries: number = 100, maxBytes: number = 100 * 1024 * 1024) {
73
- this.cache = new Map();
74
- this.maxEntries = maxEntries;
75
- this.maxBytes = maxBytes; // 100MB default
76
- this.currentEntries = 0;
77
- this.currentBytes = 0;
78
- }
79
-
80
- set(key: K, value: V, filePath?: string, estimatedSize: number = 1000): void {
81
- // Evict if over byte limit
82
- while (this.currentBytes + estimatedSize > this.maxBytes && this.cache.size > 0) {
83
- const oldestKey = this.cache.keys().next().value as K;
84
- const oldEntry = this.cache.get(oldestKey);
85
- if (oldEntry) {
86
- this.currentBytes -= oldEntry.size;
87
- this.cache.delete(oldestKey);
88
- this.currentEntries--;
89
- }
90
- }
91
-
92
- // Evict if over entry limit
93
- while (this.currentEntries >= this.maxEntries && this.cache.size > 0) {
94
- const oldestKey = this.cache.keys().next().value as K;
95
- const oldEntry = this.cache.get(oldestKey);
96
- if (oldEntry) {
97
- this.currentBytes -= oldEntry.size;
98
- this.cache.delete(oldestKey);
99
- this.currentEntries--;
100
- }
101
- }
102
-
103
- this.cache.set(key, { value, mtime, size: estimatedSize });
104
- this.currentEntries++;
105
- this.currentBytes += estimatedSize;
106
- }
107
- }
108
- ```
109
-
110
- ### Test a crear:
111
- - `tests/test-cache-memory-limits.ts`
112
-
113
- ---
114
-
115
- ## ✅ FASE 3: ABORTCONTROLLER SUPPORT (COMPLETADA)
116
-
117
- **Tiempo:** 1h
118
- **Archivos modificados:**
119
- - `src/handlers/readHandlers.ts` ✅
120
- - `src/utils/ignoreManager.ts` ✅
121
-
122
- **Funcionalidad:**
123
- - Timeout 60s en get_semantic_repo_map
124
- - Cancelación graceful
125
- - Signal propagation
126
-
127
- ### Archivos a modificar:
128
- 1. `src/handlers/readHandlers.ts` - handleGetSemanticRepoMap
129
- 2. `src/utils/ignoreManager.ts` - walkDirectoryAsync
130
-
131
- ### Cambios necesarios:
132
-
133
- ```typescript
134
- // En handleGetSemanticRepoMap (línea 47)
135
- export async function handleGetSemanticRepoMap(
136
- args: Record<string, unknown>,
137
- signal?: AbortSignal // ✅ Nuevo parámetro
138
- ) {
139
- // Crear timeout de 60s
140
- const controller = new AbortController();
141
- const timeout = setTimeout(() => controller.abort(), 60000);
142
-
143
- try {
144
- const files = await ignoreManager.walkDirectoryAsync(resolvedPath, controller.signal);
145
-
146
- // Check abort
147
- if (signal?.aborted || controller.signal.aborted) {
148
- throw new Error("Operation cancelled");
149
- }
150
-
151
- // ... resto del código
152
- } finally {
153
- clearTimeout(timeout);
154
- }
155
- }
156
-
157
- // En ignoreManager.ts walkDirectoryAsync
158
- private async walkAsync(
159
- currentDir: string,
160
- collected: string[],
161
- signal?: AbortSignal // ✅ Nuevo parámetro
162
- ): Promise<void> {
163
- // Check abort
164
- if (signal?.aborted) {
165
- throw new Error("Operation cancelled");
166
- }
167
-
168
- // ... resto del código
169
- }
170
- ```
171
-
172
- ### Test a crear:
173
- - `tests/test-abort-controller.ts`
174
-
175
- ---
176
-
177
- ## ✅ FASE 4: AST-AWARE DEPENDENCY CHECK (COMPLETADA)
178
-
179
- **Tiempo:** 2h
180
- **Archivos creados:**
181
- - `src/utils/dependencyChecker.ts` ✅
182
-
183
- **Archivos modificados:**
184
- - `src/handlers/writeHandlers.ts` ✅
185
-
186
- **Tests:** 149/149 pasando ✅
187
-
188
- **Funcionalidad:**
189
- - AST parsing para TS/JS/PHP
190
- - Ignora símbolos en comments/strings
191
- - Elimina falsos positivos
192
-
193
- ### Archivos a modificar:
194
- 1. `src/handlers/writeHandlers.ts` - handleRemoveSymbol (línea 480-510)
195
-
196
- ### Cambios necesarios:
197
-
198
- ```typescript
199
- // ANTES (línea 493-510) - Regex check
200
- const escaped = symbolName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
201
- const regex = new RegExp(`(?<=^|[^a-zA-Z0-9_$])(${escaped})(?=[^a-zA-Z0-9_$]|$)`);
202
-
203
- if (regex.test(fContent)) {
204
- return errorResponse(`Symbol "${symbolName}" used in ${path.relative(projectRoot, f)}. Use force: true to delete.`);
205
- }
206
-
207
- // DESPUÉS - AST check
208
- import { checkSymbolUsage } from "../utils/dependencyChecker.js";
209
-
210
- const isUsed = await checkSymbolUsage(f, fContent, symbolName);
211
- if (isUsed) {
212
- return errorResponse(`Symbol "${symbolName}" used in ${path.relative(projectRoot, f)}. Use force: true to delete.`);
213
- }
214
- ```
215
-
216
- ### Archivo a crear:
217
- - `src/utils/dependencyChecker.ts`
218
-
219
- ```typescript
220
- /**
221
- * AST-aware dependency checker
222
- * Checks if a symbol is actually used in code (not in comments/strings)
223
- */
224
-
225
- import * as ts from "typescript";
226
- import * as path from "node:path";
227
-
228
- export async function checkSymbolUsage(
229
- filePath: string,
230
- content: string,
231
- symbolName: string
232
- ): Promise<boolean> {
233
- const ext = path.extname(filePath).toLowerCase();
234
-
235
- switch (ext) {
236
- case ".ts":
237
- case ".tsx":
238
- case ".js":
239
- case ".jsx":
240
- return checkTSSymbolUsage(content, symbolName);
241
-
242
- case ".php":
243
- return checkPHPSymbolUsage(content, symbolName);
244
-
245
- default:
246
- // Fallback to regex for unsupported languages
247
- const escaped = symbolName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
248
- const regex = new RegExp(`(?<=^|[^a-zA-Z0-9_$])(${escaped})(?=[^a-zA-Z0-9_$]|$)`);
249
- return regex.test(content);
250
- }
251
- }
252
-
253
- function checkTSSymbolUsage(content: string, symbolName: string): boolean {
254
- const sourceFile = ts.createSourceFile(
255
- "temp.ts",
256
- content,
257
- ts.ScriptTarget.Latest,
258
- true
259
- );
260
-
261
- let found = false;
262
-
263
- function visit(node: ts.Node) {
264
- // Check identifiers (skip string literals and comments)
265
- if (ts.isIdentifier(node) && node.text === symbolName) {
266
- found = true;
267
- }
268
-
269
- if (!found) {
270
- ts.forEachChild(node, visit);
271
- }
272
- }
273
-
274
- visit(sourceFile);
275
- return found;
276
- }
277
-
278
- async function checkPHPSymbolUsage(content: string, symbolName: string): Promise<boolean> {
279
- try {
280
- const phpParserModule = await import("php-parser");
281
- const phpParser = phpParserModule.default || phpParserModule;
282
- const parser = new phpParser.Engine();
283
- const ast = parser.parseCode(content, "temp.php");
284
-
285
- let found = false;
286
-
287
- function visit(node: any) {
288
- if (node.kind === "identifier" && node.name === symbolName) {
289
- found = true;
290
- }
291
-
292
- if (!found && node.children) {
293
- for (const child of node.children) {
294
- visit(child);
295
- }
296
- }
297
- }
298
-
299
- visit(ast);
300
- return found;
301
- } catch {
302
- // Fallback to regex
303
- const escaped = symbolName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
304
- const regex = new RegExp(`(?<=^|[^a-zA-Z0-9_$])(${escaped})(?=[^a-zA-Z0-9_$]|$)`);
305
- return regex.test(content);
306
- }
307
- }
308
- ```
309
-
310
- ### Test a crear:
311
- - `tests/test-dependency-checker.ts`
312
-
313
- ---
314
-
315
- ## 📦 RELEASE v2.5.0
316
-
317
- ### Checklist final:
318
-
319
- - [ ] Todas las fases completadas
320
- - [ ] Todos los tests pasando
321
- - [ ] Actualizar versiones:
322
- - [ ] `package.json` → 2.5.0
323
- - [ ] `src/utils/constants.ts` → SERVER_VERSION = "2.5.0"
324
- - [ ] `README.md` → badge 2.5.0
325
- - [ ] `llms.txt` → v2.5.0
326
- - [ ] `CHANGELOG.md` → entrada 2.5.0
327
-
328
- ### CHANGELOG.md template:
329
-
330
- ```markdown
331
- ## [2.5.0] - 2024-01-XX
332
-
333
- ### 🚀 Performance & Reliability
334
-
335
- - **Syntax Validation**: Automatic syntax checking before commit
336
- - Validates TS, JS, PHP, Dart, Python
337
- - Automatic rollback on syntax errors
338
- - Prevents broken code from being written
339
-
340
- - **Cache Memory Limits**: Real byte-based cache limits
341
- - Prevents OOM on large repositories
342
- - 100MB default limit (configurable)
343
- - Evicts oldest entries when limit reached
344
-
345
- - **AbortController Support**: Cancellable operations
346
- - 60s timeout on get_semantic_repo_map
347
- - Graceful cancellation of long operations
348
- - Prevents hanging on large repos
349
-
350
- - **AST-aware Dependency Check**: Eliminates false positives
351
- - Uses AST parsing instead of regex
352
- - Ignores symbols in comments and strings
353
- - More accurate dependency detection in remove_symbol
354
-
355
- ### 📊 Metrics Improvement
356
- - Reliability: 8.5 → 9.5 (+1.0)
357
- - Safety: 8.0 → 9.5 (+1.5)
358
- - User Experience: 8.0 → 9.0 (+1.0)
359
-
360
- ### Technical
361
- - All tests passing (160+ tests)
362
- - Zero breaking changes
363
- - Backward compatible
364
- ```
365
-
366
- ### Comandos de release:
367
-
368
- ```bash
369
- # 1. Build y test
370
- npm run build
371
- npm test
372
-
373
- # 2. Git
374
- git add .
375
- git commit -m "v2.5.0: Syntax validation, cache limits, abort support, AST dependency check"
376
- git push origin main
377
-
378
- # 3. Tag
379
- git tag -a v2.5.0 -m "v2.5.0: Quick Wins - Reliability & Safety"
380
- git push origin v2.5.0
381
-
382
- # 4. Publish
383
- npm publish
384
- ```
385
-
386
- ---
387
-
388
- ## 🎯 ESTADO ACTUAL
389
-
390
- **Última actualización:** 2024-01-15
391
- **Fase actual:** FASE 1 COMPLETADA ✅
392
- **Próxima fase:** FASE 2 - Cache Memory Limits
393
- **Progreso:** 25% (1/4 fases)
394
-
395
- ---
396
-
397
- ## 📝 NOTAS DE RECUPERACIÓN
398
-
399
- Si la memoria se resetea:
400
-
401
- 1. Leer este archivo: `PLAN_v2.5.0.md`
402
- 2. Verificar fase actual en sección "ESTADO ACTUAL"
403
- 3. Ejecutar: `git log --oneline -5` para ver últimos commits
404
- 4. Ejecutar: `npm test` para verificar estado
405
- 5. Continuar con la fase marcada como PENDIENTE
406
-
407
- **Para Dios, no para los hombres** - Colosenses 3:23