@imenam/refactoring-mcp 3.3.0 → 3.4.2
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/README.md +93 -87
- package/dist/index.js +2 -2
- package/package.json +3 -6
package/README.md
CHANGED
|
@@ -1,87 +1,93 @@
|
|
|
1
|
-
# @imenam/refactoring-mcp
|
|
2
|
-
|
|
3
|
-
An MCP (Model Context Protocol) server that lets AI agents copy or move blocks of code between files, with optional directory confinement for safety.
|
|
4
|
-
|
|
5
|
-
## Tools
|
|
6
|
-
|
|
7
|
-
### `move_or_copy_code`
|
|
8
|
-
|
|
9
|
-
Copies or moves a range of lines from a source file to a destination file.
|
|
10
|
-
|
|
11
|
-
| Parameter | Type | Required | Description |
|
|
12
|
-
|---|---|---|---|
|
|
13
|
-
| `sourceFile` | `string` | ✅ | Absolute path to the source file |
|
|
14
|
-
| `startLine` | `number` | ✅ | Start line of the block (1-indexed) |
|
|
15
|
-
| `endLine` | `number` | ✅ | End line of the block, inclusive (1-indexed) |
|
|
16
|
-
| `operationType` | `"copy" \| "cut"` | ✅ | `copy` keeps the source intact, `cut` removes the lines |
|
|
17
|
-
| `destinationFile` | `string` | ✅ | Absolute path to the destination file (created automatically if it doesn't exist) |
|
|
18
|
-
| `destinationLine` | `number` | ❌ | Line at which to insert in the destination (appended at end by default) |
|
|
19
|
-
|
|
20
|
-
### `get_file_outline`
|
|
21
|
-
|
|
22
|
-
Returns the list of top-level symbols in a file (functions, classes, interfaces, types, constants, methods) with their start and end line numbers. Useful for identifying the exact coordinates of a code block before moving it.
|
|
23
|
-
|
|
24
|
-
| Parameter | Type | Required | Description |
|
|
25
|
-
|---|---|---|---|
|
|
26
|
-
| `filePath` | `string` | ✅ | Absolute path to the file to analyse |
|
|
27
|
-
|
|
28
|
-
### `compare_code_sections`
|
|
29
|
-
|
|
30
|
-
Compares two code sections from two files (delimited by line numbers) and returns a unified diff in git format. Useful for verifying that a block of code was correctly copied from one file to another. Leading and trailing blank lines in each section are ignored to avoid false positives from positioning differences.
|
|
31
|
-
|
|
32
|
-
| Parameter | Type | Required | Description |
|
|
33
|
-
|---|---|---|---|
|
|
34
|
-
| `fileA` | `string` | ✅ | Absolute path to the first file |
|
|
35
|
-
| `startLineA` | `number` | ✅ | Start line of the section in file A (1-indexed) |
|
|
36
|
-
| `endLineA` | `number` | ✅ | End line of the section in file A, inclusive (1-indexed) |
|
|
37
|
-
| `fileB` | `string` | ✅ | Absolute path to the second file |
|
|
38
|
-
| `startLineB` | `number` | ✅ | Start line of the section in file B (1-indexed) |
|
|
39
|
-
| `endLineB` | `number` | ✅ | End line of the section in file B, inclusive (1-indexed) |
|
|
40
|
-
|
|
41
|
-
Returns `"Les sections sont identiques."` when no differences are found, or a unified diff with real file line numbers otherwise.
|
|
42
|
-
|
|
43
|
-
## Configuration
|
|
44
|
-
|
|
45
|
-
All file paths must be **absolute**. Relative paths are rejected.
|
|
46
|
-
|
|
47
|
-
To restrict operations to a specific directory, set the `REFACTORING_ALLOWED_DIR` environment variable. Any attempt to access a file outside that directory will be blocked.
|
|
48
|
-
|
|
49
|
-
```env
|
|
50
|
-
# .env
|
|
51
|
-
REFACTORING_ALLOWED_DIR=C:/Users/you/my-project
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## Installation
|
|
55
|
-
|
|
56
|
-
```bash
|
|
57
|
-
npm install -g @imenam/refactoring-mcp
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
Or use it directly with `npx`:
|
|
61
|
-
|
|
62
|
-
```json
|
|
63
|
-
{
|
|
64
|
-
"refactoring-mcp": {
|
|
65
|
-
"command": "npx",
|
|
66
|
-
"args": ["-y", "@imenam/refactoring-mcp"]
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
Or point to a local build:
|
|
72
|
-
|
|
73
|
-
```json
|
|
74
|
-
{
|
|
75
|
-
"refactoring-mcp": {
|
|
76
|
-
"command": "node",
|
|
77
|
-
"args": ["/absolute/path/to/refactoring-mcp/dist/index.js"],
|
|
78
|
-
"env": {
|
|
79
|
-
"REFACTORING_ALLOWED_DIR": "/absolute/path/to/your/project"
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
##
|
|
86
|
-
|
|
87
|
-
|
|
1
|
+
# @imenam/refactoring-mcp
|
|
2
|
+
|
|
3
|
+
An MCP (Model Context Protocol) server that lets AI agents copy or move blocks of code between files, with optional directory confinement for safety.
|
|
4
|
+
|
|
5
|
+
## Tools
|
|
6
|
+
|
|
7
|
+
### `move_or_copy_code`
|
|
8
|
+
|
|
9
|
+
Copies or moves a range of lines from a source file to a destination file.
|
|
10
|
+
|
|
11
|
+
| Parameter | Type | Required | Description |
|
|
12
|
+
|---|---|---|---|
|
|
13
|
+
| `sourceFile` | `string` | ✅ | Absolute path to the source file |
|
|
14
|
+
| `startLine` | `number` | ✅ | Start line of the block (1-indexed) |
|
|
15
|
+
| `endLine` | `number` | ✅ | End line of the block, inclusive (1-indexed) |
|
|
16
|
+
| `operationType` | `"copy" \| "cut"` | ✅ | `copy` keeps the source intact, `cut` removes the lines |
|
|
17
|
+
| `destinationFile` | `string` | ✅ | Absolute path to the destination file (created automatically if it doesn't exist) |
|
|
18
|
+
| `destinationLine` | `number` | ❌ | Line at which to insert in the destination (appended at end by default) |
|
|
19
|
+
|
|
20
|
+
### `get_file_outline`
|
|
21
|
+
|
|
22
|
+
Returns the list of top-level symbols in a file (functions, classes, interfaces, types, constants, methods) with their start and end line numbers. Useful for identifying the exact coordinates of a code block before moving it.
|
|
23
|
+
|
|
24
|
+
| Parameter | Type | Required | Description |
|
|
25
|
+
|---|---|---|---|
|
|
26
|
+
| `filePath` | `string` | ✅ | Absolute path to the file to analyse |
|
|
27
|
+
|
|
28
|
+
### `compare_code_sections`
|
|
29
|
+
|
|
30
|
+
Compares two code sections from two files (delimited by line numbers) and returns a unified diff in git format. Useful for verifying that a block of code was correctly copied from one file to another. Leading and trailing blank lines in each section are ignored to avoid false positives from positioning differences.
|
|
31
|
+
|
|
32
|
+
| Parameter | Type | Required | Description |
|
|
33
|
+
|---|---|---|---|
|
|
34
|
+
| `fileA` | `string` | ✅ | Absolute path to the first file |
|
|
35
|
+
| `startLineA` | `number` | ✅ | Start line of the section in file A (1-indexed) |
|
|
36
|
+
| `endLineA` | `number` | ✅ | End line of the section in file A, inclusive (1-indexed) |
|
|
37
|
+
| `fileB` | `string` | ✅ | Absolute path to the second file |
|
|
38
|
+
| `startLineB` | `number` | ✅ | Start line of the section in file B (1-indexed) |
|
|
39
|
+
| `endLineB` | `number` | ✅ | End line of the section in file B, inclusive (1-indexed) |
|
|
40
|
+
|
|
41
|
+
Returns `"Les sections sont identiques."` when no differences are found, or a unified diff with real file line numbers otherwise.
|
|
42
|
+
|
|
43
|
+
## Configuration
|
|
44
|
+
|
|
45
|
+
All file paths must be **absolute**. Relative paths are rejected.
|
|
46
|
+
|
|
47
|
+
To restrict operations to a specific directory, set the `REFACTORING_ALLOWED_DIR` environment variable. Any attempt to access a file outside that directory will be blocked.
|
|
48
|
+
|
|
49
|
+
```env
|
|
50
|
+
# .env
|
|
51
|
+
REFACTORING_ALLOWED_DIR=C:/Users/you/my-project
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Installation
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npm install -g @imenam/refactoring-mcp
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Or use it directly with `npx`:
|
|
61
|
+
|
|
62
|
+
```json
|
|
63
|
+
{
|
|
64
|
+
"refactoring-mcp": {
|
|
65
|
+
"command": "npx",
|
|
66
|
+
"args": ["-y", "@imenam/refactoring-mcp"]
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Or point to a local build:
|
|
72
|
+
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"refactoring-mcp": {
|
|
76
|
+
"command": "node",
|
|
77
|
+
"args": ["/absolute/path/to/refactoring-mcp/dist/index.js"],
|
|
78
|
+
"env": {
|
|
79
|
+
"REFACTORING_ALLOWED_DIR": "/absolute/path/to/your/project"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Publication
|
|
86
|
+
|
|
87
|
+
Chaque push sur `master`, merge de pull request compris, publie une nouvelle version de `@imenam/refactoring-mcp` sur npm (`.github/workflows/publish.yml`) : `npm ci` et build, puis `npm version patch`, dont le commit et le tag sont poussés sur `master`, et `npm publish`. La publication passe par le trusted publishing de npm (OIDC, sans token), avec attestation de provenance. Un échec du build arrête le workflow avant la montée de version.
|
|
88
|
+
|
|
89
|
+
Sur npmjs.com, le paquet déclare ce workflow comme publieur de confiance (Settings → Trusted publishing → GitHub Actions : `Matthieu-Pesnot-Pin`, `refactoring-mcp`, `publish.yml`, avec `npm publish` dans les actions autorisées). Le commit de version est poussé avec `GITHUB_TOKEN` : si `master` est protégée, la règle doit autoriser GitHub Actions à y pousser.
|
|
90
|
+
|
|
91
|
+
## License
|
|
92
|
+
|
|
93
|
+
MIT
|
package/dist/index.js
CHANGED
|
@@ -70,7 +70,7 @@ const InsertTextSchema = z.object({
|
|
|
70
70
|
.describe("Numéro de la ligne devant laquelle le texte sera inséré (1-indexé). Utiliser fileLength + 1 pour insérer en fin de fichier."),
|
|
71
71
|
text: z
|
|
72
72
|
.string()
|
|
73
|
-
.describe("Texte à insérer. Peut contenir plusieurs lignes (\\n)."),
|
|
73
|
+
.describe("Texte à insérer. Peut contenir plusieurs lignes (\\n). Ne pas terminer par \\n : le saut de ligne final est géré automatiquement par l'outil."),
|
|
74
74
|
}))
|
|
75
75
|
.min(1)
|
|
76
76
|
.describe("Liste des insertions à effectuer. Les insertions sont appliquées du bas vers le haut pour éviter les décalages d'offset. Les numéros de lignes doivent référencer le fichier dans son état ORIGINAL (avant toute insertion)."),
|
|
@@ -128,7 +128,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
|
128
128
|
},
|
|
129
129
|
text: {
|
|
130
130
|
type: "string",
|
|
131
|
-
description: "Texte à insérer. Peut contenir plusieurs lignes (\\n).",
|
|
131
|
+
description: "Texte à insérer. Peut contenir plusieurs lignes (\\n). Ne pas terminer par \\n : le saut de ligne final est géré automatiquement par l'outil.",
|
|
132
132
|
},
|
|
133
133
|
},
|
|
134
134
|
required: ["lineNumber", "text"],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imenam/refactoring-mcp",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.2",
|
|
4
4
|
"description": "MCP server to copy or move code blocks between files, with optional directory confinement.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -14,10 +14,7 @@
|
|
|
14
14
|
"build": "tsc",
|
|
15
15
|
"start": "node dist/index.js",
|
|
16
16
|
"dev": "tsx src/index.ts",
|
|
17
|
-
"prepublishOnly": "npm run build"
|
|
18
|
-
"release:patch": "npm version patch && npm publish --access public && git push origin master --follow-tags",
|
|
19
|
-
"release:minor": "npm version minor && npm publish --access public && git push origin master --follow-tags",
|
|
20
|
-
"release:major": "npm version major && npm publish --access public && git push origin master --follow-tags"
|
|
17
|
+
"prepublishOnly": "npm run build"
|
|
21
18
|
},
|
|
22
19
|
"keywords": [
|
|
23
20
|
"mcp",
|
|
@@ -31,7 +28,7 @@
|
|
|
31
28
|
"license": "MIT",
|
|
32
29
|
"repository": {
|
|
33
30
|
"type": "git",
|
|
34
|
-
"url": "https://github.com/Matthieu-Pesnot-Pin/refactoring-mcp.git"
|
|
31
|
+
"url": "git+https://github.com/Matthieu-Pesnot-Pin/refactoring-mcp.git"
|
|
35
32
|
},
|
|
36
33
|
"publishConfig": {
|
|
37
34
|
"access": "public"
|