#!/usr/bin/env node
"use strict";
/**
 * Create Agent Script
 * Creates a new agent from a template
 */
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 });
exports.createAgentFromTemplate = createAgentFromTemplate;
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
function generateAgentTemplate(options) {
    const { name, emoji, color } = options;
    const displayName = name
        .split('-')
        .map(word => word.charAt(0).toUpperCase() + word.slice(1))
        .join(' ');
    return `---
name: ${displayName}
description: A specialized agent for [describe what this agent does]
color: ${color}
emoji: ${emoji}
vibe: Brief personality description
---

# ${displayName} Agent Personality

You are **${displayName}**, a specialized agent focused on [domain]. You bring deep expertise in [specific skills] and help users achieve [outcomes].

## Your Identity & Memory
- **Role**: [Primary role description]
- **Personality**: [Key personality traits]
- **Memory**: [What you remember and learn from]
- **Experience**: [Your background and expertise]

## Your Core Mission

### Primary Objective
- [Main task 1]
- [Main task 2]
- [Main task 3]

### Secondary Objectives
- [Secondary task 1]
- [Secondary task 2]

## Critical Rules You Must Follow

### Rule Category 1
- **DO**: [What to do]
- **DON'T**: [What not to do]

### Rule Category 2
- **DO**: [What to do]
- **DON'T**: [What not to do]

## Your Technical Approach

### Process
1. **Step 1**: [Description]
2. **Step 2**: [Description]
3. **Step 3**: [Description]

### Templates
[Template example]

## Tools & Technologies

- **Primary**: [Tool/tech 1], [Tool/tech 2]
- **Secondary**: [Tool/tech 3], [Tool/tech 4]

## Integration with Other Agents

| Task | Collaborate With |
|------|-----------------|
| [Task 1] | @[other-agent] |
| [Task 2] | @[other-agent] |

## Delivery Checklist

- [ ] [Deliverable 1]
- [ ] [Deliverable 2]
- [ ] [Deliverable 3]
`;
}
async function createAgentFromTemplate(options) {
    const agentsDir = path.join(process.cwd(), 'agents', options.department);
    // Ensure department directory exists
    if (!fs.existsSync(agentsDir)) {
        fs.mkdirSync(agentsDir, { recursive: true });
    }
    const fileName = `${options.department}-${options.name}.md`;
    const filePath = path.join(agentsDir, fileName);
    // Check if agent already exists
    if (fs.existsSync(filePath)) {
        throw new Error(`Agent already exists: ${filePath}`);
    }
    // Generate and write template
    const template = generateAgentTemplate(options);
    fs.writeFileSync(filePath, template, 'utf-8');
    return filePath;
}
// CLI execution
if (require.main === module) {
    const args = process.argv.slice(2);
    if (args.length < 1) {
        console.log('Usage: npx tsx scripts/create-agent.ts <name> [options]');
        console.log('');
        console.log('Options:');
        console.log('  -d, --department <dept>  Department (default: specialized)');
        console.log('  -e, --emoji <emoji>      Emoji (default: 🤖)');
        console.log('  -c, --color <color>      Color hex (default: #3B82F6)');
        console.log('');
        console.log('Example:');
        console.log('  npx tsx scripts/create-agent.ts my-agent -d engineering -e 🚀 -c #FF5733');
        process.exit(1);
    }
    const options = {
        name: args[0],
        department: 'specialized',
        emoji: '🤖',
        color: '#3B82F6'
    };
    // Parse options
    for (let i = 1; i < args.length; i += 2) {
        const flag = args[i];
        const value = args[i + 1];
        if (flag === '-d' || flag === '--department') {
            options.department = value;
        }
        else if (flag === '-e' || flag === '--emoji') {
            options.emoji = value;
        }
        else if (flag === '-c' || flag === '--color') {
            options.color = value;
        }
    }
    createAgentFromTemplate(options)
        .then(filePath => {
        console.log('\n✅ Agent created successfully!');
        console.log(`   File: ${filePath}`);
        console.log('\nNext steps:');
        console.log('  1. Edit the agent file to customize instructions');
        console.log('  2. Add keywords to router/keywords.json');
        console.log('  3. Run: npm run registry');
    })
        .catch(error => {
        console.error('❌ Failed to create agent:', error.message);
        process.exit(1);
    });
}
//# sourceMappingURL=create-agent.js.map