mcp-code-context 2.6.0 → 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 (128) hide show
  1. package/CHANGELOG.md +92 -260
  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 -236
  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/TROUBLESHOOTING.md +0 -38
  40. package/dist/src/ast/dartCompressor.d.ts +0 -27
  41. package/dist/src/ast/dartCompressor.js +0 -859
  42. package/dist/src/ast/dartCompressor.js.map +0 -1
  43. package/dist/src/ast/phpCompressor.d.ts +0 -24
  44. package/dist/src/ast/phpCompressor.js +0 -634
  45. package/dist/src/ast/phpCompressor.js.map +0 -1
  46. package/dist/src/ast/semanticCompressor.d.ts +0 -22
  47. package/dist/src/ast/semanticCompressor.js +0 -677
  48. package/dist/src/ast/semanticCompressor.js.map +0 -1
  49. package/dist/src/ast/writers/dartWriter.d.ts +0 -37
  50. package/dist/src/ast/writers/dartWriter.js +0 -544
  51. package/dist/src/ast/writers/dartWriter.js.map +0 -1
  52. package/dist/src/ast/writers/phpWriter.d.ts +0 -37
  53. package/dist/src/ast/writers/phpWriter.js +0 -411
  54. package/dist/src/ast/writers/phpWriter.js.map +0 -1
  55. package/dist/src/ast/writers/pyWriter.d.ts +0 -37
  56. package/dist/src/ast/writers/pyWriter.js +0 -355
  57. package/dist/src/ast/writers/pyWriter.js.map +0 -1
  58. package/dist/src/ast/writers/safeRename.d.ts +0 -14
  59. package/dist/src/ast/writers/safeRename.js +0 -258
  60. package/dist/src/ast/writers/safeRename.js.map +0 -1
  61. package/dist/src/ast/writers/symbolWriter.d.ts +0 -64
  62. package/dist/src/ast/writers/symbolWriter.js +0 -174
  63. package/dist/src/ast/writers/symbolWriter.js.map +0 -1
  64. package/dist/src/ast/writers/tsWriter.d.ts +0 -38
  65. package/dist/src/ast/writers/tsWriter.js +0 -344
  66. package/dist/src/ast/writers/tsWriter.js.map +0 -1
  67. package/dist/src/cache/astCache.d.ts +0 -39
  68. package/dist/src/cache/astCache.js +0 -169
  69. package/dist/src/cache/astCache.js.map +0 -1
  70. package/dist/src/handlers/readHandlers.d.ts +0 -70
  71. package/dist/src/handlers/readHandlers.js +0 -455
  72. package/dist/src/handlers/readHandlers.js.map +0 -1
  73. package/dist/src/handlers/utilHandlers.d.ts +0 -31
  74. package/dist/src/handlers/utilHandlers.js +0 -69
  75. package/dist/src/handlers/utilHandlers.js.map +0 -1
  76. package/dist/src/handlers/writeHandlers.d.ts +0 -57
  77. package/dist/src/handlers/writeHandlers.js +0 -499
  78. package/dist/src/handlers/writeHandlers.js.map +0 -1
  79. package/dist/src/tools/readFileLines.d.ts +0 -26
  80. package/dist/src/tools/readFileLines.js +0 -77
  81. package/dist/src/tools/readFileLines.js.map +0 -1
  82. package/dist/src/tools/searchCodePattern.d.ts +0 -37
  83. package/dist/src/tools/searchCodePattern.js +0 -144
  84. package/dist/src/tools/searchCodePattern.js.map +0 -1
  85. package/dist/src/utils/arrayUtils.d.ts +0 -12
  86. package/dist/src/utils/arrayUtils.js +0 -27
  87. package/dist/src/utils/arrayUtils.js.map +0 -1
  88. package/dist/src/utils/backupManager.d.ts +0 -31
  89. package/dist/src/utils/backupManager.js +0 -124
  90. package/dist/src/utils/backupManager.js.map +0 -1
  91. package/dist/src/utils/confirmationCache.d.ts +0 -16
  92. package/dist/src/utils/confirmationCache.js +0 -40
  93. package/dist/src/utils/confirmationCache.js.map +0 -1
  94. package/dist/src/utils/constants.d.ts +0 -46
  95. package/dist/src/utils/constants.js +0 -112
  96. package/dist/src/utils/constants.js.map +0 -1
  97. package/dist/src/utils/dependencyChecker.d.ts +0 -1
  98. package/dist/src/utils/dependencyChecker.js +0 -55
  99. package/dist/src/utils/dependencyChecker.js.map +0 -1
  100. package/dist/src/utils/diffEngine.d.ts +0 -21
  101. package/dist/src/utils/diffEngine.js +0 -163
  102. package/dist/src/utils/diffEngine.js.map +0 -1
  103. package/dist/src/utils/fuzzyMatch.d.ts +0 -8
  104. package/dist/src/utils/fuzzyMatch.js +0 -70
  105. package/dist/src/utils/fuzzyMatch.js.map +0 -1
  106. package/dist/src/utils/ignoreManager.d.ts +0 -29
  107. package/dist/src/utils/ignoreManager.js +0 -144
  108. package/dist/src/utils/ignoreManager.js.map +0 -1
  109. package/dist/src/utils/normalization.d.ts +0 -49
  110. package/dist/src/utils/normalization.js +0 -173
  111. package/dist/src/utils/normalization.js.map +0 -1
  112. package/dist/src/utils/projectRoot.d.ts +0 -17
  113. package/dist/src/utils/projectRoot.js +0 -42
  114. package/dist/src/utils/projectRoot.js.map +0 -1
  115. package/dist/src/utils/secureValidation.d.ts +0 -15
  116. package/dist/src/utils/secureValidation.js +0 -41
  117. package/dist/src/utils/secureValidation.js.map +0 -1
  118. package/dist/src/utils/syntaxValidator.d.ts +0 -15
  119. package/dist/src/utils/syntaxValidator.js +0 -218
  120. package/dist/src/utils/syntaxValidator.js.map +0 -1
  121. package/dist/src/utils/transactionManager.d.ts +0 -46
  122. package/dist/src/utils/transactionManager.js +0 -123
  123. package/dist/src/utils/transactionManager.js.map +0 -1
  124. package/dist/src/utils/validation.d.ts +0 -87
  125. package/dist/src/utils/validation.js +0 -231
  126. package/dist/src/utils/validation.js.map +0 -1
  127. package/docs/ARCHITECTURE.md +0 -300
  128. 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! 🚀
