evals: use pre-commit hooks

This commit is contained in:
Drew Ritter
2026-05-06 15:41:52 -07:00
committed by Drew Ritter
parent 35e42a16ce
commit 7f02ccd91b
14 changed files with 244 additions and 63 deletions

View File

@@ -1,11 +1,12 @@
from __future__ import annotations
import json
import subprocess
from contextlib import suppress
from pathlib import Path
from setup_helpers.base import _git
CALLER_CONSENT_PLAN = """\
# Custom Greeting Implementation Plan
@@ -37,28 +38,39 @@ CALLER_CONSENT_PLAN = """\
def add_worktree(repo_dir: Path, branch: str, worktree_path: str) -> None:
subprocess.run(
["git", "worktree", "add", "-b", branch, worktree_path],
cwd=repo_dir, check=True, capture_output=True,
cwd=repo_dir,
check=True,
capture_output=True,
)
def detach_head(worktree_path: str) -> None:
result = subprocess.run(
["git", "rev-parse", "HEAD"], cwd=worktree_path,
capture_output=True, text=True, check=True,
["git", "rev-parse", "HEAD"],
cwd=worktree_path,
capture_output=True,
text=True,
check=True,
)
commit = result.stdout.strip()
result = subprocess.run(
["git", "branch", "--show-current"], cwd=worktree_path,
capture_output=True, text=True, check=True,
["git", "branch", "--show-current"],
cwd=worktree_path,
capture_output=True,
text=True,
check=True,
)
branch = result.stdout.strip()
subprocess.run(
["git", "checkout", "--detach", commit], cwd=worktree_path,
check=True, capture_output=True,
["git", "checkout", "--detach", commit],
cwd=worktree_path,
check=True,
capture_output=True,
)
if branch:
subprocess.run(
["git", "branch", "-D", branch], cwd=worktree_path,
["git", "branch", "-D", branch],
cwd=worktree_path,
capture_output=True,
)
@@ -93,10 +105,8 @@ def link_gemini_extension(workdir: Path, superpowers_root: str) -> None:
extension_name = "superpowers"
manifest = Path(superpowers_root) / "gemini-extension.json"
if manifest.exists():
try:
with suppress(json.JSONDecodeError):
extension_name = json.loads(manifest.read_text()).get("name", extension_name)
except json.JSONDecodeError:
pass
# Gemini extensions are global; replace any prior link so this run tests
# the requested SUPERPOWERS_ROOT checkout rather than a stale install.