fix(core): avoid reinjecting ancestor instructions (#52364)

This commit is contained in:
Aiden Cline
2026-09-30 15:01:58 -05:00
committed by GitHub
parent b020f1018b
commit 14636b9900
+3 -3
View File
@@ -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 })