You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add Pi-Agent detection via process name and breadcrumb scanning (#21)
_This PR description was generated by AMP._ 🤖
## Summary
Adds detection for three new AI agents and fixes a false-positive
matching issue for short process names.
## Changes
### New agents (`src/agent.rs`)
**Pi-Agent** — process + breadcrumbs:
- Process: `pi` (exact match only — see below)
- Breadcrumbs: `~/.pi/agent/sessions/*.jsonl`
- Email: `Pi <noreply@pi.dev>`
- ℹ️ Pi is a Node.js CLI — `process.name()` returns `"node"`, not
`"pi"`. Detection works via `basename(argv[0])` which is `"pi"` (npm bin
shim). [Verified on a live Pi
session](#21).
**Copilot CLI** — process + breadcrumbs:
- Process: `copilot` (distinct from `copilot-agent` VS Code extension)
- Breadcrumbs: `~/.copilot/session-state/{session-id}/events.jsonl`
- Email: `Copilot <223556219+Copilot@users.noreply.github.com>`
([verified](github/copilot-cli#975))
- ⚠️ Placed after `copilot-agent` — `find_by_name` uses `contains()` so
the more specific entry must match first
**OpenCode** — process only:
- Process: `opencode`
- Email: `opencode <noreply@opencode.ai>`
([verified](anomalyco/opencode#786))
- No breadcrumbs — sessions stored in SQLite
(`~/.local/share/opencode/opencode.db`), TODO for future
### Bug fix: `exact_process_match` flag
Added `exact_process_match: bool` to the `Agent` struct. When `true`,
`find_by_name` requires the basename to equal the process name exactly
instead of using `contains()`.
**Problem**: The 2-character process name `pi` caused false positives —
e.g., bash's `argv[1]` containing `pipefail` would match
`"pipefail".contains("pi")`.
**Fix**: Pi-Agent is the only agent with `exact_process_match: true`.
All other agents retain the default `false` (backward compatible).
Also added `Agent::default()` const fn so entries in `KNOWN_AGENTS` only
need to specify fields that differ from defaults, keeping the list
concise.
### `README.md`
- Updated breadcrumb examples and limitations to include Pi, Copilot
CLI, and OpenCode
## Testing
```bash
just run --debug # Verify Pi no longer false-positive matches on "pipefail" etc.
just run # Only detects actually running agents
```
---------
Co-authored-by: Amp <amp@ampcode.com>
Copy file name to clipboardExpand all lines: README.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ It finds agents in four ways:
7
7
1. It checks for agent-specific environment variables.
8
8
2. It walks its own process ancestry, under the assumption that the git commit was initiated by an agent.
9
9
3. It walks up the process tree and checks all descendants of siblings at each level, looking for agents working in the same repository.
10
-
4. It checks agent-specific state files ("breadcrumbs") to determine if an agent was recently active in this repo (e.g. `~/.claude/projects/`, `~/.codex/sessions/`).
10
+
4. It checks agent-specific state files ("breadcrumbs") to determine if an agent was recently active in this repo (e.g. `~/.claude/projects/`, `~/.codex/sessions/`, `~/.pi/agent/sessions/`).
11
11
12
12
Multiple agents can be attributed in a single commit. Results are deduplicated by email address.
**Process detection is not always possible.** Agents may exit before the commit runs, or use process names that don't match (e.g. Electron-based desktop apps). When process scanning fails, aittributor falls back to agent session history, checking state files for recent activity in the same repo. This fallback only works for agents that write state files (currently Claudeand Codex), and it cannot distinguish between an agent that wrote the code being committed and one that was only used for research. The result is a bias toward over-attribution, which is a deliberate tradeoff as undercounting real AI usage is harder to correct after the fact than occasional overcounting.
65
+
**Process detection is not always possible.** Agents may exit before the commit runs, or use process names that don't match (e.g. Electron-based desktop apps). When process scanning fails, aittributor falls back to agent session history, checking state files for recent activity in the same repo. This fallback only works for agents that write scannable state files (currently Claude, Codex, Copilot CLI, and Pi). Some agents like OpenCode store sessions in SQLite, which is not yet supported by the breadcrumb scanner, and it cannot distinguish between an agent that wrote the code being committed and one that was only used for research. The result is a bias toward over-attribution, which is a deliberate tradeoff as undercounting real AI usage is harder to correct after the fact than occasional overcounting.
66
66
67
67
**Agent-initiated commits are the most reliable.** Attribution is most accurate when the agent itself runs `git commit`. Manual commits while an agent session is open (or recently closed) are the main source of attribution that may not reflect actual code contribution.
0 commit comments