pi-thread-engine 0.1.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/PLAN.md +43 -0
- package/README.md +108 -0
- package/extensions/index.ts +641 -0
- package/package.json +36 -0
- package/src/core/executor.ts +200 -0
- package/src/core/registry.ts +281 -0
- package/src/core/types.ts +104 -0
- package/src/dashboard.ts +223 -0
package/PLAN.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# pi-threads — Thread Engineering for Pi
|
|
2
|
+
|
|
3
|
+
## Vision
|
|
4
|
+
All 7 thread types as first-class pi commands, plus Stories (goal → auto-decomposed phases).
|
|
5
|
+
Wraps pi-subagents where it excels. Builds natively what nobody else has.
|
|
6
|
+
|
|
7
|
+
## Architecture
|
|
8
|
+
|
|
9
|
+
Two backends:
|
|
10
|
+
1. **Subagent** — P/C/B threads delegate to pi-subagents (inherits agents, TUI, artifacts, chains)
|
|
11
|
+
2. **Native** — F/Z/L threads spawn `pi -p` directly (for multi-model fusion + verify gates)
|
|
12
|
+
|
|
13
|
+
Stories orchestrate across both backends — auto-picking the right thread type per phase.
|
|
14
|
+
|
|
15
|
+
## What's Unique (not in pi-subagents or pi-messenger)
|
|
16
|
+
|
|
17
|
+
| Feature | Why it's new |
|
|
18
|
+
|---------|-------------|
|
|
19
|
+
| F-Thread (fusion) | Multi-model competition on same prompt |
|
|
20
|
+
| Z-Thread (zero-touch) | Autonomous + verify command gate |
|
|
21
|
+
| Stories | Goal → auto-decomposed thread phases |
|
|
22
|
+
| Unified dashboard | One /threads view for all agent work |
|
|
23
|
+
| Fusion review | Side-by-side comparison of multi-model results |
|
|
24
|
+
|
|
25
|
+
## Files
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
extensions/index.ts — Extension entry (commands, tools, dashboard, stories)
|
|
29
|
+
src/core/types.ts — Thread, Task, Story, Phase types
|
|
30
|
+
src/core/registry.ts — State machine + event bus + story tracking
|
|
31
|
+
src/core/executor.ts — Dual backend: subagent delegation + native pi -p
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Status
|
|
35
|
+
- [x] Phase 1: Core types, registry, executor
|
|
36
|
+
- [x] Phase 2: All 7 thread commands
|
|
37
|
+
- [x] Phase 3: Stories (/story, /stories)
|
|
38
|
+
- [x] Phase 4: Subagent integration for P/C/B threads
|
|
39
|
+
- [x] Phase 5: Fusion with multi-model support
|
|
40
|
+
- [x] Phase 6: Zero-touch with verify gate
|
|
41
|
+
- [x] Phase 7: Dashboard as TUI custom component (Ctrl+Shift+T)
|
|
42
|
+
- [x] Phase 8: Session persistence (appendEntry + restore)
|
|
43
|
+
- [ ] Phase 9: npm publish
|
package/README.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# 🧵 pi-threads
|
|
2
|
+
|
|
3
|
+
Thread engineering for [pi](https://github.com/badlogic/pi-mono) — all 7 thread types + stories.
|
|
4
|
+
|
|
5
|
+
**Wraps pi-subagents** for P/C/B threads (inheriting agent specialization, chain artifacts, live progress). **Builds natively** what nobody else has: F-Thread (multi-model fusion), Z-Thread (verify gate), and Stories (goal → auto-decomposed thread phases).
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pi install npm:pi-thread-engine
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Or from source:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pi install ./path/to/pi-threads
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Commands
|
|
20
|
+
|
|
21
|
+
| Command | Type | Backend | What |
|
|
22
|
+
|---------|------|---------|------|
|
|
23
|
+
| `/pthread` | P-Thread | subagent | N independent tasks in parallel |
|
|
24
|
+
| `/cthread` | C-Thread | subagent | Sequential phases via subagent chain |
|
|
25
|
+
| `/bthread` | B-Thread | subagent | scout → plan → build → review pipeline |
|
|
26
|
+
| `/fthread` | F-Thread | **native** | Same prompt → N models → compare (UNIQUE) |
|
|
27
|
+
| `/zthread` | Z-Thread | **native** | Autonomous + verify command gate (UNIQUE) |
|
|
28
|
+
| `/lthread` | L-Thread | native | Extended autonomous run |
|
|
29
|
+
| `/story` | Stories | mixed | Auto-decompose goal into thread phases (UNIQUE) |
|
|
30
|
+
|
|
31
|
+
## Unique Features (not in pi-subagents or pi-messenger)
|
|
32
|
+
|
|
33
|
+
### Fusion (`/fthread`)
|
|
34
|
+
Same prompt sent to multiple models in parallel. Compare results, pick the best.
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
/fthread "Design the caching architecture" --count 5
|
|
38
|
+
/fthread "Refactor the auth module" --models anthropic/claude-sonnet-4,google/gemini-2.5-pro,openai/gpt-4o
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Zero-Touch (`/zthread`)
|
|
42
|
+
Autonomous execution with a verification gate. Only ships if the verify command passes.
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
/zthread "Fix all ESLint warnings" --verify "npm run lint"
|
|
46
|
+
/zthread "Add input validation" --verify "npm test"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Stories (`/story`)
|
|
50
|
+
A goal gets auto-decomposed into thread phases. pi-threads picks the right thread type for each phase.
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
/story "Add dark mode to the dashboard" --verify "npm test"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Auto-generates phases:
|
|
57
|
+
1. **Scout** (meta) — research the codebase
|
|
58
|
+
2. **Plan** (fusion) — 3 models brainstorm approaches
|
|
59
|
+
3. **Decide** (chained) — human picks the winner
|
|
60
|
+
4. **Build** (parallel) — implement across files
|
|
61
|
+
5. **Verify** (zero) — run tests
|
|
62
|
+
|
|
63
|
+
## Dashboard
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
/threads — show all threads + stories
|
|
67
|
+
/threads kill t-001 — kill a thread
|
|
68
|
+
/threads review — see completed results (fusion shows comparison)
|
|
69
|
+
/threads prune — clear finished threads
|
|
70
|
+
/stories — list all stories with phase progress
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## LLM Tools
|
|
74
|
+
|
|
75
|
+
- `thread_spawn` — Start any thread type (auto-selects backend)
|
|
76
|
+
- `thread_status` — Check progress of threads and stories
|
|
77
|
+
- `thread_kill` — Stop a thread
|
|
78
|
+
|
|
79
|
+
## Architecture
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
Wrapper layer (pi-subagents): Native layer (pi -p):
|
|
83
|
+
┌──────────────────────────┐ ┌────────────────────────┐
|
|
84
|
+
│ /pthread → /parallel │ │ /fthread → N models │
|
|
85
|
+
│ /cthread → /chain │ │ /zthread → run+verify │
|
|
86
|
+
│ /bthread → scout chain │ │ /lthread → long run │
|
|
87
|
+
└──────────────────────────┘ └────────────────────────┘
|
|
88
|
+
↕ ↕
|
|
89
|
+
┌─────────────────────────────────┐
|
|
90
|
+
│ ThreadRegistry (state machine) │
|
|
91
|
+
│ ThreadExecutor (dispatch) │
|
|
92
|
+
│ /threads dashboard │
|
|
93
|
+
│ /story orchestrator │
|
|
94
|
+
└─────────────────────────────────┘
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## The Thread Framework
|
|
98
|
+
|
|
99
|
+
Based on [thread-engineering](https://github.com/disler/agentic-coding-patterns):
|
|
100
|
+
|
|
101
|
+
> A thread is a unit of engineering work: prompt at the start, review at the end, agent tool calls in between.
|
|
102
|
+
> The metric: **tool calls per unit of your attention**. Maximize this.
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
Base → P-Thread → C-Thread → F-Thread → B-Thread → L-Thread → Z-Thread
|
|
106
|
+
↑
|
|
107
|
+
The north star
|
|
108
|
+
```
|