feat: load .env file at startup using Node built-in loadEnvFile

Adds process.loadEnvFile() to CLI entry point so API keys (ZHIPUAI_API_KEY,
OPENROUTER_API_KEY, XAI_API_KEY, etc.) can be stored in a project .env file
instead of shell environment or systemd service config. Uses Node >= 20.12
built-in — no dotenv dependency needed. Silent no-op if .env doesn't exist.

Updates .env.example with placeholders for all provider API keys.
This commit is contained in:
William Valentin
2026-02-10 21:43:09 -08:00
parent 5c90640e2a
commit 2f6d045e2a
2 changed files with 14 additions and 0 deletions
+9
View File
@@ -4,5 +4,14 @@ FLYNN_TELEGRAM_TOKEN=your-bot-token-here
# Anthropic API Key
ANTHROPIC_API_KEY=your-anthropic-api-key-here
# Optional: ZhipuAI API Key (for GLM models via /model command)
# ZHIPUAI_API_KEY=your-zhipuai-api-key-here
# Optional: OpenRouter API Key
# OPENROUTER_API_KEY=your-openrouter-api-key-here
# Optional: xAI API Key (for Grok models)
# XAI_API_KEY=your-xai-api-key-here
# Optional: Custom config path
# FLYNN_CONFIG=/path/to/config.yaml
+5
View File
@@ -1,4 +1,9 @@
#!/usr/bin/env node
// Load .env file from project root (Node >= 20.12 built-in, no dotenv needed).
// Silent no-op if the file doesn't exist.
try { process.loadEnvFile(); } catch { /* .env not found — that's fine */ }
import { Command } from 'commander';
import { registerStartCommand } from './start.js';
import { registerSendCommand } from './send.js';