@alexeiled/pi-fusion 0.1.2 → 0.2.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/README.md +119 -35
- package/docs/user-guide.md +16 -6
- package/package.json +5 -8
- package/src/index.ts +1 -0
- package/src/orchestrator.ts +801 -89
- package/src/report.ts +21 -3
- package/src/result-extract.ts +21 -2
- package/src/run-builder.ts +131 -19
- package/src/run-store.ts +121 -1
- package/src/status.ts +34 -14
- package/src/subagent-artifacts.ts +40 -0
- package/src/types.ts +31 -1
- package/AGENTS.md +0 -7
- package/tsconfig.json +0 -19
package/README.md
CHANGED
|
@@ -1,22 +1,121 @@
|
|
|
1
1
|
# pi-fusion
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/@alexeiled/pi-fusion)
|
|
4
|
+
[](https://github.com/alexei-led/pi-fusion/actions/workflows/test.yml?query=branch%3Amaster)
|
|
4
5
|
[](https://nodejs.org/)
|
|
5
6
|
[](./LICENSE)
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
> Parallel models. One judge. Better answers.
|
|
9
|
+
|
|
10
|
+
`pi-fusion` is a Pi extension for hard technical questions.
|
|
11
|
+
It uses `pi-subagents` to send the same prompt through a small parallel model panel,
|
|
12
|
+
then asks a judge agent to compare the outputs and return the best realistic answer.
|
|
13
|
+
|
|
14
|
+
CI covers lint, typecheck, unit tests, integration tests, package smoke tests,
|
|
15
|
+
and `npm pack --dry-run`.
|
|
16
|
+
|
|
17
|
+

|
|
18
|
+
|
|
19
|
+
## Why Fusion exists
|
|
20
|
+
|
|
21
|
+
Hard questions are often bottlenecked by one model's search path.
|
|
22
|
+
`pi-fusion` trades latency for diversity:
|
|
23
|
+
|
|
24
|
+
- the same prompt fans out to several model runs in parallel
|
|
25
|
+
- each model explores the problem from a different training prior and reasoning path
|
|
26
|
+
- overlap raises confidence
|
|
27
|
+
- disagreement exposes risk
|
|
28
|
+
- the judge keeps the strongest parts and drops weak, partial, or conflicting ones
|
|
29
|
+
|
|
30
|
+
This is evidence selection, not majority vote.
|
|
31
|
+
|
|
32
|
+
```mermaid
|
|
33
|
+
%%{init: {"theme": "base", "flowchart": {"curve": "basis", "nodeSpacing": 28, "rankSpacing": 48}, "themeVariables": {"background": "#050816", "fontFamily": "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace", "primaryTextColor": "#E5F0FF", "lineColor": "#38bdf8", "tertiaryColor": "#0b1220"}}}%%
|
|
34
|
+
flowchart LR
|
|
35
|
+
classDef prompt fill:#071321,stroke:#38bdf8,color:#dbeafe,stroke-width:2px;
|
|
36
|
+
classDef modelA fill:#081223,stroke:#38bdf8,color:#dbeafe,stroke-width:2px;
|
|
37
|
+
classDef modelB fill:#120826,stroke:#a855f7,color:#f3e8ff,stroke-width:2px;
|
|
38
|
+
classDef modelC fill:#08180f,stroke:#22c55e,color:#dcfce7,stroke-width:2px;
|
|
39
|
+
classDef modelD fill:#241307,stroke:#f59e0b,color:#fef3c7,stroke-width:2px;
|
|
40
|
+
classDef modelE fill:#260712,stroke:#ff4d8d,color:#ffd1e7,stroke-width:2px;
|
|
41
|
+
classDef judge fill:#2b1905,stroke:#f59e0b,color:#fef3c7,stroke-width:3px;
|
|
42
|
+
classDef answer fill:#062814,stroke:#22c55e,color:#dcfce7,stroke-width:3px;
|
|
43
|
+
classDef note fill:#0b1220,stroke:#475569,color:#cbd5e1,stroke-width:1px;
|
|
44
|
+
|
|
45
|
+
P["input prompt<br/>same question to every model"]:::prompt
|
|
46
|
+
|
|
47
|
+
subgraph PANEL[parallel model panel]
|
|
48
|
+
direction TB
|
|
49
|
+
A["model A<br/>strong baseline candidate"]:::modelA
|
|
50
|
+
B["model B<br/>finds contradiction"]:::modelB
|
|
51
|
+
C["model C<br/>adds unique insight"]:::modelC
|
|
52
|
+
D["model D<br/>fast practical path"]:::modelD
|
|
53
|
+
E["model E<br/>catches edge case"]:::modelE
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
J["judge<br/>consensus • contradictions • blind spots"]:::judge
|
|
57
|
+
R["best answer<br/>selected or synthesized"]:::answer
|
|
58
|
+
N["not majority vote<br/>best evidence wins"]:::note
|
|
59
|
+
|
|
60
|
+
P --> A
|
|
61
|
+
P --> B
|
|
62
|
+
P --> C
|
|
63
|
+
P --> D
|
|
64
|
+
P --> E
|
|
65
|
+
|
|
66
|
+
A --> J
|
|
67
|
+
B --> J
|
|
68
|
+
C --> J
|
|
69
|
+
D --> J
|
|
70
|
+
E --> J
|
|
71
|
+
|
|
72
|
+
J --> R
|
|
73
|
+
J -.-> N
|
|
74
|
+
|
|
75
|
+
linkStyle 0,5 stroke:#38bdf8,stroke-width:3px;
|
|
76
|
+
linkStyle 1,6 stroke:#a855f7,stroke-width:3px;
|
|
77
|
+
linkStyle 2,7 stroke:#22c55e,stroke-width:3px;
|
|
78
|
+
linkStyle 3,8 stroke:#f59e0b,stroke-width:3px;
|
|
79
|
+
linkStyle 4,9 stroke:#ff4d8d,stroke-width:3px;
|
|
80
|
+
linkStyle 10 stroke:#22c55e,stroke-width:4px;
|
|
81
|
+
linkStyle 11 stroke:#94a3b8,stroke-width:2px,stroke-dasharray: 5 5;
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Why a panel can beat one model
|
|
85
|
+
|
|
86
|
+
Single-model answers are brittle on hard tasks. They are limited by one model's
|
|
87
|
+
priors, one reasoning path, and one failure mode.
|
|
88
|
+
|
|
89
|
+
A panel helps because:
|
|
90
|
+
|
|
91
|
+
- different models are trained differently and make different bets
|
|
92
|
+
- errors are less correlated, so blind spots do not line up perfectly
|
|
93
|
+
- consensus is a useful confidence signal without pretending certainty
|
|
94
|
+
- disagreement tells you where the answer is fragile
|
|
95
|
+
- a judge can select or synthesize the best realistic answer from the set
|
|
96
|
+
|
|
97
|
+
The result is slower, but usually better for design choices, risk review,
|
|
98
|
+
tricky debugging, and research-heavy questions.
|
|
99
|
+
|
|
100
|
+
## What the judge actually does
|
|
101
|
+
|
|
102
|
+
The judge gets:
|
|
8
103
|
|
|
9
|
-
|
|
104
|
+
- the original prompt
|
|
105
|
+
- every panel output
|
|
106
|
+
- panel failures and blind spots
|
|
107
|
+
- the configured judge model
|
|
10
108
|
|
|
11
|
-
|
|
109
|
+
It then:
|
|
12
110
|
|
|
13
|
-
- consensus
|
|
14
|
-
- disagreements
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
111
|
+
- finds consensus
|
|
112
|
+
- preserves real disagreements
|
|
113
|
+
- spots weak or incomplete answers
|
|
114
|
+
- pulls forward unique insights worth keeping
|
|
115
|
+
- returns one clear recommendation and next step
|
|
18
116
|
|
|
19
|
-
It
|
|
117
|
+
It does not edit files or spawn more subagents. It does one job: choose or
|
|
118
|
+
synthesize the best realistic answer.
|
|
20
119
|
|
|
21
120
|
## Good fit
|
|
22
121
|
|
|
@@ -30,25 +129,18 @@ Use it for questions like:
|
|
|
30
129
|
|
|
31
130
|
Do not use it for trivial edits, formatting, or obvious one-step fixes.
|
|
32
131
|
|
|
33
|
-
##
|
|
132
|
+
## Commands
|
|
34
133
|
|
|
35
134
|
```text
|
|
36
|
-
/fusion
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
135
|
+
/fusion
|
|
136
|
+
/fusion <prompt>
|
|
137
|
+
/fusion --profile <name> <prompt>
|
|
138
|
+
/fusion -p <name> <prompt>
|
|
139
|
+
/fusion status
|
|
140
|
+
/fusion stop
|
|
141
|
+
/fusion init
|
|
41
142
|
```
|
|
42
143
|
|
|
43
|
-
Default roles:
|
|
44
|
-
|
|
45
|
-
- **Architect** — tradeoffs and failure modes
|
|
46
|
-
- **Implementer** — contracts, edge cases, practical fit
|
|
47
|
-
- **Tester** — regressions and verification
|
|
48
|
-
- **Judge** — synthesis and recommendation
|
|
49
|
-
|
|
50
|
-
Bundled agents are read-only by default. They can inspect files, but they do not edit code, commit changes, or run nested subagents.
|
|
51
|
-
|
|
52
144
|
## Quick start
|
|
53
145
|
|
|
54
146
|
Requirements:
|
|
@@ -68,16 +160,7 @@ Then reload Pi:
|
|
|
68
160
|
/reload
|
|
69
161
|
```
|
|
70
162
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
```text
|
|
74
|
-
/fusion
|
|
75
|
-
/fusion <prompt>
|
|
76
|
-
/fusion --profile <name> <prompt>
|
|
77
|
-
/fusion status
|
|
78
|
-
/fusion stop
|
|
79
|
-
/fusion init
|
|
80
|
-
```
|
|
163
|
+
For commands, config, and troubleshooting details, see [`docs/user-guide.md`](./docs/user-guide.md).
|
|
81
164
|
|
|
82
165
|
## Notes
|
|
83
166
|
|
|
@@ -85,6 +168,7 @@ Then reload Pi:
|
|
|
85
168
|
- Config is optional. Defaults work. Use `/fusion init` when you want project config.
|
|
86
169
|
- Project config lives at `.pi/fusion.json`. Global config lives at `~/.pi/agent/fusion.json`.
|
|
87
170
|
- Output appears as a Pi custom message. Active progress also uses the `fusion` status key.
|
|
171
|
+
- Active runs are reconciled from `pi-subagents` lifecycle artifacts, not only completion events.
|
|
88
172
|
- `pi-fusion` does not own the footer.
|
|
89
173
|
- Prompts and inspected snippets may be sent to your configured model providers through `pi-subagents`.
|
|
90
174
|
|
package/docs/user-guide.md
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
# pi-fusion user guide
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
README covers the why. This guide covers commands, config, and troubleshooting.
|
|
4
4
|
|
|
5
5
|
## Mental model
|
|
6
6
|
|
|
7
|
-
`pi-fusion` turns one hard question into a small
|
|
7
|
+
`pi-fusion` turns one hard question into a small parallel panel:
|
|
8
8
|
|
|
9
9
|
```text
|
|
10
|
-
prompt →
|
|
10
|
+
prompt → parallel panel → judge synthesis → final report
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
+
Normal execution is a single `pi-subagents` async chain. If that chain completes without a judge result but at least two panelists still produced usable answers, `pi-fusion` runs one fallback judge pass instead of losing the review.
|
|
14
|
+
|
|
15
|
+
Panel diversity can come from different model choices, different perspective prompts, or both. In practice, mixing models is usually the main lever.
|
|
16
|
+
|
|
13
17
|
The base Pi session stays in control. Fusion is a tool for decisions, not a replacement for normal coding.
|
|
14
18
|
|
|
15
19
|
## Commands
|
|
@@ -30,7 +34,7 @@ Notes:
|
|
|
30
34
|
|
|
31
35
|
- Bare `/fusion` shows a short help message.
|
|
32
36
|
- `/fusion status` shows the active run, last run, warnings, and subagent run IDs.
|
|
33
|
-
- `/fusion stop` stops the active
|
|
37
|
+
- `/fusion stop` stops the active chain or fallback judge run.
|
|
34
38
|
- `/fusion init` writes `.pi/fusion.json` for the current trusted project.
|
|
35
39
|
- Exact one-word prompts `init`, `status`, and `stop` are reserved as `/fusion` subcommands.
|
|
36
40
|
|
|
@@ -106,9 +110,9 @@ Panel member:
|
|
|
106
110
|
- `id`: stable machine name
|
|
107
111
|
- `label`: human-readable report label
|
|
108
112
|
- `agent`: subagent name
|
|
109
|
-
- `model`: optional model override
|
|
113
|
+
- `model`: optional model override; often the main source of panel diversity
|
|
110
114
|
- `thinking`: optional `off`, `minimal`, `low`, `medium`, `high`, or `xhigh`
|
|
111
|
-
- `role`:
|
|
115
|
+
- `role`: optional perspective hint layered on top of the model
|
|
112
116
|
|
|
113
117
|
Judge:
|
|
114
118
|
|
|
@@ -250,3 +254,9 @@ Need the run IDs:
|
|
|
250
254
|
```text
|
|
251
255
|
/fusion status
|
|
252
256
|
```
|
|
257
|
+
|
|
258
|
+
Notes:
|
|
259
|
+
|
|
260
|
+
- `Chain run` is the normal end-to-end Fusion run.
|
|
261
|
+
- `Fallback judge run` appears only when Fusion had enough panel output to recover a missing judge result.
|
|
262
|
+
- If `pi-subagents` completion notifications are delayed or missed, Fusion still reconciles from lifecycle artifacts written under the subagent async run directory.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alexeiled/pi-fusion",
|
|
3
|
-
"version": "0.1
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "Stronger answers for hard Pi questions via a parallel model panel + judge, built on pi-subagents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
7
7
|
"license": "MIT",
|
|
@@ -22,11 +22,7 @@
|
|
|
22
22
|
"files": [
|
|
23
23
|
"agents/*.md",
|
|
24
24
|
"src/*.ts",
|
|
25
|
-
"
|
|
26
|
-
"LICENSE",
|
|
27
|
-
"AGENTS.md",
|
|
28
|
-
"docs/user-guide.md",
|
|
29
|
-
"tsconfig.json"
|
|
25
|
+
"docs/user-guide.md"
|
|
30
26
|
],
|
|
31
27
|
"scripts": {
|
|
32
28
|
"check": "tsc --noEmit",
|
|
@@ -47,7 +43,8 @@
|
|
|
47
43
|
"agents": [
|
|
48
44
|
"./agents"
|
|
49
45
|
]
|
|
50
|
-
}
|
|
46
|
+
},
|
|
47
|
+
"image": "https://raw.githubusercontent.com/alexei-led/pi-fusion/master/docs/assets/fusion-icon.png"
|
|
51
48
|
},
|
|
52
49
|
"peerDependencies": {
|
|
53
50
|
"@earendil-works/pi-coding-agent": "*",
|
package/src/index.ts
CHANGED