// =============================================================================
// Git commit-and-push tool registration. Logic lives in ./git-api.ts.
// =============================================================================

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

registerTool({
    name: 'git_commit_and_push',
    description: 'Stage all changes, commit with a message, and push to the remote. Call this when work is complete.',
    parameters: {
        type: 'object',
        properties: {
            message: { type: 'string', description: 'Commit message describing the changes made' }
        },
        required: ['message']
    },
    async handler(args, ctx) {
        return api.gitCommitAndPush(ctx.workspaceRoot, String(args.message), {
            apiUrl: ctx.gitea.apiUrl,
            apiToken: ctx.gitea.apiToken,
            username: ctx.gitea.username,
        });
    }
});
