@herbertgao/pi-extensions 2026.11.9 → 2026.11.10

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 (34) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +1 -1
  3. package/node_modules/@herbertgao/pi-cc-extensions/CHANGELOG.md +6 -0
  4. package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +8 -6
  5. package/node_modules/@herbertgao/pi-cc-extensions/README.md +8 -6
  6. package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/config.ts +12 -0
  7. package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/panel.ts +36 -13
  8. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/compact-thinking.ts +4 -8
  9. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/context.ts +7 -2
  10. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/footer.ts +115 -6
  11. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/prompt-editor.ts +47 -15
  12. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/startup-header.ts +3 -18
  13. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/compact-mode.ts +27 -8
  14. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/default-mode.ts +6 -1
  15. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/markdown-enhance.ts +30 -17
  16. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/scroll.ts +4 -21
  17. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/grouping.ts +13 -0
  18. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/names.ts +3 -13
  19. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/transcript-mode.ts +34 -7
  20. package/node_modules/@herbertgao/pi-cc-extensions/extensions/utils/ansi-text.ts +25 -0
  21. package/node_modules/@herbertgao/pi-cc-extensions/extensions/utils/keybindings.ts +75 -0
  22. package/node_modules/@herbertgao/pi-cc-extensions/package.json +4 -4
  23. package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +6 -0
  24. package/node_modules/@herbertgao/pi-subagents/README.md +26 -17
  25. package/node_modules/@herbertgao/pi-subagents/docs/workflows.md +1 -1
  26. package/node_modules/@herbertgao/pi-subagents/package.json +4 -4
  27. package/node_modules/@herbertgao/pi-subagents/src/agent-manager.ts +71 -8
  28. package/node_modules/@herbertgao/pi-subagents/src/index.ts +83 -34
  29. package/node_modules/@herbertgao/pi-subagents/src/settings.ts +18 -0
  30. package/node_modules/@herbertgao/pi-subagents/src/types.ts +10 -0
  31. package/node_modules/@herbertgao/pi-subagents/src/ui/agent-tree.ts +47 -0
  32. package/node_modules/@herbertgao/pi-subagents/src/ui/agent-widget.ts +7 -5
  33. package/node_modules/@herbertgao/pi-subagents/src/ui/fleet-list.ts +211 -47
  34. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @herbertgao/pi-extensions
2
2
 
