@each1024/pi-mini-mode 2.0.17 → 2.0.19
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 +1 -1
- package/README.zh-CN.md +1 -1
- package/extensions/footer-status.ts +70 -11
- package/lib/agent-render.ts +352 -14
- package/lib/agent-state.ts +109 -6
- package/lib/agent-view.ts +4 -1
- package/lib/assistant-images.ts +30 -3
- package/lib/file-links.ts +24 -3
- package/lib/input-editor.ts +26 -5
- package/lib/minimal-output.ts +417 -83
- package/lib/minimal-turns.ts +18 -2
- package/lib/print-agent.ts +712 -0
- package/lib/settings.ts +6 -2
- package/lib/token-speed.ts +219 -30
- package/lib/update-banner.ts +161 -0
- package/lib/usage.ts +41 -8
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -75,7 +75,7 @@ Enable **Minimal output** in `/pi-mini-mode-settings`.
|
|
|
75
75
|

|
|
76
76
|
|
|
77
77
|
- **Long prompts, folded.** In fullscreen minimal mode, long user messages show the first four rendered rows. Click the fold control to reveal the rest. Complete fenced code blocks stay intact.
|
|
78
|
-
- **Subagents, in plain sight.** Click a subagent row to expand its available activity and message/final output. In minimal mode, this extension uses `Ctrl+S` to expand or collapse completed subagent summaries; Pi's focused selectors keep their own keys. A dispatch receipt or returned tool call is not a completed background task.
|
|
78
|
+
- **Subagents, in plain sight.** Click a subagent row to expand its available activity and message/final output. In minimal mode, this extension uses `Ctrl+S` to expand or collapse completed subagent summaries; Pi's focused selectors keep their own keys. A dispatch receipt or returned tool call is not a completed background task. Without pi-subagents, `pi -p` / `pi --mode json` shell calls are collected as subagent rows too; both kinds show a table of time, steps, input/output tokens and cache hit rate, with per-step usage and session details when expanded.
|
|
79
79
|
- **A process tree, not a wall of output.** Thinking, tools and skill reads share one chronological tree. The latest summaries stay visible, including the latest thinking; `Ctrl+O` expands or collapses the full process. New questions start collapsed.
|
|
80
80
|
- **Tool details on demand.** Expand a tool or thinking entry, including the latest thinking, using its fold control. Thinking starts collapsed and only expands or collapses manually, including while running. Tool details show saved text, not the original custom renderer or image output.
|
|
81
81
|
- **Readable summaries.** Long tool rows keep the command beginning and put the ellipsis at the end; expanding reveals the complete long or multiline input. Live thinking follows the latest returned summary, while completed thinking previews its beginning and expands to the full received text. Empty summaries show their actual state without repeating a tool command; failures and interruptions stop the thinking clock.
|
package/README.zh-CN.md
CHANGED
|
@@ -75,7 +75,7 @@ pi install git:github.com/eachann1024/pi-mini-mode
|
|
|
75
75
|

