From 7ecdc1b5d8c324edfd28a9ce23a7fc6e8b7d520f Mon Sep 17 00:00:00 2001 From: Yihui Khuu Date: Sat, 27 Sep 2025 00:46:49 +1000 Subject: [PATCH] fix: config loading not considering symlinks (#2800) --- packages/opencode/src/config/config.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/opencode/src/config/config.ts b/packages/opencode/src/config/config.ts index ec4e6be9..40e4d90a 100644 --- a/packages/opencode/src/config/config.ts +++ b/packages/opencode/src/config/config.ts @@ -120,7 +120,13 @@ export namespace Config { async function assertValid(dir: string) { const ALLOWED_DIRS = new Set(["agent", "command", "mode", "plugin", "tool", "themes"]) const UNEXPECTED_DIR_GLOB = new Bun.Glob("*/") - for await (const item of UNEXPECTED_DIR_GLOB.scan({ absolute: true, cwd: dir, onlyFiles: false })) { + for await (const item of UNEXPECTED_DIR_GLOB.scan({ + absolute: true, + followSymlinks: true, + dot: true, + cwd: dir, + onlyFiles: false, + })) { const dirname = path.basename(item) if (!ALLOWED_DIRS.has(dirname)) { throw new InvalidError({ @@ -134,7 +140,7 @@ export namespace Config { const COMMAND_GLOB = new Bun.Glob("command/**/*.md") async function loadCommand(dir: string) { const result: Record = {} - for await (const item of COMMAND_GLOB.scan({ absolute: true, cwd: dir })) { + for await (const item of COMMAND_GLOB.scan({ absolute: true, followSymlinks: true, dot: true, cwd: dir })) { const content = await Bun.file(item).text() const md = matter(content) if (!md.data) continue @@ -169,7 +175,7 @@ export namespace Config { async function loadAgent(dir: string) { const result: Record = {} - for await (const item of AGENT_GLOB.scan({ absolute: true, cwd: dir })) { + for await (const item of AGENT_GLOB.scan({ absolute: true, followSymlinks: true, dot: true, cwd: dir })) { const content = await Bun.file(item).text() const md = matter(content) if (!md.data) continue @@ -207,7 +213,7 @@ export namespace Config { const MODE_GLOB = new Bun.Glob("mode/*.md") async function loadMode(dir: string) { const result: Record = {} - for await (const item of MODE_GLOB.scan({ absolute: true, cwd: dir })) { + for await (const item of MODE_GLOB.scan({ absolute: true, followSymlinks: true, dot: true, cwd: dir })) { const content = await Bun.file(item).text() const md = matter(content) if (!md.data) continue @@ -233,7 +239,7 @@ export namespace Config { async function loadPlugin(dir: string) { const plugins: string[] = [] - for await (const item of PLUGIN_GLOB.scan({ absolute: true, cwd: dir })) { + for await (const item of PLUGIN_GLOB.scan({ absolute: true, followSymlinks: true, dot: true, cwd: dir })) { plugins.push("file://" + item) } return plugins