validate_changes
Validate proposed code changes using AI-powered syntax checking and impact analysis to prevent errors before implementation.
Instructions
Pre-flight validation for code changes - AI-powered syntax checking and impact analysis. Validates proposed modifications before implementation.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | ||
| proposed_changes | Yes | ||
| language | No | ||
| validation_rules | No |
Implementation Reference
- src/handlers/system-handlers.js:201-237 (handler)The ValidateChangesHandler class that implements the tool logic. It validates proposed code changes by checking each change for potential null/undefined values if 'syntax' is in validation_rules, then returns a summary with validation results.
/** * Validate changes handler */ class ValidateChangesHandler extends BaseHandler { async execute(args) { const { file_path, proposed_changes, validation_rules = ['syntax'] } = args; const validationResults = []; for (const change of proposed_changes) { const result = { find: change.find, replace: change.replace, valid: true, warnings: [], suggestions: [] }; // Basic validation if (validation_rules.includes('syntax')) { if (change.replace.includes('undefined') || change.replace.includes('null')) { result.warnings.push('Potential null/undefined values detected'); } } validationResults.push(result); } return { success: true, file_path, total_changes: proposed_changes.length, valid_changes: validationResults.filter(r => r.valid).length, validation_results: validationResults }; } } - src/tools/tool-definitions.js:68-97 (schema)The tool definition for 'validate_changes' including its name, description, handler mapping (handleValidateChanges), and JSON schema defining inputs: file_path (string, required), proposed_changes (array of {find, replace, line_number}, required), language (string), validation_rules (array of strings, default: ['syntax','logic','security','performance']).
{ name: 'validate_changes', description: 'Pre-flight validation for code changes - AI-powered syntax checking and impact analysis. Validates proposed modifications before implementation.', handler: 'handleValidateChanges', schema: { type: 'object', properties: { file_path: { type: 'string' }, proposed_changes: { type: 'array', items: { type: 'object', properties: { find: { type: 'string' }, replace: { type: 'string' }, line_number: { type: 'number' } }, required: ['find', 'replace'] } }, language: { type: 'string' }, validation_rules: { type: 'array', items: { type: 'string' }, default: ['syntax', 'logic', 'security', 'performance'] } }, required: ['file_path', 'proposed_changes'] } }, - src/handlers/index.js:47-47 (registration)Registration of 'handleValidateChanges' mapping to ValidateChangesHandler class in the HANDLER_REGISTRY object.
'handleValidateChanges': ValidateChangesHandler, - src/handlers/index.js:164-164 (registration)Export of the ValidateChangesHandler class from the handlers module.
ValidateChangesHandler, - src/handlers/system-handlers.js:442-447 (registration)Export of ValidateChangesHandler from system-handlers.js, which is then imported by handlers/index.js.
export { HealthHandler, ValidateChangesHandler, ManageConversationHandler, GetAnalyticsHandler };