test: add regression test for command file dedup from $ARGUMENTS
This commit is contained in:
parent
5917aec929
commit
06f5469be8
1 changed files with 53 additions and 0 deletions
|
|
@ -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,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue