✨ feat: P-02 agent identity: machine and doctor with a classic token

Merged
AL
1mo ago
+1797-52

Roadmap P-02, agent identity (roadmap v1 in #2). The agent account uses one classic token: the owner's decision, recorded in docs/decisions.md.

  • process-rules machine [agent]: needs no client repo. It makes the agent's signing key, then opens GitHub's classic-token page with the note and scopes filled in (repo, workflow, read:org, project, write:ssh_signing_key). It reads the token through a hidden prompt into the keychain (service process-rules). It refuses a fine-grained token, missing scopes, or another account's token, and offers to replace a stored token in its last 14 days. Then it registers the key (API, else the browser) and writes ~/.config/process-rules/<agent>/session.sh, one folder per agent account.
  • process-rules doctor [agent]: checks the key pair, the token and its scopes, the key's registration and the session file. It names each failed step, including checks GitHub could not answer, and warns 14 days before the token ends.
  • Without [agent], both read the agent from .github/process-rules.json in the repo around the working directory.
  • The session file holds no secret. GH_TOKEN is read from the keychain on each use, and is a placeholder GitHub refuses when the keychain has none. Git's credential helpers are reset to one that gives the agent's token to github.com only. Inherited git-config injection and askpass are dropped. SSH is off, and GitHub SSH remotes go over HTTPS.
  • Moved to onboard (P-04): the push-access check and the Verified test commit. Those checks name a missing invite, an organisation's SAML authorisation, or its block on classic tokens.

Why not a separate gh config dir: with an empty GH_CONFIG_DIR, gh auth git-credential get still returned the owner's token from gh's shared keychain entry, and gh auth login there would overwrite it.

pnpm check: 111 tests pass; coverage 96% lines, 99% branches. Tests and docs name no client.

🤖 Generated with Claude Code