@@ -362,10 +362,17 @@ test("replaces compaction summaries and renders Claude bash transcript tags", as
362362 const tmp = makeTempDir ( ) ;
363363 const fakeKey = `jieli_${ "a" . repeat ( 30 ) } ` ;
364364 const prose = "我用 `!rm -rf x` 执行了:<bash-input>rm -rf x</bash-input><bash-stdout>(Bash completed with no output)</bash-stdout> 你看下" ;
365+ const unflaggedCompactSummary =
366+ "This session is being continued from a previous conversation that ran out of context. " +
367+ "The conversation is summarized below:\n\n" +
368+ "Current progress:\n\n" +
369+ "- Repo: `/Users/alice/work/jieli`.\n" +
370+ "- This Claude compacted implementation detail should not be uploaded.\n" . repeat ( 20 ) ;
365371 const transcript = join ( tmp , "session.jsonl" ) ;
366372 writeJsonl ( transcript , [
367373 { type : "user" , uuid : "u-real" , sessionId : "cc-bash" , cwd : "/Users/alice/work/jieli" , message : { role : "user" , content : "原始第一条消息" } } ,
368374 { type : "user" , uuid : "u-compact" , sessionId : "cc-bash" , isCompactSummary : true , isVisibleInTranscriptOnly : true , message : { role : "user" , content : "This session is being continued. " + "x" . repeat ( 5000 ) } } ,
375+ { type : "user" , uuid : "u-compact-text" , sessionId : "cc-bash" , message : { role : "user" , content : unflaggedCompactSummary } } ,
369376 { type : "user" , uuid : "u-bash-in" , sessionId : "cc-bash" , cwd : "/Users/alice/work/jieli" , message : { role : "user" , content : "<bash-input>echo $JIELI_API_KEY</bash-input>" } } ,
370377 { type : "user" , uuid : "u-bash-out" , sessionId : "cc-bash" , message : { role : "user" , content : `<bash-stdout>${ fakeKey } </bash-stdout><bash-stderr></bash-stderr>` } } ,
371378 { type : "user" , uuid : "u-rm" , sessionId : "cc-bash" , message : { role : "user" , content : "<bash-input>rm -rf /tmp/x</bash-input><bash-stdout>(Bash completed with no output)</bash-stdout><bash-stderr></bash-stderr>" } } ,
@@ -375,12 +382,15 @@ test("replaces compaction summaries and renders Claude bash transcript tags", as
375382 const payload = await runtime . buildPayloadFromHook ( { session_id : "cc-bash" , transcript_path : transcript } , "https://jieli.example.test" ) ;
376383 assert . equal ( payload . thread . title , "原始第一条消息" ) ;
377384 assert . equal ( payload . thread . messages [ 1 ] . content , runtime . COMPACTION_PLACEHOLDER ) ;
378- assert . equal ( payload . thread . messages [ 2 ] . content , "```console\n$ echo $JIELI_API_KEY\n[REDACTED:jieli-api-key]\n```" ) ;
379- assert . equal ( payload . thread . messages [ 3 ] . content , "```console\n$ rm -rf /tmp/x\n# (no output)\n```" ) ;
380- assert . equal ( payload . thread . messages [ 4 ] . content , prose ) ;
385+ assert . equal ( payload . thread . messages [ 2 ] . content , runtime . COMPACTION_PLACEHOLDER ) ;
386+ assert . equal ( runtime . COMPACTION_PLACEHOLDER , "[Context automatically compacted]" ) ;
387+ assert . equal ( payload . thread . messages [ 3 ] . content , "```console\n$ echo $JIELI_API_KEY\n[REDACTED:jieli-api-key]\n```" ) ;
388+ assert . equal ( payload . thread . messages [ 4 ] . content , "```console\n$ rm -rf /tmp/x\n# (no output)\n```" ) ;
389+ assert . equal ( payload . thread . messages [ 5 ] . content , prose ) ;
381390 const raw = JSON . stringify ( payload ) ;
382391 assert . doesNotMatch ( raw , new RegExp ( fakeKey ) ) ;
383392 assert . doesNotMatch ( raw , / x { 5000 } / ) ;
393+ assert . doesNotMatch ( raw , / C l a u d e c o m p a c t e d i m p l e m e n t a t i o n d e t a i l / ) ;
384394} ) ;
385395
386396test ( "configuration, upload, lock, and transcript flush helpers match hook behavior" , async ( ) => {
@@ -554,9 +564,22 @@ test("handoff info and commit trailer helpers inject Node-based context and trai
554564
555565 const handoff = runtime . buildHookResponse ( { session_id : "cc-handoff" , transcript_path : "/tmp/claude-session.jsonl" , cwd : "/repo" , tool_name : "Bash" , tool_input : { command : "jieli-handoff-info" } } ) ;
556566 const handoffCommand = handoff . hookSpecificOutput . updatedInput . command ;
557- assert . match ( handoffCommand , / J I E L I _ H A N D O F F _ C O N T E X T _ B 6 4 = / ) ;
558- assert . match ( handoffCommand , / n o d e .* j i e l i _ n o d e \. m j s h a n d o f f - i n f o / ) ;
567+ assert . doesNotMatch ( handoffCommand , / J I E L I _ H A N D O F F _ C O N T E X T _ B 6 4 = / ) ;
568+ assert . match ( handoffCommand , / n o d e .* j i e l i _ n o d e \. m j s h a n d o f f - i n f o - - c o n t e x t - b 6 4 / ) ;
559569 assert . deepEqual ( decodeHandoffContext ( handoffCommand ) , { session_id : "cc-handoff" , transcript_path : "/tmp/claude-session.jsonl" , cwd : "/repo" } ) ;
570+ for ( const command of [
571+ "jieli-handoff-info.cmd" ,
572+ "jieli-handoff-info.exe" ,
573+ "C:\\Users\\Administrator\\.claude\\plugins\\cache\\jieliapp\\claude-code\\bin\\jieli-handoff-info.cmd" ,
574+ "& 'C:\\Users\\Administrator\\.claude\\plugins\\cache\\jieliapp\\claude-code\\bin\\jieli-handoff-info.cmd'" ,
575+ ] ) {
576+ const response = runtime . buildHookResponse ( { session_id : "cc-win" , transcript_path : "C:\\Users\\Administrator\\.claude\\projects\\session.jsonl" , cwd : "C:\\repo" , tool_name : "Bash" , tool_input : { command } } ) ;
577+ const updated = response . hookSpecificOutput . updatedInput . command ;
578+ assert . match ( updated , / h a n d o f f - i n f o - - c o n t e x t - b 6 4 / ) ;
579+ assert . deepEqual ( decodeHandoffContext ( updated ) , { session_id : "cc-win" , transcript_path : "C:\\Users\\Administrator\\.claude\\projects\\session.jsonl" , cwd : "C:\\repo" } ) ;
580+ }
581+ const cliInfo = await withEnv ( { JIELI_HANDOFF_CONTEXT_B64 : undefined , JIELI_BASE_URL : "https://jieli.example.test" } , ( ) => runtime . buildHandoffInfo ( process . env , encoded ) ) ;
582+ assert . equal ( cliInfo . thread_id , "T-cc-1" ) ;
560583 assert . deepEqual ( runtime . buildHookResponse ( { session_id : "cc-handoff" , tool_name : "Bash" , tool_input : { command : "jieli-handoff-info | cat" } } ) , { } ) ;
561584
562585 await withEnv ( { HOME : tmp } , async ( ) => {
0 commit comments