pi-cc-extensions 0.5.6 → 0.6.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
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.5.6" src="https://img.shields.io/badge/version-0.5.6-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>
|
|
@@ -15,10 +15,15 @@
|
|
|
15
15
|
|
|
16
16
|
---
|
|
17
17
|
|
|
18
|
-
##
|
|
18
|
+
## 界面预览
|
|
19
19
|
|
|
20
20
|
<table>
|
|
21
21
|
<tr>
|
|
22
|
+
<td width="50%" align="center">
|
|
23
|
+
<img src="./assets/readme/fixed-editor-navigation.webp" width="100%" alt="Pi fixed-editor 中的工具结果、回到底部按钮与 Ctrl+End 快捷键">
|
|
24
|
+
<br>
|
|
25
|
+
<sub><b>固定编辑器工作流</b><br>工具结果摘要、折叠展开与键盘导航</sub>
|
|
26
|
+
</td>
|
|
22
27
|
<td width="50%" align="center">
|
|
23
28
|
<img src="./assets/readme/session-reference.webp" width="100%" alt="在 Pi 中通过 @ 补全选择历史 Session">
|
|
24
29
|
<br>
|
|
@@ -55,9 +60,9 @@
|
|
|
55
60
|
|
|
56
61
|
```text
|
|
57
62
|
/ccstyle # 切换开关
|
|
63
|
+
/ccstyle on # 开启
|
|
64
|
+
/ccstyle off # 关闭
|
|
58
65
|
/ccstyle status # 查看状态
|
|
59
|
-
/ccstyle compact # 紧凑摘要
|
|
60
|
-
/ccstyle minimal # 最小化输出
|
|
61
66
|
```
|
|
62
67
|
|
|
63
68
|
### 上下文窗口查看
|
|
@@ -82,6 +87,16 @@
|
|
|
82
87
|
|
|
83
88
|
Session 模糊查询默认显示 5 个候选;若已加载 `pi-subagents`,也可直接引用现有 SubAgent。一次提示词可以引用多个 Session;扩展会自动去重,并限制注入规模以避免上下文无限膨胀。更多细节见 [`extensions/session-reference/README.md`](./extensions/session-reference/README.md)。
|
|
84
89
|
|
|
90
|
+
### SubAgent `@` 补全
|
|
91
|
+
|
|
92
|
+
`extensions/agent-autocomplete.ts` 将 `~/.pi/agent/agents/*.md` 中定义的 SubAgent 接入 `@` 补全:
|
|
93
|
+
|
|
94
|
+
1. 在提示词中输入 `@agent-name`。
|
|
95
|
+
2. 从补全列表中选择 SubAgent。
|
|
96
|
+
3. 提交后自动注入委托指令;提示词中提到的每个 SubAgent 都会分别交由 Agent 工具处理。
|
|
97
|
+
|
|
98
|
+
该补全不会占用 `@session:` 的历史 Session 引用语法;修改 SubAgent 定义后执行 `/reload` 即可重新加载。
|
|
99
|
+
|
|
85
100
|
## 安装
|
|
86
101
|
|
|
87
102
|
从 npm 安装(推荐):
|
|
@@ -100,7 +115,7 @@ pi install git:github.com/minuque/pi-cc-extensions
|
|
|
100
115
|
|
|
101
116
|
```text
|
|
102
117
|
/context
|
|
103
|
-
/ccstyle
|
|
118
|
+
/ccstyle on
|
|
104
119
|
```
|
|
105
120
|
|
|
106
121
|
## 本地开发
|
|
@@ -126,20 +141,3 @@ pi install /absolute/path/to/pi-cc-extensions
|
|
|
126
141
|
|
|
127
142
|
- Node.js `>=22.19.0`
|
|
128
143
|
- 作为 Pi package 加载,入口由根目录 `package.json` 的 `pi.extensions` 显式声明
|
|
129
|
-
|
|
130
|
-
## 发布
|
|
131
|
-
|
|
132
|
-
发布前检查:
|
|
133
|
-
|
|
134
|
-
```bash
|
|
135
|
-
npm test
|
|
136
|
-
npm pack --dry-run
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
使用 npm 发布。未指定 tag 时使用 `latest`:
|
|
140
|
-
|
|
141
|
-
```bash
|
|
142
|
-
npm run release
|
|
143
|
-
npm run release -- --tag next
|
|
144
|
-
npm run release -- --tag beta
|
|
145
|
-
```
|
|
Binary file
|
|
@@ -30,18 +30,13 @@ import { join, resolve } from "node:path";
|
|
|
30
30
|
* /ccstyle on enable
|
|
31
31
|
* /ccstyle off disable
|
|
32
32
|
* /ccstyle status show current state
|
|
33
|
-
* /ccstyle minimal hide most tool output in collapsed view
|
|
34
|
-
* /ccstyle compact show short summaries in collapsed view
|
|
35
33
|
*
|
|
36
34
|
* Shortcut:
|
|
37
35
|
* ctrl+shift+o toggle on/off
|
|
38
36
|
*/
|
|
39
37
|
|
|
40
|
-
type StyleMode = "compact" | "minimal";
|
|
41
|
-
|
|
42
38
|
type Config = {
|
|
43
39
|
enabled: boolean;
|
|
44
|
-
mode: StyleMode;
|
|
45
40
|
};
|
|
46
41
|
|
|
47
42
|
const CONFIG_PATH = join(homedir(), ".pi", "agent", "claude-code-style.json");
|
|
@@ -54,13 +49,12 @@ function loadConfig(): Config {
|
|
|
54
49
|
const parsed = JSON.parse(readFileSync(CONFIG_PATH, "utf8")) as Partial<Config>;
|
|
55
50
|
return {
|
|
56
51
|
enabled: parsed.enabled ?? true,
|
|
57
|
-
mode: parsed.mode === "minimal" ? "minimal" : "compact",
|
|
58
52
|
};
|
|
59
53
|
}
|
|
60
54
|
} catch {
|
|
61
55
|
// Ignore bad config and fall back to defaults.
|
|
62
56
|
}
|
|
63
|
-
return { enabled: true
|
|
57
|
+
return { enabled: true };
|
|
64
58
|
}
|
|
65
59
|
|
|
66
60
|
function saveConfig() {
|
|
@@ -1097,7 +1091,7 @@ function renderFileDiffPreview(_toolName: string, _args: any, theme: any, contex
|
|
|
1097
1091
|
}
|
|
1098
1092
|
|
|
1099
1093
|
function statusText() {
|
|
1100
|
-
return config.enabled ?
|
|
1094
|
+
return config.enabled ? "CC on" : "CC off";
|
|
1101
1095
|
}
|
|
1102
1096
|
|
|
1103
1097
|
function updateStatus(ctx: any) {
|
|
@@ -1207,14 +1201,7 @@ function createCcstyleTool(originalTool: any): any {
|
|
|
1207
1201
|
const expanded = isToolExpanded(options, context);
|
|
1208
1202
|
|
|
1209
1203
|
const text = textFromResult(result);
|
|
1210
|
-
|
|
1211
|
-
if (config.mode === "minimal" && !expanded) {
|
|
1212
|
-
rendered = "";
|
|
1213
|
-
} else if (!expanded) {
|
|
1214
|
-
rendered = text ? oneLine(text, 96) : "Done";
|
|
1215
|
-
} else {
|
|
1216
|
-
rendered = text;
|
|
1217
|
-
}
|
|
1204
|
+
const rendered = !expanded ? (text ? oneLine(text, 96) : "Done") : text;
|
|
1218
1205
|
|
|
1219
1206
|
const hint = !expanded && hasExpandableResult(text) ? expandHint(theme) : "";
|
|
1220
1207
|
if (expanded) return renderExpandedToolResult(rendered, theme, isError);
|
|
@@ -1509,35 +1496,27 @@ export default function (pi: ExtensionAPI) {
|
|
|
1509
1496
|
const topLevel = [
|
|
1510
1497
|
{ value: "on", label: "on", description: "Enable Claude Code style" },
|
|
1511
1498
|
{ value: "off", label: "off", description: "Disable Claude Code style" },
|
|
1512
|
-
{ value: "status", label: "status", description: "Show current
|
|
1513
|
-
{ value: "minimal", label: "minimal", description: "Hide most tool output in collapsed view" },
|
|
1514
|
-
{ value: "compact", label: "compact", description: "Show short summaries in collapsed view" },
|
|
1499
|
+
{ value: "status", label: "status", description: "Show current state" },
|
|
1515
1500
|
];
|
|
1516
1501
|
return topLevel.filter((item) => item.value.startsWith(prefix));
|
|
1517
1502
|
},
|
|
1518
1503
|
handler: async (args, ctx) => {
|
|
1519
1504
|
const arg = args.trim().toLowerCase();
|
|
1520
|
-
if (arg === "on"
|
|
1521
|
-
else if (arg === "off"
|
|
1522
|
-
else if (arg === "
|
|
1523
|
-
config.enabled = true;
|
|
1524
|
-
config.mode = "minimal";
|
|
1525
|
-
} else if (arg === "compact") {
|
|
1526
|
-
config.enabled = true;
|
|
1527
|
-
config.mode = "compact";
|
|
1528
|
-
} else if (arg === "status") {
|
|
1505
|
+
if (arg === "on") config.enabled = true;
|
|
1506
|
+
else if (arg === "off") config.enabled = false;
|
|
1507
|
+
else if (arg === "status") {
|
|
1529
1508
|
updateStatus(ctx);
|
|
1530
|
-
ctx.ui.notify(
|
|
1531
|
-
`Claude Code style: ${config.enabled ? "on" : "off"}, mode=${config.mode}`,
|
|
1532
|
-
"info",
|
|
1533
|
-
);
|
|
1509
|
+
ctx.ui.notify(`Claude Code style: ${config.enabled ? "on" : "off"}`, "info");
|
|
1534
1510
|
return;
|
|
1535
|
-
} else {
|
|
1511
|
+
} else if (!arg) {
|
|
1536
1512
|
config.enabled = !config.enabled;
|
|
1513
|
+
} else {
|
|
1514
|
+
ctx.ui.notify("Usage: /ccstyle [on|off|status]", "warning");
|
|
1515
|
+
return;
|
|
1537
1516
|
}
|
|
1538
1517
|
saveConfig();
|
|
1539
1518
|
updateStatus(ctx);
|
|
1540
|
-
ctx.ui.notify(`Claude Code style: ${config.enabled ? "on" : "off"}
|
|
1519
|
+
ctx.ui.notify(`Claude Code style: ${config.enabled ? "on" : "off"}`, "info");
|
|
1541
1520
|
},
|
|
1542
1521
|
});
|
|
1543
1522
|
|
|
@@ -1584,7 +1563,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
1584
1563
|
call: (args) => fileAction(args, "Read"),
|
|
1585
1564
|
result: (result, { expanded }) => {
|
|
1586
1565
|
const text = textFromResult(result);
|
|
1587
|
-
if (config.mode === "minimal" && !expanded) return "";
|
|
1588
1566
|
if (!expanded) return `${countLines(text)} lines read`;
|
|
1589
1567
|
return text;
|
|
1590
1568
|
},
|
|
@@ -1594,7 +1572,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
1594
1572
|
call: (args) => `Bash(${oneLine(args?.command, 86) || "..."})`,
|
|
1595
1573
|
result: (result, { expanded }) => {
|
|
1596
1574
|
const text = textFromResult(result).trim();
|
|
1597
|
-
if (config.mode === "minimal" && !expanded) return "";
|
|
1598
1575
|
if (!expanded) return summarizeBash(text);
|
|
1599
1576
|
return text;
|
|
1600
1577
|
},
|
|
@@ -1606,7 +1583,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
1606
1583
|
diffAfterResult: true,
|
|
1607
1584
|
result: (result, { expanded }, _theme, context) => {
|
|
1608
1585
|
const text = textFromResult(result).trim();
|
|
1609
|
-
if (config.mode === "minimal" && !expanded) return "";
|
|
1610
1586
|
return summarizeDiffStats(context?.state?.ccstyleDiffPreview) ?? summarizeEdit(text);
|
|
1611
1587
|
},
|
|
1612
1588
|
});
|
|
@@ -1621,7 +1597,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
1621
1597
|
diffAfterResult: true,
|
|
1622
1598
|
result: (result, { expanded }, _theme, context) => {
|
|
1623
1599
|
const text = textFromResult(result).trim();
|
|
1624
|
-
if (config.mode === "minimal" && !expanded) return "";
|
|
1625
1600
|
return summarizeDiffStats(context?.state?.ccstyleDiffPreview) ?? (text ? oneLine(text, 96) : "Written");
|
|
1626
1601
|
},
|
|
1627
1602
|
});
|
|
@@ -1630,7 +1605,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
1630
1605
|
call: (args) => `Find(${args?.pattern || "..."}${args?.path ? ` in ${shortenPath(args.path)}` : ""})`,
|
|
1631
1606
|
result: (result, { expanded }) => {
|
|
1632
1607
|
const text = textFromResult(result).trim();
|
|
1633
|
-
if (config.mode === "minimal" && !expanded) return "";
|
|
1634
1608
|
if (!expanded) return `${countLines(text)} files`;
|
|
1635
1609
|
return text;
|
|
1636
1610
|
},
|
|
@@ -1640,7 +1614,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
1640
1614
|
call: (args) => `Grep(${args?.pattern ? `/${oneLine(args.pattern, 48)}/` : "..."})`,
|
|
1641
1615
|
result: (result, { expanded }) => {
|
|
1642
1616
|
const text = textFromResult(result).trim();
|
|
1643
|
-
if (config.mode === "minimal" && !expanded) return "";
|
|
1644
1617
|
if (!expanded) {
|
|
1645
1618
|
const matches = countLines(text);
|
|
1646
1619
|
const files = parsePathCount(text);
|
|
@@ -1654,7 +1627,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
1654
1627
|
call: (args) => `List(${shortenPath(args?.path || ".")})`,
|
|
1655
1628
|
result: (result, { expanded }) => {
|
|
1656
1629
|
const text = textFromResult(result).trim();
|
|
1657
|
-
if (config.mode === "minimal" && !expanded) return "";
|
|
1658
1630
|
if (!expanded) return `${countLines(text)} entries`;
|
|
1659
1631
|
return text;
|
|
1660
1632
|
},
|