Skip to content

usirin/pi-loop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pi-loop

Claude Code-style /loop command for pi.

pi-loop adds an autonomous loop command that keeps sending follow-up turns until the agent reports completion, gets blocked, or hits a max-iteration guardrail.

Install

From npm:

pi install npm:@usirin/pi-loop

Try without installing:

pi -e npm:@usirin/pi-loop

Install from git:

pi install git:github.com/usirin/pi-loop

Install from a local checkout:

pi install /path/to/pi-loop

After install, restart pi or run:

/reload

Usage

/loop <objective>
/loop 3m <objective>
/loop --interval 30s <objective>
/loop --max 10 <objective>
/loop 10 <objective>
/loop status
/loop pause
/loop resume
/loop stop

Examples:

/loop --max 8 inspect this repo, add the smallest useful test/build setup, and stop when everything passes
/loop 5 fix the failing tests, running the relevant test command after each change

Run every three minutes, like Claude Code's interval form:

/loop 3m take a look at these prs and fix the reviews

How it stops

A loop stops when one of these happens:

  • the assistant calls the loop_done tool
  • the assistant includes LOOP_DONE in its response
  • you run /loop stop
  • the max iteration count is reached
  • the session shuts down

Default max iterations: 25.

How it works

The extension registers:

  • /loop slash command
  • loop_done tool for the model to stop the loop explicitly
  • a status/widget display showing the active loop objective and iteration count

Each iteration instructs the model to do exactly one useful slice of work. If the model does not stop the loop, the extension queues the next follow-up turn. When an interval is provided, the first turn starts immediately and subsequent turns wait for that interval. Interval loops treat each turn as a recurring scheduled tick, so the model is instructed not to stop merely because one tick succeeded.

Package metadata

This is a pi package. The extension is declared in package.json:

{
  "keywords": ["pi-package"],
  "pi": {
    "extensions": ["./extensions/loop.ts"]
  }
}

Development

Run from a checkout without installing:

pi -e ./extensions/loop.ts

Check the npm tarball contents:

npm run pack:dry-run

Security

Pi extensions run with your full system permissions. Review any extension source before installing it.

About

Claude Code-style /loop command for pi-coding-agent

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors