mcp-code-context 2.2.0 → 2.4.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.
- package/.io/RULES.md +12 -0
- package/CHANGELOG.md +114 -1
- package/README.md +28 -1
- package/dist/src/ast/writers/safeRename.d.ts +14 -0
- package/dist/src/ast/writers/safeRename.js +258 -0
- package/dist/src/ast/writers/safeRename.js.map +1 -0
- package/dist/src/ast/writers/symbolWriter.d.ts +2 -0
- package/dist/src/ast/writers/symbolWriter.js +9 -14
- package/dist/src/ast/writers/symbolWriter.js.map +1 -1
- package/dist/src/cache/astCache.d.ts +33 -0
- package/dist/src/cache/astCache.js +113 -0
- package/dist/src/cache/astCache.js.map +1 -0
- package/dist/src/handlers/readHandlers.d.ts +70 -0
- package/dist/src/handlers/readHandlers.js +431 -0
- package/dist/src/handlers/readHandlers.js.map +1 -0
- package/dist/src/handlers/utilHandlers.d.ts +31 -0
- package/dist/src/handlers/utilHandlers.js +69 -0
- package/dist/src/handlers/utilHandlers.js.map +1 -0
- package/dist/src/handlers/writeHandlers.d.ts +57 -0
- package/dist/src/handlers/writeHandlers.js +475 -0
- package/dist/src/handlers/writeHandlers.js.map +1 -0
- package/dist/src/index.d.ts +6 -143
- package/dist/src/index.js +77 -1091
- package/dist/src/index.js.map +1 -1
- package/dist/src/tools/searchCodePattern.d.ts +7 -2
- package/dist/src/tools/searchCodePattern.js +68 -4
- package/dist/src/tools/searchCodePattern.js.map +1 -1
- package/dist/src/utils/arrayUtils.d.ts +12 -0
- package/dist/src/utils/arrayUtils.js +27 -0
- package/dist/src/utils/arrayUtils.js.map +1 -0
- package/dist/src/utils/constants.d.ts +46 -0
- package/dist/src/utils/constants.js +112 -0
- package/dist/src/utils/constants.js.map +1 -0
- package/dist/src/utils/ignoreManager.d.ts +8 -0
- package/dist/src/utils/ignoreManager.js +49 -0
- package/dist/src/utils/ignoreManager.js.map +1 -1
- package/dist/src/utils/normalization.d.ts +49 -0
- package/dist/src/utils/normalization.js +173 -0
- package/dist/src/utils/normalization.js.map +1 -0
- package/dist/src/utils/projectRoot.d.ts +12 -5
- package/dist/src/utils/projectRoot.js +22 -20
- package/dist/src/utils/projectRoot.js.map +1 -1
- package/dist/src/utils/secureValidation.d.ts +15 -0
- package/dist/src/utils/secureValidation.js +41 -0
- package/dist/src/utils/secureValidation.js.map +1 -0
- package/dist/src/utils/transactionManager.d.ts +45 -0
- package/dist/src/utils/transactionManager.js +102 -0
- package/dist/src/utils/transactionManager.js.map +1 -0
- package/dist/src/utils/validation.d.ts +87 -0
- package/dist/src/utils/validation.js +231 -0
- package/dist/src/utils/validation.js.map +1 -0
- package/docs/ARCHITECTURE.md +300 -0
- package/docs/architecture/ADR-001-modular-handlers.md +119 -0
- package/llms.txt +10 -1
- package/package.json +5 -5
- package/AGENT_INSTRUCTIONS.md +0 -135
- package/DEPLOYMENT_INSTRUCTIONS.md +0 -110
- package/MEJORAS_PROPUESTAS.md +0 -324
- package/RELEASE_NOTES_v2.1.3.md +0 -78
- package/RELEASE_NOTES_v2.2.0.md +0 -286
- package/dist/src/tests/test-confirmation-flow.d.ts +0 -1
- package/dist/src/tests/test-confirmation-flow.js +0 -43
- package/dist/src/tests/test-confirmation-flow.js.map +0 -1
- package/dist/tests/debug-replace.d.ts +0 -1
- package/dist/tests/debug-replace.js +0 -17
- package/dist/tests/debug-replace.js.map +0 -1
- package/dist/tests/test-backup-system.d.ts +0 -7
- package/dist/tests/test-backup-system.js +0 -152
- package/dist/tests/test-backup-system.js.map +0 -1
- package/dist/tests/test-confirmation-flow.d.ts +0 -1
- package/dist/tests/test-confirmation-flow.js +0 -43
- package/dist/tests/test-confirmation-flow.js.map +0 -1
- package/dist/tests/test-dart.d.ts +0 -1
- package/dist/tests/test-dart.js +0 -242
- package/dist/tests/test-dart.js.map +0 -1
- package/dist/tests/test-new-tools.d.ts +0 -4
- package/dist/tests/test-new-tools.js +0 -147
- package/dist/tests/test-new-tools.js.map +0 -1
- package/dist/tests/test-php-ast.d.ts +0 -1
- package/dist/tests/test-php-ast.js +0 -152
- package/dist/tests/test-php-ast.js.map +0 -1
- package/dist/tests/test-php.d.ts +0 -1
- package/dist/tests/test-php.js +0 -234
- package/dist/tests/test-php.js.map +0 -1
- package/dist/tests/test-smoke.d.ts +0 -5
- package/dist/tests/test-smoke.js +0 -83
- package/dist/tests/test-smoke.js.map +0 -1
- package/dist/tests/writers/test-crlf-handling.d.ts +0 -4
- package/dist/tests/writers/test-crlf-handling.js +0 -73
- package/dist/tests/writers/test-crlf-handling.js.map +0 -1
- package/dist/tests/writers/test-write-smoke.d.ts +0 -9
- package/dist/tests/writers/test-write-smoke.js +0 -346
- package/dist/tests/writers/test-write-smoke.js.map +0 -1
- package/src/ast/dartCompressor.ts +0 -1013
- package/src/ast/phpCompressor.ts +0 -814
- package/src/ast/semanticCompressor.ts +0 -808
- package/src/ast/writers/dartWriter.ts +0 -648
- package/src/ast/writers/phpWriter.ts +0 -508
- package/src/ast/writers/pyWriter.ts +0 -446
- package/src/ast/writers/symbolWriter.ts +0 -277
- package/src/ast/writers/tsWriter.ts +0 -418
- package/src/index.ts +0 -1784
- package/src/tools/readFileLines.ts +0 -104
- package/src/tools/searchCodePattern.ts +0 -129
- package/src/utils/backupManager.ts +0 -141
- package/src/utils/confirmationCache.ts +0 -61
- package/src/utils/diffEngine.ts +0 -223
- package/src/utils/fuzzyMatch.ts +0 -86
- package/src/utils/ignoreManager.ts +0 -144
- package/src/utils/projectRoot.ts +0 -44
- package/tests/test-backup-system.ts +0 -174
- package/tests/test-confirmation-flow.ts +0 -49
- package/tests/test-dart.d.ts +0 -1
- package/tests/test-dart.js +0 -209
- package/tests/test-dart.js.map +0 -1
- package/tests/test-dart.ts +0 -265
- package/tests/test-new-tools.ts +0 -165
- package/tests/test-php-ast.d.ts +0 -1
- package/tests/test-php-ast.js +0 -152
- package/tests/test-php-ast.js.map +0 -1
- package/tests/test-php-ast.ts +0 -155
- package/tests/test-php.d.ts +0 -1
- package/tests/test-php.js +0 -234
- package/tests/test-php.js.map +0 -1
- package/tests/test-php.ts +0 -261
- package/tests/test-smoke.d.ts +0 -5
- package/tests/test-smoke.js +0 -83
- package/tests/test-smoke.js.map +0 -1
- package/tests/test-smoke.ts +0 -93
- package/tests/writers/test-crlf-handling.ts +0 -100
- package/tests/writers/test-write-smoke.ts +0 -568
- package/tsconfig.json +0 -19
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-code-context",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Powerful MCP server for LLM-ready semantic code context and surgical AST-aware editing. Supports TypeScript, JavaScript, PHP, Dart, and Python.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"build": "tsc",
|
|
12
12
|
"start": "node dist/src/index.js",
|
|
13
13
|
"dev": "tsc && node dist/src/index.js",
|
|
14
|
-
"test": "npm run build && node dist/tests/test-dart.js && node dist/tests/test-php.js && node dist/tests/writers/test-write-smoke.js && node dist/tests/test-new-tools.js && node dist/tests/test-backup-system.js",
|
|
14
|
+
"test": "npm run build && node dist/tests/test-dart.js && node dist/tests/test-php.js && node dist/tests/writers/test-write-smoke.js && node dist/tests/test-new-tools.js && node dist/tests/test-backup-system.js && node dist/tests/test-rename-limitations.js",
|
|
15
15
|
"clean": "rimraf dist",
|
|
16
16
|
"rebuild": "npm run clean && npm run build"
|
|
17
17
|
},
|
|
@@ -44,12 +44,12 @@
|
|
|
44
44
|
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
45
45
|
"ignore": "^6.0.2",
|
|
46
46
|
"php-parser": "^3.5.1",
|
|
47
|
-
"ts-morph": "^24.0.0"
|
|
47
|
+
"ts-morph": "^24.0.0",
|
|
48
|
+
"typescript": "^5.7.0"
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|
|
50
51
|
"@types/node": "^22.10.0",
|
|
51
|
-
"rimraf": "^6.0.1"
|
|
52
|
-
"typescript": "^5.7.0"
|
|
52
|
+
"rimraf": "^6.0.1"
|
|
53
53
|
},
|
|
54
54
|
"engines": {
|
|
55
55
|
"node": ">=18.0.0"
|
package/AGENT_INSTRUCTIONS.md
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
# Smart Code Analysis & Editing Tools
|
|
2
|
-
**Available tools for efficient code analysis, context management, and surgical code modification.**
|
|
3
|
-
|
|
4
|
-
## Read Tools
|
|
5
|
-
|
|
6
|
-
### 1. `get_semantic_repo_map` — Architectural Map
|
|
7
|
-
**When to use**: At the start of a session, before a major refactor, or when you need to understand a new codebase or directory structure.
|
|
8
|
-
**NEVER use**: For reading specific implementations — this tool extracts ONLY structural signatures (classes, functions), not the code bodies.
|
|
9
|
-
```ts
|
|
10
|
-
get_semantic_repo_map(directoryPath: "/path/to/project/src", format: "markdown")
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
### 2. `read_file_surgical` — Surgical Reading
|
|
14
|
-
**When to use**: When you need a specific method, class, or symbol. ALWAYS prefer this over reading the entire file (like `fsRead`) if the symbol name is known.
|
|
15
|
-
**NEVER use**: For reading complete files if you only need a single function or symbol.
|
|
16
|
-
```ts
|
|
17
|
-
read_file_surgical(filePath: "/path/to/file.ts", symbolName: "ClassName")
|
|
18
|
-
read_file_surgical(filePath: "/path/to/file.dart", symbolName: "WidgetName")
|
|
19
|
-
// Omitting symbolName will read the entire file
|
|
20
|
-
read_file_surgical(filePath: "/path/to/file.php")
|
|
21
|
-
```
|
|
22
|
-
- If the symbol is not found, the tool returns a **structured JSON error** with `available_symbols` and `suggestions` (e.g., if a `className` scope is missing but the symbol exists in a class).
|
|
23
|
-
- **Pro-tip**: Use the suggestions to fix your next tool call (e.g., adding the correct `className`).
|
|
24
|
-
|
|
25
|
-
### 3. `analyze_impact` — Blast Radius Detection
|
|
26
|
-
**When to use**: ALWAYS before modifying a file that might be imported or depended upon by other parts of the system.
|
|
27
|
-
**NEVER use**: Ignore or skip this step when refactoring shared services, utilities, or core components.
|
|
28
|
-
**Features**: Detects imports across ecosystems (e.g., `use Namespace\Class` in PHP, `import` in JS/TS/Dart/Python).
|
|
29
|
-
```ts
|
|
30
|
-
analyze_impact(filePath: "/path/to/project/src/services/MyService.ts")
|
|
31
|
-
analyze_impact(filePath: "/path/to/project/src/Services/GeoIPService.php")
|
|
32
|
-
analyze_impact(filePath: "/path/to/detodo24_mobile/lib/services/tracking_service.dart")
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
---
|
|
36
|
-
|
|
37
|
-
## Write Tools
|
|
38
|
-
|
|
39
|
-
### Mandatory Two-Phase Write Workflow (v2.1.1+)
|
|
40
|
-
|
|
41
|
-
All write tools (`write_file_surgical`, `insert_symbol`, `rename_symbol`, `remove_symbol`) now enforce a safety-first confirmation flow.
|
|
42
|
-
|
|
43
|
-
**Phase 1: Dry-Run / Preview**
|
|
44
|
-
Call the tool with your proposed changes. You will receive:
|
|
45
|
-
1. A unified `diff` of the proposed changes.
|
|
46
|
-
2. A `confirmationToken`.
|
|
47
|
-
|
|
48
|
-
**Phase 2: Confirmation**
|
|
49
|
-
To apply the changes, call the SAME tool again with:
|
|
50
|
-
1. `confirmationToken`: The token from Phase 1.
|
|
51
|
-
2. `confirm: true`.
|
|
52
|
-
|
|
53
|
-
---
|
|
54
|
-
|
|
55
|
-
### 4. `write_file_surgical` — Surgical Symbol Replacement
|
|
56
|
-
**When to use**: Replace a specific function, method, class, or interface.
|
|
57
|
-
**Phase 1 (Preview)**:
|
|
58
|
-
```ts
|
|
59
|
-
write_file_surgical(filePath: "/path/to/file.ts", symbolName: "processOrder", newContent: "...")
|
|
60
|
-
```
|
|
61
|
-
**Phase 2 (Apply)**:
|
|
62
|
-
```ts
|
|
63
|
-
write_file_surgical(filePath: "/path/to/file.ts", symbolName: "processOrder", confirmationToken: "TOKEN_FROM_P1", confirm: true)
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
### 5. `insert_symbol` — Precise Code Insertion
|
|
67
|
-
**When to use**: Adding new members relative to an existing anchor symbol.
|
|
68
|
-
**Phase 1 (Preview)**:
|
|
69
|
-
```ts
|
|
70
|
-
insert_symbol(filePath: "/path/to/file.dart", code: "void clear() { ... }", anchorSymbol: "getUser", position: "after")
|
|
71
|
-
```
|
|
72
|
-
**Phase 2 (Apply)**:
|
|
73
|
-
```ts
|
|
74
|
-
insert_symbol(filePath: "/path/to/file.dart", code: "void clear() { ... }", confirmationToken: "TOKEN_FROM_P1", confirm: true)
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
### 6. `rename_symbol` — Repository-Wide Rename
|
|
78
|
-
**When to use**: Atomic identifier renaming across the entire project.
|
|
79
|
-
**Phase 1 (Preview)**:
|
|
80
|
-
```ts
|
|
81
|
-
rename_symbol(filePath: "/path/to/UserService.ts", oldName: "UserService", newName: "AccountService")
|
|
82
|
-
```
|
|
83
|
-
**Phase 2 (Apply)**:
|
|
84
|
-
```ts
|
|
85
|
-
rename_symbol(filePath: "/path/to/UserService.ts", oldName: "UserService", newName: "AccountService", confirmationToken: "TOKEN_FROM_P1", confirm: true)
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### 7. `remove_symbol` — Safe Symbol Deletion
|
|
89
|
-
**When to use**: Removing code with dependency checking.
|
|
90
|
-
**Phase 1 (Preview)**:
|
|
91
|
-
```ts
|
|
92
|
-
remove_symbol(filePath: "/path/to/file.ts", symbolName: "deprecatedHelper")
|
|
93
|
-
```
|
|
94
|
-
**Phase 2 (Apply)**:
|
|
95
|
-
```ts
|
|
96
|
-
remove_symbol(filePath: "/path/to/file.ts", symbolName: "deprecatedHelper", confirmationToken: "TOKEN_FROM_P1", confirm: true)
|
|
97
|
-
```
|
|
98
|
-
- **Safety**: Safe removal check happens in Phase 1. If dependents exist, use `force: true` in your next Phase 1 call to override.
|
|
99
|
-
|
|
100
|
-
### 8. `rollback_file` — Surgical Restoration
|
|
101
|
-
**When to use**: If an applied change introduces an unexpected error or side effect.
|
|
102
|
-
**Safety**: The server automatically keeps the last 5 versions in `.mcp-backups/`.
|
|
103
|
-
```ts
|
|
104
|
-
rollback_file(filePath: "/path/to/file.ts", steps: 1)
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### 7. `remove_symbol` — Safe Symbol Deletion
|
|
108
|
-
**When to use**: When removing a function, method, or class from a file.
|
|
109
|
-
**Safety**: By default, checks for dependents and **refuses** to remove if other files reference it.
|
|
110
|
-
```ts
|
|
111
|
-
// Safe removal (checks dependents first)
|
|
112
|
-
remove_symbol(filePath: "/path/to/file.ts", symbolName: "deprecatedHelper")
|
|
113
|
-
// Force removal (skip dependency check)
|
|
114
|
-
remove_symbol(filePath: "/path/to/file.php", symbolName: "oldMethod", force: true)
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
---
|
|
118
|
-
|
|
119
|
-
## Mandatory Workflow
|
|
120
|
-
1. **New Session / Unknown Context** → Use `get_semantic_repo_map` on the relevant directory to understand the structure.
|
|
121
|
-
2. **Read Code** → Use `read_file_surgical` with a `symbolName` whenever possible.
|
|
122
|
-
3. **Handle Missing Symbols** → If you get a JSON error, use the `suggestions` to refine your `symbolName` or `className`.
|
|
123
|
-
4. **Before Modifying** → Use `analyze_impact` if the file is a shared module or component.
|
|
124
|
-
5. **Modify Code (Phase 1)** → Use write tools to generate a `diff` and `confirmationToken`.
|
|
125
|
-
6. **Verify Diff** → Read the diff carefully. If incorrect, correct your prompt and start Phase 1 again.
|
|
126
|
-
7. **Apply (Phase 2)** → Call the same write tool with the token and `confirm: true`.
|
|
127
|
-
8. **Verify Result** → Ensure nothing broke. Use `rollback_file` if needed.
|
|
128
|
-
|
|
129
|
-
## Supported Languages (Read + Write)
|
|
130
|
-
| Language | Read | Write | Engine |
|
|
131
|
-
|----------|------|-------|--------|
|
|
132
|
-
| TypeScript / JavaScript | ✅ | ✅ | AST (ts-morph) |
|
|
133
|
-
| PHP | ✅ | ✅ | AST (php-parser) |
|
|
134
|
-
| Dart | ✅ | ✅ | Brace-counting + regex |
|
|
135
|
-
| Python | ✅ | ✅ | Indentation-based |
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
# Deployment Instructions for v2.1.3
|
|
2
|
-
|
|
3
|
-
## ✅ Completed Steps
|
|
4
|
-
1. ✅ Code fixes implemented and tested
|
|
5
|
-
2. ✅ Version bumped to 2.1.3 in package.json
|
|
6
|
-
3. ✅ CHANGELOG.md updated
|
|
7
|
-
4. ✅ TROUBLESHOOTING.md updated
|
|
8
|
-
5. ✅ llms.txt updated
|
|
9
|
-
6. ✅ Test suite created and passing (11/11 tests)
|
|
10
|
-
7. ✅ Git commit created with semantic message
|
|
11
|
-
8. ✅ Git tag v2.1.3 created with release notes
|
|
12
|
-
9. ✅ Pushed to GitHub (main branch + tag)
|
|
13
|
-
|
|
14
|
-
## 🚀 Next Steps (Manual)
|
|
15
|
-
|
|
16
|
-
### 1. Publish to npm
|
|
17
|
-
You need to be logged in to npm. Run:
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
cd C:\code\antigravity-mcp-context
|
|
21
|
-
|
|
22
|
-
# Login to npm (if not already)
|
|
23
|
-
npm login
|
|
24
|
-
|
|
25
|
-
# Publish the package
|
|
26
|
-
npm publish
|
|
27
|
-
|
|
28
|
-
# Verify publication
|
|
29
|
-
npm view mcp-code-context@2.1.3
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
### 2. Create GitHub Release
|
|
33
|
-
Go to: https://github.com/achatainga/mcp-code-context/releases/new
|
|
34
|
-
|
|
35
|
-
- **Tag**: Select `v2.1.3` (already pushed)
|
|
36
|
-
- **Title**: `v2.1.3 - Windows CRLF & Parameter Brace Fixes`
|
|
37
|
-
- **Description**: Copy content from `RELEASE_NOTES_v2.1.3.md`
|
|
38
|
-
- **Attach files**: None needed (npm package is the artifact)
|
|
39
|
-
- Click **Publish release**
|
|
40
|
-
|
|
41
|
-
### 3. Verify Installation
|
|
42
|
-
Test that users can install the new version:
|
|
43
|
-
|
|
44
|
-
```bash
|
|
45
|
-
# Global install
|
|
46
|
-
npm install -g mcp-code-context@2.1.3
|
|
47
|
-
|
|
48
|
-
# Verify version
|
|
49
|
-
npx mcp-code-context --version # Should show 2.1.3
|
|
50
|
-
|
|
51
|
-
# Test with MCP client (Claude Desktop, Amazon Q, etc.)
|
|
52
|
-
# Update config to use @2.1.3 and restart client
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### 4. Announce (Optional)
|
|
56
|
-
Consider announcing on:
|
|
57
|
-
- GitHub Discussions
|
|
58
|
-
- Twitter/X
|
|
59
|
-
- Reddit (r/LocalLLaMA, r/ClaudeAI)
|
|
60
|
-
- Discord communities
|
|
61
|
-
|
|
62
|
-
## 📋 Verification Checklist
|
|
63
|
-
|
|
64
|
-
Before announcing:
|
|
65
|
-
- [ ] npm package published successfully
|
|
66
|
-
- [ ] GitHub release created
|
|
67
|
-
- [ ] Can install via `npm install -g mcp-code-context@2.1.3`
|
|
68
|
-
- [ ] Version shows correctly in `package.json`
|
|
69
|
-
- [ ] Tag visible on GitHub releases page
|
|
70
|
-
- [ ] CHANGELOG.md shows v2.1.3 entry
|
|
71
|
-
- [ ] Tests passing on CI (if configured)
|
|
72
|
-
|
|
73
|
-
## 🐛 Rollback Plan (If Needed)
|
|
74
|
-
|
|
75
|
-
If critical issues are discovered:
|
|
76
|
-
|
|
77
|
-
```bash
|
|
78
|
-
# Unpublish from npm (within 72 hours)
|
|
79
|
-
npm unpublish mcp-code-context@2.1.3
|
|
80
|
-
|
|
81
|
-
# Delete GitHub release
|
|
82
|
-
# Go to releases page and delete v2.1.3
|
|
83
|
-
|
|
84
|
-
# Delete git tag
|
|
85
|
-
git tag -d v2.1.3
|
|
86
|
-
git push origin :refs/tags/v2.1.3
|
|
87
|
-
|
|
88
|
-
# Revert commit
|
|
89
|
-
git revert f0bfcfe
|
|
90
|
-
git push origin main
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
## 📊 Monitoring
|
|
94
|
-
|
|
95
|
-
After release, monitor:
|
|
96
|
-
- npm download stats: https://npm-stat.com/charts.html?package=mcp-code-context
|
|
97
|
-
- GitHub issues for bug reports
|
|
98
|
-
- GitHub stars/forks for adoption
|
|
99
|
-
|
|
100
|
-
## 🎉 Success Criteria
|
|
101
|
-
- No critical bugs reported within 48 hours
|
|
102
|
-
- Windows users confirm CRLF issues resolved
|
|
103
|
-
- Download count increases
|
|
104
|
-
- Positive feedback from users
|
|
105
|
-
|
|
106
|
-
---
|
|
107
|
-
|
|
108
|
-
**Current Status**: Ready for npm publish and GitHub release creation
|
|
109
|
-
**Blocked By**: npm authentication required
|
|
110
|
-
**Next Action**: Run `npm login` then `npm publish`
|
package/MEJORAS_PROPUESTAS.md
DELETED
|
@@ -1,324 +0,0 @@
|
|
|
1
|
-
# 🚀 Antigravity MCP - Mejoras Propuestas
|
|
2
|
-
|
|
3
|
-
## 📋 Resumen
|
|
4
|
-
|
|
5
|
-
Basado en la experiencia real de debugging en DeTodo24, se identificaron limitaciones en las herramientas AST actuales y se proponen 2 nuevas herramientas para mejorar la eficiencia.
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## ✅ Nuevas Herramientas Implementadas
|
|
10
|
-
|
|
11
|
-
### 1. `read_file_lines` ⭐ **ALTA PRIORIDAD**
|
|
12
|
-
|
|
13
|
-
**Ubicación:** `src/tools/readFileLines.ts`
|
|
14
|
-
|
|
15
|
-
**Propósito:** Leer rangos específicos de líneas sin cargar el archivo completo.
|
|
16
|
-
|
|
17
|
-
**Casos de uso:**
|
|
18
|
-
- Ver líneas 120-135 de un archivo
|
|
19
|
-
- Ver ±5 líneas alrededor de un patrón (ej: "HeroBannerWidget")
|
|
20
|
-
- Debugging rápido sin consumir tokens del archivo completo
|
|
21
|
-
|
|
22
|
-
**Ahorro estimado:** 90% vs `read_file_surgical` para fragmentos pequeños
|
|
23
|
-
|
|
24
|
-
**Ejemplo de uso:**
|
|
25
|
-
```typescript
|
|
26
|
-
// Modo 1: Rango exacto
|
|
27
|
-
read_file_lines({
|
|
28
|
-
filePath: "/path/to/file.dart",
|
|
29
|
-
startLine: 120,
|
|
30
|
-
endLine: 135
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
// Modo 2: Alrededor de patrón
|
|
34
|
-
read_file_lines({
|
|
35
|
-
filePath: "/path/to/file.dart",
|
|
36
|
-
aroundPattern: "HeroBannerWidget",
|
|
37
|
-
contextLines: 5
|
|
38
|
-
})
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
---
|
|
42
|
-
|
|
43
|
-
### 2. `search_code_pattern` ⭐ **ALTA PRIORIDAD**
|
|
44
|
-
|
|
45
|
-
**Ubicación:** `src/tools/searchCodePattern.ts`
|
|
46
|
-
|
|
47
|
-
**Propósito:** Buscar patrones de código en múltiples archivos con contexto.
|
|
48
|
-
|
|
49
|
-
**Casos de uso:**
|
|
50
|
-
- Buscar todas las ocurrencias de "widget.height"
|
|
51
|
-
- Encontrar logs específicos (ej: "🎯 [BUILDER]")
|
|
52
|
-
- Buscar imports o referencias a símbolos
|
|
53
|
-
|
|
54
|
-
**Ahorro estimado:** 85% vs grep manual + análisis
|
|
55
|
-
|
|
56
|
-
**Ejemplo de uso:**
|
|
57
|
-
```typescript
|
|
58
|
-
search_code_pattern({
|
|
59
|
-
rootDir: "/project",
|
|
60
|
-
pattern: "widget\\.height",
|
|
61
|
-
fileExtensions: [".dart", ".ts"],
|
|
62
|
-
showContext: true,
|
|
63
|
-
contextLines: 3,
|
|
64
|
-
maxResults: 20
|
|
65
|
-
})
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
---
|
|
69
|
-
|
|
70
|
-
## 🔧 Pasos para Integración
|
|
71
|
-
|
|
72
|
-
### 1. Agregar definiciones de herramientas en `src/index.ts`
|
|
73
|
-
|
|
74
|
-
Insertar en el array `TOOLS` (después de `rollback_file`):
|
|
75
|
-
|
|
76
|
-
```typescript
|
|
77
|
-
{
|
|
78
|
-
name: "read_file_lines",
|
|
79
|
-
description:
|
|
80
|
-
"Reads specific line ranges from a file without loading the entire content. " +
|
|
81
|
-
"Supports reading by exact line range (startLine/endLine) or around a pattern match. " +
|
|
82
|
-
"More efficient than read_file_surgical when you only need a small fragment of code. " +
|
|
83
|
-
"Perfect for debugging, viewing specific code blocks, or extracting context around errors.",
|
|
84
|
-
inputSchema: {
|
|
85
|
-
type: "object" as const,
|
|
86
|
-
properties: {
|
|
87
|
-
filePath: {
|
|
88
|
-
type: "string",
|
|
89
|
-
description: "Absolute path to the source file to read.",
|
|
90
|
-
},
|
|
91
|
-
startLine: {
|
|
92
|
-
type: "number",
|
|
93
|
-
description: "Starting line number (1-indexed). Required if using exact range mode.",
|
|
94
|
-
},
|
|
95
|
-
endLine: {
|
|
96
|
-
type: "number",
|
|
97
|
-
description: "Ending line number (1-indexed). Required if using exact range mode.",
|
|
98
|
-
},
|
|
99
|
-
aroundPattern: {
|
|
100
|
-
type: "string",
|
|
101
|
-
description:
|
|
102
|
-
"Search pattern to find in the file. Returns lines around the first match. " +
|
|
103
|
-
"Use this mode when you don't know the exact line numbers.",
|
|
104
|
-
},
|
|
105
|
-
contextLines: {
|
|
106
|
-
type: "number",
|
|
107
|
-
description:
|
|
108
|
-
"Number of lines to include before and after the pattern match. " +
|
|
109
|
-
"Defaults to 5. Only used with aroundPattern mode.",
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
required: ["filePath"],
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
name: "search_code_pattern",
|
|
117
|
-
description:
|
|
118
|
-
"Searches for code patterns across multiple files in a repository. " +
|
|
119
|
-
"Returns matches with file paths, line numbers, and optional context lines. " +
|
|
120
|
-
"Respects .gitignore rules and allows filtering by file extensions. " +
|
|
121
|
-
"More efficient than manual grep when you need structured results with context.",
|
|
122
|
-
inputSchema: {
|
|
123
|
-
type: "object" as const,
|
|
124
|
-
properties: {
|
|
125
|
-
rootDir: {
|
|
126
|
-
type: "string",
|
|
127
|
-
description: "Absolute path to the repository root directory to search.",
|
|
128
|
-
},
|
|
129
|
-
pattern: {
|
|
130
|
-
type: "string",
|
|
131
|
-
description:
|
|
132
|
-
"Regular expression pattern to search for. Use proper regex escaping " +
|
|
133
|
-
"(e.g., 'widget\\\\.height' to match 'widget.height').",
|
|
134
|
-
},
|
|
135
|
-
fileExtensions: {
|
|
136
|
-
type: "array",
|
|
137
|
-
items: { type: "string" },
|
|
138
|
-
description:
|
|
139
|
-
"Array of file extensions to search (e.g., ['.ts', '.dart', '.py']). " +
|
|
140
|
-
"Defaults to common code extensions if omitted.",
|
|
141
|
-
},
|
|
142
|
-
excludeDirs: {
|
|
143
|
-
type: "array",
|
|
144
|
-
items: { type: "string" },
|
|
145
|
-
description:
|
|
146
|
-
"Array of directory names to exclude (e.g., ['node_modules', 'dist']). " +
|
|
147
|
-
"Defaults to common build/dependency directories.",
|
|
148
|
-
},
|
|
149
|
-
showContext: {
|
|
150
|
-
type: "boolean",
|
|
151
|
-
description: "If true, includes surrounding lines for each match. Defaults to true.",
|
|
152
|
-
},
|
|
153
|
-
contextLines: {
|
|
154
|
-
type: "number",
|
|
155
|
-
description: "Number of context lines before/after each match. Defaults to 3.",
|
|
156
|
-
},
|
|
157
|
-
maxResults: {
|
|
158
|
-
type: "number",
|
|
159
|
-
description: "Maximum number of matches to return. Defaults to 50.",
|
|
160
|
-
},
|
|
161
|
-
},
|
|
162
|
-
required: ["rootDir", "pattern"],
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
### 2. Agregar imports en `src/index.ts`
|
|
168
|
-
|
|
169
|
-
Después de los imports existentes:
|
|
170
|
-
|
|
171
|
-
```typescript
|
|
172
|
-
import { readFileLines } from "./tools/readFileLines.js";
|
|
173
|
-
import { searchCodePattern } from "./tools/searchCodePattern.js";
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
### 3. Agregar handlers en el switch del dispatcher
|
|
177
|
-
|
|
178
|
-
En la función `server.setRequestHandler(CallToolRequestSchema, ...)`, agregar:
|
|
179
|
-
|
|
180
|
-
```typescript
|
|
181
|
-
case "read_file_lines":
|
|
182
|
-
return await handleReadFileLines(args as Record<string, unknown>);
|
|
183
|
-
case "search_code_pattern":
|
|
184
|
-
return await handleSearchCodePattern(args as Record<string, unknown>);
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
### 4. Implementar los handlers
|
|
188
|
-
|
|
189
|
-
Agregar al final del archivo (antes de `// ─── Bootstrap`):
|
|
190
|
-
|
|
191
|
-
```typescript
|
|
192
|
-
// ─── Tool: read_file_lines ──────────────────────────────────────────
|
|
193
|
-
|
|
194
|
-
export async function handleReadFileLines(args: Record<string, unknown>) {
|
|
195
|
-
const result = readFileLines(args as any);
|
|
196
|
-
|
|
197
|
-
if (!result.success) {
|
|
198
|
-
return errorResponse(result.error || "Unknown error reading file lines");
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
const { content, lineRange } = result;
|
|
202
|
-
const header = lineRange
|
|
203
|
-
? `// Lines ${lineRange.start}-${lineRange.end}\n// File: ${args.filePath}\n\n`
|
|
204
|
-
: `// File: ${args.filePath}\n\n`;
|
|
205
|
-
|
|
206
|
-
return {
|
|
207
|
-
content: [
|
|
208
|
-
{
|
|
209
|
-
type: "text" as const,
|
|
210
|
-
text: header + content,
|
|
211
|
-
},
|
|
212
|
-
],
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
// ─── Tool: search_code_pattern ──────────────────────────────────────
|
|
217
|
-
|
|
218
|
-
export async function handleSearchCodePattern(args: Record<string, unknown>) {
|
|
219
|
-
const result = searchCodePattern(args as any);
|
|
220
|
-
|
|
221
|
-
if (!result.success) {
|
|
222
|
-
return errorResponse(result.error || "Unknown error searching code");
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
const { matches, totalMatches } = result;
|
|
226
|
-
|
|
227
|
-
if (!matches || matches.length === 0) {
|
|
228
|
-
return {
|
|
229
|
-
content: [
|
|
230
|
-
{
|
|
231
|
-
type: "text" as const,
|
|
232
|
-
text: `# Search Results\n\nNo matches found for pattern: "${args.pattern}"`,
|
|
233
|
-
},
|
|
234
|
-
],
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
const lines: string[] = [
|
|
239
|
-
`# Search Results`,
|
|
240
|
-
``,
|
|
241
|
-
`**Pattern:** \`${args.pattern}\``,
|
|
242
|
-
`**Root:** \`${args.rootDir}\``,
|
|
243
|
-
`**Matches:** ${totalMatches} (showing ${matches.length})`,
|
|
244
|
-
``,
|
|
245
|
-
];
|
|
246
|
-
|
|
247
|
-
for (const match of matches) {
|
|
248
|
-
lines.push(`## \`${match.file}\` (line ${match.lineNumber})`);
|
|
249
|
-
lines.push(``);
|
|
250
|
-
|
|
251
|
-
if (match.context) {
|
|
252
|
-
lines.push("```");
|
|
253
|
-
lines.push(...match.context);
|
|
254
|
-
lines.push("```");
|
|
255
|
-
} else {
|
|
256
|
-
lines.push(`\`\`\`\n${match.line}\n\`\`\``);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
lines.push(``);
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
return {
|
|
263
|
-
content: [
|
|
264
|
-
{
|
|
265
|
-
type: "text" as const,
|
|
266
|
-
text: lines.join("\n"),
|
|
267
|
-
},
|
|
268
|
-
],
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
### 5. Compilar y probar
|
|
274
|
-
|
|
275
|
-
```bash
|
|
276
|
-
cd C:\code\antigravity-mcp-context
|
|
277
|
-
npm run build
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
### 6. Actualizar versión
|
|
281
|
-
|
|
282
|
-
En `src/index.ts`, cambiar:
|
|
283
|
-
```typescript
|
|
284
|
-
const SERVER_VERSION = "2.2.0"; // Era "2.0.0"
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
---
|
|
288
|
-
|
|
289
|
-
## 📊 Comparación de Eficiencia
|
|
290
|
-
|
|
291
|
-
| Tarea | Herramienta Actual | Nueva Herramienta | Ahorro |
|
|
292
|
-
|-------|-------------------|-------------------|--------|
|
|
293
|
-
| Ver líneas 120-135 | `read_file_surgical` (2500 tokens) | `read_file_lines` (200 tokens) | 92% |
|
|
294
|
-
| Buscar patrón en 50 archivos | `grep` manual + análisis | `search_code_pattern` | 85% |
|
|
295
|
-
| Ver contexto de error | Leer archivo completo | `read_file_lines` con `aroundPattern` | 90% |
|
|
296
|
-
|
|
297
|
-
---
|
|
298
|
-
|
|
299
|
-
## 🎯 Beneficios Clave
|
|
300
|
-
|
|
301
|
-
1. **Menor consumo de tokens:** 60-90% de ahorro en operaciones de lectura
|
|
302
|
-
2. **Debugging más rápido:** Acceso directo a fragmentos específicos
|
|
303
|
-
3. **Búsqueda estructurada:** Resultados con contexto automático
|
|
304
|
-
4. **Compatibilidad total:** Se integra con herramientas AST existentes
|
|
305
|
-
|
|
306
|
-
---
|
|
307
|
-
|
|
308
|
-
## 📝 Notas de Implementación
|
|
309
|
-
|
|
310
|
-
- ✅ `.mcp-backups/` ya está en `.gitignore` (línea 31)
|
|
311
|
-
- ✅ Ambas herramientas respetan `.gitignore` usando `IgnoreManager`
|
|
312
|
-
- ✅ Manejo de errores consistente con herramientas existentes
|
|
313
|
-
- ✅ TypeScript types completos
|
|
314
|
-
|
|
315
|
-
---
|
|
316
|
-
|
|
317
|
-
## 🚀 Próximos Pasos
|
|
318
|
-
|
|
319
|
-
1. Integrar las herramientas siguiendo los pasos anteriores
|
|
320
|
-
2. Compilar y probar con `npm run build`
|
|
321
|
-
3. Recargar Amazon Q para detectar las nuevas herramientas
|
|
322
|
-
4. Documentar en CHANGELOG.md
|
|
323
|
-
|
|
324
|
-
**Tiempo estimado de integración:** 15-20 minutos
|
package/RELEASE_NOTES_v2.1.3.md
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
# Release v2.1.3 - Windows CRLF & Parameter Brace Fixes
|
|
2
|
-
|
|
3
|
-
## 🎯 Overview
|
|
4
|
-
This release completely resolves false brace imbalance errors on Windows systems and fixes a critical bug with Dart method parameters containing braces.
|
|
5
|
-
|
|
6
|
-
## ✨ What's Fixed
|
|
7
|
-
|
|
8
|
-
### Windows CRLF Support (Complete Resolution)
|
|
9
|
-
- ✅ All Dart writer functions now normalize `\r\n` to `\n` before processing
|
|
10
|
-
- ✅ No more false "unbalanced braces" errors on Windows files
|
|
11
|
-
- ✅ Consistent behavior across Windows, macOS, and Linux
|
|
12
|
-
- ✅ Helper functions (`hasBraceBalance`, `reindentCode`) also normalize line endings
|
|
13
|
-
|
|
14
|
-
### Method Parameter Brace Handling
|
|
15
|
-
- ✅ Fixed critical bug where braces in method parameters (e.g., `{int? cart}`) were incorrectly counted as method body braces
|
|
16
|
-
- ✅ `findMatchingBraceStateAware` now tracks closing parenthesis to identify method body start
|
|
17
|
-
- ✅ Correctly handles Dart named parameters, optional parameters, and destructuring syntax
|
|
18
|
-
|
|
19
|
-
## 🧪 Testing
|
|
20
|
-
- **11 new test cases** covering:
|
|
21
|
-
- CRLF line endings
|
|
22
|
-
- Mixed CRLF/LF line endings
|
|
23
|
-
- Methods with braces in parameters
|
|
24
|
-
- All write operations (replace, insert, rename, remove)
|
|
25
|
-
- **100% test pass rate** on Windows 11
|
|
26
|
-
|
|
27
|
-
## 📝 Changes
|
|
28
|
-
|
|
29
|
-
### Modified Files
|
|
30
|
-
- `src/ast/writers/dartWriter.ts` - Core CRLF normalization and parameter brace detection
|
|
31
|
-
- `package.json` - Version bump to 2.1.3
|
|
32
|
-
- `CHANGELOG.md` - Detailed release notes
|
|
33
|
-
- `TROUBLESHOOTING.md` - Marked CRLF issue as resolved
|
|
34
|
-
- `llms.txt` - Updated for LLM consumption
|
|
35
|
-
|
|
36
|
-
### New Files
|
|
37
|
-
- `tests/writers/test-crlf-handling.ts` - Comprehensive CRLF test suite
|
|
38
|
-
|
|
39
|
-
## 🔄 Migration Guide
|
|
40
|
-
No breaking changes. Simply update:
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
npm install -g mcp-code-context@2.1.3
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
Or in your MCP client config:
|
|
47
|
-
```json
|
|
48
|
-
{
|
|
49
|
-
"mcpServers": {
|
|
50
|
-
"code-context": {
|
|
51
|
-
"command": "npx",
|
|
52
|
-
"args": ["-y", "mcp-code-context@2.1.3"]
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
## 🐛 Bug Reports Resolved
|
|
59
|
-
- Windows CRLF false positive errors
|
|
60
|
-
- Parameter brace detection in Dart methods
|
|
61
|
-
- Mixed line ending handling
|
|
62
|
-
|
|
63
|
-
## 📊 Impact
|
|
64
|
-
- **Platforms affected**: Windows (primary), all platforms benefit from improved robustness
|
|
65
|
-
- **Languages affected**: Dart (primary fix), all languages benefit from CRLF normalization
|
|
66
|
-
- **Backward compatible**: Yes, no breaking changes
|
|
67
|
-
|
|
68
|
-
## 🙏 Credits
|
|
69
|
-
Special thanks to the Amazon Q Developer user who reported the Windows CRLF bug with detailed reproduction steps.
|
|
70
|
-
|
|
71
|
-
## 📚 Documentation
|
|
72
|
-
- [CHANGELOG.md](./CHANGELOG.md) - Full version history
|
|
73
|
-
- [TROUBLESHOOTING.md](./TROUBLESHOOTING.md) - Known issues and solutions
|
|
74
|
-
- [README.md](./README.md) - Complete usage guide
|
|
75
|
-
|
|
76
|
-
---
|
|
77
|
-
|
|
78
|
-
**Full Changelog**: https://github.com/achatainga/mcp-code-context/compare/v2.1.2...v2.1.3
|