"use strict";
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.SystemInstaller = void 0;
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
class SystemInstaller {
    root;
    constructor(root = process.cwd()) {
        this.root = root;
    }
    install() {
        const configDir = path.join(this.root, '.openlife');
        if (!fs.existsSync(configDir))
            fs.mkdirSync(configDir, { recursive: true });
        const installManifest = {
            installedAt: new Date().toISOString(),
            root: this.root,
            files: [
                'models.json',
                'executor-policy.json',
                'voice.config.json'
            ],
            providers: {
                openai: !!process.env.OPENAI_API_KEY,
                gemini: !!process.env.GEMINI_API_KEY,
                anthropic: !!process.env.ANTHROPIC_API_KEY
            },
            clis: {
                codex: true,
                gemini: true,
                ollama: true
            }
        };
        const manifestPath = path.join(configDir, 'install-manifest.json');
        fs.writeFileSync(manifestPath, JSON.stringify(installManifest, null, 2), 'utf-8');
        return manifestPath;
    }
    status() {
        return {
            root: this.root,
            hasModels: fs.existsSync(path.join(this.root, 'models.json')),
            hasExecutorPolicy: fs.existsSync(path.join(this.root, 'executor-policy.json')),
            hasVoiceConfig: fs.existsSync(path.join(this.root, 'voice.config.json')),
            hasArtifacts: fs.existsSync(path.join(this.root, '.artifacts')),
            hasInstallManifest: fs.existsSync(path.join(this.root, '.openlife', 'install-manifest.json'))
        };
    }
    initProject() {
        const configDir = path.join(this.root, '.openlife');
        if (!fs.existsSync(configDir))
            fs.mkdirSync(configDir, { recursive: true });
        const file = path.join(configDir, 'PROJECT.md');
        if (!fs.existsSync(file)) {
            fs.writeFileSync(file, '# OPENLIFE PROJECT\n\nDescreva aqui o projeto, contexto, regras e objetivos.\n', 'utf-8');
        }
        return file;
    }
}
exports.SystemInstaller = SystemInstaller;
