-
Notifications
You must be signed in to change notification settings - Fork 47
[Fix] Recursive list_files omits nested files in temp workspaces #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d77bf8d
test(list-files,search-files): unskip read-only e2e tools
roomote 6012893
chore: tighten list_files replay predicates
roomote ca71996
test(e2e): replace opaque smoke codes with explicit instructions
edelauna d7776cf
test(e2e): log say messages when running against real endpoints
edelauna 55cb374
test(e2e): restore replay result validation
roomote 0f30e86
test(e2e): address review feedback on readonly tool fixtures
edelauna 706c4b7
fix(e2e): address readonly tool review feedback
roomote 26ff2c0
test(e2e): address search-files review feedback
edelauna f8e26a2
test: fix Windows list-files cwd assertions
roomote 893d29b
test: fix Windows list-files expected file path
roomote File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,15 @@ | ||
| import type { ChatCompletionRequest, ChatMessage } from "@copilotkit/aimock" | ||
|
|
||
| export function toolResultContains(req: ChatCompletionRequest, toolCallId: string, expected: string[]) { | ||
| const messages = Array.isArray(req?.messages) ? req.messages : [] | ||
| const toolMessage = messages.find( | ||
| (message: ChatMessage) => message?.role === "tool" && message.tool_call_id === toolCallId, | ||
| ) | ||
|
|
||
| const content = toolMessage?.content | ||
| if (typeof content !== "string") { | ||
| return false | ||
| } | ||
|
|
||
| return expected.every((text) => content.includes(text)) | ||
| } |
This file contains hidden or 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,87 @@ | ||
| import { LLMock } from "@copilotkit/aimock" | ||
|
|
||
| import { toolResultContains } from "./fixture-utils" | ||
|
|
||
| type ListFilesFixture = { | ||
| userMessagePattern: string | ||
| toolName: string | ||
| arguments: string | ||
| toolCallId: string | ||
| expected: string[] | ||
| result: string | ||
| id: string | ||
| } | ||
|
|
||
| export function addListFilesResultFixtures(mock: InstanceType<typeof LLMock>) { | ||
| const fixtures: ListFilesFixture[] = [ | ||
| { | ||
| userMessagePattern: "without recursing into subdirectories", | ||
| toolName: "list_files", | ||
| arguments: '{"path":"list-files-tool-fixture","recursive":false}', | ||
| toolCallId: "call_list_files_non_recursive_001", | ||
| expected: ["root-file-1.txt", ".hidden-file", "nested/"], | ||
| result: "The non-recursive listing for `list-files-tool-fixture` includes `root-file-1.txt`, `root-file-2.js`, `config.yaml`, `README.md`, `.hidden-file`, and the `nested/` directory.", | ||
| id: "call_list_files_non_recursive_002", | ||
| }, | ||
| { | ||
| userMessagePattern: "deep-nested-file.ts is included", | ||
| toolName: "list_files", | ||
| arguments: '{"path":"list-files-tool-fixture","recursive":true}', | ||
| toolCallId: "call_list_files_recursive_001", | ||
| expected: ["nested/", "nested/deep/", "deep-nested-file.ts"], | ||
| result: "The recursive listing for `list-files-tool-fixture` reached the nested structure and includes `nested/`, `nested/deep/`, and `deep-nested-file.ts`.", | ||
| id: "call_list_files_recursive_002", | ||
| }, | ||
| { | ||
| userMessagePattern: "path='list-files-symlink-fixture'", | ||
| toolName: "list_files", | ||
| arguments: '{"path":"list-files-symlink-fixture","recursive":false}', | ||
| toolCallId: "call_list_files_symlink_001", | ||
| expected: ["link-to-file.txt", "source/"], | ||
| result: "The symlink fixture listing shows the original `source/` directory and its `source-file.txt`, plus the symlink entry `link-to-file.txt` in `list-files-symlink-fixture`.", | ||
| id: "call_list_files_symlink_002", | ||
| }, | ||
| { | ||
| userMessagePattern: "confirm whether list-files-tool-fixture or list-files-symlink-fixture is present", | ||
| toolName: "list_files", | ||
| arguments: '{"path":".","recursive":false}', | ||
| toolCallId: "call_list_files_workspace_root_001", | ||
| expected: ["list-files-tool-fixture/"], | ||
| result: "The workspace root currently contains the `list-files-tool-fixture/` and `list-files-symlink-fixture/` test directories.", | ||
| id: "call_list_files_workspace_root_002", | ||
| }, | ||
| ] | ||
|
|
||
| for (const fixture of fixtures) { | ||
| mock.addFixture({ | ||
| match: { | ||
| userMessage: new RegExp(fixture.userMessagePattern), | ||
| }, | ||
| response: { | ||
| toolCalls: [ | ||
| { | ||
| name: fixture.toolName, | ||
| arguments: fixture.arguments, | ||
| id: fixture.toolCallId, | ||
| }, | ||
| ], | ||
| }, | ||
| }) | ||
|
|
||
| mock.addFixture({ | ||
| match: { | ||
| toolCallId: fixture.toolCallId, | ||
|
roomote[bot] marked this conversation as resolved.
|
||
| predicate: (req) => toolResultContains(req, fixture.toolCallId, fixture.expected), | ||
| }, | ||
| response: { | ||
| toolCalls: [ | ||
| { | ||
| name: "attempt_completion", | ||
| arguments: JSON.stringify({ result: fixture.result }), | ||
| id: fixture.id, | ||
| }, | ||
| ], | ||
| }, | ||
| }) | ||
| } | ||
| } | ||
This file contains hidden or 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,144 @@ | ||
| import { LLMock } from "@copilotkit/aimock" | ||
|
|
||
| import { toolResultContains } from "./fixture-utils" | ||
|
|
||
| type SearchFilesFixture = { | ||
| userMessagePattern: string | ||
| toolName: string | ||
| arguments: string | ||
| toolCallId: string | ||
| expected: string[] | ||
| result: string | ||
| id: string | ||
| } | ||
|
|
||
| export function addSearchFilesResultFixtures(mock: InstanceType<typeof LLMock>) { | ||
| const fixtures: SearchFilesFixture[] = [ | ||
| { | ||
| userMessagePattern: "JavaScript function declarations", | ||
| toolName: "search_files", | ||
| arguments: '{"path":"search-files-tool-fixture","regex":"function\\\\s+\\\\w+"}', | ||
| toolCallId: "call_search_files_functions_001", | ||
| expected: [ | ||
| "# search-files-tool-fixture/search-fixture.js", | ||
| "function calculateTotal(items) {", | ||
| "function validateUser(user) {", | ||
| ], | ||
| result: "The function search found declarations including `calculateTotal`, `validateUser`, and `formatCurrency`.", | ||
| id: "call_search_files_functions_002", | ||
| }, | ||
| { | ||
| userMessagePattern: "TODO comments using the regex TODO", | ||
| toolName: "search_files", | ||
| arguments: '{"path":"search-files-tool-fixture","regex":"TODO.*"}', | ||
| toolCallId: "call_search_files_todo_001", | ||
| expected: [ | ||
| "# search-files-tool-fixture/search-fixture.js", | ||
| "// TODO: Add more validation functions", | ||
| "// TODO: Implement user fetching", | ||
| ], | ||
| result: "The TODO search found matching TODO entries in the fixture files, including the validation and user-fetching notes.", | ||
| id: "call_search_files_todo_002", | ||
| }, | ||
| { | ||
| userMessagePattern: "TypeScript interfaces you find", | ||
| toolName: "search_files", | ||
| arguments: '{"path":"search-files-tool-fixture","regex":"interface\\\\s+\\\\w+","file_pattern":"*.ts"}', | ||
| toolCallId: "call_search_files_typescript_001", | ||
| expected: ["# search-files-tool-fixture/search-fixture.ts", "interface User {", "interface Product {"], | ||
| result: "The TypeScript-only search found the `User` and `Product` interface definitions.", | ||
| id: "call_search_files_typescript_002", | ||
| }, | ||
| { | ||
| userMessagePattern: "JSON configuration keys", | ||
| toolName: "search_files", | ||
| arguments: '{"path":"search-files-tool-fixture","regex":"\\"\\\\w+\\":\\\\s*","file_pattern":"*.json"}', | ||
| toolCallId: "call_search_files_json_001", | ||
| expected: ["# search-files-tool-fixture/search-config.json", '"name": "test-app",', '"dependencies": {'], | ||
| result: "The JSON search found configuration keys such as `name`, `version`, and `dependencies` in `search-config.json`.", | ||
| id: "call_search_files_json_002", | ||
| }, | ||
| { | ||
| userMessagePattern: "formatCurrency and debounce", | ||
| toolName: "search_files", | ||
| arguments: '{"path":"search-files-tool-fixture","regex":"function\\\\s+(format|debounce)"}', | ||
| toolCallId: "call_search_files_nested_001", | ||
| expected: [ | ||
| "# search-files-tool-fixture/nested/nested-search.js", | ||
| "function formatCurrency(amount) {", | ||
| "function debounce(func, wait) {", | ||
| ], | ||
| result: "The nested-directory search found the utility functions `formatCurrency` and `debounce`.", | ||
| id: "call_search_files_nested_002", | ||
| }, | ||
| { | ||
| userMessagePattern: "import and export statements", | ||
| toolName: "search_files", | ||
| arguments: '{"path":"search-files-tool-fixture","regex":"(import|export).*","file_pattern":"*.{js,ts}"}', | ||
| toolCallId: "call_search_files_complex_regex_001", | ||
| expected: [ | ||
| "# search-files-tool-fixture/search-fixture.js", | ||
| "export { calculateTotal, validateUser }", | ||
| "module.exports = { formatCurrency, debounce }", | ||
| ], | ||
| result: "The import/export search found the `export` statement in the JavaScript fixture module.", | ||
| id: "call_search_files_complex_regex_002", | ||
| }, | ||
| { | ||
| userMessagePattern: "nonExistentPattern12345 and report that there are no matches", | ||
| toolName: "search_files", | ||
| arguments: '{"path":"search-files-tool-fixture","regex":"nonExistentPattern12345"}', | ||
| toolCallId: "call_search_files_no_match_001", | ||
| expected: ["No results found"], | ||
| result: "No matches were found for `nonExistentPattern12345` in the search fixture directory.", | ||
| id: "call_search_files_no_match_002", | ||
| }, | ||
| { | ||
| userMessagePattern: "TypeScript class definitions and async methods", | ||
| toolName: "search_files", | ||
| arguments: | ||
| '{"path":"search-files-tool-fixture","regex":"(class\\\\s+\\\\w+|async\\\\s+\\\\w+)","file_pattern":"*.ts"}', | ||
| toolCallId: "call_search_files_class_method_001", | ||
| expected: [ | ||
| "# search-files-tool-fixture/search-fixture.ts", | ||
| "class UserService {", | ||
| "async getUser(id: number): Promise<User> {", | ||
| ], | ||
| result: "The class-and-method search found `UserService` and its async `getUser` method in the TypeScript fixture.", | ||
| id: "call_search_files_class_method_002", | ||
| }, | ||
| ] | ||
|
|
||
| for (const fixture of fixtures) { | ||
| mock.addFixture({ | ||
| match: { | ||
| userMessage: new RegExp(fixture.userMessagePattern), | ||
| }, | ||
| response: { | ||
| toolCalls: [ | ||
| { | ||
| name: fixture.toolName, | ||
| arguments: fixture.arguments, | ||
| id: fixture.toolCallId, | ||
| }, | ||
| ], | ||
| }, | ||
| }) | ||
|
|
||
| mock.addFixture({ | ||
| match: { | ||
| toolCallId: fixture.toolCallId, | ||
|
roomote[bot] marked this conversation as resolved.
roomote[bot] marked this conversation as resolved.
|
||
| predicate: (req) => toolResultContains(req, fixture.toolCallId, fixture.expected), | ||
| }, | ||
| response: { | ||
| toolCalls: [ | ||
| { | ||
| name: "attempt_completion", | ||
| arguments: JSON.stringify({ result: fixture.result }), | ||
| id: fixture.id, | ||
| }, | ||
| ], | ||
| }, | ||
| }) | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.