diff --git a/docs/configuration.md b/docs/configuration.md index c422312..b9ff769 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -6,10 +6,15 @@ Complete reference for LettaBot configuration options. LettaBot checks these locations in order: -1. `./lettabot.yaml` - Project-local (recommended) -2. `./lettabot.yml` - Project-local alternate -3. `~/.lettabot/config.yaml` - User global -4. `~/.lettabot/config.yml` - User global alternate +1. `LETTABOT_CONFIG` env var - Explicit path override +2. `./lettabot.yaml` - Project-local (recommended) +3. `./lettabot.yml` - Project-local alternate +4. `~/.lettabot/config.yaml` - User global +5. `~/.lettabot/config.yml` - User global alternate + +For global installs (`npm install -g`), either: +- Create `~/.lettabot/config.yaml`, or +- Set `export LETTABOT_CONFIG=/path/to/your/config.yaml` ## Example Configuration @@ -203,6 +208,7 @@ Environment variables override config file values: | Env Variable | Config Equivalent | |--------------|-------------------| +| `LETTABOT_CONFIG` | Path to config file (overrides search order) | | `LETTA_API_KEY` | `server.apiKey` | | `LETTA_BASE_URL` | `server.baseUrl` | | `LETTA_AGENT_ID` | `agent.id` | diff --git a/src/cli.ts b/src/cli.ts index fbf3a92..f504667 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -105,12 +105,13 @@ async function server() { if (!existsSync(configPath)) { console.log(` No config file found. Searched locations: - 1. ./lettabot.yaml (project-local - recommended) - 2. ./lettabot.yml - 3. ~/.lettabot/config.yaml (user global) - 4. ~/.lettabot/config.yml + 1. LETTABOT_CONFIG env var (not set) + 2. ./lettabot.yaml (project-local - recommended) + 3. ./lettabot.yml + 4. ~/.lettabot/config.yaml (user global) + 5. ~/.lettabot/config.yml -Run "lettabot onboard" to create a config file. +Run "lettabot onboard" to create a config, or set LETTABOT_CONFIG=/path/to/config.yaml `); process.exit(1); } diff --git a/src/config/io.ts b/src/config/io.ts index 06bc6f2..0047901 100644 --- a/src/config/io.ts +++ b/src/config/io.ts @@ -23,8 +23,20 @@ const DEFAULT_CONFIG_PATH = join(homedir(), '.lettabot', 'config.yaml'); /** * Find the config file path (first existing, or default) + * + * Priority: + * 1. LETTABOT_CONFIG env var (explicit override) + * 2. ./lettabot.yaml (project-local) + * 3. ./lettabot.yml (project-local alt) + * 4. ~/.lettabot/config.yaml (user global) + * 5. ~/.lettabot/config.yml (user global alt) */ export function resolveConfigPath(): string { + // Environment variable takes priority + if (process.env.LETTABOT_CONFIG) { + return resolve(process.env.LETTABOT_CONFIG); + } + for (const p of CONFIG_PATHS) { if (existsSync(p)) { return p; diff --git a/src/main.ts b/src/main.ts index 352aa5a..a4382b6 100644 --- a/src/main.ts +++ b/src/main.ts @@ -131,12 +131,13 @@ const isContainerDeploy = !!(process.env.RAILWAY_ENVIRONMENT || process.env.REND if (!existsSync(configPath) && !isContainerDeploy) { console.log(` No config file found. Searched locations: - 1. ./lettabot.yaml (project-local - recommended) - 2. ./lettabot.yml - 3. ~/.lettabot/config.yaml (user global) - 4. ~/.lettabot/config.yml + 1. LETTABOT_CONFIG env var (not set) + 2. ./lettabot.yaml (project-local - recommended) + 3. ./lettabot.yml + 4. ~/.lettabot/config.yaml (user global) + 5. ~/.lettabot/config.yml -Run "lettabot onboard" to create a config file. +Run "lettabot onboard" to create a config, or set LETTABOT_CONFIG=/path/to/config.yaml `); process.exit(1); }