Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

pi-durable-template

A minimal template for long-running, tightly scoped backend agents: an agent that wakes, works, records what it learned, and exits.

It is meant to be used with two skills from will-wright-eng/skills. agent-specification interviews you and writes a one-page SPECIFICATION.md. new-pi-durable-agent copies this template and adapts it to that specification. The template supplies everything that stays the same between agents.

How it fits together

Piece Role
SPECIFICATION.md The agent's scope in prose: job, non-goals, trigger, workspace, output, tools, done check, budget, memory, escalation. Written with agent-specification and loaded as the agent's instructions on every wake. Not shipped; see the example.
src/agent.ts The same limits in code: tool allowlist (at most 6), budgets, trigger, done-check, and an optional accept-check. Rewritten by new-pi-durable-agent. Ships as the example agent, a CHANGELOG drafter.
Everything else in src/ The fixed runtime: the wake cycle, memory and run journal, inbox, guards, service generators, CLI.
.agent/ Every artifact of the running agent: env file, SQLite database, inbox, lock, logs, backups. Gitignored, in the repository root so it is easy to inspect.

The stack is fixed: pi-durable on Bun, Cloudflare AI Gateway for models, SQLite for storage, launchd on macOS or systemd on Linux.

Getting started

With the skills, write SPECIFICATION.md with agent-specification, then run new-pi-durable-agent in a fresh repo; it copies this template and writes src/agent.ts from the specification.

make check fails when the two disagree on names. It compares the agent's name, and the tools and memory documents the specification lists as bullets opening with a backticked name (- `git_log`: ...), with src/agent.ts. Trigger, output, done check and budget are prose in the specification, so keeping those in step is done by reading.

An agent that receives its work from another agent can set acceptCheck in src/agent.ts: a shell command run in the workspace before the model sees anything. A non-zero exit ends the wake as accept_check_failed, with the wake's tasks recorded in the journal. State it in the specification's Trigger section.

To try the template on its own, use the example specification:

cp docs/SPECIFICATION.example.md SPECIFICATION.md
make env        # creates .agent/ and .agent/env; set AGENT_WORKSPACE in it
make setup      # installs dependencies and verifies .agent/, the specification and src/agent.ts
make dry-run    # one wake with a scripted model and stubbed tools; stores nothing

For a real wake, fill in the Cloudflare values in .agent/env, then:

make submit TASK="Mention the breaking change first"   # optional: queue a task for the next wake
make wake
make journal
make install    # wake on the agent's trigger from now on

make help lists every target. Each wraps bun run agent <command>; the commands are check, wake, submit, journal, memory, install and uninstall.

References

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages