From 00bb9836a60f1dcdd0ce5078b05d12f749fdde66 Mon Sep 17 00:00:00 2001 From: Aiden Cline <63023139+rekram1-node@users.noreply.github.com> Date: Wed, 29 Apr 2026 10:55:53 -0500 Subject: [PATCH] tweak: adjust order of system prompt instructions: Global, Project, Skills (#24974) --- packages/opencode/src/session/instruction.ts | 14 +++++++------- packages/opencode/src/session/prompt.ts | 2 +- packages/opencode/test/session/instruction.test.ts | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/opencode/src/session/instruction.ts b/packages/opencode/src/session/instruction.ts index bd50980159..5d91066b41 100644 --- a/packages/opencode/src/session/instruction.ts +++ b/packages/opencode/src/session/instruction.ts @@ -122,6 +122,13 @@ export const layer: Layer.Layer() + 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 { 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`, + ) }), ), ),