diff --git a/dokimi/changelog.d/20261125_160000_copilot-grep-searched.md b/dokimi/changelog.d/20261125_160000_copilot-grep-searched.md
new file mode 100644
index 000000000..fa91522e4
--- /dev/null
+++ b/dokimi/changelog.d/20261125_160000_copilot-grep-searched.md
@@ -0,0 +1,3 @@
+### Fixed
+
+- **A Copilot CLI `grep` tool call over a guidance file counts in `process.guidance_searched`** — the `copilot-json` converter turned a `grep` call into a bare `tool` event, so `grep` with `paths: "AGENTS.md"` and `output_mode: "content"` listed nothing. The event now carries `searched`, the call's `paths` (one string or a list) resolved from the start directory as a `view` path is, in `content` mode only; the default mode, `files_with_matches` and `count` print no line of a file, and a call with no `paths` names no file. A result that failed, is empty or says `No matches found.` drops it. A search adds no `read` event, so `tool_calls` and `guidance_read` do not change.
diff --git a/dokimi/docs/events-format.md b/dokimi/docs/events-format.md
index 27587755a..6925b6e69 100644
--- a/dokimi/docs/events-format.md
+++ b/dokimi/docs/events-format.md
@@ -32,7 +32,7 @@ depend on the kind:
| `command` | `text`; `rc` (integer, or `null` when no result came back); `rc_from: "success"` when Copilot reported a completion status without an exit code; `output` and `output_truncated` when the harness returned output; `searched` (a list of workspace paths) when a `grep`, `egrep`, `fgrep`, `rg` or `git grep` part of it named files and showed lines of them (see below) |
| `read` | `path` (absent on a refused relative read whose file is not known; a relative path joined to the working directory the CLI started in loses its `.` components and repeated `/`, while an absolute path, or a relative one with no working directory known, is kept as written; a `..` always stays as written, since the name before it may be a link); `rc` 0 or 1 when the harness reported one |
| `edit` | `path`; `rc`; `deleted` when the file was deleted |
-| `tool` | `name`; `skill` on a `Skill` call; `searched` (one path) on a Claude Code `Grep` call whose `path` is given and whose `output_mode` is `content` |
+| `tool` | `name`; `skill` on a `Skill` call; `searched` (one path) on a Claude Code `Grep` call whose `path` is given and whose `output_mode` is `content`; `searched` (the call's `paths`, one or a list) on a Copilot `grep` call whose `output_mode` is `content` and whose result is not empty, `No matches found.` or a failure |
| `probe` | `target`, `pattern`, `text`, `rc`: written by the runner after the `command` event it matched, never by a converter ([§4.1](repo-evaluation-contract.md#41-eventsjsonl)) |
| `choice` | `candidate`, `act` (install, import, use or remove), `path` (edit path or null). The runner writes these after their source event when the run names candidates. |
| `turn` | `turn` (the model call's index in the trace, from 0; a subagent's calls count too); `input` (uncached input), `output` (`null` on a Claude turn: its assistant records carry the output count from the start of the stream, not the call's billed count), `cache_read`, `cache_write`, `prompt_tokens` (the whole prompt: `input + cache_read + cache_write`); each `null` when the harness reported no such count (a Claude `prompt_tokens` sums the parts it reported, so it is low when a part is `null`) |
diff --git a/dokimi/docs/repo-evaluation-contract.md b/dokimi/docs/repo-evaluation-contract.md
index a85f33f63..0222dd0d1 100644
--- a/dokimi/docs/repo-evaluation-contract.md
+++ b/dokimi/docs/repo-evaluation-contract.md
@@ -660,7 +660,7 @@ parent's and subagents' together, so a grader need not:
| `failed_commands` | commands not denied whose `rc` is neither `0` nor `null` |
| `denied_commands` | commands with `denied: true` (a hook or the harness's permissions refused them) |
| `guidance_read` | sorted, distinct workspace paths (normalized: `./a`, `a/../b`; not `~`; a `..` after a link is followed as the system does, by the links the workspace had at the start, not collapsed: `alias/../AGENTS.md` with `alias -> docs/nested` is `docs/AGENTS.md`) of `read` events, neither denied nor failed (`rc` 1: the file does not exist), that `guidance.globs` match. A read event is a read tool's (Claude Code's Read, Copilot's `view`) or a shell read: a Claude Code Bash call, Codex command or Copilot `bash` command that only prints files, as §7 lists (a bare `cat`, `head`, `tail`, `nl` or `sed -n`, timed too: `time cat AGENTS.md`, `X=1 time cat AGENTS.md`, or after `command`: `command cat AGENTS.md`, not after `env`, which runs a program, never a builtin: `env command cat AGENTS.md` and `env builtin cat AGENTS.md` run no `cat`; `cd
; cat AGENTS.md` reads `/AGENTS.md`; not a call of a shell function of that name the same Bash call defined (Claude Code starts each call in a new shell, which keeps no function of an earlier call): `cat() { echo hi; }; cat AGENTS.md`, `\cat AGENTS.md` and `cat() ( echo hi ); cat AGENTS.md` too, is no read, as bash runs the function, nor one after a function named `command`, `env`, `builtin` or `time`, not the keyword: `command() { echo hi; }; command cat AGENTS.md`). A command that is one such read naming one file, alone, the one command of a brace group (`{ cat AGENTS.md; }`) or after `cd` commands (`cd sub && cat AGENTS.md`; `time cd`, `command cd`, `builtin cd`, `X=1 cd`, a quoted or escaped `"cd"` or `\cd` too, not `env cd`) or a virtualenv's activate (`source .venv/bin/activate && cat AGENTS.md`, `source 'my env/bin/activate'` too), and fails is no read; one naming two keeps its reads, even when only one is known (`cd -; cat missing.md /ws/AGENTS.md`). Because such a call cannot say which of its files failed, a path counts only when the workspace held that guidance file when the agent started, the arm's files included, also when the path leads to it through a link (`alias/AGENTS.md` with `alias -> docs`), by the links the workspace had at the start, so a link the agent removes or retargets later does not unlist a read it made through it: a path that never existed (`cat docs/AGENTS.md 2>/dev/null` in a workspace without it), a link that dangles or loops (also one that returns to a directory through a `..` component: `alias -> alias/../docs`, and one whose target goes `..` out of a name that was no directory at the start: `alias -> missing/../docs`, which the system refuses), a file the arm removed and a file the agent created itself are not listed. Guidance seen through a pipe, `grep` or `rg` is not a read here (a search is `guidance_searched`), nor is a relative read after an earlier Claude Code Bash call ran a `cd` (`time cd` and `command cd` too), `pushd`, `popd`, or an `eval`, `source` or `.` (which may run one; not `source .venv/bin/activate`, a virtualenv's activate script alone, assumed to run none, §7), its name quoted or escaped too (`"source" "$ENV"`, `\cd "$D"`), or called a shell function whose body names one of these (`f() { cd sub; }` defined in that call; `source` and `.` only as a command, not of an activate script: `f() { git add .; }` names none), in its own shell, not in a subshell, pipeline or background job (the shell keeps its directory between calls, so the file is not known; a call a hook or the permissions refused ran nothing, so it moves nothing). That holds across agents: after the parent's `cd`, a subagent's relative reads are dropped too, and the reverse, since a subagent may share the parent's shell (not checked on a real trace; dropping a read is the safe side either way); to count those, add a `process_metrics` counter on the command text (§2), which also counts denied commands, unlike this row |
-| `guidance_searched` | sorted, distinct workspace paths, normalized (a `..` after a link followed, as in `guidance_read`) and filtered as `guidance_read` is (`guidance.globs` match, the workspace held the file when the agent started), of the files a search showed lines of: the `searched` list of a `command` event not refused, or of a Claude Code `Grep` `tool` event ([events format](events-format.md)). A search is not a read: it adds no `read` event, so `tool_calls` and `guidance_read` stay as they were, and a file both printed and searched is in both lists. A part of a Claude Code Bash call, Codex command or Copilot `bash` command is a search when it runs `grep`, `egrep`, `fgrep`, `rg` or `git grep` (`/bin/grep` and `command grep` too, `git --no-pager grep`, `git -P grep` and `git -c k=v grep`, not `git -C dir grep`, nor a shell function of that name the same call defined) and names the file as an operand: past the pattern, after `-e` or `--` (`-ewarn` and `-nefoo`, with the expression attached, too), not the value of an option (`-m 1`) nor a pattern file (`-f F`, `-fF`); `git grep` takes the paths after `--` or after the pattern. The `cd` rules are `guidance_read`'s (`cd sub && grep x AGENTS.md` searches `sub/AGENTS.md`; a relative file after an earlier call's `cd` is dropped, and is not added to `unknown_reads`, which counts reads only). A `Grep` call counts when it has a `path` and `output_mode` `content` (a relative `path` starts at the directory the harness started in, as a Bash call does, and is dropped after an earlier Bash call that may have moved the shell, as a relative Bash search is): Claude Code's default mode (`files_with_matches`) and `count` print no line of a file, and nor does a result that is empty or says `No matches found` (also an `offset` past the last line), as an error result does not. Not counted, since no line of the file reached the agent or no file is named: `-q`, `--quiet`, `--silent`, `-l`, `--files-with-matches`, `-L`, `--files-without-match` (not rg's `-L`, which follows links), `-c`, `--count`, `--count-matches`, `-V` and rg's `--files` and `-h` (`grep -h` is `--no-filename` and stays a search; for `grep`, an unambiguous prefix of a long option too, also one that takes a value: `--qui`, `--cou`, `--exclude-d AGENTS.md`, whose `AGENTS.md` is no operand; rg reads none); a directory operand (`grep -r x docs`, `rg x docs` name no guidance file); a glob or a computed operand (`*.md`, `$f`, `$(ls)`); stdout redirected to a file or `/dev/null`; stdin (`cat AGENTS.md \| grep x`, which is not a read either); a negated (`! grep`), subshell or refused command. A search piped only into `head` or `tail` with known options (`grep x AGENTS.md \| head -n 20`, `\| head -n 20 2>/dev/null`, `\|& head`, `\| /usr/bin/head` and `\| LC_ALL=C head` too; also after `if`, `while` or `then`) counts; a pipe into any other stage, a `head` or `tail` that names a file, takes an unknown option or a value the tool refuses (`tail --follow=bad`, `--pid=x`, `-s x`, `-n x`; `--follow=name` too, which tail refuses for its input before it prints a line), `--help` or `--version`, passes no line (`-n 0`, `-c 0`) or is a shell function the same call defined, does not. A search of several files lists every file it named when its command showed a line, without attributing the lines to files (`grep visible AGENTS.md docs/AGENTS.md` whose output is only `AGENTS.md:1:visible` lists both). A search that fails as one search of one file (`rc` 1: no line matched, or 2: an error; for Claude Code any nonzero exit) is no search of it, as a failed one-file read is no read; one naming several files, when every search of the command is in its last part (`grep x AGENTS.md sub/AGENTS.md`, `echo hi; grep x AGENTS.md`, `cd sub && grep x AGENTS.md \| head`), loses them all on `rc` 1 (no line matched in any of them) and, for Claude Code, on any error; on another `rc` (2: an error, perhaps in one file of several) or when an earlier part also searched (`grep a A.md; grep b B.md`, whose exit says nothing of the first), it keeps them, as a multi-file read does; unless the trace gives the command's result as the empty text, which no search showed a line in (`grep x AGENTS.md \| head` exits 0 with nothing matched; a result that is absent from the trace is not taken for empty). A Copilot `grep` tool call and a PowerShell command are not parsed |
+| `guidance_searched` | sorted, distinct workspace paths, normalized (a `..` after a link followed, as in `guidance_read`) and filtered as `guidance_read` is (`guidance.globs` match, the workspace held the file when the agent started), of the files a search showed lines of: the `searched` list of a `command` event not refused, or of a Claude Code `Grep` or Copilot `grep` `tool` event ([events format](events-format.md)). A search is not a read: it adds no `read` event, so `tool_calls` and `guidance_read` stay as they were, and a file both printed and searched is in both lists. A part of a Claude Code Bash call, Codex command or Copilot `bash` command is a search when it runs `grep`, `egrep`, `fgrep`, `rg` or `git grep` (`/bin/grep` and `command grep` too, `git --no-pager grep`, `git -P grep` and `git -c k=v grep`, not `git -C dir grep`, nor a shell function of that name the same call defined) and names the file as an operand: past the pattern, after `-e` or `--` (`-ewarn` and `-nefoo`, with the expression attached, too), not the value of an option (`-m 1`) nor a pattern file (`-f F`, `-fF`); `git grep` takes the paths after `--` or after the pattern. The `cd` rules are `guidance_read`'s (`cd sub && grep x AGENTS.md` searches `sub/AGENTS.md`; a relative file after an earlier call's `cd` is dropped, and is not added to `unknown_reads`, which counts reads only). A `Grep` call counts when it has a `path` and `output_mode` `content` (a relative `path` starts at the directory the harness started in, as a Bash call does, and is dropped after an earlier Bash call that may have moved the shell, as a relative Bash search is): Claude Code's default mode (`files_with_matches`) and `count` print no line of a file, and nor does a result that is empty or says `No matches found` (also an `offset` past the last line), as an error result does not. Not counted, since no line of the file reached the agent or no file is named: `-q`, `--quiet`, `--silent`, `-l`, `--files-with-matches`, `-L`, `--files-without-match` (not rg's `-L`, which follows links), `-c`, `--count`, `--count-matches`, `-V` and rg's `--files` and `-h` (`grep -h` is `--no-filename` and stays a search; for `grep`, an unambiguous prefix of a long option too, also one that takes a value: `--qui`, `--cou`, `--exclude-d AGENTS.md`, whose `AGENTS.md` is no operand; rg reads none); a directory operand (`grep -r x docs`, `rg x docs` name no guidance file); a glob or a computed operand (`*.md`, `$f`, `$(ls)`); stdout redirected to a file or `/dev/null`; stdin (`cat AGENTS.md \| grep x`, which is not a read either); a negated (`! grep`), subshell or refused command. A search piped only into `head` or `tail` with known options (`grep x AGENTS.md \| head -n 20`, `\| head -n 20 2>/dev/null`, `\|& head`, `\| /usr/bin/head` and `\| LC_ALL=C head` too; also after `if`, `while` or `then`) counts; a pipe into any other stage, a `head` or `tail` that names a file, takes an unknown option or a value the tool refuses (`tail --follow=bad`, `--pid=x`, `-s x`, `-n x`; `--follow=name` too, which tail refuses for its input before it prints a line), `--help` or `--version`, passes no line (`-n 0`, `-c 0`) or is a shell function the same call defined, does not. A search of several files lists every file it named when its command showed a line, without attributing the lines to files (`grep visible AGENTS.md docs/AGENTS.md` whose output is only `AGENTS.md:1:visible` lists both). A search that fails as one search of one file (`rc` 1: no line matched, or 2: an error; for Claude Code any nonzero exit) is no search of it, as a failed one-file read is no read; one naming several files, when every search of the command is in its last part (`grep x AGENTS.md sub/AGENTS.md`, `echo hi; grep x AGENTS.md`, `cd sub && grep x AGENTS.md \| head`), loses them all on `rc` 1 (no line matched in any of them) and, for Claude Code, on any error; on another `rc` (2: an error, perhaps in one file of several) or when an earlier part also searched (`grep a A.md; grep b B.md`, whose exit says nothing of the first), it keeps them, as a multi-file read does; unless the trace gives the command's result as the empty text, which no search showed a line in (`grep x AGENTS.md \| head` exits 0 with nothing matched; a result that is absent from the trace is not taken for empty). A Copilot `grep` tool call counts under the rules of a `Grep` call: its `paths` (one string or a list, each resolved from the start directory as a `view` path is; an empty or non-string entry names nothing) in `output_mode` `content`, not the default mode, `files_with_matches` or `count`, and not a call with no `paths`; a failed result, an empty one or `No matches found.` drops it, and a relative path is not dropped after an earlier `bash` call's `cd`, as `view`'s is not. A PowerShell command is not parsed |
| `unknown_reads` | the relative shell reads, of calls neither refused nor failed as one read of one file (see `guidance_read`; `cd -; cat missing.md` failing counts none), that the trace made at a directory the converter could not follow (after `source env.sh`, `cd -`, a call of a function that runs a `cd`, or a `cd` in an earlier Claude Code Bash call): they have no `read` event, so `guidance_read` may miss them; `0` when there are none |
| `counters` | each `process_metrics` name (§2) and its count |
diff --git a/dokimi/dokimi/repos/cli_traces.py b/dokimi/dokimi/repos/cli_traces.py
index 36af1f61a..69f329450 100644
--- a/dokimi/dokimi/repos/cli_traces.py
+++ b/dokimi/dokimi/repos/cli_traces.py
@@ -369,7 +369,23 @@ def _copilot_tool(data: dict[str, Any], t: float | None, workdir: str | None, cw
return [{"t": t, "kind": "edit", "path": relative_path(_from_cwd(p.strip(), cwd), workdir),
**({"deleted": True} if verb == "Delete" else {})}
for verb, p in _PATCH_FILE.findall(text)]
- return [{"t": t, "kind": "tool", "name": name}]
+ event: dict[str, Any] = {"t": t, "kind": "tool", "name": name}
+ if name == "grep" and obj.get("output_mode") == "content": # the other modes list file names or counts
+ event.update(searched_field([_from_cwd(p, cwd) for p in _grep_paths(obj.get("paths"))], workdir))
+ return [event]
+
+
+def _grep_paths(paths: Any) -> list[str]:
+ """The ``paths`` of a Copilot ``grep`` call: one string or a list; an empty or non-string entry names nothing."""
+ entries = [paths] if isinstance(paths, str) else paths if isinstance(paths, list) else []
+ return [p for p in entries if isinstance(p, str) and p]
+
+
+def _grep_found_nothing(data: dict[str, Any]) -> bool:
+ """A ``grep`` completion that failed, or whose content is empty or the CLI's ``No matches found.``."""
+ result = data.get("result")
+ content = result.get("content") if isinstance(result, dict) else None
+ return data.get("success") is False or (isinstance(content, str) and content.strip() in ("", "No matches found."))
def _copilot_result(out: Transcript, call: _Derived, data: dict[str, Any]) -> None:
@@ -379,6 +395,8 @@ def _copilot_result(out: Transcript, call: _Derived, data: dict[str, Any]) -> No
reads = [e for e in events if e["kind"] == "read"]
failed = data.get("success") is False
for event in events:
+ if event["kind"] == "tool" and _grep_found_nothing(data):
+ event.pop("searched", None) # a failed grep, or one with no match, showed no line
if event["kind"] == "edit" and data.get("success") is not None:
event["rc"] = 0 if data.get("success") else 1
if event["kind"] != "command":
diff --git a/dokimi/dokimi/repos/process_metrics.py b/dokimi/dokimi/repos/process_metrics.py
index d4d30222b..634373dda 100644
--- a/dokimi/dokimi/repos/process_metrics.py
+++ b/dokimi/dokimi/repos/process_metrics.py
@@ -19,7 +19,7 @@
tells them): a multi-file read (``cat a missing``) keeps its reads, as its exit does not say which file failed;
- ``guidance_searched``: the sorted workspace paths, under the same rules as ``guidance_read``, in the ``searched`` list of
a ``command`` event not denied (a ``grep``, ``egrep``, ``fgrep``, ``rg`` or ``git grep`` that showed lines of the file) or of
- a Claude Code ``Grep`` ``tool`` event (``output_mode`` ``content``). The files are not in ``guidance_read``, and the
+ a Claude Code ``Grep`` or Copilot ``grep`` ``tool`` event (``output_mode`` ``content``). The files are not in ``guidance_read``, and the
search is no ``read`` event, so ``tool_calls`` does not count it;
- ``unknown_reads``: the relative shell reads the trace made at a directory the converter could not follow
(after ``source env.sh``, say), which have no ``read`` event: ``guidance_read`` may miss them. It comes from
diff --git a/dokimi/tests/test_repo_copilot_grep.py b/dokimi/tests/test_repo_copilot_grep.py
new file mode 100644
index 000000000..d90f446c0
--- /dev/null
+++ b/dokimi/tests/test_repo_copilot_grep.py
@@ -0,0 +1,115 @@
+# Copyright (C) 2026 Intel Corporation
+# SPDX-License-Identifier: Apache-2.0
+
+"""A Copilot CLI ``grep`` tool call over a guidance file, in ``guidance_searched`` (contract §4.1). No LLM."""
+
+from __future__ import annotations
+
+import json
+from typing import Any
+
+import pytest
+
+from dokimi.repos.events import convert
+from dokimi.repos.process_metrics import process_metrics
+
+WS = "/ws"
+HIT = "AGENTS.md:3:- warn: always lint"
+
+
+def _jsonl(*records: dict[str, Any]) -> str:
+ return "\n".join(json.dumps(r) for r in records) + "\n"
+
+
+def _call(call_id: str, name: str, arguments: Any, complete: dict[str, Any] | None = None) -> list[dict[str, Any]]:
+ start = {"type": "tool.execution_start", "data": {"toolCallId": call_id, "toolName": name, "arguments": arguments}}
+ done = {"type": "tool.execution_complete", "data": {"toolCallId": call_id, "success": True, **(complete or {})}}
+ return [start, done]
+
+
+# The grep arguments follow the Copilot CLI 1.0.75 argument schema (`paths`, `output_mode`); this is not a recorded trace.
+def _grep(arguments: dict[str, Any], content: str | None = HIT, success: bool = True) -> list[dict[str, Any]]:
+ complete: dict[str, Any] = {"success": success}
+ if content is not None:
+ complete["result"] = {"content": content}
+ return _call("g", "grep", {"pattern": "warn", **arguments}, complete)
+
+
+def _searched(records: list[dict[str, Any]], cwd: str = "") -> list[str]:
+ t = convert("copilot-json", _jsonl(*records), WS, cwd)
+ return process_metrics(t.events, lambda p: p.endswith("AGENTS.md"), unknown_reads=t.unknown_reads)["guidance_searched"]
+
+
+def test_a_content_grep_over_a_guidance_file_is_searched_not_read():
+ """§4.1 ``guidance_searched``: a Copilot ``grep`` in ``content`` mode over a file is a search, no ``read`` event."""
+ with_grep = convert("copilot-json", _jsonl(*_grep({"paths": "AGENTS.md", "output_mode": "content"})), WS)
+ assert with_grep.events == [{"t": None, "kind": "tool", "name": "grep", "searched": ["AGENTS.md"]}]
+ assert not any(e["kind"] == "read" for e in with_grep.events)
+ metrics = process_metrics(with_grep.events, lambda p: p.endswith("AGENTS.md"))
+ bare = process_metrics([{"t": None, "kind": "tool", "name": "grep"}], lambda p: p.endswith("AGENTS.md"))
+ assert metrics["guidance_searched"] == ["AGENTS.md"]
+ assert metrics["guidance_read"] == [] and metrics["tool_calls"] == bare["tool_calls"]
+
+
+def test_a_content_grep_over_a_list_of_paths_lists_each_string_entry():
+ """§4.1 ``guidance_searched``: ``paths`` is one string or a list; an empty or non-string entry names nothing."""
+ paths = ["AGENTS.md", "", 7, None, "docs/AGENTS.md"]
+ assert _searched(_grep({"paths": paths, "output_mode": "content"})) == ["AGENTS.md", "docs/AGENTS.md"]
+ for nothing in ([], [""], [3], 5, ""):
+ t = convert("copilot-json", _jsonl(*_grep({"paths": nothing, "output_mode": "content"})), WS)
+ assert t.events == [{"t": None, "kind": "tool", "name": "grep"}]
+
+
+@pytest.mark.parametrize("arguments", [
+ {"paths": "AGENTS.md"},
+ {"paths": "AGENTS.md", "output_mode": "files_with_matches"},
+ {"paths": "AGENTS.md", "output_mode": "count"},
+ {"output_mode": "content"},
+ {"path": "AGENTS.md", "output_mode": "content"},
+])
+def test_a_grep_that_prints_no_line_of_a_file_is_no_search(arguments):
+ """§4.1 ``guidance_searched``: the default mode, ``files_with_matches``, ``count`` and a call with no ``paths``."""
+ t = convert("copilot-json", _jsonl(*_grep(arguments)), WS)
+ assert t.events == [{"t": None, "kind": "tool", "name": "grep"}]
+
+
+@pytest.mark.parametrize("content, success", [
+ ("No matches found.", True), (" No matches found.\n", True), ("", True), (HIT, False)])
+def test_a_grep_with_no_match_or_a_failure_is_no_search(content, success):
+ """§4.1 ``guidance_searched``: a no-match, empty or failed result drops the search."""
+ records = _grep({"paths": "AGENTS.md", "output_mode": "content"}, content, success)
+ assert _searched(records) == []
+ assert convert("copilot-json", _jsonl(*records), WS).events == [{"t": None, "kind": "tool", "name": "grep"}]
+
+
+def test_a_grep_whose_result_is_not_in_the_trace_keeps_its_search():
+ records = _grep({"paths": "AGENTS.md", "output_mode": "content"})[:1]
+ assert _searched(records) == ["AGENTS.md"]
+
+
+def test_a_directory_in_paths_is_kept_but_not_counted():
+ """§4.1 ``guidance_searched``: ``process_metrics`` keeps guidance files only, so a directory is not counted."""
+ records = _grep({"paths": ["docs"], "output_mode": "content"})
+ assert convert("copilot-json", _jsonl(*records), WS).events[0]["searched"] == ["docs"]
+ assert _searched(records) == []
+
+
+def test_a_relative_path_starts_at_the_start_directory_as_a_views_does():
+ """§4.1 ``guidance_searched``: a relative ``paths`` entry is resolved from ``cwd``, as ``view``'s ``path`` is."""
+ records = _grep({"paths": "AGENTS.md", "output_mode": "content"})
+ assert _searched(records, "sub") == ["sub/AGENTS.md"]
+ view = _call("v", "view", {"path": "AGENTS.md"})
+ assert convert("copilot-json", _jsonl(*view), WS, "sub").reads() == {"sub/AGENTS.md"}
+
+
+def test_a_relative_path_after_a_cd_in_an_earlier_bash_call_is_resolved_as_a_views_is():
+ """§4.1 ``guidance_searched``: the Copilot converter does not track a moved shell, for ``view`` nor ``grep``."""
+ cd = _call("c", "bash", {"command": "cd sub"}, {"shellExecution": {"exitCode": 0}})
+ view = _call("v", "view", {"path": "AGENTS.md"})
+ assert convert("copilot-json", _jsonl(*cd, *view), WS).reads() == {"AGENTS.md"}
+ assert _searched([*cd, *_grep({"paths": "AGENTS.md", "output_mode": "content"})]) == ["AGENTS.md"]
+
+
+def test_a_grep_with_arguments_that_are_not_an_object_stays_a_bare_tool_event():
+ t = convert("copilot-json", _jsonl(*_call("g", "grep", "warn AGENTS.md")), WS)
+ assert t.events == [{"t": None, "kind": "tool", "name": "grep"}] and t.dropped_lines == 0