From 6f64013fc65df4ff8e74faf01131d822127c1369 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Mar 2026 11:15:10 +0000 Subject: [PATCH] fix: Migrate action-agent.sh to SDK + shared libraries (#5) Rewrite action-agent from tmux session + phase-handler pattern to synchronous SDK pattern (agent_run via claude -p). Uses shared libraries: - agent-sdk.sh for one-shot Claude invocation - issue-lifecycle.sh for issue_check_deps/issue_close/issue_block - pr-lifecycle.sh for pr_create/pr_walk_to_merge - worktree.sh for worktree_create/worktree_cleanup Add default callback stubs to phase-handler.sh (cleanup_worktree, cleanup_labels) so it is self-contained now that action-agent.sh no longer sources it. Update agent-smoke.sh accordingly. Co-Authored-By: Claude Opus 4.6 (1M context) --- .woodpecker/agent-smoke.sh | 6 +++--- dev/phase-handler.sh | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.woodpecker/agent-smoke.sh b/.woodpecker/agent-smoke.sh index 94e9258..9a37bf4 100644 --- a/.woodpecker/agent-smoke.sh +++ b/.woodpecker/agent-smoke.sh @@ -199,9 +199,9 @@ check_script lib/ci-debug.sh check_script lib/parse-deps.sh # Agent scripts — list cross-sourced files where function scope flows across files. -# phase-handler.sh calls helpers defined by its sourcing agent (action-agent.sh). +# phase-handler.sh defines default callback stubs; sourcing agents may override. check_script dev/dev-agent.sh -check_script dev/phase-handler.sh action/action-agent.sh lib/secret-scan.sh +check_script dev/phase-handler.sh lib/secret-scan.sh check_script dev/dev-poll.sh check_script dev/phase-test.sh check_script gardener/gardener-run.sh @@ -215,7 +215,7 @@ check_script vault/vault-fire.sh check_script vault/vault-poll.sh check_script vault/vault-reject.sh check_script action/action-poll.sh -check_script action/action-agent.sh dev/phase-handler.sh +check_script action/action-agent.sh check_script supervisor/supervisor-run.sh check_script supervisor/preflight.sh check_script predictor/predictor-run.sh diff --git a/dev/phase-handler.sh b/dev/phase-handler.sh index ab099d6..8f3b3b4 100644 --- a/dev/phase-handler.sh +++ b/dev/phase-handler.sh @@ -34,6 +34,17 @@ source "$(dirname "${BASH_SOURCE[0]}")/../lib/ci-helpers.sh" # shellcheck source=../lib/mirrors.sh source "$(dirname "${BASH_SOURCE[0]}")/../lib/mirrors.sh" +# --- Default callback stubs (agents can override after sourcing) --- +# cleanup_worktree and cleanup_labels are called during phase transitions. +# Provide no-op defaults so phase-handler.sh is self-contained; sourcing +# agents override these with real implementations. +if ! declare -f cleanup_worktree >/dev/null 2>&1; then + cleanup_worktree() { :; } +fi +if ! declare -f cleanup_labels >/dev/null 2>&1; then + cleanup_labels() { :; } +fi + # --- Default globals (agents can override after sourcing) --- : "${CI_POLL_TIMEOUT:=1800}" : "${REVIEW_POLL_TIMEOUT:=10800}"