Files
clinera-site/pi-worker
Azreen Jamal bd2c7d5102 feat: pi-worker now picks up and fixes real bugs from Asana
Major changes:
- Task loop polls Under Review + New Bugs sections (was only checking empty sections)
- Smart project routing: keyword matching maps task names to correct codebase
  (e.g. 'pledge' → legacy-donation-system-laravel)
- Pi executes in the project directory, not /opt/pi-worker
- Git pull before execution to get latest code
- Skips already-attempted tasks (checks Asana comments)
- Config now exposes projectsPath

First real bug fixed autonomously:
  'Duplicate Pledges Detected with Same External Reference'
  → Fixed uniqid() causing duplicate Engage pledges on every sync
  → 1 file changed in app/N3O/Schema.php

Also: fix watchdog to use systemd-notify command (unix_dgram unsupported in Bun),
add debug logging to lock acquire failures
2026-03-09 01:33:24 +08:00
..

🤖 Pi Worker

Autonomous agent that runs inside cr-server-new, picks up Asana tasks, and performs automated project improvements using the Pi improved agent.

What It Does

  1. Asana Task Execution: Polls Asana for tasks in "To Do" or "Pi Worker" sections, executes them using the Pi CLI agent, and reports results back as comments
  2. Autonomous Improvements: Periodically analyzes the project codebase and makes improvements (code quality, security, docs, testing, performance, type safety)

Architecture

Asana Board ←→ Pi Worker (cr-server-new) ←→ Pi CLI Agent ←→ Codebase
                    ↕
              Health Server (:8787)

Setup

  1. Copy .env.sample to .env and fill in credentials
  2. bun install
  3. bun run dev (local) or bash deploy.sh (production)

Configuration

Variable Description Default
ASANA_ACCESS_TOKEN Asana personal access token Required
ASANA_PROJECT_GID Project to poll (auto-discovered if empty) Auto
PI_MODEL AI model to use claude-sonnet-4-6
POLL_INTERVAL_SEC Asana polling interval 120
IMPROVEMENT_INTERVAL_SEC Auto-improvement interval 3600

Asana Board Setup

Create these sections in your Asana project:

  • To Do — Tasks for Pi Worker to pick up
  • In Progress — Currently being executed
  • Done — Completed tasks
  • Pi Worker (optional) — Dedicated section for Pi Worker tasks

Health Check

curl http://localhost:8787/health

Logs

Logs are written to ./logs/pi-worker-YYYY-MM-DD.log and stdout.