tweak: filter out duplicate instructions (#1567)

This commit is contained in:
Aiden Cline
2025-08-03 14:10:21 -05:00
committed by GitHub
parent ea4e1913c0
commit edda26ab33
2 changed files with 14 additions and 19 deletions

View File

@@ -5,7 +5,7 @@
"type": "module", "type": "module",
"packageManager": "bun@1.2.14", "packageManager": "bun@1.2.14",
"scripts": { "scripts": {
"dev": "bun run packages/opencode/src/index.ts", "dev": "bun run --conditions=development packages/opencode/src/index.ts",
"typecheck": "bun run --filter='*' typecheck", "typecheck": "bun run --filter='*' typecheck",
"stainless": "./scripts/stainless", "stainless": "./scripts/stainless",
"postinstall": "./script/hooks" "postinstall": "./script/hooks"

View File

@@ -60,33 +60,28 @@ export namespace SystemPrompt {
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 found = [] const paths = new Set<string>()
for (const item of CUSTOM_FILES) { for (const item of CUSTOM_FILES) {
const matches = await Filesystem.findUp(item, cwd, root) 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")) paths.add(path.join(Global.Path.config, "AGENTS.md"))
.text() paths.add(path.join(os.homedir(), ".claude", "CLAUDE.md"))
.catch(() => ""),
)
found.push(
Bun.file(path.join(os.homedir(), ".claude", "CLAUDE.md"))
.text()
.catch(() => ""),
)
if (config.instructions) { if (config.instructions) {
for (const instruction of config.instructions) { for (const instruction of config.instructions) {
try { const matches = await Filesystem.globUp(instruction, cwd, root).catch(() => [])
const matches = await Filesystem.globUp(instruction, cwd, root) matches.forEach((path) => paths.add(path))
found.push(...matches.map((x) => Bun.file(x).text()))
} catch {
continue // Skip invalid glob patterns
}
} }
} }
const found = Array.from(paths).map((p) =>
Bun.file(p)
.text()
.catch(() => ""),
)
return Promise.all(found).then((result) => result.filter(Boolean)) return Promise.all(found).then((result) => result.filter(Boolean))
} }