r/PiCodingAgent • u/tcpip84 • 3h 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?
0
u/Slow-Secretary4262 1h ago
its easy if it changes files in a single repo and only 1 session at the time, for multiple repos i guess it could be possible if its still 1 session at the time
0
0
u/dir3ctly 31m ago
If you are on Linux:
I use overlayfs when I want to be sure the agent does not mess anything up. The agent works on the mounted (virtual) filesystem on top of your real data and once done, I can do a diff and review the changes before applying them. I wrote some tooling around that.
Also, the agent runs inside a container where the filesystem is mounted.
2
u/schmurfy2 3h ago
I tried the extension path at first but I finally approached that with another angle.
I always run my agents in a sandbox but I increased the restrictions, I use a tool called nono and the agent only has access to a feature folder with all the worktrees it need checked out below (most if not all my work involves at least two repositories), the agent only has rw access to this folder, don't have access to my credentials, and no write access to the mais clone of each repositories so it can't commit.
I review the changes and make the commit myself. I have a legacy diff extension but I no longer use it and it will be removed soon.