From 4d4e218575c724d4e3e9fd3e5f5c439dd32e90cf Mon Sep 17 00:00:00 2001 From: Chris Estreich Date: Thu, 26 Jun 2025 13:24:09 -0700 Subject: [PATCH] Default NODE_ENV to development (#139) --- apps/roomote/package.json | 6 +++-- apps/roomote/src/{ => lib}/cli.ts | 42 ++++++++++++++----------------- apps/roomote/src/lib/runTask.ts | 13 +--------- packages/env/src/index.ts | 2 +- 4 files changed, 25 insertions(+), 38 deletions(-) rename apps/roomote/src/{ => lib}/cli.ts (91%) diff --git a/apps/roomote/package.json b/apps/roomote/package.json index f428b58a25..28318af923 100644 --- a/apps/roomote/package.json +++ b/apps/roomote/package.json @@ -9,9 +9,11 @@ "dev": "dotenvx run -f ../../.env.development -- next dev --turbopack --port 3001", "build": "dotenvx run -f ../../.env.production -- next build", "start": "dotenvx run -f ../../.env.production -- next start --port 3001", - "worker": "dotenvx run -f ../../.env.development -- tsx src/lib/worker.ts", "controller": "dotenvx run -f ../../.env.development -- tsx src/lib/controller.ts", - "cli": "dotenvx run -f ../../.env.development -- tsx src/cli.ts", + "controller:production": "dotenvx run -f ../../.env.production -- tsx src/lib/controller.ts", + "worker": "dotenvx run -f ../../.env.development -- tsx src/lib/worker.ts", + "worker:production": "dotenvx run -f ../../.env.production -- tsx src/lib/worker.ts", + "cli": "dotenvx run -f ../../.env.development -- tsx src/lib/cli.ts", "clean": "rimraf .next .turbo" }, "dependencies": { diff --git a/apps/roomote/src/cli.ts b/apps/roomote/src/lib/cli.ts similarity index 91% rename from apps/roomote/src/cli.ts rename to apps/roomote/src/lib/cli.ts index a64c70bfff..a9457efbcc 100644 --- a/apps/roomote/src/cli.ts +++ b/apps/roomote/src/lib/cli.ts @@ -21,12 +21,6 @@ import { import { runTask } from '@/lib/runTask'; import { Logger } from '@/lib/logger'; -const logger = new Logger({ - logDir: path.resolve(os.tmpdir(), 'logs'), - filename: 'cli.log', - tag: 'worker', -}); - const fixIssueCommand = command({ name: 'fix-issue', description: 'Fix a GitHub issue', @@ -76,10 +70,8 @@ const fixIssueCommand = command({ const result = await fixGitHubIssue(payload); - console.log('✅ Issue fix completed successfully!'); - console.log(`Repository: ${result.repo}`); - console.log(`Issue: #${result.issue}`); - console.log('Result:', result.result); + console.log('✅ Issue fix completed successfully!', result); + process.exit(0); } catch (error) { console.error('❌ Error fixing issue:', error); process.exit(1); @@ -149,9 +141,8 @@ const respondIssueCommentCommand = command({ }; const result = await processIssueComment(payload); - - console.log('✅ Issue comment response completed successfully!'); - console.log('Result:', result); + console.log('✅ Issue comment response completed successfully!', result); + process.exit(0); } catch (error) { console.error('❌ Error responding to issue comment:', error); process.exit(1); @@ -248,9 +239,8 @@ const respondPrCommentCommand = command({ }; const result = await processPullRequestComment(payload); - - console.log('✅ PR comment response completed successfully!'); - console.log('Result:', result); + console.log('✅ PR comment response completed successfully!', result); + process.exit(0); } catch (error) { console.error('❌ Error responding to PR comment:', error); process.exit(1); @@ -283,28 +273,34 @@ const promptCommand = command({ throw new Error('Invalid mode'); } - console.log(`${text} (${mode}) in ${workspacePath}`); - await runTask({ jobType: 'test.prompt', jobPayload: { text }, prompt: text, - logger, + logger: new Logger({ + logDir: path.resolve(os.tmpdir(), 'logs'), + filename: 'cli.log', + tag: 'worker', + }), notify: false, workspacePath, settings: { mode }, }); + + process.exit(0); }, }); +// Example: +// pnpm --filter @roo-code-cloud/roomote cli prompt --text "What time is it?" --mode ask --workspace-path ~/Documents/Roo-Code const app = subcommands({ name: 'roomote-cli', description: 'Roomote CLI - Run jobs directly from the command line', cmds: { - 'fix-issue': fixIssueCommand, - 'respond-issue-comment': respondIssueCommentCommand, - 'respond-pr-comment': respondPrCommentCommand, - prompt: promptCommand, + [fixIssueCommand.name]: fixIssueCommand, + [respondIssueCommentCommand.name]: respondIssueCommentCommand, + [respondPrCommentCommand.name]: respondPrCommentCommand, + [promptCommand.name]: promptCommand, }, }); diff --git a/apps/roomote/src/lib/runTask.ts b/apps/roomote/src/lib/runTask.ts index dd62ed2a72..252969c814 100644 --- a/apps/roomote/src/lib/runTask.ts +++ b/apps/roomote/src/lib/runTask.ts @@ -82,15 +82,6 @@ export const runTask = async ({ logger.info(codeCommand); - // Sleep for a random amount of time between 5 and 10 seconds, unless we're - // running in a container, in which case there are no issues with flooding - // VSCode with new windows. - if (!containerized) { - await new Promise((resolve) => - setTimeout(resolve, Math.random() * 5_000 + 5_000), - ); - } - const subprocess = execa({ env, shell: '/bin/bash', @@ -100,8 +91,6 @@ export const runTask = async ({ // If debugging, add `--verbose` to `command` and uncomment the following line. // subprocess.stdout.pipe(process.stdout) - // Give VSCode some time to spawn before connecting to its unix socket. - await new Promise((resolve) => setTimeout(resolve, 3_000)); let client: IpcClient | undefined = undefined; let attempts = 5; @@ -219,10 +208,10 @@ export const runTask = async ({ configuration: { ...EVALS_SETTINGS, openRouterApiKey: process.env.OPENROUTER_API_KEY, + lastShownAnnouncementId: 'jun-17-2025-3-21', ...settings, }, text: prompt, - newTab: true, }, }); diff --git a/packages/env/src/index.ts b/packages/env/src/index.ts index aed7d74a9d..a0f4113bbb 100644 --- a/packages/env/src/index.ts +++ b/packages/env/src/index.ts @@ -15,7 +15,7 @@ export const Env = createEnv({ client: {}, // You need to destructure all the keys manually. runtimeEnv: { - NODE_ENV: process.env.NODE_ENV, + NODE_ENV: process.env.NODE_ENV || 'development', DATABASE_URL: process.env.DATABASE_URL, REDIS_URL: process.env.REDIS_URL, CLICKHOUSE_URL: process.env.CLICKHOUSE_URL,