pi-cc-extensions 0.2.0 → 0.4.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.
- package/README.md +2 -19
- package/extensions/claude-code-style.ts +36 -57
- package/package.json +1 -1
- package/assets/readme/showcase.webp +0 -0
- package/assets/readme/welcome.webp +0 -0
- package/extensions/ccstyle-powerline/bash-mode/completion.ts +0 -556
- package/extensions/ccstyle-powerline/bash-mode/editor.ts +0 -442
- package/extensions/ccstyle-powerline/bash-mode/history.ts +0 -151
- package/extensions/ccstyle-powerline/bash-mode/shell-session.ts +0 -286
- package/extensions/ccstyle-powerline/bash-mode/transcript.ts +0 -108
- package/extensions/ccstyle-powerline/bash-mode/types.ts +0 -59
- package/extensions/ccstyle-powerline/colors.ts +0 -69
- package/extensions/ccstyle-powerline/context-usage.ts +0 -46
- package/extensions/ccstyle-powerline/fixed-editor/cluster.ts +0 -107
- package/extensions/ccstyle-powerline/fixed-editor/terminal-split.ts +0 -1318
- package/extensions/ccstyle-powerline/git-status.ts +0 -283
- package/extensions/ccstyle-powerline/icons.ts +0 -181
- package/extensions/ccstyle-powerline/powerline-config.ts +0 -234
- package/extensions/ccstyle-powerline/powerline.ts +0 -3150
- package/extensions/ccstyle-powerline/presets.ts +0 -109
- package/extensions/ccstyle-powerline/render-scheduler.ts +0 -24
- package/extensions/ccstyle-powerline/segments.ts +0 -486
- package/extensions/ccstyle-powerline/separators.ts +0 -41
- package/extensions/ccstyle-powerline/shortcuts.ts +0 -57
- package/extensions/ccstyle-powerline/theme.json +0 -26
- package/extensions/ccstyle-powerline/theme.ts +0 -241
- package/extensions/ccstyle-powerline/types.ts +0 -200
- package/extensions/ccstyle-powerline/welcome-dismiss.ts +0 -34
- package/extensions/ccstyle-powerline/welcome.ts +0 -611
- package/extensions/ccstyle-powerline/working-vibes.ts +0 -695
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
6
|
<a href="#安装"><img alt="Pi package" src="https://img.shields.io/badge/Pi-package-58B7FF?style=flat-square"></a>
|
|
7
|
-
<a href="./package.json"><img alt="Version 0.
|
|
7
|
+
<a href="./package.json"><img alt="Version 0.2.0" src="https://img.shields.io/badge/version-0.2.0-66E3C4?style=flat-square"></a>
|
|
8
8
|
<a href="#兼容性"><img alt="Node.js 22.19 or newer" src="https://img.shields.io/badge/Node.js-%E2%89%A522.19-66E3C4?style=flat-square"></a>
|
|
9
9
|
<a href="./extensions"><img alt="TypeScript extensions" src="https://img.shields.io/badge/TypeScript-extensions-3178C6?style=flat-square"></a>
|
|
10
10
|
</p>
|
|
@@ -18,19 +18,7 @@
|
|
|
18
18
|
## 截图
|
|
19
19
|
|
|
20
20
|
<table>
|
|
21
|
-
<tr>
|
|
22
|
-
<td colspan="2" align="center">
|
|
23
|
-
<img src="./assets/readme/welcome.webp" width="100%" alt="Pi 的 Welcome 界面,展示 Tips、已加载上下文、扩展和最近会话">
|
|
24
|
-
<br>
|
|
25
|
-
<sub><b>Welcome 界面</b><br>启动时查看已加载上下文、扩展与最近会话</sub>
|
|
26
|
-
</td>
|
|
27
|
-
</tr>
|
|
28
21
|
<tr>
|
|
29
|
-
<td width="50%" align="center">
|
|
30
|
-
<img src="./assets/readme/showcase.webp" width="100%" alt="Pi 终端中的 Claude Code 风格扩展界面,包含工具调用摘要、Diff 预览和 Powerline 状态栏">
|
|
31
|
-
<br>
|
|
32
|
-
<sub><b>Claude Code 风格界面</b><br>工具调用摘要、Diff 预览与 Powerline 状态栏</sub>
|
|
33
|
-
</td>
|
|
34
22
|
<td width="50%" align="center">
|
|
35
23
|
<img src="./assets/readme/session-reference.webp" width="100%" alt="在 Pi 中通过 @ 补全选择历史 Session">
|
|
36
24
|
<br>
|
|
@@ -58,7 +46,7 @@
|
|
|
58
46
|
`extensions/claude-code-style.ts` 提供:
|
|
59
47
|
|
|
60
48
|
- Claude Code 风格的工具调用行与结果摘要
|
|
61
|
-
-
|
|
49
|
+
- Pi 默认输入栏
|
|
62
50
|
- Edit / Write 的 Diff 预览
|
|
63
51
|
- 工具结果的折叠与展开
|
|
64
52
|
- `/ccstyle` 配置命令和 `Ctrl+Shift+O` 快捷键
|
|
@@ -70,7 +58,6 @@
|
|
|
70
58
|
/ccstyle status # 查看状态
|
|
71
59
|
/ccstyle compact # 紧凑摘要
|
|
72
60
|
/ccstyle minimal # 最小化输出
|
|
73
|
-
/ccstyle powerline # 查看 Powerline 预设
|
|
74
61
|
```
|
|
75
62
|
|
|
76
63
|
### 上下文窗口查看
|
|
@@ -156,7 +143,3 @@ npm run release
|
|
|
156
143
|
npm run release -- --tag next
|
|
157
144
|
npm run release -- --tag beta
|
|
158
145
|
```
|
|
159
|
-
|
|
160
|
-
## 致谢
|
|
161
|
-
|
|
162
|
-
本项目中的 Powerline 状态栏、Welcome 界面、Working Vibes 等功能基于 [nicobailon/pi-powerline-footer](https://github.com/nicobailon/pi-powerline-footer) 二次开发,感谢原作者的开源贡献。
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
ToolExecutionComponent,
|
|
14
14
|
} from "@earendil-works/pi-coding-agent";
|
|
15
15
|
import { Text, truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
|
|
16
|
-
import powerlineFooter from "./ccstyle-powerline/powerline.ts";
|
|
17
16
|
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
18
17
|
import { readFile, stat } from "node:fs/promises";
|
|
19
18
|
import { homedir } from "node:os";
|
|
@@ -22,13 +21,9 @@ import { join, resolve } from "node:path";
|
|
|
22
21
|
/**
|
|
23
22
|
* Claude Code Style for pi
|
|
24
23
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* latest output, including when new messages arrive. Click it, or use the
|
|
29
|
-
* displayed shortcut, to resume following the chat. Edit/write tool calls also
|
|
30
|
-
* show a bounded, colorized diff preview with +/- lines after execution. A
|
|
31
|
-
* collapsed tool result can be clicked on its Ctrl+O hint to expand only that tool.
|
|
24
|
+
* Edit/write tool calls show a bounded, colorized diff preview with +/- lines
|
|
25
|
+
* after execution. A collapsed tool result can be clicked on its Ctrl+O hint to
|
|
26
|
+
* expand only that tool.
|
|
32
27
|
*
|
|
33
28
|
* Dynamic commands:
|
|
34
29
|
* /ccstyle toggle on/off
|
|
@@ -37,7 +32,6 @@ import { join, resolve } from "node:path";
|
|
|
37
32
|
* /ccstyle status show current state
|
|
38
33
|
* /ccstyle minimal hide most tool output in collapsed view
|
|
39
34
|
* /ccstyle compact show short summaries in collapsed view
|
|
40
|
-
* /ccstyle powerline compact|full|default|minimal|nerd|ascii|custom
|
|
41
35
|
*
|
|
42
36
|
* Shortcut:
|
|
43
37
|
* ctrl+shift+o toggle on/off
|
|
@@ -178,31 +172,46 @@ function animationFrame(frames: string[], intervalMs = 120): string {
|
|
|
178
172
|
return frames[Math.floor(Date.now() / intervalMs) % frames.length] ?? frames[0] ?? "";
|
|
179
173
|
}
|
|
180
174
|
|
|
181
|
-
const
|
|
175
|
+
const activeAnimationContexts = new Set<any>();
|
|
176
|
+
let sharedAnimationTimer: ReturnType<typeof setTimeout> | null = null;
|
|
182
177
|
|
|
183
178
|
function clearAnimation(context: any) {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
179
|
+
if (!context?.state?.ccstyleAnimationScheduled) return;
|
|
180
|
+
context.state.ccstyleAnimationScheduled = false;
|
|
181
|
+
activeAnimationContexts.delete(context);
|
|
182
|
+
if (activeAnimationContexts.size === 0 && sharedAnimationTimer) {
|
|
183
|
+
clearTimeout(sharedAnimationTimer);
|
|
184
|
+
sharedAnimationTimer = null;
|
|
185
|
+
}
|
|
189
186
|
}
|
|
190
187
|
|
|
191
188
|
function clearAllAnimations() {
|
|
192
|
-
for (const
|
|
193
|
-
|
|
189
|
+
for (const ctx of activeAnimationContexts) {
|
|
190
|
+
ctx.state.ccstyleAnimationScheduled = false;
|
|
191
|
+
}
|
|
192
|
+
activeAnimationContexts.clear();
|
|
193
|
+
if (sharedAnimationTimer) {
|
|
194
|
+
clearTimeout(sharedAnimationTimer);
|
|
195
|
+
sharedAnimationTimer = null;
|
|
196
|
+
}
|
|
194
197
|
}
|
|
195
198
|
|
|
196
199
|
function scheduleAnimation(context: any, intervalMs = 80) {
|
|
197
200
|
const state = (context.state ??= {});
|
|
198
|
-
if (state.
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
201
|
+
if (state.ccstyleAnimationScheduled) return;
|
|
202
|
+
state.ccstyleAnimationScheduled = true;
|
|
203
|
+
activeAnimationContexts.add(context);
|
|
204
|
+
if (!sharedAnimationTimer) {
|
|
205
|
+
sharedAnimationTimer = setTimeout(() => {
|
|
206
|
+
sharedAnimationTimer = null;
|
|
207
|
+
const contexts = Array.from(activeAnimationContexts);
|
|
208
|
+
activeAnimationContexts.clear();
|
|
209
|
+
for (const ctx of contexts) {
|
|
210
|
+
ctx.state.ccstyleAnimationScheduled = false;
|
|
211
|
+
ctx.invalidate?.();
|
|
212
|
+
}
|
|
213
|
+
}, intervalMs);
|
|
214
|
+
}
|
|
206
215
|
}
|
|
207
216
|
|
|
208
217
|
function pendingIcon(name: string): string {
|
|
@@ -835,11 +844,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
835
844
|
installGlobalToolRendering();
|
|
836
845
|
deactivateLegacyCompactionRendering();
|
|
837
846
|
|
|
838
|
-
// Bundle the full powerline footer into ccstyle so it is loaded as one plugin.
|
|
839
|
-
const powerline = powerlineFooter(pi);
|
|
840
|
-
|
|
841
847
|
pi.registerCommand("ccstyle", {
|
|
842
|
-
description: "Configure Claude Code style
|
|
848
|
+
description: "Configure Claude Code style",
|
|
843
849
|
getArgumentCompletions: (prefix) => {
|
|
844
850
|
const topLevel = [
|
|
845
851
|
{ value: "on", label: "on", description: "Enable Claude Code style" },
|
|
@@ -847,38 +853,11 @@ export default function (pi: ExtensionAPI) {
|
|
|
847
853
|
{ value: "status", label: "status", description: "Show current toggle and mode" },
|
|
848
854
|
{ value: "minimal", label: "minimal", description: "Hide most tool output in collapsed view" },
|
|
849
855
|
{ value: "compact", label: "compact", description: "Show short summaries in collapsed view" },
|
|
850
|
-
{ value: "powerline", label: "powerline", description: "Set Powerline preset (e.g. powerline compact)" },
|
|
851
856
|
];
|
|
852
|
-
// If the user typed "powerline " — suggest available presets
|
|
853
|
-
const match = prefix.match(/^powerline\s+/i);
|
|
854
|
-
if (match) {
|
|
855
|
-
const after = prefix.slice(match[0].length);
|
|
856
|
-
return powerline.getPresets()
|
|
857
|
-
.filter((p) => p.startsWith(after))
|
|
858
|
-
.map((p) => ({ value: `powerline ${p}`, label: p, description: `Powerline preset: ${p}` }));
|
|
859
|
-
}
|
|
860
857
|
return topLevel.filter((item) => item.value.startsWith(prefix));
|
|
861
858
|
},
|
|
862
859
|
handler: async (args, ctx) => {
|
|
863
860
|
const arg = args.trim().toLowerCase();
|
|
864
|
-
const parts = arg.split(/\s+/).filter(Boolean);
|
|
865
|
-
if (parts[0] === "powerline") {
|
|
866
|
-
const requested = parts[1] === "mode" ? parts[2] : parts[1];
|
|
867
|
-
if (!requested) {
|
|
868
|
-
ctx.ui.notify(`Powerline preset: ${powerline.getPreset()}. Available: ${powerline.getPresets().join(", ")}`, "info");
|
|
869
|
-
return;
|
|
870
|
-
}
|
|
871
|
-
const result = powerline.setPreset(requested, ctx);
|
|
872
|
-
if (!result.valid) {
|
|
873
|
-
ctx.ui.notify(`Unknown Powerline preset: ${requested}. Available: ${powerline.getPresets().join(", ")}`, "warning");
|
|
874
|
-
return;
|
|
875
|
-
}
|
|
876
|
-
ctx.ui.notify(
|
|
877
|
-
`Powerline preset set to: ${requested}${result.persisted ? "" : " (not persisted; check settings.json)"}`,
|
|
878
|
-
result.persisted ? "info" : "warning",
|
|
879
|
-
);
|
|
880
|
-
return;
|
|
881
|
-
}
|
|
882
861
|
if (arg === "on" || arg === "enable") config.enabled = true;
|
|
883
862
|
else if (arg === "off" || arg === "disable") config.enabled = false;
|
|
884
863
|
else if (arg === "minimal") {
|
|
@@ -890,7 +869,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
890
869
|
} else if (arg === "status") {
|
|
891
870
|
updateStatus(ctx);
|
|
892
871
|
ctx.ui.notify(
|
|
893
|
-
`Claude Code style: ${config.enabled ? "on" : "off"}, mode=${config.mode}
|
|
872
|
+
`Claude Code style: ${config.enabled ? "on" : "off"}, mode=${config.mode}`,
|
|
894
873
|
"info",
|
|
895
874
|
);
|
|
896
875
|
return;
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|