// =============================================================================
// Shell execution tool registration. Logic lives in ./shell-api.ts.
// =============================================================================

import { registerTool } from './registry';
import * as api from './shell-api';

registerTool({
    name: 'execute_command',
    description: 'Run a shell command in the workspace and return stdout + stderr. 120s timeout. Use for: npm install, npm test, git status, building, etc.',
    parameters: {
        type: 'object',
        properties: {
            command: { type: 'string', description: 'Shell command to run' },
            working_directory: { type: 'string', description: 'Optional: relative subdirectory to run in' }
        },
        required: ['command']
    },
    async handler(args, ctx) {
        return api.executeCommand(
            ctx.workspaceRoot,
            String(args.command),
            args.working_directory ? String(args.working_directory) : undefined
        );
    }
});
