pi-loop-mode 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/DOCUMENTATION.md +628 -0
- package/LICENSE +21 -0
- package/README.md +152 -0
- package/extensions/index.ts +1442 -0
- package/package.json +34 -0
- package/prompts/loop-prompt.md +21 -0
- package/skills/loop-skill/SKILL.md +89 -0
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pi-loop-mode",
|
|
3
|
+
"version": "2.5.0",
|
|
4
|
+
"description": "Unattended loop mode for pi — separate goal/prepare/run phases with per-phase model selection, endless by default, objective goal function (--check) with score/regression tracking, error retry with backoff, layered anti-repetition defenses (near-duplicate and degenerate-generation detection, mid-stream abort, context sanitizing, sampling penalties, rescue model, auto-compaction), backlog-driven improvement mode, per-iteration JSONL stats, auto-resume, and persistence.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"pi-package",
|
|
7
|
+
"pi",
|
|
8
|
+
"agent",
|
|
9
|
+
"loop",
|
|
10
|
+
"unattended",
|
|
11
|
+
"autonomous",
|
|
12
|
+
"llm"
|
|
13
|
+
],
|
|
14
|
+
"author": "Robert Ressl <rr@canus.ch>",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"type": "module",
|
|
17
|
+
"files": [
|
|
18
|
+
"extensions",
|
|
19
|
+
"skills",
|
|
20
|
+
"prompts",
|
|
21
|
+
"README.md",
|
|
22
|
+
"DOCUMENTATION.md",
|
|
23
|
+
"CHANGELOG.md",
|
|
24
|
+
"LICENSE"
|
|
25
|
+
],
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@earendil-works/pi-coding-agent": "*"
|
|
28
|
+
},
|
|
29
|
+
"pi": {
|
|
30
|
+
"extensions": ["extensions"],
|
|
31
|
+
"skills": ["skills"],
|
|
32
|
+
"prompts": ["prompts"]
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Loop Mode
|
|
2
|
+
|
|
3
|
+
A loop is active. It runs until the operator stops it.
|
|
4
|
+
|
|
5
|
+
**Goal:** {LOOP_DESCRIPTION}
|
|
6
|
+
|
|
7
|
+
**Completion criteria:** {LOOP_COMPLETION_CRITERIA}
|
|
8
|
+
|
|
9
|
+
## Rules
|
|
10
|
+
|
|
11
|
+
1. Do exactly one concrete progress batch per turn, then stop.
|
|
12
|
+
2. Prefer tools and actual changes over long narration. Every turn must include at least one tool call — never answer with text only, and never claim something "already exists" without verifying it with a tool.
|
|
13
|
+
3. Keep assistant output under 1,200 characters. Never repeat a sentence within your response.
|
|
14
|
+
4. Do not print full logs, full diffs, large code blocks, or repeated context.
|
|
15
|
+
5. If the core goal appears complete, start with `LOOP_DONE: <one-line summary>`. In endless mode (default) the loop continues with improvements, driven by an `IMPROVEMENTS.md` backlog: concrete items with file paths and an acceptance criterion — vague items are forbidden. Never stop on your own.
|
|
16
|
+
6. Never wait for a human. If information is missing, make the most reasonable assumption, record it in `ASSUMPTIONS.md`, and continue. Use `LOOP_BLOCKED:` only for truly impossible external barriers.
|
|
17
|
+
7. If not complete, summarize only what changed and let the extension continue.
|
|
18
|
+
8. For long runs, keep `PROGRESS.md` updated with current state, decisions, and next steps.
|
|
19
|
+
9. If a goal check command is configured, it decides completion — not your claim. Its status and score appear in each loop prompt; treat the score as a fitness function and raise it. If the score drops, fix the regression first.
|
|
20
|
+
|
|
21
|
+
The operator can use `/loop status`, `/loop stop`, `/loop resume`, or `/loop end` at any time.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: loop-skill
|
|
3
|
+
description: >
|
|
4
|
+
Skill for operating the loop module. Use this skill when a loop is active.
|
|
5
|
+
Defines the loop goal, monitors progress, breaks stuck cycles, and
|
|
6
|
+
drives the agent toward completion. The operator can stop the loop at any time.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Loop Skill
|
|
10
|
+
|
|
11
|
+
## Purpose
|
|
12
|
+
|
|
13
|
+
When loop mode is active, every turn must advance the loop goal in a small, concrete batch. The loop is designed for long unattended runs (hours to days): by default it never stops on its own — only the operator stops it with `/loop stop`.
|
|
14
|
+
|
|
15
|
+
## Operating rules
|
|
16
|
+
|
|
17
|
+
1. Use tools to inspect or change files; do not replace tool use with long narration. Every turn must contain at least one tool call — never answer with text only, and never claim something "already exists" without verifying it with a tool.
|
|
18
|
+
2. Keep assistant responses concise (under 1,200 characters).
|
|
19
|
+
3. Never dump full logs, full diffs, large files, or the whole conversation.
|
|
20
|
+
4. Produce a tangible artifact every few turns: a file change, a passing test, a fixed bug, a committed improvement.
|
|
21
|
+
5. If the core goal appears complete, say `LOOP_DONE: <one-line summary>`. In default (endless) mode the loop then continues with improvement work, driven by an `IMPROVEMENTS.md` backlog: concrete checklist items with affected file paths and a one-line acceptance criterion. Vague items without file paths are forbidden. Take the top open item, implement it, mark it done; add new specific items (based on tool inspection) when fewer than 3 remain. In `--until-done` mode the loop stops.
|
|
22
|
+
6. Never wait for a human. If information is missing, make the most reasonable assumption, record it in `ASSUMPTIONS.md`, and continue. Use `LOOP_BLOCKED:` only for truly impossible external barriers — the loop will still push you to continue with assumptions.
|
|
23
|
+
7. Maintain a `PROGRESS.md` for long runs: current state, decisions, next steps. This survives compaction and restarts.
|
|
24
|
+
|
|
25
|
+
## Commands
|
|
26
|
+
|
|
27
|
+
```text
|
|
28
|
+
/loop goal <goal[. Done when: criteria]> [--max N] [--delay S] [--check "CMD"] [--check-timeout S] [--file GOAL.md] [--model M] [--rescue-model M] [--until-done]
|
|
29
|
+
/loop prepare [--model M] [--file F]
|
|
30
|
+
/loop run [--model M] [--rescue-model M]
|
|
31
|
+
/loop start <goal> [flags] # goal + run in one step
|
|
32
|
+
/loop resume [--max N] [--check "CMD"] [--model M] [--rescue-model M]
|
|
33
|
+
/loop status
|
|
34
|
+
/loop stats
|
|
35
|
+
/loop stop
|
|
36
|
+
/loop end
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Recommended workflow: `/loop goal` (set only), `/loop prepare --model <strong model>` (write the spec), `/loop run --model <cheap model>` (execute).
|
|
40
|
+
|
|
41
|
+
- Default is **endless**: no iteration cap, `LOOP_DONE` does not stop the loop.
|
|
42
|
+
- `--max N` sets an optional iteration cap (pauses at N; `/loop resume` continues).
|
|
43
|
+
- `--delay S` waits S seconds between iterations.
|
|
44
|
+
- `--check "CMD"` sets an objective goal function: a shell command run after every iteration. Exit 0 = criteria met. Print `SCORE: <n>` (higher = better) for progress/regression tracking.
|
|
45
|
+
- `--until-done` stops the loop on verified completion (goal check passes; without a check: `LOOP_DONE:`).
|
|
46
|
+
- `--model M` selects the model per phase (`provider/id` or unique id substring).
|
|
47
|
+
- `--rescue-model M` sets a stronger model that takes over for a single cleanup turn after 3 consecutive stuck interventions.
|
|
48
|
+
- `/loop stats` summarizes the per-iteration JSONL log (`.pi-loop-log.jsonl`): events, interventions, productive iterations/hour, score trend.
|
|
49
|
+
|
|
50
|
+
## Preparation turns (/loop prepare)
|
|
51
|
+
|
|
52
|
+
When asked to prepare a goal specification:
|
|
53
|
+
|
|
54
|
+
1. Do NOT start implementing the goal.
|
|
55
|
+
2. Inspect the current project state, then write the goal file (default `GOAL.md`): refined objective, scope & non-goals, measurable completion criteria, milestone roadmap of small steps, quality standards (tests, docs, git commits), explicit assumptions.
|
|
56
|
+
3. If objectively checkable, create a check script (exit 0 = criteria met, print `SCORE: <n>`) and reference it in the goal file.
|
|
57
|
+
4. Keep the goal file under ~200 lines, concrete and unambiguous — it must guide another (possibly weaker) model through a long unattended run.
|
|
58
|
+
5. End with `GOAL_READY: <one-line summary>` and the exact `--check` command if you created a check script.
|
|
59
|
+
|
|
60
|
+
## Loop turns with a prepared goal
|
|
61
|
+
|
|
62
|
+
If a goal file exists, read it at the start of the run and whenever you lose track of the plan. Follow its milestone roadmap and quality standards.
|
|
63
|
+
|
|
64
|
+
## Goal check behavior
|
|
65
|
+
|
|
66
|
+
When a goal check is configured:
|
|
67
|
+
|
|
68
|
+
- Completion is decided by the check command, not by your claim. `LOOP_DONE:` with a failing check is rejected — fix exactly what the check reports.
|
|
69
|
+
- The current check status and score appear in every loop prompt. Treat the score as your fitness function: raise it.
|
|
70
|
+
- If the score drops, a recent change broke something. Inspect recent diffs and fix the regression before anything else.
|
|
71
|
+
|
|
72
|
+
## Stuck behavior
|
|
73
|
+
|
|
74
|
+
The extension detects being stuck via exact repeats, near-duplicate responses (≥ 80 % similarity, numbers ignored), alternating repeats, repeated tool results, turns without any tool call, and degenerate generation (the same sentence repeated within one response — such turns are aborted mid-stream and truncated in context). If it reports that you are stuck:
|
|
75
|
+
|
|
76
|
+
- Do not repeat the same answer, command, or question — not even rephrased.
|
|
77
|
+
- If the intervention lists banned openings, never start your response with any of them; begin the turn with a tool call instead.
|
|
78
|
+
- Follow the injected strategy: list alternatives, switch subtasks, write `PROGRESS.md`, run tests and fix one failure, or review recent diffs.
|
|
79
|
+
- Keep the intervention response concise.
|
|
80
|
+
|
|
81
|
+
The extension never pauses on stuck detection; it escalates: rotating strategies with escalating delays → anti-repetition sampling penalties for a few turns → a single rescue turn with a stronger model (if `--rescue-model` is set) → automatic context compaction. It keeps going until the operator stops the loop.
|
|
82
|
+
|
|
83
|
+
## Rescue turns
|
|
84
|
+
|
|
85
|
+
If you are the rescue model (the prompt says "RESCUE TURN"): inspect the project state, fix or finish ONE concrete thing, rewrite `PROGRESS.md` with the next 3 unambiguous steps (exact file paths), update the `IMPROVEMENTS.md` backlog, and end with a single line `NEXT: <exact instruction for the next turn>`. Do not start large refactorings — you have one turn.
|
|
86
|
+
|
|
87
|
+
## Error behavior
|
|
88
|
+
|
|
89
|
+
If a turn fails with a model/provider error, the extension retries automatically with exponential backoff (5s → 5min). After recovery, briefly re-check the project state and continue — do not restart from scratch.
|