|
| 1 | +--- |
| 2 | +name: agent-transcript |
| 3 | +description: "Add a redacted agent session transcript to a GitHub PR or issue body as local-only provenance for agent-authored workflows." |
| 4 | +--- |
| 5 | + |
| 6 | +# Agent Transcript |
| 7 | + |
| 8 | +Best-effort local-only provenance for agent-authored PR/issue bodies. Use during agent-created GitHub PR or issue workflows before creating/updating the body. |
| 9 | + |
| 10 | +## Contract |
| 11 | + |
| 12 | +- Never use network. Session discovery reads local agent logs only. |
| 13 | +- Never upload raw logs. Render sanitized Markdown first. |
| 14 | +- Always ask the user before adding transcript logs to a GitHub PR/issue body. |
| 15 | +- Tell the user sanitized session logs help reviewers and can make PRs easier to prioritize. |
| 16 | +- Offer a local HTML preview before insertion. If the user wants preview, open it and wait for confirmation before adding the section. |
| 17 | +- Fail closed on unresolved secrets, private keys, browser/session/cookie details, or auth URLs. |
| 18 | +- Drop system/developer prompts, raw tool outputs, reasoning, env, cookies, tokens, and broad local paths. |
| 19 | +- Keep user prompts, assistant visible decisions, terse tool summaries, and test/proof outcomes. |
| 20 | +- Automatically trim the rendered transcript before showing it, previewing it, or inserting it into a public body. Never paste the raw full-session render into a PR/issue body just because `render` or `append-body` produced it. |
| 21 | +- Remove session turns unrelated to the PR/issue work. Use the PR/issue title, branch name, changed files, and stated goal as scope; omit earlier/later unrelated tasks even when they are in the same session log. |
| 22 | +- Best effort only: PR/issue creation must continue if no safe transcript is found. |
| 23 | +- Add the `## Agent Transcript` section only when inserting a real transcript. Never add a placeholder transcript heading or text such as "A sanitized local transcript preview was generated but not included." |
| 24 | +- Use a collapsed `<details>` section and update existing markers instead of duplicating sections. |
| 25 | + |
| 26 | +## Helper |
| 27 | + |
| 28 | +```bash |
| 29 | +.agents/skills/agent-transcript/scripts/agent-transcript --help |
| 30 | +``` |
| 31 | + |
| 32 | +Find a likely local session: |
| 33 | + |
| 34 | +```bash |
| 35 | +.agents/skills/agent-transcript/scripts/agent-transcript find \ |
| 36 | + --query "$PR_TITLE $BRANCH_OR_PR_URL" \ |
| 37 | + --cwd "$PWD" \ |
| 38 | + --since-days 14 |
| 39 | +``` |
| 40 | + |
| 41 | +`find` scans the newest 400 matching local JSONL logs by default across Codex, Claude, Pi, and other local agent sessions. Use `--max-files N` for a wider local search. |
| 42 | + |
| 43 | +Render a PR/issue body section: |
| 44 | + |
| 45 | +```bash |
| 46 | +.agents/skills/agent-transcript/scripts/agent-transcript render \ |
| 47 | + --session "$SESSION_JSONL" \ |
| 48 | + --scope-query "$PR_TITLE $BRANCH_OR_PR_URL" \ |
| 49 | + --out /tmp/agent-transcript.md |
| 50 | +``` |
| 51 | + |
| 52 | +Preview one candidate session locally: |
| 53 | + |
| 54 | +```bash |
| 55 | +.agents/skills/agent-transcript/scripts/agent-transcript preview \ |
| 56 | + --session "$SESSION_JSONL" \ |
| 57 | + --scope-query "$PR_TITLE $BRANCH_OR_PR_URL" \ |
| 58 | + --out /tmp/agent-transcript-preview.html |
| 59 | +open /tmp/agent-transcript-preview.html |
| 60 | +``` |
| 61 | + |
| 62 | +Append/update a body file before `gh pr create --body-file` or connector PR creation: |
| 63 | + |
| 64 | +```bash |
| 65 | +.agents/skills/agent-transcript/scripts/agent-transcript append-body \ |
| 66 | + --body /tmp/pr-body.md \ |
| 67 | + --session "$SESSION_JSONL" \ |
| 68 | + --scope-query "$PR_TITLE $BRANCH_OR_PR_URL" \ |
| 69 | + --out /tmp/pr-body.with-transcript.md |
| 70 | +``` |
| 71 | + |
| 72 | +## PR/Issue Workflow |
| 73 | + |
| 74 | +1. Draft the normal PR/issue body first. |
| 75 | +2. Run `find` with title, branch, PR URL/number if known, and cwd. |
| 76 | +3. If a high-confidence session is found, ask: |
| 77 | + `Include a redacted agent transcript? It helps reviewers and can make the PR easier to prioritize. I can open a local preview first.` |
| 78 | +4. If the user wants preview, run `preview`, open the HTML with `open`, and wait for confirmation. |
| 79 | +5. Render or append to a temp body, then automatically trim the `## Agent Transcript` section before showing it to the user or inserting it publicly. Keep only turns that explain this PR/issue's goal, implementation choices, files, tests, proof, blockers, and final outcome. |
| 80 | +6. Inspect the trimmed transcript text. If it still includes unrelated earlier/later work, trim again before proceeding. |
| 81 | +7. If the user approves, use the enriched trimmed body file for creation/update. |
| 82 | +8. If no safe session is found, say nothing and continue without transcript. If the user declines, continue without transcript and do not add any transcript placeholder section. |
| 83 | + |
| 84 | +## Validate |
| 85 | + |
| 86 | +```bash |
| 87 | +node --test .agents/skills/agent-transcript/scripts/agent-transcript.test.mjs |
| 88 | +``` |
| 89 | + |
| 90 | +## Review Artifacts |
| 91 | + |
| 92 | +For manual audits across many PR/session candidates, create a local HTML preview from a local JSON file. This is for maintainers only and is not part of the PR/issue workflow: |
| 93 | + |
| 94 | +```bash |
| 95 | +.agents/skills/agent-transcript/scripts/agent-transcript html \ |
| 96 | + --prs /tmp/recent-prs.json \ |
| 97 | + --out /tmp/agent-transcript-preview.html |
| 98 | +``` |
0 commit comments