rinco-pi-hud 1.0.0

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.
Files changed (45) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +18 -0
  3. package/README.md +204 -0
  4. package/docs/CONTRIBUTING.md +110 -0
  5. package/docs/README.zh-CN.md +204 -0
  6. package/docs/footer.md +139 -0
  7. package/extensions/hud/commands/settings.ts +765 -0
  8. package/extensions/hud/config/config-counts.ts +87 -0
  9. package/extensions/hud/config/config.ts +65 -0
  10. package/extensions/hud/config/file-io.ts +128 -0
  11. package/extensions/hud/config/normalize.ts +374 -0
  12. package/extensions/hud/config/persist.ts +277 -0
  13. package/extensions/hud/config/schema.ts +303 -0
  14. package/extensions/hud/footer/format.ts +279 -0
  15. package/extensions/hud/footer/index.ts +543 -0
  16. package/extensions/hud/footer/layout.ts +183 -0
  17. package/extensions/hud/footer/render-labels.ts +305 -0
  18. package/extensions/hud/index.ts +466 -0
  19. package/extensions/hud/segments/extension-status.ts +88 -0
  20. package/extensions/hud/segments/git.ts +384 -0
  21. package/extensions/hud/segments/mcp-status.ts +25 -0
  22. package/extensions/hud/segments/package-version.ts +651 -0
  23. package/extensions/hud/segments/project-state.ts +67 -0
  24. package/extensions/hud/segments/runtime-definitions.ts +695 -0
  25. package/extensions/hud/segments/runtime.ts +167 -0
  26. package/extensions/hud/segments/skill-activity.ts +152 -0
  27. package/extensions/hud/session/context.ts +19 -0
  28. package/extensions/hud/session/lifecycle.ts +60 -0
  29. package/extensions/hud/session/live-context.ts +75 -0
  30. package/extensions/hud/state/index.ts +67 -0
  31. package/extensions/hud/state/project-refresh.ts +104 -0
  32. package/extensions/hud/state/telemetry.ts +261 -0
  33. package/extensions/hud/telemetry/codex-usage/LICENSE +21 -0
  34. package/extensions/hud/telemetry/codex-usage/app-server-client.ts +231 -0
  35. package/extensions/hud/telemetry/codex-usage/format.ts +278 -0
  36. package/extensions/hud/telemetry/codex-usage/index.ts +462 -0
  37. package/extensions/hud/telemetry/codex-usage/normalize.ts +264 -0
  38. package/extensions/hud/telemetry/codex-usage/query.ts +207 -0
  39. package/extensions/hud/telemetry/codex-usage/safety.ts +27 -0
  40. package/extensions/hud/telemetry/codex-usage/types.ts +137 -0
  41. package/extensions/hud/telemetry/format.ts +434 -0
  42. package/extensions/hud/telemetry/token-switch.ts +114 -0
  43. package/extensions/hud/ui/icons.ts +239 -0
  44. package/extensions/hud/ui/style.ts +276 -0
  45. package/package.json +56 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 rinco-pi-hud contributors
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/NOTICE ADDED
@@ -0,0 +1,18 @@
1
+ This package is a personal derivative of pi-sakura-cyberdeck by beautifulrem.
2
+ Original project: https://github.com/beautifulrem/pi-sakura-cyberdeck
3
+ License: MIT.
4
+
5
+ This package contains a dynamic HUD footer for Pi, adapted from the Footer
6
+ portion of pi-zentui by Luka: https://github.com/lmilojevicc/pi-zentui
7
+ License: MIT.
8
+
9
+ Session, model, activity, MCP, configuration-count, and Codex subscription
10
+ status capabilities are adapted from pi-shannon-statusline by RealAlexandreAI:
11
+ https://github.com/RealAlexandreAI/pi-shannon-statusline
12
+ License: MIT. The integrated presentation has been rewritten for the HUD footer;
13
+ Shannon's HUD, Matrix animation, independent Footer, and Monokai palette are
14
+ not included.
15
+
16
+ The Codex usage client included under extensions/hud/telemetry/codex-usage
17
+ derives from pi-codex-usage by narumiruna and is MIT licensed. Its full license
18
+ text is kept at extensions/hud/telemetry/codex-usage/LICENSE.
package/README.md ADDED
@@ -0,0 +1,204 @@
1
+ <div align="center">
2
+
3
+ # Rinco Pi HUD
4
+
5
+ **A dynamic HUD footer for [Pi](https://github.com/earendil-works/pi).**
6
+
7
+ [![Pi package](https://img.shields.io/badge/Pi-package-F2A7C6?style=flat-square)](https://github.com/earendil-works/pi) [![TypeScript](https://img.shields.io/badge/TypeScript-5.9-3178C6?style=flat-square&logo=typescript&logoColor=white)](https://www.typescriptlang.org/) [![Tests](https://img.shields.io/badge/tests-Vitest-6E9F18?style=flat-square&logo=vitest&logoColor=white)](https://vitest.dev/) [![License](https://img.shields.io/badge/license-MIT-C7B8F5?style=flat-square)](LICENSE)
8
+
9
+ [Features](#features) · [Installation](#installation) · [Usage](#usage) · [Customization](#customization) · [Development](#development)
10
+
11
+ [简体中文](docs/README.zh-CN.md)
12
+
13
+ </div>
14
+
15
+ Rinco Pi HUD provides a rich, real-time status footer for Pi TUI sessions. It displays project state, Git metrics, runtime versions, session activity, model usage, token costs, and more — all in a configurable three-line or single-line layout. Pi loads the TypeScript extension directly, so no build step is required (`tsconfig.json` sets `noEmit: true` and is used only for `npm run typecheck`).
16
+
17
+ ## Features
18
+
19
+ - **Project state** — Working directory, Git branch, commit, tag, status, diff metrics, and runtime versions.
20
+ - **Session activity** — Model, provider, context usage, tokens, cache, session cost, turn count, and thinking level.
21
+ - **Tool and agent activity** — Native tool completion counts, running tools, active agent runs, skills, and MCP server status.
22
+ - **Model quota** — Automatic Codex weekly quota or Token Switch balance display by model provider.
23
+ - **Git awareness** — Branches, detached HEAD, tags, ahead/behind, stash, merge/rebase conflicts, and dirty state.
24
+ - **Runtime detection** — Node, Python, Go, Rust, Java, and 60+ other runtimes with package version parsing.
25
+ - **Configurable layout** — Three-line categorized layout by default, or fully customizable single-line templates.
26
+ - **Extension statuses** — Reads third-party extension statuses and places them by configurable position and color mode.
27
+ - **Safe fallback** — Graceful timeout and error handling; no stale data after session shutdown.
28
+
29
+ ## Installation
30
+
31
+ ### Install from npm (recommended)
32
+
33
+ ```bash
34
+ pi install npm:rinco-pi-hud
35
+ ```
36
+
37
+ The published package is available on [npm](https://www.npmjs.com/package/rinco-pi-hud).
38
+
39
+ ### Install from GitHub
40
+
41
+ ```bash
42
+ pi install git:github.com/Rinisnotarobot/rinco-pi-hud
43
+ ```
44
+
45
+ ### Install from a local checkout
46
+
47
+ ```bash
48
+ git clone https://github.com/Rinisnotarobot/rinco-pi-hud.git
49
+ cd rinco-pi-hud
50
+ pi install "$PWD"
51
+ ```
52
+
53
+ > [!IMPORTANT]
54
+ > Pi extensions run with your user permissions. Review the source before installing any third-party extension.
55
+
56
+ ## Usage
57
+
58
+ Restart Pi after installation, or run:
59
+
60
+ ```text
61
+ /reload
62
+ ```
63
+
64
+ The HUD footer is enabled by default. Run `/zentui` to open the interactive settings UI.
65
+
66
+ ### Common commands
67
+
68
+ ```text
69
+ /zentui statusline enable
70
+ /zentui statusline disable
71
+ /zentui statusline toggle
72
+ /zentui format clear
73
+ /zentui format "$model · $context · $cost · $git_branch( $git_commit) · $session_duration"
74
+ /codex-status
75
+ /usage-refresh
76
+ ```
77
+
78
+ > [!NOTE]
79
+ > For the best result, use a Truecolor terminal and a Nerd Font. The footer uses Unicode glyphs that render best with proper font support.
80
+
81
+ ## Project contents
82
+
83
+ | Path | Purpose |
84
+ | --- | --- |
85
+ | [`extensions/hud/index.ts`](extensions/hud/index.ts) | Extension lifecycle and side-effect orchestration |
86
+ | [`extensions/hud/config/`](extensions/hud/config/config.ts) | Configuration model, normalization, and persistence |
87
+ | [`extensions/hud/footer/`](extensions/hud/footer/index.ts) | Footer rendering, categorized layout, and template parsing |
88
+ | [`extensions/hud/segments/`](extensions/hud/segments/) | State collectors: Git, runtime, MCP, skills, projects, etc. |
89
+ | [`extensions/hud/telemetry/`](extensions/hud/telemetry/format.ts) | Usage formatting, token switch, and Codex subscription client |
90
+ | [`extensions/hud/session/`](extensions/hud/session/) | Session lifecycle, context, and live context overlay |
91
+ | [`extensions/hud/state/`](extensions/hud/state/) | Aggregated state, telemetry, and project refresh |
92
+ | [`extensions/hud/commands/`](extensions/hud/commands/settings.ts) | `/zentui` command and interactive TUI settings |
93
+ | [`extensions/hud/ui/`](extensions/hud/ui/) | Icons and terminal style utilities |
94
+ | [`docs/footer.md`](docs/footer.md) | Complete footer configuration reference |
95
+ | [`docs/CONTRIBUTING.md`](docs/CONTRIBUTING.md) | Local development, testing guidance, and pull request checklist |
96
+ | [`tests/`](tests/) | Vitest test suite (34+ tests across 6 files) |
97
+
98
+ ## Customization
99
+
100
+ ### Layout
101
+
102
+ The default three-line layout groups project, session, and usage information. Set `footerFormat` to a template string for a single-line layout:
103
+
104
+ ```text
105
+ /zentui format "$cwd( $git_branch)$fill($context)( $tokens)( $cost)"
106
+ ```
107
+
108
+ Template variables use `$name` or `${name}` syntax. See the [footer reference](docs/footer.md) for the complete variable list.
109
+
110
+ ### Segments
111
+
112
+ Enable or disable individual status segments via `/zentui`:
113
+
114
+ ```text
115
+ /zentui statusline enable
116
+ /zentui statusline disable
117
+ /zentui statusline toggle
118
+ ```
119
+
120
+ ### Extension statuses
121
+
122
+ Third-party extensions publish statuses that the HUD footer can display. Configure placement (`left`, `middle`, `right`, `off`) and color mode (`zentui`, `original`) for each extension status key.
123
+
124
+ ## Development
125
+
126
+ ### Prerequisites
127
+
128
+ - [Node.js](https://nodejs.org/) 22.19 or later
129
+ - [Pi](https://github.com/earendil-works/pi)
130
+
131
+ Install development dependencies:
132
+
133
+ ```bash
134
+ npm install
135
+ ```
136
+
137
+ ### Available commands
138
+
139
+ <!-- AUTO-GENERATED: package-scripts:start -->
140
+ <!-- Source: package.json#scripts. Do not edit manually. -->
141
+
142
+ | Command | Description |
143
+ | --- | --- |
144
+ | `npm test` | Run the complete Vitest suite once. |
145
+ | `npm run test:watch` | Run Vitest in watch mode and retest when files change. |
146
+ | `npm run typecheck` | Run TypeScript type checking with `tsc --noEmit`. |
147
+ | `npm run pack:check` | Inspect the publishable package with `npm pack --dry-run` without publishing it. |
148
+
149
+ <!-- AUTO-GENERATED: package-scripts:end -->
150
+
151
+ Run the test suite:
152
+
153
+ ```bash
154
+ npm test
155
+ ```
156
+
157
+ Check types:
158
+
159
+ ```bash
160
+ npm run typecheck
161
+ ```
162
+
163
+ Verify tests and package contents:
164
+
165
+ ```bash
166
+ npm test
167
+ npm run typecheck
168
+ npm run pack:check
169
+ ```
170
+
171
+ Vitest covers footer layout, telemetry, codex usage, token switch, config counts, and MCP status parsing. Pi loads the TypeScript source directly, so this project has no separate build command.
172
+
173
+ ## Troubleshooting
174
+
175
+ ### The footer does not appear
176
+
177
+ 1. Confirm that Pi is running in TUI mode rather than headless, JSON, or print mode.
178
+ 2. Run `/reload` or restart Pi.
179
+ 3. Run `pi list` to confirm that the package is installed.
180
+
181
+ ### The footer layout looks wrong
182
+
183
+ The footer auto-detects terminal width and truncates content. In narrow terminals, some segments may be clipped. Adjust the layout by setting a custom `footerFormat` template, or disable low-priority segments in `/zentui`.
184
+
185
+ ### Colors look incorrect
186
+
187
+ Make sure your terminal supports Truecolor. The footer emits `38;2;r;g;b` ANSI sequences.
188
+
189
+ ### Unicode icons are missing or misaligned
190
+
191
+ Unicode and Nerd Font glyphs vary between terminals and fonts. Install a Nerd Font, or switch to ASCII icon mode via `/zentui`.
192
+
193
+ ## Third-party licenses
194
+
195
+ This package incorporates work from the following open-source projects:
196
+
197
+ - **pi-zentui** by Luka — MIT licensed. The Footer portion was adapted for this package.
198
+ Source: https://github.com/lmilojevicc/pi-zentui
199
+ - **pi-shannon-statusline** by RealAlexandreAI — MIT licensed. Session, model, activity, MCP, configuration-count, and Codex subscription capabilities were adapted.
200
+ Source: https://github.com/RealAlexandreAI/pi-shannon-statusline
201
+ - **pi-codex-usage** by narumiruna — MIT licensed. The Codex usage client under `extensions/hud/telemetry/codex-usage/` derives from this project.
202
+ Source: https://github.com/narumiruna/pi-codex-usage
203
+
204
+ See [NOTICE](NOTICE) for details.
@@ -0,0 +1,110 @@
1
+ # Contributing
2
+
3
+ Thank you for helping improve Rinco Pi HUD. This guide describes the local development, testing, and submission workflow.
4
+
5
+ ## Development environment
6
+
7
+ Before you begin, install:
8
+
9
+ - Node.js 22.19 or later
10
+ - npm
11
+ - Pi, for validating the HUD footer in a real TUI
12
+
13
+ Clone the project and install its dependencies:
14
+
15
+ ```bash
16
+ git clone https://github.com/Rinisnotarobot/rinco-pi-hud.git
17
+ cd rinco-pi-hud
18
+ npm install
19
+ ```
20
+
21
+ Pi loads the TypeScript extension directly, so this project has no separate build step. Accordingly, `tsconfig.json` sets `noEmit: true` — it is used only for type checking (`npm run typecheck`), never for compiling output.
22
+
23
+ ## Available commands
24
+
25
+ <!-- AUTO-GENERATED: package-scripts:start -->
26
+ <!-- Source: package.json#scripts. Do not edit manually. -->
27
+
28
+ | Command | Description |
29
+ | --- | --- |
30
+ | `npm test` | Run the complete Vitest suite once. |
31
+ | `npm run test:watch` | Run Vitest in watch mode and retest when files change. |
32
+ | `npm run typecheck` | Run TypeScript type checking with `tsc --noEmit`. |
33
+ | `npm run pack:check` | Inspect the publishable package with `npm pack --dry-run` without publishing it. |
34
+
35
+ <!-- AUTO-GENERATED: package-scripts:end -->
36
+
37
+ ## Testing
38
+
39
+ Before submitting a change, run:
40
+
41
+ ```bash
42
+ npm test
43
+ npm run typecheck
44
+ npm run pack:check
45
+ ```
46
+
47
+ Tests live in `tests/`:
48
+
49
+ - `zentui-status.test.ts` — Config counts, MCP status parsing, and extension status helpers.
50
+ - `codex-usage.test.ts` — Codex payload normalization and model-specific quota formatting.
51
+ - `footer-layout.test.ts` — Categorized three-line layout and narrow-width budget.
52
+ - `model-switch-statusline.test.ts` — Model switch statusline integration.
53
+ - `model-usage-refresh.test.ts` — Model usage refresh integration.
54
+ - `token-switch-usage.test.ts` — Token Switch balance formatting.
55
+
56
+ When adding tests:
57
+
58
+ 1. Use Vitest's `describe`, `it`, and `expect` APIs.
59
+ 2. Name files `*.test.ts` and place them in `tests/`.
60
+ 3. Prefer user-observable behavior over internal implementation details.
61
+ 4. Use Vitest fake timers for timer-dependent behavior and restore them after each test.
62
+ 5. Keep tests isolated from one another and independent of a real terminal.
63
+
64
+ In addition to automated tests, validate HUD behavior in a real Pi TUI across different terminal widths, model switches, and project types.
65
+
66
+ ## Code style
67
+
68
+ The project currently has no configured linter, formatter, or pre-commit hook. Follow the existing conventions:
69
+
70
+ - Use TypeScript ESM and explicit types.
71
+ - Use two-space indentation, double quotes, and semicolons.
72
+ - Keep extension lifecycle handling clear and release timers and UI state during `session_shutdown`.
73
+ - Do not edit content enclosed by `AUTO-GENERATED` markers manually; regenerate it from the source identified in the marker.
74
+
75
+ Do not add ignore rules, skip tests, or weaken types merely to bypass a check.
76
+
77
+ ## Architecture notes
78
+
79
+ The HUD extension is organized into functional modules under `extensions/hud/`:
80
+
81
+ - **`index.ts`** — Lifecycle and side-effect orchestration.
82
+ - **`config/`** — Configuration model, normalization, and persistence.
83
+ - **`footer/`** — Footer rendering, categorized layout, and template parsing.
84
+ - **`segments/`** — State collectors: Git, runtime, MCP, skills, projects, etc.
85
+ - **`telemetry/`** — Usage formatting, token switch, and Codex subscription client.
86
+ - **`session/`** — Session lifecycle, context, and live context overlay.
87
+ - **`state/`** — Aggregated state, telemetry, and project refresh.
88
+ - **`commands/`** — `/zentui` command and interactive TUI settings.
89
+ - **`ui/`** — Icons and terminal style utilities.
90
+
91
+ Key conventions:
92
+
93
+ - Keep event listeners and side-effects in `index.ts`; do not read files or spawn processes in `render()`.
94
+ - Async results check session generation before applying.
95
+ - Timers should be cleaned up on shutdown and `unref()` where possible.
96
+ - State collectors return explicit `ok` / `error` / `not found` semantics.
97
+ - Use `visibleWidth()` and `truncateToWidth()` for terminal width calculations.
98
+
99
+ ## Pull request checklist
100
+
101
+ Before opening a pull request, confirm that:
102
+
103
+ - [ ] The change has a focused scope and contains no unrelated files.
104
+ - [ ] New behavior or bug fixes include appropriate tests.
105
+ - [ ] `npm test` passes.
106
+ - [ ] `npm run typecheck` passes.
107
+ - [ ] `npm run pack:check` passes and the package contains the expected files.
108
+ - [ ] Affected HUD behavior was verified in a real Pi TUI.
109
+ - [ ] Related documentation was synchronized from its source of truth.
110
+ - [ ] No `node_modules/`, `.tgz` archives, or sensitive data were committed.
@@ -0,0 +1,204 @@
1
+ <div align="center">
2
+
3
+ # Rinco Pi HUD
4
+
5
+ **为 [Pi](https://github.com/earendil-works/pi) 打造的动态 HUD 脚注。**
6
+
7
+ [![Pi package](https://img.shields.io/badge/Pi-package-F2A7C6?style=flat-square)](https://github.com/earendil-works/pi) [![TypeScript](https://img.shields.io/badge/TypeScript-5.9-3178C6?style=flat-square&logo=typescript&logoColor=white)](https://www.typescriptlang.org/) [![Tests](https://img.shields.io/badge/tests-Vitest-6E9F18?style=flat-square&logo=vitest&logoColor=white)](https://vitest.dev/) [![License](https://img.shields.io/badge/license-MIT-C7B8F5?style=flat-square)](../LICENSE)
8
+
9
+ [功能](#功能) · [安装](#安装) · [使用](#使用) · [定制](#定制) · [开发](#开发)
10
+
11
+ [English](../README.md)
12
+
13
+ </div>
14
+
15
+ Rinco Pi HUD 为 Pi TUI 会话提供丰富的实时状态脚注,可显示项目状态、Git 指标、运行时版本、会话活动、模型用量、Token 费用等信息,支持可配置的三行或单行布局。Pi 可直接加载 TypeScript 扩展,无需构建步骤(`tsconfig.json` 设置了 `noEmit: true`,仅用于 `npm run typecheck` 类型检查)。
16
+
17
+ ## 功能
18
+
19
+ - **Project state**:当前目录、Git 分支、Commit、Tag、工作区状态、差异指标和运行时版本。
20
+ - **Session activity**:模型、Provider、Context 用量、Token、缓存、会话费用、轮次和 Thinking 等级。
21
+ - **Tool and agent activity**:Native Tool 完成次数、正在运行的 Tool、活跃 Agent 数、Skill 和 MCP Server 状态。
22
+ - **Model quota**:根据当前模型自动切换 Codex 周限额或 Token Switch 余额。
23
+ - **Git awareness**:分支、Detached HEAD、Tag、Ahead/Behind、Stash、合并冲突和脏状态。
24
+ - **Runtime detection**:支持 Node、Python、Go、Rust、Java 等 60+ 运行时,并解析项目清单版本。
25
+ - **Configurable layout**:默认三行分类布局,或完全自定义的单行模板。
26
+ - **Extension statuses**:读取第三方扩展发布的状态,按配置的位置和颜色模式显示。
27
+ - **Safe fallback**:超时和错误处理优雅,会话关闭后不留过期数据。
28
+
29
+ ## 安装
30
+
31
+ ### 从 npm 安装(推荐)
32
+
33
+ ```bash
34
+ pi install npm:rinco-pi-hud
35
+ ```
36
+
37
+ 该包已发布至 [npm](https://www.npmjs.com/package/rinco-pi-hud)。
38
+
39
+ ### 从 GitHub 安装
40
+
41
+ ```bash
42
+ pi install git:github.com/Rinisnotarobot/rinco-pi-hud
43
+ ```
44
+
45
+ ### 从本地目录安装
46
+
47
+ ```bash
48
+ git clone https://github.com/Rinisnotarobot/rinco-pi-hud.git
49
+ cd rinco-pi-hud
50
+ pi install "$PWD"
51
+ ```
52
+
53
+ > [!IMPORTANT]
54
+ > Pi 扩展以当前用户权限运行。安装任何第三方扩展前,请先审查其源码。
55
+
56
+ ## 使用
57
+
58
+ 安装后重启 Pi,或执行:
59
+
60
+ ```text
61
+ /reload
62
+ ```
63
+
64
+ HUD 脚注默认启用。运行 `/zentui` 打开交互式设置。
65
+
66
+ ### 常用命令
67
+
68
+ ```text
69
+ /zentui statusline enable
70
+ /zentui statusline disable
71
+ /zentui statusline toggle
72
+ /zentui format clear
73
+ /zentui format "$model · $context · $cost · $git_branch( $git_commit) · $session_duration"
74
+ /codex-status
75
+ /usage-refresh
76
+ ```
77
+
78
+ > [!NOTE]
79
+ > 最佳显示效果需要支持 Truecolor 的终端和 Nerd Font。脚注使用 Unicode 符号,需要合适的字体支持。
80
+
81
+ ## 包含内容
82
+
83
+ | 路径 | 说明 |
84
+ | --- | --- |
85
+ | [`extensions/hud/index.ts`](../extensions/hud/index.ts) | 扩展生命周期与副作用编排 |
86
+ | [`extensions/hud/config/`](../extensions/hud/config/config.ts) | 配置模型、归一化与持久化 |
87
+ | [`extensions/hud/footer/`](../extensions/hud/footer/index.ts) | 脚注渲染、分类布局与模板解析 |
88
+ | [`extensions/hud/segments/`](../extensions/hud/segments/) | 状态采集器:Git、运行时、MCP、Skill、项目等 |
89
+ | [`extensions/hud/telemetry/`](../extensions/hud/telemetry/format.ts) | 用量格式化、Token Switch 与 Codex 订阅客户端 |
90
+ | [`extensions/hud/session/`](../extensions/hud/session/) | 会话生命周期、上下文与实时上下文覆盖 |
91
+ | [`extensions/hud/state/`](../extensions/hud/state/) | 聚合状态、遥测与项目刷新 |
92
+ | [`extensions/hud/commands/`](../extensions/hud/commands/settings.ts) | `/zentui` 命令与交互式 TUI 设置 |
93
+ | [`extensions/hud/ui/`](../extensions/hud/ui/) | 图标与终端样式工具 |
94
+ | [`docs/footer.md`](footer.md) | 完整脚注配置参考 |
95
+ | [`docs/CONTRIBUTING.md`](CONTRIBUTING.md) | 本地开发、测试规范和 PR 检查清单 |
96
+ | [`tests/`](../tests/) | Vitest 测试套件(34+ 测试用例,6 个文件) |
97
+
98
+ ## 定制
99
+
100
+ ### 布局
101
+
102
+ 默认三行布局将项目、会话和用量信息分组显示。设置 `footerFormat` 模板字符串可切换为单行布局:
103
+
104
+ ```text
105
+ /zentui format "$cwd( $git_branch)$fill($context)( $tokens)( $cost)"
106
+ ```
107
+
108
+ 模板变量使用 `$name` 或 `${name}` 语法。完整变量列表见[脚注参考](footer.md)。
109
+
110
+ ### 状态段
111
+
112
+ 通过 `/zentui` 启用或禁用单个状态段:
113
+
114
+ ```text
115
+ /zentui statusline enable
116
+ /zentui statusline disable
117
+ /zentui statusline toggle
118
+ ```
119
+
120
+ ### 扩展状态
121
+
122
+ 第三方扩展发布的状态可由 HUD 脚注显示。可为每个扩展状态键配置位置(`left`、`middle`、`right`、`off`)和颜色模式(`zentui`、`original`)。
123
+
124
+ ## 开发
125
+
126
+ ### 环境要求
127
+
128
+ - [Node.js](https://nodejs.org/) 22.19 或更高版本
129
+ - [Pi](https://github.com/earendil-works/pi)
130
+
131
+ 安装开发依赖:
132
+
133
+ ```bash
134
+ npm install
135
+ ```
136
+
137
+ ### 可用命令
138
+
139
+ <!-- AUTO-GENERATED: package-scripts:start -->
140
+ <!-- Source: package.json#scripts. Do not edit manually. -->
141
+
142
+ | 命令 | 说明 |
143
+ | --- | --- |
144
+ | `npm test` | 使用 Vitest 运行一次完整测试套件。 |
145
+ | `npm run test:watch` | 以监听模式运行 Vitest,并在文件变化后重新测试。 |
146
+ | `npm run typecheck` | 使用 `tsc --noEmit` 运行 TypeScript 类型检查。 |
147
+ | `npm run pack:check` | 使用 `npm pack --dry-run` 检查发布包内容,不生成正式发布。 |
148
+
149
+ <!-- AUTO-GENERATED: package-scripts:end -->
150
+
151
+ 运行测试:
152
+
153
+ ```bash
154
+ npm test
155
+ ```
156
+
157
+ 类型检查:
158
+
159
+ ```bash
160
+ npm run typecheck
161
+ ```
162
+
163
+ 验证测试与发布内容:
164
+
165
+ ```bash
166
+ npm test
167
+ npm run typecheck
168
+ npm run pack:check
169
+ ```
170
+
171
+ 本项目使用 Vitest 测试脚注布局、遥测、Codex 用量、Token Switch、配置统计和 MCP 状态解析。Pi 运行时会直接加载 TypeScript 源码,因此没有单独的构建命令。
172
+
173
+ ## 常见问题
174
+
175
+ ### 脚注没有显示
176
+
177
+ 1. 确认当前运行在 Pi TUI 模式,而不是 Headless、JSON 或 Print 模式。
178
+ 2. 执行 `/reload` 或重启 Pi。
179
+ 3. 使用 `pi list` 确认包已安装。
180
+
181
+ ### 脚注布局异常
182
+
183
+ 脚注会自动检测终端宽度并截断内容。在窄终端中,部分状态段可能被裁剪。可通过设置自定义 `footerFormat` 模板调整布局,或在 `/zentui` 中关闭低优先级段。
184
+
185
+ ### 颜色显示异常
186
+
187
+ 确认终端已启用 Truecolor。脚注使用 `38;2;r;g;b` ANSI 序列。
188
+
189
+ ### Unicode 图标缺失或错位
190
+
191
+ Unicode 和 Nerd Font 符号的显示效果因终端和字体而异。建议安装 Nerd Font,或在 `/zentui` 中切换到 ASCII 图标模式。
192
+
193
+ ## 第三方许可证
194
+
195
+ 本包包含以下开源项目的衍生作品:
196
+
197
+ - **pi-zentui**(Luka)— MIT 许可。脚注部分经改编后用于本包。
198
+ 源码:https://github.com/lmilojevicc/pi-zentui
199
+ - **pi-shannon-statusline**(RealAlexandreAI)— MIT 许可。会话、模型、活动、MCP、配置统计和 Codex 订阅功能改编自该项目。
200
+ 源码:https://github.com/RealAlexandreAI/pi-shannon-statusline
201
+ - **pi-codex-usage**(narumiruna)— MIT 许可。`extensions/hud/telemetry/codex-usage/` 下的 Codex 用量客户端衍生自该项目。
202
+ 源码:https://github.com/narumiruna/pi-codex-usage
203
+
204
+ 详见 [NOTICE](../NOTICE)。