@@ -251,19 +251,20 @@ async function runTests() {
251251 assert . ok ( result . stderr . includes ( '[PreCompact]' ) , 'Should output to stderr with prefix' ) ;
252252 } ) ) passed ++ ; else failed ++ ;
253253
254- if ( await asyncTest ( 'blocking hooks output BLOCKED message ' , async ( ) => {
255- // Test the dev server blocking hook — must send a matching command
256- const blockingCommand = hooks . hooks . PreToolUse [ 0 ] . hooks [ 0 ] . command ;
257- const result = await runHookCommand ( blockingCommand , {
254+ if ( await asyncTest ( 'dev server hook transforms command to tmux session ' , async ( ) => {
255+ // Test the auto-tmux dev hook — transforms dev commands to run in tmux
256+ const hookCommand = hooks . hooks . PreToolUse [ 0 ] . hooks [ 0 ] . command ;
257+ const result = await runHookCommand ( hookCommand , {
258258 tool_input : { command : 'npm run dev' }
259259 } ) ;
260260
261- // Hook only blocks on non-Windows platforms (tmux is Unix-only)
262- if ( process . platform === 'win32' ) {
263- assert . strictEqual ( result . code , 0 , 'On Windows, hook should not block (exit 0)' ) ;
264- } else {
265- assert . ok ( result . stderr . includes ( 'BLOCKED' ) , 'Blocking hook should output BLOCKED' ) ;
266- assert . strictEqual ( result . code , 2 , 'Blocking hook should exit with code 2' ) ;
261+ assert . strictEqual ( result . code , 0 , 'Hook should exit 0 (transforms, does not block)' ) ;
262+ // On Unix with tmux, stdout contains transformed JSON with tmux command
263+ // On Windows or without tmux, stdout contains original JSON passthrough
264+ const output = result . stdout . trim ( ) ;
265+ if ( output ) {
266+ const parsed = JSON . parse ( output ) ;
267+ assert . ok ( parsed . tool_input , 'Should output valid JSON with tool_input' ) ;
267268 }
268269 } ) ) passed ++ ; else failed ++ ;
269270
@@ -277,18 +278,20 @@ async function runTests() {
277278 assert . strictEqual ( result . code , 0 , 'Non-blocking hook should exit 0' ) ;
278279 } ) ) passed ++ ; else failed ++ ;
279280
280- if ( await asyncTest ( 'blocking hooks exit with code 2 ' , async ( ) => {
281- // The dev server blocker blocks when a dev server command is detected
282- const blockingCommand = hooks . hooks . PreToolUse [ 0 ] . hooks [ 0 ] . command ;
283- const result = await runHookCommand ( blockingCommand , {
281+ if ( await asyncTest ( 'dev server hook transforms yarn dev to tmux session ' , async ( ) => {
282+ // The auto-tmux dev hook transforms dev commands (yarn dev, npm run dev, etc.)
283+ const hookCommand = hooks . hooks . PreToolUse [ 0 ] . hooks [ 0 ] . command ;
284+ const result = await runHookCommand ( hookCommand , {
284285 tool_input : { command : 'yarn dev' }
285286 } ) ;
286287
287- // Hook only blocks on non-Windows platforms (tmux is Unix-only)
288- if ( process . platform === 'win32' ) {
289- assert . strictEqual ( result . code , 0 , 'On Windows, hook should not block (exit 0)' ) ;
290- } else {
291- assert . strictEqual ( result . code , 2 , 'Blocking hook should exit 2' ) ;
288+ // Hook always exits 0 — it transforms, never blocks
289+ assert . strictEqual ( result . code , 0 , 'Hook should exit 0 (transforms, does not block)' ) ;
290+ const output = result . stdout . trim ( ) ;
291+ if ( output ) {
292+ const parsed = JSON . parse ( output ) ;
293+ assert . ok ( parsed . tool_input , 'Should output valid JSON with tool_input' ) ;
294+ assert . ok ( parsed . tool_input . command , 'Should have a command in output' ) ;
292295 }
293296 } ) ) passed ++ ; else failed ++ ;
294297
0 commit comments