chore: rm fuzzy search on references (#30931)

This commit is contained in:
Shoubhit Dash 2026-06-05 16:57:39 +05:30 committed by GitHub
commit a136caa1b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 105 additions and 282 deletions

View file

@ -1969,7 +1969,7 @@ noLLMServer.instance(
)
noLLMServer.instance(
"resolves configured reference mentions before workspace paths and agents",
"resolves configured reference mentions to one root directory attachment",
() =>
Effect.gen(function* () {
const { directory: dir } = yield* TestInstance
@ -1984,33 +1984,18 @@ noLLMServer.instance(
const parts = yield* prompt.resolvePromptParts(
"Use @docs and @docs/README.md and @docs/guide and @docs/missing.md and @docs/README.md and @build",
)
const references = parts.filter(
(part): part is SessionV1.TextPartInput =>
part.type === "text" && part.synthetic === true && part.text.startsWith("Referenced configured reference "),
)
const files = parts.filter((part): part is SessionV1.FilePartInput => part.type === "file")
const agents = parts.filter((part): part is SessionV1.AgentPartInput => part.type === "agent")
const bare = references.find((part) => part.text.includes("@docs."))
const missing = references.find((part) => part.text.includes("@docs/missing.md"))
const guide = files.find((part) => part.filename === "docs/guide")
const text = parts.find((part): part is SessionV1.TextPartInput => part.type === "text" && !part.synthetic)
expect(references.length).toBe(2)
expect(bare?.metadata?.reference).toMatchObject({
name: "docs",
kind: "local",
path: docs,
expect(text?.text).toContain("@docs")
expect(files).toHaveLength(1)
expect(files[0]).toMatchObject({
filename: "docs",
mime: "application/x-directory",
source: { type: "file", path: "docs", text: { value: "@docs" } },
})
expect(missing?.text).toContain("Path does not exist inside configured reference @docs")
expect(missing?.metadata?.reference).toMatchObject({
target: "missing.md",
targetPath: path.join(docs, "missing.md"),
})
expect(files.length).toBe(2)
expect(files.map((file) => fileURLToPath(file.url)).sort()).toEqual(
[path.join(docs, "README.md"), path.join(docs, "guide")].sort(),
)
expect(guide?.mime).toBe("application/x-directory")
expect(fileURLToPath(files[0].url)).toBe(docs)
expect(agents.map((agent) => agent.name)).toEqual(["build"])
}),
{
@ -2024,7 +2009,7 @@ noLLMServer.instance(
)
noLLMServer.instance(
"injects metadata for bare configured reference mentions",
"stores raw reference mentions alongside directory attachments",
() =>
Effect.gen(function* () {
const { directory: dir } = yield* TestInstance
@ -2037,83 +2022,25 @@ noLLMServer.instance(
const message = yield* prompt.prompt({
sessionID: session.id,
noReply: true,
parts: yield* prompt.resolvePromptParts("Use @docs for context"),
parts: [{ type: "text", text: "Use @docs for context" }],
})
const stored = yield* MessageV2.get({ sessionID: session.id, messageID: message.info.id })
const synthetic = stored.parts.filter(
(part): part is SessionV1.TextPart => part.type === "text" && part.synthetic === true,
)
const reference = synthetic.find((part) => part.text.startsWith("Referenced configured reference @docs."))
const files = stored.parts.filter((part): part is SessionV1.FilePart => part.type === "file")
const text = stored.parts.find((part): part is SessionV1.TextPart => part.type === "text" && !part.synthetic)
expect(reference?.metadata?.reference).toMatchObject({ name: "docs", kind: "local", path: docs })
expect(synthetic.some((part) => part.text.includes(`Reference root: ${docs}`))).toBe(true)
expect(synthetic.some((part) => part.text.includes("Inspect the configured reference"))).toBe(true)
yield* sessions.remove(session.id)
}),
{
config: {
...cfg,
reference: {
docs: "./external-docs",
},
},
},
)
noLLMServer.instance(
"injects metadata for configured reference file attachments",
() =>
Effect.gen(function* () {
const { directory: dir } = yield* TestInstance
const docs = path.join(dir, "external-docs")
const readme = path.join(docs, "README.md")
yield* ensureDir(docs)
yield* writeText(readme, "reference readme")
const prompt = yield* SessionPrompt.Service
const sessions = yield* Session.Service
const session = yield* sessions.create({})
const message = yield* prompt.prompt({
sessionID: session.id,
agent: "build",
noReply: true,
parts: [
{ type: "text", text: "Read @docs/README.md" },
{
type: "file",
mime: "text/plain",
filename: "docs/README.md",
url: pathToFileURL(readme).href,
source: {
type: "file",
path: "docs/README.md",
text: { value: "@docs/README.md", start: 5, end: 20 },
},
},
],
expect(text?.text).toBe("Use @docs for context")
expect(synthetic.some((part) => part.text.includes(JSON.stringify({ filePath: docs })))).toBe(true)
expect(files).toHaveLength(1)
expect(files[0]).toMatchObject({
filename: "docs",
mime: "application/x-directory",
source: { type: "file", path: "docs", text: { value: "@docs", start: 4, end: 9 } },
})
const stored = yield* MessageV2.get({ sessionID: session.id, messageID: message.info.id })
const synthetic = stored.parts.filter(
(part): part is SessionV1.TextPart => part.type === "text" && part.synthetic === true,
)
const reference = synthetic.find((part) =>
part.text.startsWith("Referenced configured reference @docs/README.md."),
)
expect(reference?.metadata?.reference).toMatchObject({
name: "docs",
kind: "local",
path: docs,
target: "README.md",
targetPath: readme,
source: { value: "@docs/README.md", start: 5, end: 20 },
})
expect(synthetic.findIndex((part) => part === reference)).toBeLessThan(
synthetic.findIndex((part) => part.text.startsWith("Called the Read tool with the following input:")),
)
expect(fileURLToPath(files[0].url)).toBe(docs)
yield* sessions.remove(session.id)
}),