char-slop/berry
multipurpose self-modifiable agentic harness
git clone https://git.t4t.associates/char-slop/berry
2c01ad9
main
1import { assertEquals } from "@std/assert" ; 2import type { PayloadHook } from "@berry/api" ; 3import { testExtension } from "@berry/api/testing.ts" ; 4import misc from "./mod.ts" ; 5 6type Model = Parameters < PayloadHook >[ 1 ]; 7const codex = { provider :"openai-codex" } as unknown as Model ; 8const other = { provider :"other" } as unknown as Model ; 9 10Deno . test ( "compact starts a manual compaction, guided by any arguments" , async () => { 11const ext = testExtension ( misc ); 12assertEquals ( await ext . command ( "compact" ), "Compacting context\u2026" ); 13assertEquals ( 14await ext . command ( "compact" , " keep the failing test names " ), 15"Compacting context\u2026" , 16); 17assertEquals ( ext . compactions , [ undefined , "keep the failing test names" ]); 18}); 19 20Deno . test ( "oai-fast toggles fast mode for codex payloads only" , async () => { 21const ext = testExtension ( misc ); 22assertEquals ( await ext . payload ({ a :1 }, codex ), { a :1 }); 23assertEquals ( await ext . command ( "oai-fast" , "" ), "OpenAI Codex fast mode enabled." ); 24assertEquals ( await ext . payload ({ a :1 }, codex ), { a :1 , service_tier :"priority" }); 25assertEquals ( await ext . payload ({ a :1 }, other ), { a :1 }); 26assertEquals ( await ext . payload ( "text" , codex ), "text" ); 27assertEquals ( await ext . command ( "oai-fast" , "" ), "OpenAI Codex fast mode disabled." ); 28assertEquals ( await ext . payload ({ a :1 }, codex ), { a :1 }); 29}); 30 31Deno . test ( "oai-fast explicitly sets fast mode without toggling it" , async () => { 32const ext = testExtension ( misc ); 33for ( const mode of [ "off" , "on" , "on" , "off" , "off" ]) { 34const enabled = mode === "on" ; 35assertEquals ( 36await ext . command ( "oai-fast" , ` ${ mode } ` ), 37`OpenAI Codex fast mode ${ enabled ? "enabled" : "disabled" } .` , 38); 39assertEquals ( 40await ext . payload ({}, codex ), 41enabled ?{ service_tier :"priority" } :{}, 42); 43} 44}); 45 46Deno . test ( "oai-fast rejects invalid arguments without changing state" , async () => { 47const ext = testExtension ( misc ); 48for ( const mode of [ "off" , "on" ]) { 49await ext . command ( "oai-fast" , mode ); 50for ( const args of [ "true" , "on off" , "onn" ]) { 51assertEquals ( await ext . command ( "oai-fast" , args ), "Usage: /oai-fast [on|off]" ); 52assertEquals ( ext . state . oaiFast , mode === "on" ); 53} 54} 55});