pi-cc-extensions 0.7.5 → 0.7.7

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
@@ -3,8 +3,8 @@
3
3
  </p>
4
4
 
5
5
  <p align="center">
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.5.6" src="https://img.shields.io/badge/version-0.5.6-66E3C4?style=flat-square"></a>
6
+ <a href="https://pi.dev/packages?name=pi-cc-extensions"><img alt="Pi package catalog" src="https://img.shields.io/badge/Pi-package-58B7FF?style=flat-square"></a>
7
+ <a href="https://www.npmjs.com/package/pi-cc-extensions"><img alt="npm version" src="https://img.shields.io/npm/v/pi-cc-extensions?style=flat-square&color=66E3C4"></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>
@@ -54,7 +54,7 @@
54
54
  - Pi 默认输入栏
55
55
  - Edit / Write 的 Diff 预览
56
56
  - 工具结果的折叠与展开
57
- - `/ccstyle` 配置命令和 `Ctrl+Shift+O` 快捷键
57
+ - 类 claude code 滚动到底部 button
58
58
 
59
59
  常用命令:
60
60
 
@@ -79,13 +79,13 @@
79
79
 
80
80
  ### 历史 Session 引用
81
81
 
82
- `extensions/session-reference/index.ts` 将历史 Session 接入 `@` 补全:
82
+ `extensions/session-reference.ts` 将历史 Session 接入 `@` 补全:
83
83
 
84
84
  1. 在提示词中输入 `@`。
85
85
  2. 从 `[Session] ...` 或 `[SubAgent] ...` 补全项中选择要引用的上下文。
86
86
  3. 提交时以 `@session:<session-id>` 引用其当前有效上下文。
87
87
 
88
- Session 模糊查询默认显示 3 个候选,并与文件候选按 1:2 交错排列;路径型查询优先显示文件。若已加载 `pi-subagents`,也可直接引用现有 SubAgent。一次提示词可以引用多个 Session;扩展会自动去重,并限制注入规模以避免上下文无限膨胀。更多细节见 [`extensions/session-reference/README.md`](./extensions/session-reference/README.md)。
88
+ Session 模糊查询默认显示 3 个候选,并与文件候选按 1:2 交错排列;路径型查询优先显示文件。若已加载 `pi-subagents`,也可直接引用现有 SubAgent。一次提示词可以引用多个 Session;扩展会自动去重,并限制注入规模以避免上下文无限膨胀。
89
89
 
90
90
  ### SubAgent `@` 补全
91
91
 
