pi-ui-extension 1.1.1 → 1.1.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.
Files changed (3) hide show
  1. package/README.md +355 -12
  2. package/README.zh-CN.md +386 -0
  3. package/package.json +15 -4
package/README.md CHANGED
@@ -1,13 +1,271 @@
1
+ [English](README.md) | [简体中文](README.zh-CN.md)
2
+
1
3
  # pi-ui-extension
2
4
 
3
- A Pi package that extends the terminal UI with a footer, split-view sidebar, context/activity panels, session controls, resource views, and configurable tool transcript rendering.
5
+ `pi-ui-extension` is a terminal UI enhancement package for [Pi Coding Agent](https://github.com/earendil-works/pi). It adds a right-side information sidebar, session management, context inspection, tool/MCP usage tracking, and a compact footer without modifying Pi Core.
4
6
 
5
- ## Requirements
7
+ The package can be installed from npm or Git, and uses GitHub Actions for type checking, automated tests, and npm Trusted Publishing via OIDC.
8
+
9
+ ## Preview
10
+
11
+ <img width="1377" height="671" alt="pi-ui-extension preview" src="https://github.com/user-attachments/assets/ddea5dc9-8796-433a-abfc-c7ea2adec089" />
12
+
13
+ ## Features
14
+
15
+ ### 1. Right-side Sidebar
16
+
17
+ The extension mounts a right-side sidebar in Pi's fullscreen TUI. It contains three default panels:
18
+
19
+ - **SESSIONS**: recent sessions and resource shortcuts.
20
+ - **CTX**: model, context window, composition estimates, and runtime performance.
21
+ - **TOOL VIEW**: tool transcript display modes and Tool/MCP usage statistics.
22
+
23
+ The sidebar supports mouse interaction, wheel scrolling, and terminal resize handling. Panels shrink or become scrollable when vertical space is limited.
24
+
25
+ > The sidebar depends on Pi fullscreen TUI mode. In non-fullscreen mode, the extension degrades safely and does not force layout replacement.
26
+
27
+ ### 2. Session management
28
+
29
+ The `SESSIONS` panel provides quick access to recent sessions:
30
+
31
+ - Click a session to switch to it.
32
+ - Rename a non-current session.
33
+ - Delete a non-current session.
34
+ - Use the `⊗` action to remove all other sessions.
35
+ - Click `SESSIONS ↻` to refresh the session list.
36
+
37
+ To avoid corrupting active agent state, switching, renaming, deleting, and bulk cleanup are only allowed while Pi is idle. The current session cannot be deleted.
38
+
39
+ ### 3. Resource shortcuts
40
+
41
+ The bottom of the `SESSIONS` panel exposes four resource categories:
42
+
43
+ - `AGENTS.md`
44
+ - `Skills`
45
+ - `Extensions`
46
+ - `MCP`
47
+
48
+ These shortcuts let you inspect the resources currently loaded by the project/Pi environment, making it easier to verify which agent instructions, skills, extensions, and MCP servers are actually available.
49
+
50
+ ### 4. CTX context inspection
51
+
52
+ The `CTX` panel shows context and runtime information for the current model request, including:
6
53
 
7
- - Node.js 24+
8
- - A compatible Pi Coding Agent installation
54
+ - Current model name.
55
+ - Thinking level.
56
+ - Pi context usage / context window.
57
+ - Current-question context delta relative to the previous settled state.
58
+ - Context composition estimates.
59
+ - Image count.
60
+ - Turn count and run duration.
61
+ - Average TTFT (Time To First Token).
62
+ - Average TPS (Tokens Per Second).
63
+ - Latest observed TTFT with speed label.
64
+ - Cache-related metrics when observable.
65
+
66
+ Context composition is grouped into:
67
+
68
+ - `System`
69
+ - `Tools`
70
+ - `Messages`
71
+ - `Tool Results`
72
+ - `Summary`
73
+ - `Other`
74
+
75
+ Token counts are local heuristic estimates intended for composition and trend visibility. They are **not** provider-accurate tokenizer results and are not billing-token counts.
76
+
77
+ For tool definitions, the extension prefers the observable provider-request tool payload when available. Before a provider request exists, it falls back to estimating the schemas of Pi's currently enabled tools.
78
+
79
+ ### 5. Tool View modes
80
+
81
+ `TOOL VIEW` supports three transcript display modes:
82
+
83
+ - **Normal**: standard tool transcript rendering.
84
+ - **Compact**: denser tool output rendering.
85
+ - **Hidden**: hide tool transcripts.
86
+
87
+ Modes can be changed directly with mouse clicks.
88
+
89
+ When Fabric takes ownership of tool rendering, the panel remains visible for usage statistics but the local mode selector is hidden and replaced with `View controlled by Fabric`. This avoids conflicting display control.
90
+
91
+ ### 6. Tool / MCP usage statistics
92
+
93
+ Tool View groups usage into:
94
+
95
+ - `TOOLS`
96
+ - `MCP`
97
+
98
+ Each entry is shown as:
99
+
100
+ ```text
101
+ current-question calls / current-session calls
102
+ ```
103
+
104
+ Example:
105
+
106
+ ```text
107
+ task_todos 1/5
108
+ ```
9
109
 
10
- ## Development
110
+ Usage state is rebuilt when the active branch changes, so restored sessions and branch switches do not blindly reuse counts from another branch.
111
+
112
+ For calls made through MCP gateways, `mcpScript`, and similar wrappers, the extension attempts to attribute activity to the actual MCP server instead of counting only the outer wrapper tool.
113
+
114
+ ### 7. Footer
115
+
116
+ The extension replaces the default footer with a compact view that displays:
117
+
118
+ - Current working directory.
119
+ - Current Git branch, when available.
120
+
121
+ The path is automatically truncated to fit terminal width.
122
+
123
+ ## Pi Package Catalog
124
+
125
+ This package is published to npm with the `pi-package` keyword and a Pi manifest, so it can be discovered by the Pi package catalog at `pi.dev/packages`. The package metadata also declares the preview image shown above for catalog/gallery presentation.
126
+
127
+ ## Installation
128
+
129
+ ### Recommended: install from npm
130
+
131
+ ```bash
132
+ pi install npm:pi-ui-extension
133
+ ```
134
+
135
+ Pi installs the package and writes the declaration to:
136
+
137
+ ```text
138
+ ~/.pi/agent/settings.json
139
+ ```
140
+
141
+ Example configuration:
142
+
143
+ ```json
144
+ {
145
+ "packages": [
146
+ "npm:pi-ui-extension"
147
+ ]
148
+ }
149
+ ```
150
+
151
+ To pin a specific version:
152
+
153
+ ```bash
154
+ pi install npm:pi-ui-extension@1.1.1
155
+ ```
156
+
157
+ or:
158
+
159
+ ```json
160
+ {
161
+ "packages": [
162
+ "npm:pi-ui-extension@1.1.1"
163
+ ]
164
+ }
165
+ ```
166
+
167
+ Pinned packages do not automatically move to newer versions.
168
+
169
+ ### Install from GitHub
170
+
171
+ You can also install directly from the Git repository:
172
+
173
+ ```bash
174
+ pi install git:github.com/1993yihuan/pi-ui-extension
175
+ ```
176
+
177
+ Configuration form:
178
+
179
+ ```json
180
+ {
181
+ "packages": [
182
+ "git:github.com/1993yihuan/pi-ui-extension"
183
+ ]
184
+ }
185
+ ```
186
+
187
+ Pin to a Git tag:
188
+
189
+ ```bash
190
+ pi install git:github.com/1993yihuan/pi-ui-extension@v1.1.1
191
+ ```
192
+
193
+ ### Temporary usage
194
+
195
+ To load the package for a single Pi launch without modifying `settings.json`:
196
+
197
+ ```bash
198
+ pi -e npm:pi-ui-extension
199
+ ```
200
+
201
+ ### Project-local installation
202
+
203
+ To enable the package only for the current project:
204
+
205
+ ```bash
206
+ pi install --local npm:pi-ui-extension
207
+ ```
208
+
209
+ The declaration is written to:
210
+
211
+ ```text
212
+ <project>/.pi/settings.json
213
+ ```
214
+
215
+ Project-local packages are loaded only after the project is trusted by Pi.
216
+
217
+ ## Update and removal
218
+
219
+ Update unpinned extensions:
220
+
221
+ ```bash
222
+ pi update --extensions
223
+ ```
224
+
225
+ List configured packages:
226
+
227
+ ```bash
228
+ pi list
229
+ ```
230
+
231
+ Remove the npm source:
232
+
233
+ ```bash
234
+ pi remove npm:pi-ui-extension
235
+ ```
236
+
237
+ If installed from Git, remove the corresponding Git source:
238
+
239
+ ```bash
240
+ pi remove git:github.com/1993yihuan/pi-ui-extension
241
+ ```
242
+
243
+ ## npm or Git?
244
+
245
+ For normal usage, npm is recommended:
246
+
247
+ ```text
248
+ npm:pi-ui-extension
249
+ ```
250
+
251
+ It provides clear SemVer versioning, predictable installation, and easy version pinning.
252
+
253
+ Use Git when you want to follow the latest repository state or test changes that have not yet been published to npm:
254
+
255
+ ```text
256
+ git:github.com/1993yihuan/pi-ui-extension
257
+ ```
258
+
259
+ For active local development, loading a local checkout is usually faster than committing, pushing, and updating on every change.
260
+
261
+ ## Local development
262
+
263
+ Clone the repository:
264
+
265
+ ```bash
266
+ git clone https://github.com/1993yihuan/pi-ui-extension.git
267
+ cd pi-ui-extension
268
+ ```
11
269
 
12
270
  Install dependencies:
13
271
 
@@ -21,23 +279,108 @@ Run the full validation suite:
21
279
  npm run check
22
280
  ```
23
281
 
24
- Or run checks separately:
282
+ Equivalent commands:
25
283
 
26
284
  ```bash
27
285
  npm run typecheck
28
286
  npm test
29
287
  ```
30
288
 
31
- ## Package entry
289
+ The test suite covers the main behavior of Sidebar, CTX, Session management, Tool View, MCP resources, Fabric detection, mouse scrolling, and resize handling.
290
+
291
+ During development, Pi can load the local source directory directly:
292
+
293
+ ```bash
294
+ pi install ./path/to/pi-ui-extension
295
+ ```
296
+
297
+ Or load it temporarily for one run:
298
+
299
+ ```bash
300
+ pi -e ./path/to/pi-ui-extension
301
+ ```
32
302
 
33
- Pi loads the extension from:
303
+ ## Package structure
34
304
 
35
305
  ```text
36
- ./extensions/index.ts
306
+ pi-ui-extension/
307
+ ├── extensions/
308
+ │ ├── ctx/ # Context composition, delta, runtime metrics
309
+ │ ├── footer/ # Footer
310
+ │ ├── mcp/ # MCP resource / usage integration
311
+ │ ├── session/ # Session list and actions
312
+ │ ├── sidebar/ # Sidebar layout, scrolling, resize
313
+ │ ├── tool-view/ # Tool View modes and usage statistics
314
+ │ ├── fabric-detection.ts # Fabric ownership detection
315
+ │ └── index.ts # Pi Extension entry point
316
+ ├── .github/workflows/
317
+ │ ├── ci.yml # Automatic checks on push / PR
318
+ │ └── release.yml # npm publishing + GitHub Release on tags
319
+ ├── package.json
320
+ └── tsconfig.check.json
321
+ ```
322
+
323
+ Pi's extension entry point is declared explicitly in `package.json`:
324
+
325
+ ```json
326
+ {
327
+ "pi": {
328
+ "extensions": [
329
+ "./extensions/index.ts"
330
+ ]
331
+ }
332
+ }
37
333
  ```
38
334
 
39
- The package metadata is declared in `package.json` under the `pi.extensions` field.
335
+ ## CI / Release
336
+
337
+ Every push to `main` and every pull request runs:
338
+
339
+ ```text
340
+ npm ci
341
+ → npm run typecheck
342
+ → npm test
343
+ ```
344
+
345
+ To publish a release, create a version tag, for example:
346
+
347
+ ```bash
348
+ npm version patch
349
+ git push
350
+ git push --tags
351
+ ```
352
+
353
+ A `v*` tag triggers the release workflow:
354
+
355
+ ```text
356
+ Checkout
357
+ → Node.js 24
358
+ → npm ci
359
+ → npm run check
360
+ → verify tag == package.json version
361
+ → npm pack --dry-run
362
+ → npm Trusted Publishing (OIDC)
363
+ → npm publish
364
+ → GitHub Release
365
+ ```
366
+
367
+ npm publishing uses GitHub Actions OIDC Trusted Publishing, so no long-lived `NPM_TOKEN` is required in the repository.
368
+
369
+ ## Compatibility and design principles
370
+
371
+ - Does not modify Pi Core.
372
+ - `@earendil-works/pi-coding-agent` and `@earendil-works/pi-tui` are host-provided peer dependencies to avoid duplicate runtime instances.
373
+ - Fabric ownership is detected explicitly to avoid conflicting Tool View controls.
374
+ - Session and resource operations use Pi public APIs wherever possible.
375
+ - Context composition is clearly presented as an estimate, not provider-exact token accounting.
376
+ - Fullscreen sidebar behavior degrades safely when fullscreen layout is unavailable.
377
+
378
+ ## Requirements
379
+
380
+ - Pi Coding Agent
381
+ - Node.js `>= 22.19.0` (use a Node version supported by your Pi installation)
382
+ - Development and CI currently use Node.js 24
40
383
 
41
- ## Notes
384
+ ## License
42
385
 
43
- This repository contains only the extension source and development metadata. Local Pi runtime configuration, credentials, sessions, caches, and browser profiles are intentionally excluded.
386
+ This repository does not currently declare a dedicated LICENSE. If the project is intended for long-term public open-source use, adding an explicit license is recommended.
@@ -0,0 +1,386 @@
1
+ [English](README.md) | [简体中文](README.zh-CN.md)
2
+
3
+ # pi-ui-extension
4
+
5
+ `pi-ui-extension` 是一个面向 [Pi Coding Agent](https://github.com/earendil-works/pi) 的终端 UI 增强包,在不修改 Pi Core 的前提下,为全屏 TUI 增加右侧信息栏、会话管理、上下文观察、工具调用统计以及更紧凑的 Footer。
6
+
7
+ 当前包同时支持通过 npm 或 Git 安装,并使用 GitHub Actions 完成类型检查、自动化测试和 npm Trusted Publishing(OIDC)发布。
8
+
9
+ ## 界面预览
10
+
11
+ <img width="1377" height="671" alt="pi-ui-extension 界面预览" src="https://github.com/user-attachments/assets/ddea5dc9-8796-433a-abfc-c7ea2adec089" />
12
+
13
+ ## 功能概览
14
+
15
+ ### 1. 右侧 Sidebar
16
+
17
+ 扩展会在 Pi 的全屏 TUI 中挂载右侧 Sidebar。默认包含三个区域:
18
+
19
+ - **SESSIONS**:最近会话与资源入口。
20
+ - **CTX**:当前模型、上下文窗口、组成估算以及运行性能。
21
+ - **TOOL VIEW**:工具输出显示模式与 Tool / MCP 调用统计。
22
+
23
+ Sidebar 支持鼠标交互、滚轮滚动和终端尺寸变化。终端高度不足时,各区域会根据可用空间自动收缩或出现滚动区域。
24
+
25
+ > 右侧 Sidebar 依赖 Pi fullscreen TUI。非 fullscreen 场景下不会强行替换布局。
26
+
27
+ ### 2. Sessions 会话管理
28
+
29
+ `SESSIONS` 面板提供最近会话的快速管理:
30
+
31
+ - 点击会话切换到对应 Session。
32
+ - 重命名非当前 Session。
33
+ - 删除非当前 Session。
34
+ - 使用右上角 `⊗` 清理除当前 Session 外的其他会话。
35
+ - 点击 `SESSIONS ↻` 刷新会话列表。
36
+
37
+ 为避免正在执行中的 Agent 状态被破坏,会话切换、重命名、删除和批量清理只会在 Pi 空闲时执行;当前正在使用的 Session 不允许删除。
38
+
39
+ ### 3. 资源快速查看
40
+
41
+ `SESSIONS` 面板底部提供四类资源入口:
42
+
43
+ - `AGENTS.md`
44
+ - `Skills`
45
+ - `Extensions`
46
+ - `MCP`
47
+
48
+ 点击后可以直接查看当前项目 / 当前 Pi 环境中已加载的相关资源,便于快速确认 Agent 当前实际使用了哪些上下文、Skill、Extension 和 MCP Server。
49
+
50
+ ### 4. CTX 上下文观察
51
+
52
+ `CTX` 面板用于观察当前模型请求相关的上下文状态,主要包括:
53
+
54
+ - 当前模型名称。
55
+ - Thinking Level。
56
+ - Pi 当前 context usage / context window。
57
+ - 当前提问相对上一轮 settled 状态的上下文增量。
58
+ - Context composition 分类估算。
59
+ - 图片数量。
60
+ - 当前 Run 的 turn 数量与耗时。
61
+ - 平均 TTFT(Time To First Token)。
62
+ - 平均 TPS(Tokens Per Second)。
63
+ - 最近一次 TTFT 及速度标签。
64
+ - 可观测时显示缓存命中相关数据。
65
+
66
+ Composition 会将当前可观测上下文拆分为:
67
+
68
+ - `System`
69
+ - `Tools`
70
+ - `Messages`
71
+ - `Tool Results`
72
+ - `Summary`
73
+ - `Other`
74
+
75
+ 其中 token 数量是本地启发式估算,主要用于观察组成比例和变化趋势,并不是模型厂商的精确 tokenizer 结果,也不等同于计费 token。
76
+
77
+ 工具定义会优先基于 provider request 中实际可观测到的 tool payload 统计;在请求尚未发生时,则回退到 Pi 当前启用工具的 schema 估算。
78
+
79
+ ### 5. Tool View 模式切换
80
+
81
+ `TOOL VIEW` 支持三种工具输出显示模式:
82
+
83
+ - **Normal**:正常显示工具 transcript。
84
+ - **Compact**:使用更紧凑的工具输出展示。
85
+ - **Hidden**:隐藏工具 transcript。
86
+
87
+ 可以直接使用鼠标点击模式进行切换。
88
+
89
+ 当 Fabric 接管工具展示行为时,扩展会保留 Tool View 面板和调用统计,但不再显示本地模式选择器,并提示 `View controlled by Fabric`,避免与 Fabric 的展示逻辑互相抢占。
90
+
91
+ ### 6. Tool / MCP 调用统计
92
+
93
+ Tool View 会将调用拆成两类展示:
94
+
95
+ - `TOOLS`
96
+ - `MCP`
97
+
98
+ 每一项使用:
99
+
100
+ ```text
101
+ 当前提问调用数 / 当前 Session 累计调用数
102
+ ```
103
+
104
+ 例如:
105
+
106
+ ```text
107
+ task_todos 1/5
108
+ ```
109
+
110
+ 统计会跟随当前 active branch 重建,切换分支或恢复 Session 时不会简单沿用旧分支的累计结果。
111
+
112
+ 对于通过 MCP gateway、`mcpScript` 等路径发起的调用,扩展会尽量归属到实际 MCP Server,而不是只统计为一个模糊的外层工具调用。
113
+
114
+ ### 7. Footer
115
+
116
+ 扩展替换默认 Footer,保持界面简洁,显示:
117
+
118
+ - 当前工作目录。
119
+ - 当前 Git branch(存在 Git 仓库时)。
120
+
121
+ 路径会自动压缩到终端宽度以内。
122
+
123
+ ## Pi Package Catalog
124
+
125
+ 本包发布到 npm 时包含 `pi-package` keyword 和 Pi manifest,因此具备被 `pi.dev/packages` 的 Pi Package Catalog 发现和索引的条件。包元数据同时声明了上方的预览图,用于 Catalog / Gallery 展示。
126
+
127
+ ## 安装
128
+
129
+ ### 推荐:从 npm 安装
130
+
131
+ ```bash
132
+ pi install npm:pi-ui-extension
133
+ ```
134
+
135
+ Pi 会安装 package,并将声明写入个人配置:
136
+
137
+ ```text
138
+ ~/.pi/agent/settings.json
139
+ ```
140
+
141
+ 对应配置类似:
142
+
143
+ ```json
144
+ {
145
+ "packages": [
146
+ "npm:pi-ui-extension"
147
+ ]
148
+ }
149
+ ```
150
+
151
+ 如果希望固定版本:
152
+
153
+ ```bash
154
+ pi install npm:pi-ui-extension@1.1.1
155
+ ```
156
+
157
+ 或者:
158
+
159
+ ```json
160
+ {
161
+ "packages": [
162
+ "npm:pi-ui-extension@1.1.1"
163
+ ]
164
+ }
165
+ ```
166
+
167
+ 固定版本属于 pinned package,不会自动移动到后续版本。
168
+
169
+ ### 从 GitHub 安装
170
+
171
+ 也可以直接使用 Git 仓库:
172
+
173
+ ```bash
174
+ pi install git:github.com/1993yihuan/pi-ui-extension
175
+ ```
176
+
177
+ 配置形式:
178
+
179
+ ```json
180
+ {
181
+ "packages": [
182
+ "git:github.com/1993yihuan/pi-ui-extension"
183
+ ]
184
+ }
185
+ ```
186
+
187
+ 固定到 Git tag:
188
+
189
+ ```bash
190
+ pi install git:github.com/1993yihuan/pi-ui-extension@v1.1.1
191
+ ```
192
+
193
+ ### 临时试用
194
+
195
+ 如果只想在一次 Pi 启动中测试,不修改 `settings.json`:
196
+
197
+ ```bash
198
+ pi -e npm:pi-ui-extension
199
+ ```
200
+
201
+ ### 项目级安装
202
+
203
+ 需要只对当前项目生效时:
204
+
205
+ ```bash
206
+ pi install --local npm:pi-ui-extension
207
+ ```
208
+
209
+ 声明会写入:
210
+
211
+ ```text
212
+ <project>/.pi/settings.json
213
+ ```
214
+
215
+ 项目级 Package 只有在项目被 Pi 信任后才会加载。
216
+
217
+ ## 更新与卸载
218
+
219
+ 更新未固定版本的扩展:
220
+
221
+ ```bash
222
+ pi update --extensions
223
+ ```
224
+
225
+ 查看当前配置的 Package:
226
+
227
+ ```bash
228
+ pi list
229
+ ```
230
+
231
+ 卸载 npm 版本:
232
+
233
+ ```bash
234
+ pi remove npm:pi-ui-extension
235
+ ```
236
+
237
+ 如果安装的是 Git 源,则使用对应 Git source 删除:
238
+
239
+ ```bash
240
+ pi remove git:github.com/1993yihuan/pi-ui-extension
241
+ ```
242
+
243
+ ## npm 与 Git 应该选哪个?
244
+
245
+ 日常使用推荐 npm:
246
+
247
+ ```text
248
+ npm:pi-ui-extension
249
+ ```
250
+
251
+ 优点是版本语义清晰、安装速度稳定,并且可以直接固定 SemVer 版本。
252
+
253
+ 如果希望始终跟随仓库最新代码,或者需要测试尚未发布到 npm 的提交,可以使用:
254
+
255
+ ```text
256
+ git:github.com/1993yihuan/pi-ui-extension
257
+ ```
258
+
259
+ 本地开发阶段则推荐直接加载本地源码目录,避免每次调试都必须 commit / push / update。
260
+
261
+ ## 本地开发
262
+
263
+ 克隆仓库:
264
+
265
+ ```bash
266
+ git clone https://github.com/1993yihuan/pi-ui-extension.git
267
+ cd pi-ui-extension
268
+ ```
269
+
270
+ 安装开发依赖:
271
+
272
+ ```bash
273
+ npm ci
274
+ ```
275
+
276
+ 完整检查:
277
+
278
+ ```bash
279
+ npm run check
280
+ ```
281
+
282
+ 等价于:
283
+
284
+ ```bash
285
+ npm run typecheck
286
+ npm test
287
+ ```
288
+
289
+ 当前自动化测试覆盖 Sidebar、CTX、Session、Tool View、MCP resource、Fabric detection、鼠标滚轮 / resize 等主要行为。
290
+
291
+ 开发时可以直接让 Pi 加载本地目录:
292
+
293
+ ```bash
294
+ pi install ./path/to/pi-ui-extension
295
+ ```
296
+
297
+ 或者在一次启动中临时加载:
298
+
299
+ ```bash
300
+ pi -e ./path/to/pi-ui-extension
301
+ ```
302
+
303
+ ## Package 结构
304
+
305
+ ```text
306
+ pi-ui-extension/
307
+ ├── extensions/
308
+ │ ├── ctx/ # 上下文组成、增量与运行性能
309
+ │ ├── footer/ # Footer
310
+ │ ├── mcp/ # MCP resource / usage 集成
311
+ │ ├── session/ # Session 列表与操作
312
+ │ ├── sidebar/ # Sidebar 布局、滚动和 resize
313
+ │ ├── tool-view/ # Tool View 模式与调用统计
314
+ │ ├── fabric-detection.ts # Fabric 工具接管检测
315
+ │ └── index.ts # Pi Extension 入口
316
+ ├── .github/workflows/
317
+ │ ├── ci.yml # push / PR 自动检查
318
+ │ └── release.yml # tag 自动发布 npm + GitHub Release
319
+ ├── package.json
320
+ └── tsconfig.check.json
321
+ ```
322
+
323
+ Pi 的扩展入口在 `package.json` 中显式声明:
324
+
325
+ ```json
326
+ {
327
+ "pi": {
328
+ "extensions": [
329
+ "./extensions/index.ts"
330
+ ]
331
+ }
332
+ }
333
+ ```
334
+
335
+ ## CI / Release
336
+
337
+ 提交到 `main` 或创建 PR 时,GitHub Actions 会自动执行:
338
+
339
+ ```text
340
+ npm ci
341
+ → npm run typecheck
342
+ → npm test
343
+ ```
344
+
345
+ 发布版本时使用 Git tag,例如:
346
+
347
+ ```bash
348
+ npm version patch
349
+ git push
350
+ git push --tags
351
+ ```
352
+
353
+ `v*` tag 会触发 Release workflow:
354
+
355
+ ```text
356
+ Checkout
357
+ → Node.js 24
358
+ → npm ci
359
+ → npm run check
360
+ → 校验 tag 与 package.json version
361
+ → npm pack --dry-run
362
+ → npm Trusted Publishing (OIDC)
363
+ → npm publish
364
+ → GitHub Release
365
+ ```
366
+
367
+ npm 发布使用 GitHub Actions OIDC Trusted Publishing,不需要在 GitHub Repository 中保存长期 `NPM_TOKEN`。
368
+
369
+ ## 兼容性与设计原则
370
+
371
+ - 不修改 Pi Core。
372
+ - Pi host 提供的 `@earendil-works/pi-coding-agent` 和 `@earendil-works/pi-tui` 使用 `peerDependencies`,避免产生重复运行时实例。
373
+ - 对 Fabric 做显式检测,避免 Tool View 模式控制发生冲突。
374
+ - Session 与资源操作尽量通过 Pi 已公开 API 完成。
375
+ - Context composition 明确标记为估算值,不冒充 provider 精确 token 统计。
376
+ - fullscreen Sidebar 不可用时安全降级,不影响 Pi 主流程。
377
+
378
+ ## Requirements
379
+
380
+ - Pi Coding Agent
381
+ - Node.js `>= 22.19.0`(建议使用当前 Pi 支持的 Node 版本)
382
+ - 开发与 CI 当前使用 Node.js 24
383
+
384
+ ## License
385
+
386
+ 当前仓库尚未声明独立 LICENSE。如准备将项目作为正式开源项目长期维护,建议补充明确的开源许可证。
package/package.json CHANGED
@@ -1,15 +1,23 @@
1
1
  {
2
2
  "name": "pi-ui-extension",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "type": "module",
5
- "description": "Pi UI extension with footer, split-view sidebar, and configurable tool transcript rendering",
5
+ "description": "Pi terminal UI extension with session management, context inspection, Tool/MCP usage tracking, sidebar panels, and a compact footer",
6
6
  "keywords": [
7
- "pi-package"
7
+ "pi-package",
8
+ "pi",
9
+ "pi-extension",
10
+ "coding-agent",
11
+ "terminal-ui",
12
+ "tui",
13
+ "mcp",
14
+ "context-window"
8
15
  ],
9
16
  "pi": {
10
17
  "extensions": [
11
18
  "./extensions/index.ts"
12
- ]
19
+ ],
20
+ "image": "https://github.com/user-attachments/assets/ddea5dc9-8796-433a-abfc-c7ea2adec089"
13
21
  },
14
22
  "scripts": {
15
23
  "typecheck": "tsc -p tsconfig.check.json",
@@ -49,5 +57,8 @@
49
57
  },
50
58
  "publishConfig": {
51
59
  "access": "public"
60
+ },
61
+ "engines": {
62
+ "node": ">=22.19.0"
52
63
  }
53
64
  }