fix: feat: planner as cron-driven formula (no issue tracking) (#232)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b4dce50f2c
commit
6c7557e87b
8 changed files with 305 additions and 647 deletions
|
|
@ -1,8 +1,10 @@
|
|||
#!/usr/bin/env bash
|
||||
# =============================================================================
|
||||
# planner-poll.sh — Cron wrapper for planner-agent
|
||||
# planner-poll.sh — Cron wrapper: files action issue for run-planner formula
|
||||
#
|
||||
# Runs weekly (or on-demand). Guards against concurrent runs and low memory.
|
||||
# Files an action issue referencing formulas/run-planner.toml; the action-agent
|
||||
# picks it up and executes the planning steps in an interactive Claude session.
|
||||
# =============================================================================
|
||||
set -euo pipefail
|
||||
|
||||
|
|
@ -38,14 +40,53 @@ fi
|
|||
|
||||
log "--- Planner poll start ---"
|
||||
|
||||
# ── Run planner agent ─────────────────────────────────────────────────────
|
||||
"$SCRIPT_DIR/planner-agent.sh" 2>&1 | while IFS= read -r line; do
|
||||
log " $line"
|
||||
done
|
||||
|
||||
EXIT_CODE=${PIPESTATUS[0]}
|
||||
if [ "$EXIT_CODE" -ne 0 ]; then
|
||||
log "poll: planner-agent exited with code $EXIT_CODE"
|
||||
# ── Dedup: skip if an open run-planner action issue already exists ────────
|
||||
OPEN_ACTIONS=$(codeberg_api GET "/issues?state=open&type=issues&labels=action&limit=50" 2>/dev/null || true)
|
||||
if [ -n "$OPEN_ACTIONS" ] && [ "$OPEN_ACTIONS" != "null" ]; then
|
||||
EXISTING=$(printf '%s' "$OPEN_ACTIONS" | \
|
||||
jq '[.[] | select(.title | test("run-planner"))] | length' 2>/dev/null || echo 0)
|
||||
if [ "${EXISTING:-0}" -gt 0 ]; then
|
||||
log "poll: open run-planner action issue already exists — skipping"
|
||||
log "--- Planner poll done ---"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# ── Fetch 'action' label ID ──────────────────────────────────────────────
|
||||
ACTION_LABEL_ID=$(codeberg_api GET "/labels" 2>/dev/null | \
|
||||
jq -r '.[] | select(.name == "action") | .id' 2>/dev/null || true)
|
||||
|
||||
if [ -z "$ACTION_LABEL_ID" ]; then
|
||||
log "ERROR: 'action' label not found — cannot file planner issue"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# ── File action issue ─────────────────────────────────────────────────────
|
||||
ISSUE_BODY="---
|
||||
formula: run-planner
|
||||
---
|
||||
|
||||
Periodic strategic planning run. The action-agent reads \`formulas/run-planner.toml\`
|
||||
and executes the five phases: preflight, AGENTS.md update, prediction triage,
|
||||
strategic planning (resource+leverage gap analysis), and memory update.
|
||||
|
||||
Filed automatically by \`planner-poll.sh\`."
|
||||
|
||||
PAYLOAD=$(jq -nc \
|
||||
--arg title "action: run-planner — periodic strategic planning" \
|
||||
--arg body "$ISSUE_BODY" \
|
||||
--argjson labels "[$ACTION_LABEL_ID]" \
|
||||
'{title: $title, body: $body, labels: $labels}')
|
||||
|
||||
RESULT=$(codeberg_api POST "/issues" -d "$PAYLOAD" 2>/dev/null || true)
|
||||
ISSUE_NUM=$(printf '%s' "$RESULT" | jq -r '.number // empty' 2>/dev/null || true)
|
||||
|
||||
if [ -z "$ISSUE_NUM" ]; then
|
||||
log "ERROR: failed to create action issue for run-planner"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log "Filed action issue #${ISSUE_NUM} for run-planner formula"
|
||||
matrix_send "planner" "Filed action #${ISSUE_NUM}: run-planner — periodic strategic planning" 2>/dev/null || true
|
||||
|
||||
log "--- Planner poll done ---"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue