pi-pretty-tui 0.3.0 → 0.3.2
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 +41 -87
- package/README.zh-CN.md +40 -86
- package/assets/screenshot.png +0 -0
- package/extensions/full-frame.ts +16 -5
- package/extensions/index.ts +192 -87
- package/extensions/markdown-emphasis.ts +87 -0
- package/extensions/markdown-spacing.ts +123 -0
- package/extensions/selection-ranges.ts +245 -0
- package/extensions/tool-presentation.ts +8 -2
- package/package.json +10 -4
package/README.md
CHANGED
|
@@ -2,18 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
English | [简体中文](./README.zh-CN.md)
|
|
4
4
|
|
|
5
|
-
A
|
|
5
|
+
A cleaner, theme-aware interface for the [Pi coding agent](https://pi.dev/), with collapsible tools and thoughts, rounded message cards, and convenient copying.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
- **Collapsible activity timeline:** instead of filling the conversation with individual calls, thoughts, tools, and ordinary `info` notifications share one chronological activity stream. Work appears beneath a single `Running(...)` row and settles into a quiet `Done(...)` row. Parent rows show a combined total of top-level and nested tool calls, plus thoughts; expanding one reveals every ordered member with summaries retained above nested details. Thoughts and tools are peers: a turn that calls no tool still gets its own `Running(1 thought)` / `Done(1 thought)` parent row with the Thought as its child, so thinking is never dropped.
|
|
10
|
-
- **Live working duration:** in all three modes, elapsed time appears beside `Working` in the prompt editor's top border, using the border's own color. It shares the agent-run clock and duration format with the completion footer, includes automatic retries, and disappears when the run settles. Narrow editors omit the timer when it cannot fit. The clean-mode `Running` parent dot alternates between the prompt editor’s current border color and `dim` about every 800 ms; its label uses that same border color, and tool dots stay stable, and the pulse stops when the run settles. Expanded `Done` titles and markers use the theme's `success` color; collapsed summary dots, titles, and details use `dim`.
|
|
11
|
-
- **Transient UI status:** one line above the editor shows direct Pi UI feedback such as Thinking/tool-output visibility changes. A newer UI status replaces it, and it disappears automatically after ten seconds without entering the transcript or session.
|
|
12
|
-
- **Durable response footers:** once the complete agent run settles—including tools, retries, and compaction—the final answer ends with one quiet gray divider containing the elapsed-work time and, in fullscreen, a `[Copy]` control. It copies only the final visible answer, excluding thoughts, tools, statuses, and the footer itself; the footer survives reloads and session-tree navigation.
|
|
13
|
-
- **Useful details on demand:** tool-aware summaries keep paths, commands, results, diffs, file previews, and live shell output concise without removing access to the original content.
|
|
14
|
-
- **A cohesive visual finish:** user messages use a rounded border in the theme's heading color (`mdHeading`, warm amber in the default theme), distinct from blue `mdLink` thoughts. Full and compact use background-filled, full-width `User` panels matching Assistant cards. Clean keeps transparent, right-aligned, content-sized bubbles, wrapping long messages at 75% of the terminal width without a `User` label. Together with the rounded prompt input, theme-aware colors, clear Markdown heading hierarchy, cleaner lists, and rounded syntax-highlighted code blocks, they make the entire TUI feel intentional. In fullscreen, each fenced code block also includes a native-feeling `[Copy]` control.
|
|
15
|
-
|
|
16
|
-
Clean uses purpose-built compact views for Pi's built-in `read`, `bash`, `edit`, `write`, `grep`, `find`, and `ls` tools. Compact uses concise summaries when folded and the same native detail cards as full when expanded. Third-party tools without nested calls automatically receive a consistent compact row; opening it preserves its native renderer while removing conflicting terminal background colors. User and steering messages, compaction summaries, visible assistant text, warnings, errors, aborted/truncated responses, and displayed custom messages with a registered renderer create hard group boundaries. Pi's cursor, IME, autocomplete, and tool execution behavior remain intact; fullscreen mouse additions are described below.
|
|
7
|
+

|
|
17
8
|
|
|
18
9
|
## Install
|
|
19
10
|
|
|
@@ -21,102 +12,65 @@ Clean uses purpose-built compact views for Pi's built-in `read`, `bash`, `edit`,
|
|
|
21
12
|
pi install npm:pi-pretty-tui
|
|
22
13
|
```
|
|
23
14
|
|
|
24
|
-
Restart Pi or run `/reload
|
|
25
|
-
|
|
26
|
-
Pi may warn that built-in tools are being overridden. This is expected: pi-pretty-tui re-registers Pi's built-in tools and delegates execution to their original implementations, changing only their TUI renderers.
|
|
27
|
-
|
|
28
|
-
## Working with tool calls
|
|
29
|
-
|
|
30
|
-
Click a `Running(...)` or `Done(...)` row to keep it as a parent and reveal tools, completed `● thought` entries, and extension updates beneath it. Click an individual tool or thought to reveal nested details without replacing its summary. The last item in each expanded tree, `└─ [↑ Collapse]`, collapses just that group without scrolling back to its parent; clicking the parent also works. In clean mode, `Ctrl+O` only shows a hint to use these local disclosures; it does not expand or collapse content. Full and compact modes retain Pi's native global tool-output expansion. Third-party replacements for `grep` and `find` (such as FFF) use compact tree rows too, with their native details available when expanded. Compact tool names use bold `text`, parameters use `muted`, and running tool dots use `dim`; success/error dots keep their corresponding theme colors. Thought dots use `mdLink`, titles use bold `text`, and detail body text uses `muted`. Tool names use each definition's `label` verbatim, falling back to its raw `name`; pi-pretty-tui does not rename or title-case them.
|
|
31
|
-
|
|
32
|
-
In clean and compact, extension calls to `ctx.ui.notify(message, "info")` (or with the type omitted) use the same presentation. Clean joins them to current thought/tool work, while compact displays them independently. Warnings and errors stay standalone, use `⚠` and `✕`, and form hard boundaries. Tool failures remain owned by their tool details. Full delegates info, warning, and error delivery to Pi's original methods, retaining its message text, individual occurrences, and status behavior.
|
|
33
|
-
|
|
34
|
-
In clean mode, Pi's native cache-miss notices join the thought/tool group of the assistant message that incurred the miss, as a yellow `⚠` child. They hide and reveal with the group and do not interrupt subsequent tool calls. If that message has no associated work (for example, a text-only final answer), the notice remains independent. Pi still decides whether a notice should appear and formats its token count, cost, model-switch and idle-gap labels; the integration hooks `addCacheMissNotice()` rather than matching text. Historical notices are re-derived on rebuild, not written as extra session entries. Full and compact show the same warning independently, without an activity-group wrapper.
|
|
35
|
-
|
|
36
|
-
In clean and compact, displayed custom messages without their own renderer use one generic accent-coloured `◇` Markdown presentation: they join current thought/tool work when it exists, otherwise remain independent, and preserve their session persistence. Messages with a registered renderer remain completely native and form hard boundaries. Full retains native custom-message rendering as well. These decisions use only Pi's notification type and renderer presence—never extension names, custom message names, or content heuristics.
|
|
37
|
-
|
|
38
|
-
In clean and compact, Pi's direct internal `showStatus()` feedback is transient: it appears only in the status line above the editor, a newer status replaces it, and a ten-second timer removes it. It never enters the transcript or activity timeline and is cleared on reload. In clean mode, `Ctrl+T` and `Ctrl+O` only show short hints to click the corresponding disclosure; neither changes visibility or Pi's Thinking setting. In full and compact modes, both shortcuts keep Pi's native behaviour. Full also preserves native `showStatus()` delivery instead of removing transcript feedback on a ten-second timer.
|
|
39
|
-
|
|
40
|
-
Visible assistant text remains outside activity trees even when a later update to the same message introduces thinking. Repeated updates do not close a separate, subsequent tool group.
|
|
41
|
-
|
|
42
|
-
`read` range labels accept numeric strings and omitted/null fields without concatenating line numbers; malformed range values omit the label. Expanded `edit` diffs use a fixed, right-aligned line-number gutter followed by a separate `+`/`-` column. Wrapped code aligns with the content column, preserving code indentation and theme diff colors.
|
|
43
|
-
|
|
44
|
-
## Error presentation
|
|
45
|
-
|
|
46
|
-
In clean and compact modes, standalone errors keep their original title and complete text in a compact `✕ Error · reason` layout. Consecutive errors with exactly the same source type, title, and full text share one visible row with a dim `×2` / `×3` count. Other transcript components break the run; errors carrying thought/tool/visible-response content are not folded. This is UI-only: session records and original message components remain unchanged. Long errors wrap without an added preview truncation. Full mode keeps native assistant error text and individual occurrences; it does not merge errors into a repetition count.
|
|
47
|
-
|
|
48
|
-
## Codemode and nested tools
|
|
49
|
-
|
|
50
|
-
Clean and compact modes share the same nested-tool presentation. Tools that call other tools through Pi's nested execution API keep their own parent node. In clean mode, expand the activity group first; in compact mode, each parent appears independently without an activity-group wrapper. Both show each internal call, its status, compact arguments, duration, and result summary. Click an internal call to inspect its arguments and text result independently. Click its expanded body to collapse just that call. Script and script-output bodies also collapse their own sections when clicked. Tool calls use a `●` marker: dim while running, success-colored when successful, and error-colored when failed. Tool names use bold theme text. `[Script]` and `[Script output]` are separate disclosures; the nested parent title is informational and clicking it does not expand or collapse details. Use each section or child to expand and collapse its own details; `Ctrl+O` only shows a hint in clean mode. Extensions can still use Pi's `setToolsExpanded()` API for global control; local disclosures remain usable afterward, and another global API call resets the local overrides. Calls retain their start order even when they finish in parallel. A handled child failure remains marked as failed even if the script succeeds.
|
|
15
|
+
Restart Pi or run `/reload`.
|
|
51
16
|
|
|
52
|
-
|
|
17
|
+
## Rendering modes
|
|
53
18
|
|
|
54
|
-
|
|
19
|
+
Run `/pretty-tui` to open settings and choose a mode:
|
|
55
20
|
|
|
56
|
-
|
|
21
|
+
| Mode | Experience |
|
|
22
|
+
|---|---|
|
|
23
|
+
| **clean** (default) | Group tools and thoughts into a collapsible `Running` / `Done` timeline. |
|
|
24
|
+
| **compact** | Show separate tool and thought cards with concise previews; expand for details. |
|
|
25
|
+
| **full** | Keep Pi's native details and interactions inside themed cards, with thoughts initially expanded. |
|
|
57
26
|
|
|
58
|
-
|
|
27
|
+
All modes include rounded messages and code blocks, syntax highlighting, a live working timer, and final-answer duration and copy controls. Clean and compact also support expandable nested-tool trees.
|
|
59
28
|
|
|
60
|
-
|
|
29
|
+
Click activity rows, tool titles or thought entries to expand and collapse details. In clean, use these local controls; in compact and full, Pi's `Ctrl+O` and `Ctrl+T` shortcuts remain available.
|
|
61
30
|
|
|
62
|
-
|
|
31
|
+
| Command | Action |
|
|
32
|
+
|---|---|
|
|
33
|
+
| `/pretty-tui clean` | Switch to clean mode |
|
|
34
|
+
| `/pretty-tui compact` | Switch to compact mode |
|
|
35
|
+
| `/pretty-tui full` | Switch to full mode |
|
|
36
|
+
| `/pretty-tui enable` / `/pretty-tui disable` | Enable or disable the extension and reload |
|
|
37
|
+
| `/pretty-tui status` | Show current settings |
|
|
63
38
|
|
|
64
|
-
|
|
39
|
+
Settings persist across sessions. Disabling the extension restores Pi's native appearance.
|
|
65
40
|
|
|
66
|
-
|
|
41
|
+
## Copying
|
|
67
42
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
Built-in tools use Pi's original renderers, including previews, truncation/expansion controls and error details. Full-mode bash commands additionally use Pi's shell syntax highlighter for variables, strings, keywords and comments. Highlighting is cached by command and syntax palette; the native `$` prompt, original command text, timeout annotation and result output are preserved. Shell/codemode `Took`/`Elapsed` timing lives on the bottom border in the outline color; narrow panels keep native timing in the body when it cannot fit. Third-party renderers, media and native mouse handlers remain intact. Clean retains its activity grouping and transparent user bubbles. Compact shares the same panel surfaces, outline colors, gutter and User/Assistant cards, but defaults to concise tool parameters and result summaries. Standalone tool panel titles show `▸` when collapsed and `▾` when expanded. Click the title to toggle details, and use native `Ctrl+O` for global expansion. User/Assistant panels and informational nested-parent titles have no disclosure arrow. Expanded standalone tools use the same native renderer and panel projection as full, including shell highlighting, output boundaries and native timing, without compact tree connectors or result indentation. Nested wrappers retain independent script/output/child disclosures. Compact records `Took` on the border when a final duration is supplied by Pi; it does not invent missing timings. Extremely narrow terminals omit the outline while retaining the panel background.
|
|
71
|
-
|
|
72
|
-
The extension supports three persistent rendering modes: `clean` (default), `compact`, and `full`. Choose one interactively, or use `/pretty-tui clean`, `/pretty-tui compact`, `/pretty-tui full`, and `/pretty-tui status` directly. Settings are stored in `~/.pi/agent/pretty-tui.json` or under the directory selected by `PI_CODING_AGENT_DIR`.
|
|
73
|
-
|
|
74
|
-
| Mode | Third-party tools | Codemode and other nested callers |
|
|
75
|
-
|---|---|---|
|
|
76
|
-
| `clean` | Compact summaries inside activity groups; native details on expansion | Nested tree inside the group, with local disclosures |
|
|
77
|
-
| `compact` | Concise independent panels; title toggles native details | Independent panel with parent/child tree and local script/output/child disclosures |
|
|
78
|
-
| `full` | Native content and interactions in a titled card | Native codemode content and disclosures in a titled card; no added snapshot-only details |
|
|
79
|
-
|
|
80
|
-
Full and compact keep Pi's native `Ctrl+O` global expansion. Shared projected rows preserve local controls afterward. These modes do not create clean-mode `Running/Done` activity wrappers.
|
|
81
|
-
|
|
82
|
-
In fullscreen, interactive activity/tool rows and copy controls tolerate same-row horizontal pointer jitter of up to two terminal columns. Larger or vertical movement remains a drag; ordinary text selection, links, and Pi's double/triple-click behavior are unchanged.
|
|
83
|
-
|
|
84
|
-
In compact and full, compaction summaries use a theme-colored `compaction ▸/▾` card. The original token count, shortcut hint and complete summary remain available; click the title/body or use native `Ctrl+O` to toggle expansion. Compaction cost notices remain separate. Clean retains Pi’s original compaction box.
|
|
85
|
-
|
|
86
|
-
## Copy user messages
|
|
87
|
-
|
|
88
|
-
In fullscreen mode, left-click a user bubble's body or border to copy its complete original text, preserving Markdown, indentation, and line breaks without the bubble frame. Existing links and code-block `[Copy]` controls retain priority; dragging to select text does not trigger whole-message copy. Pi's native clipboard path provides copy feedback. This copies text, not image attachments. Regular mode keeps terminal-owned mouse selection and copying.
|
|
89
|
-
|
|
90
|
-
## Copy code blocks
|
|
91
|
-
|
|
92
|
-
Rounded code-block lines and corners use `borderMuted`; language labels, `[Copy]`, and code text retain their existing colors.
|
|
93
|
-
|
|
94
|
-
In fullscreen TUI mode, fenced Markdown code blocks in user and assistant transcript messages include a clickable `[Copy]` control in the top rule:
|
|
43
|
+
Start Pi in **fullscreen mode** to use mouse controls:
|
|
95
44
|
|
|
96
45
|
```sh
|
|
97
46
|
pi --tui-mode fullscreen
|
|
98
47
|
```
|
|
99
48
|
|
|
100
|
-
|
|
49
|
+
- **User message:** click its body or border to copy the original text.
|
|
50
|
+
- **Code block:** click `[Copy]` to copy the code without its frame.
|
|
51
|
+
- **Final answer:** click `[Copy]` beside the response duration to copy the answer without thoughts or tool output.
|
|
101
52
|
|
|
102
|
-
|
|
53
|
+
Dragging selects text rather than copying a whole message. Links keep their normal behavior; image attachments are not included in text copies.
|
|
103
54
|
|
|
104
|
-
|
|
55
|
+
### Optional border-free selection
|
|
105
56
|
|
|
106
|
-
|
|
107
|
-
npm install
|
|
108
|
-
npm test
|
|
109
|
-
```
|
|
57
|
+
Enable **Selection copy** in `/pretty-tui`, or run:
|
|
110
58
|
|
|
111
|
-
|
|
59
|
+
```text
|
|
60
|
+
/pretty-tui selection-copy on
|
|
61
|
+
/pretty-tui selection-copy off
|
|
62
|
+
```
|
|
112
63
|
|
|
113
|
-
|
|
64
|
+
This experimental option is **off by default**. In fullscreen mode, it removes UI borders, titles and layout padding from copied selections while preserving literal box-drawing characters in the content. It works in all three rendering modes; toggling it saves the setting and reloads Pi.
|
|
114
65
|
|
|
115
|
-
|
|
66
|
+
In regular mode, the terminal handles selection and copying, so this option has no border-removal effect. Fullscreen/regular is independent of clean/compact/full.
|
|
116
67
|
|
|
117
|
-
|
|
68
|
+
## Notes
|
|
118
69
|
|
|
119
|
-
|
|
70
|
+
- Tested with **Pi 1.5.0**. Future Pi updates may require compatibility fixes.
|
|
71
|
+
- Keeps Pi's native input behavior and tool execution, including third-party tool implementations.
|
|
72
|
+
- Nested-tool text details are saved with sessions for restoration and may be truncated. Session files can contain sensitive tool output.
|
|
73
|
+
- See [Releases](https://github.com/ykn0309/pi-pretty-tui/releases) for changes and contributor acknowledgments.
|
|
120
74
|
|
|
121
75
|
## Uninstall
|
|
122
76
|
|
|
@@ -124,8 +78,8 @@ No Pi source files are modified. Runtime patches are removed during session shut
|
|
|
124
78
|
pi remove npm:pi-pretty-tui
|
|
125
79
|
```
|
|
126
80
|
|
|
127
|
-
|
|
81
|
+
Restart Pi afterward.
|
|
128
82
|
|
|
129
83
|
## License
|
|
130
84
|
|
|
131
|
-
MIT
|
|
85
|
+
[MIT](./LICENSE)
|
package/README.zh-CN.md
CHANGED
|
@@ -2,18 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
[English](./README.md) | 简体中文
|
|
4
4
|
|
|
5
|
-
为 [Pi coding agent](https://pi.dev/)
|
|
5
|
+
为 [Pi coding agent](https://pi.dev/) 提供更清爽的界面:可折叠的工具与思考、跟随主题的圆角卡片,以及便捷的复制操作。
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
- **可折叠的活动时间线:** 不再让大量独立调用填满对话。思考、工具和普通 `info` 通知会进入同一条按真实时间排序的活动流;工作进行时显示为 `Running(...)`,结束后变为低调的 `Done(...)`。父级合并统计顶层与嵌套工具调用总数,并单独显示思考数量;展开后可查看所有有序成员,成员摘要在展开嵌套详情后仍然保留。思考与工具地位相同:没有调用任何工具的那一轮同样会有自己的 `Running(1 thought)` / `Done(1 thought)` 父行,思考作为其子级,内容不会被丢弃。
|
|
10
|
-
- **可持久化的回答 footer:** 整轮 Agent 工作真正 settled 后(包括工具、自动重试和 compaction),最终回答底部会显示一条低调的灰色分隔线,工作时长与 fullscreen 模式下的 `[Copy]` 控件都嵌在线中。`[Copy]` 只复制最终可见回答,不包含 thought、工具、状态或 footer;reload 和 session tree 切换后仍会保留。
|
|
11
|
-
- **实时工作计时:** 三种模式下,耗时显示在输入框顶部边框的 `Working` 右侧,颜色与边框一致。它与完成 footer 共用 Agent 整轮工作的计时起点和时长格式,包含自动重试,工作真正结束后消失;窄输入框放不下时会隐藏计时。clean 模式下,`Running` 父节点圆点约每 800 ms 在输入框当前边框色和 `dim` 间切换;`Running` 文字使用相同边框色,工具圆点保持稳定,整轮结束后停止闪烁。展开后的 `Done` 标题和圆点使用主题的 `success` 色,折叠摘要的圆点、标题与内容统一使用 `dim`。
|
|
12
|
-
- **临时 UI 状态:** 编辑器上方的一行只显示 Pi 直接产生的 UI 操作反馈,例如 Thinking 或工具输出可见性变化。新状态会替换旧状态,并在十秒后自动消失,不进入 transcript 或 session。
|
|
13
|
-
- **按需查看有效信息:** 针对不同工具设计的摘要,会简洁呈现路径、命令、结果、diff、文件预览和实时 shell 输出,同时保留查看原始完整内容的能力。
|
|
14
|
-
- **统一、精致的视觉体验:** 用户消息使用主题标题色(`mdHeading`,默认暖黄/琥珀色)的圆角边框,与蓝色 `mdLink` 思考区分。full 和 compact 使用带底色、铺满宽度的 `User` 面板,与 Assistant 卡片一致;clean 保留透明、右对齐、自适应宽度的气泡,长消息在终端宽度的 75% 处换行,不显示 `User` 标注。配合圆角输入框、主题感知配色、层级清晰的 Markdown 标题、更清爽的列表,以及带语法高亮的圆角代码块,让整个 TUI 更协调。在 fullscreen 模式下,每个围栏代码块还带有符合原生体验的 `[Copy]` 控件。
|
|
15
|
-
|
|
16
|
-
clean 中,Pi 内置的 `read`、`bash`、`edit`、`write`、`grep`、`find` 和 `ls` 工具使用专门设计的紧凑视图;compact 折叠时显示简短摘要,展开后与 full 共用原生详情卡片。没有嵌套调用的第三方工具会自动获得统一的紧凑行,单独展开时继续使用原生 renderer,但会移除与整体冲突的终端背景色。用户与 steer 消息、compaction 摘要、可见 assistant 正文、warning、error、aborted/length 响应,以及注册了专用 renderer 的 displayed custom message 都会形成硬分组边界。同时不会影响 Pi 原有的光标、输入法、自动补全和工具执行行为;fullscreen 鼠标交互增强见下文。
|
|
7
|
+

|
|
17
8
|
|
|
18
9
|
## 安装
|
|
19
10
|
|
|
@@ -23,100 +14,63 @@ pi install npm:pi-pretty-tui
|
|
|
23
14
|
|
|
24
15
|
安装后重启 Pi,或运行 `/reload`。
|
|
25
16
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
## 使用工具调用
|
|
29
|
-
|
|
30
|
-
点击 `Running(...)` 或 `Done(...)` 行,可以保留父级并展开其下方的工具、已完成的 `● thought` 和扩展更新。点击单个工具或思考子项可在保留摘要的同时展开嵌套详情。每棵展开的树末尾都有 `└─ [↑ Collapse]`,无需滚回父级即可只折叠当前分组;再次点击父级也可以折叠。clean 模式下,`Ctrl+O` 只提示使用这些局部展开入口,不会展开或收起内容;full 和 compact 模式保留 Pi 原生的工具输出全局展开行为。第三方替换的 `grep`、`find`(如 FFF)也使用紧凑的树节点,展开子项时仍可查看原生详情。紧凑工具名使用 `text` 加粗,参数使用 `muted`,运行中工具圆点使用 `dim`,成功/失败圆点保留对应主题色。思考圆点使用 `mdLink`,标题使用 `text` 加粗,详情正文使用 `muted`。工具名称会原样使用定义中的 `label`,没有 `label` 时回退到原始 `name`;pi-pretty-tui 不再重命名或转换大小写。
|
|
31
|
-
|
|
32
|
-
clean 和 compact 中,扩展调用 `ctx.ui.notify(message, "info")`(或省略 type)使用相同展示:clean 加入当前 thought/tool 活动组,compact 独立显示。warning 和 error 保持独立,使用 `⚠` 和 `✕` 并形成硬边界;工具失败归属于对应工具详情。full 将 info、warning、error 的投递委托给 Pi 原始方法,保留其文案、每次独立出现及状态行为。
|
|
33
|
-
|
|
34
|
-
在 clean 模式下,Pi 原生的 cache miss 提示以黄色 `⚠` 子节点加入产生该次缓存未命中的 assistant 消息所属的 thought/tool 活动组,随组折叠与展开,并且不会打断后续工具调用。如果该消息没有关联的工作(例如只输出正文的最终回答),提示保持独立。是否显示提示,以及 token 数、成本、模型切换和空闲时长等文案仍由 Pi 决定;接管的是 `addCacheMissNotice()` 入口,不匹配文本。历史提示在重建时重新推导,不额外写入会话记录。full 和 compact 使用相同的警告展示,独立显示,不包裹活动组。
|
|
35
|
-
|
|
36
|
-
clean 和 compact 下,没有自有 renderer 的 displayed custom message 使用统一、accent 配色的 `◇` Markdown 显示:当前存在 thought/tool 工作时加入当前组,否则独立显示,并保留 session 持久化。注册了 renderer 的消息完全保留插件原生显示并形成硬边界。full 同样保留 custom message 的原生展示。所有判断只依据 Pi 的通知 type 和 renderer 是否存在,不识别扩展名称、custom message 名称,也不根据文本内容推断语义。
|
|
37
|
-
|
|
38
|
-
clean 和 compact 中,Pi 内部直接调用 `showStatus()` 产生的反馈属于临时 UI 状态:它只显示在编辑器上方,新状态替换旧状态,并由十秒 timer 自动清除;它不会进入 transcript 或活动时间线,reload 时也会清除。在 clean 模式下,`Ctrl+T` 和 `Ctrl+O` 都只显示点击对应节点的简短提示,不改变内容可见性或 Pi 的 Thinking 设置。在 full 和 compact 模式下,两者保留 Pi 的原生行为。full 也保留原生 `showStatus()` 投递,不使用十秒 timer 删除 transcript 中的状态反馈。
|
|
39
|
-
|
|
40
|
-
即使同一消息的后续更新才加入思考,可见 assistant 正文也保持在活动树之外;重复更新不会关闭后续独立的工具活动组。
|
|
41
|
-
|
|
42
|
-
`read` 行范围标签正确处理数字字符串及省略/null 参数,不再拼接出错误行号;无效范围值不显示范围标签。展开的 `edit` diff 使用固定宽度、右对齐的左侧行号栏,`+`/`-` 独占一列;长代码续行与正文列对齐,保留代码缩进及主题 diff 配色。
|
|
43
|
-
|
|
44
|
-
## 错误展示
|
|
45
|
-
|
|
46
|
-
clean 和 compact 模式下,独立错误保留原始标题和完整内容,以紧凑的 `✕ Error · 原因` 展示。来源类型、标题及完整内容完全一致的相邻错误合为一条可见行,并使用暗色 `×2` / `×3` 标识次数。其他 transcript 组件会打断计数;包含思考、工具或可见回答的错误不参与合并。合并仅影响 UI,不删除或修改会话记录及原始消息组件。长错误完整换行,不增加预览截断;full 保留原生 assistant 错误文案及每次独立出现,不将它们合并为重复计数。
|
|
47
|
-
|
|
48
|
-
## Codemode 与嵌套工具
|
|
49
|
-
|
|
50
|
-
clean 和 compact 模式共用嵌套工具展示。通过 Pi 嵌套执行 API 调用其他工具的工具保留自己的父节点;clean 模式先展开活动组,compact 模式直接显示独立的父子调用树,不包裹活动组。两者都会显示各内部调用的状态、紧凑参数、耗时和结果摘要;点击某个内部调用,可以独立展开其参数和文本结果;点击展开后的正文可收起该调用,脚本和脚本输出正文也可点击收起各自区块。工具统一使用 `●` 圆点:运行中为主题暗色,成功与失败分别为主题成功色与错误色;工具名使用正文色加粗。`[Script]` 和 `[Script output]` 分别控制脚本与汇总输出;嵌套父工具标题仅用于展示,点击不会展开或折叠详情。各区块或子调用通过自己的入口独立展开/收起,`Ctrl+O` 在 clean 模式下只显示提示。扩展仍可通过 Pi 的 `setToolsExpanded()` API 全局控制,之后也可局部展开/收起;再次调用全局 API 会重置局部状态。并行调用按照启动顺序排列,不会随完成顺序跳动。即使脚本捕获错误后成功,失败的子调用仍会明确标记。
|
|
51
|
-
|
|
52
|
-
活动组摘要合并统计顶层与嵌套调用:一个父调用加三个内部调用显示为 `4 tool calls`,父调用本身也计一次;父工具节点仍保留子调用数量和树结构。内部调用不会变成不存在的顶层 transcript 成员,也不会挤掉树尾折叠按钮。归属依据 Pi 的 `parentToolCallId`,不依赖工具名或 JavaScript 源码解析,因此其他嵌套调用工具也适用。这需要支持嵌套执行事件的 Pi(0.99.0 及以后);旧版本保持原有显示。full 在工具卡片内使用 codemode 自己的原生 renderer,不额外追加 pretty-tui 快照中保存的子调用详情;可见信息、展开折叠及快捷键行为跟随 Pi。clean 和 compact 共用嵌套执行状态、历史快照、状态处理与子项局部展开逻辑;全局展开操作会重置它们的局部覆盖。
|
|
17
|
+
## 展示模式
|
|
53
18
|
|
|
54
|
-
|
|
19
|
+
运行 `/pretty-tui` 打开设置,选择模式:
|
|
55
20
|
|
|
56
|
-
|
|
21
|
+
| 模式 | 展示方式 |
|
|
22
|
+
|---|---|
|
|
23
|
+
| **clean**(默认) | 将工具与思考归入可折叠的 `Running` / `Done` 活动时间线。 |
|
|
24
|
+
| **compact** | 工具与思考分别显示为简洁卡片,展开查看详情。 |
|
|
25
|
+
| **full** | 在主题卡片中保留 Pi 原生详情与交互,思考默认展开。 |
|
|
57
26
|
|
|
58
|
-
|
|
27
|
+
三种模式均提供圆角消息与代码块、语法高亮、实时工作计时,以及回答末尾的耗时和复制入口。clean 和 compact 还支持展开查看嵌套工具调用。
|
|
59
28
|
|
|
60
|
-
|
|
29
|
+
点击活动行、工具标题或思考条目可展开、收起详情。clean 使用这些局部入口;compact 和 full 保留 Pi 的 `Ctrl+O`、`Ctrl+T` 快捷键。
|
|
61
30
|
|
|
62
|
-
|
|
31
|
+
| 命令 | 作用 |
|
|
32
|
+
|---|---|
|
|
33
|
+
| `/pretty-tui clean` | 切换到 clean |
|
|
34
|
+
| `/pretty-tui compact` | 切换到 compact |
|
|
35
|
+
| `/pretty-tui full` | 切换到 full |
|
|
36
|
+
| `/pretty-tui enable` / `/pretty-tui disable` | 启用或禁用插件,并自动重载 |
|
|
37
|
+
| `/pretty-tui status` | 查看当前设置 |
|
|
63
38
|
|
|
64
|
-
|
|
39
|
+
设置会持久保存。禁用插件后恢复 Pi 原生外观。
|
|
65
40
|
|
|
66
|
-
|
|
41
|
+
## 复制操作
|
|
67
42
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
内置工具使用 Pi 官方 renderer,保留预览、截断/展开入口及错误详情。full 模式的 bash 命令额外使用 Pi 的 shell 语法高亮,区分变量、字符串、关键字和注释,并按命令与语法配色缓存;原生 `$` 提示符、命令原文、超时标注和结果输出保持不变。shell/codemode 原生 `Took`/`Elapsed` 保留在底边框且与边框同色;窄面板放不下时保留原生正文计时。第三方 renderer、媒体数据和原生鼠标交互继续保留。clean 保留活动分组与透明用户气泡。compact 共用面板底色、边框配色、留白及 User/Assistant 卡片,工具默认只显示参数和结果摘要,独立工具卡片标题用 `▸` 表示折叠、`▾` 表示展开,点击标题切换详情,`Ctrl+O` 保留原生全局展开。User/Assistant 和仅用于展示的嵌套父工具标题不添加折叠箭头。独立工具展开后与 full 共用原生 renderer 和卡片投影,包括命令高亮、输出分界及原生耗时,不再带 compact 的树状连接线和结果缩进;嵌套工具保留脚本、输出和子项的局部展开。Pi 提供最终耗时时,compact 在边框显示 `Took`,缺失时不猜测。极窄终端省略边框但保留面板底色。
|
|
71
|
-
|
|
72
|
-
扩展支持三种可持久化的渲染模式:`clean`(默认)、`compact` 和 `full`。可交互选择,也可以直接使用 `/pretty-tui clean`、`/pretty-tui compact`、`/pretty-tui full` 和 `/pretty-tui status`。设置会保存到 `~/.pi/agent/pretty-tui.json`,或 `PI_CODING_AGENT_DIR` 指定目录中的对应位置。
|
|
73
|
-
|
|
74
|
-
| 模式 | 第三方工具 | codemode 等嵌套调用工具 |
|
|
75
|
-
|---|---|---|
|
|
76
|
-
| `clean` | 活动组中的紧凑摘要,展开查看原生详情 | 活动组内的嵌套树,各区块局部展开 |
|
|
77
|
-
| `compact` | 独立紧凑面板,点击标题查看原生详情 | 卡片内的独立父子树,脚本、输出及子项按需展开 |
|
|
78
|
-
| `full` | 原生内容与交互,外加标题卡片 | 标题卡片内的原生 codemode 内容与展开控件,不额外添加快照详情 |
|
|
79
|
-
|
|
80
|
-
full 和 compact 保留 Pi 原生的 `Ctrl+O` 全局展开,之后仍可局部控制共享展示中的各子项;这两种模式不生成 clean 的 `Running/Done` 活动组外壳。
|
|
81
|
-
|
|
82
|
-
fullscreen 模式下,活动树/工具交互行与复制入口允许同一行左右最多两个终端字符格的鼠标抖动;更大偏移或跨行移动仍按拖动处理。普通文本选择、链接和 Pi 的双击/三击行为保持不变。
|
|
83
|
-
|
|
84
|
-
compact 和 full 中,压缩摘要使用主题配色的 `compaction ▸/▾` 卡片,保留原始 token 数、快捷键提示和完整摘要;点击标题/正文或使用原生 `Ctrl+O` 切换展开。压缩费用提示仍独立显示,clean 保留 Pi 原生压缩消息样式。
|
|
85
|
-
|
|
86
|
-
## 复制用户消息
|
|
87
|
-
|
|
88
|
-
fullscreen 模式下,左键点击用户气泡的正文或边框,可复制完整原始文本,保留 Markdown、缩进和换行,不包含气泡边框。已有链接和代码块 `[Copy]` 控件保留优先级;拖动选择文本不会触发整条复制。复制使用 Pi 原生剪贴板路径及反馈,只复制文本,不复制图片附件。regular 模式保留终端自身的鼠标选择与复制行为。
|
|
89
|
-
|
|
90
|
-
## 复制代码块
|
|
91
|
-
|
|
92
|
-
代码块的圆角与线条使用 `borderMuted`,语言标签、`[Copy]` 和代码正文保持原有配色。
|
|
93
|
-
|
|
94
|
-
在 fullscreen TUI 模式下,用户消息与助手回复中的 Markdown 围栏代码块会在顶部边框显示可点击的 `[Copy]` 控件:
|
|
43
|
+
以 **fullscreen 全屏模式**启动 Pi,即可使用鼠标复制入口:
|
|
95
44
|
|
|
96
45
|
```sh
|
|
97
46
|
pi --tui-mode fullscreen
|
|
98
47
|
```
|
|
99
48
|
|
|
100
|
-
|
|
49
|
+
- **用户消息:** 点击正文或边框,复制原始文本。
|
|
50
|
+
- **代码块:** 点击 `[Copy]`,复制不含边框的代码。
|
|
51
|
+
- **最终回答:** 点击回答耗时旁的 `[Copy]`,复制不含思考和工具输出的回答。
|
|
101
52
|
|
|
102
|
-
|
|
53
|
+
拖动鼠标按选区处理,不触发整条消息复制。链接保留正常行为;文本复制不包含图片附件。
|
|
103
54
|
|
|
104
|
-
|
|
55
|
+
### 可选的无边框选区复制
|
|
105
56
|
|
|
106
|
-
|
|
107
|
-
npm install
|
|
108
|
-
npm test
|
|
109
|
-
```
|
|
57
|
+
在 `/pretty-tui` 中切换 **Selection copy**,或运行:
|
|
110
58
|
|
|
111
|
-
|
|
59
|
+
```text
|
|
60
|
+
/pretty-tui selection-copy on
|
|
61
|
+
/pretty-tui selection-copy off
|
|
62
|
+
```
|
|
112
63
|
|
|
113
|
-
|
|
64
|
+
这是**默认关闭的实验性选项**。在全屏模式下,复制鼠标选区时排除界面边框、标题和布局留白,保留正文里真实存在的框线字符。适用于三种展示模式,切换后保存设置并自动重载 Pi。
|
|
114
65
|
|
|
115
|
-
|
|
66
|
+
regular 非全屏模式由终端处理选择与复制,开启此选项也不会获得边框排除效果。fullscreen/regular 与 clean/compact/full 是两组独立设置。
|
|
116
67
|
|
|
117
|
-
|
|
68
|
+
## 必要说明
|
|
118
69
|
|
|
119
|
-
|
|
70
|
+
- 当前已在 **Pi 1.5.0** 上测试;未来 Pi 更新可能需要适配。
|
|
71
|
+
- 保留 Pi 原生输入行为和工具执行逻辑,包括第三方工具实现。
|
|
72
|
+
- 嵌套工具的文本详情会随会话保存以便恢复,内容可能截断;会话文件可能包含工具输出中的敏感信息。
|
|
73
|
+
- 版本变更与贡献者致谢见 [Releases](https://github.com/ykn0309/pi-pretty-tui/releases)。
|
|
120
74
|
|
|
121
75
|
## 卸载
|
|
122
76
|
|
|
@@ -124,8 +78,8 @@ npm test
|
|
|
124
78
|
pi remove npm:pi-pretty-tui
|
|
125
79
|
```
|
|
126
80
|
|
|
127
|
-
|
|
81
|
+
卸载后重启 Pi。
|
|
128
82
|
|
|
129
83
|
## 许可证
|
|
130
84
|
|
|
131
|
-
MIT
|
|
85
|
+
[MIT](./LICENSE)
|
package/assets/screenshot.png
CHANGED
|
Binary file
|
package/extensions/full-frame.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { selectableRow, selectionMetadataActive } from "./selection-ranges.js";
|
|
1
2
|
import { cardSurface } from "./card-surface.js";
|
|
2
3
|
import { isNativeImageRow, stripAnsiBackgrounds } from "./ansi-style.js";
|
|
3
4
|
import { stripTerminalSequences, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
@@ -44,7 +45,7 @@ function renderPanel(
|
|
|
44
45
|
): NativeFrame {
|
|
45
46
|
const palette = ["borderMuted", "text", "accent", "success", "error", titleColor, borderColor]
|
|
46
47
|
.map((role) => theme.fg(role, "x")).join("|") + (theme.bold?.("x") ?? "x") +
|
|
47
|
-
cardSurface(theme, borderColor, background).signature;
|
|
48
|
+
cardSurface(theme, borderColor, background).signature + selectionMetadataActive();
|
|
48
49
|
const sectionKey = titleColor + borderColor + footer + background + JSON.stringify([...sections]);
|
|
49
50
|
const cached = cacheOwner ? frameCache.get(cacheOwner) : undefined;
|
|
50
51
|
if (cached && cached.title === title && cached.width === width && cached.palette === palette && cached.sections === sectionKey &&
|
|
@@ -58,6 +59,7 @@ function renderPanel(
|
|
|
58
59
|
const border = (s: string) => theme.fg(borderColor, s);
|
|
59
60
|
const plainCaption = truncateToWidth(title, width - 6, "…");
|
|
60
61
|
const caption = theme.fg(titleColor, theme.bold?.(plainCaption) ?? plainCaption);
|
|
62
|
+
const copyRanges: Array<Array<[number, number]>> | undefined = selectionMetadataActive() ? [[]] : undefined;
|
|
61
63
|
const lines = [border("╭─ ") + caption + border(" " + "─".repeat(Math.max(0, width - visibleWidth(plainCaption) - 5)) + "╮")];
|
|
62
64
|
source.forEach((row, sourceY) => {
|
|
63
65
|
const section = sections.get(sourceY);
|
|
@@ -66,19 +68,28 @@ function renderPanel(
|
|
|
66
68
|
const label = theme.fg(section.color, plainLabel);
|
|
67
69
|
sourceRows.set(lines.length, sourceY);
|
|
68
70
|
lines.push(border("├─ ") + label + border(" " + "─".repeat(Math.max(0, width - visibleWidth(plainLabel) - 5)) + "┤"));
|
|
71
|
+
copyRanges?.push([]);
|
|
69
72
|
}
|
|
70
73
|
sourceRows.set(lines.length, sourceY);
|
|
71
|
-
if (isNativeImageRow(row)) lines.push(row);
|
|
74
|
+
if (isNativeImageRow(row)) { lines.push(row); copyRanges?.push([]); }
|
|
72
75
|
else {
|
|
73
76
|
const content = stripAnsiBackgrounds(row);
|
|
74
|
-
|
|
77
|
+
const length = visibleWidth(content);
|
|
78
|
+
lines.push(border("│ ") + content + " ".repeat(Math.max(0, contentWidth - length)) + border(" │"));
|
|
79
|
+
copyRanges?.push([[2, 2 + Math.max(1, Math.min(contentWidth, length))]]);
|
|
75
80
|
}
|
|
76
81
|
});
|
|
77
82
|
const footerFits = footer && visibleWidth(footer) + 6 <= width;
|
|
78
83
|
lines.push(footerFits
|
|
79
84
|
? border("╰" + "─".repeat(width - visibleWidth(footer) - 5) + " " + footer + " ─╯")
|
|
80
85
|
: border("╰" + "─".repeat(width - 2) + "╯"));
|
|
81
|
-
|
|
86
|
+
copyRanges?.push([]);
|
|
87
|
+
// Apply backgrounds before adding this frame's annotations so the width
|
|
88
|
+
// cache doesn't retain an extra marked variant of every newly painted row.
|
|
89
|
+
const frame = { lines: lines.map((line, i) => {
|
|
90
|
+
const painted = cardBackground(line, width, theme, background, borderColor);
|
|
91
|
+
return copyRanges ? selectableRow(painted, width, copyRanges[i]) : painted;
|
|
92
|
+
}), sourceRows, contentWidth, inset: 2 };
|
|
82
93
|
if (cacheOwner) frameCache.set(cacheOwner, { title, source: source.slice(), width, palette, sections: sectionKey, frame });
|
|
83
94
|
return frame;
|
|
84
95
|
}
|
|
@@ -98,7 +109,7 @@ export function frameNativeRows(
|
|
|
98
109
|
const cached = gutterFrames.get(frame);
|
|
99
110
|
if (cached) return cached;
|
|
100
111
|
const padded = { ...frame, inset: frame.inset + margin,
|
|
101
|
-
lines: frame.lines.map((line) => isNativeImageRow(line) ? line : " ".repeat(margin) + line + " ".repeat(margin)),
|
|
112
|
+
lines: frame.lines.map((line) => isNativeImageRow(line) ? line : selectableRow(" ".repeat(margin) + line + " ".repeat(margin), width, [[margin, width - margin]])),
|
|
102
113
|
};
|
|
103
114
|
gutterFrames.set(frame, padded);
|
|
104
115
|
return padded;
|