r/PiCodingAgent • u/tcpip84 • 2h ago
Question How do you track which files a pi session changed, including edits made through bash?
I want to keep track of the files my pi session changes, and look them up at any point during the session. One session often touches 3 or 4 repos, so `git status` in pi's working dir doesn't give me that list.
I thought this would be easy: hook into `edit` and collect the changed files. But some models edit files through bash or python instead. In https://github.com/earendil-works/pi/issues/11876 a maintainer replied that this is model behaviour and pi can't do much about it. So how do you keep track of the files a session changed when some of the edits never go through `edit`?
What I have so far
I wrote a small extension that hooks `tool_result` for the `edit` and `write` tools:
- For each file, it runs `git rev-parse --show-toplevel` and records the file and its repo root in a JSON file for that session.
- It skips files that aren't in a git repo.
- A picker reads that list and opens a diff review for the repo I choose.
This works well for anything the model changes through `edit` or `write`.
The gap
The extension never sees changes the model makes through bash, such as `sed -i`, `perl -i`, or a `python3 - <<EOF` heredoc.
What I've looked at
- https://pi.dev/packages/pi-workspace-history It snapshots the workspace with git, so it does catch bash edits. But it tracks a single workspace, it's off in the home dir by default, and it skips nested repos, so it doesn't fit my setup.
- Running `git status` after every bash call in the repos the session already knows about. This catches bash edits in those repos, but it's expensive: one `git status` per known repo after every bash call. It also can't find a repo the session didn't already know about, so a repo the model only ever touched through bash is still missed.
- Blocking `sed -i` and similar commands in a permission-gate extension, with a message telling the model to use `edit`. That enforces the rule, but sometimes a bash edit is the right call, for example a rename across many files.
Has anyone found a reliable way to catch the files a model writes through bash?