edit_file
Modify files with AI-powered edits using find-and-replace operations, validation modes, and fuzzy matching to ensure accurate content changes.
Instructions
๐ง ENHANCED Intelligent file editing - FileModificationManager orchestrated operations with smart AI routing. AI-powered targeted modifications with validation, rollback capability, and complexity-based endpoint selection for optimal performance.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| edits | Yes | ||
| file_path | Yes | ||
| fuzzy_threshold | No | Similarity threshold for fuzzy matching (0.1-1.0, higher = more strict) | |
| language | No | ||
| max_suggestions | No | Maximum number of fuzzy match suggestions to provide | |
| suggest_alternatives | No | Include fuzzy match suggestions in error messages | |
| validation_mode | No | strict |
Input Schema (JSON Schema)
{
"properties": {
"edits": {
"items": {
"properties": {
"description": {
"type": "string"
},
"find": {
"type": "string"
},
"replace": {
"type": "string"
}
},
"required": [
"find",
"replace"
],
"type": "object"
},
"type": "array"
},
"file_path": {
"type": "string"
},
"fuzzy_threshold": {
"default": 0.8,
"description": "Similarity threshold for fuzzy matching (0.1-1.0, higher = more strict)",
"maximum": 1,
"minimum": 0.1,
"type": "number"
},
"language": {
"type": "string"
},
"max_suggestions": {
"default": 3,
"description": "Maximum number of fuzzy match suggestions to provide",
"maximum": 10,
"minimum": 1,
"type": "integer"
},
"suggest_alternatives": {
"default": true,
"description": "Include fuzzy match suggestions in error messages",
"type": "boolean"
},
"validation_mode": {
"default": "strict",
"enum": [
"strict",
"lenient",
"dry_run"
],
"type": "string"
}
},
"required": [
"file_path",
"edits"
],
"type": "object"
}
Implementation Reference
- smart-ai-bridge-v1.1.0.js:1017-1019 (handler)The primary handler function for the 'edit_file' MCP tool. It delegates the edit operation to the FileModificationManager.orchestrateOperation with 'single_edit' type.async handleEditFile(args) { return await this.fileManager.orchestrateOperation('single_edit', args); }
- smart-ai-bridge-v1.1.0.js:339-363 (schema)Input schema for the 'edit_file' tool defining the expected parameters: file_path, array of edits (find/replace pairs), optional language and validation_mode.schema: { type: 'object', properties: { file_path: { type: 'string' }, edits: { type: 'array', items: { type: 'object', properties: { find: { type: 'string' }, replace: { type: 'string' }, description: { type: 'string' } }, required: ['find', 'replace'] } }, language: { type: 'string' }, validation_mode: { type: 'string', enum: ['strict', 'lenient', 'none'], default: 'strict' } }, required: ['file_path', 'edits'] }
- smart-ai-bridge-v1.1.0.js:335-364 (registration)Core tool registration for 'edit_file' in SmartAliasResolver.initializeCoreTools(), including name, description, handler reference, and schema. This object is added to coreTools Map.{ name: 'edit_file', description: '๐ง ENHANCED Intelligent file editing - FileModificationManager orchestrated operations with smart AI routing. AI-powered targeted modifications with validation, rollback capability, and complexity-based endpoint selection for optimal performance.', handler: 'handleEditFile', schema: { type: 'object', properties: { file_path: { type: 'string' }, edits: { type: 'array', items: { type: 'object', properties: { find: { type: 'string' }, replace: { type: 'string' }, description: { type: 'string' } }, required: ['find', 'replace'] } }, language: { type: 'string' }, validation_mode: { type: 'string', enum: ['strict', 'lenient', 'none'], default: 'strict' } }, required: ['file_path', 'edits'] } },
- smart-ai-bridge-v1.1.0.js:582-596 (registration)Alias registrations mapping 'MKG_edit' and 'deepseek_edit' to the core 'edit_file' tool in SmartAliasResolver.initializeAliasGroups().const aliasDefinitions = [ // MKG aliases { alias: 'MKG_analyze', coreTool: 'review' }, { alias: 'MKG_generate', coreTool: 'ask' }, { alias: 'MKG_review', coreTool: 'review' }, { alias: 'MKG_edit', coreTool: 'edit_file' }, { alias: 'MKG_health', coreTool: 'health' }, // DeepSeek aliases { alias: 'deepseek_analyze', coreTool: 'review' }, { alias: 'deepseek_generate', coreTool: 'ask' }, { alias: 'deepseek_review', coreTool: 'review' }, { alias: 'deepseek_edit', coreTool: 'edit_file' }, { alias: 'deepseek_health', coreTool: 'health' } ];