local-llm/agent-loop/README.md
Philip Peterson 01522a0573 Add the nugitea daily agent loop
nugitea-daily.sh runs opencode with qwen3-coder over elixir_nugitea's
BACKLOG.md, one fresh session per task, and keeps a change only if it
stays in elixir_nugitea/, is under 800 lines and passes format, compile
and tests; then it commits and pushes agent/daily with its own deploy
key. opencode-agent.json denies git history, network, package and
service commands. Run by hand.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 09:23:30 -08:00

2.9 KiB

nugitea daily agent

Run ./nugitea-daily.sh when you like (say, once a day): opencode with the local Qwen3 Coder works through elixir_nugitea/BACKLOG.md in the nugitea repo unattended, and pushes what passes to the agent/daily branch on Forgejo for you to review and merge. It prints as it goes, so you can glance at it, but it never waits for you.

What a run does (nugitea-daily.sh)

  1. Checks Ollama is up, resets its own worktree (~/Code/nugitea-agent, branch agent/daily), merges in the latest elixir-prototype, and requires the checks to pass before it starts.
  2. Takes the first - [ ] task in BACKLOG.md and gives it to a fresh opencode session (opencode run --standalone --auto, 45 minutes max), with elixir_nugitea/AGENTS.md as its instructions.
  3. Keeps the result only if it:
    • changed only files under elixir_nugitea/, and none of AGENTS.md, BACKLOG.md, priv/schema.graphql, mix.exs, mix.lock;
    • is under 800 changed lines;
    • passes mix format --check-formatted, mix compile --warnings-as-errors and mix test, with no fewer passing tests than before.
  4. If not, a second session gets the failure output and tries to fix it. If that fails too, the changes are thrown away and the task is marked [!].
  5. Commits each finished task (checking it off as [x]) as "nugitea agent", and pushes agent/daily with its own deploy key.
  6. Up to 3 tasks, or 3 hours, per run.

Output also goes to ~/Library/Logs/nugitea-agent/<date>.log, including each session's own summary. MAX_TASKS=1 ./nugitea-daily.sh does just one task.

Guardrails

  • opencode-agent.json (passed as OPENCODE_CONFIG) denies: files outside the worktree, web access, questions, sub-agents, and shell commands that touch git history, the network, packages or services (git commit/push/reset/..., curl, ssh, brew, npm, launchctl, ...). Everything else in the shell is allowed: it runs as you, so this is a speed bump, not a sandbox.
  • It pushes with a deploy key (~/.config/nugitea-agent/deploy_key) that can only write to quine-global-labs/nugitea, and only ever to agent/daily (though the key itself could push any branch there).
  • Nothing it does reaches elixir-prototype or main until you merge it.

Setup (once)

git -C ~/Code/nugitea worktree add -b agent/daily ~/Code/nugitea-agent origin/elixir-prototype
mkdir -p ~/.config/nugitea-agent
ssh-keygen -t ed25519 -N "" -f ~/.config/nugitea-agent/deploy_key
# add deploy_key.pub as a write deploy key on quine-global-labs/nugitea
ssh-keyscan -p 2200 forge.quinefoundation.com | grep ed25519 > ~/.config/nugitea-agent/known_hosts

Steering it

Edit elixir_nugitea/BACKLOG.md on elixir-prototype: add tasks at the end, reorder, or reset a [!] to [ ] after making it smaller. Each task should be finishable in one sitting and say what test proves it. Review agent/daily, merge what's good into elixir-prototype; the next run picks up from there.