mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-23 10:44:21 +01:00
fix: only load the first local and global rule file (#1761)
This commit is contained in:
@@ -54,24 +54,35 @@ export namespace SystemPrompt {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
const CUSTOM_FILES = [
|
const LOCAL_RULE_FILES = [
|
||||||
"AGENTS.md",
|
"AGENTS.md",
|
||||||
"CLAUDE.md",
|
"CLAUDE.md",
|
||||||
"CONTEXT.md", // deprecated
|
"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() {
|
export async function custom() {
|
||||||
const { cwd, root } = App.info().path
|
const { cwd, root } = App.info().path
|
||||||
const config = await Config.get()
|
const config = await Config.get()
|
||||||
const paths = new Set<string>()
|
const paths = new Set<string>()
|
||||||
|
|
||||||
for (const item of CUSTOM_FILES) {
|
for (const localRuleFile of LOCAL_RULE_FILES) {
|
||||||
const matches = await Filesystem.findUp(item, cwd, root)
|
const matches = await Filesystem.findUp(localRuleFile, cwd, root)
|
||||||
|
if (matches.length > 0) {
|
||||||
matches.forEach((path) => paths.add(path))
|
matches.forEach((path) => paths.add(path))
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
paths.add(path.join(Global.Path.config, "AGENTS.md"))
|
for (const globalRuleFile of GLOBAL_RULE_FILES) {
|
||||||
paths.add(path.join(os.homedir(), ".claude", "CLAUDE.md"))
|
if (await Bun.file(globalRuleFile).exists()) {
|
||||||
|
paths.add(globalRuleFile)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (config.instructions) {
|
if (config.instructions) {
|
||||||
for (let instruction of config.instructions) {
|
for (let instruction of config.instructions) {
|
||||||
|
|||||||
Reference in New Issue
Block a user