char-slop/berry
multipurpose self-modifiable agentic harness
git clone https://git.t4t.associates/char-slop/berry
c5dd844
main
1import type { ViewDestination } from "@berry/api/web.ts" ; 2 3let guard :(( destination :ViewDestination ) => boolean | Promise < boolean >) | null = null ; 4 5export function guardNavigation ( check :NonNullable < typeof guard >) { 6guard = check ; 7return () => { 8if ( guard === check ) guard = null ; 9}; 10} 11 12export function beforeNavigate ( route :string ) :boolean | Promise < boolean > { 13const [ tid , extension , ...parts ] = route . split ( "/" ); 14const decode = ( part :string ) => { 15try { 16return decodeURIComponent ( part ); 17} catch { 18return part ; 19} 20}; 21return guard ?.({ 22tid :/ ^[a-z2-7]{13}$ / . test ( tid ) ?tid :null , 23extension :extension ?? null , 24route :parts . map ( decode ). join ( "/" ), 25}) ?? true ; 26}