feat(cli): port Fase 4 CLI — parser arg, mode dispatch, single-process composition root + REPL loop, bootstrap seed
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Bootstrap seed — create the initial settings.json / app_config.json if missing.
|
||||
* Mirrors the Rust `bootstrap` seed.
|
||||
*/
|
||||
import { newStore, ensureStoreDirs } from "@zesdex/domain";
|
||||
import { JsonSettingsRepository, JsonAppConfigRepository } from "@zesdex/infrastructure";
|
||||
|
||||
/** Seed default settings + app config into the store directory. */
|
||||
export async function bootstrap(): Promise<void> {
|
||||
const store = newStore();
|
||||
await ensureStoreDirs(store);
|
||||
|
||||
const settingsRepo = new JsonSettingsRepository();
|
||||
const appConfigRepo = new JsonAppConfigRepository();
|
||||
|
||||
const settings = await settingsRepo.load(store.base_dir);
|
||||
const appConfig = await appConfigRepo.load(store.base_dir);
|
||||
|
||||
if (!settings.api_keys[settings.provider]) {
|
||||
console.info(`provider '${settings.provider}' has no API key configured.`);
|
||||
}
|
||||
|
||||
console.info(`seeded defaults at ${store.base_dir}`);
|
||||
console.info(` provider: ${settings.provider}`);
|
||||
console.info(` model: ${settings.model}`);
|
||||
console.info(` providers: ${Object.keys(appConfig.providers).join(", ") || "(none)"}`);
|
||||
}
|
||||
|
||||
// Run when invoked directly as `bun src/bootstrap.ts`.
|
||||
if (import.meta.main) {
|
||||
bootstrap().catch((e) => {
|
||||
console.error(e instanceof Error ? e.message : String(e));
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user