@@ -113,9 +113,10 @@ vaults:
113113 return configPath ;
114114}
115115
116- async function runAgents ( args : string [ ] , env : Record < string , string > = { } ) {
117- const proc = Bun . spawn ( [ process . execPath , "run" , "bin/agents.ts" , ...args ] , {
118- cwd : REPO_ROOT ,
116+ async function runAgents ( args : string [ ] , env : Record < string , string > = { } , cwd = REPO_ROOT ) {
117+ const entry = cwd === REPO_ROOT ? "bin/agents.ts" : join ( REPO_ROOT , "bin/agents.ts" ) ;
118+ const proc = Bun . spawn ( [ process . execPath , "run" , entry , ...args ] , {
119+ cwd,
119120 stdout : "pipe" ,
120121 stderr : "pipe" ,
121122 env : {
@@ -430,6 +431,33 @@ test("validate reports reference errors through the core runtime", async () => {
430431 expect ( result . stderr ) . toContain ( "references unknown environment 'ghost'" ) ;
431432} ) ;
432433
434+ test ( "validate loads .env before resolving provider placeholders" , async ( ) => {
435+ const dir = await makeTempDir ( ) ;
436+ await Bun . write (
437+ join ( dir , "agents.yaml" ) ,
438+ `version: "1"
439+
440+ providers:
441+ qoder:
442+ api_key: \${QODER_PAT}
443+
444+ defaults:
445+ provider: qoder
446+
447+ agents:
448+ assistant:
449+ model: ultimate
450+ instructions: "You are helpful."
451+ ` ,
452+ ) ;
453+ await Bun . write ( join ( dir , ".env" ) , "QODER_PAT=test-token\n" ) ;
454+
455+ const result = await runAgents ( [ "validate" , "--file" , "agents.yaml" ] , { QODER_PAT : "" } , dir ) ;
456+
457+ expect ( result . exitCode ) . toBe ( 0 ) ;
458+ expect ( result . stderr ) . toContain ( "Configuration is valid" ) ;
459+ } ) ;
460+
433461test ( "models list keeps missing config guidance in the core runtime" , async ( ) => {
434462 const result = await runAgents ( [ "models" , "list" , "--file" , "/missing/agents.yaml" ] ) ;
435463
0 commit comments