2026-03-12 12:44:15 +00:00
#!/usr/bin/env bash
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
# dev-agent.sh — Synchronous developer agent for a single issue
2026-03-12 12:44:15 +00:00
#
# Usage: ./dev-agent.sh <issue-number>
#
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
# Architecture:
# Synchronous bash loop using claude -p (one-shot invocations).
# Session continuity via --resume and .sid file.
# CI/review loop delegated to pr_walk_to_merge().
2026-03-12 12:44:15 +00:00
#
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
# Flow:
# 1. Preflight: issue_check_deps, issue_claim, memory guard, lock
# 2. Worktree: worktree_recover or worktree_create
# 3. Prompt: build context (issue body, open issues, push instructions)
# 4. Implement: agent_run → Claude implements + pushes → save session_id
# 5. Create PR: pr_create or pr_find_by_branch
# 6. Walk to merge: pr_walk_to_merge (CI fix, review feedback loops)
# 7. Cleanup: worktree_cleanup, issue_close, label cleanup
#
# Session file: /tmp/dev-session-{project}-{issue}.sid
# Log: tail -f dev-agent.log
2026-03-12 12:44:15 +00:00
set -euo pipefail
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
# Load shared environment and libraries
2026-03-12 12:44:15 +00:00
source " $( dirname " $0 " ) /../lib/env.sh "
2026-03-21 05:06:12 +00:00
source " $( dirname " $0 " ) /../lib/ci-helpers.sh "
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
source " $( dirname " $0 " ) /../lib/issue-lifecycle.sh "
2026-03-27 19:06:31 +00:00
source " $( dirname " $0 " ) /../lib/worktree.sh "
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
source " $( dirname " $0 " ) /../lib/pr-lifecycle.sh "
source " $( dirname " $0 " ) /../lib/mirrors.sh "
2026-03-28 06:32:12 +00:00
source " $( dirname " $0 " ) /../lib/agent-sdk.sh "
2026-03-12 12:44:15 +00:00
2026-03-17 19:35:29 +00:00
# Auto-pull factory code to pick up merged fixes before any logic runs
git -C " $FACTORY_ROOT " pull --ff-only origin main 2>/dev/null || true
2026-03-12 12:44:15 +00:00
# --- Config ---
ISSUE = " ${ 1 : ?Usage : dev-agent.sh <issue-number> } "
2026-03-14 13:49:09 +01:00
REPO_ROOT = " ${ PROJECT_REPO_ROOT } "
2026-03-12 12:44:15 +00:00
2026-03-21 14:25:13 +00:00
LOCKFILE = " /tmp/dev-agent- ${ PROJECT_NAME :- default } .lock "
2026-03-21 16:20:07 +00:00
STATUSFILE = " /tmp/dev-agent-status- ${ PROJECT_NAME :- default } "
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
BRANCH = " fix/issue- ${ ISSUE } "
WORKTREE = " /tmp/ ${ PROJECT_NAME } -worktree- ${ ISSUE } "
SID_FILE = " /tmp/dev-session- ${ PROJECT_NAME } - ${ ISSUE } .sid "
PREFLIGHT_RESULT = "/tmp/dev-agent-preflight.json"
IMPL_SUMMARY_FILE = " /tmp/dev-impl-summary- ${ PROJECT_NAME } - ${ ISSUE } .txt "
2026-03-18 16:10:12 +00:00
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
LOGFILE = " ${ DISINTO_LOG_DIR } /dev/dev-agent.log "
2026-03-20 14:25:00 +00:00
2026-03-18 16:37:55 +00:00
log( ) {
printf '[%s] #%s %s\n' " $( date -u '+%Y-%m-%d %H:%M:%S UTC' ) " " $ISSUE " " $* " >> " $LOGFILE "
}
2026-03-18 16:10:12 +00:00
status( ) {
printf '[%s] dev-agent #%s: %s\n' " $( date -u '+%Y-%m-%d %H:%M:%S UTC' ) " " $ISSUE " " $* " > " $STATUSFILE "
log " $* "
}
fix: feat: tmux session manager in dev-agent.sh (#80)
Replace fire-and-forget `claude -p` calls with a persistent tmux session
that Claude Code runs in interactively. The orchestrator (dev-agent.sh)
monitors a phase file and reacts to Claude's signals:
- Session lifecycle: create `dev-{project}-{issue}` tmux session, send
the full initial prompt (issue body + phase protocol instructions) via
`tmux load-buffer` / `tmux paste-buffer`, then enter a phase monitor loop.
- Phase monitor loop: polls `/tmp/dev-session-{project}-{issue}.phase`
every 30s for mtime changes. Handles all five phase sentinels:
- PHASE:awaiting_ci → create PR if needed, poll CI, inject result
- PHASE:awaiting_review → poll for review comment, inject verdict
- PHASE:needs_human → send Matrix notification, wait for injection
- PHASE:done → call do_merge(), exit on success
- PHASE:failed → detect refusal JSON vs genuine failure, post
comment / escalate, kill session, restore backlog
- Crash recovery: if the tmux session dies unexpectedly, dev-agent.sh
restarts it in the same worktree and injects a recovery prompt with
the last known phase and git diff.
- Idle timeout: 2h with no phase update kills the session gracefully.
- PR creation moved into the PHASE:awaiting_ci handler; Claude pushes the
branch and writes the phase, orchestrator creates the PR and starts CI.
- Summary file `/tmp/dev-impl-summary-{project}-{issue}.txt` carries the
implementation summary (for PR body) and refusal JSON between Claude and
the orchestrator.
- All existing logic preserved: dep preflight, label management, do_merge()
with rebase retry, CI escalation, prior art detection, log rotation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 20:20:38 +00:00
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
# =============================================================================
# CLEANUP
# =============================================================================
2026-03-12 12:44:15 +00:00
CLAIMED = false
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
PR_NUMBER = ""
2026-03-12 12:44:15 +00:00
cleanup( ) {
rm -f " $LOCKFILE " " $STATUSFILE "
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
# If we claimed the issue but never created a PR, release it
if [ " $CLAIMED " = true ] && [ -z " $PR_NUMBER " ] ; then
log "cleanup: releasing issue (no PR created)"
issue_release " $ISSUE "
2026-03-12 12:44:15 +00:00
fi
}
trap cleanup EXIT
fix: feat: tmux session manager in dev-agent.sh (#80)
Replace fire-and-forget `claude -p` calls with a persistent tmux session
that Claude Code runs in interactively. The orchestrator (dev-agent.sh)
monitors a phase file and reacts to Claude's signals:
- Session lifecycle: create `dev-{project}-{issue}` tmux session, send
the full initial prompt (issue body + phase protocol instructions) via
`tmux load-buffer` / `tmux paste-buffer`, then enter a phase monitor loop.
- Phase monitor loop: polls `/tmp/dev-session-{project}-{issue}.phase`
every 30s for mtime changes. Handles all five phase sentinels:
- PHASE:awaiting_ci → create PR if needed, poll CI, inject result
- PHASE:awaiting_review → poll for review comment, inject verdict
- PHASE:needs_human → send Matrix notification, wait for injection
- PHASE:done → call do_merge(), exit on success
- PHASE:failed → detect refusal JSON vs genuine failure, post
comment / escalate, kill session, restore backlog
- Crash recovery: if the tmux session dies unexpectedly, dev-agent.sh
restarts it in the same worktree and injects a recovery prompt with
the last known phase and git diff.
- Idle timeout: 2h with no phase update kills the session gracefully.
- PR creation moved into the PHASE:awaiting_ci handler; Claude pushes the
branch and writes the phase, orchestrator creates the PR and starts CI.
- Summary file `/tmp/dev-impl-summary-{project}-{issue}.txt` carries the
implementation summary (for PR body) and refusal JSON between Claude and
the orchestrator.
- All existing logic preserved: dep preflight, label management, do_merge()
with rebase retry, CI escalation, prior art detection, log rotation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 20:20:38 +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 "
log "Log rotated"
fi
fix: feat: tmux session manager in dev-agent.sh (#80)
Replace fire-and-forget `claude -p` calls with a persistent tmux session
that Claude Code runs in interactively. The orchestrator (dev-agent.sh)
monitors a phase file and reacts to Claude's signals:
- Session lifecycle: create `dev-{project}-{issue}` tmux session, send
the full initial prompt (issue body + phase protocol instructions) via
`tmux load-buffer` / `tmux paste-buffer`, then enter a phase monitor loop.
- Phase monitor loop: polls `/tmp/dev-session-{project}-{issue}.phase`
every 30s for mtime changes. Handles all five phase sentinels:
- PHASE:awaiting_ci → create PR if needed, poll CI, inject result
- PHASE:awaiting_review → poll for review comment, inject verdict
- PHASE:needs_human → send Matrix notification, wait for injection
- PHASE:done → call do_merge(), exit on success
- PHASE:failed → detect refusal JSON vs genuine failure, post
comment / escalate, kill session, restore backlog
- Crash recovery: if the tmux session dies unexpectedly, dev-agent.sh
restarts it in the same worktree and injects a recovery prompt with
the last known phase and git diff.
- Idle timeout: 2h with no phase update kills the session gracefully.
- PR creation moved into the PHASE:awaiting_ci handler; Claude pushes the
branch and writes the phase, orchestrator creates the PR and starts CI.
- Summary file `/tmp/dev-impl-summary-{project}-{issue}.txt` carries the
implementation summary (for PR body) and refusal JSON between Claude and
the orchestrator.
- All existing logic preserved: dep preflight, label management, do_merge()
with rebase retry, CI escalation, prior art detection, log rotation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 20:20:38 +00:00
# =============================================================================
# MEMORY GUARD
# =============================================================================
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
memory_guard 2000
2026-03-12 12:44:15 +00:00
fix: feat: tmux session manager in dev-agent.sh (#80)
Replace fire-and-forget `claude -p` calls with a persistent tmux session
that Claude Code runs in interactively. The orchestrator (dev-agent.sh)
monitors a phase file and reacts to Claude's signals:
- Session lifecycle: create `dev-{project}-{issue}` tmux session, send
the full initial prompt (issue body + phase protocol instructions) via
`tmux load-buffer` / `tmux paste-buffer`, then enter a phase monitor loop.
- Phase monitor loop: polls `/tmp/dev-session-{project}-{issue}.phase`
every 30s for mtime changes. Handles all five phase sentinels:
- PHASE:awaiting_ci → create PR if needed, poll CI, inject result
- PHASE:awaiting_review → poll for review comment, inject verdict
- PHASE:needs_human → send Matrix notification, wait for injection
- PHASE:done → call do_merge(), exit on success
- PHASE:failed → detect refusal JSON vs genuine failure, post
comment / escalate, kill session, restore backlog
- Crash recovery: if the tmux session dies unexpectedly, dev-agent.sh
restarts it in the same worktree and injects a recovery prompt with
the last known phase and git diff.
- Idle timeout: 2h with no phase update kills the session gracefully.
- PR creation moved into the PHASE:awaiting_ci handler; Claude pushes the
branch and writes the phase, orchestrator creates the PR and starts CI.
- Summary file `/tmp/dev-impl-summary-{project}-{issue}.txt` carries the
implementation summary (for PR body) and refusal JSON between Claude and
the orchestrator.
- All existing logic preserved: dep preflight, label management, do_merge()
with rebase retry, CI escalation, prior art detection, log rotation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 20:20:38 +00:00
# =============================================================================
# CONCURRENCY LOCK
# =============================================================================
2026-03-12 12:44:15 +00:00
if [ -f " $LOCKFILE " ] ; then
LOCK_PID = $( cat " $LOCKFILE " 2>/dev/null || echo "" )
if [ -n " $LOCK_PID " ] && kill -0 " $LOCK_PID " 2>/dev/null; then
log " SKIP: another dev-agent running (PID ${ LOCK_PID } ) "
exit 0
fi
log " Removing stale lock (PID ${ LOCK_PID :- ? } ) "
rm -f " $LOCKFILE "
fi
echo $$ > " $LOCKFILE "
fix: feat: tmux session manager in dev-agent.sh (#80)
Replace fire-and-forget `claude -p` calls with a persistent tmux session
that Claude Code runs in interactively. The orchestrator (dev-agent.sh)
monitors a phase file and reacts to Claude's signals:
- Session lifecycle: create `dev-{project}-{issue}` tmux session, send
the full initial prompt (issue body + phase protocol instructions) via
`tmux load-buffer` / `tmux paste-buffer`, then enter a phase monitor loop.
- Phase monitor loop: polls `/tmp/dev-session-{project}-{issue}.phase`
every 30s for mtime changes. Handles all five phase sentinels:
- PHASE:awaiting_ci → create PR if needed, poll CI, inject result
- PHASE:awaiting_review → poll for review comment, inject verdict
- PHASE:needs_human → send Matrix notification, wait for injection
- PHASE:done → call do_merge(), exit on success
- PHASE:failed → detect refusal JSON vs genuine failure, post
comment / escalate, kill session, restore backlog
- Crash recovery: if the tmux session dies unexpectedly, dev-agent.sh
restarts it in the same worktree and injects a recovery prompt with
the last known phase and git diff.
- Idle timeout: 2h with no phase update kills the session gracefully.
- PR creation moved into the PHASE:awaiting_ci handler; Claude pushes the
branch and writes the phase, orchestrator creates the PR and starts CI.
- Summary file `/tmp/dev-impl-summary-{project}-{issue}.txt` carries the
implementation summary (for PR body) and refusal JSON between Claude and
the orchestrator.
- All existing logic preserved: dep preflight, label management, do_merge()
with rebase retry, CI escalation, prior art detection, log rotation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 20:20:38 +00:00
# =============================================================================
# FETCH ISSUE
# =============================================================================
2026-03-12 12:44:15 +00:00
status "fetching issue"
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
ISSUE_JSON = $( forge_api GET " /issues/ ${ ISSUE } " ) || true
if [ -z " $ISSUE_JSON " ] || ! printf '%s' " $ISSUE_JSON " | jq -e '.id' >/dev/null 2>& 1; then
2026-03-27 21:23:48 +00:00
log " ERROR: failed to fetch issue # ${ ISSUE } (API down or invalid response) " ; exit 1
2026-03-12 12:44:15 +00:00
fi
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
ISSUE_TITLE = $( printf '%s' " $ISSUE_JSON " | jq -r '.title' )
ISSUE_BODY = $( printf '%s' " $ISSUE_JSON " | jq -r '.body // ""' )
2026-03-19 08:25:02 +00:00
ISSUE_BODY_ORIGINAL = " $ISSUE_BODY "
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
ISSUE_STATE = $( printf '%s' " $ISSUE_JSON " | jq -r '.state' )
2026-03-19 07:56:11 +00:00
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
if [ " $ISSUE_STATE " != "open" ] ; then
log " SKIP: issue # ${ ISSUE } is ${ ISSUE_STATE } "
echo '{"status":"already_done","reason":"issue is closed"}' > " $PREFLIGHT_RESULT "
exit 0
fi
log " Issue: ${ ISSUE_TITLE } "
2026-03-21 16:35:00 +00:00
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
# =============================================================================
# GUARD: Reject formula-labeled issues
# =============================================================================
ISSUE_LABELS = $( printf '%s' " $ISSUE_JSON " | jq -r '[.labels[].name] | join(",")' ) || true
if printf '%s' " $ISSUE_LABELS " | grep -qw 'formula' ; then
log " SKIP: issue # ${ ISSUE } has 'formula' label "
echo '{"status":"unmet_dependency","blocked_by":"formula dispatch not implemented","suggestion":null}' > " $PREFLIGHT_RESULT "
exit 0
fi
# --- Append human comments to issue body ---
_bot_login = $( curl -sf -H " Authorization: token ${ FORGE_TOKEN } " \
" ${ FORGE_API %%/repos* } /user " | jq -r '.login // empty' 2>/dev/null || true )
2026-03-21 16:35:00 +00:00
_bot_logins = " ${ _bot_login } "
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
[ -n " ${ FORGE_BOT_USERNAMES :- } " ] && \
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
_bot_logins = " ${ _bot_logins : + ${ _bot_logins } , } ${ FORGE_BOT_USERNAMES } "
2026-03-21 16:35:00 +00:00
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
ISSUE_COMMENTS = $( curl -sf -H " Authorization: token ${ FORGE_TOKEN } " \
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
" ${ FORGE_API } /issues/ ${ ISSUE } /comments " | \
2026-03-21 16:35:00 +00:00
jq -r --arg bots " $_bot_logins " \
' ( $bots | split( "," ) | map( select ( . != "" ) ) ) as $bl |
.[ ] | select ( .user.login as $u | $bl | index( $u ) | not) |
"### @\(.user.login) (\(.created_at[:10])):\n\(.body)\n" ' 2>/dev/null || true )
2026-03-19 07:56:11 +00:00
if [ -n " $ISSUE_COMMENTS " ] ; then
ISSUE_BODY = " ${ ISSUE_BODY }
## Issue comments
${ ISSUE_COMMENTS } "
fi
2026-03-18 02:17:18 +00:00
2026-03-12 12:44:15 +00:00
# =============================================================================
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
# PREFLIGHT: Check dependencies
2026-03-12 12:44:15 +00:00
# =============================================================================
status "preflight check"
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
if ! issue_check_deps " $ISSUE " ; then
BLOCKED_LIST = $( printf '#%s, ' " ${ _ISSUE_BLOCKED_BY [@] } " | sed 's/, $//' )
COMMENT_BODY = " ### Blocked by open issues
2026-03-12 12:44:15 +00:00
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
This issue depends on ${ BLOCKED_LIST } , which $( [ " ${# _ISSUE_BLOCKED_BY [@] } " -eq 1 ] && echo "is" || echo "are" ) not yet closed."
[ -n " $_ISSUE_SUGGESTION " ] && COMMENT_BODY = " ${ COMMENT_BODY }
2026-03-12 12:44:15 +00:00
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
**Suggestion:** Work on #${_ISSUE_SUGGESTION} first."
2026-03-12 12:44:15 +00:00
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
issue_post_refusal " $ISSUE " "🚧" "Unmet dependency" " $COMMENT_BODY "
2026-03-12 12:44:15 +00:00
# Write preflight result
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
BLOCKED_JSON = $( printf '%s\n' " ${ _ISSUE_BLOCKED_BY [@] } " | jq -R 'tonumber' | jq -sc '.' )
if [ -n " $_ISSUE_SUGGESTION " ] ; then
jq -n --argjson blocked " $BLOCKED_JSON " --argjson suggestion " $_ISSUE_SUGGESTION " \
2026-03-12 12:44:15 +00:00
'{"status":"unmet_dependency","blocked_by":$blocked,"suggestion":$suggestion}' > " $PREFLIGHT_RESULT "
else
jq -n --argjson blocked " $BLOCKED_JSON " \
'{"status":"unmet_dependency","blocked_by":$blocked,"suggestion":null}' > " $PREFLIGHT_RESULT "
fi
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
log " BLOCKED: unmet dependencies: ${ _ISSUE_BLOCKED_BY [*] } "
2026-03-12 12:44:15 +00:00
exit 0
fi
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
log "preflight passed"
2026-03-12 12:44:15 +00:00
# =============================================================================
fix: feat: tmux session manager in dev-agent.sh (#80)
Replace fire-and-forget `claude -p` calls with a persistent tmux session
that Claude Code runs in interactively. The orchestrator (dev-agent.sh)
monitors a phase file and reacts to Claude's signals:
- Session lifecycle: create `dev-{project}-{issue}` tmux session, send
the full initial prompt (issue body + phase protocol instructions) via
`tmux load-buffer` / `tmux paste-buffer`, then enter a phase monitor loop.
- Phase monitor loop: polls `/tmp/dev-session-{project}-{issue}.phase`
every 30s for mtime changes. Handles all five phase sentinels:
- PHASE:awaiting_ci → create PR if needed, poll CI, inject result
- PHASE:awaiting_review → poll for review comment, inject verdict
- PHASE:needs_human → send Matrix notification, wait for injection
- PHASE:done → call do_merge(), exit on success
- PHASE:failed → detect refusal JSON vs genuine failure, post
comment / escalate, kill session, restore backlog
- Crash recovery: if the tmux session dies unexpectedly, dev-agent.sh
restarts it in the same worktree and injects a recovery prompt with
the last known phase and git diff.
- Idle timeout: 2h with no phase update kills the session gracefully.
- PR creation moved into the PHASE:awaiting_ci handler; Claude pushes the
branch and writes the phase, orchestrator creates the PR and starts CI.
- Summary file `/tmp/dev-impl-summary-{project}-{issue}.txt` carries the
implementation summary (for PR body) and refusal JSON between Claude and
the orchestrator.
- All existing logic preserved: dep preflight, label management, do_merge()
with rebase retry, CI escalation, prior art detection, log rotation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 20:20:38 +00:00
# CLAIM ISSUE
2026-03-12 12:44:15 +00:00
# =============================================================================
2026-03-28 19:31:27 +00:00
if ! issue_claim " $ISSUE " ; then
log " SKIP: failed to claim issue # ${ ISSUE } (already assigned to another agent) "
echo '{"status":"already_done","reason":"issue was claimed by another agent"}' > " $PREFLIGHT_RESULT "
exit 0
fi
2026-03-12 12:44:15 +00:00
CLAIMED = true
# =============================================================================
# CHECK FOR EXISTING PR (recovery mode)
# =============================================================================
RECOVERY_MODE = false
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
# Check issue body for explicit PR reference
BODY_PR = $( printf '%s' " $ISSUE_BODY_ORIGINAL " | grep -oP 'Existing PR:\s*#\K[0-9]+' | head -1) || true
2026-03-12 12:44:15 +00:00
if [ -n " $BODY_PR " ] ; then
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
PR_CHECK = $( forge_api GET " /pulls/ ${ BODY_PR } " ) || true
PR_CHECK_STATE = $( printf '%s' " $PR_CHECK " | jq -r '.state' )
2026-03-12 12:44:15 +00:00
if [ " $PR_CHECK_STATE " = "open" ] ; then
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
PR_NUMBER = " $BODY_PR "
BRANCH = $( printf '%s' " $PR_CHECK " | jq -r '.head.ref' )
log " found existing PR # ${ PR_NUMBER } on branch ${ BRANCH } (from issue body) "
2026-03-12 12:44:15 +00:00
fi
fi
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
# Priority 1: match by branch name
if [ -z " $PR_NUMBER " ] ; then
PR_NUMBER = $( pr_find_by_branch " $BRANCH " ) || true
[ -n " $PR_NUMBER " ] && log " found existing PR # ${ PR_NUMBER } (from branch match) "
2026-03-12 12:44:15 +00:00
fi
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
# Priority 2: match "Fixes #NNN" in PR body
if [ -z " $PR_NUMBER " ] ; then
FOUND_PR = $( forge_api GET "/pulls?state=open&limit=20" | \
2026-03-12 12:44:15 +00:00
jq -r --arg issue " ixes # ${ ISSUE } \\b " \
'.[] | select(.body | test($issue; "i")) | "\(.number) \(.head.ref)"' | head -1) || true
if [ -n " $FOUND_PR " ] ; then
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
PR_NUMBER = $( printf '%s' " $FOUND_PR " | awk '{print $1}' )
BRANCH = $( printf '%s' " $FOUND_PR " | awk '{print $2}' )
log " found existing PR # ${ PR_NUMBER } on branch ${ BRANCH } (from body match) "
2026-03-12 12:44:15 +00:00
fi
fi
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
# Priority 3: check closed PRs for prior art
2026-03-12 12:44:15 +00:00
PRIOR_ART_DIFF = ""
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
if [ -z " $PR_NUMBER " ] ; then
CLOSED_PR = $( forge_api GET "/pulls?state=closed&limit=30" | \
2026-03-12 12:44:15 +00:00
jq -r --arg issue " # ${ ISSUE } " \
'.[] | select(.merged != true) | select((.title | contains($issue)) or (.body // "" | test("ixes " + $issue + "\\b"; "i"))) | "\(.number) \(.head.ref)"' | head -1) || true
if [ -n " $CLOSED_PR " ] ; then
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
CLOSED_PR_NUM = $( printf '%s' " $CLOSED_PR " | awk '{print $1}' )
2026-03-12 12:44:15 +00:00
log " found closed (unmerged) PR # ${ CLOSED_PR_NUM } as prior art "
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
PRIOR_ART_DIFF = $( forge_api GET " /pulls/ ${ CLOSED_PR_NUM } .diff " 2>/dev/null \
| head -500) || true
2026-03-12 12:44:15 +00:00
fi
fi
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
if [ -n " $PR_NUMBER " ] ; then
2026-03-12 12:44:15 +00:00
RECOVERY_MODE = true
log " RECOVERY MODE: adopting PR # ${ PR_NUMBER } on branch ${ BRANCH } "
fix: feat: tmux session manager in dev-agent.sh (#80)
Replace fire-and-forget `claude -p` calls with a persistent tmux session
that Claude Code runs in interactively. The orchestrator (dev-agent.sh)
monitors a phase file and reacts to Claude's signals:
- Session lifecycle: create `dev-{project}-{issue}` tmux session, send
the full initial prompt (issue body + phase protocol instructions) via
`tmux load-buffer` / `tmux paste-buffer`, then enter a phase monitor loop.
- Phase monitor loop: polls `/tmp/dev-session-{project}-{issue}.phase`
every 30s for mtime changes. Handles all five phase sentinels:
- PHASE:awaiting_ci → create PR if needed, poll CI, inject result
- PHASE:awaiting_review → poll for review comment, inject verdict
- PHASE:needs_human → send Matrix notification, wait for injection
- PHASE:done → call do_merge(), exit on success
- PHASE:failed → detect refusal JSON vs genuine failure, post
comment / escalate, kill session, restore backlog
- Crash recovery: if the tmux session dies unexpectedly, dev-agent.sh
restarts it in the same worktree and injects a recovery prompt with
the last known phase and git diff.
- Idle timeout: 2h with no phase update kills the session gracefully.
- PR creation moved into the PHASE:awaiting_ci handler; Claude pushes the
branch and writes the phase, orchestrator creates the PR and starts CI.
- Summary file `/tmp/dev-impl-summary-{project}-{issue}.txt` carries the
implementation summary (for PR body) and refusal JSON between Claude and
the orchestrator.
- All existing logic preserved: dep preflight, label management, do_merge()
with rebase retry, CI escalation, prior art detection, log rotation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 20:20:38 +00:00
fi
2026-03-12 12:44:15 +00:00
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
# Recover session_id from .sid file (crash recovery)
2026-03-28 06:34:26 +00:00
agent_recover_session
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
fix: feat: tmux session manager in dev-agent.sh (#80)
Replace fire-and-forget `claude -p` calls with a persistent tmux session
that Claude Code runs in interactively. The orchestrator (dev-agent.sh)
monitors a phase file and reacts to Claude's signals:
- Session lifecycle: create `dev-{project}-{issue}` tmux session, send
the full initial prompt (issue body + phase protocol instructions) via
`tmux load-buffer` / `tmux paste-buffer`, then enter a phase monitor loop.
- Phase monitor loop: polls `/tmp/dev-session-{project}-{issue}.phase`
every 30s for mtime changes. Handles all five phase sentinels:
- PHASE:awaiting_ci → create PR if needed, poll CI, inject result
- PHASE:awaiting_review → poll for review comment, inject verdict
- PHASE:needs_human → send Matrix notification, wait for injection
- PHASE:done → call do_merge(), exit on success
- PHASE:failed → detect refusal JSON vs genuine failure, post
comment / escalate, kill session, restore backlog
- Crash recovery: if the tmux session dies unexpectedly, dev-agent.sh
restarts it in the same worktree and injects a recovery prompt with
the last known phase and git diff.
- Idle timeout: 2h with no phase update kills the session gracefully.
- PR creation moved into the PHASE:awaiting_ci handler; Claude pushes the
branch and writes the phase, orchestrator creates the PR and starts CI.
- Summary file `/tmp/dev-impl-summary-{project}-{issue}.txt` carries the
implementation summary (for PR body) and refusal JSON between Claude and
the orchestrator.
- All existing logic preserved: dep preflight, label management, do_merge()
with rebase retry, CI escalation, prior art detection, log rotation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 20:20:38 +00:00
# =============================================================================
# WORKTREE SETUP
# =============================================================================
status "setting up worktree"
cd " $REPO_ROOT "
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
# Determine forge remote by matching FORGE_URL host against git remotes
_forge_host = $( printf '%s' " $FORGE_URL " | sed 's|https\?://||; s|/.*||' )
2026-03-25 06:17:34 +00:00
FORGE_REMOTE = $( git remote -v | awk -v host = " $_forge_host " '$2 ~ host && /\(push\)/ {print $1; exit}' )
FORGE_REMOTE = " ${ FORGE_REMOTE :- origin } "
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
export FORGE_REMOTE
log " forge remote: ${ FORGE_REMOTE } "
2026-03-25 06:17:34 +00:00
fix: feat: tmux session manager in dev-agent.sh (#80)
Replace fire-and-forget `claude -p` calls with a persistent tmux session
that Claude Code runs in interactively. The orchestrator (dev-agent.sh)
monitors a phase file and reacts to Claude's signals:
- Session lifecycle: create `dev-{project}-{issue}` tmux session, send
the full initial prompt (issue body + phase protocol instructions) via
`tmux load-buffer` / `tmux paste-buffer`, then enter a phase monitor loop.
- Phase monitor loop: polls `/tmp/dev-session-{project}-{issue}.phase`
every 30s for mtime changes. Handles all five phase sentinels:
- PHASE:awaiting_ci → create PR if needed, poll CI, inject result
- PHASE:awaiting_review → poll for review comment, inject verdict
- PHASE:needs_human → send Matrix notification, wait for injection
- PHASE:done → call do_merge(), exit on success
- PHASE:failed → detect refusal JSON vs genuine failure, post
comment / escalate, kill session, restore backlog
- Crash recovery: if the tmux session dies unexpectedly, dev-agent.sh
restarts it in the same worktree and injects a recovery prompt with
the last known phase and git diff.
- Idle timeout: 2h with no phase update kills the session gracefully.
- PR creation moved into the PHASE:awaiting_ci handler; Claude pushes the
branch and writes the phase, orchestrator creates the PR and starts CI.
- Summary file `/tmp/dev-impl-summary-{project}-{issue}.txt` carries the
implementation summary (for PR body) and refusal JSON between Claude and
the orchestrator.
- All existing logic preserved: dep preflight, label management, do_merge()
with rebase retry, CI escalation, prior art detection, log rotation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 20:20:38 +00:00
if [ " $RECOVERY_MODE " = true ] ; then
2026-03-27 19:06:31 +00:00
if ! worktree_recover " $WORKTREE " " $BRANCH " " $FORGE_REMOTE " ; then
log "ERROR: worktree recovery failed"
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
issue_release " $ISSUE "
CLAIMED = false
2026-03-27 19:06:31 +00:00
exit 1
fix: feat: tmux session manager in dev-agent.sh (#80)
Replace fire-and-forget `claude -p` calls with a persistent tmux session
that Claude Code runs in interactively. The orchestrator (dev-agent.sh)
monitors a phase file and reacts to Claude's signals:
- Session lifecycle: create `dev-{project}-{issue}` tmux session, send
the full initial prompt (issue body + phase protocol instructions) via
`tmux load-buffer` / `tmux paste-buffer`, then enter a phase monitor loop.
- Phase monitor loop: polls `/tmp/dev-session-{project}-{issue}.phase`
every 30s for mtime changes. Handles all five phase sentinels:
- PHASE:awaiting_ci → create PR if needed, poll CI, inject result
- PHASE:awaiting_review → poll for review comment, inject verdict
- PHASE:needs_human → send Matrix notification, wait for injection
- PHASE:done → call do_merge(), exit on success
- PHASE:failed → detect refusal JSON vs genuine failure, post
comment / escalate, kill session, restore backlog
- Crash recovery: if the tmux session dies unexpectedly, dev-agent.sh
restarts it in the same worktree and injects a recovery prompt with
the last known phase and git diff.
- Idle timeout: 2h with no phase update kills the session gracefully.
- PR creation moved into the PHASE:awaiting_ci handler; Claude pushes the
branch and writes the phase, orchestrator creates the PR and starts CI.
- Summary file `/tmp/dev-impl-summary-{project}-{issue}.txt` carries the
implementation summary (for PR body) and refusal JSON between Claude and
the orchestrator.
- All existing logic preserved: dep preflight, label management, do_merge()
with rebase retry, CI escalation, prior art detection, log rotation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 20:20:38 +00:00
fi
2026-03-12 12:44:15 +00:00
else
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
# Ensure repo is in clean state
2026-03-12 12:44:15 +00:00
if [ -d " $REPO_ROOT /.git/rebase-merge " ] || [ -d " $REPO_ROOT /.git/rebase-apply " ] ; then
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
log "WARNING: stale rebase detected — aborting"
2026-03-12 12:44:15 +00:00
git rebase --abort 2>/dev/null || true
fi
CURRENT_BRANCH = $( git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "unknown" )
2026-03-14 13:49:09 +01:00
if [ " $CURRENT_BRANCH " != " ${ PRIMARY_BRANCH } " ] ; then
git checkout " ${ PRIMARY_BRANCH } " 2>/dev/null || true
2026-03-12 12:44:15 +00:00
fi
2026-03-25 06:17:34 +00:00
git fetch " ${ FORGE_REMOTE } " " ${ PRIMARY_BRANCH } " 2>/dev/null
git pull --ff-only " ${ FORGE_REMOTE } " " ${ PRIMARY_BRANCH } " 2>/dev/null || true
2026-03-27 19:06:31 +00:00
if ! worktree_create " $WORKTREE " " $BRANCH " " ${ FORGE_REMOTE } / ${ PRIMARY_BRANCH } " ; then
2026-03-12 12:44:15 +00:00
log "ERROR: worktree creation failed"
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
issue_release " $ISSUE "
CLAIMED = false
2026-03-12 12:44:15 +00:00
exit 1
2026-03-27 19:06:31 +00:00
fi
2026-03-14 07:34:47 +00:00
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
# Symlink shared node_modules from main repo
2026-03-12 12:44:15 +00:00
for lib_dir in " $REPO_ROOT " /onchain/lib/*/; do
lib_name = $( basename " $lib_dir " )
if [ -d " $lib_dir /node_modules " ] && [ ! -d " $WORKTREE /onchain/lib/ $lib_name /node_modules " ] ; then
ln -s " $lib_dir /node_modules " " $WORKTREE /onchain/lib/ $lib_name /node_modules " 2>/dev/null || true
fi
done
fix: feat: tmux session manager in dev-agent.sh (#80)
Replace fire-and-forget `claude -p` calls with a persistent tmux session
that Claude Code runs in interactively. The orchestrator (dev-agent.sh)
monitors a phase file and reacts to Claude's signals:
- Session lifecycle: create `dev-{project}-{issue}` tmux session, send
the full initial prompt (issue body + phase protocol instructions) via
`tmux load-buffer` / `tmux paste-buffer`, then enter a phase monitor loop.
- Phase monitor loop: polls `/tmp/dev-session-{project}-{issue}.phase`
every 30s for mtime changes. Handles all five phase sentinels:
- PHASE:awaiting_ci → create PR if needed, poll CI, inject result
- PHASE:awaiting_review → poll for review comment, inject verdict
- PHASE:needs_human → send Matrix notification, wait for injection
- PHASE:done → call do_merge(), exit on success
- PHASE:failed → detect refusal JSON vs genuine failure, post
comment / escalate, kill session, restore backlog
- Crash recovery: if the tmux session dies unexpectedly, dev-agent.sh
restarts it in the same worktree and injects a recovery prompt with
the last known phase and git diff.
- Idle timeout: 2h with no phase update kills the session gracefully.
- PR creation moved into the PHASE:awaiting_ci handler; Claude pushes the
branch and writes the phase, orchestrator creates the PR and starts CI.
- Summary file `/tmp/dev-impl-summary-{project}-{issue}.txt` carries the
implementation summary (for PR body) and refusal JSON between Claude and
the orchestrator.
- All existing logic preserved: dep preflight, label management, do_merge()
with rebase retry, CI escalation, prior art detection, log rotation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 20:20:38 +00:00
fi
# =============================================================================
# BUILD PROMPT
# =============================================================================
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
OPEN_ISSUES_SUMMARY = $( forge_api GET "/issues?state=open&labels=backlog&limit=20&type=issues" | \
fix: feat: tmux session manager in dev-agent.sh (#80)
Replace fire-and-forget `claude -p` calls with a persistent tmux session
that Claude Code runs in interactively. The orchestrator (dev-agent.sh)
monitors a phase file and reacts to Claude's signals:
- Session lifecycle: create `dev-{project}-{issue}` tmux session, send
the full initial prompt (issue body + phase protocol instructions) via
`tmux load-buffer` / `tmux paste-buffer`, then enter a phase monitor loop.
- Phase monitor loop: polls `/tmp/dev-session-{project}-{issue}.phase`
every 30s for mtime changes. Handles all five phase sentinels:
- PHASE:awaiting_ci → create PR if needed, poll CI, inject result
- PHASE:awaiting_review → poll for review comment, inject verdict
- PHASE:needs_human → send Matrix notification, wait for injection
- PHASE:done → call do_merge(), exit on success
- PHASE:failed → detect refusal JSON vs genuine failure, post
comment / escalate, kill session, restore backlog
- Crash recovery: if the tmux session dies unexpectedly, dev-agent.sh
restarts it in the same worktree and injects a recovery prompt with
the last known phase and git diff.
- Idle timeout: 2h with no phase update kills the session gracefully.
- PR creation moved into the PHASE:awaiting_ci handler; Claude pushes the
branch and writes the phase, orchestrator creates the PR and starts CI.
- Summary file `/tmp/dev-impl-summary-{project}-{issue}.txt` carries the
implementation summary (for PR body) and refusal JSON between Claude and
the orchestrator.
- All existing logic preserved: dep preflight, label management, do_merge()
with rebase retry, CI escalation, prior art detection, log rotation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 20:20:38 +00:00
jq -r '.[] | "#\(.number) \(.title)"' 2>/dev/null || echo "(could not fetch)" )
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
PUSH_INSTRUCTIONS = $( build_phase_protocol_prompt " $BRANCH " " $FORGE_REMOTE " )
2026-03-20 23:27:32 +00:00
fix: feat: tmux session manager in dev-agent.sh (#80)
Replace fire-and-forget `claude -p` calls with a persistent tmux session
that Claude Code runs in interactively. The orchestrator (dev-agent.sh)
monitors a phase file and reacts to Claude's signals:
- Session lifecycle: create `dev-{project}-{issue}` tmux session, send
the full initial prompt (issue body + phase protocol instructions) via
`tmux load-buffer` / `tmux paste-buffer`, then enter a phase monitor loop.
- Phase monitor loop: polls `/tmp/dev-session-{project}-{issue}.phase`
every 30s for mtime changes. Handles all five phase sentinels:
- PHASE:awaiting_ci → create PR if needed, poll CI, inject result
- PHASE:awaiting_review → poll for review comment, inject verdict
- PHASE:needs_human → send Matrix notification, wait for injection
- PHASE:done → call do_merge(), exit on success
- PHASE:failed → detect refusal JSON vs genuine failure, post
comment / escalate, kill session, restore backlog
- Crash recovery: if the tmux session dies unexpectedly, dev-agent.sh
restarts it in the same worktree and injects a recovery prompt with
the last known phase and git diff.
- Idle timeout: 2h with no phase update kills the session gracefully.
- PR creation moved into the PHASE:awaiting_ci handler; Claude pushes the
branch and writes the phase, orchestrator creates the PR and starts CI.
- Summary file `/tmp/dev-impl-summary-{project}-{issue}.txt` carries the
implementation summary (for PR body) and refusal JSON between Claude and
the orchestrator.
- All existing logic preserved: dep preflight, label management, do_merge()
with rebase retry, CI escalation, prior art detection, log rotation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 20:20:38 +00:00
if [ " $RECOVERY_MODE " = true ] ; then
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
GIT_DIFF_STAT = $( git -C " $WORKTREE " diff " ${ FORGE_REMOTE } / ${ PRIMARY_BRANCH } ..HEAD " --stat 2>/dev/null \
| head -20 || echo "(no diff)" )
fix: feat: tmux session manager in dev-agent.sh (#80)
Replace fire-and-forget `claude -p` calls with a persistent tmux session
that Claude Code runs in interactively. The orchestrator (dev-agent.sh)
monitors a phase file and reacts to Claude's signals:
- Session lifecycle: create `dev-{project}-{issue}` tmux session, send
the full initial prompt (issue body + phase protocol instructions) via
`tmux load-buffer` / `tmux paste-buffer`, then enter a phase monitor loop.
- Phase monitor loop: polls `/tmp/dev-session-{project}-{issue}.phase`
every 30s for mtime changes. Handles all five phase sentinels:
- PHASE:awaiting_ci → create PR if needed, poll CI, inject result
- PHASE:awaiting_review → poll for review comment, inject verdict
- PHASE:needs_human → send Matrix notification, wait for injection
- PHASE:done → call do_merge(), exit on success
- PHASE:failed → detect refusal JSON vs genuine failure, post
comment / escalate, kill session, restore backlog
- Crash recovery: if the tmux session dies unexpectedly, dev-agent.sh
restarts it in the same worktree and injects a recovery prompt with
the last known phase and git diff.
- Idle timeout: 2h with no phase update kills the session gracefully.
- PR creation moved into the PHASE:awaiting_ci handler; Claude pushes the
branch and writes the phase, orchestrator creates the PR and starts CI.
- Summary file `/tmp/dev-impl-summary-{project}-{issue}.txt` carries the
implementation summary (for PR body) and refusal JSON between Claude and
the orchestrator.
- All existing logic preserved: dep preflight, label management, do_merge()
with rebase retry, CI escalation, prior art detection, log rotation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 20:20:38 +00:00
INITIAL_PROMPT = " You are working in a git worktree at ${ WORKTREE } on branch ${ BRANCH } .
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
This is issue #${ISSUE} for the ${FORGE_REPO} project.
fix: feat: tmux session manager in dev-agent.sh (#80)
Replace fire-and-forget `claude -p` calls with a persistent tmux session
that Claude Code runs in interactively. The orchestrator (dev-agent.sh)
monitors a phase file and reacts to Claude's signals:
- Session lifecycle: create `dev-{project}-{issue}` tmux session, send
the full initial prompt (issue body + phase protocol instructions) via
`tmux load-buffer` / `tmux paste-buffer`, then enter a phase monitor loop.
- Phase monitor loop: polls `/tmp/dev-session-{project}-{issue}.phase`
every 30s for mtime changes. Handles all five phase sentinels:
- PHASE:awaiting_ci → create PR if needed, poll CI, inject result
- PHASE:awaiting_review → poll for review comment, inject verdict
- PHASE:needs_human → send Matrix notification, wait for injection
- PHASE:done → call do_merge(), exit on success
- PHASE:failed → detect refusal JSON vs genuine failure, post
comment / escalate, kill session, restore backlog
- Crash recovery: if the tmux session dies unexpectedly, dev-agent.sh
restarts it in the same worktree and injects a recovery prompt with
the last known phase and git diff.
- Idle timeout: 2h with no phase update kills the session gracefully.
- PR creation moved into the PHASE:awaiting_ci handler; Claude pushes the
branch and writes the phase, orchestrator creates the PR and starts CI.
- Summary file `/tmp/dev-impl-summary-{project}-{issue}.txt` carries the
implementation summary (for PR body) and refusal JSON between Claude and
the orchestrator.
- All existing logic preserved: dep preflight, label management, do_merge()
with rebase retry, CI escalation, prior art detection, log rotation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 20:20:38 +00:00
## Issue: ${ISSUE_TITLE}
${ ISSUE_BODY }
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
fix: feat: tmux session manager in dev-agent.sh (#80)
Replace fire-and-forget `claude -p` calls with a persistent tmux session
that Claude Code runs in interactively. The orchestrator (dev-agent.sh)
monitors a phase file and reacts to Claude's signals:
- Session lifecycle: create `dev-{project}-{issue}` tmux session, send
the full initial prompt (issue body + phase protocol instructions) via
`tmux load-buffer` / `tmux paste-buffer`, then enter a phase monitor loop.
- Phase monitor loop: polls `/tmp/dev-session-{project}-{issue}.phase`
every 30s for mtime changes. Handles all five phase sentinels:
- PHASE:awaiting_ci → create PR if needed, poll CI, inject result
- PHASE:awaiting_review → poll for review comment, inject verdict
- PHASE:needs_human → send Matrix notification, wait for injection
- PHASE:done → call do_merge(), exit on success
- PHASE:failed → detect refusal JSON vs genuine failure, post
comment / escalate, kill session, restore backlog
- Crash recovery: if the tmux session dies unexpectedly, dev-agent.sh
restarts it in the same worktree and injects a recovery prompt with
the last known phase and git diff.
- Idle timeout: 2h with no phase update kills the session gracefully.
- PR creation moved into the PHASE:awaiting_ci handler; Claude pushes the
branch and writes the phase, orchestrator creates the PR and starts CI.
- Summary file `/tmp/dev-impl-summary-{project}-{issue}.txt` carries the
implementation summary (for PR body) and refusal JSON between Claude and
the orchestrator.
- All existing logic preserved: dep preflight, label management, do_merge()
with rebase retry, CI escalation, prior art detection, log rotation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 20:20:38 +00:00
## CRASH RECOVERY
Your previous session for this issue was interrupted. Resume from where you left off.
Git is the checkpoint — your code changes survived.
### Work completed before crash:
\` \` \`
${ GIT_DIFF_STAT }
\` \` \`
2026-03-12 12:44:15 +00:00
fix: feat: tmux session manager in dev-agent.sh (#80)
Replace fire-and-forget `claude -p` calls with a persistent tmux session
that Claude Code runs in interactively. The orchestrator (dev-agent.sh)
monitors a phase file and reacts to Claude's signals:
- Session lifecycle: create `dev-{project}-{issue}` tmux session, send
the full initial prompt (issue body + phase protocol instructions) via
`tmux load-buffer` / `tmux paste-buffer`, then enter a phase monitor loop.
- Phase monitor loop: polls `/tmp/dev-session-{project}-{issue}.phase`
every 30s for mtime changes. Handles all five phase sentinels:
- PHASE:awaiting_ci → create PR if needed, poll CI, inject result
- PHASE:awaiting_review → poll for review comment, inject verdict
- PHASE:needs_human → send Matrix notification, wait for injection
- PHASE:done → call do_merge(), exit on success
- PHASE:failed → detect refusal JSON vs genuine failure, post
comment / escalate, kill session, restore backlog
- Crash recovery: if the tmux session dies unexpectedly, dev-agent.sh
restarts it in the same worktree and injects a recovery prompt with
the last known phase and git diff.
- Idle timeout: 2h with no phase update kills the session gracefully.
- PR creation moved into the PHASE:awaiting_ci handler; Claude pushes the
branch and writes the phase, orchestrator creates the PR and starts CI.
- Summary file `/tmp/dev-impl-summary-{project}-{issue}.txt` carries the
implementation summary (for PR body) and refusal JSON between Claude and
the orchestrator.
- All existing logic preserved: dep preflight, label management, do_merge()
with rebase retry, CI escalation, prior art detection, log rotation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 20:20:38 +00:00
### PR: #${PR_NUMBER} (${BRANCH})
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
**IMPORTANT: PR #${PR_NUMBER} already exists — do NOT create a new PR.**
fix: feat: tmux session manager in dev-agent.sh (#80)
Replace fire-and-forget `claude -p` calls with a persistent tmux session
that Claude Code runs in interactively. The orchestrator (dev-agent.sh)
monitors a phase file and reacts to Claude's signals:
- Session lifecycle: create `dev-{project}-{issue}` tmux session, send
the full initial prompt (issue body + phase protocol instructions) via
`tmux load-buffer` / `tmux paste-buffer`, then enter a phase monitor loop.
- Phase monitor loop: polls `/tmp/dev-session-{project}-{issue}.phase`
every 30s for mtime changes. Handles all five phase sentinels:
- PHASE:awaiting_ci → create PR if needed, poll CI, inject result
- PHASE:awaiting_review → poll for review comment, inject verdict
- PHASE:needs_human → send Matrix notification, wait for injection
- PHASE:done → call do_merge(), exit on success
- PHASE:failed → detect refusal JSON vs genuine failure, post
comment / escalate, kill session, restore backlog
- Crash recovery: if the tmux session dies unexpectedly, dev-agent.sh
restarts it in the same worktree and injects a recovery prompt with
the last known phase and git diff.
- Idle timeout: 2h with no phase update kills the session gracefully.
- PR creation moved into the PHASE:awaiting_ci handler; Claude pushes the
branch and writes the phase, orchestrator creates the PR and starts CI.
- Summary file `/tmp/dev-impl-summary-{project}-{issue}.txt` carries the
implementation summary (for PR body) and refusal JSON between Claude and
the orchestrator.
- All existing logic preserved: dep preflight, label management, do_merge()
with rebase retry, CI escalation, prior art detection, log rotation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 20:20:38 +00:00
### Next steps
1. Run \` git log --oneline -5\` and \` git status\` to understand current state.
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
2. Read AGENTS.md for project conventions.
3. Address any pending review comments or CI failures.
4. Commit and push to \` ${ BRANCH } \` .
fix: feat: tmux session manager in dev-agent.sh (#80)
Replace fire-and-forget `claude -p` calls with a persistent tmux session
that Claude Code runs in interactively. The orchestrator (dev-agent.sh)
monitors a phase file and reacts to Claude's signals:
- Session lifecycle: create `dev-{project}-{issue}` tmux session, send
the full initial prompt (issue body + phase protocol instructions) via
`tmux load-buffer` / `tmux paste-buffer`, then enter a phase monitor loop.
- Phase monitor loop: polls `/tmp/dev-session-{project}-{issue}.phase`
every 30s for mtime changes. Handles all five phase sentinels:
- PHASE:awaiting_ci → create PR if needed, poll CI, inject result
- PHASE:awaiting_review → poll for review comment, inject verdict
- PHASE:needs_human → send Matrix notification, wait for injection
- PHASE:done → call do_merge(), exit on success
- PHASE:failed → detect refusal JSON vs genuine failure, post
comment / escalate, kill session, restore backlog
- Crash recovery: if the tmux session dies unexpectedly, dev-agent.sh
restarts it in the same worktree and injects a recovery prompt with
the last known phase and git diff.
- Idle timeout: 2h with no phase update kills the session gracefully.
- PR creation moved into the PHASE:awaiting_ci handler; Claude pushes the
branch and writes the phase, orchestrator creates the PR and starts CI.
- Summary file `/tmp/dev-impl-summary-{project}-{issue}.txt` carries the
implementation summary (for PR body) and refusal JSON between Claude and
the orchestrator.
- All existing logic preserved: dep preflight, label management, do_merge()
with rebase retry, CI escalation, prior art detection, log rotation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 20:20:38 +00:00
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
${ PUSH_INSTRUCTIONS } "
fix: feat: tmux session manager in dev-agent.sh (#80)
Replace fire-and-forget `claude -p` calls with a persistent tmux session
that Claude Code runs in interactively. The orchestrator (dev-agent.sh)
monitors a phase file and reacts to Claude's signals:
- Session lifecycle: create `dev-{project}-{issue}` tmux session, send
the full initial prompt (issue body + phase protocol instructions) via
`tmux load-buffer` / `tmux paste-buffer`, then enter a phase monitor loop.
- Phase monitor loop: polls `/tmp/dev-session-{project}-{issue}.phase`
every 30s for mtime changes. Handles all five phase sentinels:
- PHASE:awaiting_ci → create PR if needed, poll CI, inject result
- PHASE:awaiting_review → poll for review comment, inject verdict
- PHASE:needs_human → send Matrix notification, wait for injection
- PHASE:done → call do_merge(), exit on success
- PHASE:failed → detect refusal JSON vs genuine failure, post
comment / escalate, kill session, restore backlog
- Crash recovery: if the tmux session dies unexpectedly, dev-agent.sh
restarts it in the same worktree and injects a recovery prompt with
the last known phase and git diff.
- Idle timeout: 2h with no phase update kills the session gracefully.
- PR creation moved into the PHASE:awaiting_ci handler; Claude pushes the
branch and writes the phase, orchestrator creates the PR and starts CI.
- Summary file `/tmp/dev-impl-summary-{project}-{issue}.txt` carries the
implementation summary (for PR body) and refusal JSON between Claude and
the orchestrator.
- All existing logic preserved: dep preflight, label management, do_merge()
with rebase retry, CI escalation, prior art detection, log rotation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 20:20:38 +00:00
else
INITIAL_PROMPT = " You are working in a git worktree at ${ WORKTREE } on branch ${ BRANCH } .
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
You have been assigned issue #${ISSUE} for the ${FORGE_REPO} project.
2026-03-12 12:44:15 +00:00
## Issue: ${ISSUE_TITLE}
${ ISSUE_BODY }
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
## Other open issues labeled 'backlog' (for context):
2026-03-12 12:44:15 +00:00
${ OPEN_ISSUES_SUMMARY }
fix: feat: tmux session manager in dev-agent.sh (#80)
Replace fire-and-forget `claude -p` calls with a persistent tmux session
that Claude Code runs in interactively. The orchestrator (dev-agent.sh)
monitors a phase file and reacts to Claude's signals:
- Session lifecycle: create `dev-{project}-{issue}` tmux session, send
the full initial prompt (issue body + phase protocol instructions) via
`tmux load-buffer` / `tmux paste-buffer`, then enter a phase monitor loop.
- Phase monitor loop: polls `/tmp/dev-session-{project}-{issue}.phase`
every 30s for mtime changes. Handles all five phase sentinels:
- PHASE:awaiting_ci → create PR if needed, poll CI, inject result
- PHASE:awaiting_review → poll for review comment, inject verdict
- PHASE:needs_human → send Matrix notification, wait for injection
- PHASE:done → call do_merge(), exit on success
- PHASE:failed → detect refusal JSON vs genuine failure, post
comment / escalate, kill session, restore backlog
- Crash recovery: if the tmux session dies unexpectedly, dev-agent.sh
restarts it in the same worktree and injects a recovery prompt with
the last known phase and git diff.
- Idle timeout: 2h with no phase update kills the session gracefully.
- PR creation moved into the PHASE:awaiting_ci handler; Claude pushes the
branch and writes the phase, orchestrator creates the PR and starts CI.
- Summary file `/tmp/dev-impl-summary-{project}-{issue}.txt` carries the
implementation summary (for PR body) and refusal JSON between Claude and
the orchestrator.
- All existing logic preserved: dep preflight, label management, do_merge()
with rebase retry, CI escalation, prior art detection, log rotation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 20:20:38 +00:00
$( if [ -n " $PRIOR_ART_DIFF " ] ; then
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
printf '## Prior Art (closed PR — DO NOT start from scratch)\n\nA previous PR attempted this issue but was closed without merging. Reuse as much as possible.\n\n```diff\n%s\n```\n' " $PRIOR_ART_DIFF "
fix: feat: tmux session manager in dev-agent.sh (#80)
Replace fire-and-forget `claude -p` calls with a persistent tmux session
that Claude Code runs in interactively. The orchestrator (dev-agent.sh)
monitors a phase file and reacts to Claude's signals:
- Session lifecycle: create `dev-{project}-{issue}` tmux session, send
the full initial prompt (issue body + phase protocol instructions) via
`tmux load-buffer` / `tmux paste-buffer`, then enter a phase monitor loop.
- Phase monitor loop: polls `/tmp/dev-session-{project}-{issue}.phase`
every 30s for mtime changes. Handles all five phase sentinels:
- PHASE:awaiting_ci → create PR if needed, poll CI, inject result
- PHASE:awaiting_review → poll for review comment, inject verdict
- PHASE:needs_human → send Matrix notification, wait for injection
- PHASE:done → call do_merge(), exit on success
- PHASE:failed → detect refusal JSON vs genuine failure, post
comment / escalate, kill session, restore backlog
- Crash recovery: if the tmux session dies unexpectedly, dev-agent.sh
restarts it in the same worktree and injects a recovery prompt with
the last known phase and git diff.
- Idle timeout: 2h with no phase update kills the session gracefully.
- PR creation moved into the PHASE:awaiting_ci handler; Claude pushes the
branch and writes the phase, orchestrator creates the PR and starts CI.
- Summary file `/tmp/dev-impl-summary-{project}-{issue}.txt` carries the
implementation summary (for PR body) and refusal JSON between Claude and
the orchestrator.
- All existing logic preserved: dep preflight, label management, do_merge()
with rebase retry, CI escalation, prior art detection, log rotation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 20:20:38 +00:00
fi )
2026-03-12 12:44:15 +00:00
## Instructions
1. Read AGENTS.md in this repo for project context and coding conventions.
2. Implement the changes described in the issue.
3. Run lint and tests before you' re done ( see AGENTS.md for commands) .
4. Commit your changes with message: fix: ${ ISSUE_TITLE } ( #${ISSUE})
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
5. Push your branch.
2026-03-12 12:44:15 +00:00
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
If you cannot implement this issue, write ONLY a JSON object to ${ IMPL_SUMMARY_FILE } :
- Unmet dependency: { \" status\" :\" unmet_dependency\" ,\" blocked_by\" :\" what' s missing\" ,\" suggestion\" :<number-or-null>}
- Too large: { \" status\" :\" too_large\" ,\" reason\" :\" explanation\" }
- Already done : { \" status\" :\" already_done\" ,\" reason\" :\" where\" }
2026-03-12 12:44:15 +00:00
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
${ PUSH_INSTRUCTIONS } "
fi
2026-03-12 12:44:15 +00:00
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
# =============================================================================
# IMPLEMENT
# =============================================================================
status "running implementation"
echo '{"status":"ready"}' > " $PREFLIGHT_RESULT "
2026-03-12 12:44:15 +00:00
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
if [ -n " $_AGENT_SESSION_ID " ] ; then
agent_run --resume " $_AGENT_SESSION_ID " --worktree " $WORKTREE " " $INITIAL_PROMPT "
else
agent_run --worktree " $WORKTREE " " $INITIAL_PROMPT "
fi
2026-03-12 12:44:15 +00:00
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
# =============================================================================
# CHECK RESULT: did Claude push?
# =============================================================================
REMOTE_SHA = $( git ls-remote " $FORGE_REMOTE " " refs/heads/ ${ BRANCH } " 2>/dev/null \
| awk '{print $1}' ) || true
if [ -z " $REMOTE_SHA " ] ; then
# Check for refusal in summary file
if [ -f " $IMPL_SUMMARY_FILE " ] && jq -e '.status' < " $IMPL_SUMMARY_FILE " >/dev/null 2>& 1; then
REFUSAL_JSON = $( cat " $IMPL_SUMMARY_FILE " )
REFUSAL_STATUS = $( printf '%s' " $REFUSAL_JSON " | jq -r '.status' )
log " claude refused: ${ REFUSAL_STATUS } "
printf '%s' " $REFUSAL_JSON " > " $PREFLIGHT_RESULT "
case " $REFUSAL_STATUS " in
unmet_dependency)
BLOCKED_BY_MSG = $( printf '%s' " $REFUSAL_JSON " | jq -r '.blocked_by // "unknown"' )
SUGGESTION = $( printf '%s' " $REFUSAL_JSON " | jq -r '.suggestion // empty' )
COMMENT_BODY = " ### Blocked by unmet dependency
${ BLOCKED_BY_MSG } "
[ -n " $SUGGESTION " ] && [ " $SUGGESTION " != "null" ] && \
COMMENT_BODY = " ${ COMMENT_BODY }
fix: feat: tmux session manager in dev-agent.sh (#80)
Replace fire-and-forget `claude -p` calls with a persistent tmux session
that Claude Code runs in interactively. The orchestrator (dev-agent.sh)
monitors a phase file and reacts to Claude's signals:
- Session lifecycle: create `dev-{project}-{issue}` tmux session, send
the full initial prompt (issue body + phase protocol instructions) via
`tmux load-buffer` / `tmux paste-buffer`, then enter a phase monitor loop.
- Phase monitor loop: polls `/tmp/dev-session-{project}-{issue}.phase`
every 30s for mtime changes. Handles all five phase sentinels:
- PHASE:awaiting_ci → create PR if needed, poll CI, inject result
- PHASE:awaiting_review → poll for review comment, inject verdict
- PHASE:needs_human → send Matrix notification, wait for injection
- PHASE:done → call do_merge(), exit on success
- PHASE:failed → detect refusal JSON vs genuine failure, post
comment / escalate, kill session, restore backlog
- Crash recovery: if the tmux session dies unexpectedly, dev-agent.sh
restarts it in the same worktree and injects a recovery prompt with
the last known phase and git diff.
- Idle timeout: 2h with no phase update kills the session gracefully.
- PR creation moved into the PHASE:awaiting_ci handler; Claude pushes the
branch and writes the phase, orchestrator creates the PR and starts CI.
- Summary file `/tmp/dev-impl-summary-{project}-{issue}.txt` carries the
implementation summary (for PR body) and refusal JSON between Claude and
the orchestrator.
- All existing logic preserved: dep preflight, label management, do_merge()
with rebase retry, CI escalation, prior art detection, log rotation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 20:20:38 +00:00
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
**Suggestion:** Work on #${SUGGESTION} first."
issue_post_refusal " $ISSUE " "🚧" "Unmet dependency" " $COMMENT_BODY "
issue_release " $ISSUE "
CLAIMED = false
; ;
too_large)
REASON = $( printf '%s' " $REFUSAL_JSON " | jq -r '.reason // "unspecified"' )
issue_post_refusal " $ISSUE " "📏" "Too large for single session" \
" ### Why this can't be implemented as-is
2026-03-12 12:44:15 +00:00
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
${ REASON }
2026-03-12 12:44:15 +00:00
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
### Next steps
A maintainer should split this issue or add more detail to the spec."
# Add underspecified label, remove backlog + in-progress
UNDERSPEC_ID = $( forge_api GET "/labels" 2>/dev/null \
| jq -r '.[] | select(.name == "underspecified") | .id' 2>/dev/null || true )
if [ -n " $UNDERSPEC_ID " ] ; then
forge_api POST " /issues/ ${ ISSUE } /labels " \
-d " {\"labels\":[ ${ UNDERSPEC_ID } ]} " >/dev/null 2>& 1 || true
fi
BACKLOG_ID = $( forge_api GET "/labels" 2>/dev/null \
| jq -r '.[] | select(.name == "backlog") | .id' 2>/dev/null || true )
if [ -n " $BACKLOG_ID " ] ; then
forge_api DELETE " /issues/ ${ ISSUE } /labels/ ${ BACKLOG_ID } " >/dev/null 2>& 1 || true
fi
IP_ID = $( forge_api GET "/labels" 2>/dev/null \
| jq -r '.[] | select(.name == "in-progress") | .id' 2>/dev/null || true )
if [ -n " $IP_ID " ] ; then
forge_api DELETE " /issues/ ${ ISSUE } /labels/ ${ IP_ID } " >/dev/null 2>& 1 || true
fi
CLAIMED = false
; ;
already_done)
REASON = $( printf '%s' " $REFUSAL_JSON " | jq -r '.reason // "unspecified"' )
issue_post_refusal " $ISSUE " "✅" "Already implemented" \
" ### Existing implementation
${ REASON }
Closing as already implemented."
issue_close " $ISSUE "
CLAIMED = false
; ;
esac
worktree_cleanup " $WORKTREE "
rm -f " $SID_FILE " " $IMPL_SUMMARY_FILE "
exit 0
fi
2026-03-20 20:12:45 +00:00
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
log "ERROR: no branch pushed after agent_run"
2026-03-28 23:03:17 +00:00
# Dump diagnostics
2026-03-29 07:14:10 +00:00
diag_file = " ${ DISINTO_LOG_DIR :- /tmp } /dev/agent-run-last.json "
2026-03-28 23:03:17 +00:00
if [ -f " $diag_file " ] ; then
2026-03-29 07:14:10 +00:00
result_text = "" ; cost_usd = "" ; num_turns = ""
2026-03-28 23:03:17 +00:00
result_text = $( jq -r '.result // "no result field"' " $diag_file " 2>/dev/null | head -50) || result_text = "(parse error)"
cost_usd = $( jq -r '.cost_usd // "?"' " $diag_file " 2>/dev/null) || cost_usd = "?"
num_turns = $( jq -r '.num_turns // "?"' " $diag_file " 2>/dev/null) || num_turns = "?"
log " no_push diagnostics: turns= ${ num_turns } cost= ${ cost_usd } "
log " no_push result: ${ result_text } "
# Save full output for later analysis
cp " $diag_file " " ${ DISINTO_LOG_DIR :- /tmp } /dev/no-push- ${ ISSUE } - $( date +%s) .json " 2>/dev/null || true
fi
2026-03-29 11:21:42 +00:00
# Save full session log for debugging
# Session logs are stored in CLAUDE_CONFIG_DIR/projects/{worktree-hash}/{session-id}.jsonl
_wt_hash = $( printf '%s' " $WORKTREE " | md5sum | cut -c1-12)
_cl_config = " ${ CLAUDE_CONFIG_DIR :- $HOME /.claude } "
_session_log = " ${ _cl_config } /projects/ ${ _wt_hash } / ${ _AGENT_SESSION_ID } .jsonl "
if [ -f " $_session_log " ] ; then
cp " $_session_log " " ${ DISINTO_LOG_DIR } /dev/no-push-session- ${ ISSUE } - $( date +%s) .jsonl " 2>/dev/null || true
log " no_push session log saved to ${ DISINTO_LOG_DIR } /dev/no-push-session- ${ ISSUE } -*.jsonl "
fi
# Log session summary for debugging
if [ -f " $_session_log " ] ; then
_read_calls = $( grep -c '"type":"read"' " $_session_log " 2>/dev/null || echo "0" )
_edit_calls = $( grep -c '"type":"edit"' " $_session_log " 2>/dev/null || echo "0" )
_bash_calls = $( grep -c '"type":"bash"' " $_session_log " 2>/dev/null || echo "0" )
_text_calls = $( grep -c '"type":"text"' " $_session_log " 2>/dev/null || echo "0" )
_failed_calls = $( grep -c '"exit_code":null' " $_session_log " 2>/dev/null || echo "0" )
_total_turns = $( grep -c '"type":"turn"' " $_session_log " 2>/dev/null || echo "0" )
log " no_push session summary: turns= ${ _total_turns } reads= ${ _read_calls } edits= ${ _edit_calls } bash= ${ _bash_calls } text= ${ _text_calls } failed= ${ _failed_calls } "
fi
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
issue_block " $ISSUE " "no_push" " Claude did not push branch ${ BRANCH } "
CLAIMED = false
worktree_cleanup " $WORKTREE "
rm -f " $SID_FILE " " $IMPL_SUMMARY_FILE "
exit 1
fix: feat: tmux session manager in dev-agent.sh (#80)
Replace fire-and-forget `claude -p` calls with a persistent tmux session
that Claude Code runs in interactively. The orchestrator (dev-agent.sh)
monitors a phase file and reacts to Claude's signals:
- Session lifecycle: create `dev-{project}-{issue}` tmux session, send
the full initial prompt (issue body + phase protocol instructions) via
`tmux load-buffer` / `tmux paste-buffer`, then enter a phase monitor loop.
- Phase monitor loop: polls `/tmp/dev-session-{project}-{issue}.phase`
every 30s for mtime changes. Handles all five phase sentinels:
- PHASE:awaiting_ci → create PR if needed, poll CI, inject result
- PHASE:awaiting_review → poll for review comment, inject verdict
- PHASE:needs_human → send Matrix notification, wait for injection
- PHASE:done → call do_merge(), exit on success
- PHASE:failed → detect refusal JSON vs genuine failure, post
comment / escalate, kill session, restore backlog
- Crash recovery: if the tmux session dies unexpectedly, dev-agent.sh
restarts it in the same worktree and injects a recovery prompt with
the last known phase and git diff.
- Idle timeout: 2h with no phase update kills the session gracefully.
- PR creation moved into the PHASE:awaiting_ci handler; Claude pushes the
branch and writes the phase, orchestrator creates the PR and starts CI.
- Summary file `/tmp/dev-impl-summary-{project}-{issue}.txt` carries the
implementation summary (for PR body) and refusal JSON between Claude and
the orchestrator.
- All existing logic preserved: dep preflight, label management, do_merge()
with rebase retry, CI escalation, prior art detection, log rotation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 20:20:38 +00:00
fi
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
log " branch pushed: ${ REMOTE_SHA : 0 : 7 } "
fix: feat: tmux session manager in dev-agent.sh (#80)
Replace fire-and-forget `claude -p` calls with a persistent tmux session
that Claude Code runs in interactively. The orchestrator (dev-agent.sh)
monitors a phase file and reacts to Claude's signals:
- Session lifecycle: create `dev-{project}-{issue}` tmux session, send
the full initial prompt (issue body + phase protocol instructions) via
`tmux load-buffer` / `tmux paste-buffer`, then enter a phase monitor loop.
- Phase monitor loop: polls `/tmp/dev-session-{project}-{issue}.phase`
every 30s for mtime changes. Handles all five phase sentinels:
- PHASE:awaiting_ci → create PR if needed, poll CI, inject result
- PHASE:awaiting_review → poll for review comment, inject verdict
- PHASE:needs_human → send Matrix notification, wait for injection
- PHASE:done → call do_merge(), exit on success
- PHASE:failed → detect refusal JSON vs genuine failure, post
comment / escalate, kill session, restore backlog
- Crash recovery: if the tmux session dies unexpectedly, dev-agent.sh
restarts it in the same worktree and injects a recovery prompt with
the last known phase and git diff.
- Idle timeout: 2h with no phase update kills the session gracefully.
- PR creation moved into the PHASE:awaiting_ci handler; Claude pushes the
branch and writes the phase, orchestrator creates the PR and starts CI.
- Summary file `/tmp/dev-impl-summary-{project}-{issue}.txt` carries the
implementation summary (for PR body) and refusal JSON between Claude and
the orchestrator.
- All existing logic preserved: dep preflight, label management, do_merge()
with rebase retry, CI escalation, prior art detection, log rotation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 20:20:38 +00:00
# =============================================================================
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
# CREATE PR (if not in recovery mode)
fix: feat: tmux session manager in dev-agent.sh (#80)
Replace fire-and-forget `claude -p` calls with a persistent tmux session
that Claude Code runs in interactively. The orchestrator (dev-agent.sh)
monitors a phase file and reacts to Claude's signals:
- Session lifecycle: create `dev-{project}-{issue}` tmux session, send
the full initial prompt (issue body + phase protocol instructions) via
`tmux load-buffer` / `tmux paste-buffer`, then enter a phase monitor loop.
- Phase monitor loop: polls `/tmp/dev-session-{project}-{issue}.phase`
every 30s for mtime changes. Handles all five phase sentinels:
- PHASE:awaiting_ci → create PR if needed, poll CI, inject result
- PHASE:awaiting_review → poll for review comment, inject verdict
- PHASE:needs_human → send Matrix notification, wait for injection
- PHASE:done → call do_merge(), exit on success
- PHASE:failed → detect refusal JSON vs genuine failure, post
comment / escalate, kill session, restore backlog
- Crash recovery: if the tmux session dies unexpectedly, dev-agent.sh
restarts it in the same worktree and injects a recovery prompt with
the last known phase and git diff.
- Idle timeout: 2h with no phase update kills the session gracefully.
- PR creation moved into the PHASE:awaiting_ci handler; Claude pushes the
branch and writes the phase, orchestrator creates the PR and starts CI.
- Summary file `/tmp/dev-impl-summary-{project}-{issue}.txt` carries the
implementation summary (for PR body) and refusal JSON between Claude and
the orchestrator.
- All existing logic preserved: dep preflight, label management, do_merge()
with rebase retry, CI escalation, prior art detection, log rotation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 20:20:38 +00:00
# =============================================================================
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
if [ -z " $PR_NUMBER " ] ; then
status "creating PR"
IMPL_SUMMARY = ""
if [ -f " $IMPL_SUMMARY_FILE " ] ; then
if ! jq -e '.status' < " $IMPL_SUMMARY_FILE " >/dev/null 2>& 1; then
IMPL_SUMMARY = $( head -c 4000 " $IMPL_SUMMARY_FILE " )
fi
fi
fix: feat: tmux session manager in dev-agent.sh (#80)
Replace fire-and-forget `claude -p` calls with a persistent tmux session
that Claude Code runs in interactively. The orchestrator (dev-agent.sh)
monitors a phase file and reacts to Claude's signals:
- Session lifecycle: create `dev-{project}-{issue}` tmux session, send
the full initial prompt (issue body + phase protocol instructions) via
`tmux load-buffer` / `tmux paste-buffer`, then enter a phase monitor loop.
- Phase monitor loop: polls `/tmp/dev-session-{project}-{issue}.phase`
every 30s for mtime changes. Handles all five phase sentinels:
- PHASE:awaiting_ci → create PR if needed, poll CI, inject result
- PHASE:awaiting_review → poll for review comment, inject verdict
- PHASE:needs_human → send Matrix notification, wait for injection
- PHASE:done → call do_merge(), exit on success
- PHASE:failed → detect refusal JSON vs genuine failure, post
comment / escalate, kill session, restore backlog
- Crash recovery: if the tmux session dies unexpectedly, dev-agent.sh
restarts it in the same worktree and injects a recovery prompt with
the last known phase and git diff.
- Idle timeout: 2h with no phase update kills the session gracefully.
- PR creation moved into the PHASE:awaiting_ci handler; Claude pushes the
branch and writes the phase, orchestrator creates the PR and starts CI.
- Summary file `/tmp/dev-impl-summary-{project}-{issue}.txt` carries the
implementation summary (for PR body) and refusal JSON between Claude and
the orchestrator.
- All existing logic preserved: dep preflight, label management, do_merge()
with rebase retry, CI escalation, prior art detection, log rotation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 20:20:38 +00:00
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
PR_BODY = $( printf 'Fixes #%s\n\n## Changes\n%s' " $ISSUE " " $IMPL_SUMMARY " )
PR_TITLE = " fix: ${ ISSUE_TITLE } (# ${ ISSUE } ) "
PR_NUMBER = $( pr_create " $BRANCH " " $PR_TITLE " " $PR_BODY " ) || true
if [ -z " $PR_NUMBER " ] ; then
log "ERROR: failed to create PR"
issue_block " $ISSUE " "pr_create_failed"
CLAIMED = false
exit 1
fi
log " created PR # ${ PR_NUMBER } "
fix: feat: tmux session manager in dev-agent.sh (#80)
Replace fire-and-forget `claude -p` calls with a persistent tmux session
that Claude Code runs in interactively. The orchestrator (dev-agent.sh)
monitors a phase file and reacts to Claude's signals:
- Session lifecycle: create `dev-{project}-{issue}` tmux session, send
the full initial prompt (issue body + phase protocol instructions) via
`tmux load-buffer` / `tmux paste-buffer`, then enter a phase monitor loop.
- Phase monitor loop: polls `/tmp/dev-session-{project}-{issue}.phase`
every 30s for mtime changes. Handles all five phase sentinels:
- PHASE:awaiting_ci → create PR if needed, poll CI, inject result
- PHASE:awaiting_review → poll for review comment, inject verdict
- PHASE:needs_human → send Matrix notification, wait for injection
- PHASE:done → call do_merge(), exit on success
- PHASE:failed → detect refusal JSON vs genuine failure, post
comment / escalate, kill session, restore backlog
- Crash recovery: if the tmux session dies unexpectedly, dev-agent.sh
restarts it in the same worktree and injects a recovery prompt with
the last known phase and git diff.
- Idle timeout: 2h with no phase update kills the session gracefully.
- PR creation moved into the PHASE:awaiting_ci handler; Claude pushes the
branch and writes the phase, orchestrator creates the PR and starts CI.
- Summary file `/tmp/dev-impl-summary-{project}-{issue}.txt` carries the
implementation summary (for PR body) and refusal JSON between Claude and
the orchestrator.
- All existing logic preserved: dep preflight, label management, do_merge()
with rebase retry, CI escalation, prior art detection, log rotation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 20:20:38 +00:00
fi
2026-03-12 12:44:15 +00:00
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
# =============================================================================
# WALK PR TO MERGE
# =============================================================================
status " walking PR # ${ PR_NUMBER } to merge "
rc = 0
pr_walk_to_merge " $PR_NUMBER " " $_AGENT_SESSION_ID " " $WORKTREE " 3 5 || rc = $?
2026-03-12 12:44:15 +00:00
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
if [ " $rc " -eq 0 ] ; then
# Merged successfully
log " PR # ${ PR_NUMBER } merged "
issue_close " $ISSUE "
refactor: extract lib/agent-session.sh — reusable tmux + Claude agent runtime (#158)
Move generic agent infrastructure from dev/dev-agent.sh into lib/agent-session.sh:
- log, status, notify, notify_ctx, read_phase, wait_for_claude_ready,
inject_into_session, kill_tmux_session extracted verbatim
- create_agent_session(session_name, workdir) — new: tmux session creation
- inject_formula(session_name, formula_text, context) — new: prompt injection
- monitor_phase_loop(phase_file, idle_timeout, callback_fn) — new: phase loop
with session health check, crash recovery, and idle timeout detection
dev-agent.sh: sources the library, implements _on_phase_change() callback,
calls monitor_phase_loop(); idle-timeout and crash-recovery-failed cleanup
handled via _MONITOR_LOOP_EXIT signal variable. Behavior unchanged.
2026-03-18 14:36:36 +00:00
fix: Migrate dev-agent.sh to SDK + shared libraries (#798)
Rewrite dev-agent.sh from tmux session manager to synchronous bash loop:
- Replace tmux + phase-handler with synchronous claude -p invocations
- Define agent_run() wrapping claude -p with --resume for session continuity
- Use .sid file to persist session_id across crash recovery
- Delegate CI/review loop to pr_walk_to_merge() from lib/pr-lifecycle.sh
- Replace inline label management with lib/issue-lifecycle.sh
(issue_claim, issue_release, issue_block, issue_close, issue_check_deps)
- Replace inline worktree management with lib/worktree.sh
(worktree_create, worktree_recover, worktree_cleanup)
- Use pr_create/pr_find_by_branch from lib/pr-lifecycle.sh
- Use build_phase_protocol_prompt for push instructions
- Keep: issue fetch, recovery mode, prior art, prompt composition,
concurrency lock, memory guard, refusal handling
The script drops from 745 to ~500 lines. No tmux sessions, no phase
file monitoring, no phase-handler.sh dependency.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:15:04 +00:00
# Pull primary branch and push to mirrors
git -C " $REPO_ROOT " fetch " $FORGE_REMOTE " " $PRIMARY_BRANCH " 2>/dev/null || true
git -C " $REPO_ROOT " checkout " $PRIMARY_BRANCH " 2>/dev/null || true
git -C " $REPO_ROOT " pull --ff-only " $FORGE_REMOTE " " $PRIMARY_BRANCH " 2>/dev/null || true
mirror_push
worktree_cleanup " $WORKTREE "
rm -f " $SID_FILE " " $IMPL_SUMMARY_FILE "
CLAIMED = false
else
# Exhausted or unrecoverable failure
log " PR walk failed: ${ _PR_WALK_EXIT_REASON :- unknown } "
issue_block " $ISSUE " " ${ _PR_WALK_EXIT_REASON :- agent_failed } "
CLAIMED = false
fi
fix: feat: tmux session manager in dev-agent.sh (#80)
Replace fire-and-forget `claude -p` calls with a persistent tmux session
that Claude Code runs in interactively. The orchestrator (dev-agent.sh)
monitors a phase file and reacts to Claude's signals:
- Session lifecycle: create `dev-{project}-{issue}` tmux session, send
the full initial prompt (issue body + phase protocol instructions) via
`tmux load-buffer` / `tmux paste-buffer`, then enter a phase monitor loop.
- Phase monitor loop: polls `/tmp/dev-session-{project}-{issue}.phase`
every 30s for mtime changes. Handles all five phase sentinels:
- PHASE:awaiting_ci → create PR if needed, poll CI, inject result
- PHASE:awaiting_review → poll for review comment, inject verdict
- PHASE:needs_human → send Matrix notification, wait for injection
- PHASE:done → call do_merge(), exit on success
- PHASE:failed → detect refusal JSON vs genuine failure, post
comment / escalate, kill session, restore backlog
- Crash recovery: if the tmux session dies unexpectedly, dev-agent.sh
restarts it in the same worktree and injects a recovery prompt with
the last known phase and git diff.
- Idle timeout: 2h with no phase update kills the session gracefully.
- PR creation moved into the PHASE:awaiting_ci handler; Claude pushes the
branch and writes the phase, orchestrator creates the PR and starts CI.
- Summary file `/tmp/dev-impl-summary-{project}-{issue}.txt` carries the
implementation summary (for PR body) and refusal JSON between Claude and
the orchestrator.
- All existing logic preserved: dep preflight, label management, do_merge()
with rebase retry, CI escalation, prior art detection, log rotation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 20:20:38 +00:00
2026-03-12 12:44:15 +00:00
log " dev-agent finished for issue # ${ ISSUE } "