@each1024/pi-mini-mode 1.3.9 → 1.3.10
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 -0
- package/README.zh-CN.md +1 -0
- package/extensions/footer-status.ts +23 -10
- package/lib/agent-view.ts +1 -8
- package/lib/input-enhancements.ts +1 -1
- package/lib/minimal-theme.ts +16 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -77,6 +77,7 @@ This earlier screenshot and recording show footer configuration, not the newer i
|
|
|
77
77
|
| `/pi-mini-mode-settings` | Configure fields, input enhancements and minimal output |
|
|
78
78
|
| `/pi-mini-mode-minimal on` / `off` | Enable minimal output / restore native history |
|
|
79
79
|
| `Ctrl+O` | Expand or collapse the complete process tree |
|
|
80
|
+
| `Ctrl+S` | Expand or collapse completed subagent rows; yields to Pi `/model`, `/thinking`, and other selectors |
|
|
80
81
|
| `/pi-mini-mode-prompts` | Select and expand/collapse a user message¹ |
|
|
81
82
|
| `/pi-mini-mode-tools` | Select and expand/collapse saved tool text or thinking¹ |
|
|
82
83
|
| `/pi-mini-mode-history` | Browse full process entries, five at a time |
|
package/README.zh-CN.md
CHANGED
|
@@ -77,6 +77,7 @@ pi install git:github.com/eachann1024/pi-mini-mode
|
|
|
77
77
|
| `/pi-mini-mode-settings` | 配置字段、输入增强和极简输出 |
|
|
78
78
|
| `/pi-mini-mode-minimal on` / `off` | 开启极简输出/恢复原生历史 |
|
|
79
79
|
| `Ctrl+O` | 展开/收起完整过程树 |
|
|
80
|
+
| `Ctrl+S` | 展开/收起已完成的子代理行;打开 `/model`、`/thinking` 等选择器时交给 Pi |
|
|
80
81
|
| `/pi-mini-mode-prompts` | 选择并展开/收起用户消息¹ |
|
|
81
82
|
| `/pi-mini-mode-tools` | 选择并展开/收起保存的工具文本或思考¹ |
|
|
82
83
|
| `/pi-mini-mode-history` | 浏览完整过程记录,每次五条 |
|
|
@@ -2,7 +2,7 @@ import { AGENT_STATUS_ENTRY, savedAgentStatuses, retainAgentStatuses, agentChild
|
|
|
2
2
|
import { CONFIG_DIR_NAME, getSettingsListTheme, getMarkdownTheme, type ExtensionAPI, type ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
3
3
|
import { attachTranscript, type NoticeRows, type TurnNotices } from "../lib/transcript-adapter.ts";
|
|
4
4
|
import { diagramMarkdown, isFencedMarkdown, minimalMarkdownTheme } from "../lib/minimal-markdown.ts";
|
|
5
|
-
import { minimalSurface } from "../lib/minimal-theme.ts";
|
|
5
|
+
import { minimalSurface, paintExpandedHeading } from "../lib/minimal-theme.ts";
|
|
6
6
|
import { Container, Markdown, matchesKey, isKeyRelease, isKeyRepeat, sliceByColumn, type SettingItem, SettingsList, Text, type TuiMouseEvent, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
7
7
|
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
8
8
|
import type { InputEnhancementsCleanup } from "../lib/input-enhancements.ts";
|
|
@@ -581,11 +581,11 @@ function visibleMinimalTurns(settings: MiniLensSettings, turns: MinimalTurn[]):
|
|
|
581
581
|
export function minimalOutputComponent(theme: ExtensionContext["ui"]["theme"], getTurns: () => MinimalTurn[], isExpanded: () => boolean = () => false, showShortcut: (turn: MinimalTurn) => boolean = () => true, showUsage: () => boolean = () => true, subAgentsExpanded: () => boolean = () => false, agentDeadlines = new Map<string, number>(), transformText: (text: string) => string = text => text) {
|
|
582
582
|
const markdown = (text: string, width: number, process = false) => new Markdown(text, 0, 0, minimalMarkdownTheme(getMarkdownTheme()),
|
|
583
583
|
{ color: (value) => theme.fg(process ? "muted" : "text", value) }, { transform: (source, available) => transformText(diagramMarkdown(source, available)) }).render(width);
|
|
584
|
-
const surface = (rows: string[], width: number, user: boolean) => {
|
|
584
|
+
const surface = (rows: string[], width: number, user: boolean, selected = -1, expanded = false) => {
|
|
585
585
|
const padding = Math.min(2, Math.floor((width - 1) / 2));
|
|
586
|
-
return ["", ...rows, ""].map((row) => {
|
|
586
|
+
return ["", ...rows, ""].map((row, index) => {
|
|
587
587
|
const line = truncateToWidth(" ".repeat(padding) + row, width, "");
|
|
588
|
-
return minimalSurface(theme, line + " ".repeat(Math.max(0, width - visibleWidth(line))), user);
|
|
588
|
+
return minimalSurface(theme, line + " ".repeat(Math.max(0, width - visibleWidth(line))), user, expanded && index === selected);
|
|
589
589
|
});
|
|
590
590
|
};
|
|
591
591
|
let agentExpiry = Infinity;
|
|
@@ -709,6 +709,9 @@ export function minimalOutputComponent(theme: ExtensionContext["ui"]["theme"], g
|
|
|
709
709
|
for (const id of expandedThinking) if (!thinkingIds.has(id)) expandedThinking.delete(id);
|
|
710
710
|
const inner = Math.max(1, width - 2 * Math.min(2, Math.floor((width - 1) / 2)));
|
|
711
711
|
const lines: string[] = [];
|
|
712
|
+
// An open heading wears the same full-width selectedBg band as an expanded SubAgent row.
|
|
713
|
+
const bandHeading = (row: string, open: boolean) => open
|
|
714
|
+
? paintExpandedHeading(theme, row + " ".repeat(Math.max(0, width - visibleWidth(row)))) : row;
|
|
712
715
|
for (const [index, turn] of turns.entries()) {
|
|
713
716
|
if (index > 0) lines.push("");
|
|
714
717
|
if (expandedPrompts.has(index) && expandedPrompts.get(index) !== turn.question) expandedPrompts.delete(index);
|
|
@@ -720,14 +723,17 @@ export function minimalOutputComponent(theme: ExtensionContext["ui"]["theme"], g
|
|
|
720
723
|
// Loop wakeups are system-generated user messages. Collapse them even when
|
|
721
724
|
// their short prompt would otherwise fit the normal four-row allowance.
|
|
722
725
|
const userRows = expanded || keepFence ? [...questionRows] : loopSummary ? markdown(loopSummary, inner) : questionRows.slice(0, 4);
|
|
726
|
+
let controlIndex = -1;
|
|
723
727
|
if (!keepFence && (loopSummary || questionRows.length > 4)) {
|
|
724
728
|
const label = expanded ? "▴ 收起" : loopSummary ? "▾ 展开" : `▾ 展开 (${questionRows.length} 行)`;
|
|
725
729
|
const control = truncateToWidth(label, inner, "");
|
|
726
730
|
promptControls.push({ index, question: turn.question, y: lines.length + 1 + userRows.length,
|
|
727
731
|
x: 0, width, label });
|
|
728
732
|
userRows.push(theme.fg("accent", control) + theme.fg("muted", truncateToWidth(" · /pi-mini-mode-prompts", Math.max(0, inner - visibleWidth(control)), "")));
|
|
733
|
+
// The expanded control is this message's heading, so it keeps the band in place of the user surface.
|
|
734
|
+
controlIndex = userRows.length;
|
|
729
735
|
}
|
|
730
|
-
lines.push(...surface(userRows, width, true));
|
|
736
|
+
lines.push(...surface(userRows, width, true, controlIndex, expanded));
|
|
731
737
|
const entries = turn.process.flatMap((entry, processIndex) => {
|
|
732
738
|
if (entry.startsWith("call ")) {
|
|
733
739
|
const call = turn.agentCalls?.find(call => call.id === entry.slice(5));
|
|
@@ -801,7 +807,7 @@ export function minimalOutputComponent(theme: ExtensionContext["ui"]["theme"], g
|
|
|
801
807
|
const bodyWidth = Math.max(0, width - visibleWidth(prefix));
|
|
802
808
|
const overflow = Math.max(0, visibleWidth(renderedBody) - bodyWidth);
|
|
803
809
|
const offset = overflow ? Math.max(0, Math.floor((Date.now() - (turn.startedAt ?? Date.now())) / THINKING_SCROLL_INTERVAL_MS) % (overflow + 9) - 4) : 0;
|
|
804
|
-
lines.push(truncateToWidth(prefix + (bodyWidth ? sliceByColumn(renderedBody, Math.min(overflow, offset), bodyWidth, true) : ""), width, ""));
|
|
810
|
+
lines.push(bandHeading(truncateToWidth(prefix + (bodyWidth ? sliceByColumn(renderedBody, Math.min(overflow, offset), bodyWidth, true) : ""), width, ""), open));
|
|
805
811
|
} else if (label === "Output") {
|
|
806
812
|
// Wrapped output hangs under the body column and keeps the tree rail to the next sibling.
|
|
807
813
|
const indent = visibleWidth(prefix);
|
|
@@ -810,7 +816,7 @@ export function minimalOutputComponent(theme: ExtensionContext["ui"]["theme"], g
|
|
|
810
816
|
lines.push(truncateToWidth(prefix + (wrapped[0] ?? ""), width, ""));
|
|
811
817
|
for (const extra of wrapped.slice(1)) lines.push(truncateToWidth(rail + extra, width, ""));
|
|
812
818
|
} else {
|
|
813
|
-
lines.push(truncateToWidth(prefix + (entry.thinking ? markdown(body, Math.max(1, visibleWidth(body) + 1), true).join(" ").replace(/\s+/g, " ").trim() : theme.fg("muted", body)), width, controlId ? "" : "…"));
|
|
819
|
+
lines.push(bandHeading(truncateToWidth(prefix + (entry.thinking ? markdown(body, Math.max(1, visibleWidth(body) + 1), true).join(" ").replace(/\s+/g, " ").trim() : theme.fg("muted", body)), width, controlId ? "" : "…"), open));
|
|
814
820
|
}
|
|
815
821
|
if (open && call && call.id === pinnedToolId) pinnedTool = { id: call.id, y: lines.length - 1, line: lines.at(-1)! };
|
|
816
822
|
if (open && call) {
|
|
@@ -871,6 +877,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
871
877
|
let promptView: ReturnType<typeof minimalOutputComponent> | undefined;
|
|
872
878
|
let lastAttachMode: string | undefined;
|
|
873
879
|
let remountQueued = false;
|
|
880
|
+
let settingsOverlayOpen = false;
|
|
874
881
|
const agentDeadlines = new Map<string, number>();
|
|
875
882
|
let minimalTurns: MinimalTurn[] = [];
|
|
876
883
|
let activeMinimalTurn: MinimalTurn | undefined;
|
|
@@ -1022,7 +1029,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
1022
1029
|
if (!restoreTranscript) {
|
|
1023
1030
|
restoreAgentWidgets?.();
|
|
1024
1031
|
restoreAgentWidgets = undefined;
|
|
1025
|
-
|
|
1032
|
+
// Settings overlay replaces the transcript; remount after it closes instead of warning.
|
|
1033
|
+
if (!settingsOverlayOpen) ctx.ui.notify(tui.mode === "regular"
|
|
1026
1034
|
? "Minimal output needs the fullscreen renderer. Quit and restart Pi — /reload does not switch TUI mode. Or set TUI mode to fullscreen in /settings."
|
|
1027
1035
|
: "Pi transcript layout not recognized; minimal mode disabled, native output preserved.", "warning");
|
|
1028
1036
|
}
|
|
@@ -1080,7 +1088,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
1080
1088
|
ctx.ui.notify(COPY.tuiRequired, "error");
|
|
1081
1089
|
return;
|
|
1082
1090
|
}
|
|
1083
|
-
|
|
1091
|
+
settingsOverlayOpen = true;
|
|
1092
|
+
try {
|
|
1093
|
+
await ctx.ui.custom((tui, theme, _keybindings, done) => {
|
|
1084
1094
|
const container = new Container();
|
|
1085
1095
|
const preview = new Text(settingsPreviewLine(theme, settings), 1, 1);
|
|
1086
1096
|
const title = new Text(theme.fg("accent", theme.bold(COPY.title)), 1, 1);
|
|
@@ -1095,7 +1105,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
1095
1105
|
items = settingsItems(settings);
|
|
1096
1106
|
cleanupInputEnhancements?.refresh();
|
|
1097
1107
|
preview.setText(settingsPreviewLine(theme, settings));
|
|
1098
|
-
mountMinimalOutput(ctx);
|
|
1099
1108
|
void persistSettings(ctx);
|
|
1100
1109
|
refresh();
|
|
1101
1110
|
refreshMinimalOutput();
|
|
@@ -1134,6 +1143,10 @@ export default function (pi: ExtensionAPI) {
|
|
|
1134
1143
|
},
|
|
1135
1144
|
};
|
|
1136
1145
|
});
|
|
1146
|
+
} finally {
|
|
1147
|
+
settingsOverlayOpen = false;
|
|
1148
|
+
mountMinimalOutput(ctx);
|
|
1149
|
+
}
|
|
1137
1150
|
};
|
|
1138
1151
|
|
|
1139
1152
|
pi.registerCommand("pi-mini-mode-minimal", {
|
package/lib/agent-view.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { diagramMarkdown, isMarkdownProse, minimalMarkdownTheme } from "./minimal-markdown.ts";
|
|
2
2
|
import { extractNoticeBody, supervisorNoticeBody } from "./transcript-adapter.ts";
|
|
3
|
+
import { paintExpandedHeading } from "./minimal-theme.ts";
|
|
3
4
|
import { readdirSync, readFileSync, statSync } from "node:fs";
|
|
4
5
|
import { join, resolve } from "node:path";
|
|
5
6
|
import { tmpdir } from "node:os";
|
|
@@ -167,14 +168,6 @@ export function restyleAgentWidget(lines: string[], theme: Theme, width: number,
|
|
|
167
168
|
return rows;
|
|
168
169
|
}
|
|
169
170
|
|
|
170
|
-
/** Expanded heading: full-width selectedBg, keeping inner fg after resets.
|
|
171
|
-
* theme.bg only wraps the ends; older themes without getBgAnsi lose fill after \x1b[0m. */
|
|
172
|
-
function paintExpandedHeading(theme: Theme, line: string): string {
|
|
173
|
-
const background = theme.getBgAnsi?.("selectedBg") ?? "";
|
|
174
|
-
return background
|
|
175
|
-
? background + line.replace(/\x1b\[(?:0|49)?m/g, reset => reset + background) + "\x1b[49m"
|
|
176
|
-
: theme.bg("selectedBg", line);
|
|
177
|
-
}
|
|
178
171
|
function agentSummary(theme: Theme, width: number, running: number, done: number, errors: number, expanded: boolean): string {
|
|
179
172
|
const label = `Sub Agent · running ${running}${done ? ` · done ${done}` : ""}${errors ? ` · failed ${errors}` : ""}${done ? ` · Ctrl+S ${expanded ? "collapse" : "expand"}` : ""}`;
|
|
180
173
|
const summary = truncateToWidth(theme.fg(errors ? "error" : "muted", label), width);
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
import { CustomEditor, stripFrontmatter, type ExtensionAPI, type ExtensionContext, type InputEvent, type InputEventResult } from "@earendil-works/pi-coding-agent";
|
|
15
15
|
import {
|
|
16
16
|
allocateImageId, getImageDimensions, renderImage, getCapabilities, setCapabilities, getOsc8LinkAtColumn, matchesKey, stripTerminalSequences, truncateToWidth, visibleWidth,
|
|
17
|
-
type AutocompleteItem, type AutocompleteProvider, type
|
|
17
|
+
type AutocompleteItem, type AutocompleteProvider, type EditorComponent, type TuiMouseEvent, type TUI, type OverlayHandle, type OverlayOptions,
|
|
18
18
|
} from "@earendil-works/pi-tui";
|
|
19
19
|
import { filePaths, inputCapabilities, linkRenderedPath, localPath } from "./file-links.ts";
|
|
20
20
|
import { open, readFile } from "node:fs/promises";
|
package/lib/minimal-theme.ts
CHANGED
|
@@ -14,12 +14,23 @@ function ansiColor(ansi: string): RGB | undefined {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
/** Expanded heading: full-width selectedBg, keeping inner fg after resets.
|
|
18
|
+
* theme.bg only wraps the ends; older themes without getBgAnsi lose fill after \x1b[0m. */
|
|
19
|
+
export function paintExpandedHeading(theme: ExtensionContext["ui"]["theme"], line: string): string {
|
|
20
|
+
const background = theme.getBgAnsi?.("selectedBg") ?? "";
|
|
21
|
+
return background
|
|
22
|
+
? background + line.replace(/\x1b\[(?:0|49)?m/g, reset => reset + background) + "\x1b[49m"
|
|
23
|
+
: theme.bg("selectedBg", line);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** User uses the theme's soft surface directly; process keeps its secondary tint.
|
|
27
|
+
* A row inside an expanded heading (selected) keeps the band instead: the
|
|
28
|
+
* blended tint and the user surface both collapse into it. */
|
|
29
|
+
export function minimalSurface(theme: ExtensionContext["ui"]["theme"], text: string, user = false, selected = false): string {
|
|
30
|
+
const background = theme.getBgAnsi?.(selected ? "selectedBg" : "userMessageBg") ?? "";
|
|
31
|
+
if (user || selected) return background
|
|
21
32
|
? background + text.replace(/\x1b\[(?:0|49)?m/g, (reset) => reset + background) + "\x1b[49m"
|
|
22
|
-
: theme.bg("userMessageBg", text);
|
|
33
|
+
: theme.bg(selected ? "selectedBg" : "userMessageBg", text);
|
|
23
34
|
const base = ansiColor(background);
|
|
24
35
|
const accent = ansiColor(theme.fg("accent", "")) ?? ansiColor(theme.fg("success", ""));
|
|
25
36
|
if (!base || !accent) return theme.bg("userMessageBg", text);
|
package/package.json
CHANGED