@pwguler/pi-loop
A pi extension for loop
Package details
Install @pwguler/pi-loop from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@pwguler/pi-loop- Package
@pwguler/pi-loop- Version
0.8.2- Published
- Oct 20, 2026
- Downloads
- 1,273/mo · 96/wk
- Author
- pwguler
- License
- MIT
- Types
- extension
- Size
- 77.9 KB
- Dependencies
- 0 dependencies · 5 peers
Pi manifest JSON
{
"extensions": [
"./extensions/index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-loop
Re-sends one prompt inside the current pi session on a schedule: an interval or a cron expression.
Install
pi install npm:@pwguler/pi-loop
Or from GitHub: pi install git:github.com/pwguler/pi-loop. Start or reload pi, then /loop is available.
Usage
/loop the roster: one row per loop
/loop list the same roster
/loop [flags] <text with an interval phrase> [flags]
/loop [flags] <cron expression> <prompt> [flags]
/loop stop <name>
/loop pause <name>
/loop resume <name>
/loop 5m check the build
/loop check the build hourly
/loop every 30 minutes review the open PRs
/loop run the smoke test every 1h30m --name smoke --max 6
/loop every 50 min @prompt.md
/loop 0 9 * * 1-5 summarize the overnight CI failures
- Interval. The phrase is cut out of the text, and the rest is the prompt. Forms include
5m,2 hours,1d,1h30m,hourly,daily, andevery 30 minutes; the minimum is1m. At the head of the text any form counts. Elsewhere only anevery/eachphrase counts; at the tail, so dohourly,daily, and a compact form such as5m. Sosummarize the dayhas no interval. - Cron. crontab's five fields (minute, hour, day of month, month, day of week), at the head of the text after any flags. A field takes
*, a value, a range, a list, or a step such as*/15. Month and weekday also take names such asjanandmon. When neither day field starts with*, a day that matches either one counts; otherwise a day must match both. - Flags.
--name <n>,--max <n>(remove the loop after its n-th fire), and--until <ISO|HH:mm>(remove it at that time;HH:mmis the next such local time). Flags go at the head or the tail, never inside the prompt. - File prompt. A prompt that is one
@pathtoken reads that file, relative to the cwd, at every fire. - Name. Without
--name, in a session with a model, an@pathfile or a short prompt names the loop. Otherwise the model picks a short name, in a side request that adds nothing to the conversation. With no model or no usable name, the name isloop-<k>. - Roster. In the TUI,
/loopopens the roster below the editor. Its header names the keys for the selected loop:ppause orrresume,xstop (it asks first), Enter for the detail panel, Esc to go back.
How loops fire
- Nothing fires on create. A loop fires at the points of a fixed grid on the local clock:
1hat every HH:00,15mat :00, :15, :30, and :45,dailyat 00:00. A cron loop fires at the minutes its expression matches. - A fire that comes due while the agent is busy is queued behind the running turn. Each loop keeps at most one fire waiting: until the agent settles, its further grid points are skipped. A skip sends nothing and does not count toward
--max. - Pause keeps the counter. Resume waits for the next grid point.
- While loops exist, a status line below the editor shows the count and the next due loop.
State
Loops live in <cwd>/.pi-loop/ and survive a restart. Only one TUI session in a cwd fires them. Another TUI session in that cwd shows owned by pid <n>, and takes over once that process is gone. Grid points that passed while pi was down do not fire.