@@ -11,10 +11,6 @@ import {
1111} from "./assistant.js" ;
1212import type { CrestodianOverview } from "./overview.js" ;
1313
14- function hasDanglingSurrogate ( value : string ) : boolean {
15- return / [ \uD800 - \uDBFF ] (? ! [ \uDC00 - \uDFFF ] ) | (?< ! [ \uD800 - \uDBFF ] ) [ \uDC00 - \uDFFF ] / u. test ( value ) ;
16- }
17-
1814function overview ( overrides : Partial < CrestodianOverview [ "tools" ] > = { } ) : CrestodianOverview {
1915 return {
2016 config : {
@@ -138,40 +134,6 @@ describe("Crestodian assistant", () => {
138134 ) ;
139135 } ) ;
140136
141- it ( "raw slice would leave a lone high surrogate at the emoji boundary" , ( ) => {
142- const prefix = "a" . repeat ( 499 ) ;
143- const text = `${ prefix } 🎉tail` ;
144- // Prove the bug on main: raw slice(0, 500) splits the surrogate pair,
145- // leaving a lone high surrogate (0xD83C) at position 499.
146- const rawSlice = text . slice ( 0 , 500 ) ;
147- expect ( hasDanglingSurrogate ( rawSlice ) ) . toBe ( true ) ;
148- expect ( rawSlice . charCodeAt ( rawSlice . length - 1 ) ) . toBeGreaterThanOrEqual ( 0xd800 ) ;
149- expect ( rawSlice . charCodeAt ( rawSlice . length - 1 ) ) . toBeLessThanOrEqual ( 0xdbff ) ;
150- } ) ;
151-
152- it ( "truncateUtf16Safe produces no dangling surrogates in the prompt output" , ( ) => {
153- const prefix = "a" . repeat ( 499 ) ;
154- const prompt = buildCrestodianAssistantUserPrompt ( {
155- input : "continue" ,
156- overview : overview ( ) ,
157- history : [ { role : "user" , text : `${ prefix } 🎉tail` } ] ,
158- } ) ;
159- expect ( hasDanglingSurrogate ( prompt ) ) . toBe ( false ) ;
160- } ) ;
161-
162- it ( "multi-emoji boundary: raw slice splits but truncateUtf16Safe does not" , ( ) => {
163- const prefix = "a" . repeat ( 499 ) ;
164- const text = `${ prefix } 🎉🦀🐚tail` ;
165- const rawSlice = text . slice ( 0 , 500 ) ;
166- expect ( hasDanglingSurrogate ( rawSlice ) ) . toBe ( true ) ;
167- const prompt = buildCrestodianAssistantUserPrompt ( {
168- input : "continue" ,
169- overview : overview ( ) ,
170- history : [ { role : "user" , text } ] ,
171- } ) ;
172- expect ( hasDanglingSurrogate ( prompt ) ) . toBe ( false ) ;
173- } ) ;
174-
175137 it ( "uses Claude CLI first for configless planning" , async ( ) => {
176138 const runCliAgent = vi . fn (
177139 async ( _params : RunCliAgentParams ) : Promise < EmbeddedAgentRunResult > => ( {
0 commit comments