@each1024/pi-mini-mode 1.3.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/LICENSE +21 -0
- package/README.md +178 -0
- package/README.zh-CN.md +178 -0
- package/extensions/footer-status.ts +1027 -0
- package/lib/agent-view.ts +107 -0
- package/lib/minimal-markdown.ts +17 -0
- package/lib/minimal-theme.ts +32 -0
- package/lib/transcript-adapter.ts +96 -0
- package/package.json +56 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 eachann1024
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/mini-lens-hero.png" alt="Mini Lens for Pi — Your session. In focus. A compact footer showing model, tokens, cache, cost, context and generation speed." width="100%">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
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>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
A compact, configurable footer for [Pi](https://pi.dev). Your model, usage, cost estimate, context, and generation speed — at a glance.
|
|
10
|
+
|
|
11
|
+
## Minimal output
|
|
12
|
+
|
|
13
|
+
`/mini-lens-settings` now has **Lens** and **极简输出 (Minimal output)** submenus. Minimal mode is on by default; explicit off settings are respected.
|
|
14
|
+
|
|
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.
|
|
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
|
+
- 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
|
+
- `/mini-lens-history` browses complete process entries, five at a time.
|
|
20
|
+
- Final Markdown streams as text events arrive; failures and interruptions are indicated.
|
|
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.
|
|
23
|
+
|
|
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
|
+
|
|
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.
|
|
27
|
+
|
|
28
|
+
## Install
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pi install npm:@each1024/pi-mini-mode
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Run `/reload` in Pi. Requires **Pi ≥ 0.84.0**.
|
|
35
|
+
|
|
36
|
+
<details>
|
|
37
|
+
<summary>Install from GitHub instead</summary>
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pi install git:github.com/eachann1024/pi-mini-mode
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
</details>
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
<table>
|
|
48
|
+
<tr>
|
|
49
|
+
<td width="50%" valign="top">
|
|
50
|
+
|
|
51
|
+
### Live session metrics
|
|
52
|
+
|
|
53
|
+
- Model & thinking level
|
|
54
|
+
- Session token totals
|
|
55
|
+
- Cached tokens & hit rate
|
|
56
|
+
- Estimated session cost
|
|
57
|
+
- Context usage & progress
|
|
58
|
+
- Latest generation speed
|
|
59
|
+
|
|
60
|
+
</td>
|
|
61
|
+
<td width="50%" valign="top">
|
|
62
|
+
|
|
63
|
+
### Make it yours
|
|
64
|
+
|
|
65
|
+
Choose the fields you need. Preview each change instantly, in your Pi theme.
|
|
66
|
+
|
|
67
|
+
<a href="assets/mini-lens-settings.jpg"><img src="assets/mini-lens-settings.jpg" alt="Mini Lens settings in Pi's light theme, showing the live preview and field toggles. Click to view at full size." width="100%"></a>
|
|
68
|
+
|
|
69
|
+
[Watch the settings demo](https://github.com/user-attachments/assets/5f2f4816-45ed-4759-b035-d9ee59e8a763)
|
|
70
|
+
|
|
71
|
+
</td>
|
|
72
|
+
</tr>
|
|
73
|
+
</table>
|
|
74
|
+
|
|
75
|
+
Customize with `/mini-lens-settings`. Changes take effect immediately.
|
|
76
|
+
|
|
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
|
+
|
|
79
|
+
## Reference
|
|
80
|
+
|
|
81
|
+
<details>
|
|
82
|
+
<summary><strong>First run & configuration</strong> — defaults, controls, and settings file</summary>
|
|
83
|
+
|
|
84
|
+
On the first interactive TUI session, Mini Lens shows a preview with every field enabled by default:
|
|
85
|
+
|
|
86
|
+
```text
|
|
87
|
+
deepseek-v4-flash high Total 45K Cached 25K CH 40.0% $0.012 500/1.0M █░░░░░░░░░ 1% 120 tok/s
|
|
88
|
+
```
|
|
89
|
+
|
|
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.
|
|
91
|
+
|
|
92
|
+
Open that settings UI any time with:
|
|
93
|
+
|
|
94
|
+
```text
|
|
95
|
+
/mini-lens-settings
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
The focused option and its corresponding preview field use bold theme `accent` text with a `selectedBg` background. Fullscreen Pi supports hover to focus and click to toggle; regular terminal mode uses keyboard navigation. Hovering never changes a setting.
|
|
99
|
+
|
|
100
|
+
Changes take effect immediately. The command requires Pi's TUI mode. Its preview always uses fixed example data rather than your current session, while reflecting every setting toggle immediately.
|
|
101
|
+
|
|
102
|
+
Settings are stored globally at Pi's agent directory (normally `~/.pi/agent/mini-lens.json`; installations with a different Pi config directory use that directory). A malformed or missing file safely falls back to the defaults.
|
|
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
|
+
| Key | Default | Controls |
|
|
122
|
+
| --- | --- | --- |
|
|
123
|
+
| `mini-lens-model-show` | `true` | Model ID without provider prefix |
|
|
124
|
+
| `mini-lens-thinking-show` | `true` | Thinking level |
|
|
125
|
+
| `mini-lens-ch-show` | `true` | Session cache-hit rate (`CH`) |
|
|
126
|
+
| `mini-lens-session-tokens-show` | `true` | Accumulated session tokens (`Total`) |
|
|
127
|
+
| `mini-lens-cache-tokens-show` | `true` | Accumulated cache read + cache write tokens |
|
|
128
|
+
| `mini-lens-cost-show` | `true` | Estimated session list price |
|
|
129
|
+
| `mini-lens-context-show` | `true` | Used/total context tokens and progress bar |
|
|
130
|
+
| `mini-lens-context-dots-show` | `false` | Use a single-line dot-matrix bar instead of the default solid bar |
|
|
131
|
+
| `mini-lens-context-percent-show` | `true` | Context-use percentage |
|
|
132
|
+
| `mini-lens-speed-show` | `true` | Generation speed at the far right |
|
|
133
|
+
| `mini-lens-speed-unit-show` | `true` | Generation-speed sub-setting: append `tok/s` to the numeric value |
|
|
134
|
+
| `onboardingCompleted` | `false` initially | Internal marker that prevents another first-run prompt |
|
|
135
|
+
|
|
136
|
+
- **Generation speed**
|
|
137
|
+
- **Show tok/s unit** (`mini-lens-speed-unit-show`) is the indented sub-setting shown beneath **Show latest generation speed** in `/mini-lens-settings`. Turning it off keeps the speed number (for example `40.0`) and removes only `tok/s`.
|
|
138
|
+
- The sub-setting is retained when generation speed itself is hidden.
|
|
139
|
+
|
|
140
|
+
</details>
|
|
141
|
+
|
|
142
|
+
<details>
|
|
143
|
+
<summary><strong>How metrics work</strong> — tokens, cache, speed, and estimated price</summary>
|
|
144
|
+
|
|
145
|
+
Session totals are aggregated from each finalized `assistant` and `toolResult` entry on the active session branch. This includes nested LLM work reported by tools (such as a child agent) exactly once. `Total` uses the provider's `totalTokens` when supplied; older/custom results without it fall back to the sum of input, output, cache-read, and cache-write tokens. `Cached` is cache-read + cache-write (included in Total); `CH` is cache-read / (input + cache-read). Only persisted finalized usage is counted, so stream updates cannot double count totals.
|
|
146
|
+
|
|
147
|
+
During an assistant stream, speed appears as soon as a positive cumulative `usage.output` sample and elapsed time are available. It is refreshed while streaming and is output tokens divided by elapsed time from the assistant message start. The completed rate remains visible while later assistant messages only call tools or wait for output; it is replaced only by a newer measurable generation. Regressing output samples and non-increasing timestamps are ignored. For a tool result that reports nested LLM usage but has no stream events, the final rate is output tokens divided by that tool execution's duration. A tool that does not report output usage has no measurable speed and leaves the prior rate intact.
|
|
148
|
+
|
|
149
|
+
Before a measurable response exists, the speed field is absent entirely—Mini Lens never displays a `-- tok/s` placeholder. When present, speed is the rightmost footer field (the context percentage, if enabled, is immediately to its left). Its color uses Pi theme semantics: **success** at >=30 tok/s, **warning** at 10–29.9 tok/s, and **error** below 10 tok/s. No colors are hard-coded, so it follows the selected Pi theme.
|
|
150
|
+
|
|
151
|
+
The price is the same finalized active-branch usage and configured per-million-token rates. It is an estimate, not a provider invoice. In narrow terminals, the footer drops/truncates lower-priority content to remain one line without overflow.
|
|
152
|
+
|
|
153
|
+
</details>
|
|
154
|
+
|
|
155
|
+
<details>
|
|
156
|
+
<summary><strong>Development</strong> — local setup and checks</summary>
|
|
157
|
+
|
|
158
|
+
Install only the local copy while developing; installing npm and local copies together double-registers the extension:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
pi remove npm:@each1024/pi-mini-mode && pi install /path/to/pi-rolling-process
|
|
162
|
+
npm run check
|
|
163
|
+
npm test
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
After source changes, run `/reload` in an already-open Pi session. `npm run check` runs TypeScript checking and `npm test` runs the footer, settings, and publishing self-checks.
|
|
167
|
+
|
|
168
|
+
</details>
|
|
169
|
+
|
|
170
|
+
## Publishing
|
|
171
|
+
|
|
172
|
+
Pushes to `main` automatically publish to npm after `npm ci`, `npm run check`, and `npm test`; the workflow also supports manual dispatch on `main`. Each release uses the higher of the local version baseline and npm's latest stable version plus one patch. Versions change only in the runner, with no version commits or tags; raise the baseline in `package.json` and the lockfile for a major/minor release. Already-published commits are skipped. Actions concurrency can replace pending pushes, so not every push (or every commit within a push) is guaranteed a separate package release.
|
|
173
|
+
|
|
174
|
+
One-time setup: publish the initial `@each1024/pi-mini-mode@1.3.1` package using an authenticated maintainer account, then configure its npm **Trusted Publisher** for GitHub owner `eachann1024`, repository `pi-mini-mode`, workflow `publish.yml` (no environment), allowing direct `npm publish`. Subsequent releases use OIDC and provenance, without an npm token.
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
[MIT License](LICENSE) · Built for [Pi](https://pi.dev)
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/mini-lens-hero.png" alt="Mini Lens for Pi — 会话状态,一眼清晰。紧凑底栏呈现模型、Token、缓存、费用、上下文与生成速度。" width="100%">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
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>
|
|
7
|
+
</p>
|
|
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 展开/收起、历史结果和窄屏,不调用模型。
|
|
27
|
+
|
|
28
|
+
## 安装
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pi install npm:@each1024/pi-mini-mode
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
在 Pi 中执行 `/reload` 即可加载。需要 **Pi ≥ 0.84.0**。
|
|
35
|
+
|
|
36
|
+
<details>
|
|
37
|
+
<summary>也可以从 GitHub 安装</summary>
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pi install git:github.com/eachann1024/pi-mini-mode
|
|
41
|
+
```
|
|
42
|
+
|
|
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` 自定义底栏,修改即时生效。
|
|
76
|
+
|
|
77
|
+
**自然融入终端。** 跟随 Pi 主题,适配窄窗口。仅替换底栏,保留 Pi 内置的工具与思考展示。
|
|
78
|
+
|
|
79
|
+
## 详细参考
|
|
80
|
+
|
|
81
|
+
<details>
|
|
82
|
+
<summary><strong>首次运行与配置</strong> — 默认值、操作方式和配置文件</summary>
|
|
83
|
+
|
|
84
|
+
首次在交互式 TUI 会话运行时,Mini Lens 会展示所有字段默认开启的预览:
|
|
85
|
+
|
|
86
|
+
```text
|
|
87
|
+
deepseek-v4-flash high Total 45K Cached 25K CH 40.0% $0.012 500/1.0M █░░░░░░░░░ 1% 120 tok/s
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
首次运行选择器提供 **Keep defaults** 和 **Configure now**。保持默认会持久化全部显示项均为开启,并不再重复提示;立即配置会直接打开同一份设置列表。print、JSON 等非交互模式绝不会弹出提示。
|
|
91
|
+
|
|
92
|
+
以后随时执行下面的命令打开设置界面:
|
|
93
|
+
|
|
94
|
+
```text
|
|
95
|
+
/mini-lens-settings
|
|
96
|
+
```
|
|
97
|
+
|
|
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
|
+
| `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>
|
|
141
|
+
|
|
142
|
+
<details>
|
|
143
|
+
<summary><strong>指标如何计算</strong> — Token、缓存、速度与预估费用</summary>
|
|
144
|
+
|
|
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)。只统计已持久化的最终用量,因此流式更新不会重复累计。
|
|
146
|
+
|
|
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 与本地副本会重复注册扩展:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
pi remove npm:@each1024/pi-mini-mode && pi install /path/to/pi-rolling-process
|
|
162
|
+
npm run check
|
|
163
|
+
npm test
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
修改源码后,在已打开的 Pi 会话中执行 `/reload`。`npm run check` 做 TypeScript 检查,`npm test` 运行底栏、设置交互和发布自检。
|
|
167
|
+
|
|
168
|
+
</details>
|
|
169
|
+
|
|
170
|
+
## 发布
|
|
171
|
+
|
|
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。
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
[MIT 许可证](LICENSE) · 为 [Pi](https://pi.dev) 而作
|