"use strict";
// =============================================================================
// Skills tool registrations. Logic lives in ./skills-api.ts.
// =============================================================================
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
const registry_1 = require("./registry");
const api = __importStar(require("./skills-api"));
(0, registry_1.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));
    }
});
(0, registry_1.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));
    }
});
