fix(trace): register checkouts that shell commands work in

Merged
JI
1d ago
+832-16

A traced session can work in a second checkout through shell commands only, for example in a fresh clone. Before this change, the trace did not see that checkout. Agent hooks run from the directory where the session started, so the clone got no git hooks, and its commits and pushes carried no session.

This change finds the checkout from the command text. The shell hooks read the command and get these directories from it:

  • the target of cd or pushd
  • the path of git -C
  • the folder that git clone or gh repo clone creates

The trace handles each directory the same as a file tool edit there: it installs the git hooks, records the session, and adds the checkout to the checkouts of the session. A hand-written tokenizer reads the command. This change adds no shell-parsing dependency.

Provider support:

  • Claude Code: supported.
  • OpenCode: supported. The plugin now sends the command text. A plugin installed by an earlier version must be installed again.
  • Cursor: partly supported, through the shell hooks from #3624. These hooks are verified for the Cursor IDE only. A relative path in the command resolves against the first workspace root.

Known limit: when one shell call clones a repository and also commits in it, that commit does not carry the session. The clone does not exist before the call, so the git hooks are installed only after the call.

Closes #3533 (PFM-7614)

AI disclosure: this change was made with Claude Code.