// packages/skill-shared/src/config.ts
import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'node:fs';
import { homedir } from 'node:os';
import { join } from 'node:path';
export function getConfigDir() {
    return process.env.MBS_CONFIG_DIR ?? join(homedir(), '.config', 'mbs');
}
const getConfigPath = () => join(getConfigDir(), 'config.json');
const DEFAULT_CONFIG = {
    apiUrl: 'http://www.instudio.me:6206',
};
export function getConfig() {
    const path = getConfigPath();
    if (!existsSync(path)) {
        return DEFAULT_CONFIG;
    }
    return JSON.parse(readFileSync(path, 'utf8'));
}
export function setConfig(config) {
    const dir = getConfigDir();
    mkdirSync(dir, { recursive: true });
    writeFileSync(getConfigPath(), JSON.stringify(config, null, 2), 'utf8');
}
//# sourceMappingURL=config.js.map