feat: local drafter (pi against a self-run model server)

drafter: local runs the pi coding agent against the model resident on an
OpenAI-compatible server at the new local_url input, keyed by the
LOCAL_MODEL_API_KEY secret. It asks the server which model is loaded and
names exactly that one, so it never evicts the resident model. An
unreachable server or no loaded model posts the stage 1 flags with a note
and exits 0; a drafter that ran and failed still exits 1.

pi runs in the existing sandbox with read, ls, edit and write, every
project-local pi file and AGENTS.md ignored, stdin from /dev/null, the task
passed as an @file, and an allowlisted environment. As root with
DOCS_REVIEW_DRAFTER_USER set, it runs as that unprivileged user, which
owns only the sandbox and pi's temporary home.

Both drafters now hash the checkout's .git/config and .git/hooks before
drafting and stop with no further git command if either changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jaredandClaude Opus 5.5 committed 2026-11-12 16:28:21 -05:00
1 parent 9dea56ce98
commit 28b993cb23
14 files changed
+1042 -30

No files matched your search

+7 -2
View File
@@ -107,6 +107,8 @@ class DraftResult:
turns: int | None
text: str
error: str | None
# Who drafted, for the PR body; None means Claude Code, which reports a cost.
drafted_by: str | None = None
def parse_claude_output(stdout: str, returncode: int) -> DraftResult:
@@ -207,6 +209,9 @@ def render_pr_body(
if stage1:
parts.append("### Flags from stage 1\n\n" + "\n\n".join(stage1))
turns = "unknown" if result.turns is None else result.turns
cost = "unknown" if result.cost_usd is None else f"{result.cost_usd:.2f}"
parts.append(f"Drafted by Claude Code: {turns} turns, ${cost} estimated.")
if result.drafted_by is not None:
parts.append(f"Drafted by {result.drafted_by}: {turns} turns.")
else:
cost = "unknown" if result.cost_usd is None else f"{result.cost_usd:.2f}"
parts.append(f"Drafted by Claude Code: {turns} turns, ${cost} estimated.")
return "\n\n".join(parts) + "\n"