@each1024/pi-mini-mode 2.0.16 → 2.0.17
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/lib/file-links.ts +6 -24
- package/lib/link-hover.ts +54 -0
- package/lib/minimal-output.ts +24 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -102,6 +102,7 @@ This earlier screenshot shows footer configuration, not the newer image, folding
|
|
|
102
102
|
|
|
103
103
|
## Compatibility
|
|
104
104
|
|
|
105
|
+
- **Links and hover:** files and directories use standard OSC 8, respecting Pi's effective terminal capabilities and user overrides instead of a terminal-specific bare-path detector. Tool, skill, and thinking rows in fullscreen minimal output highlight across the row on hover; links elsewhere highlight locally. Links gain an underline when the terminal reports Ctrl. macOS Cmd underlining belongs to the terminal; Ghostty fullscreen mouse capture usually requires `Shift+Cmd`. Standard mouse reports do not include Cmd, so identical Cmd-only behavior across terminals cannot be guaranteed. Paths remain visible when OSC 8 is unavailable.
|
|
105
106
|
- **Images:** previews require a terminal image protocol; unsupported terminals show a hint. Large images are resized for the terminal preview only (up to 1200 × 800 pixels and 1 MB encoded); the original file and submitted path are unchanged. Image reads are limited to **20 MB**, and deleted files cannot be reopened. Link gestures depend on the terminal: usually `Cmd+click` on macOS or `Ctrl+click` on Windows/Linux; Ghostty fullscreen may require `Shift+Cmd` / `Shift+Ctrl`. Pi fullscreen also supports a direct left-click. Right-clicking a file link reveals and selects that file on macOS and Windows, and opens its folder elsewhere. Right-clicking empty space keeps selection or paste behavior. See [Pi terminal setup](https://github.com/earendil-works/pi-mono/blob/main/packages/coding-agent/docs/terminal-setup.md).
|
|
106
107
|
- **Minimal output:** uses a private Pi 0.85.x layout adapter without patching Pi’s installation. Unknown layouts refuse activation and keep native output. Recheck after Pi upgrades; other transcript-replacing extensions can conflict.
|
|
107
108
|
- **Subagents:** the pi-subagents widget adapter runs only in minimal mode, restores on disable, and passes unknown formats through. Available details depend on the integration’s status/output data; this is not a complete subagent transcript viewer.
|
package/README.zh-CN.md
CHANGED
|
@@ -101,6 +101,7 @@ pi install git:github.com/eachann1024/pi-mini-mode
|
|
|
101
101
|
|
|
102
102
|
## 兼容性
|
|
103
103
|
|
|
104
|
+
- **链接与悬停:** 文件、目录统一使用标准 OSC 8,遵循 Pi 检测到的终端能力和用户开关,不依赖某个终端识别裸路径。全屏极简模式中的工具、技能和思考记录悬停时整行高亮,其他位置的链接局部高亮;终端报告 Ctrl 状态时增加链接下划线。macOS 的 Cmd 下划线由终端处理,Ghostty 全屏鼠标捕获下通常需要 `Shift+Cmd`。标准鼠标协议不报告 Cmd 状态,因此无法保证各终端仅按 Cmd 的行为完全一致。不支持 OSC 8 时保留路径文字。
|
|
104
105
|
- **图片:** 预览依赖终端图片协议,不支持时显示提示。大图仅对终端预览副本缩放(不超过 1200 × 800 像素、编码后 1 MB);原文件和提交路径不变。读取上限 **20 MB**,文件被清理后无法重新打开。点击手势由终端决定:macOS 通常使用 `Cmd+点击`,Windows/Linux 通常使用 `Ctrl+点击`;Ghostty 全屏可能需要 `Shift+Cmd` / `Shift+Ctrl`。Pi 全屏也支持直接左键打开链接;右键文件链接会在文件管理器中定位并选中该文件(macOS、Windows),其他系统打开所在文件夹。空白处右键仍按原来的选择或粘贴行为。参见 [Pi 终端设置](https://github.com/earendil-works/pi-mono/blob/main/packages/coding-agent/docs/terminal-setup.md)。
|
|
105
106
|
- **极简输出:** 使用私有 Pi 0.85.x 布局适配器,不修改 Pi 安装目录。未知布局会拒绝启用并保留原生输出;升级 Pi 后需重新检查,其他替换 transcript 的扩展可能冲突。
|
|
106
107
|
- **子代理:** pi-subagents 小组件适配仅在极简模式启用,关闭后恢复原状,未知格式原样交给原生处理。可用详情取决于集成提供的状态/输出数据,不是完整子代理会话查看器。
|
package/lib/file-links.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
|
-
import { dirname, isAbsolute,
|
|
3
|
+
import { dirname, isAbsolute, resolve } from "node:path";
|
|
4
4
|
import { pathToFileURL } from "node:url";
|
|
5
5
|
import { Marked, getCapabilities, sliceByColumn, stripTerminalSequences, visibleWidth } from "@earendil-works/pi-tui";
|
|
6
6
|
|
|
@@ -23,21 +23,6 @@ export function localPath(path: string, cwd: string): string {
|
|
|
23
23
|
return path.startsWith("~/") ? resolve(homedir(), path.slice(2)) : isAbsolute(path) ? path : resolve(cwd, path);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
/** Otty always underlines OSC 8; ordinary paths use its Cmd-only detection instead. */
|
|
27
|
-
function nativePathLinks(): boolean {
|
|
28
|
-
return process.env.TERM_PROGRAM?.toLowerCase() === "otty"
|
|
29
|
-
&& !process.env.TMUX && !process.env.STY && !/^(tmux|screen)/i.test(process.env.TERM ?? "");
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/** Short forms must remain real paths that Otty can resolve from the pane's cwd. */
|
|
33
|
-
function nativePathLabel(path: string, cwd: string): string {
|
|
34
|
-
const fromCwd = relative(cwd, path);
|
|
35
|
-
if (fromCwd && fromCwd !== ".." && !fromCwd.startsWith("../") && !isAbsolute(fromCwd)) return `./${fromCwd}`;
|
|
36
|
-
const fromHome = relative(homedir(), path);
|
|
37
|
-
if (fromHome && fromHome !== ".." && !fromHome.startsWith("../") && !isAbsolute(fromHome)) return `~/${fromHome}`;
|
|
38
|
-
return path;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
26
|
/** Opening/closing fences must stay intact; quoted paths inside them are not links. */
|
|
42
27
|
function fenceRanges(text: string): Array<[number, number]> {
|
|
43
28
|
const ranges: Array<[number, number]> = [];
|
|
@@ -82,15 +67,14 @@ export const fileLink = (text: string, path: string, underline = true) => `\x1b]
|
|
|
82
67
|
|
|
83
68
|
/** Shorten only visible tool labels; OSC 8 targets retain the complete original path. */
|
|
84
69
|
export function linkToolFiles(text: string, cwd: string, compact: boolean): string {
|
|
85
|
-
const
|
|
86
|
-
const shorten = (label: string) => compact && !native ? label
|
|
70
|
+
const shorten = (label: string) => compact ? label
|
|
87
71
|
.replace(/\/var\/folders\/[^\s]*\/otty-paste\//g, "…/otty-paste/")
|
|
88
72
|
.replace(/node_modules\/@earendil-works\//g, "…/") : label;
|
|
89
73
|
const hyperlinks = inputCapabilities().hyperlinks;
|
|
90
74
|
// Image chips already carry a complete target; never shorten or relink it.
|
|
91
75
|
return text.split(/(\x1b\]8;[^\x07]*\x07[\s\S]*?\x1b\]8;;\x07)/g).map((part, index) => {
|
|
92
76
|
if (index % 2) return part;
|
|
93
|
-
if (!hyperlinks
|
|
77
|
+
if (!hyperlinks) return shorten(part);
|
|
94
78
|
// A path tool's entire argument can contain spaces or punctuation without quotes.
|
|
95
79
|
const matches = part && !/[\x00-\x1f\x7f]/.test(part) && existsSync(localPath(part, cwd))
|
|
96
80
|
? [{ path: part, start: 0, end: part.length }] : filePaths(part);
|
|
@@ -99,8 +83,8 @@ export function linkToolFiles(text: string, cwd: string, compact: boolean): stri
|
|
|
99
83
|
const path = localPath(match.path, cwd);
|
|
100
84
|
result += shorten(part.slice(offset, match.start));
|
|
101
85
|
const exists = existsSync(path);
|
|
102
|
-
const label =
|
|
103
|
-
result += exists
|
|
86
|
+
const label = shorten(part.slice(match.start, match.end));
|
|
87
|
+
result += exists ? fileLink(label, path, false) : label;
|
|
104
88
|
offset = match.end;
|
|
105
89
|
}
|
|
106
90
|
return result + shorten(part.slice(offset));
|
|
@@ -110,7 +94,6 @@ export function linkToolFiles(text: string, cwd: string, compact: boolean): stri
|
|
|
110
94
|
/** Display-only: normalize local targets without changing persisted messages or remote URLs. */
|
|
111
95
|
export function linkMessageFiles(text: string, cwd: string): string {
|
|
112
96
|
if (!inputCapabilities().hyperlinks) return text;
|
|
113
|
-
const native = nativePathLinks();
|
|
114
97
|
let imageNumber = 0;
|
|
115
98
|
return text.split(/(\x1b\]8;[^\x07]*(?:\x07)[\s\S]*?\x1b\]8;;\x07|\[[^\]\n]*\]\([^\n]*?\))/g).map((part, index) => {
|
|
116
99
|
if (index % 2) {
|
|
@@ -126,8 +109,7 @@ export function linkMessageFiles(text: string, cwd: string): string {
|
|
|
126
109
|
for (const match of matches.reverse()) {
|
|
127
110
|
const path = localPath(match.path, cwd);
|
|
128
111
|
if (!existsSync(path)) continue;
|
|
129
|
-
const label =
|
|
130
|
-
: fileLink(match.image ? ` #${match.number}` : match.path, path, !match.image);
|
|
112
|
+
const label = fileLink(match.image ? ` #${match.number}` : match.path, path, false);
|
|
131
113
|
part = part.slice(0, match.start) + label + part.slice(match.end);
|
|
132
114
|
}
|
|
133
115
|
return part;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { getOsc8LinkAtColumn, sliceByColumn, visibleWidth, type TuiMouseEvent } from "@earendil-works/pi-tui";
|
|
2
|
+
|
|
3
|
+
/** OSC 8 identifies targets; standard mouse events and SGR supply hover feedback.
|
|
4
|
+
* Cmd is not a modifier in SGR mouse reports. The terminal owns Cmd underlining;
|
|
5
|
+
* Ctrl reports can provide the same feedback inside a mouse-capturing TUI.
|
|
6
|
+
*/
|
|
7
|
+
export function createLinkHover(highlight: (text: string) => string) {
|
|
8
|
+
let rows: string[] = [];
|
|
9
|
+
let width = 0;
|
|
10
|
+
let hovered: { row: number; start: number; end: number; source: string; underline: boolean } | undefined;
|
|
11
|
+
const clear = () => { const changed = !!hovered; hovered = undefined; return changed; };
|
|
12
|
+
return {
|
|
13
|
+
clear,
|
|
14
|
+
handleMouse(event: TuiMouseEvent): boolean {
|
|
15
|
+
if (event.type !== "move") return clear();
|
|
16
|
+
const source = rows[event.y];
|
|
17
|
+
if (!source || event.x < 0 || event.x >= visibleWidth(source)) return clear();
|
|
18
|
+
const underline = event.ctrl;
|
|
19
|
+
if (hovered?.row === event.y && hovered.source === source
|
|
20
|
+
&& event.x >= hovered.start && event.x < hovered.end) {
|
|
21
|
+
const changed = hovered.underline !== underline;
|
|
22
|
+
hovered.underline = underline;
|
|
23
|
+
return changed;
|
|
24
|
+
}
|
|
25
|
+
const url = getOsc8LinkAtColumn(source, event.x);
|
|
26
|
+
if (!url) return clear();
|
|
27
|
+
let start = event.x, end = event.x + 1;
|
|
28
|
+
while (start > 0 && getOsc8LinkAtColumn(source, start - 1) === url) start--;
|
|
29
|
+
while (end < visibleWidth(source) && getOsc8LinkAtColumn(source, end) === url) end++;
|
|
30
|
+
hovered = { row: event.y, start, end, source, underline };
|
|
31
|
+
return true;
|
|
32
|
+
},
|
|
33
|
+
render(lines: string[], columns: number): string[] {
|
|
34
|
+
if (columns !== width || hovered && lines[hovered.row] !== hovered.source) clear();
|
|
35
|
+
rows = lines;
|
|
36
|
+
width = columns;
|
|
37
|
+
if (!hovered) return lines;
|
|
38
|
+
const { row, start, end, underline } = hovered;
|
|
39
|
+
const line = lines[row];
|
|
40
|
+
// A slice replays preceding ANSI state. Remove its old background so
|
|
41
|
+
// user-message/code surfaces cannot cover the hover background.
|
|
42
|
+
let label = highlight(sliceByColumn(line, start, end - start)
|
|
43
|
+
.replace(/\x1b\[(?:4[0-9]|10[0-7]|48;(?:2;\d+;\d+;\d+|5;\d+))m/g, ""));
|
|
44
|
+
if (underline) label = "\x1b[4m" + label.replace(/\x1b\[(?:0|24)?m/g, reset => reset + "\x1b[4m") + "\x1b[24m";
|
|
45
|
+
const result = [...lines];
|
|
46
|
+
// Column slicing omits zero-width sequences after the final cell.
|
|
47
|
+
// Retain them (including image placement), then isolate the row's state.
|
|
48
|
+
const trailing = line.match(/(?:\x1b\[[0-?]*[ -/]*[@-~]|\x1b[\]_][^\x07\x1b]*(?:\x07|\x1b\\))+$/)?.[0] ?? "";
|
|
49
|
+
result[row] = sliceByColumn(line, 0, start) + label + sliceByColumn(line, end, Math.max(0, visibleWidth(line) - end))
|
|
50
|
+
+ trailing + "\x1b]8;;\x07\x1b[0m";
|
|
51
|
+
return result;
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}
|
package/lib/minimal-output.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { stripVTControlCharacters } from "node:util";
|
|
|
4
4
|
import { agentCallDisplay, isAgentTool, liveAgentView, runningGlyph } from "./agent-view.ts";
|
|
5
5
|
import { createAssistantImages, imagePlaceholders } from "./assistant-images.ts";
|
|
6
6
|
import { linkToolFiles } from "./file-links.ts";
|
|
7
|
+
import { createLinkHover } from "./link-hover.ts";
|
|
7
8
|
import { diagramMarkdown, isFencedMarkdown, renderMinimalMarkdown } from "./minimal-markdown.ts";
|
|
8
9
|
import { minimalSurface, paintExpandedHeading } from "./minimal-theme.ts";
|
|
9
10
|
import { formatElapsed, formatThinkingElapsed, formatToolElapsed, piLoopSummary, type MinimalTurn } from "./minimal-turns.ts";
|
|
@@ -46,9 +47,13 @@ export function minimalOutputComponent(theme: ExtensionContext["ui"]["theme"], g
|
|
|
46
47
|
let pinnedSubagentId: string | undefined;
|
|
47
48
|
let pinnedSubagent: { id: string; y: number; line: string; autoScroll?: boolean } | undefined;
|
|
48
49
|
let toolControls: Array<{ id: string; y: number; width: number; title: string }> = [];
|
|
50
|
+
let processRows: Array<{ key: string; y: number }> = [];
|
|
51
|
+
let hoveredProcess: { key: string; y: number } | undefined;
|
|
52
|
+
let hoverWidth = 0;
|
|
49
53
|
let agentControls: Array<{ index: number; y: number; width: number }> = [];
|
|
50
54
|
let hoveredTool: typeof toolControls[number] | undefined;
|
|
51
|
-
const
|
|
55
|
+
const linkHover = createLinkHover(text => paintExpandedHeading(theme, text));
|
|
56
|
+
const clearHover = () => { const changed = !!hoveredTool || hoveredProcess !== undefined; hoveredTool = undefined; hoveredProcess = undefined; return linkHover.clear() || changed; };
|
|
52
57
|
const toggleTool = (id: string) => {
|
|
53
58
|
if (id.startsWith("thinking:")) {
|
|
54
59
|
const present = getTurns().some((turn, turnIndex) => turn.process.some((entry, processIndex) =>
|
|
@@ -123,9 +128,12 @@ export function minimalOutputComponent(theme: ExtensionContext["ui"]["theme"], g
|
|
|
123
128
|
handleMouse(event: TuiMouseEvent) {
|
|
124
129
|
const tool = toolControls.find(control => event.y === control.y && event.x >= 2 && event.x < Math.min(5, control.width));
|
|
125
130
|
if (event.type === "move") {
|
|
131
|
+
const linkChanged = linkHover.handleMouse(event);
|
|
126
132
|
const next = !event.shift && !event.ctrl && !event.alt ? tool : undefined;
|
|
127
|
-
|
|
133
|
+
const record = processRows.find(row => row.y === event.y);
|
|
134
|
+
if (hoveredTool?.id !== next?.id || hoveredProcess?.key !== record?.key || hoveredProcess?.y !== record?.y || linkChanged) {
|
|
128
135
|
hoveredTool = next;
|
|
136
|
+
hoveredProcess = record;
|
|
129
137
|
return { handled: true, render: true };
|
|
130
138
|
}
|
|
131
139
|
return;
|
|
@@ -171,8 +179,11 @@ export function minimalOutputComponent(theme: ExtensionContext["ui"]["theme"], g
|
|
|
171
179
|
return region?.rows.handleMouse?.({ ...event, y: event.y - region.y });
|
|
172
180
|
},
|
|
173
181
|
render(width: number, notices?: TurnNotices): string[] {
|
|
182
|
+
if (width !== hoverWidth) clearHover();
|
|
183
|
+
hoverWidth = width;
|
|
174
184
|
promptControls = [];
|
|
175
185
|
toolControls = [];
|
|
186
|
+
processRows = [];
|
|
176
187
|
agentControls = [];
|
|
177
188
|
pinnedTool = undefined;
|
|
178
189
|
pinnedAgent = undefined;
|
|
@@ -180,7 +191,7 @@ export function minimalOutputComponent(theme: ExtensionContext["ui"]["theme"], g
|
|
|
180
191
|
subagentControls = [];
|
|
181
192
|
noticeRegions = [];
|
|
182
193
|
agentExpiry = Infinity;
|
|
183
|
-
if (width <= 0) { clearHover(); return []; }
|
|
194
|
+
if (width <= 0) { clearHover(); return linkHover.render([], width); }
|
|
184
195
|
const turns = getTurns();
|
|
185
196
|
const toolIds = new Set(turns.flatMap(turn => (turn.agentCalls ?? []).map(call => call.id)));
|
|
186
197
|
for (const id of expandedTools) if (!toolIds.has(id)) expandedTools.delete(id);
|
|
@@ -279,6 +290,7 @@ export function minimalOutputComponent(theme: ExtensionContext["ui"]["theme"], g
|
|
|
279
290
|
? left + " ".repeat(width - visibleWidth(left) - visibleWidth(totals)) + totals
|
|
280
291
|
: truncateToWidth(left, width));
|
|
281
292
|
shown.forEach((entry, row) => {
|
|
293
|
+
processRows.push({ key: entry.id || `${index}:${entry.processIndex}`, y: lines.length });
|
|
282
294
|
const title = entry.title;
|
|
283
295
|
const text = title.split(/\r?\n/).find(line => line.trim())?.replace(/\s+/g, " ").trim() ?? "";
|
|
284
296
|
const split = text.indexOf(" ");
|
|
@@ -384,8 +396,16 @@ export function minimalOutputComponent(theme: ExtensionContext["ui"]["theme"], g
|
|
|
384
396
|
lines.push(...noticeRows);
|
|
385
397
|
}
|
|
386
398
|
if (hoveredTool && !toolControls.some(control => control.id === hoveredTool!.id)) clearHover();
|
|
399
|
+
if (hoveredProcess && !processRows.some(row => row.key === hoveredProcess!.key && row.y === hoveredProcess!.y)) clearHover();
|
|
387
400
|
for (const deadline of agentDeadlines.values()) if (deadline > Date.now()) agentExpiry = Math.min(agentExpiry, deadline);
|
|
388
|
-
|
|
401
|
+
const linkedRows = linkHover.render(lines, width);
|
|
402
|
+
const hovered = hoveredProcess;
|
|
403
|
+
const hoveredRow = hovered && processRows.find(row => row.key === hovered.key && row.y === hovered.y);
|
|
404
|
+
if (!hoveredRow) return linkedRows;
|
|
405
|
+
const result = [...linkedRows];
|
|
406
|
+
const line = result[hoveredRow.y];
|
|
407
|
+
result[hoveredRow.y] = paintExpandedHeading(theme, line + " ".repeat(Math.max(0, width - visibleWidth(line))));
|
|
408
|
+
return result;
|
|
389
409
|
},
|
|
390
410
|
};
|
|
391
411
|
}
|
package/package.json
CHANGED