@@ -46,7 +46,7 @@ export function createWrappedTextCache(content: string): {
46
46
 
47
47
  export async function showTextPreview(ctx: Pick<ExtensionCommandContext, "ui">, title: string, rawContent: string): Promise<void> {
48
48
  const content = normalizePreviewText(rawContent);
49
- await ctx.ui.custom<void>((tui, theme, _keybindings, done) => {
49
+ await ctx.ui.custom((tui, theme, _keybindings, done) => {
50
50
  let scrollOffset = 0;
51
51
  let pageSize = 1;
52
52
  let totalLines = 1;
@@ -63,7 +63,7 @@ export async function showTextPreview(ctx: Pick<ExtensionCommandContext, "ui">,
63
63
  },
64
64
  handleInput(data: string) {
65
65
  if (matchesKey(data, Key.escape) || matchesKey(data, Key.ctrl("c"))) {
66
- done();
66
+ done(undefined);
67
67
  return;
68
68
  }
69
69
  if (matchesKey(data, Key.up)) scrollTo(scrollOffset - 1);
@@ -161,6 +161,12 @@ const tokenEstimate = (value: unknown): number => {
161
161
  return Math.max(0, Math.ceil(text.length / 4));
162
162
  };
163
163
 
164
+ type ToolPreviewInfo = {
165
+ name: string;
166
+ description?: string;
167
+ promptGuidelines?: string[];
168
+ };
169
+
164
170
  export function scaleParts(parts: ContextPart[], target: number): ContextPart[] {
165
171
  const estimated = parts.reduce((sum, part) => sum + part.tokens, 0);
166
172
  if (estimated === 0 || target <= 0) return parts;
@@ -233,7 +239,9 @@ export default function contextUsageExtension(pi: ExtensionAPI) {
233
239
  }
234
240
 
235
241
  const options = ctx.getSystemPromptOptions();
236
- const toolByName = new Map(pi.getAllTools().map((tool) => [tool.name, tool]));
242
+ const toolByName = new Map<string, ToolPreviewInfo>(
243
+ (pi.getAllTools() as ToolPreviewInfo[]).map((tool) => [tool.name, tool] as const),
244
+ );
237
245
  const toolContent = (options.selectedTools ?? []).map((name) => {
238
246
  const tool = toolByName.get(name);
239
247
  const lines = [`## ${name}`];
@@ -273,7 +281,7 @@ export default function contextUsageExtension(pi: ExtensionAPI) {
273
281
  let selectedPreviewIndex = 0;
274
282
 
275
283
  while (true) {
276
- const action = await ctx.ui.custom<PreviewKey | undefined>((tui, theme, _keybindings, done) => {
284
+ const action = await ctx.ui.custom((tui, theme, _keybindings, done) => {
277
285
  let previewHitboxes: Array<{ key: PreviewKey; row: number; startCol: number; endCol: number }> = [];
278
286
 
279
287
  const padLine = (text: string, width: number): string => {
@@ -20,7 +20,7 @@ import {
20
20
  sessionTitle,
21
21
  type ReferenceSessionInfo,
22
22
  type ReferenceSource,
23
- } from "./core.ts";
23
+ } from "./session-reference-core.ts";
24
24
 
25
25
  const MAX_SESSION_SUGGESTIONS = 3;
26
26
  const MAX_FILE_SUGGESTIONS = 7;
package/package.json CHANGED
@@ -1,12 +1,22 @@
1
1
  {
2
2
  "name": "pi-cc-extensions",
3
- "version": "0.7.5",
4
- "description": "Personal extensions for the Pi coding agent",
3
+ "version": "0.7.7",
4
+ "description": "Claude Code-style UI, context insights, and session references for the Pi coding agent",
5
5
  "type": "module",
6
6
  "keywords": [
7
7
  "pi-package",
8
- "pi-extension"
8
+ "pi-extension",
9
+ "pi-coding-agent",
10
+ "claude-code"
9
11
  ],
12
+ "homepage": "https://github.com/minuque/pi-cc-extensions#readme",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/minuque/pi-cc-extensions.git"
16
+ },
17
+ "bugs": {
18
+ "url": "https://github.com/minuque/pi-cc-extensions/issues"
19
+ },
10
20
  "files": [
11
21
  "extensions",
12
22
  "assets/readme",
@@ -16,9 +26,10 @@
16
26
  "extensions": [
17
27
  "./extensions/claude-code-style.ts",
18
28
  "./extensions/context.ts",
19
- "./extensions/session-reference/index.ts",
29
+ "./extensions/session-reference.ts",
20
30
  "./extensions/agent-autocomplete.ts"
21
- ]
31
+ ],
32
+ "image": "https://raw.githubusercontent.com/minuque/pi-cc-extensions/main/assets/readme/fixed-editor-navigation.webp"
22
33
  },
23
34
  "scripts": {
24
35
  "test": "node --test tests/**/*.test.ts",
@@ -1,3 +0,0 @@
1
- # Extensions
2
-
3
- 扩展入口由根目录 `package.json` 的 `pi.extensions` 显式声明。辅助模块和测试文件不会被 Pi 当作独立扩展加载。
@@ -1,28 +0,0 @@
1
- # Session Reference
2
-
3
- 在 pi 编辑器中输入 `@`,从统一补全列表选择 `[Session] ...`,即可把历史 Session 绑定为:
4
-
5
- ```text
6
- @session:<session-id>
7
- ```
8
-
9
- 提交 prompt 时,扩展读取该 Session 当前有效分支(遵循分支与 compaction),以自定义上下文消息注入当前 Session。历史内容被标记为不可信背景上下文,不会切换或合并 Session。
10
-
11
- ## 行为
12
-
13
- - 搜索全部 pi 历史 Session;当前 Workspace 的 Session 优先。
14
- - Session 模糊查询默认最多显示 3 个候选。
15
- - 与 pi 原有 `@` 文件补全并存:普通查询按 1:2 交错排列 Session 与文件,路径型查询优先显示文件。
16
- - 若已加载 `pi-subagents`,`@` 补全会同时显示现有 SubAgent,并引用其当前有效上下文。
17
- - 支持一个 prompt 引用多个 Session,并自动去重;单次最多注入前 5 个。
18
- - 跳过历史 Session 中嵌套的 Session 引用,避免递归膨胀。
19
- - 上下文限制:单条消息 8 KB、单 Session 24 KB、总计 48 KB;超限保留开头和结尾。
20
- - 选择后仅插入引用标记;真正读取和注入发生在提交 prompt 时。
21
-
22
- 项目扩展可通过 `/reload` 热重载。
23
-
24
- ## 验证
25
-
26
- ```bash
27
- node --test .pi/extensions/session-reference/core.test.ts
28
- ```