summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTimo Clasen <[email protected]>2025-08-11 15:28:03 +0200
committerGitHub <[email protected]>2025-08-11 08:28:03 -0500
commit23757f3ac09b540f31d5df2088e65e5399d92f7f (patch)
tree24ef3ccfc3e6321f96f45decb0d252056eada03a
parentdf7296cfe16d3c2dfffb01941354173fb5f4a812 (diff)
downloadopencode-23757f3ac09b540f31d5df2088e65e5399d92f7f.tar.gz
opencode-23757f3ac09b540f31d5df2088e65e5399d92f7f.zip
fix: only load the first local and global rule file (#1761)
-rw-r--r--packages/opencode/src/session/system.ts23
1 files changed, 17 insertions, 6 deletions
diff --git a/packages/opencode/src/session/system.ts b/packages/opencode/src/session/system.ts
index 7e5c75e67..b2f156f14 100644
--- a/packages/opencode/src/session/system.ts
+++ b/packages/opencode/src/session/system.ts
@@ -54,24 +54,35 @@ export namespace SystemPrompt {
]
}
- const CUSTOM_FILES = [
+ const LOCAL_RULE_FILES = [
"AGENTS.md",
"CLAUDE.md",
"CONTEXT.md", // deprecated
]
+ const GLOBAL_RULE_FILES = [
+ path.join(Global.Path.config, "AGENTS.md"),
+ path.join(os.homedir(), ".claude", "CLAUDE.md"),
+ ]
export async function custom() {
const { cwd, root } = App.info().path
const config = await Config.get()
const paths = new Set<string>()
- for (const item of CUSTOM_FILES) {
- const matches = await Filesystem.findUp(item, cwd, root)
- matches.forEach((path) => paths.add(path))
+ for (const localRuleFile of LOCAL_RULE_FILES) {
+ const matches = await Filesystem.findUp(localRuleFile, cwd, root)
+ if (matches.length > 0) {
+ matches.forEach((path) => paths.add(path))
+ break
+ }
}
- paths.add(path.join(Global.Path.config, "AGENTS.md"))
- paths.add(path.join(os.homedir(), ".claude", "CLAUDE.md"))
+ for (const globalRuleFile of GLOBAL_RULE_FILES) {
+ if (await Bun.file(globalRuleFile).exists()) {
+ paths.add(globalRuleFile)
+ break
+ }
+ }
if (config.instructions) {
for (let instruction of config.instructions) {