@@ -28,7 +28,6 @@ import { constants, existsSync } from "fs"
2828import { Bus } from "@/bus"
2929import { GlobalBus } from "@/bus/global"
3030import { Event } from "../server/event"
31- import { Glob } from "../util/glob"
3231import { PackageRegistry } from "@/bun/registry"
3332import { proxied } from "@/util/proxied"
3433import { iife } from "@/util/iife"
@@ -352,12 +351,14 @@ export namespace Config {
352351 return ext . length ? file . slice ( 0 , - ext . length ) : file
353352 }
354353
354+ const COMMAND_GLOB = new Bun . Glob ( "{command,commands}/**/*.md" )
355355 async function loadCommand ( dir : string ) {
356356 const result : Record < string , Command > = { }
357- for ( const item of await Glob . scan ( "{command,commands}/**/*.md" , {
358- cwd : dir ,
357+ for await ( const item of COMMAND_GLOB . scan ( {
359358 absolute : true ,
359+ followSymlinks : true ,
360360 dot : true ,
361+ cwd : dir ,
361362 } ) ) {
362363 const md = await ConfigMarkdown . parse ( item ) . catch ( async ( err ) => {
363364 const message = ConfigMarkdown . FrontmatterError . isInstance ( err )
@@ -389,13 +390,15 @@ export namespace Config {
389390 return result
390391 }
391392
393+ const AGENT_GLOB = new Bun . Glob ( "{agent,agents}/**/*.md" )
392394 async function loadAgent ( dir : string ) {
393395 const result : Record < string , Agent > = { }
394396
395- for ( const item of await Glob . scan ( "{agent,agents}/**/*.md" , {
396- cwd : dir ,
397+ for await ( const item of AGENT_GLOB . scan ( {
397398 absolute : true ,
399+ followSymlinks : true ,
398400 dot : true ,
401+ cwd : dir ,
399402 } ) ) {
400403 const md = await ConfigMarkdown . parse ( item ) . catch ( async ( err ) => {
401404 const message = ConfigMarkdown . FrontmatterError . isInstance ( err )
@@ -427,12 +430,14 @@ export namespace Config {
427430 return result
428431 }
429432
433+ const MODE_GLOB = new Bun . Glob ( "{mode,modes}/*.md" )
430434 async function loadMode ( dir : string ) {
431435 const result : Record < string , Agent > = { }
432- for ( const item of await Glob . scan ( "{mode,modes}/*.md" , {
433- cwd : dir ,
436+ for await ( const item of MODE_GLOB . scan ( {
434437 absolute : true ,
438+ followSymlinks : true ,
435439 dot : true ,
440+ cwd : dir ,
436441 } ) ) {
437442 const md = await ConfigMarkdown . parse ( item ) . catch ( async ( err ) => {
438443 const message = ConfigMarkdown . FrontmatterError . isInstance ( err )
@@ -462,13 +467,15 @@ export namespace Config {
462467 return result
463468 }
464469
470+ const PLUGIN_GLOB = new Bun . Glob ( "{plugin,plugins}/*.{ts,js}" )
465471 async function loadPlugin ( dir : string ) {
466472 const plugins : string [ ] = [ ]
467473
468- for ( const item of await Glob . scan ( "{plugin,plugins}/*.{ts,js}" , {
469- cwd : dir ,
474+ for await ( const item of PLUGIN_GLOB . scan ( {
470475 absolute : true ,
476+ followSymlinks : true ,
471477 dot : true ,
478+ cwd : dir ,
472479 } ) ) {
473480 plugins . push ( pathToFileURL ( item ) . href )
474481 }
0 commit comments