@each1024/pi-mini-mode 1.3.1 → 1.3.3

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
@@ -3,27 +3,27 @@
3
3
  </p>
4
4
 
5
5
  <p align="center">
6
- <a href="README.zh-CN.md">简体中文</a> · <a href="#install">Install</a> · <a href="#make-it-yours">Settings</a> · <a href="https://github.com/user-attachments/assets/5f2f4816-45ed-4759-b035-d9ee59e8a763">Watch demo</a>
6
+ <a href="#install">Install</a> · <a href="#make-it-yours">Settings</a> · <a href="https://github.com/user-attachments/assets/5f2f4816-45ed-4759-b035-d9ee59e8a763">Watch demo</a> · <a href="README.zh-CN.md">中文</a>
7
7
  </p>
8
8
 
9
9
  A compact, configurable footer for [Pi](https://pi.dev). Your model, usage, cost estimate, context, and generation speed — at a glance.
10
10
 
11
11
  ## Minimal output
12
12
 
13
- `/mini-lens-settings` now has **Lens** and **极简输出 (Minimal output)** submenus. Minimal mode is on by default; explicit off settings are respected.
13
+ `/mini-lens-settings` now has **Lens**, a separate **Collapse replies** switch, and **Minimal output**. Collapsed replies are off by default, so Pi's conversation history stays native until you turn them on. While the switch is off, Minimal output options stay disabled.
14
14
 
15
15
  - `/mini-lens-minimal on` shows the user's Markdown on an accent-tinted surface, a background-free process summary, and the final reply without a heading or extra background. No duplicate dock panel.
16
- - Each turn uses one shared tree showing the latest **six summary entries**: available thinking, tool calls, streaming tool output, and skill reads. `Ctrl+O` expands the full Markdown process and toggles it closed again; new questions start collapsed; tools without output show an elapsed wait counter, and empty progress events never overwrite existing content; there are no section headings, collapsed counts, or completion labels. Original session messages remain intact.
16
+ - Each turn uses one shared tree showing the latest **ten summary entries**: available thinking, tool calls, streaming tool output, and skill reads. `Ctrl+O` expands the full Markdown process and toggles it closed again; new questions start collapsed; tools without output show an elapsed wait counter, and empty progress events never overwrite existing content; there are no section headings, collapsed counts, or completion labels. Original session messages remain intact.
17
17
  - Agent/subagent calls share the same chronological tree as tools and skills; `Ctrl+O` reveals tasks and Markdown output. A returned call does not imply background completion.
18
18
  - The pi-subagents `async subagent` / `Async agents` widget uses a background-free status tree, retaining native detail shortcuts and output paths. This adapter is active only in minimal mode, restores on disable, and passes unknown formats through. Grouping design reference: [pi-cc-extensions](https://github.com/minuque/pi-cc-extensions).
19
19
  - `/mini-lens-history` browses complete process entries, five at a time.
20
20
  - Final Markdown streams as text events arrive; failures and interruptions are indicated.
21
21
  - `/reload` remounts the transcript, including history created in native mode. Expanded tree rails continue through paragraphs, blank lines and code blocks.
22
- - `/mini-lens-minimal off` restores native rendering.
22
+ - `/mini-lens-minimal off` restores Pi's default conversation history.
23
23
 
24
24
  The user surface blends the active Pi accent with its user background. Process and answer text have no background. User padding is two terminal columns horizontally and one row vertically. Markdown, highlighted code, tables and Mermaid terminal diagrams work in light/dark themes; incomplete, unsupported or over-wide diagrams retain their source. **Minimal mode uses a private Pi 0.85.x layout adapter**, without patching the Pi installation. Unknown layouts refuse activation and retain native output. Recheck compatibility after Pi upgrades; another extension replacing the transcript may conflict.
25
25
 
26
- Checks: `npm run check && npm test`. Real terminal smoke test: `python3 test/minimal-pty.py` (Python 3, Node, and the installed dependency's bundled Pi CLI). It uses temporary fixtures, tests regular/fullscreen, toggling, six-entry process and Ctrl+O expand/collapse, restored results, and narrow terminals, without model calls.
26
+ Checks: `npm run check && npm test`. Real terminal smoke test: `python3 test/minimal-pty.py` (Python 3, Node, and the installed dependency's bundled Pi CLI). It uses temporary fixtures, tests regular/fullscreen, toggling, ten-entry process and Ctrl+O expand/collapse, restored results, and narrow terminals, without model calls.
27
27
 
28
28
  ## Install
29
29
 
@@ -76,6 +76,9 @@ Customize with `/mini-lens-settings`. Changes take effect immediately.
76
76
 
77
77
  **Fits your terminal.** Follows your Pi theme and adapts to narrow widths. Only the footer changes; Pi's built-in tool and thinking views stay intact.
78
78
 
79
+ Bundled themes `cc-light` / `cc-dark` are vendored from [pi-cc-extensions](https://github.com/minuque/pi-cc-extensions) (MIT).
80
+
81
+
79
82
  ## Reference
80
83
 
81
84
  <details>
@@ -87,7 +90,7 @@ On the first interactive TUI session, Mini Lens shows a preview with every field
87
90
  deepseek-v4-flash high Total 45K Cached 25K CH 40.0% $0.012 500/1.0M █░░░░░░░░░ 1% 120 tok/s
88
91
  ```
89
92
 
90
- The first-run picker offers **Keep defaults** and **Configure now**. Keeping defaults persists every display field as enabled and prevents the prompt from appearing again; configuring opens the same settings list immediately. Print, JSON, and other non-interactive modes never prompt.
93
+ The first-run picker offers **Keep defaults** and **Configure now**. Keeping defaults persists footer fields as enabled, leaves collapsed replies off, and prevents the prompt from appearing again; configuring opens the same settings list immediately. Print, JSON, and other non-interactive modes never prompt.
91
94
 
92
95
  Open that settings UI any time with:
93
96
 
@@ -130,7 +133,8 @@ Settings are stored globally at Pi's agent directory (normally `~/.pi/agent/mini
130
133
  | `mini-lens-context-dots-show` | `false` | Use a single-line dot-matrix bar instead of the default solid bar |
131
134
  | `mini-lens-context-percent-show` | `true` | Context-use percentage |
132
135
  | `mini-lens-speed-show` | `true` | Generation speed at the far right |
133
- | &nbsp;&nbsp;&nbsp;&nbsp;`mini-lens-speed-unit-show` | `true` | Generation-speed sub-setting: append `tok/s` to the numeric value |
136
+ | `mini-lens-speed-unit-show` | `true` | Generation-speed sub-setting: append `tok/s` to the numeric value |
137
+ | `mini-lens-minimal-show` | `false` | Collapse replies; off keeps Pi's default conversation history |
134
138
  | `onboardingCompleted` | `false` initially | Internal marker that prevents another first-run prompt |
135
139
 
136
140
  - **Generation speed**
package/README.zh-CN.md CHANGED
@@ -1,29 +1,12 @@
1
- <p align="center">
2
- <img src="assets/mini-lens-hero.png" alt="Mini Lens for Pi — 会话状态,一眼清晰。紧凑底栏呈现模型、Token、缓存、费用、上下文与生成速度。" width="100%">
3
- </p>
1
+ # Mini Lens for Pi(中文)
2
+
3
+ [English](README.md)
4
4
 
5
5
  <p align="center">
6
- <a href="README.md">English</a> · <a href="#安装">安装</a> · <a href="#按你所需">设置</a> · <a href="https://github.com/user-attachments/assets/5f2f4816-45ed-4759-b035-d9ee59e8a763">演示视频</a>
6
+ <img src="assets/mini-lens-hero.png" alt="Mini Lens:显示模型、令牌、缓存、费用、上下文和生成速度的紧凑页脚" width="100%">
7
7
  </p>
8
8
 
9
- [Pi](https://pi.dev) 的紧凑、可配置底栏。模型、用量、预估费用、上下文与生成速度,一眼清晰。
10
-
11
- ## 极简输出
12
-
13
- 执行 `/mini-lens-settings`,进入 **Lens** 或 **极简输出** 分组。极简模式默认开启(保留用户显式关闭的设置):
14
-
15
- - `/mini-lens-minimal on`:用户原文使用强调色背景;执行过程和最终回复均无背景色,最终回复直接显示,无标题、无额外背景。不重复添加底部面板。
16
- - 每轮工具、Agent、Skill 与思考统一为状态树,默认显示最近 **6 条摘要**;`Ctrl+O` 展开完整过程,再按一次收起。新提问恢复默认折叠。工具暂未输出时保留执行状态并每秒更新等待时长;空进度不会覆盖已有内容。支持流式思考(模型提供时)、工具调用、执行输出与读取的 skill。完整原始消息仍保留在会话中。
17
- - Agent/subagent 调用与工具、Skill 按发生顺序合并,`Ctrl+O` 展开任务与 Markdown 输出;摘要中的“完成”仅表示工具调用返回,不代表后台任务完成。
18
- - 接管 pi-subagents 的 `async subagent` / `Async agents` 后台摘要,使用无背景状态树,保留详情快捷键和输出路径。仅在极简模式开启时启用;关闭后恢复原视图,未知格式保持原样。设计参考 [pi-cc-extensions](https://github.com/minuque/pi-cc-extensions) 的调用分组。
19
- - `/mini-lens-history`:按轮翻阅收起的完整过程内容,每页最多 5 条。
20
- - 最终正文随文本事件实时流式展示;中止或失败会显示相应状态。
21
- - `/reload` 后自动重新挂载,原生模式产生的历史消息也按当前极简样式重建;展开详情的竖线跨段落、空行和代码块连续显示。
22
- - `/mini-lens-minimal off`:恢复原生消息展示。
23
-
24
- 用户块背景由 Pi 当前强调色与用户背景色混合;过程和回答无背景,文字适配深浅主题。用户块内边距为左右 2 列、上下 1 行(终端不支持 px)。全程支持 Markdown、表格、代码高亮和 Mermaid 终端图表;图表不支持、未完整或过宽时保留源码。**极简模式依赖 Pi 0.85.x 的私有消息区布局**,不修改 Pi 安装文件;无法识别布局时拒绝启用并保留原生输出。Pi 升级后需重新验证兼容性,其他扩展同时替换消息区时也可能冲突。
25
-
26
- 开发验证:`npm run check && npm test`;真实终端冒烟:`python3 test/minimal-pty.py`(Python 3、Node,以及依赖中 Pi 的 bundled CLI)。后者使用临时会话验证 regular/fullscreen、开关恢复、六条摘要、Ctrl+O 展开/收起、历史结果和窄屏,不调用模型。
9
+ 适用于 [Pi](https://pi.dev) 的紧凑、可配置页脚。模型、用量、费用估算、上下文使用率和生成速度,一眼即可查看。
27
10
 
28
11
  ## 安装
29
12
 
@@ -31,148 +14,86 @@
31
14
  pi install npm:@each1024/pi-mini-mode
32
15
  ```
33
16
 
34
- 在 Pi 中执行 `/reload` 即可加载。需要 **Pi ≥ 0.84.0**。
17
+ 在 Pi 中运行 `/reload`。需要 **Pi ≥ 0.84.0**。
35
18
 
36
- <details>
37
- <summary>也可以从 GitHub 安装</summary>
19
+ 也可以直接从 GitHub 安装:
38
20
 
39
21
  ```bash
40
22
  pi install git:github.com/eachann1024/pi-mini-mode
41
23
  ```
42
24
 
43
- </details>
44
-
45
- ---
46
-
47
- <table>
48
- <tr>
49
- <td width="50%" valign="top">
50
-
51
- ### 会话状态,尽在眼前
52
-
53
- - 模型与思考等级
54
- - 会话累计 Token
55
- - 缓存用量与命中率
56
- - 会话预估费用
57
- - 上下文占用与进度
58
- - 最近一次生成速度
59
-
60
- </td>
61
- <td width="50%" valign="top">
62
-
63
- ### 按你所需
64
-
65
- 自由选择显示字段。每次调整都有即时预览,并跟随你的 Pi 主题。
66
-
67
- <a href="assets/mini-lens-settings.jpg"><img src="assets/mini-lens-settings.jpg" alt="Pi 浅色主题下的 Mini Lens 设置界面,包含即时预览与字段开关。点击查看原图。" width="100%"></a>
68
-
69
- [观看设置演示](https://github.com/user-attachments/assets/5f2f4816-45ed-4759-b035-d9ee59e8a763)
70
-
71
- </td>
72
- </tr>
73
- </table>
74
-
75
- 执行 `/mini-lens-settings` 自定义底栏,修改即时生效。
25
+ ## 极简输出
76
26
 
77
- **自然融入终端。** 跟随 Pi 主题,适配窄窗口。仅替换底栏,保留 Pi 内置的工具与思考展示。
27
+ 在 `/mini-lens-settings` 中可以找到 **Lens**、独立的 **Collapse replies(折叠回复)** 和 **Minimal output(极简输出)** 设置。折叠回复默认关闭;关闭时,极简输出选项也会禁用。
78
28
 
79
- ## 详细参考
29
+ - `/mini-lens-minimal on` 显示带主题色背景的用户 Markdown、无背景的过程摘要,以及没有标题和额外背景的最终回复。
30
+ - 每轮使用一棵共享树,显示最新 **10 条摘要**,包括思考、工具调用、流式工具输出和技能读取。按 `Ctrl+O` 展开完整 Markdown 过程,再按一次收起。
31
+ - Agent/subagent 调用会按时间顺序与工具、技能共用同一棵树;展开后可查看任务和 Markdown 输出。
32
+ - `/mini-lens-history` 可浏览完整过程记录,每次显示 5 条。
33
+ - 最终 Markdown 会随着文本事件流式显示;失败和中断会明确标记。
34
+ - `/reload` 会重新挂载 transcript,也会包含原生模式中产生的历史记录。
35
+ - `/mini-lens-minimal off` 恢复 Pi 默认的对话历史显示。
80
36
 
81
- <details>
82
- <summary><strong>首次运行与配置</strong> — 默认值、操作方式和配置文件</summary>
37
+ 极简模式使用私有的 Pi 0.85.x 布局适配器,不会修改 Pi 安装目录。未知布局会拒绝启用并保留原生输出。升级 Pi 后请重新检查兼容性;如果其他扩展也替换 transcript,可能产生冲突。
83
38
 
84
- 首次在交互式 TUI 会话运行时,Mini Lens 会展示所有字段默认开启的预览:
39
+ ## 页脚指标
85
40
 
86
- ```text
87
- deepseek-v4-flash high Total 45K Cached 25K CH 40.0% $0.012 500/1.0M █░░░░░░░░░ 1% 120 tok/s
88
- ```
41
+ 默认显示:
89
42
 
90
- 首次运行选择器提供 **Keep defaults** 和 **Configure now**。保持默认会持久化全部显示项均为开启,并不再重复提示;立即配置会直接打开同一份设置列表。print、JSON 等非交互模式绝不会弹出提示。
43
+ - 模型与思考级别
44
+ - 会话令牌总数
45
+ - 缓存令牌与命中率
46
+ - 会话费用估算
47
+ - 上下文用量与进度条
48
+ - 最新生成速度
91
49
 
92
- 以后随时执行下面的命令打开设置界面:
50
+ 运行以下命令即可配置显示字段,修改立即生效,并会按照当前 Pi 主题预览:
93
51
 
94
52
  ```text
95
53
  /mini-lens-settings
96
54
  ```
97
55
 
98
- 当前设置项与上方对应预览字段同步使用主题强调色 `accent` 加粗高亮,并带有 `selectedBg` 背景。Pi 全屏模式支持鼠标悬停定位、点击切换;普通终端模式使用键盘导航。仅悬停不会修改设置。
99
-
100
- 修改会立即刷新底栏;该命令需要在 Pi TUI 模式中执行。设置面板中的预览始终使用固定示例数据,而不会读取当前会话,并会立即反映每个开关。
101
-
102
- 设置保存在 Pi 的全局 agent 目录(通常是 `~/.pi/agent/mini-lens.json`;若 Pi 使用其他配置目录,则随 Pi 的目录而定)。文件缺失或损坏时会安全地回退为默认值。
103
-
104
- ```json
105
- {
106
- "mini-lens-model-show": true,
107
- "mini-lens-thinking-show": true,
108
- "mini-lens-ch-show": true,
109
- "mini-lens-session-tokens-show": true,
110
- "mini-lens-cache-tokens-show": true,
111
- "mini-lens-cost-show": true,
112
- "mini-lens-context-show": true,
113
- "mini-lens-context-dots-show": false,
114
- "mini-lens-context-percent-show": true,
115
- "mini-lens-speed-show": true,
116
- "mini-lens-speed-unit-show": true,
117
- "onboardingCompleted": true
118
- }
119
- ```
120
-
121
- | 配置项 | 默认值 | 控制内容 |
122
- | --- | --- | --- |
123
- | `mini-lens-model-show` | `true` | 不含 provider 前缀的模型 ID |
124
- | `mini-lens-thinking-show` | `true` | thinking level |
125
- | `mini-lens-ch-show` | `true` | 会话缓存命中率(`CH`) |
126
- | `mini-lens-session-tokens-show` | `true` | 会话累计 Token(`Total`) |
127
- | `mini-lens-cache-tokens-show` | `true` | 累计缓存读取 + 缓存写入 Token |
128
- | `mini-lens-cost-show` | `true` | 会话列表价预估 |
129
- | `mini-lens-context-show` | `true` | 已用/总上下文 Token 和进度条 |
130
- | `mini-lens-context-dots-show` | `false` | 使用单行点阵进度条,默认保留原实心样式 |
131
- | `mini-lens-context-percent-show` | `true` | 上下文使用百分比 |
132
- | `mini-lens-speed-show` | `true` | 最右侧生成速度 |
133
- | &nbsp;&nbsp;&nbsp;&nbsp;`mini-lens-speed-unit-show` | `true` | 生成速度的子项:是否在数值后显示 `tok/s` |
134
- | `onboardingCompleted` | 初始为 `false` | 用于防止再次出现首次运行提示的内部标记 |
135
-
136
- - **生成速度**
137
- - **Show tok/s unit**(`mini-lens-speed-unit-show`)是 `/mini-lens-settings` 中 **Show latest generation speed** 下方缩进的次级设置。关闭后仍显示速度数值(例如 `40.0`),但去掉 `tok/s`。
138
- - 关闭生成速度主项时,子项值会被保留,但不会生效。
139
-
140
- </details>
56
+ 页脚会跟随 Pi 主题并适配窄终端。只有页脚会变化,Pi 内置的工具和思考视图保持不变。
141
57
 
142
- <details>
143
- <summary><strong>指标如何计算</strong> — Token、缓存、速度与预估费用</summary>
58
+ ## 配置
144
59
 
145
- 会话累计值从当前会话分支上每个已完成的 `assistant` 和 `toolResult` 条目聚合。工具上报的嵌套 LLM 用量(例如子代理)也会恰好计入一次。`Total` 优先使用服务商上报的 `totalTokens`;旧版或自定义工具结果没有该字段时,回退为 input、output、cache-read、cache-write Token 之和。`Cached` 是 cache-read + cache-write,属于 Total 的一部分;`CH` 是 cache-read / (input + cache-read)。只统计已持久化的最终用量,因此流式更新不会重复累计。
60
+ 设置保存在 Pi 的 agent 目录中,通常是 `~/.pi/agent/mini-lens.json`。文件缺失或格式错误时会安全回退到默认设置。
146
61
 
147
- assistant 流式输出期间,一旦同时有正数的累计 `usage.output` 和已过时间,速度就会出现;流式期间会持续刷新,计算为从该 assistant 消息开始至今的输出 Token / 时间。完成后的速度会保留:之后只有工具调用或等待输出的 assistant 消息不会清除它;只有新的可测量生成才会替换它。output 倒退或时间未递增的采样会忽略。对于只在工具完成时上报嵌套 LLM 用量、没有流式事件的工具,最终速度为输出 Token / 该工具执行时长。工具没有上报 output 用量时无法可靠测速,会保留之前的速度。
148
-
149
- 还没有可测量的响应时,速度字段会完全隐藏,绝不显示 `-- tok/s` 占位内容。速度出现时固定在底栏最右侧;若开启上下文百分比,百分比紧邻在速度左边。速度颜色使用 Pi 主题语义色:>=30 tok/s 为 **success**,10–29.9 tok/s 为 **warning**,低于 10 tok/s 为 **error**。没有硬编码颜色,因此会契合当前 Pi 主题。
150
-
151
- 价格来自同一份当前分支最终用量和模型配置的每百万 Token 单价,是预估值而不是服务商账单。窄终端会降级或截断低优先级内容,以保持单行且不溢出。
152
-
153
- </details>
154
-
155
- <details>
156
- <summary><strong>开发</strong> — 本地安装与检查</summary>
157
-
158
- 开发时只能安装本地副本;同时安装 npm 与本地副本会重复注册扩展:
62
+ | 配置项 | 默认值 | 说明 |
63
+ | --- | --- | --- |
64
+ | `mini-lens-model-show` | `true` | 显示模型 ID |
65
+ | `mini-lens-thinking-show` | `true` | 显示思考级别 |
66
+ | `mini-lens-ch-show` | `true` | 显示会话缓存命中率(`CH`) |
67
+ | `mini-lens-session-tokens-show` | `true` | 显示会话累计令牌(`Total`) |
68
+ | `mini-lens-cache-tokens-show` | `true` | 显示缓存读取与写入令牌 |
69
+ | `mini-lens-cost-show` | `true` | 显示会话费用估算 |
70
+ | `mini-lens-context-show` | `true` | 显示上下文令牌和进度条 |
71
+ | `mini-lens-context-dots-show` | `false` | 使用点阵进度条 |
72
+ | `mini-lens-context-percent-show` | `true` | 显示上下文使用百分比 |
73
+ | `mini-lens-speed-show` | `true` | 显示最新生成速度 |
74
+ | `mini-lens-speed-unit-show` | `true` | 在速度后显示 `tok/s` |
75
+ | `mini-lens-minimal-show` | `false` | 折叠回复;关闭则使用 Pi 默认历史显示 |
76
+
77
+ 生成速度只有在获得有效的输出令牌和耗时后才会显示,不会显示 `-- tok/s` 占位符。速度颜色遵循 Pi 主题:至少 30 tok/s 为成功色,10–29.9 tok/s 为警告色,低于 10 tok/s 为错误色。费用是基于已完成会话用量和配置费率的估算,并非服务商账单。
78
+
79
+ ## 开发
159
80
 
160
81
  ```bash
161
- pi remove npm:@each1024/pi-mini-mode && pi install /path/to/pi-rolling-process
82
+ pi remove npm:@each1024/pi-mini-mode && pi install /path/to/pi-mini-mode
162
83
  npm run check
163
84
  npm test
164
85
  ```
165
86
 
166
- 修改源码后,在已打开的 Pi 会话中执行 `/reload`。`npm run check` 做 TypeScript 检查,`npm test` 运行底栏、设置交互和发布自检。
87
+ 修改源码后,在已打开的 Pi 会话中运行 `/reload`。真实终端冒烟测试:
167
88
 
168
- </details>
89
+ ```bash
90
+ python3 test/minimal-pty.py
91
+ ```
169
92
 
170
93
  ## 发布
171
94
 
172
- 每次推送到 `main`,通过 `npm ci`、`npm run check` 和 `npm test` 后自动发布 npm;也可在 `main` 手动触发工作流。发布版本取本地版本基线与 npm 最新稳定版本 patch 加一的较大值。版本仅在 runner 工作副本中修改,不回写版本提交、不创建 tag;发布 major/minor 时,提高 `package.json` 和 lockfile 中的本地基线即可。已发布的 commit 会跳过。Actions 并发机制可能合并待运行的 push,不保证每次 push(或一次 push 中每个 commit)都单独发包。
173
-
174
- 一次性配置:先由已登录的维护者账号首次发布 `@each1024/pi-mini-mode@1.3.1`,再在 npm 包设置中绑定 **Trusted Publisher**:GitHub owner `eachann1024`、repo `pi-mini-mode`、workflow `publish.yml`(不填 environment),并允许直接 `npm publish`。后续通过 OIDC 发布并附带 provenance,无需 npm token。
95
+ 推送到 `main` 后,GitHub Actions 会在通过 `npm ci`、`npm run check` 和 `npm test` 后自动发布到 npm。发布使用 npm Trusted Publisher、OIDC 和 provenance,无需 npm token。
175
96
 
176
97
  ---
177
98
 
178
- [MIT 许可证](LICENSE) · 为 [Pi](https://pi.dev) 而作
99
+ [MIT License](LICENSE) · 为 [Pi](https://pi.dev) 打造