aios-core
Version:
Synkra AIOS: AI-Orchestrated System for Full Stack Development - Core Framework
271 lines (216 loc) • 7.64 kB
JavaScript
/**
* .env Template Generator
* Story 1.6: Environment Configuration
*
* Generates .env file with secure defaults and helpful comments
*
* @module env-template
*/
const path = require('path');
const fs = require('fs');
/**
* Get the current AIOS version from package.json
* @returns {string} The version string
*/
function getAiosVersion() {
try {
// Try to find the root package.json
const rootPkgPath = path.resolve(__dirname, '../../../../package.json');
if (fs.existsSync(rootPkgPath)) {
const pkg = JSON.parse(fs.readFileSync(rootPkgPath, 'utf8'));
return pkg.version || '2.2.0';
}
} catch {
// Ignore errors
}
return '2.2.0';
}
const AIOS_VERSION = getAiosVersion();
/**
* Generate .env file content
*
* @param {Object} apiKeys - API keys provided by user
* @param {string} [apiKeys.deepseek] - DeepSeek API key (optional)
* @param {string} [apiKeys.openai] - OpenAI API key (optional)
* @param {string} [apiKeys.anthropic] - Anthropic API key (optional)
* @param {string} [apiKeys.openrouter] - OpenRouter API key (optional)
* @param {string} [apiKeys.clickup] - ClickUp API key (optional)
* @param {string} [apiKeys.github] - GitHub token (optional)
* @param {string} [apiKeys.exa] - Exa API key (optional)
* @param {string} [apiKeys.supabaseUrl] - Supabase URL (optional)
* @param {string} [apiKeys.supabaseAnonKey] - Supabase anon key (optional)
* @returns {string} .env file content
*/
function generateEnvContent(apiKeys = {}) {
const content = `# ============================================
# Synkra AIOS Environment Configuration
# ============================================
# Generated by AIOS Installer
# DO NOT commit this file - it contains sensitive credentials
# ============================================
# --------------------------------------------
# LLM Providers
# --------------------------------------------
# DeepSeek API (for claude-free command)
# Get your key at: https://platform.deepseek.com/api_keys
# Cost: ~$0.14/M tokens with tool calling support
DEEPSEEK_API_KEY=${apiKeys.deepseek || ''}
# OpenRouter API (for multi-model routing)
# Get your key at: https://openrouter.ai/keys
OPENROUTER_API_KEY=${apiKeys.openrouter || ''}
# Anthropic API (direct, if not using Claude Max subscription)
# Get your key at: https://console.anthropic.com/
ANTHROPIC_API_KEY=${apiKeys.anthropic || ''}
# OpenAI API Key - Get yours at: https://platform.openai.com/api-keys
OPENAI_API_KEY=${apiKeys.openai || ''}
# --------------------------------------------
# Search & Research Tools
# --------------------------------------------
# Exa Search API (web search for agents)
# Get your key at: https://exa.ai/
EXA_API_KEY=${apiKeys.exa || ''}
# Context7 (library documentation lookup)
# Usually free, no key required for basic usage
CONTEXT7_API_KEY=
# --------------------------------------------
# Database & Backend
# --------------------------------------------
# Supabase (database, auth, storage)
# Get from your Supabase project settings
SUPABASE_URL=${apiKeys.supabaseUrl || ''}
SUPABASE_ANON_KEY=${apiKeys.supabaseAnonKey || ''}
SUPABASE_SERVICE_ROLE_KEY=
# --------------------------------------------
# Version Control & CI/CD
# --------------------------------------------
# GitHub Token (for GitHub CLI and API access)
# Create at: https://github.com/settings/tokens
GITHUB_TOKEN=${apiKeys.github || ''}
# --------------------------------------------
# Project Management
# --------------------------------------------
# ClickUp API (if using ClickUp integration)
# Get from: ClickUp Settings > Apps > API Token
CLICKUP_API_KEY=${apiKeys.clickup || ''}
# --------------------------------------------
# Automation & Workflows
# --------------------------------------------
# N8N (workflow automation)
# From your N8N instance settings
N8N_API_KEY=
N8N_WEBHOOK_URL=
# --------------------------------------------
# Monitoring & Analytics
# --------------------------------------------
# Sentry (error tracking)
SENTRY_DSN=
# --------------------------------------------
# Cloud Providers
# --------------------------------------------
# Railway (deployment)
RAILWAY_TOKEN=
# Vercel (deployment)
VERCEL_TOKEN=
# --------------------------------------------
# AIOS Core Configuration
# --------------------------------------------
NODE_ENV=development
AIOS_VERSION=${AIOS_VERSION}
# --------------------------------------------
# Custom Configuration
# --------------------------------------------
# Add your custom API keys below
`;
return content;
}
/**
* Generate .env.example file content (no sensitive data)
*
* @returns {string} .env.example file content
*/
function generateEnvExample() {
const content = `# ============================================
# Synkra AIOS Environment Configuration
# ============================================
# Copy this file to .env and fill in your actual values
# DO NOT commit .env with real credentials
# ============================================
# --------------------------------------------
# LLM Providers
# --------------------------------------------
# DeepSeek API (for claude-free command)
# Get your key at: https://platform.deepseek.com/api_keys
# Cost: ~$0.14/M tokens with tool calling support
DEEPSEEK_API_KEY=
# OpenRouter API (for multi-model routing)
# Get your key at: https://openrouter.ai/keys
OPENROUTER_API_KEY=
# Anthropic API (direct, if not using Claude Max subscription)
# Get your key at: https://console.anthropic.com/
ANTHROPIC_API_KEY=
# OpenAI API Key - Get yours at: https://platform.openai.com/api-keys
OPENAI_API_KEY=
# --------------------------------------------
# Search & Research Tools
# --------------------------------------------
# Exa Search API (web search for agents)
# Get your key at: https://exa.ai/
EXA_API_KEY=
# Context7 (library documentation lookup)
# Usually free, no key required for basic usage
CONTEXT7_API_KEY=
# --------------------------------------------
# Database & Backend
# --------------------------------------------
# Supabase (database, auth, storage)
# Get from your Supabase project settings
SUPABASE_URL=
SUPABASE_ANON_KEY=
SUPABASE_SERVICE_ROLE_KEY=
# --------------------------------------------
# Version Control & CI/CD
# --------------------------------------------
# GitHub Token (for GitHub CLI and API access)
# Create at: https://github.com/settings/tokens
GITHUB_TOKEN=
# --------------------------------------------
# Project Management
# --------------------------------------------
# ClickUp API (if using ClickUp integration)
# Get from: ClickUp Settings > Apps > API Token
CLICKUP_API_KEY=
# --------------------------------------------
# Automation & Workflows
# --------------------------------------------
# N8N (workflow automation)
# From your N8N instance settings
N8N_API_KEY=
N8N_WEBHOOK_URL=
# --------------------------------------------
# Monitoring & Analytics
# --------------------------------------------
# Sentry (error tracking)
SENTRY_DSN=
# --------------------------------------------
# Cloud Providers
# --------------------------------------------
# Railway (deployment)
RAILWAY_TOKEN=
# Vercel (deployment)
VERCEL_TOKEN=
# --------------------------------------------
# AIOS Core Configuration
# --------------------------------------------
NODE_ENV=development
AIOS_VERSION=${AIOS_VERSION}
# --------------------------------------------
# Custom Configuration
# --------------------------------------------
# Add your custom API keys below
`;
return content;
}
module.exports = {
generateEnvContent,
generateEnvExample,
};