|
|
@@ -0,0 +1,59 @@
|
|
|
+# EXAMPLE scheduler for the pr-babysitter L1 loop — the "clone-and-run" glue.
|
|
|
+# Copy to .github/workflows/pr-babysitter.yml, PIN the action/CLI versions, add the
|
|
|
+# ANTHROPIC_API_KEY secret. The SCHEDULER is the authorizer (no auto-mode session in the
|
|
|
+# loop), and the child runs gated (--permission-mode dontAsk + a narrow allowlist), never
|
|
|
+# bypassPermissions on a shared runner. See references/claude-code-loops.md.
|
|
|
+name: pr-babysitter
|
|
|
+on:
|
|
|
+ schedule:
|
|
|
+ - cron: "*/10 * * * *" # every 10 min (matches loop.config.yaml cadence: 10m)
|
|
|
+ workflow_dispatch: {}
|
|
|
+
|
|
|
+permissions:
|
|
|
+ contents: write # commit STATE.md / run-log.md back
|
|
|
+ pull-requests: write # post the at-most-one summary comment (L1 stays report-only)
|
|
|
+
|
|
|
+concurrency:
|
|
|
+ group: pr-babysitter # never overlap two ticks
|
|
|
+ cancel-in-progress: false
|
|
|
+
|
|
|
+jobs:
|
|
|
+ tick:
|
|
|
+ runs-on: ubuntu-latest
|
|
|
+ steps:
|
|
|
+ - uses: actions/checkout@v4 # <-- pin to a SHA in production
|
|
|
+
|
|
|
+ # Kill switch: a 'loop-pause' label on the repo, or a committed PAUSED sentinel.
|
|
|
+ - name: Honor the kill switch
|
|
|
+ id: gate
|
|
|
+ env: { GH_TOKEN: "${{ github.token }}" }
|
|
|
+ run: |
|
|
|
+ if [ -f .loops/pr-babysitter/PAUSED ]; then echo "paused=1" >> "$GITHUB_OUTPUT"; fi
|
|
|
+ if gh label list --limit 100 | grep -qi '^loop-pause'; then echo "paused=1" >> "$GITHUB_OUTPUT"; fi
|
|
|
+
|
|
|
+ - name: Install Claude Code
|
|
|
+ if: steps.gate.outputs.paused != '1'
|
|
|
+ run: npm i -g @anthropic-ai/claude-code # <-- pin a version
|
|
|
+
|
|
|
+ # The run: same prompt every tick (cache-friendly), gated with dontAsk + an
|
|
|
+ # allowlist scoped to exactly what an L1 report loop needs (read-only + gh + STATE writes).
|
|
|
+ - name: Run one tick
|
|
|
+ if: steps.gate.outputs.paused != '1'
|
|
|
+ env:
|
|
|
+ ANTHROPIC_API_KEY: "${{ secrets.ANTHROPIC_API_KEY }}"
|
|
|
+ run: |
|
|
|
+ cd .loops/pr-babysitter
|
|
|
+ claude -p "$(cat run.md)" \
|
|
|
+ --permission-mode dontAsk \
|
|
|
+ --append-system-prompt "$(cat STATE.md)" \
|
|
|
+ --allowedTools 'Bash(gh pr list:*)' 'Bash(gh pr view:*)' 'Bash(gh pr comment:*)' 'Read' 'Write(STATE.md)' 'Write(run-log.md)' \
|
|
|
+ --max-turns 30
|
|
|
+
|
|
|
+ - name: Persist STATE + run-log
|
|
|
+ if: steps.gate.outputs.paused != '1'
|
|
|
+ run: |
|
|
|
+ git config user.name "pr-babysitter-loop"
|
|
|
+ git config user.email "loop@users.noreply.github.com"
|
|
|
+ git add .loops/pr-babysitter/STATE.md .loops/pr-babysitter/run-log.md
|
|
|
+ git diff --cached --quiet || git commit -m "chore(loop): pr-babysitter tick $(date -u +%FT%TZ)"
|
|
|
+ git push
|