@@ -781,6 +781,81 @@ test("guardrail profile plugin records lifecycle events and compaction context",
781781 } )
782782} )
783783
784+ test ( "team plugin skips parallel enforcement on HEAD-less repos" , async ( ) => {
785+ await withProfile ( async ( ) => {
786+ await using tmp = await tmpdir ( {
787+ git : false ,
788+ init : async ( dir ) => {
789+ const $ = Bun . $
790+ await $ `git init` . cwd ( dir ) . quiet ( )
791+ await $ `git config core.fsmonitor false` . cwd ( dir ) . quiet ( )
792+ await $ `git config user.email "[email protected] "` . cwd ( dir ) . quiet ( ) 793+ await $ `git config user.name "Test"` . cwd ( dir ) . quiet ( )
794+ // Intentionally NO initial commit — HEAD does not exist
795+ } ,
796+ } )
797+
798+ await Instance . provide ( {
799+ directory : tmp . path ,
800+ fn : async ( ) => {
801+ const bigRequest =
802+ "Implement the following multi-file refactoring across packages/a, packages/b, and packages/c:\n" +
803+ "- 1. Extract shared types into a common module\n" +
804+ "- 2. Update all imports across the three packages\n" +
805+ "- 3. Add barrel exports for the new module\n" +
806+ "- 4. Fix downstream consumers\n" +
807+ "This is a large plan that touches multiple packages."
808+
809+ const parts : { id ?: string ; sessionID ?: string ; messageID ?: string ; type ?: string ; text ?: string } [ ] = [
810+ { type : "text" , text : bigRequest } ,
811+ ]
812+
813+ await Plugin . trigger (
814+ "chat.message" ,
815+ {
816+ sessionID : "session_headless" ,
817+ agent : "implement" ,
818+ } ,
819+ {
820+ message : {
821+ id : "msg_headless" ,
822+ sessionID : "session_headless" ,
823+ role : "user" ,
824+ } ,
825+ parts,
826+ } ,
827+ )
828+
829+ const injected = parts . find (
830+ ( item ) => item . type === "text" && typeof item . text === "string" && item . text . includes ( "Bootstrap mode" ) ,
831+ )
832+ expect ( injected ) . toBeDefined ( )
833+ expect ( injected ! . text ) . toContain ( "Parallel implementation policy is suspended" )
834+
835+ const parallelInjected = parts . find (
836+ ( item ) => item . type === "text" && typeof item . text === "string" && item . text . includes ( "Parallel implementation policy is active" ) ,
837+ )
838+ expect ( parallelInjected ) . toBeUndefined ( )
839+
840+ // Mutations should NOT be blocked — no need gate was set
841+ await expect (
842+ Plugin . trigger (
843+ "tool.execute.before" ,
844+ { tool : "edit" , sessionID : "session_headless" , callID : "call_headless_edit" } ,
845+ {
846+ args : {
847+ filePath : path . join ( tmp . path , "src" , "index.ts" ) ,
848+ oldString : "const a = 1" ,
849+ newString : "const a = 2" ,
850+ } ,
851+ } ,
852+ ) ,
853+ ) . resolves . toBeDefined ( )
854+ } ,
855+ } )
856+ } )
857+ } )
858+
784859for ( const replay of Object . values ( replays ) ) {
785860 it . live ( `guardrail replay keeps ${ replay . command } executable` , ( ) =>
786861 run ( replay ) . pipe (
0 commit comments