summaryrefslogtreecommitdiffhomepage
path: root/packages
diff options
context:
space:
mode:
authorAiden Cline <[email protected]>2026-04-29 10:55:53 -0500
committerGitHub <[email protected]>2026-04-29 10:55:53 -0500
commit00bb9836a60f1dcdd0ce5078b05d12f749fdde66 (patch)
tree664f25fabb3c9b1915467b25667f7da2cab088da /packages
parent71f91896077fb02e6a086ef1ff402b3e093d05bf (diff)
downloadopencode-00bb9836a60f1dcdd0ce5078b05d12f749fdde66.tar.gz
opencode-00bb9836a60f1dcdd0ce5078b05d12f749fdde66.zip
tweak: adjust order of system prompt instructions: Global, Project, Skills (#24974)
Diffstat (limited to 'packages')
-rw-r--r--packages/opencode/src/session/instruction.ts14
-rw-r--r--packages/opencode/src/session/prompt.ts2
-rw-r--r--packages/opencode/test/session/instruction.test.ts8
3 files changed, 12 insertions, 12 deletions
diff --git a/packages/opencode/src/session/instruction.ts b/packages/opencode/src/session/instruction.ts
index bd5098015..5d91066b4 100644
--- a/packages/opencode/src/session/instruction.ts
+++ b/packages/opencode/src/session/instruction.ts
@@ -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
diff --git a/packages/opencode/src/session/prompt.ts b/packages/opencode/src/session/prompt.ts
index 4c259e4ae..c4d867322 100644
--- a/packages/opencode/src/session/prompt.ts
+++ b/packages/opencode/src/session/prompt.ts
@@ -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({
diff --git a/packages/opencode/test/session/instruction.test.ts b/packages/opencode/test/session/instruction.test.ts
index 60882d2b3..a9926b1e2 100644
--- a/packages/opencode/test/session/instruction.test.ts
+++ b/packages/opencode/test/session/instruction.test.ts
@@ -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`,
+ )
}),
),
),