2026-03-12 12:44:15 +00:00
#!/usr/bin/env bash
2026-03-20 22:59:02 +00:00
# shellcheck disable=SC2015,SC2016
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
# review-pr.sh — Synchronous reviewer agent for a single PR
#
2026-03-12 12:44:15 +00:00
# Usage: ./review-pr.sh <pr-number> [--force]
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
#
# Architecture:
# Synchronous bash loop using claude -p (one-shot invocations).
# Session continuity via --resume and .sid file.
# Re-review resumes the original session — Claude remembers its prior review.
#
# Flow:
# 1. Fetch PR metadata (title, body, head, base, SHA, CI state)
# 2. Detect re-review (previous review at different SHA, incremental diff)
# 3. Create review worktree, checkout PR head
# 4. Build structural analysis graph
# 5. Load review formula
# 6. agent_run(worktree, prompt) → Claude reviews, writes verdict JSON
# 7. Parse verdict, post as Forge review (APPROVE / REQUEST_CHANGES / COMMENT)
# 8. Save session ID to .sid file for re-review continuity
#
# Session file: /tmp/review-session-{project}-{pr}.sid
2026-03-12 12:44:15 +00:00
set -euo pipefail
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
# Load shared environment and libraries
2026-03-12 12:44:15 +00:00
source " $( dirname " $0 " ) /../lib/env.sh "
2026-03-18 02:05:54 +00:00
source " $( dirname " $0 " ) /../lib/ci-helpers.sh "
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
source " $( dirname " $0 " ) /../lib/worktree.sh "
2026-03-28 06:32:12 +00:00
source " $( dirname " $0 " ) /../lib/agent-sdk.sh "
2026-04-01 09:39:57 +00:00
source " $( dirname " $0 " ) /../lib/formula-session.sh "
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
# Auto-pull factory code to pick up merged fixes before any logic runs
2026-03-17 19:35:29 +00:00
git -C " $FACTORY_ROOT " pull --ff-only origin main 2>/dev/null || true
2026-03-12 12:44:15 +00:00
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
# --- Config ---
2026-03-12 12:44:15 +00:00
PR_NUMBER = " ${ 1 : ?Usage : review-pr.sh <pr-number> [--force] } "
FORCE = " ${ 2 :- } "
fix: Replace Codeberg dependency with local Forgejo instance (#611)
- Add setup_forge() to bin/disinto: provisions Forgejo via Docker,
creates admin + bot users (dev-bot, review-bot), generates API
tokens, creates repo, and pushes code — all automated
- Rename env vars: CODEBERG_TOKEN→FORGE_TOKEN, REVIEW_BOT_TOKEN→
FORGE_REVIEW_TOKEN, CODEBERG_REPO→FORGE_REPO, CODEBERG_API→
FORGE_API, CODEBERG_WEB→FORGE_WEB, CODEBERG_BOT_USERNAMES→
FORGE_BOT_USERNAMES (with backwards-compat fallbacks)
- Rename API helpers: codeberg_api()→forge_api(), codeberg_api_all()
→forge_api_all() (with compat aliases)
- Add forge_url field to project TOML; load-project.sh derives
FORGE_API/FORGE_WEB from forge_url + repo
- Update parse_repo_slug() to accept any host URL, not just codeberg
- Forgejo data stored under ~/.disinto/forgejo/ (not in factory repo)
- Update all 58 files: agent scripts, formulas, docs, site HTML
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 16:57:12 +00:00
API = " ${ FORGE_API } "
2026-03-27 14:29:22 +00:00
LOGFILE = " ${ DISINTO_LOG_DIR } /review/review.log "
2026-03-20 22:59:02 +00:00
WORKTREE = " /tmp/ ${ PROJECT_NAME } -review- ${ PR_NUMBER } "
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
SID_FILE = " /tmp/review-session- ${ PROJECT_NAME } - ${ PR_NUMBER } .sid "
OUTPUT_FILE = " /tmp/ ${ PROJECT_NAME } -review-output- ${ PR_NUMBER } .json "
2026-03-14 13:49:09 +01:00
LOCKFILE = " /tmp/ ${ PROJECT_NAME } -review.lock "
STATUSFILE = " /tmp/ ${ PROJECT_NAME } -review-status "
2026-03-12 12:44:15 +00:00
MAX_DIFF = 25000
2026-03-20 22:59:02 +00:00
REVIEW_TMPDIR = $( mktemp -d)
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
2026-03-20 22:59:02 +00:00
log( ) { printf '[%s] PR#%s %s\n' " $( date -u '+%Y-%m-%d %H:%M:%S UTC' ) " " $PR_NUMBER " " $* " >> " $LOGFILE " ; }
status( ) { printf '[%s] PR #%s: %s\n' " $( date -u '+%Y-%m-%d %H:%M:%S UTC' ) " " $PR_NUMBER " " $* " > " $STATUSFILE " ; log " $* " ; }
2026-03-24 21:24:20 +00:00
cleanup( ) { rm -rf " $REVIEW_TMPDIR " " $LOCKFILE " " $STATUSFILE " " /tmp/ ${ PROJECT_NAME } -review-graph- ${ PR_NUMBER } .json " ; }
2026-03-12 12:44:15 +00:00
trap cleanup EXIT
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
# =============================================================================
# LOG ROTATION
# =============================================================================
2026-03-12 12:44:15 +00:00
if [ -f " $LOGFILE " ] && [ " $( stat -c%s " $LOGFILE " 2>/dev/null || echo 0) " -gt 102400 ] ; then
mv " $LOGFILE " " $LOGFILE .old "
fi
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
2026-04-01 09:39:57 +00:00
# =============================================================================
# RESOLVE AGENT IDENTITY FOR .PROFILE REPO
# =============================================================================
if [ -z " ${ AGENT_IDENTITY :- } " ] && [ -n " ${ FORGE_TOKEN :- } " ] ; then
AGENT_IDENTITY = $( curl -sf -H " Authorization: token ${ FORGE_TOKEN } " \
" ${ FORGE_URL :- http : //localhost : 3000 } /api/v1/user " 2>/dev/null | jq -r '.login // empty' 2>/dev/null || true )
fi
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
# =============================================================================
# MEMORY GUARD
# =============================================================================
memory_guard 1500
# =============================================================================
# CONCURRENCY LOCK
# =============================================================================
2026-03-12 12:44:15 +00:00
if [ -f " $LOCKFILE " ] ; then
2026-03-20 22:59:02 +00:00
LPID = $( cat " $LOCKFILE " 2>/dev/null || true )
[ -n " $LPID " ] && kill -0 " $LPID " 2>/dev/null && { log "SKIP: locked" ; exit 0; }
2026-03-12 12:44:15 +00:00
rm -f " $LOCKFILE "
fi
echo $$ > " $LOCKFILE "
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
# =============================================================================
# FETCH PR METADATA
# =============================================================================
2026-03-12 12:44:15 +00:00
status "fetching metadata"
fix: Replace Codeberg dependency with local Forgejo instance (#611)
- Add setup_forge() to bin/disinto: provisions Forgejo via Docker,
creates admin + bot users (dev-bot, review-bot), generates API
tokens, creates repo, and pushes code — all automated
- Rename env vars: CODEBERG_TOKEN→FORGE_TOKEN, REVIEW_BOT_TOKEN→
FORGE_REVIEW_TOKEN, CODEBERG_REPO→FORGE_REPO, CODEBERG_API→
FORGE_API, CODEBERG_WEB→FORGE_WEB, CODEBERG_BOT_USERNAMES→
FORGE_BOT_USERNAMES (with backwards-compat fallbacks)
- Rename API helpers: codeberg_api()→forge_api(), codeberg_api_all()
→forge_api_all() (with compat aliases)
- Add forge_url field to project TOML; load-project.sh derives
FORGE_API/FORGE_WEB from forge_url + repo
- Update parse_repo_slug() to accept any host URL, not just codeberg
- Forgejo data stored under ~/.disinto/forgejo/ (not in factory repo)
- Update all 58 files: agent scripts, formulas, docs, site HTML
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 16:57:12 +00:00
PR_JSON = $( curl -sf -H " Authorization: token ${ FORGE_TOKEN } " " ${ API } /pulls/ ${ PR_NUMBER } " )
2026-03-20 22:59:02 +00:00
PR_TITLE = $( printf '%s' " $PR_JSON " | jq -r '.title' )
PR_BODY = $( printf '%s' " $PR_JSON " | jq -r '.body // ""' )
PR_HEAD = $( printf '%s' " $PR_JSON " | jq -r '.head.ref' )
PR_BASE = $( printf '%s' " $PR_JSON " | jq -r '.base.ref' )
PR_SHA = $( printf '%s' " $PR_JSON " | jq -r '.head.sha' )
PR_STATE = $( printf '%s' " $PR_JSON " | jq -r '.state' )
2026-03-12 12:44:15 +00:00
log " ${ PR_TITLE } ( ${ PR_HEAD } → ${ PR_BASE } ${ PR_SHA : 0 : 7 } ) "
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
2026-03-12 12:44:15 +00:00
if [ " $PR_STATE " != "open" ] ; then
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
log " SKIP: state= ${ PR_STATE } "
worktree_cleanup " $WORKTREE "
rm -f " $OUTPUT_FILE " " $SID_FILE " 2>/dev/null || true
exit 0
2026-03-12 12:44:15 +00:00
fi
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
# =============================================================================
# CI CHECK
# =============================================================================
2026-03-23 17:19:01 +00:00
CI_STATE = $( ci_commit_status " $PR_SHA " )
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
CI_NOTE = ""
if ! ci_passed " $CI_STATE " ; then
2026-03-20 22:59:02 +00:00
ci_required_for_pr " $PR_NUMBER " && { log " SKIP: CI= ${ CI_STATE } " ; exit 0; }
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
CI_NOTE = " (not required — non-code PR)"
fi
# =============================================================================
# DUPLICATE CHECK — skip if already reviewed at this SHA
# =============================================================================
fix: Replace Codeberg dependency with local Forgejo instance (#611)
- Add setup_forge() to bin/disinto: provisions Forgejo via Docker,
creates admin + bot users (dev-bot, review-bot), generates API
tokens, creates repo, and pushes code — all automated
- Rename env vars: CODEBERG_TOKEN→FORGE_TOKEN, REVIEW_BOT_TOKEN→
FORGE_REVIEW_TOKEN, CODEBERG_REPO→FORGE_REPO, CODEBERG_API→
FORGE_API, CODEBERG_WEB→FORGE_WEB, CODEBERG_BOT_USERNAMES→
FORGE_BOT_USERNAMES (with backwards-compat fallbacks)
- Rename API helpers: codeberg_api()→forge_api(), codeberg_api_all()
→forge_api_all() (with compat aliases)
- Add forge_url field to project TOML; load-project.sh derives
FORGE_API/FORGE_WEB from forge_url + repo
- Update parse_repo_slug() to accept any host URL, not just codeberg
- Forgejo data stored under ~/.disinto/forgejo/ (not in factory repo)
- Update all 58 files: agent scripts, formulas, docs, site HTML
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 16:57:12 +00:00
ALL_COMMENTS = $( forge_api_all " /issues/ ${ PR_NUMBER } /comments " )
2026-03-20 22:59:02 +00:00
HAS_CMT = $( printf '%s' " $ALL_COMMENTS " | jq --arg s " $PR_SHA " \
'[.[]|select(.body|contains("<!-- reviewed: "+$s+" -->"))]|length' )
[ " ${ HAS_CMT :- 0 } " -gt 0 ] && [ " $FORCE " != "--force" ] && { log " SKIP: reviewed ${ PR_SHA : 0 : 7 } " ; exit 0; }
fix: Replace Codeberg dependency with local Forgejo instance (#611)
- Add setup_forge() to bin/disinto: provisions Forgejo via Docker,
creates admin + bot users (dev-bot, review-bot), generates API
tokens, creates repo, and pushes code — all automated
- Rename env vars: CODEBERG_TOKEN→FORGE_TOKEN, REVIEW_BOT_TOKEN→
FORGE_REVIEW_TOKEN, CODEBERG_REPO→FORGE_REPO, CODEBERG_API→
FORGE_API, CODEBERG_WEB→FORGE_WEB, CODEBERG_BOT_USERNAMES→
FORGE_BOT_USERNAMES (with backwards-compat fallbacks)
- Rename API helpers: codeberg_api()→forge_api(), codeberg_api_all()
→forge_api_all() (with compat aliases)
- Add forge_url field to project TOML; load-project.sh derives
FORGE_API/FORGE_WEB from forge_url + repo
- Update parse_repo_slug() to accept any host URL, not just codeberg
- Forgejo data stored under ~/.disinto/forgejo/ (not in factory repo)
- Update all 58 files: agent scripts, formulas, docs, site HTML
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 16:57:12 +00:00
HAS_FML = $( forge_api_all " /pulls/ ${ PR_NUMBER } /reviews " | jq --arg s " $PR_SHA " \
2026-03-20 22:59:02 +00:00
'[.[]|select(.commit_id==$s)|select(.state!="COMMENT")]|length' )
[ " ${ HAS_FML :- 0 } " -gt 0 ] && [ " $FORCE " != "--force" ] && { log "SKIP: formal review" ; exit 0; }
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
# =============================================================================
# RE-REVIEW DETECTION
# =============================================================================
2026-03-20 22:59:02 +00:00
PREV_CONTEXT = "" IS_RE_REVIEW = false PREV_SHA = ""
PREV_REV = $( printf '%s' " $ALL_COMMENTS " | jq -r --arg s " $PR_SHA " \
'[.[]|select(.body|contains("<!-- reviewed:"))|select(.body|contains($s)|not)]|last // empty' )
if [ -n " $PREV_REV " ] && [ " $PREV_REV " != "null" ] ; then
PREV_BODY = $( printf '%s' " $PREV_REV " | jq -r '.body' )
PREV_SHA = $( printf '%s' " $PREV_BODY " | grep -oP '<!-- reviewed: \K[a-f0-9]+' | head -1)
cd " ${ PROJECT_REPO_ROOT } " ; git fetch origin " $PR_HEAD " 2>/dev/null || true
INCR = $( git diff " ${ PREV_SHA } .. ${ PR_SHA } " 2>/dev/null | head -c " $MAX_DIFF " ) || true
if [ -n " $INCR " ] ; then
IS_RE_REVIEW = true; log " re-review: previous at ${ PREV_SHA : 0 : 7 } "
DEV_R = $( printf '%s' " $ALL_COMMENTS " | jq -r \
'[.[]|select(.body|contains("<!-- dev-response:"))]|last // empty' )
DEV_SEC = "" ; [ -n " $DEV_R " ] && [ " $DEV_R " != "null" ] && \
DEV_SEC = $( printf '\n### Developer Response\n%s' " $( printf '%s' " $DEV_R " | jq -r '.body' ) " ) || true
PREV_CONTEXT = $( printf '\n## This is a RE-REVIEW\nPrevious review at %s requested changes.\n### Previous Review\n%s%s\n### Incremental Diff (%s..%s)\n```diff\n%s\n```' \
" ${ PREV_SHA : 0 : 7 } " " $PREV_BODY " " $DEV_SEC " " ${ PREV_SHA : 0 : 7 } " " ${ PR_SHA : 0 : 7 } " " $INCR " )
2026-03-12 12:44:15 +00:00
fi
fi
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
# Recover session_id from .sid file (re-review continuity)
2026-03-28 06:34:26 +00:00
agent_recover_session
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
# =============================================================================
# FETCH DIFF
# =============================================================================
2026-03-12 12:44:15 +00:00
status "fetching diff"
fix: Replace Codeberg dependency with local Forgejo instance (#611)
- Add setup_forge() to bin/disinto: provisions Forgejo via Docker,
creates admin + bot users (dev-bot, review-bot), generates API
tokens, creates repo, and pushes code — all automated
- Rename env vars: CODEBERG_TOKEN→FORGE_TOKEN, REVIEW_BOT_TOKEN→
FORGE_REVIEW_TOKEN, CODEBERG_REPO→FORGE_REPO, CODEBERG_API→
FORGE_API, CODEBERG_WEB→FORGE_WEB, CODEBERG_BOT_USERNAMES→
FORGE_BOT_USERNAMES (with backwards-compat fallbacks)
- Rename API helpers: codeberg_api()→forge_api(), codeberg_api_all()
→forge_api_all() (with compat aliases)
- Add forge_url field to project TOML; load-project.sh derives
FORGE_API/FORGE_WEB from forge_url + repo
- Update parse_repo_slug() to accept any host URL, not just codeberg
- Forgejo data stored under ~/.disinto/forgejo/ (not in factory repo)
- Update all 58 files: agent scripts, formulas, docs, site HTML
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 16:57:12 +00:00
curl -s -H " Authorization: token ${ FORGE_TOKEN } " \
2026-03-20 22:59:02 +00:00
" ${ API } /pulls/ ${ PR_NUMBER } .diff " > " ${ REVIEW_TMPDIR } /full.diff "
FSIZE = $( stat -c%s " ${ REVIEW_TMPDIR } /full.diff " 2>/dev/null || echo 0)
DIFF = $( head -c " $MAX_DIFF " " ${ REVIEW_TMPDIR } /full.diff " )
FILES = $( grep -E '^\+\+\+ b/' " ${ REVIEW_TMPDIR } /full.diff " | sed 's|^+++ b/||' | grep -v '/dev/null' | sort -u || true )
DNOTE = "" ; [ " $FSIZE " -gt " $MAX_DIFF " ] && DNOTE = " (truncated from ${ FSIZE } bytes) "
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
# =============================================================================
# WORKTREE SETUP
# =============================================================================
cd " ${ PROJECT_REPO_ROOT } "
git fetch origin " $PR_HEAD " 2>/dev/null || true
2026-03-20 22:59:02 +00:00
if [ -d " $WORKTREE " ] ; then
cd " $WORKTREE " ; git checkout --detach " $PR_SHA " 2>/dev/null || {
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
cd " ${ PROJECT_REPO_ROOT } " ; worktree_cleanup " $WORKTREE "
git worktree add " $WORKTREE " " $PR_SHA " --detach 2>/dev/null; }
else
git worktree add " $WORKTREE " " $PR_SHA " --detach 2>/dev/null
fi
2026-03-24 21:24:20 +00:00
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
# =============================================================================
# BUILD STRUCTURAL ANALYSIS GRAPH
# =============================================================================
status "preparing review"
2026-03-24 21:24:20 +00:00
GRAPH_REPORT = " /tmp/ ${ PROJECT_NAME } -review-graph- ${ PR_NUMBER } .json "
GRAPH_SECTION = ""
# shellcheck disable=SC2086
if python3 " $FACTORY_ROOT /lib/build-graph.py " \
--project-root " $PROJECT_REPO_ROOT " \
--changed-files $FILES \
--output " $GRAPH_REPORT " 2>>" $LOGFILE " ; then
GRAPH_SECTION = $( printf '\n## Structural analysis (affected objectives)\n```json\n%s\n```\n' \
" $( cat " $GRAPH_REPORT " ) " )
log " graph report generated for PR # ${ PR_NUMBER } "
else
log "WARN: build-graph.py failed — continuing without structural analysis"
fi
2026-04-01 09:39:57 +00:00
# =============================================================================
# LOAD LESSONS FROM .PROFILE REPO (PRE-SESSION)
# =============================================================================
profile_load_lessons || true
LESSONS_INJECTION = " ${ LESSONS_CONTEXT :- } "
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
# =============================================================================
# BUILD PROMPT
# =============================================================================
2026-03-20 22:59:02 +00:00
FORMULA = $( cat " ${ FACTORY_ROOT } /formulas/review-pr.toml " )
2026-03-12 12:44:15 +00:00
{
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
printf 'You are the review agent for %s. Follow the formula to review PR #%s.\n\n' \
" ${ FORGE_REPO } " " ${ PR_NUMBER } "
2026-03-20 22:59:02 +00:00
printf '## PR Context\n**%s** (%s → %s) | SHA: %s | CI: %s%s\nRe-review: %s\n\n' \
" $PR_TITLE " " $PR_HEAD " " $PR_BASE " " $PR_SHA " " $CI_STATE " " $CI_NOTE " " $IS_RE_REVIEW "
printf '### Description\n%s\n\n### Changed Files\n%s\n\n### Diff%s\n```diff\n%s\n```\n' \
" $PR_BODY " " $FILES " " $DNOTE " " $DIFF "
[ -n " $PREV_CONTEXT " ] && printf '%s\n' " $PREV_CONTEXT "
2026-03-24 21:24:20 +00:00
[ -n " $GRAPH_SECTION " ] && printf '%s\n' " $GRAPH_SECTION "
2026-04-01 09:39:57 +00:00
[ -n " $LESSONS_INJECTION " ] && printf '\n## Lessons learned\n%s\n\n' " $LESSONS_INJECTION "
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
printf '\n## Formula\n%s\n\n## Environment\nREVIEW_OUTPUT_FILE=%s\nFORGE_API=%s\nPR_NUMBER=%s\nFACTORY_ROOT=%s\n' \
" $FORMULA " " $OUTPUT_FILE " " $API " " $PR_NUMBER " " $FACTORY_ROOT "
fix: Replace Codeberg dependency with local Forgejo instance (#611)
- Add setup_forge() to bin/disinto: provisions Forgejo via Docker,
creates admin + bot users (dev-bot, review-bot), generates API
tokens, creates repo, and pushes code — all automated
- Rename env vars: CODEBERG_TOKEN→FORGE_TOKEN, REVIEW_BOT_TOKEN→
FORGE_REVIEW_TOKEN, CODEBERG_REPO→FORGE_REPO, CODEBERG_API→
FORGE_API, CODEBERG_WEB→FORGE_WEB, CODEBERG_BOT_USERNAMES→
FORGE_BOT_USERNAMES (with backwards-compat fallbacks)
- Rename API helpers: codeberg_api()→forge_api(), codeberg_api_all()
→forge_api_all() (with compat aliases)
- Add forge_url field to project TOML; load-project.sh derives
FORGE_API/FORGE_WEB from forge_url + repo
- Update parse_repo_slug() to accept any host URL, not just codeberg
- Forgejo data stored under ~/.disinto/forgejo/ (not in factory repo)
- Update all 58 files: agent scripts, formulas, docs, site HTML
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 16:57:12 +00:00
printf 'NEVER echo the actual token — always reference ${FORGE_TOKEN} or ${FORGE_REVIEW_TOKEN}.\n'
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
printf '\n## Completion\nAfter writing the JSON file to REVIEW_OUTPUT_FILE, stop.\nDo NOT write to any phase file — completion is automatic.\n'
2026-03-20 22:59:02 +00:00
} > " ${ REVIEW_TMPDIR } /prompt.md "
PROMPT = $( cat " ${ REVIEW_TMPDIR } /prompt.md " )
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
# =============================================================================
# RUN REVIEW AGENT
# =============================================================================
status "running review"
rm -f " $OUTPUT_FILE "
2026-03-20 22:59:02 +00:00
export CLAUDE_MODEL = "sonnet"
2026-03-17 23:56:04 +00:00
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
if [ " $IS_RE_REVIEW " = true ] && [ -n " $_AGENT_SESSION_ID " ] ; then
agent_run --resume " $_AGENT_SESSION_ID " --worktree " $WORKTREE " " $PROMPT "
else
agent_run --worktree " $WORKTREE " " $PROMPT "
fi
log " agent_run complete (re-review: ${ IS_RE_REVIEW } ) "
# =============================================================================
# PARSE REVIEW OUTPUT
# =============================================================================
2026-03-12 12:44:15 +00:00
REVIEW_JSON = ""
2026-03-20 22:59:02 +00:00
if [ -f " $OUTPUT_FILE " ] ; then
RAW = $( cat " $OUTPUT_FILE " )
if printf '%s' " $RAW " | jq -e '.verdict' >/dev/null 2>& 1; then REVIEW_JSON = " $RAW "
2026-03-12 12:44:15 +00:00
else
2026-03-20 22:59:02 +00:00
EXT = $( printf '%s' " $RAW " | sed -n '/^```json/,/^```$/p' | sed '1d;$d' )
[ -z " $EXT " ] && EXT = $( printf '%s' " $RAW " | sed -n '/^{/,/^}/p' )
[ -n " ${ EXT :- } " ] && printf '%s' " $EXT " | jq -e '.verdict' >/dev/null 2>& 1 && REVIEW_JSON = " $EXT "
2026-03-12 12:44:15 +00:00
fi
2026-03-20 22:59:02 +00:00
fi
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
2026-03-12 12:44:15 +00:00
if [ -z " $REVIEW_JSON " ] ; then
2026-03-20 22:59:02 +00:00
log "ERROR: no valid review output"
jq -n --arg b " ## AI Review — Error\n<!-- review-error: ${ PR_SHA } -->\nReview failed.\n---\n* ${ PR_SHA : 0 : 7 } * " \
fix: Replace Codeberg dependency with local Forgejo instance (#611)
- Add setup_forge() to bin/disinto: provisions Forgejo via Docker,
creates admin + bot users (dev-bot, review-bot), generates API
tokens, creates repo, and pushes code — all automated
- Rename env vars: CODEBERG_TOKEN→FORGE_TOKEN, REVIEW_BOT_TOKEN→
FORGE_REVIEW_TOKEN, CODEBERG_REPO→FORGE_REPO, CODEBERG_API→
FORGE_API, CODEBERG_WEB→FORGE_WEB, CODEBERG_BOT_USERNAMES→
FORGE_BOT_USERNAMES (with backwards-compat fallbacks)
- Rename API helpers: codeberg_api()→forge_api(), codeberg_api_all()
→forge_api_all() (with compat aliases)
- Add forge_url field to project TOML; load-project.sh derives
FORGE_API/FORGE_WEB from forge_url + repo
- Update parse_repo_slug() to accept any host URL, not just codeberg
- Forgejo data stored under ~/.disinto/forgejo/ (not in factory repo)
- Update all 58 files: agent scripts, formulas, docs, site HTML
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 16:57:12 +00:00
'{body: $b}' | curl -sf -o /dev/null -X POST -H " Authorization: token ${ FORGE_TOKEN } " \
2026-03-20 22:59:02 +00:00
-H "Content-Type: application/json" " ${ API } /issues/ ${ PR_NUMBER } /comments " -d @- || true
fix: Remove Matrix integration — notifications move to forge + OpenClaw (#732)
Remove all Matrix/Dendrite infrastructure:
- Delete lib/matrix_listener.sh (long-poll daemon), lib/matrix_listener.service
(systemd unit), lib/hooks/on-stop-matrix.sh (response streaming hook)
- Remove matrix_send() and matrix_send_ctx() from lib/env.sh
- Remove MATRIX_HOMESERVER auto-detection, MATRIX_THREAD_MAP from lib/env.sh
- Remove [matrix] section parsing from lib/load-project.sh
- Remove Matrix hook installation from lib/agent-session.sh
- Remove notify/notify_ctx helpers and Matrix thread tracking from
dev/dev-agent.sh and action/action-agent.sh
- Remove all matrix_send calls from dev-poll.sh, phase-handler.sh,
action-poll.sh, vault-poll.sh, vault-fire.sh, vault-reject.sh,
review-poll.sh, review-pr.sh, supervisor-poll.sh, formula-session.sh
- Remove Matrix listener startup from docker/agents/entrypoint.sh
- Remove append_dendrite_compose() and setup_matrix() from bin/disinto
- Remove --matrix flag from disinto init
- Clean Matrix references from .env.example, projects/*.toml.example,
formulas/*.toml, AGENTS.md, BOOTSTRAP.md, README.md, RESOURCES.md,
PHASE-PROTOCOL.md, and all agent AGENTS.md/PROMPT.md files
Status visibility now via Codeberg PR/issue activity. Human interaction
via vault items through forge. Proactive alerts via OpenClaw heartbeats.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 14:53:56 +00:00
exit 1
2026-03-12 12:44:15 +00:00
fi
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
2026-03-19 08:34:45 +00:00
VERDICT = $( printf '%s' " $REVIEW_JSON " | jq -r '.verdict' | tr '[:lower:]' '[:upper:]' | tr '-' '_' )
2026-03-20 22:59:02 +00:00
REASON = $( printf '%s' " $REVIEW_JSON " | jq -r '.verdict_reason // ""' )
REVIEW_MD = $( printf '%s' " $REVIEW_JSON " | jq -r '.review_markdown // ""' )
log " verdict: ${ VERDICT } "
2026-03-12 12:44:15 +00:00
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
# =============================================================================
# POST REVIEW
# =============================================================================
2026-03-20 22:59:02 +00:00
status "posting review"
RTYPE = "Review"
2026-03-12 12:44:15 +00:00
if [ " $IS_RE_REVIEW " = true ] ; then
2026-03-20 22:59:02 +00:00
RTYPE = " Re-review (round $(( $( printf '%s' " $ALL_COMMENTS " | \
jq '[.[]|select(.body|contains("<!-- reviewed:"))]|length' ) + 1) ) ) "
fi
PREV_REF = "" ; [ " $IS_RE_REVIEW " = true ] && PREV_REF = $( printf ' | Previous: `%s`' " ${ PREV_SHA : 0 : 7 } " ) || true
COMMENT_BODY = $( printf '## AI %s\n<!-- reviewed: %s -->\n\n%s\n\n### Verdict\n**%s** — %s\n\n---\n*Reviewed at `%s`%s | [AGENTS.md](AGENTS.md)*' \
" $RTYPE " " $PR_SHA " " $REVIEW_MD " " $VERDICT " " $REASON " " ${ PR_SHA : 0 : 7 } " " $PREV_REF " )
printf '%s' " $COMMENT_BODY " > " ${ REVIEW_TMPDIR } /body.txt "
jq -Rs '{body: .}' < " ${ REVIEW_TMPDIR } /body.txt " > " ${ REVIEW_TMPDIR } /comment.json "
POST_RC = $( curl -s -o /dev/null -w "%{http_code}" -X POST \
fix: Replace Codeberg dependency with local Forgejo instance (#611)
- Add setup_forge() to bin/disinto: provisions Forgejo via Docker,
creates admin + bot users (dev-bot, review-bot), generates API
tokens, creates repo, and pushes code — all automated
- Rename env vars: CODEBERG_TOKEN→FORGE_TOKEN, REVIEW_BOT_TOKEN→
FORGE_REVIEW_TOKEN, CODEBERG_REPO→FORGE_REPO, CODEBERG_API→
FORGE_API, CODEBERG_WEB→FORGE_WEB, CODEBERG_BOT_USERNAMES→
FORGE_BOT_USERNAMES (with backwards-compat fallbacks)
- Rename API helpers: codeberg_api()→forge_api(), codeberg_api_all()
→forge_api_all() (with compat aliases)
- Add forge_url field to project TOML; load-project.sh derives
FORGE_API/FORGE_WEB from forge_url + repo
- Update parse_repo_slug() to accept any host URL, not just codeberg
- Forgejo data stored under ~/.disinto/forgejo/ (not in factory repo)
- Update all 58 files: agent scripts, formulas, docs, site HTML
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 16:57:12 +00:00
-H " Authorization: token ${ FORGE_REVIEW_TOKEN } " -H "Content-Type: application/json" \
2026-03-20 22:59:02 +00:00
" ${ API } /issues/ ${ PR_NUMBER } /comments " --data-binary @" ${ REVIEW_TMPDIR } /comment.json " )
[ " $POST_RC " != "201" ] && { log " ERROR: comment HTTP ${ POST_RC } " ; exit 1; }
log "posted review comment"
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
# =============================================================================
# POST FORMAL REVIEW
# =============================================================================
2026-03-20 22:59:02 +00:00
REVENT = "COMMENT"
case " $VERDICT " in APPROVE) REVENT = "APPROVED" ; ; REQUEST_CHANGES| DISCUSS) REVENT = "REQUEST_CHANGES" ; ; esac
if [ " $REVENT " = "APPROVED" ] ; then
fix: Replace Codeberg dependency with local Forgejo instance (#611)
- Add setup_forge() to bin/disinto: provisions Forgejo via Docker,
creates admin + bot users (dev-bot, review-bot), generates API
tokens, creates repo, and pushes code — all automated
- Rename env vars: CODEBERG_TOKEN→FORGE_TOKEN, REVIEW_BOT_TOKEN→
FORGE_REVIEW_TOKEN, CODEBERG_REPO→FORGE_REPO, CODEBERG_API→
FORGE_API, CODEBERG_WEB→FORGE_WEB, CODEBERG_BOT_USERNAMES→
FORGE_BOT_USERNAMES (with backwards-compat fallbacks)
- Rename API helpers: codeberg_api()→forge_api(), codeberg_api_all()
→forge_api_all() (with compat aliases)
- Add forge_url field to project TOML; load-project.sh derives
FORGE_API/FORGE_WEB from forge_url + repo
- Update parse_repo_slug() to accept any host URL, not just codeberg
- Forgejo data stored under ~/.disinto/forgejo/ (not in factory repo)
- Update all 58 files: agent scripts, formulas, docs, site HTML
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 16:57:12 +00:00
BLOGIN = $( curl -sf -H " Authorization: token ${ FORGE_REVIEW_TOKEN } " \
2026-03-20 22:59:02 +00:00
" ${ API %%/repos* } /user " 2>/dev/null | jq -r '.login // empty' || true )
fix: Replace Codeberg dependency with local Forgejo instance (#611)
- Add setup_forge() to bin/disinto: provisions Forgejo via Docker,
creates admin + bot users (dev-bot, review-bot), generates API
tokens, creates repo, and pushes code — all automated
- Rename env vars: CODEBERG_TOKEN→FORGE_TOKEN, REVIEW_BOT_TOKEN→
FORGE_REVIEW_TOKEN, CODEBERG_REPO→FORGE_REPO, CODEBERG_API→
FORGE_API, CODEBERG_WEB→FORGE_WEB, CODEBERG_BOT_USERNAMES→
FORGE_BOT_USERNAMES (with backwards-compat fallbacks)
- Rename API helpers: codeberg_api()→forge_api(), codeberg_api_all()
→forge_api_all() (with compat aliases)
- Add forge_url field to project TOML; load-project.sh derives
FORGE_API/FORGE_WEB from forge_url + repo
- Update parse_repo_slug() to accept any host URL, not just codeberg
- Forgejo data stored under ~/.disinto/forgejo/ (not in factory repo)
- Update all 58 files: agent scripts, formulas, docs, site HTML
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 16:57:12 +00:00
[ -n " $BLOGIN " ] && forge_api_all " /pulls/ ${ PR_NUMBER } /reviews " " ${ FORGE_REVIEW_TOKEN } " 2>/dev/null | \
2026-03-20 22:59:02 +00:00
jq -r --arg l " $BLOGIN " '.[]|select(.state=="REQUEST_CHANGES")|select(.user.login==$l)|.id' | \
while IFS = read -r rid; do
fix: Replace Codeberg dependency with local Forgejo instance (#611)
- Add setup_forge() to bin/disinto: provisions Forgejo via Docker,
creates admin + bot users (dev-bot, review-bot), generates API
tokens, creates repo, and pushes code — all automated
- Rename env vars: CODEBERG_TOKEN→FORGE_TOKEN, REVIEW_BOT_TOKEN→
FORGE_REVIEW_TOKEN, CODEBERG_REPO→FORGE_REPO, CODEBERG_API→
FORGE_API, CODEBERG_WEB→FORGE_WEB, CODEBERG_BOT_USERNAMES→
FORGE_BOT_USERNAMES (with backwards-compat fallbacks)
- Rename API helpers: codeberg_api()→forge_api(), codeberg_api_all()
→forge_api_all() (with compat aliases)
- Add forge_url field to project TOML; load-project.sh derives
FORGE_API/FORGE_WEB from forge_url + repo
- Update parse_repo_slug() to accept any host URL, not just codeberg
- Forgejo data stored under ~/.disinto/forgejo/ (not in factory repo)
- Update all 58 files: agent scripts, formulas, docs, site HTML
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 16:57:12 +00:00
curl -sf -o /dev/null -X POST -H " Authorization: token ${ FORGE_REVIEW_TOKEN } " \
2026-03-20 22:59:02 +00:00
-H "Content-Type: application/json" " ${ API } /pulls/ ${ PR_NUMBER } /reviews/ ${ rid } /dismissals " \
-d '{"message":"Superseded by approval"}' || true; log " dismissed review ${ rid } "
done || true
fi
jq -n --arg b " AI ${ RTYPE } : ** ${ VERDICT } ** — ${ REASON } " --arg e " $REVENT " --arg s " $PR_SHA " \
'{body: $b, event: $e, commit_id: $s}' > " ${ REVIEW_TMPDIR } /formal.json "
fix: Replace Codeberg dependency with local Forgejo instance (#611)
- Add setup_forge() to bin/disinto: provisions Forgejo via Docker,
creates admin + bot users (dev-bot, review-bot), generates API
tokens, creates repo, and pushes code — all automated
- Rename env vars: CODEBERG_TOKEN→FORGE_TOKEN, REVIEW_BOT_TOKEN→
FORGE_REVIEW_TOKEN, CODEBERG_REPO→FORGE_REPO, CODEBERG_API→
FORGE_API, CODEBERG_WEB→FORGE_WEB, CODEBERG_BOT_USERNAMES→
FORGE_BOT_USERNAMES (with backwards-compat fallbacks)
- Rename API helpers: codeberg_api()→forge_api(), codeberg_api_all()
→forge_api_all() (with compat aliases)
- Add forge_url field to project TOML; load-project.sh derives
FORGE_API/FORGE_WEB from forge_url + repo
- Update parse_repo_slug() to accept any host URL, not just codeberg
- Forgejo data stored under ~/.disinto/forgejo/ (not in factory repo)
- Update all 58 files: agent scripts, formulas, docs, site HTML
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 16:57:12 +00:00
curl -s -o /dev/null -X POST -H " Authorization: token ${ FORGE_REVIEW_TOKEN } " \
2026-03-20 22:59:02 +00:00
-H "Content-Type: application/json" " ${ API } /pulls/ ${ PR_NUMBER } /reviews " \
--data-binary @" ${ REVIEW_TMPDIR } /formal.json " >/dev/null 2>& 1 || true
log " formal ${ REVENT } submitted "
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
# =============================================================================
# FINAL CLEANUP
# =============================================================================
2026-03-19 20:09:22 +00:00
case " $VERDICT " in
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
REQUEST_CHANGES| DISCUSS)
# Keep session and worktree for re-review continuity
log " keeping session for re-review (SID: ${ _AGENT_SESSION_ID : 0 : 12 } ...) "
; ;
*)
rm -f " $SID_FILE " " $OUTPUT_FILE "
worktree_cleanup " $WORKTREE "
; ;
2026-03-19 20:09:22 +00:00
esac
fix: Migrate review-pr.sh to SDK + pr-lifecycle (#800)
Rewrite review-pr.sh from tmux-based agent-session.sh to synchronous
claude -p invocations via inline agent_run(), matching the SDK pattern
established in dev-agent.sh (#798).
Key changes:
- Replace agent-session.sh (tmux + monitor_phase_loop) with inline
agent_run() using one-shot claude -p and --output-format json
- Add .sid file for session continuity: re-reviews resume the original
session via --resume, so Claude remembers its prior review
- Use worktree.sh for worktree cleanup instead of manual git commands
- Remove phase file signaling (PHASE:done) — completion is automatic
when claude -p returns
- Keep all review business logic: PR metadata, diff extraction,
re-review detection (SHA tracking), incremental diff, build graph,
formula loading, review posting, formal review submission
Session continuity for re-reviews:
Initial review → save session_id to .sid file
Re-review → load session_id, agent_run --resume → Claude remembers
what it flagged and checks specifically whether concerns were addressed
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 06:29:20 +00:00
2026-04-01 09:39:57 +00:00
# Write journal entry post-session
profile_write_journal " review- ${ PR_NUMBER } " " Review PR # ${ PR_NUMBER } ( ${ VERDICT } ) " " ${ VERDICT ,, } " "" || true
2026-03-20 22:59:02 +00:00
log " DONE: ${ VERDICT } (re-review: ${ IS_RE_REVIEW } ) "