generated from ellisonleao/nvim-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve findReferences and hover tools
- Loading branch information
Showing
9 changed files
with
251 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
type Nested = { | ||
a: { | ||
b: { | ||
c: "test"; | ||
}; | ||
}; | ||
}; | ||
|
||
const val: Nested = { | ||
a: { | ||
b: { | ||
c: "test", | ||
}, | ||
}, | ||
}; | ||
|
||
console.log(val.a.b.c); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { type ToolRequestId } from "./toolManager.ts"; | ||
import { describe, it, expect } from "bun:test"; | ||
import { withDriver } from "../test/preamble"; | ||
import { pollUntil } from "../utils/async.ts"; | ||
|
||
describe("bun/tools/findReferences.spec.ts", () => { | ||
it.only("findReferences end-to-end", async () => { | ||
await withDriver(async (driver) => { | ||
await driver.editFile("bun/test/fixtures/test.ts"); | ||
await driver.showSidebar(); | ||
|
||
await driver.inputMagentaText(`Try finding references for a symbol`); | ||
await driver.send(); | ||
|
||
const toolRequestId = "id" as ToolRequestId; | ||
await driver.mockAnthropic.respond({ | ||
stopReason: "tool_use", | ||
text: "ok, here goes", | ||
toolRequests: [ | ||
{ | ||
status: "ok", | ||
value: { | ||
type: "tool_use", | ||
id: toolRequestId, | ||
name: "find_references", | ||
input: { | ||
filePath: "bun/test/fixtures/test.ts", | ||
symbol: "val.a.b.c", | ||
}, | ||
}, | ||
}, | ||
], | ||
}); | ||
|
||
const result = await pollUntil( | ||
() => { | ||
const state = driver.magenta.chatApp.getState(); | ||
if (state.status != "running") { | ||
throw new Error(`app crashed`); | ||
} | ||
|
||
const toolWrapper = | ||
state.model.toolManager.toolWrappers[toolRequestId]; | ||
if (!toolWrapper) { | ||
throw new Error( | ||
`could not find toolWrapper with id ${toolRequestId}`, | ||
); | ||
} | ||
|
||
if (toolWrapper.model.state.state != "done") { | ||
throw new Error(`Request not done`); | ||
Check failure on line 51 in bun/tools/findReferences.spec.ts GitHub Actions / testerror: Request not done
|
||
} | ||
|
||
return toolWrapper.model.state.result; | ||
}, | ||
{ timeout: 3000 }, | ||
); | ||
|
||
expect(result).toEqual({ | ||
tool_use_id: toolRequestId, | ||
type: "tool_result", | ||
content: `bun/test/fixtures/test.ts:4:6\nbun/test/fixtures/test.ts:12:6\nbun/test/fixtures/test.ts:17:20\n`, | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.