|
| 1 | +--- |
| 2 | +id: partio-attach-manual-session-link |
| 3 | +target_repos: |
| 4 | + - cli |
| 5 | +pr_labels: |
| 6 | + - minion |
| 7 | +acceptance_criteria: |
| 8 | + - "`partio attach <session-id>` links a previously untracked session to the most recent commit" |
| 9 | + - "`partio attach <session-id> <commit-hash>` links the session to the specified commit" |
| 10 | + - "Command validates that the session ID exists in the local sessions directory" |
| 11 | + - "Command creates a checkpoint on the orphan branch linking session to commit" |
| 12 | + - "Command fails gracefully with a helpful error if the session or commit is not found" |
| 13 | + - "Command is idempotent: re-attaching an already-linked session updates rather than duplicates" |
| 14 | +--- |
| 15 | + |
| 16 | +# Add `partio attach` command to manually link untracked sessions to commits |
| 17 | + |
| 18 | +## Description |
| 19 | + |
| 20 | +When Claude Code sessions are started outside the normal pre-commit hook flow — for example, when Partio wasn't enabled at session start, when the agent was launched from a parent directory before the repo was initialized, or when a session ran without triggering the pre-commit hook — users have no way to retroactively link those sessions to their commits. |
| 21 | + |
| 22 | +Add a `partio attach` command that accepts a session ID and optional commit hash, then creates a checkpoint on the `partio/checkpoints/v1` branch linking the session to that commit. |
| 23 | + |
| 24 | +``` |
| 25 | +partio attach <session-id> # link to HEAD |
| 26 | +partio attach <session-id> <commit-hash> # link to specific commit |
| 27 | +``` |
| 28 | + |
| 29 | +The command should: |
| 30 | +1. Validate the session ID exists in the local Claude sessions directory (via `internal/agent/claude`) |
| 31 | +2. Parse the session's JSONL transcript to extract metadata (prompt, context, files) |
| 32 | +3. Calculate attribution from the session data |
| 33 | +4. Write a checkpoint using the existing git plumbing machinery in `internal/checkpoint` |
| 34 | +5. Amend the target commit with the `Partio-Checkpoint: <id>` trailer (or print instructions if amending HEAD is not desirable) |
| 35 | + |
| 36 | +## Context Hints |
| 37 | + |
| 38 | +- `cmd/partio/` — add new `attach` command |
| 39 | +- `internal/checkpoint/` — checkpoint creation logic |
| 40 | +- `internal/agent/claude/` — session discovery and JSONL parsing |
| 41 | +- `internal/session/` — session lifecycle types |
| 42 | +- `internal/git/` — git operations for commit amendment |
| 43 | + |
| 44 | +<!-- program: .minions/programs/partio-attach-manual-session-link.md --> |
0 commit comments