tweak: adjust order of system prompt instructions: Global, Project, Skills (#24974)

This commit is contained in:
Aiden Cline 2026-04-29 10:55:53 -05:00 committed by GitHub
parent 71f9189607
commit 00bb9836a6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 12 deletions

View file

@ -122,6 +122,13 @@ export const layer: Layer.Layer<Service, never, AppFileSystem.Service | Config.S
const ctx = yield* InstanceState.context
const paths = new Set<string>()
for (const file of globalFiles()) {
if (yield* fs.existsSafe(file)) {
paths.add(path.resolve(file))
break
}
}
// The first project-level match wins so we don't stack AGENTS.md/CLAUDE.md from every ancestor.
if (!Flag.OPENCODE_DISABLE_PROJECT_CONFIG) {
for (const file of FILES) {
@ -133,13 +140,6 @@ export const layer: Layer.Layer<Service, never, AppFileSystem.Service | Config.S
}
}
for (const file of globalFiles()) {
if (yield* fs.existsSafe(file)) {
paths.add(path.resolve(file))
break
}
}
if (config.instructions) {
for (const raw of config.instructions) {
if (raw.startsWith("https://") || raw.startsWith("http://")) continue

View file

@ -1445,7 +1445,7 @@ NOTE: At any point in time through this workflow you should feel free to ask the
instruction.system().pipe(Effect.orDie),
MessageV2.toModelMessagesEffect(msgs, model),
])
const system = [...env, ...(skills ? [skills] : []), ...instructions]
const system = [...env, ...instructions, ...(skills ? [skills] : [])]
const format = lastUser.format ?? { type: "text" as const }
if (format.type === "json_schema") system.push(STRUCTURED_OUTPUT_SYSTEM_PROMPT)
const result = yield* handle.process({

View file

@ -251,12 +251,12 @@ describe("Instruction.system", () => {
const rules = yield* svc.system()
expect(rules).toHaveLength(2)
expect(rules).toContain(
`Instructions from: ${path.join(projectTmp.path, "AGENTS.md")}\n# Project Instructions`,
)
expect(rules).toContain(
expect(rules[0]).toBe(
`Instructions from: ${path.join(globalTmp.path, "AGENTS.md")}\n# Global Instructions`,
)
expect(rules[1]).toBe(
`Instructions from: ${path.join(projectTmp.path, "AGENTS.md")}\n# Project Instructions`,
)
}),
),
),