Skip to content

Commit 00bb983

Browse files
authored
tweak: adjust order of system prompt instructions: Global, Project, Skills (anomalyco#24974)
1 parent 71f9189 commit 00bb983

3 files changed

Lines changed: 12 additions & 12 deletions

File tree

packages/opencode/src/session/instruction.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,13 @@ export const layer: Layer.Layer<Service, never, AppFileSystem.Service | Config.S
122122
const ctx = yield* InstanceState.context
123123
const paths = new Set<string>()
124124

125+
for (const file of globalFiles()) {
126+
if (yield* fs.existsSafe(file)) {
127+
paths.add(path.resolve(file))
128+
break
129+
}
130+
}
131+
125132
// The first project-level match wins so we don't stack AGENTS.md/CLAUDE.md from every ancestor.
126133
if (!Flag.OPENCODE_DISABLE_PROJECT_CONFIG) {
127134
for (const file of FILES) {
@@ -133,13 +140,6 @@ export const layer: Layer.Layer<Service, never, AppFileSystem.Service | Config.S
133140
}
134141
}
135142

136-
for (const file of globalFiles()) {
137-
if (yield* fs.existsSafe(file)) {
138-
paths.add(path.resolve(file))
139-
break
140-
}
141-
}
142-
143143
if (config.instructions) {
144144
for (const raw of config.instructions) {
145145
if (raw.startsWith("https://") || raw.startsWith("http://")) continue

packages/opencode/src/session/prompt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1445,7 +1445,7 @@ NOTE: At any point in time through this workflow you should feel free to ask the
14451445
instruction.system().pipe(Effect.orDie),
14461446
MessageV2.toModelMessagesEffect(msgs, model),
14471447
])
1448-
const system = [...env, ...(skills ? [skills] : []), ...instructions]
1448+
const system = [...env, ...instructions, ...(skills ? [skills] : [])]
14491449
const format = lastUser.format ?? { type: "text" as const }
14501450
if (format.type === "json_schema") system.push(STRUCTURED_OUTPUT_SYSTEM_PROMPT)
14511451
const result = yield* handle.process({

packages/opencode/test/session/instruction.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,12 @@ describe("Instruction.system", () => {
251251

252252
const rules = yield* svc.system()
253253
expect(rules).toHaveLength(2)
254-
expect(rules).toContain(
255-
`Instructions from: ${path.join(projectTmp.path, "AGENTS.md")}\n# Project Instructions`,
256-
)
257-
expect(rules).toContain(
254+
expect(rules[0]).toBe(
258255
`Instructions from: ${path.join(globalTmp.path, "AGENTS.md")}\n# Global Instructions`,
259256
)
257+
expect(rules[1]).toBe(
258+
`Instructions from: ${path.join(projectTmp.path, "AGENTS.md")}\n# Project Instructions`,
259+
)
260260
}),
261261
),
262262
),

0 commit comments

Comments
 (0)