@@ -1056,12 +1056,21 @@ describe("geminiProvider.buildArgs", () => {
10561056 expect ( args [ promptIdx + 1 ] ) . toBe ( "You are a helpful assistant." ) ;
10571057 } ) ;
10581058
1059- it ( "uses empty string as prompt when systemPromptFile cannot be read" , ( ) => {
1059+ it ( "combines system prompt content and task context in --prompt" , async ( ) => {
1060+ const fsModule = await import ( "node:fs" ) ;
1061+ vi . mocked ( fsModule . readFileSync ) . mockReturnValueOnce ( "You are a helpful assistant." as any ) ;
1062+ const args = geminiBuildArgs ( { sessionId : "s1" , cwd : "/" , env : { } , taskContext : "Do the task." , systemPromptFile : "/tmp/system.txt" } ) ;
1063+ const promptIdx = args . indexOf ( "--prompt" ) ;
1064+
1065+ expect ( args [ promptIdx + 1 ] ) . toBe ( "You are a helpful assistant.\n\nDo the task." ) ;
1066+ } ) ;
1067+
1068+ it ( "uses task context as prompt when systemPromptFile cannot be read" , ( ) => {
10601069 // readFileSync is already mocked to throw by default
1061- const args = geminiBuildArgs ( { sessionId : "s1" , cwd : "/" , env : { } , taskContext : "" , systemPromptFile : "/nonexistent/file.txt" } ) ;
1070+ const args = geminiBuildArgs ( { sessionId : "s1" , cwd : "/" , env : { } , taskContext : "Do the task. " , systemPromptFile : "/nonexistent/file.txt" } ) ;
10621071 const promptIdx = args . indexOf ( "--prompt" ) ;
10631072 expect ( promptIdx ) . toBeGreaterThan ( - 1 ) ;
1064- expect ( args [ promptIdx + 1 ] ) . toBe ( "" ) ;
1073+ expect ( args [ promptIdx + 1 ] ) . toBe ( "Do the task. " ) ;
10651074 } ) ;
10661075} ) ;
10671076
@@ -1093,6 +1102,13 @@ describe("geminiProvider.buildResumeArgs", () => {
10931102 expect ( args [ idx + 1 ] ) . toBe ( "latest" ) ;
10941103 } ) ;
10951104
1105+ it ( "uses task context as resume prompt" , ( ) => {
1106+ const args = geminiBuildResumeArgs ( undefined , "Address review feedback." ) ;
1107+ const idx = args . indexOf ( "--prompt" ) ;
1108+
1109+ expect ( args [ idx + 1 ] ) . toBe ( "Address review feedback." ) ;
1110+ } ) ;
1111+
10961112 it ( "includes --model when model is provided" , ( ) => {
10971113 const args = geminiBuildResumeArgs ( "gemini-2.5-pro" ) ;
10981114 const idx = args . indexOf ( "--model" ) ;
@@ -1298,13 +1314,11 @@ describe("geminiProvider.parseEvent — error variants", () => {
12981314} ) ;
12991315
13001316// ---------------------------------------------------------------------------
1301- // geminiProvider.buildInput — Gemini passes context directly as input
1317+ // geminiProvider.buildInput — Gemini passes context through --prompt
13021318// ---------------------------------------------------------------------------
13031319
13041320describe ( "geminiProvider.buildInput" , ( ) => {
1305- it ( "execute passes task context directly as input (not wrapped)" , ( ) => {
1306- // Gemini's input is the raw taskContext string — verified by the buildArgs/execute design.
1307- // We verify this by confirming buildArgs does not add a JSON wrapper flag.
1321+ it ( "does not add stdin input flags" , ( ) => {
13081322 const args = geminiBuildArgs ( { sessionId : "s1" , cwd : "/" , env : { } , taskContext : "do the task" } ) ;
13091323 expect ( args ) . not . toContain ( "--input-format" ) ;
13101324 } ) ;
@@ -1339,11 +1353,12 @@ describe("geminiProvider.execute — arg selection", () => {
13391353 expect ( spawnAgent ) . toHaveBeenCalled ( ) ;
13401354 } ) ;
13411355
1342- it ( "passes taskContext as input to spawnAgent " , async ( ) => {
1356+ it ( "passes taskContext through --prompt instead of stdin " , async ( ) => {
13431357 const { spawnAgent } = await import ( "../src/providers/spawnHelper.js" ) ;
13441358 vi . mocked ( spawnAgent ) . mockClear ( ) ;
13451359 await geminiProvider . execute ( { sessionId : "s1" , cwd : "/tmp" , env : { } , taskContext : "my task context" } ) ;
1346- expect ( vi . mocked ( spawnAgent ) ) . toHaveBeenCalledWith ( expect . objectContaining ( { input : "my task context" } ) ) ;
1360+ expect ( vi . mocked ( spawnAgent ) ) . toHaveBeenCalledWith ( expect . not . objectContaining ( { input : expect . any ( String ) } ) ) ;
1361+ expect ( vi . mocked ( spawnAgent ) . mock . calls [ 0 ] [ 0 ] . args ) . toContain ( "my task context" ) ;
13471362 } ) ;
13481363
13491364 it ( "uses buildResumeArgs when resume is true" , async ( ) => {
0 commit comments