@@ -1,38 +0,0 @@
1
- # Troubleshooting Guide: Surgical Editing Edge Cases
2
-
3
- This document covers known edge cases and behaviors for the Antigravity MCP surgical tools. These insights are derived from real-world usage scenarios.
4
-
5
- ## 1. `write_file_surgical` - False Brace Imbalance
6
- **Problem:** The server rejects a code change, claiming the resulting file has unbalanced braces, even if the code provided is syntactically valid.
7
- **Cause:**
8
- - Discrepancies between character counting and line endings (CRLF vs LF).
9
- - Braces found inside string literals or comments being counted as structural braces.
10
- - Braces in method parameters (e.g., `{int? cart}`) being counted as method body braces.
11
- **Solution (Internal):**
12
- - v2.1.2: State-aware brace counting that ignores literals and comments.
13
- - v2.1.3: CRLF normalization and parameter brace detection. **RESOLVED**.
14
- **Workaround:** No longer needed as of v2.1.3.
15
-
16
- ## 2. `rename_symbol` - Dependents Not Updating
17
- **Problem:** The symbol is renamed in the definition file, but imports and references in other files are unchanged.
18
- **Cause:** The tool was previously looking for the *definition* of the symbol in every file.
19
- **Solution (Internal):** The tool now separates definition renaming from reference updating. It will update any whole-word match of the symbol in files that are detected as dependents.
20
- **Workaround:** Run `analyze_impact` first to verify the server detects the dependencies. If missed, perform a manual surgical replace on the import line.
21
-
22
- ## 3. `insert_symbol` - Ambiguous Positioning
23
- **Problem:** Using `position: "after"` on a method sometimes inserts the new code *inside* the closing brace of that method.
24
- **Cause:** Ambiguity in block-end detection when the closing brace is on a line with other content or when braces are presence in strings inside the body.
25
- **Solution (Internal):** Improved block detection in v2.1.2.
26
- **Best Practice:** For inserting new members inside a class, prefer using `position: "inside_end"` with the `className` as the anchor, rather than `after` on the last method.
27
-
28
- ## 4. `remove_symbol` - False Positive Dependency Check
29
- **Problem:** The tool refuses to remove a symbol because it "might be used" in another file, but the reference is actually a comment or a different symbol with the same name.
30
- **Cause:** To stay fast, the dependency check uses a whole-word regex search rather than a full cross-file AST index.
31
- **Solution:**
32
- 1. Run `analyze_impact` to verify the actual blast radius.
33
- 2. If you confirm the "matches" are false positives, use the `force: true` parameter to bypass the check.
34
-
35
- ---
36
-
37
- > [!TIP]
38
- > **Always use the Two-Phase Workflow.** Review the `diff` provided in the first response carefully before providing the `confirmationToken`. This is your strongest guard against edge-case misbehavior.
@@ -1,27 +0,0 @@
1
- /**
2
- * dartCompressor — Regex + brace-counting Dart semantic compressor.
3
- *
4
- * Dart has no npm AST parser, so we use a high-fidelity regex engine combined
5
- * with precise brace-counting to extract structural signatures from Dart source.
6
- * This approach handles all real-world Flutter/Dart patterns including generics,
7
- * factory constructors, mixins, extensions, and enum members.
8
- *
9
- * Design principles:
10
- * 1. Brace-counting for block boundaries — never fails on nested blocks
11
- * 2. Regex for signature detection — generics-aware, handles multi-line
12
- * 3. Preserve doc comments (///) for semantic context
13
- * 4. Preserve annotations (@override, @visibleForTesting, etc.)
14
- * 5. Preserve field declarations (they ARE the structural contract)
15
- */
16
- /**
17
- * Compress a Dart file into its semantic skeleton.
18
- * Returns only structural signatures — no function/method bodies.
19
- */
20
- export declare function compressDart(content: string): string;
21
- /**
22
- * Extract the full source code of a named symbol from a Dart file.
23
- * Supports classes, mixins, extensions, enums, functions, and methods.
24
- * When className is provided, scopes method search to within that class only.
25
- * Returns null if the symbol is not found.
26
- */
27
- export declare function extractDartSymbol(content: string, symbolName: string, className?: string): string | null;