1+ // Broad helper coverage for runEmbeddedAttempt prompt, stream, and tool seams.
12import { describe , expect , it , vi } from "vitest" ;
23import { streamSimple } from "../../../llm/stream.js" ;
34
@@ -47,6 +48,8 @@ function createFakeStream(params: {
4748 events : unknown [ ] ;
4849 resultMessage : unknown ;
4950} ) : FakeWrappedStream {
51+ // Minimal stream compatible with wrappers that decorate result and iteration
52+ // without needing a real provider stream.
5053 return {
5154 async result ( ) {
5255 return params . resultMessage ;
@@ -67,6 +70,7 @@ async function invokeWrappedTestStream(
6770 ) => ( ...args : never [ ] ) => FakeWrappedStream | Promise < FakeWrappedStream > ,
6871 baseFn : ( ...args : never [ ] ) => unknown ,
6972) : Promise < FakeWrappedStream > {
73+ // Helper keeps wrapper tests focused on mutated stream behavior.
7074 const wrappedFn = wrap ( baseFn ) ;
7175 return await Promise . resolve ( wrappedFn ( { } as never , { } as never , { } as never ) ) ;
7276}
@@ -101,6 +105,7 @@ function expectSingleToolCallContent(content: unknown[], name: string) {
101105}
102106
103107function firstBaseContext ( baseFn : ReturnType < typeof vi . fn > ) : { messages : unknown [ ] } {
108+ // Wrapper tests assert the context passed to the underlying stream function.
104109 const call = baseFn . mock . calls . at ( 0 ) ;
105110 if ( ! call ) {
106111 throw new Error ( "expected base stream call" ) ;
@@ -178,6 +183,8 @@ describe("resolvePromptBuildHookResult", () => {
178183 } ) ;
179184
180185 it ( "merges prompt-build and before_agent_start context fields in deterministic order" , async ( ) => {
186+ // Prompt-build hook context comes before before_agent_start context so plugin
187+ // injections are replayed in stable order.
181188 const hookRunner = {
182189 hasHooks : vi . fn ( ( ) => true ) ,
183190 runBeforePromptBuild : vi . fn ( async ( ) => ( {
0 commit comments