Skip to content

Commit 9e34e22

Browse files
committed
Актуализация схем инструментов для LLM: новые возможности в описаниях
CodeRefactorTool: - Добавлено описание CHANGE_SIGNATURE с примером params - Добавлена секция BATCH INTEGRATION с affectedFiles и токенами - Добавлен inputSchema для params (change_signature): name, type, action, newName, defaultValue FileManageTool: - Уточнено описание PATH ALIASING для move/rename - Пример транзитивной цепочки: A.java -> B.java -> C.java BatchToolsTool: - Добавлена секция REFACTOR INTEGRATION с примерами интерполяции - {{ref.affectedFiles[0].accessToken}}, {{ref.affectedFiles[0].path}}, {{ref.token}} - Обновлён пример: refactor + edit chain - Добавлено упоминание Virtual FS Context для refactor
1 parent 29cbb70 commit 9e34e22

3 files changed

Lines changed: 47 additions & 11 deletions

File tree

app/src/main/java/ru/nts/tools/mcp/tools/fs/FileManageTool.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ public String getDescription() {
5959
6060
TOKEN BEHAVIOR:
6161
- create: Returns access token for immediate editing (no read needed!)
62-
- move/rename: Tokens automatically transferred to new path
62+
- move/rename: Tokens transferred via PATH ALIASING - even chains work!
63+
Example: A.java -> B.java -> C.java - token from A.java still valid for C.java
6364
- delete: All tokens for the file are invalidated
6465
6566
SAFETY:

app/src/main/java/ru/nts/tools/mcp/tools/refactoring/CodeRefactorTool.java

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,21 @@ public String getDescription() {
6565
path + symbol + newName [+ kind] [+ scope]
6666
scope: file|directory|project (default: project)
6767
68+
CHANGE_SIGNATURE:
69+
path + symbol (method) + params: [{name, type, action: add|remove|rename|retype|reorder}]
70+
Automatically updates ALL call sites across the project!
71+
6872
GENERATE:
6973
path + symbol (class name) + what (accessors|constructor|builder|toString)
7074
7175
LANGUAGES: Java, Kotlin, JS/TS/TSX, Python, Go, Rust, C/C++, C#, PHP, HTML
7276
73-
OTHER: delete, wrap, extract_method, inline, change_signature, move, batch
77+
OTHER: delete, wrap, extract_method, inline, move, batch
78+
79+
BATCH INTEGRATION:
80+
Returns 'affectedFiles' array with access tokens for each modified file.
81+
Use in nts_batch_tools: {{step.affectedFiles[0].accessToken}} or {{step.token}} (single file shortcut).
82+
Enables chains like: refactor -> edit without re-reading files!
7483
""";
7584
}
7685

@@ -215,6 +224,27 @@ public JsonNode getInputSchema() {
215224
options.put("type", "object");
216225
options.put("description", "Additional options specific to operation");
217226

227+
// params (for change_signature)
228+
ObjectNode csParams = properties.putObject("params");
229+
csParams.put("type", "array");
230+
ObjectNode csItem = csParams.putObject("items");
231+
csItem.put("type", "object");
232+
ObjectNode csItemProps = csItem.putObject("properties");
233+
csItemProps.putObject("name").put("type", "string").put("description", "Parameter name");
234+
csItemProps.putObject("type").put("type", "string").put("description", "Parameter type (for add/retype)");
235+
csItemProps.putObject("newName").put("type", "string").put("description", "New name (for rename)");
236+
csItemProps.putObject("defaultValue").put("type", "string").put("description", "Default value for new parameter");
237+
ObjectNode csAction = csItemProps.putObject("action");
238+
csAction.put("type", "string");
239+
ArrayNode csActionEnum = csAction.putArray("enum");
240+
csActionEnum.add("add");
241+
csActionEnum.add("remove");
242+
csActionEnum.add("rename");
243+
csActionEnum.add("retype");
244+
csActionEnum.add("reorder");
245+
csAction.put("description", "What to do with parameter");
246+
csParams.put("description", "[change_signature] Parameter modifications: add, remove, rename, retype, reorder");
247+
218248
// operations (for batch)
219249
ObjectNode operations = properties.putObject("operations");
220250
operations.put("type", "array");

app/src/main/java/ru/nts/tools/mcp/tools/system/BatchToolsTool.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,18 @@ public String getDescription() {
7171
- All-or-nothing: If ANY action fails -> ALL rolled back
7272
- Session Tokens: CRC check skipped within batch (no re-read needed)
7373
- InfinityRange: Files created in batch have no line boundary checks
74+
- Virtual FS Context: nts_code_refactor sees in-memory edits from previous steps
7475
7576
VARIABLE INTERPOLATION (token & path passing):
76-
- {{step1.token}} - First LAT token from step 1
77-
- {{step1.tokens}} - All tokens comma-separated
78-
- {{myId.token}} - Reference by action 'id'
79-
- {{myId.path}} - Current file path (auto-updates after rename/move!)
77+
- {{step1.token}} - First LAT token from step 1
78+
- {{step1.tokens}} - All tokens comma-separated
79+
- {{myId.token}} - Reference by action 'id'
80+
- {{myId.path}} - Current file path (auto-updates after rename/move!)
81+
82+
REFACTOR INTEGRATION (nts_code_refactor returns affectedFiles):
83+
- {{ref.affectedFiles[0].accessToken}} - Token for first affected file
84+
- {{ref.affectedFiles[0].path}} - Path of first affected file
85+
- {{ref.token}} - Shortcut when single file affected
8086
8187
SESSION REFERENCES (path tracking after rename/move):
8288
Use {{id.path}} to reference a file that was renamed/moved:
@@ -86,17 +92,16 @@ SESSION REFERENCES (path tracking after rename/move):
8692
{tool: 'nts_edit_file', params: {path: '{{f.path}}', ...}} // <- auto-resolves to 'New.java'!
8793
]
8894
89-
SMART LINE ADDRESSING (Virtual FS Context):
95+
SMART LINE ADDRESSING:
9096
For startLine/endLine, use special values that auto-calculate:
9197
- $LAST - Last line of the file
9298
- $PREV_END - End line of previous edit on this file
9399
- $PREV_END+N - N lines after previous edit (e.g., $PREV_END+1)
94100
95-
EXAMPLE (create + rename + edit):
101+
EXAMPLE (refactor + edit chain):
96102
actions: [
97-
{id: 'svc', tool: 'nts_file_manage', params: {action: 'create', path: 'Service.java', content: 'class Service {}'}},
98-
{tool: 'nts_file_manage', params: {action: 'rename', path: '{{svc.path}}', newName: 'UserService.java'}},
99-
{tool: 'nts_edit_file', params: {path: '{{svc.path}}', startLine: 1, content: 'class UserService {}', accessToken: '{{svc.token}}'}}
103+
{id: 'ref', tool: 'nts_code_refactor', params: {action: 'rename', path: 'User.java', symbol: 'getName', newName: 'getFullName'}},
104+
{tool: 'nts_edit_file', params: {path: '{{ref.affectedFiles[0].path}}', startLine: 1, operation: 'insert_after', content: '// Renamed method', accessToken: '{{ref.affectedFiles[0].accessToken}}'}}
100105
]
101106
102107
LIMITATION: Only NTS MCP tools tracked in rollback.

0 commit comments

Comments
 (0)