pi-goal-pro 1.0.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/LICENSE +21 -0
- package/README.md +397 -0
- package/index.ts +1037 -0
- package/package.json +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 pi-goal-pro contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
|
|
2
|
+
<p align="center">
|
|
3
|
+
<img src="https://img.shields.io/badge/pi-extension-8B5CF6?style=flat-square&logo=pi-hole&logoColor=white" alt="pi extension">
|
|
4
|
+
<img src="https://img.shields.io/badge/license-MIT-green?style=flat-square" alt="MIT">
|
|
5
|
+
<img src="https://img.shields.io/badge/status-beta-orange?style=flat-square" alt="beta">
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
# pi-goal-pro 🎯
|
|
9
|
+
|
|
10
|
+
> Persistent autonomous goals for [Pi](https://pi.dev) — with no-progress detection, evidence-based completion, token budgets, and auto-continuation.
|
|
11
|
+
|
|
12
|
+
Set a long-running objective and let the agent work autonomously until it's done, paused, or blocked — without you having to re-prompt every turn.
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
/goal Refactor the auth module to use JWT with proper error handling
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Then walk away. The agent keeps going. When it's done, it reports with evidence.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
mkdir -p ~/.pi/agent/extensions/pi-goal-pro
|
|
26
|
+
# Copy the extension file:
|
|
27
|
+
cp ./index.ts ~/.pi/agent/extensions/pi-goal-pro/
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Then reload Pi:
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
/reload
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Verify it's loaded:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
/goal status
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Quick Start
|
|
45
|
+
|
|
46
|
+
Set a goal and let the agent work:
|
|
47
|
+
|
|
48
|
+
```text
|
|
49
|
+
/goal Add retry logic to the API client with exponential backoff
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The agent starts working immediately. Watch the status bar:
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
🎯 goal active (1.2K/50K) ← footer status while the agent works
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Manage the goal lifecycle:
|
|
59
|
+
|
|
60
|
+
```text
|
|
61
|
+
/goal status # Show current goal state
|
|
62
|
+
/goal pause # Pause the active goal
|
|
63
|
+
/goal resume # Resume a paused goal
|
|
64
|
+
/goal clear # Clear all goals
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Features
|
|
70
|
+
|
|
71
|
+
### 🎯 Goal Setting
|
|
72
|
+
|
|
73
|
+
```text
|
|
74
|
+
/goal Refactor the auth module
|
|
75
|
+
|
|
76
|
+
# With a token budget (auto-pauses when exceeded):
|
|
77
|
+
/goal Refactor the auth module --tokens 100k
|
|
78
|
+
|
|
79
|
+
# With a max auto-continue turn limit:
|
|
80
|
+
/goal Refactor the auth module --max-turns 10
|
|
81
|
+
|
|
82
|
+
# Combine them:
|
|
83
|
+
/goal Refactor the auth module --tokens 50k --max-turns 20
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 🤖 Agent Tools
|
|
87
|
+
|
|
88
|
+
Once a goal is active, the agent gets two tools:
|
|
89
|
+
|
|
90
|
+
**`get_goal`** — Read the current goal state:
|
|
91
|
+
|
|
92
|
+
```json
|
|
93
|
+
{
|
|
94
|
+
"active": {
|
|
95
|
+
"objective": "Refactor the auth module to use JWT",
|
|
96
|
+
"status": "active",
|
|
97
|
+
"tokens_used": 12400,
|
|
98
|
+
"token_budget": 50000,
|
|
99
|
+
"remaining_tokens": 37600,
|
|
100
|
+
"time_used_seconds": 89,
|
|
101
|
+
"auto_turns": 3,
|
|
102
|
+
"max_auto_turns": 25
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**`update_goal`** — Mark complete or unmet (with evidence/blocker):
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
// Complete — requires evidence
|
|
111
|
+
update_goal({
|
|
112
|
+
status: "complete",
|
|
113
|
+
evidence: "JWT middleware implemented, 12 tests passing, no regressions in CI"
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
// Unmet — requires a blocker
|
|
117
|
+
update_goal({
|
|
118
|
+
status: "unmet",
|
|
119
|
+
blocker: "Blocked on JWT library decision — waiting for security review"
|
|
120
|
+
})
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### 🔄 Auto-Continuation
|
|
124
|
+
|
|
125
|
+
After each agent turn, the extension automatically sends a continuation prompt if:
|
|
126
|
+
- The goal is still `active`
|
|
127
|
+
- The previous turn was goal-driven
|
|
128
|
+
- The user hasn't typed anything (which suspends auto-continuation)
|
|
129
|
+
- No limits have been hit
|
|
130
|
+
|
|
131
|
+
### 🛡️ No-Progress Detection
|
|
132
|
+
|
|
133
|
+
If the agent generates very low output (default: <50 tokens) for 2 consecutive turns, the goal auto-pauses with a warning:
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
⏸ Goal paused (no progress for 2 turns). Use /goal resume to continue.
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
This prevents infinite loops where the agent keeps acknowledging without making progress.
|
|
140
|
+
|
|
141
|
+
### 💰 Token Budget
|
|
142
|
+
|
|
143
|
+
Set a token budget with `--tokens`:
|
|
144
|
+
|
|
145
|
+
```text
|
|
146
|
+
/goal Write documentation for all API endpoints --tokens 100k
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
When the budget is exhausted, the goal auto-pauses with a wrap-up prompt so the agent summarizes what was done and what remains.
|
|
150
|
+
|
|
151
|
+
### 📋 Evidence-Based Completion
|
|
152
|
+
|
|
153
|
+
The agent must provide concrete evidence before marking a goal complete. This prevents premature "done" claims and ensures real verification against files, tests, and command output.
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Commands
|
|
158
|
+
|
|
159
|
+
| Command | Description |
|
|
160
|
+
|---------|-------------|
|
|
161
|
+
| `/goal <objective>` | Set a new goal (replaces active with confirmation) |
|
|
162
|
+
| `/goal <text> --tokens N` | Set a goal with a token budget |
|
|
163
|
+
| `/goal <text> --max-turns N` | Set a goal with a max auto-turn limit |
|
|
164
|
+
| `/goal status` | Show current goal state |
|
|
165
|
+
| `/goal pause` | Pause the active goal |
|
|
166
|
+
| `/goal resume` | Resume a paused goal |
|
|
167
|
+
| `/goal clear` | Clear all goals |
|
|
168
|
+
| `/goal help` | Show help |
|
|
169
|
+
| `/goal config` | Show current configuration |
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Configuration
|
|
174
|
+
|
|
175
|
+
Set these at the top of `index.ts` if you need to tune behavior:
|
|
176
|
+
|
|
177
|
+
| Setting | Default | Description |
|
|
178
|
+
|---------|---------|-------------|
|
|
179
|
+
| `maxAutoTurns` | `25` | Max auto-continue turns before forced pause |
|
|
180
|
+
| `noProgressTokenThreshold` | `50` | Output tokens below this = "no progress" |
|
|
181
|
+
| `maxNoProgressTurns` | `2` | Consecutive no-progress turns before auto-pause |
|
|
182
|
+
| `minContinueIntervalMs` | `3000` | Debounce interval between continuations |
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## How It Works
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
/goal Refactor auth module
|
|
190
|
+
│
|
|
191
|
+
▼
|
|
192
|
+
✓ Goal created & saved as session entry
|
|
193
|
+
✓ Agent gets get_goal + update_goal tools
|
|
194
|
+
✓ First continuation fires immediately
|
|
195
|
+
│
|
|
196
|
+
▼
|
|
197
|
+
┌── Auto-continuation loop ──────────────────┐
|
|
198
|
+
│ │
|
|
199
|
+
│ turn_start → turn_end → agent_end │
|
|
200
|
+
│ │ │
|
|
201
|
+
│ ┌─────────┴─────────┐ │
|
|
202
|
+
│ │ Goal still active? │ │
|
|
203
|
+
│ │ No progress? │ │
|
|
204
|
+
│ │ User suspended? │ │
|
|
205
|
+
│ │ Budget exhausted? │ │
|
|
206
|
+
│ │ Max turns reached? │ │
|
|
207
|
+
│ └─────────┬─────────┘ │
|
|
208
|
+
│ │ │
|
|
209
|
+
│ ┌──────────┴──────────┐ │
|
|
210
|
+
│ │ Yes → send │ │
|
|
211
|
+
│ │ continuation │ │
|
|
212
|
+
│ │ No → stop / pause │ │
|
|
213
|
+
│ └─────────────────────┘ │
|
|
214
|
+
│ │
|
|
215
|
+
└────────────────────────────────────────────┘
|
|
216
|
+
│
|
|
217
|
+
▼
|
|
218
|
+
Agent calls update_goal({ status: "complete", evidence })
|
|
219
|
+
→ Goal archived, agent stops
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### State Persistence
|
|
223
|
+
|
|
224
|
+
Goal state is stored in Pi session entries (custom type `pi-goal-pro`). It survives:
|
|
225
|
+
- Session reloads (`/reload`)
|
|
226
|
+
- Compaction
|
|
227
|
+
- Tree navigation (`/tree`)
|
|
228
|
+
- Session resume
|
|
229
|
+
|
|
230
|
+
State is branch-local — navigating to a different branch restores that branch's goal state.
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
## Design Philosophy
|
|
235
|
+
|
|
236
|
+
1. **User owns intent** — The agent can't silently change the goal. Objective is set by the user.
|
|
237
|
+
2. **Evidence before completion** — The agent must verify against real artifacts, not just claim "done".
|
|
238
|
+
3. **No infinite loops** — No-progress detection, max turns, and token budgets prevent runaway agents.
|
|
239
|
+
4. **User input suspends** — When you type something, auto-continuation pauses automatically. No interference.
|
|
240
|
+
5. **Branch-local state** — Goal state follows session branches. `/tree` to a different point and you get that point's goals.
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## Comparison
|
|
245
|
+
|
|
246
|
+
| Feature | pi-goal-pro | Michaelliv/pi-goal | capyup/pi-goal | opencode-goal-plugin |
|
|
247
|
+
|---------|------------|-------------------|----------------|---------------------|
|
|
248
|
+
| No-progress detection | ✅ | ❌ | ❌ | ✅ |
|
|
249
|
+
| Evidence/blocker required | ✅ | ❌ | ❌ | ✅ |
|
|
250
|
+
| Token budget | ✅ | ✅ | ✅ | ✅ |
|
|
251
|
+
| Max auto-turns | ✅ | ❌ | ❌ | ✅ |
|
|
252
|
+
| Auto-continuation | ✅ | ✅ | ✅ | ✅ |
|
|
253
|
+
| User input suspends | ✅ | ❌ | ❌ | ❌ |
|
|
254
|
+
| Session entry persistence | ✅ | ✅ | ✅ | N/A |
|
|
255
|
+
| Compaction survival | ✅ | ✅ | ✅ | N/A |
|
|
256
|
+
| Footer status bar | ✅ | ✅ | ✅ | N/A |
|
|
257
|
+
| Multiple goals (queue) | ✅ (paused) | ✅ (FIFO) | ✅ (focus) | ❌ |
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## Development
|
|
262
|
+
|
|
263
|
+
Built as a single-file Pi extension — no build step required. Edit `index.ts`, then `/reload`.
|
|
264
|
+
|
|
265
|
+
To run without installing:
|
|
266
|
+
|
|
267
|
+
```bash
|
|
268
|
+
pi -e ~/.pi/agent/extensions/pi-goal-pro/index.ts
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
## Credits
|
|
274
|
+
|
|
275
|
+
Inspired by and building upon:
|
|
276
|
+
- [Michaelliv/pi-goal](https://github.com/Michaelliv/pi-goal) — Clean architecture and session persistence patterns
|
|
277
|
+
- [capyup/pi-goal](https://github.com/capyup/pi-goal) — Immutable objective, completion audit concepts
|
|
278
|
+
- [prevalentWare/opencode-goal-plugin](https://github.com/prevalentWare/opencode-goal-plugin) — No-progress detection, evidence requirements
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## License
|
|
283
|
+
|
|
284
|
+
MIT
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
# pi-goal-pro 🎯
|
|
289
|
+
|
|
290
|
+
> Персистентные автономные цели для [Pi](https://pi.dev) — с детекцией отсутствия прогресса, завершением на основе доказательств, бюджетом токенов и автопродолжением.
|
|
291
|
+
|
|
292
|
+
Задай долгоживущую цель — и агент будет работать автономно, пока не закончит, не будет приостановлен или не упрётся в ограничение. Без необходимости повторять промпт каждый turn.
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
/goal Переписать auth модуль на JWT с нормальной обработкой ошибок
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
Можно отойти от клавиатуры. Агент продолжает сам. Когда закончит — отчитается с доказательствами.
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
## Установка
|
|
303
|
+
|
|
304
|
+
```bash
|
|
305
|
+
mkdir -p ~/.pi/agent/extensions/pi-goal-pro
|
|
306
|
+
# Скопировать файл расширения:
|
|
307
|
+
cp ./index.ts ~/.pi/agent/extensions/pi-goal-pro/
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
Перезагрузить Pi:
|
|
311
|
+
|
|
312
|
+
```
|
|
313
|
+
/reload
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
Проверить что загрузилось:
|
|
317
|
+
|
|
318
|
+
```
|
|
319
|
+
/goal status
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
## Быстрый старт
|
|
325
|
+
|
|
326
|
+
Задай цель — агент начнёт работать:
|
|
327
|
+
|
|
328
|
+
```text
|
|
329
|
+
/goal Добавить retry логику в API клиент с экспоненциальной задержкой
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
Агент начинает немедленно. Статус в футере:
|
|
333
|
+
|
|
334
|
+
```
|
|
335
|
+
🎯 goal active (1.2K/50K) ← статус в футере
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
Управление жизненным циклом:
|
|
339
|
+
|
|
340
|
+
```text
|
|
341
|
+
/goal status # Показать текущее состояние
|
|
342
|
+
/goal pause # Приостановить активную цель
|
|
343
|
+
/goal resume # Возобновить приостановленную
|
|
344
|
+
/goal clear # Удалить все цели
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
---
|
|
348
|
+
|
|
349
|
+
## Инструменты агента
|
|
350
|
+
|
|
351
|
+
Когда цель активна, агент получает два инструмента:
|
|
352
|
+
|
|
353
|
+
**`get_goal`** — прочитать состояние цели.
|
|
354
|
+
|
|
355
|
+
**`update_goal`** — завершить цель (с доказательствами) или признать недостижимой (с причиной):
|
|
356
|
+
|
|
357
|
+
```typescript
|
|
358
|
+
// Завершено — нужно подтверждение
|
|
359
|
+
update_goal({
|
|
360
|
+
status: "complete",
|
|
361
|
+
evidence: "JWT middleware реализован, 12 тестов проходят, CI без регрессий"
|
|
362
|
+
})
|
|
363
|
+
|
|
364
|
+
// Недостижимо — нужно объяснение
|
|
365
|
+
update_goal({
|
|
366
|
+
status: "unmet",
|
|
367
|
+
blocker: "Заблокировано решением по JWT библиотеке — ожидание security review"
|
|
368
|
+
})
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
---
|
|
372
|
+
|
|
373
|
+
## Как это работает
|
|
374
|
+
|
|
375
|
+
Состояние цели хранится в session entry (custom type `pi-goal-pro`). Оно переживает:
|
|
376
|
+
- Перезагрузку сессии (`/reload`)
|
|
377
|
+
- Компактизацию (compaction)
|
|
378
|
+
- Навигацию по дереву сессии (`/tree`)
|
|
379
|
+
- Возобновление сессии
|
|
380
|
+
|
|
381
|
+
Состояние привязано к ветке — при переходе на другую ветку восстанавливается состояние целей для этой ветки.
|
|
382
|
+
|
|
383
|
+
---
|
|
384
|
+
|
|
385
|
+
## Философия дизайна
|
|
386
|
+
|
|
387
|
+
1. **Пользователь владеет целью** — Агент не может молча изменить objective.
|
|
388
|
+
2. **Доказательства перед завершением** — Агент должен верифицировать по реальным артефактам.
|
|
389
|
+
3. **Никаких бесконечных циклов** — Детекция отсутствия прогресса, лимит turn-ов и бюджет токенов.
|
|
390
|
+
4. **Ввод пользователя приостанавливает** — Когда ты печатаешь, автопродолжение ставится на паузу.
|
|
391
|
+
5. **Состояние привязано к ветке** — `/tree` в другую точку восстанавливает цели этой точки.
|
|
392
|
+
|
|
393
|
+
---
|
|
394
|
+
|
|
395
|
+
## Лицензия
|
|
396
|
+
|
|
397
|
+
MIT
|