@trevonistrevon/pi-loop 0.3.1 → 0.4.1
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/DIFFERENTIAL_REVIEW_REPORT.md +81 -0
- package/README.md +50 -6
- package/dist/index.js +404 -85
- package/dist/task-store.d.ts +22 -0
- package/dist/task-store.js +181 -0
- package/dist/task-types.d.ts +15 -0
- package/dist/task-types.js +1 -0
- package/dist/trigger-system.d.ts +2 -1
- package/dist/trigger-system.js +19 -16
- package/dist/ui/widget.d.ts +9 -7
- package/dist/ui/widget.js +29 -93
- package/package.json +1 -1
- package/src/index.ts +420 -83
- package/src/task-store.ts +171 -0
- package/src/task-types.ts +17 -0
- package/src/trigger-system.ts +20 -16
- package/src/ui/widget.ts +34 -91
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Differential Review Report
|
|
2
|
+
|
|
3
|
+
## Update — 2026-06-02
|
|
4
|
+
|
|
5
|
+
### Resolved audit finding
|
|
6
|
+
- **Resolved:** recurring `event` / `hybrid` loops now clean themselves up immediately when `maxFires` is reached on the final allowed fire.
|
|
7
|
+
- **Implementation:** `src/trigger-system.ts` now removes and deletes recurring event/hybrid loops as soon as `fireCount >= maxFires` after `onFire(...)` completes.
|
|
8
|
+
- **Why this mattered:** the previous behavior left one stale active loop behind until the next matching event arrived, which was a real runtime cleanup bug.
|
|
9
|
+
|
|
10
|
+
### Regression coverage added
|
|
11
|
+
- `test/trigger-system.test.ts`
|
|
12
|
+
- recurring `event` loop is deleted immediately at final `maxFires`
|
|
13
|
+
- recurring `hybrid` loop is deleted immediately at final `maxFires`
|
|
14
|
+
- hybrid cleanup also clears scheduled cron state
|
|
15
|
+
- `test/index.test.ts`
|
|
16
|
+
- extension-level `LoopCreate`/`LoopList` path confirms the loop is gone immediately after the final allowed event fire
|
|
17
|
+
|
|
18
|
+
### Validation status
|
|
19
|
+
- `npm run lint` ✅
|
|
20
|
+
- `npm run typecheck` ✅
|
|
21
|
+
- `npm run test` ✅
|
|
22
|
+
- `npm run build` ✅
|
|
23
|
+
- Current suite: **112 passing tests**
|
|
24
|
+
|
|
25
|
+
## Scope
|
|
26
|
+
Reviewed recent uncommitted changes in:
|
|
27
|
+
- `src/index.ts`
|
|
28
|
+
- `src/ui/widget.ts`
|
|
29
|
+
- `test/index.test.ts`
|
|
30
|
+
- `test/widget.test.ts`
|
|
31
|
+
- `README.md`
|
|
32
|
+
|
|
33
|
+
## Risk Summary
|
|
34
|
+
- **Overall risk:** Medium
|
|
35
|
+
- **Primary areas affected:** runtime task fallback routing, UI/widget behavior, interactive command registration
|
|
36
|
+
- **Security impact:** Low direct security impact; main risks are state-management regressions and missing coverage around command behavior
|
|
37
|
+
|
|
38
|
+
## Findings
|
|
39
|
+
|
|
40
|
+
### 🟡 Warning
|
|
41
|
+
`src/index.ts` - Native task fallback is covered for registration and file persistence, but not for interactive `/tasks` flows or loop-driven task lifecycle integration.
|
|
42
|
+
|
|
43
|
+
**Why it matters:**
|
|
44
|
+
The new `/tasks` command and interactive actions (`Start`, `Complete`, `Reopen`, `Delete`) are stateful and user-facing. Regressions here would not be caught by current tests. Similarly, native fallback behavior for `autoTask`, `hasPendingTasks()`, and `cleanDoneTasks()` is only indirectly covered.
|
|
45
|
+
|
|
46
|
+
**Recommended follow-up:**
|
|
47
|
+
Add tests for:
|
|
48
|
+
- `/tasks` command registration and quick-create path
|
|
49
|
+
- native `autoTask` creation path
|
|
50
|
+
- `hasPendingTasks()` using native fallback
|
|
51
|
+
- completed-task sweep behavior for native tasks
|
|
52
|
+
|
|
53
|
+
### 🟢 Suggestion
|
|
54
|
+
`src/ui/widget.ts` - Compact widget behavior is appropriately simplified and focus-oriented.
|
|
55
|
+
|
|
56
|
+
**Good pattern:**
|
|
57
|
+
The single-line status approach reduces noise and matches the intended UX. Showing only active/next task focus text is a good constraint.
|
|
58
|
+
|
|
59
|
+
## Test Coverage Review
|
|
60
|
+
|
|
61
|
+
### Covered well
|
|
62
|
+
- Native tool registration when `pi-tasks` is absent/present
|
|
63
|
+
- Native task persistence path (`.pi/tasks/tasks.json`)
|
|
64
|
+
- Compact widget states:
|
|
65
|
+
- `none`
|
|
66
|
+
- monitor-only count
|
|
67
|
+
- loop + monitor count
|
|
68
|
+
- active task focus text
|
|
69
|
+
- next task focus text
|
|
70
|
+
- retained widget rendering after content clears
|
|
71
|
+
|
|
72
|
+
### Coverage gaps
|
|
73
|
+
- No tests for `/tasks` command behavior beyond registration
|
|
74
|
+
- No direct tests for native `TaskUpdate` → widget focus transitions
|
|
75
|
+
- No direct tests for native `cleanDoneTasks()` sweep behavior
|
|
76
|
+
- No end-to-end tests for `LoopCreate(autoTask: true)` using native fallback
|
|
77
|
+
|
|
78
|
+
## Review Verdict
|
|
79
|
+
- **No merge-blocking issues found**
|
|
80
|
+
- Safe to release after version bump and validation
|
|
81
|
+
- Recommended follow-up: add native task lifecycle command/integration tests in a later pass
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<p align="center">
|
|
2
2
|
<h1 align="center">@trevonistrevon/pi-loop</h1>
|
|
3
|
-
<h6 align="center">Cron and event loops for the pi coding agent. Background monitors, scheduled re-wakes, pi-tasks integration.</h6>
|
|
3
|
+
<h6 align="center">Cron and event loops for the pi coding agent. Background monitors, scheduled re-wakes, pi-tasks integration, and native task fallback.</h6>
|
|
4
4
|
</p>
|
|
5
5
|
|
|
6
6
|
## Install
|
|
@@ -11,29 +11,45 @@ pi install @trevonistrevon/pi-loop
|
|
|
11
11
|
|
|
12
12
|
## Quick start
|
|
13
13
|
|
|
14
|
-
```
|
|
14
|
+
```text
|
|
15
15
|
LoopCreate trigger="5m" prompt="Check if the build passed"
|
|
16
16
|
LoopCreate trigger="tool_execution_start" prompt="Log the tool being used" triggerType="event"
|
|
17
17
|
LoopList
|
|
18
18
|
LoopDelete id="1"
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
```
|
|
21
|
+
```text
|
|
22
22
|
MonitorCreate command="tail -n0 -f build.log" description="Watch build"
|
|
23
23
|
MonitorCreate command="python train.py" onDone="Analyze results and report best loss"
|
|
24
24
|
MonitorList
|
|
25
25
|
MonitorStop monitorId="1"
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
+
When `pi-tasks` is not installed, `pi-loop` also exposes native task tools after startup detection:
|
|
29
|
+
|
|
30
|
+
```text
|
|
31
|
+
TaskCreate subject="Fix deploy polling" description="Switch deploy check to event-driven loop"
|
|
32
|
+
TaskList
|
|
33
|
+
TaskUpdate id="1" status="in_progress"
|
|
34
|
+
TaskDelete id="1"
|
|
35
|
+
```
|
|
36
|
+
|
|
28
37
|
## Commands
|
|
29
38
|
|
|
30
39
|
`/loop [interval] [prompt]` — interactive loop creation.
|
|
31
40
|
|
|
32
|
-
```
|
|
41
|
+
```text
|
|
33
42
|
/loop # menu
|
|
34
43
|
/loop 5m check the deploy # 5-minute cron loop
|
|
35
44
|
```
|
|
36
45
|
|
|
46
|
+
`/tasks` — interactive native task viewer/manager, only registered when `pi-tasks` is absent.
|
|
47
|
+
|
|
48
|
+
```text
|
|
49
|
+
/tasks # open native task viewer
|
|
50
|
+
/tasks Write README updates # quick-create native task
|
|
51
|
+
```
|
|
52
|
+
|
|
37
53
|
## Tools
|
|
38
54
|
|
|
39
55
|
| Tool | What it does |
|
|
@@ -44,16 +60,44 @@ MonitorStop monitorId="1"
|
|
|
44
60
|
| `MonitorCreate` | Run a background command, stream output as `monitor:output` events. Use `onDone` for auto-notify on completion |
|
|
45
61
|
| `MonitorList` | Show monitors with status, uptime, and output line count |
|
|
46
62
|
| `MonitorStop` | Stop a monitor (SIGTERM → 5s → SIGKILL) |
|
|
63
|
+
| `TaskCreate` | Create a native fallback task when `pi-tasks` is absent |
|
|
64
|
+
| `TaskList` | List native fallback tasks |
|
|
65
|
+
| `TaskUpdate` | Update native fallback task status/details |
|
|
66
|
+
| `TaskDelete` | Delete a native fallback task |
|
|
47
67
|
|
|
48
68
|
Trigger types: `cron` (`5m`, `1h`, `0 9 * * 1-5`), `event` (any pi event source), or `hybrid` (both, debounced).
|
|
49
69
|
|
|
50
|
-
##
|
|
70
|
+
## Tasks
|
|
71
|
+
|
|
72
|
+
### With `pi-tasks`
|
|
51
73
|
|
|
52
74
|
Works with [@tintinweb/pi-tasks](https://github.com/tintinweb/pi-tasks). Pass `autoTask: true` on `LoopCreate` and each loop fire auto-creates a tracked task. Detection happens over pi's event bus — no manual wiring.
|
|
53
75
|
|
|
76
|
+
### Without `pi-tasks`
|
|
77
|
+
|
|
78
|
+
If `pi-tasks` does not respond during startup detection, `pi-loop` registers a native fallback task system for the session:
|
|
79
|
+
|
|
80
|
+
- persistent store at `.pi/tasks/tasks.json`
|
|
81
|
+
- `TaskCreate`, `TaskList`, `TaskUpdate`, `TaskDelete`
|
|
82
|
+
- `/tasks` interactive viewer
|
|
83
|
+
- compact widget task tracking
|
|
84
|
+
|
|
85
|
+
This fallback is session-sticky: `pi-loop` decides once at startup whether `pi-tasks` or native tasks own task management for that session.
|
|
86
|
+
|
|
54
87
|
## Widget
|
|
55
88
|
|
|
56
|
-
|
|
89
|
+
`pi-loop` keeps a compact persistent TUI widget above the editor.
|
|
90
|
+
|
|
91
|
+
It now shows a single focus-friendly status line such as:
|
|
92
|
+
|
|
93
|
+
```text
|
|
94
|
+
none
|
|
95
|
+
1 loop · 1 monitor
|
|
96
|
+
2 tasks | active: Fix deploy polling
|
|
97
|
+
1 loop · 2 monitors · 3 tasks | next: Update README
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Only task counts and the single active/next task are shown in the widget so attention stays on what is currently happening. Use `LoopList`, `MonitorList`, and `/tasks` for detail.
|
|
57
101
|
|
|
58
102
|
## Configuration
|
|
59
103
|
|