diff options
| author | Aiden Cline <[email protected]> | 2025-08-03 14:10:21 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-03 15:10:21 -0400 |
| commit | edda26ab33903099e66d1ecde7247b5a0d317e8d (patch) | |
| tree | 761315ccfdaa72c3a5969181ef511cb8e09a65c4 /packages | |
| parent | ea4e1913c00597c548845cee2ab3195676ebada9 (diff) | |
| download | opencode-edda26ab33903099e66d1ecde7247b5a0d317e8d.tar.gz opencode-edda26ab33903099e66d1ecde7247b5a0d317e8d.zip | |
tweak: filter out duplicate instructions (#1567)
Diffstat (limited to 'packages')
| -rw-r--r-- | packages/opencode/src/session/system.ts | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/packages/opencode/src/session/system.ts b/packages/opencode/src/session/system.ts index 0cf2685bb..a9b167be4 100644 --- a/packages/opencode/src/session/system.ts +++ b/packages/opencode/src/session/system.ts @@ -60,33 +60,28 @@ export namespace SystemPrompt { export async function custom() { const { cwd, root } = App.info().path const config = await Config.get() - const found = [] + const paths = new Set<string>() + for (const item of CUSTOM_FILES) { const matches = await Filesystem.findUp(item, cwd, root) - found.push(...matches.map((x) => Bun.file(x).text())) + matches.forEach((path) => paths.add(path)) } - found.push( - Bun.file(path.join(Global.Path.config, "AGENTS.md")) - .text() - .catch(() => ""), - ) - found.push( - Bun.file(path.join(os.homedir(), ".claude", "CLAUDE.md")) - .text() - .catch(() => ""), - ) + + paths.add(path.join(Global.Path.config, "AGENTS.md")) + paths.add(path.join(os.homedir(), ".claude", "CLAUDE.md")) if (config.instructions) { for (const instruction of config.instructions) { - try { - const matches = await Filesystem.globUp(instruction, cwd, root) - found.push(...matches.map((x) => Bun.file(x).text())) - } catch { - continue // Skip invalid glob patterns - } + const matches = await Filesystem.globUp(instruction, cwd, root).catch(() => []) + matches.forEach((path) => paths.add(path)) } } + const found = Array.from(paths).map((p) => + Bun.file(p) + .text() + .catch(() => ""), + ) return Promise.all(found).then((result) => result.filter(Boolean)) } |
