@@ -749,6 +749,48 @@ async function handleSetup(args) {
749749 ( failed > 0 ? `, \x1b[31m${ failed } failed\x1b[0m` : "" ) +
750750 "\n"
751751 ) ;
752+
753+ // Auto-setup WSL if on Windows to ensure codex works properly
754+ if ( process . platform === "win32" && ! checkOnly && failed === 0 ) {
755+ try {
756+ const wslCheck = spawnSync ( "wsl" , [ "--status" ] , { stdio : "ignore" , timeout : 2000 } ) ;
757+ if ( wslCheck . status === 0 ) {
758+ console . log ( " \x1b[36m⚡ Windows Subsystem for Linux (WSL) detected.\x1b[0m" ) ;
759+ console . log ( " Running automatic setup in WSL (this may take a moment)..." ) ;
760+
761+ let installCmd = "npm install -g @openai/codex cloding 2>/dev/null && cloding setup" ;
762+
763+ // Check if node is installed in WSL
764+ const nodeCheck = spawnSync ( "wsl" , [ "bash" , "-c" , "command -v node" ] , { stdio : "ignore" , timeout : 2000 } ) ;
765+ if ( nodeCheck . status !== 0 ) {
766+ console . log ( " \x1b[33mNode.js not found in WSL. Installing...\x1b[0m" ) ;
767+ // Install Node.js 22.x on Debian/Ubuntu based WSL and then install the tools
768+ installCmd = "curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - && sudo apt-get install -y nodejs && sudo npm install -g @openai/codex cloding && cloding setup" ;
769+ }
770+
771+ const wslResult = spawnSync (
772+ "wsl" ,
773+ [
774+ "bash" ,
775+ "-c" ,
776+ installCmd ,
777+ ] ,
778+ { stdio : "inherit" }
779+ ) ;
780+
781+ if ( wslResult . status === 0 ) {
782+ console . log ( " \x1b[32m✓\x1b[0m WSL setup completed successfully\n" ) ;
783+ } else {
784+ console . log ( " \x1b[31m✗\x1b[0m WSL setup failed or requires manual permissions.\n" ) ;
785+ console . log ( " You can run the setup manually inside your WSL terminal:" ) ;
786+ console . log ( " npm install -g @openai/codex cloding && cloding setup\n" ) ;
787+ }
788+ }
789+ } catch {
790+ // Ignore WSL detection errors
791+ }
792+ }
793+
752794 process . exit ( failed > 0 ? 1 : 0 ) ;
753795}
754796
@@ -968,8 +1010,11 @@ function dockerRun(dockerArgs, models, interactive) {
9681010 if ( apiKeyEnv === "OPENROUTER_API_KEY" ) {
9691011 console . error (
9701012 "Error: OPENROUTER_API_KEY not set.\n\n" +
971- "Get your key at https://openrouter.ai/keys\n" +
972- `Then: ${ envSetHint ( "OPENROUTER_API_KEY" , "sk-or-v1-..." ) } \n`
1013+ "Options:\n" +
1014+ " 1. Set OpenRouter key: " + envSetHint ( "OPENROUTER_API_KEY" , "sk-or-v1-..." ) + "\n" +
1015+ " Get one at https://openrouter.ai/keys\n" +
1016+ " 2. Use Anthropic API key: cloding docker run -m sonnet-a \"...\"\n" +
1017+ " (Requires: " + envSetHint ( "ANTHROPIC_API_KEY" , "sk-ant-..." ) + ")\n"
9731018 ) ;
9741019 } else {
9751020 console . error (
@@ -1078,6 +1123,7 @@ function dockerRun(dockerArgs, models, interactive) {
10781123 envVars . push ( `OPENCODE_API_KEY=${ apiKey } ` ) ;
10791124 } else if ( tool === "codex" ) {
10801125 if ( apiKey ) envVars . push ( `OPENAI_API_KEY=${ apiKey } ` ) ;
1126+ envVars . push ( "NPM_CONFIG_UPDATE_NOTIFIER=false" ) ;
10811127 } else if ( tool === "copilot" && apiKey ) {
10821128 envVars . push ( `GITHUB_TOKEN=${ apiKey } ` ) ;
10831129 }
@@ -1506,10 +1552,22 @@ function main() {
15061552 const apiKey = isPlanProvider ? "" : process . env [ apiKeyEnv ] ;
15071553 const usingLinkedCliAuth = ! apiKey && canUseCliLinkedAuth ( tool ) ;
15081554 if ( ! apiKey && ! usingLinkedCliAuth && ! isPlanProvider ) {
1509- console . error (
1510- `Error: ${ apiKeyEnv } not set.\n\n` +
1511- `Please set it: ${ envSetHint ( apiKeyEnv , "..." ) } `
1512- ) ;
1555+ if ( apiKeyEnv === "OPENROUTER_API_KEY" ) {
1556+ console . error (
1557+ `Error: OPENROUTER_API_KEY not set (required for default models).\n\n` +
1558+ `Options:\n` +
1559+ ` 1. Set OpenRouter key: ${ envSetHint ( "OPENROUTER_API_KEY" , "sk-or-v1-..." ) } \n` +
1560+ ` Get one at https://openrouter.ai/keys\n` +
1561+ ` 2. Use Claude paid plan: cloding -m sonnet-p\n` +
1562+ ` 3. Use Anthropic API key: cloding -m sonnet-a\n` +
1563+ ` (Requires: ${ envSetHint ( "ANTHROPIC_API_KEY" , "sk-ant-..." ) } )\n`
1564+ ) ;
1565+ } else {
1566+ console . error (
1567+ `Error: ${ apiKeyEnv } not set.\n\n` +
1568+ `Please set it: ${ envSetHint ( apiKeyEnv , "..." ) } `
1569+ ) ;
1570+ }
15131571 process . exit ( 1 ) ;
15141572 }
15151573
@@ -1544,6 +1602,8 @@ function main() {
15441602 if ( apiKey ) {
15451603 runEnv . OPENAI_API_KEY = apiKey ;
15461604 }
1605+ // Prevent codex cli update prompt loop
1606+ runEnv . NPM_CONFIG_UPDATE_NOTIFIER = "false" ;
15471607 } else if ( tool === "copilot" ) {
15481608 if ( apiKey ) {
15491609 runEnv . GITHUB_TOKEN = apiKey ;
@@ -1626,6 +1686,7 @@ function main() {
16261686 // Add common ones just in case (only if they exist)
16271687 if ( runEnv . OPENAI_API_KEY ) wslenv . push ( "OPENAI_API_KEY/u" ) ;
16281688 if ( runEnv . OPENROUTER_API_KEY ) wslenv . push ( "OPENROUTER_API_KEY/u" ) ;
1689+ wslenv . push ( "NPM_CONFIG_UPDATE_NOTIFIER/u" ) ;
16291690
16301691 if ( process . env . WSLENV ) {
16311692 runEnv . WSLENV = `${ process . env . WSLENV } :${ wslenv . join ( ":" ) } ` ;
0 commit comments