3
+ ## 2026.11.10
4
+
5
+ ### Patch Changes
6
+
7
+ - [#374](https://github.com/HerbertGao/pi-extensions/pull/374) [`4d323bd`](https://github.com/HerbertGao/pi-extensions/commit/4d323bdfd68139885b475e721ad150d9ee4958ea) Thanks [@HerbertGao](https://github.com/HerbertGao)! - Pin graphifyy 0.9.108. The CLI stays outside the npm aggregate. Warm AST caches rebuild, a query filter that matches nothing says so, and Python stays on >=3.10,<3.15.
8
+
9
+ - Updated dependencies [[`4d323bd`](https://github.com/HerbertGao/pi-extensions/commit/4d323bdfd68139885b475e721ad150d9ee4958ea), [`4d323bd`](https://github.com/HerbertGao/pi-extensions/commit/4d323bdfd68139885b475e721ad150d9ee4958ea)]:
10
+ - @herbertgao/pi-cc-extensions@1.1.0
11
+ - @herbertgao/pi-subagents@0.24.0
12
+
3
13
  ## 2026.11.9
4
14
 
5
15
  ### Patch Changes
package/README.md CHANGED
@@ -41,7 +41,7 @@ The package bundles 6 active `@herbertgao/*` child packages—`pi-agency`, `pi-b
41
41
 
42
42
  Pi loads their extensions and skills through `node_modules/` paths inside one package root. The upstream companions are pinned and bundled, not forked or renamed.
43
43
 
44
- The locally customized CC package follows upstream `pi-cc-extensions@1.0.16`; SoL-Pi follows its complete main baseline `e1a586af` with Pi 1.x/codemode compatibility updates through `21956803`. Local behavior not already covered upstream is retained. SoL-Pi's `update_plan` now follows upstream's model-only contract: invoke it directly, not inside codemode scripts. Action Fusion and ccstyle write rich diffs coexist without disabling either feature. All four SoL-Pi features remain opt-in; its new non-persistent-session evidence archives remain on disk for consumers and require host or caller cleanup.
44
+ The locally customized CC package follows upstream `pi-cc-extensions@1.0.17`; SoL-Pi follows its complete main baseline `e1a586af` with Pi 1.x/codemode compatibility updates through `21956803`. Local behavior not already covered upstream is retained. SoL-Pi's `update_plan` now follows upstream's model-only contract: invoke it directly, not inside codemode scripts. Action Fusion and ccstyle write rich diffs coexist without disabling either feature. All four SoL-Pi features remain opt-in; its new non-persistent-session evidence archives remain on disk for consumers and require host or caller cleanup.
45
45
 
46
46
  Antigravity `0.12.0` enriches search citations by visiting source sites by default (`ANTIGRAVITY_NO_SOURCE_ENRICH=1` disables enrichment). `ANTIGRAVITY_DEFER_TOOLS=1` registers `google_search` and `generate_image` as deferred tools; the default stays direct. A refreshed catalog does not restore a model the current catalog omitted, and an image save rejects a symlink destination. It refreshes a curated model catalog and upgrades the existing model cache; previously listed model IDs may disappear. Ask `2.15.0` lets other extensions in the same process answer or cancel TUI questionnaires through its event channel, without sender authentication. Its notes shortcut defaults to `n` and can be a single non-Latin character; reserved navigation keys stay on `n`. Web Access `0.45.0` keeps direct tool exposure and `toolActivation: auto` by default. Linkup, DeepSeek search and fetch, provider gateways, `toolActivation: "none"`, deferred exposure, GCE ADC, field extraction, 9router, and plain HTTP gateway URLs require explicit configuration. Web Access `0.47.0` adds Sofya and Outcrawl as explicit-only search providers. `lockProxy: true` rejects a tool-call proxy that differs from the configured proxy, including a direct connection. A GitHub repository README is returned up to 100K characters, and a clone with no `githubClone.clonePath` goes under the OS temp directory.
47
47
 
@@ -1,5 +1,11 @@
1
1
  # @herbertgao/pi-cc-extensions
2
2
 
3
+ ## 1.0.17-local.1
4
+
5
+ ### Minor Changes
6
+
7
+ - [#374](https://github.com/HerbertGao/pi-extensions/pull/374) [`4d323bd`](https://github.com/HerbertGao/pi-extensions/commit/4d323bdfd68139885b475e721ad150d9ee4958ea) Thanks [@HerbertGao](https://github.com/HerbertGao)! - Replay upstream pi-cc-extensions 1.0.17. Ctrl+O leaves a long finished bang-command output to Pi and still opens the fullscreen transcript otherwise. The context chip can use Pi's auto-compaction point as its limit. Plain mermaid fences use Pi's renderer, and dialect fences stay here. Turning the editor prefix off and back on in one /ccstyle panel keeps the last choice. Regular mode still does not enable terminal mouse reporting.
8
+
3
9
  ## 1.0.16-local.1
4
10
 
5
11
  ### Minor Changes
@@ -28,11 +28,11 @@ Run `/reload` after installation.
28
28
  | Feature | Description | Entry point |
29
29
  | --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------- |
30
30
  | Claude Code UI | Tool summaries, expand/collapse, rich edit/write diffs, and `on` / `compact` / `off` modes | `/ccstyle` |
31
- | Markdown enhancements | Mermaid dialects and circled-number conversion | Automatic; turn off with `enableMarkdownEnhance: false` |
32
- | Fullscreen mode | Tool card/group expand and collapse on click, previews, hover highlight, and a back-to-bottom button | `TUIMODE=fullscreen` or `--tui-mode fullscreen` |
31
+ | Markdown enhancements | Mermaid dialects in non-standard fences (`statediagram`, `classdiagram`…) and circled-number conversion; plain mermaid goes to pi | Automatic; turn off with `enableMarkdownEnhance: false` |
32
+ | Fullscreen mode | Tool card/group expand and collapse on click, previews, hover highlight, and a back-to-bottom button | `--tui-mode fullscreen` (default since pi 1.5) |
33
33
  | Settings panel | `Style / Features / UI / Diff / Thinking / Footer` tabs | `/ccstyle` |
34
34
  | Context inspection | Usage breakdown and previews for the system prompt, memory, skills, tools definition, and messages | `/context` |
35
- | Transcript browsing | Full-screen transcript browsing with every tool output expanded | `Ctrl+O` |
35
+ | Transcript browsing | Full-screen transcript browsing with every tool output expanded; the key goes to pi while a long `!` output can be expanded | `Ctrl+O` |
36
36
  | Session/Subagent references | Search and inject effective context from previous Sessions or existing SubAgents | `@` |
37
37
  | Status bar | Shows model, context, cache, cost, the conversation token total, and git; also works with `@narumitw/pi-usage` for live quota. Git/cache/token Nerd Font icons can be turned off | `/ccstyle` |
38
38
  | Theme | Bundled themes: CC Dark, CC Light, CC Dark HC, CC Light HC | `/settings` → Theme |
@@ -92,6 +92,8 @@ Renderer snapshots for `on` / `compact` modes: [default](./docs/tool-render-exam
92
92
  "footerCurrencyRate": null, // display units per 1 cost unit; null changes the symbol only
93
93
  "footerNerdIcons": true, // Nerd Font glyphs for git/cache/tokens; false = plain text
94
94
  "footerGitStatsMode": "working", // working (default): uncommitted; branch: cumulative net changes
95
+ "footerContextLimit": "window", // context chip limit: window (default); compaction: auto-compaction point (window − compaction.reserveTokens); both: compaction point, window in brackets
96
+ // Pi compacts only after crossing that point, so the text can briefly exceed 100% (e.g. 104%/184k); the bar clamps at 100%
95
97
  "footerHiddenKeys": [], // hidden chip keys
96
98
  "footerLine1Keys": ["model", "context", "cache", "rate", "cost", "tokens", "pi-usage"], // chip order per line; builtins and plugins share one layout
97
99
  "footerLine2Keys": ["cwd", "git"], // cwd: directory and session; git: branch and changes. Either can move to any line
@@ -103,7 +105,7 @@ Renderer snapshots for `on` / `compact` modes: [default](./docs/tool-render-exam
103
105
  > **Fullscreen**: expanded diffs always show every line. When expanded Input/Output exceeds the line cap, the footer shows `… +N more lines`; click for the full preview, click again to collapse.
104
106
 
105
107
  > [!NOTE]
106
- > **Mermaid rendering**: set `markdown.mermaid` to `final` via `~/.pi/agent/settings.json` or `/settings`. Default `streaming` redraws every frame; `final` renders once.
108
+ > **Mermaid rendering**: set `markdown.mermaid` to `final` (`/settings`) so it renders once instead of every frame.
107
109
 
108
110
  ## Local development
109
111
 
@@ -117,7 +119,7 @@ pi -e . # one run, does not edit settings.json
117
119
 
118
120
  ## Compatibility
119
121
 
120
- - Node.js `>=22.19.0`; the monorepo uses Pi `1.5.0`, with published Pi peer versions kept at `*`.
122
+ - Node.js `>=22.19.0`; the monorepo typechecks against Pi `1.5.0`, and published Pi peer versions stay `*`. 1.0.17 passes injected keybinding hints, `messageTypes`, and the waiting-for-input state through to Pi 1.5.x hosts that provide them.
121
123
 
122
124
  ## Recommended companions
123
125
 
@@ -129,7 +131,7 @@ pi -e . # one run, does not edit settings.json
129
131
 
130
132
  ## Credits
131
133
 
132
- - Based on [`minuque/pi-cc-extensions`](https://github.com/minuque/pi-cc-extensions) 1.0.16 (MIT), upstream baseline [`5e3ef6b`](https://github.com/minuque/pi-cc-extensions/commit/5e3ef6b9f96d198f93ec242eac81ff21bebdb4e1), with this repository's configuration migration and compatibility patches retained.
134
+ - Based on [`minuque/pi-cc-extensions`](https://github.com/minuque/pi-cc-extensions) 1.0.17 (MIT), upstream baseline [`04c4274`](https://github.com/minuque/pi-cc-extensions/commit/04c4274d08135b5880bad285f92b11e9b22d115e), with this repository's configuration migration and compatibility patches retained.
133
135
  - Rich diffs are adapted from [`MasuRii/pi-tool-display`](https://github.com/MasuRii/pi-tool-display) (MIT). See [`extensions/renderer/tool/diff/ATTRIBUTION.md`](./extensions/renderer/tool/diff/ATTRIBUTION.md).
134
136
 
135
137
  ## License
@@ -28,11 +28,11 @@ pi install git:github.com/HerbertGao/pi-extensions
28
28
  | 功能 | 说明 | 入口 |
29
29
  | --------------------- | ------------------------------------------------------------------------------- | ----------------------------------------------- |
30
30
  | Claude Code UI | 工具摘要、折叠展开、rich edit/write diff,以及`on` / `compact` / `off` 三种模式 | `/ccstyle` |
31
- | Markdown 增强 | Mermaid 方言渲染、圈数字转半角括号 | 自动生效;`enableMarkdownEnhance: false` 关闭 |
32
- | Fullscreen mode | 工具卡/group 单击展开与收起、预览、hover 高亮、回到底部按钮 | `TUIMODE=fullscreen` 或 `--tui-mode fullscreen` |
31
+ | Markdown 增强 | 方言 fence 的 Mermaid 渲染(`statediagram`、`classdiagram` 等)、圈数字转半角括号;标准 mermaid 交给 pi | 自动生效;`enableMarkdownEnhance: false` 关闭 |
32
+ | Fullscreen mode | 工具卡/group 单击展开与收起、预览、hover 高亮、回到底部按钮 | `--tui-mode fullscreen`(pi 1.5 起默认) |
33
33
  | 配置面板 | `Style / Features / UI / Diff / Thinking / Footer` 六页签 | `/ccstyle` |
34
34
  | 上下文检查 | 查看上下文占用,并预览 System prompt、Memory、Skills、Tools definition 和消息内容 | `/context` |
35
- | 会话记录浏览 | 全屏浏览完整会话记录,工具输出全展开 | `Ctrl+O` |
35
+ | 会话记录浏览 | 全屏浏览完整会话记录,工具输出全展开;对话区有可展开的 `!` 输出时把键让给 pi | `Ctrl+O` |
36
36
  | Session/Subagent 引用 | 搜索并注入历史 Session 或现有 SubAgent 的有效上下文 | `@` |
37
37
  | 状态栏 | 显示:模型、上下文、缓存、费用、本次对话累计 token、git并适配 @narumitw/pi-usage 实时显示额度;git/缓存/token 图标可关 Nerd Font | `/ccstyle` |
38
38
  | 主题 | 随包提供 4 个主题:CC Dark、CC Light、CC Dark HC、CC Light HC | `/settings` → Theme |
@@ -92,6 +92,8 @@ pi install git:github.com/HerbertGao/pi-extensions
92
92
  "footerCurrencyRate": null, // 1 单位费用换成多少显示币种;null 只换符号、不乘倍率
93
93
  "footerNerdIcons": true, // git/缓存/token 用 Nerd Font 图标;false 为纯文本
94
94
  "footerGitStatsMode": "working", // working(默认):未提交改动;branch:分支累计净改动
95
+ "footerContextLimit": "window", // 上下文芯片分母:window(默认):完整上下文窗口;compaction:自动压缩触发点(窗口 − compaction.reserveTokens);both:压缩点并在括号中显示完整窗口
96
+ // Pi 越过压缩点后才压缩,所以文字可能短暂超过 100%(如 104%/184k);条形图封顶 100%
95
97
  "footerHiddenKeys": [], // 隐藏的芯片 key
96
98
  "footerLine1Keys": ["model", "context", "cache", "rate", "cost", "tokens", "pi-usage"], // 每行芯片顺序;内置项与插件同一套排布
97
99
  "footerLine2Keys": ["cwd", "git"], // cwd:目录和会话名;git:分支和改动。可换到任意行
@@ -103,7 +105,7 @@ pi install git:github.com/HerbertGao/pi-extensions
103
105
  > **全屏模式**:展开态 diff 全量显示。Input/Output 超行时末行给 `… +N more lines`,单击看全量,再击收起。
104
106
 
105
107
  > [!NOTE]
106
- > **Mermaid 渲染**:`markdown.mermaid` 建议设为 `final`(`~/.pi/agent/settings.json` 或 `/settings`)。默认 `streaming` 逐帧重绘,`final` 只渲染最终版。
108
+ > **Mermaid 渲染**:`markdown.mermaid` 建议设 `final`(`/settings`),避免流式逐帧重绘。
107
109
 
108
110
  ## 本地开发
109
111
 
@@ -117,7 +119,7 @@ pi -e . # 只跑一次,不改 settings.json
117
119
 
118
120
  ## 兼容性
119
121
 
120
- - Node.js `>=22.19.0`;monorepo 使用 Pi `1.5.0`,发布包的 Pi peer 版本保持 `*`。
122
+ - Node.js `>=22.19.0`;monorepo 的类型检查使用 Pi `1.5.0`,发布包的 Pi peer 版本保持 `*`。1.0.17 会把注入式按键提示、`messageTypes` 和等待输入状态交给支持它们的 Pi 1.5.x。
121
123
 
122
124
  ## 推荐搭配
123
125
 
@@ -129,7 +131,7 @@ pi -e . # 只跑一次,不改 settings.json
129
131
 
130
132
  ## 致谢
131
133
 
132
- - 基于 [`minuque/pi-cc-extensions`](https://github.com/minuque/pi-cc-extensions) 1.0.16(MIT),上游基线 [`5e3ef6b`](https://github.com/minuque/pi-cc-extensions/commit/5e3ef6b9f96d198f93ec242eac81ff21bebdb4e1);保留本仓库的配置迁移与兼容性补丁。
134
+ - 基于 [`minuque/pi-cc-extensions`](https://github.com/minuque/pi-cc-extensions) 1.0.17(MIT),上游基线 [`04c4274`](https://github.com/minuque/pi-cc-extensions/commit/04c4274d08135b5880bad285f92b11e9b22d115e);保留本仓库的配置迁移与兼容性补丁。
133
135
  - Rich diff 改编自 [`MasuRii/pi-tool-display`](https://github.com/MasuRii/pi-tool-display)(MIT);详见 [`extensions/renderer/tool/diff/ATTRIBUTION.md`](./extensions/renderer/tool/diff/ATTRIBUTION.md)。
134
136
 
135
137
  ## 许可证
@@ -13,6 +13,8 @@ export type CompactStyleMode = "on" | "compact" | "off";
13
13
  export type DiffViewMode = "auto" | "split" | "unified";
14
14
  export type DiffIndicatorMode = "bars" | "classic" | "none";
15
15
  export type FooterGitStatsMode = "working" | "branch";
16
+ /** window: total context window; compaction: Pi's auto-compaction point; both: compaction point, window in brackets. */
17
+ export type FooterContextLimit = "window" | "compaction" | "both";
16
18
  export type FooterTokenRateMode = "average" | "live";
17
19
  export type ScrollButtonMode = "dock" | "native";
18
20
 
@@ -95,6 +97,8 @@ export type Config = {
95
97
  footerCurrencyRate: number | null;
96
98
  footerNerdIcons: boolean;
97
99
  footerGitStatsMode: FooterGitStatsMode;
100
+ /** Denominator of the context chip; compaction = contextWindow − compaction.reserveTokens. */
101
+ footerContextLimit: FooterContextLimit;
98
102
  footerHiddenKeys: string[];
99
103
  footerLine1Keys: string[];
100
104
  footerLine2Keys: string[];
@@ -108,6 +112,7 @@ const LEGACY_CONFIG_PATH = join(AGENT_DIR, "claude-code-style.json");
108
112
  export const DIFF_VIEW_MODES: DiffViewMode[] = ["auto", "split", "unified"];
109
113
  export const DIFF_INDICATOR_MODES: DiffIndicatorMode[] = ["bars", "classic", "none"];
110
114
  export const FOOTER_GIT_STATS_MODES: FooterGitStatsMode[] = ["working", "branch"];
115
+ export const FOOTER_CONTEXT_LIMITS: FooterContextLimit[] = ["window", "compaction", "both"];
111
116
  export const FOOTER_TOKEN_RATE_MODES: FooterTokenRateMode[] = ["average", "live"];
112
117
  export const SCROLL_BUTTON_MODES: ScrollButtonMode[] = ["dock", "native"];
113
118
  export const DIFF_SPLIT_MIN_WIDTH_VALUES = ["80", "100", "120", "140", "160", "180"];
@@ -178,6 +183,7 @@ export const DEFAULT_CONFIG: Config = {
178
183
  footerCurrencyRate: null,
179
184
  footerNerdIcons: true,
180
185
  footerGitStatsMode: "working",
186
+ footerContextLimit: "window",
181
187
  ...DEFAULT_FOOTER_CHIP_LAYOUT,
182
188
  };
183
189
 
@@ -329,6 +335,11 @@ export function normalizeConfig(input: unknown): Config {
329
335
  FOOTER_GIT_STATS_MODES,
330
336
  DEFAULT_CONFIG.footerGitStatsMode,
331
337
  ),
338
+ footerContextLimit: pickEnum(
339
+ source.footerContextLimit,
340
+ FOOTER_CONTEXT_LIMITS,
341
+ DEFAULT_CONFIG.footerContextLimit,
342
+ ),
332
343
  ...normalizeFooterChipLayout(source),
333
344
  };
334
345
  }
@@ -433,6 +444,7 @@ export function formatConfigStatus(source: Config = config): string {
433
444
  `footerRate=${source.footerCurrencyRate ?? "-"}`,
434
445
  `footerIcons=${source.footerNerdIcons ? "nerd" : "plain"}`,
435
446
  `footerGitStats=${source.footerGitStatsMode}`,
447
+ `footerContextLimit=${source.footerContextLimit}`,
436
448
  formatFooterChipSummary(source),
437
449
  ].join(" · ");
438
450
  }
@@ -30,6 +30,7 @@ import {
30
30
  } from "../feature/shell/footer-layout.ts";
31
31
  import { applyPromptEditor, clearPromptEditor } from "../feature/shell/prompt-editor.ts";
32
32
  import { applyStartupHeader, clearStartupHeader } from "../feature/shell/startup-header.ts";
33
+ import { setInjectedKeybindings } from "../utils/keybindings.ts";
33
34
  import type { ToolGroupingHooks } from "../renderer/tool/grouping.ts";
34
35
  import {
35
36
  config,
@@ -42,6 +43,7 @@ import {
42
43
  EXPANDED_INPUT_MAX_LINES_VALUES,
43
44
  EXPANDED_OUTPUT_MAX_LINES_VALUES,
44
45
  EXPANDED_PREVIEW_MAX_LINES_VALUES,
46
+ FOOTER_CONTEXT_LIMITS,
45
47
  FOOTER_GIT_STATS_MODES,
46
48
  FOOTER_TOKEN_RATE_MODES,
47
49
  formatExcludeRenderers,
@@ -60,6 +62,7 @@ import {
60
62
  type Config,
61
63
  type DiffIndicatorMode,
62
64
  type DiffViewMode,
65
+ type FooterContextLimit,
63
66
  type FooterGitStatsMode,
64
67
  type FooterTokenRateMode,
65
68
  type ScrollButtonMode,
@@ -119,6 +122,14 @@ function footerSessionTokensDescription(enabled: boolean): string {
119
122
  : "Conversation token total hidden.";
120
123
  }
121
124
 
125
+ function footerContextLimitDescription(mode: FooterContextLimit): string {
126
+ if (mode === "compaction")
127
+ return "Context chip measures against Pi's auto-compaction point (window minus compaction.reserveTokens).";
128
+ if (mode === "both")
129
+ return "Context chip measures against the auto-compaction point and shows the full window in brackets.";
130
+ return "Context chip measures against the full model context window (default).";
131
+ }
132
+
122
133
  function footerGitStatsDescription(mode: FooterGitStatsMode): string {
123
134
  return mode === "branch"
124
135
  ? "Net changes since the merge base, including uncommitted edits. Base: origin/HEAD, then local main/master. Untracked files excluded; unavailable stats hidden."
@@ -449,12 +460,10 @@ export async function showCcstylePanel(
449
460
  return;
450
461
  }
451
462
 
452
- // 编辑器插槽只能在面板关闭后替换:面板自己就挂在 editorContainer 上,面板开着时调
453
- // setEditorComponent 会把面板踢出渲染树、done() 再也走不到,`ctx.ui.custom()` 永不落定,
454
- // 整个输入管线随之卡死。
455
- let editorPrefixChanged = false;
456
-
457
- await ctx.ui.custom((tui: any, theme: any, _keybindings: any, done: () => void) => {
463
+ // 面板是一次提问:告诉宿主 pi 在等用户输入(OSC 7501)。
464
+ const blocked = { blocked: { kind: "question", message: "Adjusting ccstyle settings" } };
465
+ await ctx.ui.custom((tui: any, theme: any, keys: any, done: () => void) => {
466
+ setInjectedKeybindings(keys);
458
467
  const modeSetting = {
459
468
  id: "mode",
460
469
  label: "Mode",
@@ -788,6 +797,13 @@ export async function showCcstylePanel(
788
797
  currentValue: config.footerGitStatsMode,
789
798
  values: FOOTER_GIT_STATS_MODES,
790
799
  };
800
+ const footerContextLimitSetting = {
801
+ id: "footerContextLimit",
802
+ label: "Context limit",
803
+ description: footerContextLimitDescription(config.footerContextLimit),
804
+ currentValue: config.footerContextLimit,
805
+ values: FOOTER_CONTEXT_LIMITS,
806
+ };
791
807
  const footerTokenRateSetting = {
792
808
  id: "footerTokenRate",
793
809
  label: "Token rate",
@@ -881,6 +897,15 @@ export async function showCcstylePanel(
881
897
  ctx.ui.notify(`Updated ${id}: ${footerCurrencyRateSetting.currentValue}`, "info");
882
898
  return;
883
899
  }
900
+ if (id === "footerContextLimit") {
901
+ updateConfig({ footerContextLimit: value as FooterContextLimit });
902
+ footerContextLimitSetting.currentValue = config.footerContextLimit;
903
+ footerContextLimitSetting.description = footerContextLimitDescription(
904
+ config.footerContextLimit,
905
+ );
906
+ ctx.ui.notify(`Updated ${id}: ${value}`, "info");
907
+ return;
908
+ }
884
909
  if (id === "footerGitStatsMode") {
885
910
  updateConfig({ footerGitStatsMode: value as FooterGitStatsMode });
886
911
  footerGitStatsSetting.currentValue = config.footerGitStatsMode;
@@ -929,7 +954,9 @@ export async function showCcstylePanel(
929
954
  editorPrefixSetting.description = enabled
930
955
  ? "Show ❯ before the input line; color follows thinking level / bash mode."
931
956
  : "Plain input line, no ❯ glyph.";
932
- editorPrefixChanged = true;
957
+ // pi 1.5.0 起 setEditorComponent 不会再把面板踢出渲染树:新编辑器等面板关闭后再出现。
958
+ if (config.enableEditorPrefix) applyPromptEditor(ctx, { force: true });
959
+ else clearPromptEditor(ctx, { force: true });
933
960
  ctx.ui.notify(`Updated ${id}: ${value}`, "info");
934
961
  return;
935
962
  }
@@ -1156,6 +1183,7 @@ export async function showCcstylePanel(
1156
1183
  label: "Footer",
1157
1184
  items: [
1158
1185
  customFooterSetting,
1186
+ footerContextLimitSetting,
1159
1187
  footerTokenRateSetting,
1160
1188
  footerTokenRateModeSetting,
1161
1189
  footerTokenRateTtftSetting,
@@ -1269,12 +1297,7 @@ export async function showCcstylePanel(
1269
1297
  tui.requestRender();
1270
1298
  },
1271
1299
  };
1272
- });
1273
- // 面板已经卸下,插槽此时替换才不会踢掉对话框。
1274
- if (editorPrefixChanged) {
1275
- if (config.enableEditorPrefix) applyPromptEditor(ctx);
1276
- else clearPromptEditor(ctx);
1277
- }
1300
+ }, blocked);
1278
1301
  // 面板卸下后主 transcript 重新挂载;再刷一次,吃掉打开期间扫树失败的切换。
1279
1302
  hooks.refreshCurrentTranscript(ctx, toolGrouping);
1280
1303
  }
@@ -11,13 +11,9 @@ import {
11
11
  type ExtensionAPI,
12
12
  type Theme,
13
13
  } from "@earendil-works/pi-coding-agent";
14
- import {
15
- getKeybindings,
16
- truncateToWidth,
17
- visibleWidth,
18
- wrapTextWithAnsi,
19
- } from "@earendil-works/pi-tui";
14
+ import { truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
20
15
  import { Box, Markdown, Spacer, Text, type Component } from "@earendil-works/pi-tui";
16
+ import { keyText } from "../utils/keybindings.ts";
21
17
  import { TOOL_CARD_BG_SLOT } from "../renderer/tool/tool-state.ts";
22
18
  import { isToolTuiFullscreen } from "../renderer/tool/names.ts";
23
19
  import {
@@ -167,8 +163,8 @@ function restoreDurationEntries(
167
163
  }
168
164
 
169
165
  function getThinkingToggleHint() {
170
- const keys = getKeybindings().getKeys("app.thinking.toggle");
171
- return keys.length > 0 ? `${keys.join("/")} to expand` : undefined;
166
+ const keys = keyText("app.thinking.toggle");
167
+ return keys.length > 0 ? `${keys} to expand` : undefined;
172
168
  }
173
169
 
174
170
  function thinkingExpandAction(): string | undefined {
@@ -11,6 +11,7 @@ import {
11
11
  import { Key, Markdown, matchesKey, visibleWidth } from "@earendil-works/pi-tui";
12
12
  import { type Color, rgbColor } from "@earendil-works/pi-tui";
13
13
  import { padLine } from "../utils/format.ts";
14
+ import { setInjectedKeybindings } from "../utils/keybindings.ts";
14
15
 
15
16
  export type ContextPart = {
16
17
  label: string;
@@ -101,7 +102,8 @@ export async function showTextPreview(
101
102
  activeContextOverlays++;
102
103
  try {
103
104
  await ctx.ui.custom(
104
- (tui, theme, _keybindings, done) => {
105
+ (tui, theme, injectedKeybindings, done) => {
106
+ setInjectedKeybindings(injectedKeybindings);
105
107
  ensureFullscreenMouseMotion(tui);
106
108
  let scrollOffset = 0;
107
109
  let pageSize = 1;
@@ -384,6 +386,7 @@ export async function showTextPreview(
384
386
  maxHeight: "80%",
385
387
  margin: 2,
386
388
  },
389
+ blocked: { kind: "question", message: "Reviewing context" },
387
390
  },
388
391
  );
389
392
  } finally {
@@ -697,7 +700,8 @@ export default function contextUsageExtension(pi: ExtensionAPI) {
697
700
  let action;
698
701
  try {
699
702
  action = await ctx.ui.custom(
700
- (tui, theme, _keybindings, done) => {
703
+ (tui, theme, injectedKeybindings, done) => {
704
+ setInjectedKeybindings(injectedKeybindings);
701
705
  ensureFullscreenMouseMotion(tui);
702
706
  let previewHitboxes: Array<{
703
707
  key: PreviewKey;
@@ -905,6 +909,7 @@ export default function contextUsageExtension(pi: ExtensionAPI) {
905
909
  maxHeight: "90%",
906
910
  margin: 1,
907
911
  },
912
+ blocked: { kind: "question", message: "Reviewing context" },
908
913
  },
909
914
  );
910
915
  } finally {
@@ -19,7 +19,7 @@ import { existsSync } from "node:fs";
19
19
  import { homedir } from "node:os";
20
20
  import { join } from "node:path";
21
21
  import { pathToFileURL } from "node:url";
22
- import { config } from "../../config/config.ts";
22
+ import { config, type FooterContextLimit } from "../../config/config.ts";
23
23
  import { stripAnsi } from "../../utils/ansi-text.ts";
24
24
  import { formatFooterCost } from "./footer-currency.ts";
25
25
  import { formatTokenCount } from "../../utils/format.ts";
@@ -47,6 +47,105 @@ import { currentTtftMs, displayTokenRate, formatTokenRate } from "./token-rate.t
47
47
 
48
48
  export { parseGitStats } from "./git-stats.ts";
49
49
 
50
+ // Pi's built-in compaction.reserveTokens default (pi-coding-agent settings defaults).
51
+ const PI_DEFAULT_COMPACTION_RESERVE_TOKENS = 16_384;
52
+ /** How long a cached compaction limit is reused before settings are read again. */
53
+ export const COMPACTION_LIMIT_REFRESH_MS = 30_000;
54
+
55
+ type CompactionSettingsView = {
56
+ compaction?: {
57
+ enabled?: unknown;
58
+ reserveTokens?: unknown;
59
+ modelOverrides?: Record<string, unknown>;
60
+ };
61
+ };
62
+
63
+ type ModelRef = { provider?: string; id?: string } | undefined;
64
+
65
+ /** A reserve value Pi accepts: a non-negative safe integer; anything else is ignored. */
66
+ function validReserveTokens(value: unknown): number | undefined {
67
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : undefined;
68
+ }
69
+
70
+ /**
71
+ * Token count at which Pi auto-compacts: it compacts once context tokens exceed
72
+ * contextWindow − reserveTokens, resolving reserveTokens as model override, then
73
+ * compaction.reserveTokens, then Pi's default. Undefined when auto-compaction is
74
+ * off or the window is unknown or not larger than the reserve.
75
+ *
76
+ * Mirrors Pi's SettingsManager.getCompactionSettings and shouldCompact, which
77
+ * extensions cannot call; update this copy when those change. Where Pi throws on
78
+ * an invalid reserve value, this skips it and falls through to the next level.
79
+ */
80
+ export function compactionLimitTokens(
81
+ contextWindow: number,
82
+ settings: CompactionSettingsView | undefined,
83
+ model: ModelRef,
84
+ ): number | undefined {
85
+ const compaction = settings?.compaction;
86
+ if (!(compaction?.enabled ?? true) || !(contextWindow > 0)) return undefined;
87
+ const override = model
88
+ ? compaction?.modelOverrides?.[`${model.provider}/${model.id}`]
89
+ : undefined;
90
+ const overrideReserve =
91
+ typeof override === "object" && override !== null
92
+ ? validReserveTokens((override as { reserveTokens?: unknown }).reserveTokens)
93
+ : undefined;
94
+ const reserve =
95
+ overrideReserve ??
96
+ validReserveTokens(compaction?.reserveTokens) ??
97
+ PI_DEFAULT_COMPACTION_RESERVE_TOKENS;
98
+ const limit = contextWindow - reserve;
99
+ return limit > 0 ? limit : undefined;
100
+ }
101
+
102
+ /**
103
+ * Caches compactionLimitTokens per model (provider/id) and context window, so a footer
104
+ * render does not read settings each frame (Pi's getSettings deep-copies them). The
105
+ * limit is recomputed when the model or window changes, or after
106
+ * COMPACTION_LIMIT_REFRESH_MS, which picks up settings edits.
107
+ */
108
+ export function createCompactionLimitCache(
109
+ readSettings: () => CompactionSettingsView | undefined,
110
+ now: () => number = Date.now,
111
+ ): (contextWindow: number, model: ModelRef) => number | undefined {
112
+ let cached: { key: string; limit: number | undefined; readAt: number } | undefined;
113
+ return (contextWindow, model) => {
114
+ const key = `${model?.provider}/${model?.id}@${contextWindow}`;
115
+ const time = now();
116
+ if (cached?.key !== key || time - cached.readAt >= COMPACTION_LIMIT_REFRESH_MS) {
117
+ cached = {
118
+ key,
119
+ limit: compactionLimitTokens(contextWindow, readSettings(), model),
120
+ readAt: time,
121
+ };
122
+ }
123
+ return cached.limit;
124
+ };
125
+ }
126
+
127
+ /**
128
+ * Percent and denominator label of the context chip. "window" keeps Pi's figures;
129
+ * "compaction" measures against the compaction point; "both" also shows the window in
130
+ * brackets. Without a compaction point every mode falls back to the window.
131
+ */
132
+ export function contextChipFigures(
133
+ usage: { tokens: number | null; contextWindow: number; percent: number | null },
134
+ compactionLimit: number | undefined,
135
+ mode: FooterContextLimit,
136
+ ): { percent: number | null; limitLabel: string } {
137
+ const windowLabel = formatTokenCount(usage.contextWindow);
138
+ if (mode === "window" || compactionLimit === undefined) {
139
+ return { percent: usage.percent, limitLabel: windowLabel };
140
+ }
141
+ const percent = usage.tokens === null ? null : (usage.tokens * 100) / compactionLimit;
142
+ const compactionLabel = formatTokenCount(compactionLimit);
143
+ return {
144
+ percent,
145
+ limitLabel: mode === "both" ? `${compactionLabel} (${windowLabel})` : compactionLabel,
146
+ };
147
+ }
148
+
50
149
  const GIT_REFRESH_INTERVAL_MS = 10_000;
51
150
  const USAGE_REFRESH_INTERVAL_MS = 5 * 60 * 1000;
52
151
  // 后台连接 MCP 服务器不会触发 footer 重绘,靠这个兜底轮询把芯片刷出来
@@ -250,7 +349,8 @@ export function refreshFooterGitStats(): void {
250
349
  let refreshCurrentUsage: (() => void) | undefined;
251
350
  let refreshCurrentMcpChip: (() => void) | undefined;
252
351
  /** 工具/命令列表在 pi API 上,而 footer 工厂只拿得到 ctx,加载时记下来。 */
253
- let extensionApi: Pick<ExtensionAPI, "getAllTools" | "getCommands"> | undefined;
352
+ let extensionApi: Pick<ExtensionAPI, "getAllTools" | "getCommands" | "getSettings"> | undefined;
353
+ const cachedCompactionLimit = createCompactionLimitCache(() => extensionApi?.getSettings?.());
254
354
 
255
355
  const createCustomFooterFactory =
256
356
  (ctx: ExtensionContext) => (tui: any, theme: any, footerData: any) => {
@@ -376,8 +476,6 @@ const createCustomFooterFactory =
376
476
  tui.requestRender();
377
477
  });
378
478
 
379
- const fmt = formatTokenCount;
380
-
381
479
  // ---- pi-cc-status 风格:上下文条形图 ----
382
480
  const BAR_WIDTH = 10;
383
481
  const BAR_WARNING = 80; // >= 80% 转 warning 色
@@ -458,7 +556,18 @@ const createCustomFooterFactory =
458
556
  const model = ctx.model;
459
557
  const { contextUsage, cost, tokens, cachePct } = sessionStats();
460
558
  const contextWindow = contextUsage?.contextWindow ?? model?.contextWindow ?? 0;
461
- const percent = contextUsage?.percent;
559
+ const contextFigures = contextChipFigures(
560
+ {
561
+ tokens: contextUsage?.tokens ?? null,
562
+ contextWindow,
563
+ percent: contextUsage?.percent ?? null,
564
+ },
565
+ config.footerContextLimit === "window"
566
+ ? undefined
567
+ : cachedCompactionLimit(contextWindow, model),
568
+ config.footerContextLimit,
569
+ );
570
+ const percent = contextFigures.percent;
462
571
 
463
572
  // cwd 默认只显示最底层路径(根目录时回退完整路径)
464
573
  const cwdLabel = ctx.cwd.split(/[\\/]/).filter(Boolean).pop() || ctx.cwd;
@@ -538,7 +647,7 @@ const createCustomFooterFactory =
538
647
  ],
539
648
  [
540
649
  FOOTER_CONTEXT_KEY,
541
- barGauge(percent ?? 0) + theme.fg("dim", ` ${pctLabel}/${fmt(contextWindow)}`),
650
+ barGauge(percent ?? 0) + theme.fg("dim", ` ${pctLabel}/${contextFigures.limitLabel}`),
542
651
  ],
543
652
  [FOOTER_CACHE_KEY, cacheLabel ? theme.fg("dim", cacheLabel) : ""],
544
653
  [FOOTER_RATE_KEY, rateLabel ? theme.fg("dim", rateLabel) : ""],