|
|
76
76
|
|
|
77
77
|
- **长消息,自动折叠。** 全屏极简模式下,长用户消息默认保留前四个显示行。点击折叠控件展开全文。完整代码围栏保持完整。
|
|
78
|
-
- **子代理,清晰可查。** 点击子代理行,展开可用的活动记录与消息/最终输出。极简模式下,本扩展用 `Ctrl+S` 展开/收起已完成的子代理摘要;Pi
|
|
78
|
+
- **子代理,清晰可查。** 点击子代理行,展开可用的活动记录与消息/最终输出。极简模式下,本扩展用 `Ctrl+S` 展开/收起已完成的子代理摘要;Pi 当前聚焦的选择器保留自己的快捷键。任务派发回执或工具调用返回,不等于后台任务已完成。未安装 pi-subagents 时,shell 里的 `pi -p` / `pi --mode json` 调用也会收纳为子代理行;两类子代理都以表格显示用时、步骤、输入/输出 token 和缓存命中率,展开后可看每步用量和会话信息。
|
|
79
79
|
- **过程是一棵树,而非满屏输出。** 思考、工具与技能读取汇入同一棵时间顺序树,显示最新摘要,包括最新一条思考;`Ctrl+O` 展开/收起完整过程,新问题默认收起。
|
|
80
80
|
- **工具详情,按需展开。** 点击工具或思考条目的折叠控件,最新一条思考也可以展开。思考默认收起,进行中与结束后均只由手动操作展开或收起。工具详情展示保存的文本,不还原原生自定义渲染器或图片输出。
|
|
81
81
|
- **把空间留给答案。** 最终 Markdown 流式呈现,不添加额外标题或背景。失败和中断明确标记;折叠只改变显示,不删除原始会话消息。
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AGENT_STATUS_ENTRY, savedAgentStatuses, retainAgentStatuses, agentChildren, agentCall, agentStatusesByTurn, attachAgentWidgets, readAgentStatuses } from "../lib/agent-view.ts";
|
|
1
|
+
import { AGENT_STATUS_ENTRY, savedAgentStatuses, retainAgentStatuses, agentChildren, agentCall, agentStatusesByTurn, attachAgentWidgets, readAgentStatuses, isPrintAgentCall } from "../lib/agent-view.ts";
|
|
2
2
|
import { getAgentDir, SettingsManager, type ExtensionAPI, type ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
3
3
|
import { matchesKey, isKeyRelease, isKeyRepeat, type TuiMouseEvent } from "@earendil-works/pi-tui";
|
|
4
4
|
import { attachTranscript } from "../lib/transcript-adapter.ts";
|
|
@@ -16,6 +16,7 @@ import { statusLine } from "../lib/footer-line.ts";
|
|
|
16
16
|
import { contentText, minimalTurnsFromBranch, processText, pushProcess, skillNames, type MinimalTurn } from "../lib/minimal-turns.ts";
|
|
17
17
|
import { minimalOutputComponent } from "../lib/minimal-output.ts";
|
|
18
18
|
import { createThinkingStream } from "../lib/thinking-stream.ts";
|
|
19
|
+
import { PACKAGE_VERSION, isNewerVersion } from "../lib/update-banner.ts";
|
|
19
20
|
|
|
20
21
|
// Preserve the existing module entry points for consumers and focused checks.
|
|
21
22
|
export { SETTINGS_FILE_NAME, DEFAULT_SETTINGS, FOOTER_FIELDS, FOOTER_STYLE_OPTIONS, settingsPath, parseSettings, settingsNeedBackfill, loadSettings, saveSettings, settingsItems, type MiniLensSettings } from "../lib/settings.ts";
|
|
@@ -25,6 +26,7 @@ export { SPEED_REFRESH_MS } from "../lib/token-speed.ts";
|
|
|
25
26
|
export { isPlannotatorPlanningStatus, planCapsule, settingsPreviewLine, statusLine } from "../lib/footer-line.ts";
|
|
26
27
|
export { formatElapsed, formatToolElapsed, formatThinkingElapsed, minimalTurnsFromBranch, type MinimalTurn, type ThinkingClock } from "../lib/minimal-turns.ts";
|
|
27
28
|
export { minimalOutputComponent } from "../lib/minimal-output.ts";
|
|
29
|
+
export { PACKAGE_VERSION, UPDATE_RELEASE_DATE, isNewerVersion, renderUpdateBanner } from "../lib/update-banner.ts";
|
|
28
30
|
|
|
29
31
|
/** Pi /model and other selectors own Ctrl+S; the editor exposes getText. */
|
|
30
32
|
export function focusedSelectorOwnsKeys(tui?: { getFocusedComponent?(): unknown } | null): boolean {
|
|
@@ -90,6 +92,10 @@ export default function (pi: ExtensionAPI) {
|
|
|
90
92
|
pi.registerMarkdownTransformer?.(messageLinks);
|
|
91
93
|
let saveChain: Promise<void> = Promise.resolve();
|
|
92
94
|
const configPath = settingsPath();
|
|
95
|
+
let updateBannerChecked = false;
|
|
96
|
+
let activeUpdateBanner: { sessionKey: string; version: string; collapsed: boolean } | undefined;
|
|
97
|
+
const getSessionKey = (ctx: ExtensionContext) =>
|
|
98
|
+
ctx.sessionManager.getSessionFile?.() ?? (ctx.sessionManager as { getSessionId?(): string | undefined }).getSessionId?.() ?? "";
|
|
93
99
|
|
|
94
100
|
const refresh = () => refreshFooter?.();
|
|
95
101
|
const refreshMinimalOutput = () => refreshMinimal?.();
|
|
@@ -136,7 +142,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
136
142
|
refreshMinimal = () => tui.requestRender();
|
|
137
143
|
// Retain children under their originating user turn, including while idle,
|
|
138
144
|
// after a follow-up user message, and when rebuilding a saved session.
|
|
139
|
-
const sessionKey =
|
|
145
|
+
const sessionKey = getSessionKey(ctx);
|
|
140
146
|
let statuses = savedAgentStatuses(ctx.sessionManager.getBranch());
|
|
141
147
|
const persisted = new Map(statuses.map(status => [String(status.runId), JSON.stringify(status)]));
|
|
142
148
|
const saveStatuses = () => {
|
|
@@ -178,6 +184,17 @@ export default function (pi: ExtensionAPI) {
|
|
|
178
184
|
cwd: () => ctx.cwd,
|
|
179
185
|
requestRender: () => tui.requestRender(),
|
|
180
186
|
write: data => tui.terminal.write(data),
|
|
187
|
+
updateBanner: () => activeUpdateBanner && activeUpdateBanner.sessionKey === sessionKey
|
|
188
|
+
? {
|
|
189
|
+
version: activeUpdateBanner.version,
|
|
190
|
+
collapsed: activeUpdateBanner.collapsed,
|
|
191
|
+
toggle: () => {
|
|
192
|
+
if (!activeUpdateBanner) return;
|
|
193
|
+
activeUpdateBanner.collapsed = !activeUpdateBanner.collapsed;
|
|
194
|
+
tui.requestRender();
|
|
195
|
+
},
|
|
196
|
+
}
|
|
197
|
+
: undefined,
|
|
181
198
|
}, () => settings["pi-mini-mode-minimal-record-limit"], () => uiLanguage(settings));
|
|
182
199
|
// Native info notifications use dim; warning/error notifications retain
|
|
183
200
|
// their position in the transcript. No plugin names or message matching.
|
|
@@ -234,16 +251,24 @@ export default function (pi: ExtensionAPI) {
|
|
|
234
251
|
}
|
|
235
252
|
if (restoreTranscript) {
|
|
236
253
|
promptView = view;
|
|
254
|
+
let lastWaitFrame = -1;
|
|
237
255
|
waitingTimer = setInterval(() => {
|
|
256
|
+
const now = Date.now();
|
|
238
257
|
let changed = false;
|
|
239
|
-
|
|
258
|
+
const hasRunningPrint = minimalTurns.some(turn => (turn.agentCalls ?? []).some(call => call.state === "running" && isPrintAgentCall(call)));
|
|
259
|
+
if (now - lastStatusRead >= 1000) {
|
|
240
260
|
const next = retainAgentStatuses(statuses, readAgentStatuses(sessionKey, undefined, statuses));
|
|
241
|
-
changed = JSON.stringify(next) !== JSON.stringify(statuses);
|
|
261
|
+
changed = JSON.stringify(next) !== JSON.stringify(statuses) || hasRunningPrint;
|
|
242
262
|
statuses = next;
|
|
243
263
|
saveStatuses();
|
|
244
|
-
lastStatusRead =
|
|
264
|
+
lastStatusRead = now;
|
|
265
|
+
}
|
|
266
|
+
const frame = Math.floor(now / 250);
|
|
267
|
+
const activeAnim = hasRunningPrint || activeMinimalTurn?.running || agentChildren(statuses).some(child => /^(running|active|starting|queued|pending)$/.test(String(child.status ?? child.state)));
|
|
268
|
+
if (changed || now >= view.agentExpiry() || (activeAnim && frame !== lastWaitFrame)) {
|
|
269
|
+
lastWaitFrame = frame;
|
|
270
|
+
tui.requestRender();
|
|
245
271
|
}
|
|
246
|
-
if (changed || Date.now() >= view.agentExpiry() || activeMinimalTurn?.running || agentChildren(statuses).some(child => /^(running|active|starting|queued|pending)$/.test(String(child.status ?? child.state)))) tui.requestRender();
|
|
247
272
|
}, 100);
|
|
248
273
|
waitingTimer.unref();
|
|
249
274
|
}
|
|
@@ -349,6 +374,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
349
374
|
if (!isRecordLimit(entry)) throw new TypeError("Invalid record limit");
|
|
350
375
|
} else if (key === "pi-mini-mode-language") {
|
|
351
376
|
if (!isUiLanguage(entry)) throw new TypeError("Invalid language");
|
|
377
|
+
} else if (key === "lastSeenVersion") {
|
|
378
|
+
if (entry !== undefined && (typeof entry !== "string" || !/^\d+\.\d+\.\d+$/.test(entry))) throw new TypeError("Invalid version");
|
|
352
379
|
} else if (isLegacyMinimalSetting(key) && typeof entry === "boolean") {
|
|
353
380
|
// Accept stale settings pages; these former child switches no longer gate output.
|
|
354
381
|
continue;
|
|
@@ -424,7 +451,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
424
451
|
};
|
|
425
452
|
const loaded = await loadSettings(configPath);
|
|
426
453
|
settings = loaded.settings;
|
|
427
|
-
if (loaded.exists && loaded.backfilled) await persistSettings(ctx);
|
|
428
454
|
messageCwd = ctx.cwd;
|
|
429
455
|
// 输入增强只在会话中生效,会话开始时再加载;传 getter 让开关变更即时生效,重复调用是幂等的。
|
|
430
456
|
cleanupInputEnhancements = installInputEnhancements(pi, ctx, () => settings["pi-mini-mode-input-enhancements"], () => settings["pi-mini-mode-image-preview"]);
|
|
@@ -434,6 +460,28 @@ export default function (pi: ExtensionAPI) {
|
|
|
434
460
|
activeMinimalTurn = undefined;
|
|
435
461
|
pendingMinimalFinal = "";
|
|
436
462
|
minimalToolOutputIndices.clear();
|
|
463
|
+
const currentSessionKey = getSessionKey(ctx);
|
|
464
|
+
if (updateBannerChecked) {
|
|
465
|
+
activeUpdateBanner = undefined;
|
|
466
|
+
if (settings.lastSeenVersion !== PACKAGE_VERSION) {
|
|
467
|
+
settings = { ...settings, lastSeenVersion: PACKAGE_VERSION };
|
|
468
|
+
}
|
|
469
|
+
} else {
|
|
470
|
+
updateBannerChecked = true;
|
|
471
|
+
const prevVersion = settings.lastSeenVersion;
|
|
472
|
+
const versionChanged = isNewerVersion(PACKAGE_VERSION, prevVersion);
|
|
473
|
+
if (prevVersion !== PACKAGE_VERSION) {
|
|
474
|
+
settings = { ...settings, lastSeenVersion: PACKAGE_VERSION };
|
|
475
|
+
}
|
|
476
|
+
if (loaded.exists && (loaded.backfilled || prevVersion !== PACKAGE_VERSION)) {
|
|
477
|
+
await persistSettings(ctx);
|
|
478
|
+
} else if (!loaded.exists && typeof ctx.ui.select !== "function") {
|
|
479
|
+
await saveSettings(settings, configPath).catch(() => {});
|
|
480
|
+
}
|
|
481
|
+
if (loaded.exists && versionChanged && ctx.mode === "tui" && ctx.hasUI && minimalTurns.length === 0) {
|
|
482
|
+
activeUpdateBanner = { sessionKey: currentSessionKey, version: PACKAGE_VERSION, collapsed: false };
|
|
483
|
+
}
|
|
484
|
+
}
|
|
437
485
|
mountMinimalOutput(ctx);
|
|
438
486
|
ctx.ui.setFooter((tui, theme, footerData) => {
|
|
439
487
|
restoreScrollbar?.();
|
|
@@ -453,6 +501,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
453
501
|
hit: speedHitBox,
|
|
454
502
|
}));
|
|
455
503
|
const onBranchChange = footerData?.onBranchChange?.(() => tui.requestRender());
|
|
504
|
+
let cachedFooterUsage: { key: string; last: unknown; usage: ReturnType<typeof sessionUsage>; waste: ReturnType<typeof cacheWaste> } | undefined;
|
|
456
505
|
return {
|
|
457
506
|
dispose() {
|
|
458
507
|
onBranchChange?.();
|
|
@@ -476,8 +525,17 @@ export default function (pi: ExtensionAPI) {
|
|
|
476
525
|
mountMinimalOutput(ctx);
|
|
477
526
|
});
|
|
478
527
|
}
|
|
528
|
+
const sm = ctx.sessionManager as { getLeafId?(): string | null; getEntries?(): unknown[]; getBranch(): any[] };
|
|
529
|
+
const hasFastKey = typeof sm.getLeafId === "function" && typeof sm.getEntries === "function";
|
|
530
|
+
const entries = hasFastKey ? sm.getEntries!() : sm.getBranch();
|
|
531
|
+
const usageKey = hasFastKey ? `${sm.getLeafId!() ?? ""}:${entries.length}` : `b:${entries.length}`;
|
|
532
|
+
const lastEntry = entries.at(-1);
|
|
533
|
+
if (!cachedFooterUsage || cachedFooterUsage.key !== usageKey || cachedFooterUsage.last !== lastEntry) {
|
|
534
|
+
const branch = hasFastKey ? sm.getBranch() : entries;
|
|
535
|
+
cachedFooterUsage = { key: usageKey, last: lastEntry, usage: sessionUsage(ctx), waste: cacheWaste(branch) };
|
|
536
|
+
}
|
|
479
537
|
const speed = speeds.displayed();
|
|
480
|
-
const line = statusLine(ctx, theme, width,
|
|
538
|
+
const line = statusLine(ctx, theme, width, cachedFooterUsage.usage, settings, speed, undefined, mcpCount, footerData?.getExtensionStatuses?.(), footerData?.getGitBranch?.(), cachedFooterUsage.waste);
|
|
481
539
|
const speedText = settings["pi-mini-mode-speed-show"] && speed !== undefined
|
|
482
540
|
? formatSpeed(speed, settings["pi-mini-mode-speed-unit-show"])
|
|
483
541
|
: "";
|
|
@@ -561,12 +619,13 @@ export default function (pi: ExtensionAPI) {
|
|
|
561
619
|
pendingMinimalFinal = "";
|
|
562
620
|
// Keep the last completed average visible until this response produces a live sample.
|
|
563
621
|
// Tool-call-only assistant messages therefore cannot erase a useful rate.
|
|
564
|
-
speeds.onAssistantStart(Date.now());
|
|
622
|
+
speeds.onAssistantStart(Date.now(), event.message as { provider?: unknown; model?: unknown });
|
|
565
623
|
startSpeedTimer();
|
|
566
624
|
});
|
|
567
625
|
pi.on("message_update", (event) => {
|
|
568
626
|
const partial = (event.assistantMessageEvent as { partial?: { usage?: UsageLike; content?: Array<Record<string, unknown>> } }).partial;
|
|
569
|
-
|
|
627
|
+
const streamEvent = event.assistantMessageEvent as { type?: string; delta?: string } | undefined;
|
|
628
|
+
if (speeds.onStream({ at: Date.now(), output: finiteNumber(partial?.usage?.output), content: partial?.content, usage: partial?.usage, type: streamEvent?.type, delta: streamEvent?.delta })) {
|
|
570
629
|
refresh();
|
|
571
630
|
speedHover?.relayout();
|
|
572
631
|
}
|
|
@@ -683,7 +742,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
683
742
|
const startedAt = finiteNumber((event as { timestamp?: unknown }).timestamp) ?? Date.now();
|
|
684
743
|
speeds.onTurnStart(startedAt);
|
|
685
744
|
});
|
|
686
|
-
pi.on("agent_start", refresh);
|
|
745
|
+
pi.on("agent_start", () => { speeds.onRunStart(); refresh(); });
|
|
687
746
|
pi.on("agent_end", refresh);
|
|
688
747
|
pi.on("agent_settled", () => {
|
|
689
748
|
if (!activeMinimalTurn) return;
|