@runminton/pi-tidy-tools 0.1.0 → 0.1.1

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 CHANGED
@@ -1,23 +1,32 @@
1
- # pi-clean-tool-render
1
+ # pi-tidy-tools
2
2
 
3
- A compact tool-rendering extension for [Pi](https://github.com/earendil-works/pi-mono) (the pi-coding-agent TUI). It overrides the rendering of `bash`, `edit` and `write` so tool output stays out of your way: collapsed into a tiny summary by default, expanded on demand per tool.
3
+ A tidy tool-rendering extension for [Pi](https://github.com/earendil-works/pi-mono) (the pi-coding-agent TUI). It overrides the rendering of `bash`, `edit` and `write`: compact summaries by default, full official rendering when you need it.
4
4
 
5
5
  [中文版](README.zh-CN.md)
6
6
 
7
- ## Features
7
+ ## Default view
8
8
 
9
- - **Collapsed by default** — each tool shows a short summary (at most 3 lines) with an ellipsis for omitted content.
10
- - **Per-tool expansion** — expand exactly the tool you care about, with one shortcut each:
9
+ Each tool starts in one of two states:
11
10
 
12
- | Shortcut | Tool |
13
- |---|---|
14
- | `Ctrl+Alt+E` | `edit` |
15
- | `Ctrl+Alt+W` | `write` |
16
- | `Ctrl+Alt+B` | `bash` |
11
+ | Tool | Default | What you see |
12
+ |---|---|---|
13
+ | `bash` | **Collapsed** | `$ command`, one output line, and `... (N more lines)` if there is more output |
14
+ | `edit` | **Expanded** | Pi's official renderer: path, block count, live diff preview, native layout |
15
+ | `write` | **Expanded** | Pi's official renderer: path, line count, syntax-highlighted content |
17
16
 
18
- - **Independent of the global `Ctrl+O`** — Pi's built-in "expand everything" toggle does not affect these three tools. Each tool has exactly two states: collapsed summary ↔ full official rendering.
19
- - **Official renderers on expansion** — expanded views delegate to Pi's built-in renderers, so the full diff preview and syntax highlighting still work.
20
- - **Fast** — rendering caches wrapped output and only processes the preview lines: roughly 13µs per frame for a 2000-line output, instead of ~3ms before.
17
+ Collapsed summaries are single-line (bash shows one preview line plus a count row).
18
+
19
+ ## Shortcuts
20
+
21
+ | Shortcut | Tool | Toggles between |
22
+ |---|---|---|
23
+ | `Ctrl+Alt+B` | `bash` | collapsed summary ↔ **one-key full output** |
24
+ | `Ctrl+Alt+E` | `edit` | official rendering ↔ collapsed summary |
25
+ | `Ctrl+Alt+W` | `write` | official rendering ↔ collapsed summary |
26
+
27
+ A notification shows the current state on each toggle; press again to switch back.
28
+
29
+ `bash` expands to the **complete output** in one keypress — it skips Pi's built-in 5-line tail preview. `edit` and `write` expand to Pi's **official default rendering**: they delegate to the official renderers, and whether the content itself is further expanded is still controlled by the global `Ctrl+O`, exactly as without this extension. Only `bash` ignores `Ctrl+O` in its expanded state.
21
30
 
22
31
  ## Usage
23
32
 
@@ -30,13 +39,11 @@ pi -e ./tidy-tools.ts
30
39
  Or install as a pi package:
31
40
 
32
41
  ```bash
33
- pi install pi-tidy-tools
42
+ pi install @runminton/pi-tidy-tools
34
43
  ```
35
44
 
36
45
  Or copy `tidy-tools.ts` into `~/.pi/agent/extensions/` (global) or `.pi/extensions/` (project) and restart Pi.
37
46
 
38
- Then toggle each tool with `Ctrl+Alt+E` / `Ctrl+Alt+W` / `Ctrl+Alt+B`. A notification shows the current state; press again to collapse.
39
-
40
47
  ## Keyboard protocol notes
41
48
 
42
49
  Pi negotiates the [Kitty keyboard protocol](https://sw.kovidgoyal.net/kitty/keyboard-protocol/) (CSI-u sequences) when the terminal supports it — Windows Terminal, WezTerm, Kitty, Ghostty and others do. Under that protocol, `Ctrl+Alt+letter` is encoded with the **control-character codepoint**: `Ctrl+Alt+E` arrives as `\x1b[5;3:1u` (5 = Ctrl+E, modifier = Alt). Pi's keybinding layer, however, recognizes the ASCII-codepoint form (`\x1b[101;7u`, ASCII `e` + Ctrl|Alt modifier). If the terminal sends the former and Pi only understands the latter, the shortcut silently does nothing.
package/README.zh-CN.md CHANGED
@@ -1,23 +1,32 @@
1
- # pi-clean-tool-render
1
+ # pi-tidy-tools
2
2
 
3
- 为 [Pi](https://github.com/earendil-works/pi-mono)(pi-coding-agent 的 TUI)打造的精简工具渲染扩展。它覆盖了 `bash`、`edit`、`write` 的渲染方式:默认折叠成一行小摘要,需要时按工具单独展开,让工具输出不打扰你。
3
+ 为 [Pi](https://github.com/earendil-works/pi-mono)(pi-coding-agent 的 TUI)打造的工具渲染精简扩展。它覆盖了 `bash`、`edit`、`write` 的渲染:默认呈现紧凑摘要,需要时切换为官方完整渲染。
4
4
 
5
5
  [English](README.md)
6
6
 
7
- ## 特性
7
+ ## 默认视图
8
8
 
9
- - **默认折叠** —— 每个工具只显示简短摘要(最多 3 行),省略的内容用 `...` 标记。
10
- - **按工具单独展开** —— 只展开你关心的那一个工具,每个工具一个快捷键:
9
+ 每个工具启动时处于两种状态之一:
11
10
 
12
- | 快捷键 | 工具 |
13
- |---|---|
14
- | `Ctrl+Alt+E` | `edit` |
15
- | `Ctrl+Alt+W` | `write` |
16
- | `Ctrl+Alt+B` | `bash` |
11
+ | 工具 | 默认状态 | 显示内容 |
12
+ |---|---|---|
13
+ | `bash` | **折叠** | `$ command`、一行输出预览、有更多输出时加 `... (N more lines)` 计数行 |
14
+ | `edit` | **展开** | Pi 官方渲染:路径、修改块数、实时 diff 预览、原生布局 |
15
+ | `write` | **展开** | Pi 官方渲染:路径、行数、语法高亮内容 |
17
16
 
18
- - **与全局 `Ctrl+O` 互不影响** —— Pi 内置的"全部展开"开关不会影响这三个工具。每个工具只有两种状态:折叠摘要 ↔ 官方完整渲染。
19
- - **展开时使用官方渲染器** —— 完整展开的内容委托给 Pi 内置渲染器,完整的 diff 预览和语法高亮依然可用。
20
- - **性能好** —— 渲染结果有缓存,且只处理预览行的文本:2000 行输出每帧约 13 微秒,修复前是约 3 毫秒。
17
+ 折叠摘要为单行样式(bash 额外保留一行输出预览 + 一行计数)。
18
+
19
+ ## 快捷键
20
+
21
+ | 快捷键 | 工具 | 切换内容 |
22
+ |---|---|---|
23
+ | `Ctrl+Alt+B` | `bash` | 折叠摘要 ↔ **一键完整输出** |
24
+ | `Ctrl+Alt+E` | `edit` | 官方渲染 ↔ 折叠摘要 |
25
+ | `Ctrl+Alt+W` | `write` | 官方渲染 ↔ 折叠摘要 |
26
+
27
+ 每次切换会弹出通知提示当前状态;再按一次切回。
28
+
29
+ `bash` 展开时**一次按键直接显示完整输出**——跳过 Pi 内置的 5 行尾部预览。`edit` 和 `write` 展开时使用 Pi **官方默认渲染**:委托给官方渲染器,内容本身是否进一步展开仍由全局 `Ctrl+O` 控制,与不装本扩展时完全一致。只有 `bash` 在展开状态下不受 `Ctrl+O` 影响。
21
30
 
22
31
  ## 使用方法
23
32
 
@@ -30,13 +39,11 @@ pi -e ./tidy-tools.ts
30
39
  或者作为 pi 包安装:
31
40
 
32
41
  ```bash
33
- pi install pi-tidy-tools
42
+ pi install @runminton/pi-tidy-tools
34
43
  ```
35
44
 
36
45
  或者把 `tidy-tools.ts` 复制到 `~/.pi/agent/extensions/`(全局)或 `.pi/extensions/`(项目级),然后重启 Pi。
37
46
 
38
- 之后用 `Ctrl+Alt+E` / `Ctrl+Alt+W` / `Ctrl+Alt+B` 切换对应工具的展开状态。按下时会弹通知提示当前状态;再按一次收起。
39
-
40
47
  ## 键盘协议说明(重要)
41
48
 
42
49
  Pi 会在终端支持时协商 [Kitty 键盘协议](https://sw.kovidgoyal.net/kitty/keyboard-protocol/)(CSI-u 序列)——Windows Terminal、WezTerm、Kitty、Ghostty 等都支持。在该协议下,`Ctrl+Alt+字母` 使用**控制字符码**编码:`Ctrl+Alt+E` 到达时是 `\x1b[5;3:1u`(5 = Ctrl+E 的控制字符,修饰位 = Alt)。而 Pi 的按键匹配层只识别 **ASCII 码形式**(`\x1b[101;7u`,即 ASCII `e` + Ctrl|Alt 修饰位)。如果终端发送前者、Pi 只认后者,快捷键就会无声失效——这就是不同终端行为差异的来源。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runminton/pi-tidy-tools",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Tidy tool rendering for the pi TUI: collapse bash/edit/write into compact summaries and expand on demand with Ctrl+Alt+B/W/E.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/tidy-tools.ts CHANGED
@@ -435,7 +435,7 @@ export default function (pi: ExtensionAPI) {
435
435
  },
436
436
  );
437
437
 
438
- // --- Write tool: collapsed shows path + first lines ---
438
+ // --- Write tool: collapsed shows path + line count ---
439
439
  registerCollapsibleTool(
440
440
  pi,
441
441
  getWriteDef,
@@ -445,18 +445,7 @@ export default function (pi: ExtensionAPI) {
445
445
  const lines = content.split("\n");
446
446
  let text = theme.fg("toolTitle", theme.bold("write ")) + theme.fg("accent", path);
447
447
  text += theme.fg("dim", ` (${lines.length} lines)`);
448
- if (content) {
449
- const preview = lines
450
- .slice(0, MAX_COLLAPSED_CONTENT_LINES - 1)
451
- .map((line) => theme.fg("toolOutput", line));
452
- if (lines.length > MAX_COLLAPSED_CONTENT_LINES) {
453
- preview.push(
454
- theme.fg("muted", `... (${lines.length - (MAX_COLLAPSED_CONTENT_LINES - 1)} more lines)`),
455
- );
456
- }
457
- text += `\n${preview.join("\n")}`;
458
- }
459
- return new LimitedLinesText(text, MAX_COLLAPSED_CONTENT_LINES, theme.fg("muted", "..."));
448
+ return new LimitedLinesText(text, 1, theme.fg("muted", "..."));
460
449
  },
461
450
  (result, _options, theme, context) => {
462
451
  if (context.isError) {