@@ -6,6 +6,7 @@ import * as vscode from "vscode"
66import type { RooCodeAPI } from "@roo-code/types"
77
88import { waitFor } from "./utils"
9+ import * as fs from "fs"
910
1011export async function run ( ) {
1112 const extension = vscode . extensions . getExtension < RooCodeAPI > ( "RooVeterinaryInc.roo-cline" )
@@ -16,6 +17,30 @@ export async function run() {
1617
1718 const api = extension . isActive ? extension . exports : await extension . activate ( )
1819
20+ // Ensure OPENROUTER_API_KEY is loaded from .env.local in CI (written by workflow)
21+ // __dirname at runtime is apps/vscode-e2e/out/suite, so go up two levels
22+ const envPath = path . resolve ( __dirname , ".." , ".." , ".env.local" )
23+ if ( ! process . env . OPENROUTER_API_KEY && fs . existsSync ( envPath ) ) {
24+ try {
25+ const content = fs . readFileSync ( envPath , "utf8" )
26+ for ( const rawLine of content . split ( "\n" ) ) {
27+ const line = rawLine . trim ( )
28+ if ( ! line || line . startsWith ( "#" ) ) continue
29+ const match = line . match ( / ^ \s * ( [ A - Z a - z _ ] [ A - Z a - z 0 - 9 _ ] * ) \s * = \s * ( .* ) \s * $ / )
30+ if ( ! match ) continue
31+ const key = match [ 1 ]
32+ let val = match [ 2 ]
33+ // Strip surrounding quotes if present
34+ if ( ( val . startsWith ( '"' ) && val . endsWith ( '"' ) ) || ( val . startsWith ( "'" ) && val . endsWith ( "'" ) ) ) {
35+ val = val . slice ( 1 , - 1 )
36+ }
37+ if ( ! process . env [ key ] ) process . env [ key ] = val
38+ }
39+ } catch {
40+ // ignore env load errors; tests may still pass without API calls
41+ }
42+ }
43+
1944 await api . setConfiguration ( {
2045 apiProvider : "openrouter" as const ,
2146 openRouterApiKey : process . env . OPENROUTER_API_KEY ! ,
0 commit comments