Skip to content

Commit a9c810c

Browse files
fix(tui): double file content injection in commands using $ARGUMENTS (anomalyco#31245)
Co-authored-by: Aiden Cline <aidenpcline@gmail.com>
1 parent fe2e4e2 commit a9c810c

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

packages/opencode/src/session/prompt.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1491,6 +1491,12 @@ export const layer = Layer.effect(
14911491
}
14921492

14931493
const templateParts = yield* resolvePromptParts(template)
1494+
const inputFiles = new Set(
1495+
input.parts?.filter((part) => new URL(part.url).protocol === "file:").map((part) => fileURLToPath(part.url)),
1496+
)
1497+
const uniqueTemplateParts = templateParts.filter(
1498+
(part) => part.type !== "file" || !inputFiles.has(fileURLToPath(part.url)),
1499+
)
14941500
const isSubtask = (agent.mode === "subagent" && cmd.subtask !== false) || cmd.subtask === true
14951501
const parts = isSubtask
14961502
? [
@@ -1503,7 +1509,7 @@ export const layer = Layer.effect(
15031509
prompt: templateParts.find((y) => y.type === "text")?.text ?? "",
15041510
},
15051511
]
1506-
: [...templateParts, ...(input.parts ?? [])]
1512+
: [...uniqueTemplateParts, ...(input.parts ?? [])]
15071513

15081514
const userAgent = isSubtask ? (input.agent ?? (yield* agents.defaultInfo()).name) : agent.name
15091515
const userModel = isSubtask

0 commit comments

Comments
 (0)