mirror of
https://gitee.com/zhangsken/opencode.git
synced 2026-10-16 02:24:10 +08:00
fix(core): avoid reinjecting ancestor instructions (#52364)
This commit is contained in:
@@ -88,15 +88,15 @@ export const Plugin = {
|
||||
if (result.target.externalDirectory !== undefined) return
|
||||
const resolved = yield* fs.resolve(result.target.absolute)
|
||||
const root = yield* fs.resolve(location.directory)
|
||||
// up() searches its stop directory, so the Location-root AGENTS.md (already
|
||||
// supplied by core initial instructions) is dropped by the dirname filter.
|
||||
// The Location and its ancestors are already supplied by initial instructions,
|
||||
// even when an upward walk from elsewhere in the project cannot reach root.
|
||||
const discovered = yield* fs.up({
|
||||
targets: [FILENAME],
|
||||
start: result.content.type === "list-page" ? resolved : dirname(resolved),
|
||||
stop: root,
|
||||
})
|
||||
const candidates = (yield* Effect.forEach(discovered, fs.resolve)).filter(
|
||||
(file) => dirname(file) !== root,
|
||||
(file) => !FSUtil.contains(dirname(file), root),
|
||||
)
|
||||
if (candidates.length === 0) return
|
||||
yield* sessionInstructions.load({ sessionID: context.sessionID, paths: candidates })
|
||||
|
||||
Reference in New Issue
Block a user