Repository navigation
fix(repo): a Copilot grep tool call over a guidance file goes into searched - #1228
Conversation
…arched (intel#1002) The copilot-json converter knew only view as a read tool and bash/powershell as shell tools, so a grep tool call was one bare tool event and guidance_searched never listed the file it searched. A grep call in output_mode content now carries searched: its paths (one string or a list, each resolved from the start directory as a view path is). The default mode, files_with_matches and count print no line of a file, and a call with no paths names none, so they stay bare. A failed result, an empty one or "No matches found." drops searched. A search adds no read event. The Copilot converter does not track a shell moved by an earlier cd for view, so a relative grep path follows view. The contract's guidance_searched row, the events format, the process_metrics docstring and a changelog fragment say so. Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 6 selected item(s). CI at Review details
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1228 +/- ##
==========================================
- Coverage 96.07% 96.07% -0.01%
==========================================
Files 496 496
Lines 65209 65221 +12
Branches 11317 11319 +2
==========================================
+ Hits 62652 62659 +7
- Misses 1583 1584 +1
- Partials 974 978 +4
🚀 New features to boost your workflow:
|
napetrov
left a comment
There was a problem hiding this comment.
Change class: CONTRACT (head 3c2e6fc)
- Contract: changed (count signal only, no file:line)
- Responsibility: none
- Dependency: none
- Review depth: check the changed surface: callers, docs, tests pin new behaviour
- Coverage gaps: none
Reviewed conversion of content-mode grep calls, path lists, and removal of search evidence on failed or empty results. Seven focused conversion tests passed locally. CI passed. Trace coverage uses the CLI schema and synthetic records. A live Copilot trace remains unverified.
Summary
#1002: Copilot CLI has its own
greptool, andcli_traces._copilot_toolknew onlyviewas a read tool andbash/powershellas shell tools, so agrepcall over a guidance file was one baretoolevent. Onmain, with the argument shape of the CLI'sgreptool (pattern,pathsas a string or a list,output_mode; the issue's repro guessed apathkey, which the CLI does not send):Now the event carries
searched: ["AGENTS.md"]andguidance_searchedis["AGENTS.md"]. The fix takes the option the issue lists: the path and mode are read from the call and the path goes intosearchedof thetoolevent, asevents._tool_eventdoes for Claude Code'sGrep. The issue asked for a recorded trace first; none could be recorded for this PR, so the argument names come from the Copilot CLI 1.0.75 argument schema instead (Risk and Open questions).Closes #1002
Changes
dokimi/dokimi/repos/cli_traces.py:_copilot_toolgives agrepcall inoutput_modecontentasearchedlist, the call'spaths(one string or a list; an empty or non-string entry is skipped), each resolved from the start directory as aviewpath is, throughsearched_field. The default mode,files_with_matches,countand a call with nopathsprint no line of a file and stay a baretoolevent._copilot_resultdropssearchedwhen the result failed (successfalse), or its content is empty orNo matches found.. A search adds noreadevent, sotool_callsandguidance_readdo not change. Arguments that are not an object stay a baretoolevent, with no dropped line.dokimi/docs/repo-evaluation-contract.md(§4.1guidance_searched),dokimi/docs/events-format.mdand theprocess_metrics.pydocstring: a Copilotgrepcall counts under the rules of a Claude CodeGrepcall; a PowerShell command is still not parsed.dokimi/tests/test_repo_copilot_grep.py: 16 tests throughconvert("copilot-json", ...)andprocess_metrics.Risk
The
grepargument shape (paths,output_mode) follows the Copilot CLI 1.0.75 argument schema; the fixture in the tests is built from it and is not a recorded trace. A trace of a CLI version that names the keys differently gets nosearched, as before.The Copilot converter does not track a shell moved by an earlier
bashcall'scdforview, so a relativegreppath followsview: it is resolved from the start directory and kept after acd. A Claude CodeGreppath is dropped there; a Copilot one is not. Whether acdin a Copilotbashcall moves the directory itsgrepandviewtools start in is not checked on a real trace; if it does, a relativegreppath after acdcan credit a file the call did not search, as a relativeviewpath can today.A merge with #1155 meets a text conflict in
repo-evaluation-contract.md: it edits the §4.1guidance_readrow, the line next to theguidance_searchedrow this PR edits. Keeping both rows settles it. #1201 and #1223 merge cleanly.A directory in
pathsis kept insearchedand filtered out byprocess_metrics, as for a Claude CodeGrep. Every other Copilot tool and Claude Code'sGrephandling convert as before.Testing
On Linux, at
3c2e6fc0(onmain602de140):make ci-local: 38 passed, 0 failed, 15 skipped (micromamba, semgrep, the fuzz run, the matrix jobs and the deploy job, whose conditions or tools are absent locally). 28398 tests passed, 23 skipped; changed-line coverage 100%.main's code, run with the CLI'spathsinput: 6 failed, 10 passed; the first failure is thecontentgrep overAGENTS.md, whose event lackssearched. The 10 that pass pin what stays (nosearchedfor the other modes, a no-match, an empty or a failed result).output_mode == "content"check, 3 tests fail (the default,files_with_matchesandcountcases); without the no-match drop, 4 fail (No matches found., with spaces around it, empty,success: false); with only the first entry of apathslist, the list test fails.Open questions
The fixture is built from the CLI's argument schema, not recorded: no Copilot login was available. Should a recorded trace replace it?
Revert
A plain revert restores the bare
toolevent for agrepcall. Nothing is stored.Checklist
pytestpassesruff,mypy, and schema checks passAGENTS.mdraise/exit and test names the doc, contract or issue it traces to.github/.licenserc.yaml)