From 2f6d045e2aced3f538a6f0dc76eaa935a3100c37 Mon Sep 17 00:00:00 2001 From: William Valentin Date: Tue, 10 Feb 2026 21:43:09 -0800 Subject: [PATCH] feat: load .env file at startup using Node built-in loadEnvFile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .env.example | 9 +++++++++ src/cli/index.ts | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/.env.example b/.env.example index 7270b81..e4562c5 100644 --- a/.env.example +++ b/.env.example @@ -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 diff --git a/src/cli/index.ts b/src/cli/index.ts index 1d2c3ec..0d2897f 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -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';