11import { describe , it , expect } from "vitest" ;
22import {
3+ isInternalFormattingArtifact ,
34 isSilentReplyPrefixText ,
45 isSilentReplyPayloadText ,
56 isSilentReplyText ,
@@ -8,6 +9,70 @@ import {
89 stripSilentToken ,
910} from "./tokens.js" ;
1011
12+ describe ( "isInternalFormattingArtifact" , ( ) => {
13+ it ( "matches <channel|> markers (#88128)" , ( ) => {
14+ expect ( isInternalFormattingArtifact ( "<channel|>" ) ) . toBe ( true ) ;
15+ expect ( isInternalFormattingArtifact ( " <channel|> " ) ) . toBe ( true ) ;
16+ expect ( isInternalFormattingArtifact ( "\n<channel|>\n" ) ) . toBe ( true ) ;
17+ } ) ;
18+
19+ it ( "matches set-thought directives with channel markers (#88128)" , ( ) => {
20+ expect ( isInternalFormattingArtifact ( "set-thought <channel|>" ) ) . toBe ( true ) ;
21+ expect ( isInternalFormattingArtifact ( " set-thought <channel|> " ) ) . toBe ( true ) ;
22+ } ) ;
23+
24+ it ( "matches em-dash / horizontal-rule separators (#88128)" , ( ) => {
25+ expect ( isInternalFormattingArtifact ( "───" ) ) . toBe ( true ) ;
26+ expect ( isInternalFormattingArtifact ( "---" ) ) . toBe ( true ) ;
27+ expect ( isInternalFormattingArtifact ( "___" ) ) . toBe ( true ) ;
28+ expect ( isInternalFormattingArtifact ( "***" ) ) . toBe ( true ) ;
29+ expect ( isInternalFormattingArtifact ( "****" ) ) . toBe ( true ) ;
30+ expect ( isInternalFormattingArtifact ( " ─── " ) ) . toBe ( true ) ;
31+ } ) ;
32+
33+ it ( "matches lone XML-like tags" , ( ) => {
34+ expect ( isInternalFormattingArtifact ( "<tag>" ) ) . toBe ( true ) ;
35+ expect ( isInternalFormattingArtifact ( "</tag>" ) ) . toBe ( true ) ;
36+ expect ( isInternalFormattingArtifact ( "<br/>" ) ) . toBe ( true ) ;
37+ } ) ;
38+
39+ it ( "matches <word|value> channel-style markup" , ( ) => {
40+ expect ( isInternalFormattingArtifact ( "<channel|answer>" ) ) . toBe ( true ) ;
41+ expect ( isInternalFormattingArtifact ( "<lane|reasoning>" ) ) . toBe ( true ) ;
42+ } ) ;
43+
44+ it ( "returns false for undefined/empty" , ( ) => {
45+ expect ( isInternalFormattingArtifact ( undefined ) ) . toBe ( false ) ;
46+ expect ( isInternalFormattingArtifact ( "" ) ) . toBe ( false ) ;
47+ } ) ;
48+
49+ it ( "returns false for normal user-facing text" , ( ) => {
50+ expect ( isInternalFormattingArtifact ( "Hello! How can I help?" ) ) . toBe ( false ) ;
51+ expect ( isInternalFormattingArtifact ( "The answer is 42." ) ) . toBe ( false ) ;
52+ expect ( isInternalFormattingArtifact ( "Here's your code:" ) ) . toBe ( false ) ;
53+ } ) ;
54+
55+ it ( "returns false for text that merely contains an artifact pattern" , ( ) => {
56+ // Real answer text that happens to include a dash separator or tag-like content
57+ // must not be suppressed.
58+ expect (
59+ isInternalFormattingArtifact (
60+ "Here are the options:\n───\n1. Option A\n2. Option B" ,
61+ ) ,
62+ ) . toBe ( false ) ;
63+ expect ( isInternalFormattingArtifact ( "See <https://example.com> for details." ) ) . toBe ( false ) ;
64+ expect (
65+ isInternalFormattingArtifact ( "Use <channel|> syntax in your config." ) ,
66+ ) . toBe ( false ) ;
67+ } ) ;
68+
69+ it ( "returns false for code blocks and markdown with substance" , ( ) => {
70+ expect ( isInternalFormattingArtifact ( "```js\nconsole.log('hi')\n```" ) ) . toBe ( false ) ;
71+ expect ( isInternalFormattingArtifact ( "**bold** and *italic* text" ) ) . toBe ( false ) ;
72+ expect ( isInternalFormattingArtifact ( "# Heading" ) ) . toBe ( false ) ;
73+ } ) ;
74+ } ) ;
75+
1176describe ( "isSilentReplyText" , ( ) => {
1277 it ( "returns true for exact token" , ( ) => {
1378 expect ( isSilentReplyText ( "NO_REPLY" ) ) . toBe ( true ) ;
0 commit comments