@runminton/pi-tidy-tools 0.1.0 → 0.1.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 +23 -16
- package/README.zh-CN.md +23 -16
- package/package.json +2 -2
- package/tidy-tools.ts +2 -13
package/README.md
CHANGED
|
@@ -1,23 +1,32 @@
|
|
|
1
|
-
# pi-
|
|
1
|
+
# pi-tidy-tools
|
|
2
2
|
|
|
3
|
-
A
|
|
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
|
-
##
|
|
7
|
+
## Default view
|
|
8
8
|
|
|
9
|
-
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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-
|
|
1
|
+
# pi-tidy-tools
|
|
2
2
|
|
|
3
|
-
为 [Pi](https://github.com/earendil-works/pi-mono)(pi-coding-agent 的 TUI
|
|
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
|
-
|
|
10
|
-
- **按工具单独展开** —— 只展开你关心的那一个工具,每个工具一个快捷键:
|
|
9
|
+
每个工具启动时处于两种状态之一:
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
| 工具 | 默认状态 | 显示内容 |
|
|
12
|
+
|---|---|---|
|
|
13
|
+
| `bash` | **折叠** | `$ command`、一行输出预览、有更多输出时加 `... (N more lines)` 计数行 |
|
|
14
|
+
| `edit` | **展开** | Pi 官方渲染:路径、修改块数、实时 diff 预览、原生布局 |
|
|
15
|
+
| `write` | **展开** | Pi 官方渲染:路径、行数、语法高亮内容 |
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runminton/pi-tidy-tools",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Collapse bash/edit/write into one-line summaries in the pi TUI; expand the official rendering per tool with Ctrl+Alt+B/W/E.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
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 +
|
|
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
|
-
|
|
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) {
|