@@ -2151,7 +2151,22 @@ it.layer(
21512151 {
21522152 name : "oversized first line" ,
21532153 stderr : ` Error: claude native binary not installed. ${ "x" . repeat ( 10_000 ) } \nsecond line` ,
2154- firstLine : undefined ,
2154+ firstLine : `Error: claude native binary not installed. ${ "x" . repeat ( 468 ) } …` ,
2155+ } ,
2156+ {
2157+ name : "ANSI color and repeated whitespace" ,
2158+ stderr : "\u001b[31m Error: claude\t native binary not installed. \u001b[0m\nsecond line" ,
2159+ firstLine : "Error: claude native binary not installed." ,
2160+ } ,
2161+ {
2162+ name : "leading blank lines" ,
2163+ stderr : "\n \t\r\n\u001b[0m\n Error: claude native binary not installed.\nsecond line" ,
2164+ firstLine : "Error: claude native binary not installed." ,
2165+ } ,
2166+ {
2167+ name : "exactly 512 characters" ,
2168+ stderr : `Error: claude native binary not installed. ${ "x" . repeat ( 469 ) } ` ,
2169+ firstLine : `Error: claude native binary not installed. ${ "x" . repeat ( 469 ) } ` ,
21552170 } ,
21562171 ] ) ( "includes a trimmed, capped version failure detail: $name" , ( { stderr, firstLine } ) =>
21572172 Effect . gen ( function * ( ) {
@@ -2169,10 +2184,11 @@ it.layer(
21692184 assert . notInclude ( message , "\n" ) ;
21702185 assert . notInclude ( message , "Run claude install" ) ;
21712186 assert . notInclude ( message , "second line" ) ;
2172- if ( firstLine ) {
2173- assert . isTrue ( message . endsWith ( firstLine ) ) ;
2174- } else {
2175- assert . isBelow ( message . length , 1_024 ) ;
2187+ const summary = "Claude Agent CLI is installed but failed to run. " ;
2188+ assert . strictEqual ( message , `${ summary } ${ firstLine } ` ) ;
2189+ assert . isAtMost ( firstLine . length , 512 ) ;
2190+ if ( stderr . length > 512 ) {
2191+ assert . strictEqual ( firstLine . length , 512 ) ;
21762192 }
21772193 } ) . pipe (
21782194 Effect . provide (
@@ -2214,22 +2230,24 @@ it.layer(
22142230 ) ;
22152231 } ) ;
22162232
2217- it . effect ( "keeps the generic version failure message when stderr is empty" , ( ) =>
2218- Effect . gen ( function * ( ) {
2219- const status = yield * checkClaudeProviderStatus (
2220- defaultClaudeSettings ,
2221- claudeCapabilities ( ) ,
2222- ) ;
2223- assert . strictEqual ( status . status , "error" ) ;
2224- assert . strictEqual ( status . message , "Claude Agent CLI is installed but failed to run." ) ;
2225- } ) . pipe (
2226- Effect . provide (
2227- layerMockSpawner ( ( args ) => {
2228- assert . deepStrictEqual ( args , [ "--version" ] ) ;
2229- return { stdout : "" , stderr : "" , code : 1 } ;
2230- } ) ,
2233+ it . effect . each ( [ "" , " \t\n \r\n\u001b[0m " ] ) (
2234+ "keeps the generic version failure message when stderr has no meaningful line: %j" ,
2235+ ( stderr ) =>
2236+ Effect . gen ( function * ( ) {
2237+ const status = yield * checkClaudeProviderStatus (
2238+ defaultClaudeSettings ,
2239+ claudeCapabilities ( ) ,
2240+ ) ;
2241+ assert . strictEqual ( status . status , "error" ) ;
2242+ assert . strictEqual ( status . message , "Claude Agent CLI is installed but failed to run." ) ;
2243+ } ) . pipe (
2244+ Effect . provide (
2245+ layerMockSpawner ( ( args ) => {
2246+ assert . deepStrictEqual ( args , [ "--version" ] ) ;
2247+ return { stdout : "" , stderr, code : 1 } ;
2248+ } ) ,
2249+ ) ,
22312250 ) ,
2232- ) ,
22332251 ) ;
22342252
22352253 it . effect ( "reports a logged-out CLI as unauthenticated" , ( ) =>
0 commit comments