From 06f5469be8442605f4995d6f830b1a6e6b371ced Mon Sep 17 00:00:00 2001 From: verdverm Date: Sun, 7 Jun 2026 08:54:53 -0700 Subject: [PATCH] test: add regression test for command file dedup from $ARGUMENTS --- packages/opencode/test/session/prompt.test.ts | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/packages/opencode/test/session/prompt.test.ts b/packages/opencode/test/session/prompt.test.ts index 1abfeaf5ee..c2ce075dc1 100644 --- a/packages/opencode/test/session/prompt.test.ts +++ b/packages/opencode/test/session/prompt.test.ts @@ -2316,3 +2316,56 @@ noLLMServer.instance( }), 30_000, ) + +it.instance( + "command deduplicates file parts from $ARGUMENTS and input parts", + () => + Effect.gen(function* () { + const { dir, llm } = yield* useServerConfig((url) => ({ + ...providerCfg(url), + command: { + testdedup: { + template: "Read $ARGUMENTS", + description: "Test command for file dedup", + }, + }, + })) + const prompt = yield* SessionPrompt.Service + const sessions = yield* Session.Service + const session = yield* sessions.create({ title: "File dedup test" }) + + const testFile = path.join(dir, "dedup-test.txt") + yield* writeText(testFile, "dedup-content") + + yield* llm.text("done") + + const result = yield* prompt.command({ + sessionID: session.id, + command: "testdedup", + arguments: "@dedup-test.txt", + parts: [ + { + type: "file", + url: pathToFileURL(testFile).href, + filename: "dedup-test.txt", + mime: "text/plain", + }, + ], + }) + + expect(result.info.role).toBe("assistant") + + const msgs = yield* sessions.messages({ sessionID: session.id }) + const userMsg = msgs.findLast((msg) => msg.info.role === "user") + expect(userMsg?.info.role).toBe("user") + if (userMsg?.info.role !== "user") return + + const syntheticTexts = userMsg.parts.filter( + (part): part is SessionV1.TextPart => part.type === "text" && "synthetic" in part && part.synthetic === true, + ) + const contentCount = syntheticTexts.filter((part) => part.text.includes("dedup-content")).length + expect(contentCount).toBe(1) + }), + { config: cfg }, + 30_000, +)