@pi-unipi/fusion 2.20.2 → 2.20.4
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 +14 -5
- package/package.json +3 -3
- package/src/picker.ts +80 -11
package/README.md
CHANGED
|
@@ -10,10 +10,9 @@ pi's extension and RPC APIs natively.
|
|
|
10
10
|
╭ Model ───────────────────────────────────────────────────────────────╮
|
|
11
11
|
│/ Type to search │
|
|
12
12
|
│───────────────────────────────────────────────────────────────────────│
|
|
13
|
-
│❭ Fusion
|
|
14
|
-
│· GLM-5.3 Flash ✱
|
|
15
|
-
│·
|
|
16
|
-
│· DeepSeek V4.1 Flash ✱ ▰▱▱▱▱ High │
|
|
13
|
+
│❭ Fusion ← ▰▰▰▱▱ → Medium Lead Fable… ▾ │
|
|
14
|
+
│· GLM-5.3 Flash ✱ ▰▰▰▰▰ Max │
|
|
15
|
+
│· openrouter · deepseek/deepseek-v4.1-flash ▰▰▱▱▱ High │
|
|
17
16
|
│ ↓ more below │
|
|
18
17
|
│ │
|
|
19
18
|
│ ━━━━━●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ │
|
|
@@ -21,6 +20,7 @@ pi's extension and RPC APIs natively.
|
|
|
21
20
|
│ $10 / 1M $0.25 / 1M $50 / 1M $0.2 / 1M │
|
|
22
21
|
│ Sidekick cached input Sidekick output │
|
|
23
22
|
│ $0.02 / 1M $1.2 / 1M │
|
|
23
|
+
│ Model key openrouter/deepseek/deepseek-v4.1-flash │
|
|
24
24
|
│ │
|
|
25
25
|
│ ✱ New ✱ Promotion ✱ Beta · Pairs frontier intelligence with cost-efficient execution │
|
|
26
26
|
│↑↓ select · tab lead · ←→ effort · ↵ confirm · esc cancel │
|
|
@@ -44,7 +44,16 @@ pi's extension and RPC APIs natively.
|
|
|
44
44
|
- **Price panel**: the highlighted model's blended price is marked on a
|
|
45
45
|
logarithmic red→orange→yellow→green→cyan→blue→violet slider. Fusion shows
|
|
46
46
|
`Input`, `Cached input`, `Output`, `Sidekick input`, `Sidekick cached input`,
|
|
47
|
-
and `Sidekick output
|
|
47
|
+
and `Sidekick output`, and the exact registry key of the highlighted row is
|
|
48
|
+
spelled out (`Model key openrouter/deepseek/deepseek-v4.1-flash`; both the
|
|
49
|
+
lead and sidekick keys on the Fusion row).
|
|
50
|
+
- **Name column & provider**: the name column sizes itself to the widest row
|
|
51
|
+
label (minimum 24 columns) up to the terminal width, and the effort control
|
|
52
|
+
stays right-anchored — so wide terminals show full names. A row only gets a
|
|
53
|
+
dim `provider · ` prefix when its display name is ambiguous: it contains a
|
|
54
|
+
`/` (`deepseek/deepseek-v4.1-flash` reads like a key) or the same friendly
|
|
55
|
+
name is offered by more than one provider. Unique names stay clean, and the
|
|
56
|
+
prefix is never truncated.
|
|
48
57
|
- **Confirm** applies: `pi.setModel`, `pi.setThinkingLevel(effort)`, updates
|
|
49
58
|
MRU + persisted active selection, and shows `Fusion · Lead ◆ Sidekick` in
|
|
50
59
|
the footer. Switching the model through pi's own `/model`/Ctrl+P drops
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-unipi/fusion",
|
|
3
|
-
"version": "2.20.
|
|
3
|
+
"version": "2.20.4",
|
|
4
4
|
"description": "Devin-style model picker, fusion presets (lead + sidekick), and Local Fusion runtime for UniPi",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@pi-unipi/core": "2.20.
|
|
36
|
-
"@pi-unipi/subagents": "2.20.
|
|
35
|
+
"@pi-unipi/core": "2.20.4",
|
|
36
|
+
"@pi-unipi/subagents": "2.20.4"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@earendil-works/pi-ai": "^0.84.0",
|
package/src/picker.ts
CHANGED
|
@@ -109,9 +109,39 @@ type Row = { kind: "fusion" } | { kind: "model"; key: ModelKey };
|
|
|
109
109
|
type FusionFocus = "effort" | "lead" | "sidekick";
|
|
110
110
|
|
|
111
111
|
const DEFAULT_VISIBLE_ROWS = 10;
|
|
112
|
-
|
|
112
|
+
/** Minimum width of the name column (the pre-autosize default). */
|
|
113
|
+
const NAME_COL_MIN = 24;
|
|
113
114
|
const MARKER_COL = 2;
|
|
114
115
|
const BAR_SEGMENTS = 5;
|
|
116
|
+
/** Visible columns outside the name: pointer + marker prefix (4) + effort block (19). */
|
|
117
|
+
const FIXED_COLS = 23;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* A model needs a provider prefix when its display name alone is ambiguous:
|
|
121
|
+
* it contains a "/" (so it reads like a `provider/id` key), or the same name
|
|
122
|
+
* is offered by more than one provider.
|
|
123
|
+
*/
|
|
124
|
+
function ambiguousNamesOf(models: readonly PickerModel[]): Set<string> {
|
|
125
|
+
const providersByName = new Map<string, Set<string>>();
|
|
126
|
+
for (const m of models) {
|
|
127
|
+
const set = providersByName.get(m.name) ?? new Set<string>();
|
|
128
|
+
set.add(m.provider);
|
|
129
|
+
providersByName.set(m.name, set);
|
|
130
|
+
}
|
|
131
|
+
const out = new Set<string>();
|
|
132
|
+
for (const [name, set] of providersByName) {
|
|
133
|
+
if (set.size > 1) out.add(name);
|
|
134
|
+
}
|
|
135
|
+
return out;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function needsProvider(m: PickerModel, ambiguous: ReadonlySet<string>): boolean {
|
|
139
|
+
return m.name.includes("/") || ambiguous.has(m.name);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function labelOf(m: PickerModel, ambiguous: ReadonlySet<string>): string {
|
|
143
|
+
return needsProvider(m, ambiguous) ? `${m.provider} \u00b7 ${m.name}` : m.name;
|
|
144
|
+
}
|
|
115
145
|
|
|
116
146
|
function printable(data: string): string | undefined {
|
|
117
147
|
if (data.length !== 1) return undefined;
|
|
@@ -146,6 +176,9 @@ export class ModelPicker {
|
|
|
146
176
|
private readonly modelsByKey: Map<ModelKey, PickerModel>;
|
|
147
177
|
private readonly state: PickerState;
|
|
148
178
|
private readonly priceRange: { min: number; max: number };
|
|
179
|
+
private readonly ambiguousNames: Set<string>;
|
|
180
|
+
/** Name column sized to the widest row label; capped to the available width at render time. */
|
|
181
|
+
private readonly naturalNameCol: number;
|
|
149
182
|
|
|
150
183
|
private effort: Record<ModelKey, EffortLevel>;
|
|
151
184
|
/** Fusion-row efforts — deliberately NOT stored in the per-model map. */
|
|
@@ -166,6 +199,12 @@ export class ModelPicker {
|
|
|
166
199
|
this.onRenderRequest = options.onRenderRequest;
|
|
167
200
|
this.visibleRows = options.visibleRows ?? DEFAULT_VISIBLE_ROWS;
|
|
168
201
|
this.modelsByKey = new Map(options.state.models.map((m) => [m.key, m]));
|
|
202
|
+
this.ambiguousNames = ambiguousNamesOf(options.state.models);
|
|
203
|
+
const widestLabel = options.state.models.reduce(
|
|
204
|
+
(max, m) => Math.max(max, visibleWidth(labelOf(m, this.ambiguousNames))),
|
|
205
|
+
0,
|
|
206
|
+
);
|
|
207
|
+
this.naturalNameCol = Math.max(NAME_COL_MIN, widestLabel + 2);
|
|
169
208
|
const prices = options.state.models.map((m) => (hasPricing(m.cost) ? blendedPrice(m.cost) : undefined)).filter((p): p is number => p !== undefined && p > 0);
|
|
170
209
|
this.priceRange = { min: prices.length > 0 ? Math.min(...prices) : 0, max: prices.length > 0 ? Math.max(...prices) : 0 };
|
|
171
210
|
this.effort = { ...options.state.effort };
|
|
@@ -416,7 +455,11 @@ export class ModelPicker {
|
|
|
416
455
|
return shortName(m?.name ?? key, max);
|
|
417
456
|
}
|
|
418
457
|
|
|
419
|
-
private
|
|
458
|
+
private isAmbiguous(model: PickerModel): boolean {
|
|
459
|
+
return needsProvider(model, this.ambiguousNames);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
private renderRow(row: Row, highlighted: boolean, width: number, nameCol: number): string {
|
|
420
463
|
const t = this.theme;
|
|
421
464
|
const pointer = highlighted ? t.fg("accent", "❭") : t.fg("dim", "·");
|
|
422
465
|
const disabledFusion = row.kind === "fusion" && !this.fusionAvailable();
|
|
@@ -429,8 +472,14 @@ export class ModelPicker {
|
|
|
429
472
|
: " "
|
|
430
473
|
: this.markerFor(row.key);
|
|
431
474
|
const working = row.kind === "model" && row.key === this.state.currentModelKey;
|
|
432
|
-
const
|
|
433
|
-
|
|
475
|
+
const model = row.kind === "model" ? this.modelsByKey.get(row.key) : undefined;
|
|
476
|
+
// Only ambiguous rows (slash-y names, or names shared across providers) pay
|
|
477
|
+
// the width cost of a dim provider prefix. The name is truncated, never the
|
|
478
|
+
// prefix, so `openrouter · …` always survives.
|
|
479
|
+
const providerPrefix = model !== undefined && this.isAmbiguous(model) ? t.fg("dim", `${model.provider} · `) : "";
|
|
480
|
+
const nameBudget = Math.max(1, nameCol - visibleWidth(providerPrefix) - 1);
|
|
481
|
+
const nameRaw = row.kind === "fusion" ? "Fusion" : this.nameOf(row.key, nameBudget);
|
|
482
|
+
const styled =
|
|
434
483
|
row.kind === "fusion"
|
|
435
484
|
? disabledFusion
|
|
436
485
|
? highlighted
|
|
@@ -444,7 +493,7 @@ export class ModelPicker {
|
|
|
444
493
|
: highlighted
|
|
445
494
|
? t.fg("accent", nameRaw)
|
|
446
495
|
: t.fg("text", nameRaw);
|
|
447
|
-
const
|
|
496
|
+
const name = `${providerPrefix}${styled}`;
|
|
448
497
|
const badge = model?.badge;
|
|
449
498
|
const badgeGlyph = badge === undefined ? "" : ` ${t.fg(badge === "new" ? "success" : badge === "promotion" ? "accent" : "warning", "✱")}`;
|
|
450
499
|
|
|
@@ -458,7 +507,7 @@ export class ModelPicker {
|
|
|
458
507
|
? t.fg("accent", effortLabel(level))
|
|
459
508
|
: t.fg("muted", effortLabel(level));
|
|
460
509
|
|
|
461
|
-
let line = `${pointer} ${marker} ${pad(`${name}${badgeGlyph}`,
|
|
510
|
+
let line = `${pointer} ${marker} ${pad(`${name}${badgeGlyph}`, nameCol)} ${left} ${this.bar(level, !disabledFusion && highlighted)} ${right} ${pad(label, 8)}`;
|
|
462
511
|
|
|
463
512
|
if (row.kind === "fusion") {
|
|
464
513
|
if (disabledFusion) {
|
|
@@ -480,10 +529,10 @@ export class ModelPicker {
|
|
|
480
529
|
return truncateToWidth(line, Math.max(1, width - 1));
|
|
481
530
|
}
|
|
482
531
|
|
|
483
|
-
private renderDropdown(width: number): string[] {
|
|
532
|
+
private renderDropdown(width: number, nameCol: number): string[] {
|
|
484
533
|
const t = this.theme;
|
|
485
534
|
const items = this.dropdownItems();
|
|
486
|
-
const indent = " ".repeat(MARKER_COL +
|
|
535
|
+
const indent = " ".repeat(MARKER_COL + nameCol + 5);
|
|
487
536
|
if (items.length === 0) {
|
|
488
537
|
return [`${indent}${t.fg("warning", `no ${this.focus} models in preset — run /unipi:fusion-preset`)}`];
|
|
489
538
|
}
|
|
@@ -547,7 +596,23 @@ export class ModelPicker {
|
|
|
547
596
|
: !hasPricing(primaryCost);
|
|
548
597
|
const pricing = !disabledFusion && noPricing ? t.fg("dim", " · no pricing data from provider") : "";
|
|
549
598
|
const description = `${badges}${badges.length > 0 ? " " : ""}${desc}${pricing}`;
|
|
550
|
-
|
|
599
|
+
// The row label may be a friendly name; spell out the exact registry key so
|
|
600
|
+
// the highlighted model is unambiguous (`openrouter/deepseek/...`).
|
|
601
|
+
const keys = row.kind === "fusion"
|
|
602
|
+
? [this.lead, this.sidekick].filter((k): k is ModelKey => k !== undefined)
|
|
603
|
+
: primaryKey === undefined
|
|
604
|
+
? []
|
|
605
|
+
: [primaryKey];
|
|
606
|
+
const out = [
|
|
607
|
+
truncateToWidth(` ${head}`, width - 1),
|
|
608
|
+
truncateToWidth(` ${vals}`, width - 1),
|
|
609
|
+
];
|
|
610
|
+
if (keys.length > 0) {
|
|
611
|
+
const keyText = keys.map((k) => t.fg("text", k)).join(t.fg("dim", " · "));
|
|
612
|
+
out.push(truncateToWidth(` ${t.fg("dim", "Model key")} ${keyText}`, width - 1));
|
|
613
|
+
}
|
|
614
|
+
out.push(truncateToWidth(` ${description}`, width - 1));
|
|
615
|
+
return out;
|
|
551
616
|
}
|
|
552
617
|
|
|
553
618
|
private hintLine(row: Row | undefined): string {
|
|
@@ -572,6 +637,10 @@ export class ModelPicker {
|
|
|
572
637
|
private renderBody(width: number): string[] {
|
|
573
638
|
const t = this.theme;
|
|
574
639
|
const rows = this.rows();
|
|
640
|
+
// Give the name column every spare column (the effort control stays
|
|
641
|
+
// right-anchored) but never less than the historical 24.
|
|
642
|
+
const maxNameCol = Math.max(NAME_COL_MIN, width - FIXED_COLS - 1);
|
|
643
|
+
const nameCol = Math.min(this.naturalNameCol, maxNameCol);
|
|
575
644
|
if (this.selected >= rows.length) this.selected = Math.max(0, rows.length - 1);
|
|
576
645
|
const row = rows[this.selected];
|
|
577
646
|
const lines: string[] = [];
|
|
@@ -591,9 +660,9 @@ export class ModelPicker {
|
|
|
591
660
|
const r = rows[i];
|
|
592
661
|
if (r === undefined) continue;
|
|
593
662
|
const highlighted = i === this.selected;
|
|
594
|
-
lines.push(this.renderRow(r, highlighted, width));
|
|
663
|
+
lines.push(this.renderRow(r, highlighted, width, nameCol));
|
|
595
664
|
if (highlighted && r.kind === "fusion" && this.focus !== "effort") {
|
|
596
|
-
lines.push(...this.renderDropdown(width));
|
|
665
|
+
lines.push(...this.renderDropdown(width, nameCol));
|
|
597
666
|
}
|
|
598
667
|
}
|
|
599
668
|
if (end < rows.length) lines.push(t.fg("dim", ` ↓ more below (${String(rows.length - end)})`));
|