// =============================================================================
// Skills tool registrations. Logic lives in ./skills-api.ts.
// =============================================================================

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

registerTool({
    name: 'list_skills',
    description: `List available skills for a project repo. Skills are stored in .skills/<name>/SKILL.md and provide reusable instructions the agent should follow (e.g. deploy process, test commands, code conventions).`,
    parameters: {
        type: 'object',
        properties: {
            repo: { type: 'string', description: 'Repo in "owner/name" format' }
        },
        required: ['repo']
    },
    async handler(args, ctx) {
        return api.listSkills(
            { apiUrl: ctx.gitea.apiUrl, apiToken: ctx.gitea.apiToken },
            String(args.repo),
        );
    }
});

registerTool({
    name: 'get_skill',
    description: `Read the full content of a specific skill from a project repo. Call list_skills first to see what's available. Use this before spawning agents so they have the relevant project-specific instructions.`,
    parameters: {
        type: 'object',
        properties: {
            repo: { type: 'string', description: 'Repo in "owner/name" format' },
            skill_name: { type: 'string', description: 'Skill name (directory name inside .skills/)' }
        },
        required: ['repo', 'skill_name']
    },
    async handler(args, ctx) {
        return api.getSkill(
            { apiUrl: ctx.gitea.apiUrl, apiToken: ctx.gitea.apiToken },
            String(args.repo),
            String(args.skill_name),
        );
    }
});
