@@ -1090,12 +1090,35 @@ function generateSettingsJson(config: Config): string {
10901090 "max_tokens" : 4096
10911091 } ;
10921092
1093- // API keys go in ${PAI_DIR} /.env, not settings.json
1093+ // API keys go in ~ /.env, not settings.json
10941094 // Voice ID is stored in daidentity.voiceId above
10951095
10961096 return JSON . stringify ( settings , null , 2 ) ;
10971097}
10981098
1099+ function generateEnvFile ( config : Config ) : string {
1100+ const lines : string [ ] = [
1101+ '# PAI Environment Variables' ,
1102+ '# Generated by install.ts' ,
1103+ '' ,
1104+ ] ;
1105+
1106+ if ( config . apiKeys . elevenlabs ) {
1107+ lines . push ( `ELEVENLABS_API_KEY=${ config . apiKeys . elevenlabs } ` ) ;
1108+ } else {
1109+ lines . push ( '# ELEVENLABS_API_KEY=your_api_key_here' ) ;
1110+ }
1111+
1112+ if ( config . apiKeys . anthropic ) {
1113+ lines . push ( `ANTHROPIC_API_KEY=${ config . apiKeys . anthropic } ` ) ;
1114+ } else {
1115+ lines . push ( '# ANTHROPIC_API_KEY=your_api_key_here' ) ;
1116+ }
1117+
1118+ lines . push ( '' ) ;
1119+ return lines . join ( '\n' ) ;
1120+ }
1121+
10991122function createDirectoryStructure ( targetDir : string ) : void {
11001123 const dirs = [
11011124 'skills/CORE/USER' ,
@@ -1436,6 +1459,16 @@ async function main(): Promise<void> {
14361459 writeFileSync ( join ( CLAUDE_DIR , 'settings.json' ) , settingsJson ) ;
14371460 printSuccess ( 'Created settings.json with full permissions' ) ;
14381461
1462+ // Write .env file with API keys to home directory (~/.env)
1463+ const envFile = generateEnvFile ( config ) ;
1464+ const envPath = join ( HOME , '.env' ) ;
1465+ writeFileSync ( envPath , envFile ) ;
1466+ if ( config . apiKeys . elevenlabs || config . apiKeys . anthropic ) {
1467+ printSuccess ( 'Created ~/.env with API keys' ) ;
1468+ } else {
1469+ printSuccess ( 'Created ~/.env template (add API keys later)' ) ;
1470+ }
1471+
14391472 // Perform migration if needed
14401473 if ( source && ( mode === 'migrate' || mode === 'merge' ) ) {
14411474 await performMigration ( source , CLAUDE_DIR ) ;
0 commit comments