pi-cc-extensions 0.8.58 → 0.8.59

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.en.md CHANGED
@@ -6,7 +6,6 @@
6
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
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="#compatibility"><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
- <a href="./extensions"><img alt="TypeScript extensions" src="https://img.shields.io/badge/TypeScript-extensions-3178C6?style=flat-square"></a>
10
9
  </p>
11
10
 
12
11
  <p align="center">
@@ -21,9 +20,7 @@
21
20
 
22
21
  ## Preview
23
22
 
24
- <table>
25
- <img width="100%" alt="demo_new" src="https://github.com/user-attachments/assets/d4f9bb51-a49a-4a34-aa60-006514d37b09" />
26
- </table>
23
+ https://github.com/user-attachments/assets/6c858000-fdad-43f9-957f-4d0278648498
27
24
 
28
25
  ## Quick start
29
26
 
package/README.md CHANGED
@@ -6,7 +6,6 @@
6
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
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
- <a href="./extensions"><img alt="TypeScript extensions" src="https://img.shields.io/badge/TypeScript-extensions-3178C6?style=flat-square"></a>
10
9
  </p>
11
10
 
12
11
  <p align="center">
@@ -21,9 +20,7 @@
21
20
 
22
21
  ## 界面预览
23
22
 
24
- <table>
25
- <img width="100%" alt="demo_new" src="https://github.com/user-attachments/assets/d4f9bb51-a49a-4a34-aa60-006514d37b09" />
26
- </table>
23
+ https://github.com/user-attachments/assets/6c858000-fdad-43f9-957f-4d0278648498
27
24
 
28
25
  ## 快速开始
29
26
 
@@ -415,6 +415,10 @@ export default function sessionReferenceExtension(pi: ExtensionAPI): void {
415
415
 
416
416
  pi.on("session_start", (_event, ctx) => {
417
417
  const generation = ++sessionGeneration;
418
+ // 会话替换/reload 会让 ctx 的 getter 抛 stale 错误,await 之后不能再读;
419
+ // 这里在同步阶段一次性取出纯值。
420
+ const currentCwd = ctx.cwd;
421
+ const ui = ctx.ui;
418
422
  subagentIds.clear();
419
423
  clearLiveSubagentRecords();
420
424
  let loadErrorShown = false;
@@ -434,7 +438,7 @@ export default function sessionReferenceExtension(pi: ExtensionAPI): void {
434
438
  if (!loadErrorShown) {
435
439
  loadErrorShown = true;
436
440
  const reason = error instanceof Error ? error.message : String(error);
437
- ctx.ui.notify(`session-reference: failed to load sessions: ${reason}`, "error");
441
+ ui.notify(`session-reference: failed to load sessions: ${reason}`, "error");
438
442
  }
439
443
  return [];
440
444
  });
@@ -447,6 +451,8 @@ export default function sessionReferenceExtension(pi: ExtensionAPI): void {
447
451
  | undefined;
448
452
  const getReferences = async (): Promise<SessionReference[]> => {
449
453
  const sessions = await getSessions();
454
+ // 会话替换/reload 后丢弃旧 generation 的结果,避免对失效状态继续工作。
455
+ if (generation !== sessionGeneration) return [];
450
456
  const subagentKey = [...subagentIds].join("\0");
451
457
  if (
452
458
  referencesCache &&
@@ -457,7 +463,7 @@ export default function sessionReferenceExtension(pi: ExtensionAPI): void {
457
463
  }
458
464
  const ordered = orderSessionReferences(
459
465
  mergeReferences(sessions, liveSubagentReferences(subagentIds, currentSessionId)),
460
- ctx.cwd,
466
+ currentCwd,
461
467
  );
462
468
  referencesCache = { sessions, subagentKey, ordered };
463
469
  return ordered;
@@ -465,13 +471,15 @@ export default function sessionReferenceExtension(pi: ExtensionAPI): void {
465
471
 
466
472
  getAvailableReferences = getReferences;
467
473
  if (ctx.mode === "tui") {
468
- void getReferences();
474
+ // 预取是 detached 的,必须兜住 rejection,否则 stale 错误会变成
475
+ // unhandled rejection 直接终止 Pi。
476
+ void getReferences().catch(() => {});
469
477
  // Register after other session_start handlers. pi-fff claims every @
470
478
  // prefix, so a provider installed before it would never see session mentions.
471
479
  setTimeout(() => {
472
480
  if (generation !== sessionGeneration) return;
473
- ctx.ui.addAutocompleteProvider((current) =>
474
- createAutocompleteProvider(current, getReferences, ctx.cwd),
481
+ ui.addAutocompleteProvider((current) =>
482
+ createAutocompleteProvider(current, getReferences, currentCwd),
475
483
  );
476
484
  }, 0);
477
485
  }
@@ -82,14 +82,23 @@ function renderAdmonition(lines: string[], i: number): { output: string[]; next:
82
82
  // 裸 URL 转可点击超链接
83
83
  // ============================================================================
84
84
 
85
- const URL_RE = /(?<!<)(?<!\]\()https?:\/\/[^\s<>'"|,。;:!?、」』】]+/g;
86
- const TRIM_URL_RE = /[.,;:!?】」』"'》]+$/;
85
+ const URL_RE = /(?<!<)(?<!\]\()https?:\/\/[^\s<>'"|,。;:!?、」』】()【】《》『』「」]+/g;
86
+ const TRIM_URL_RE = /[.,;:!?】」』"'》)}]+$/;
87
87
 
88
- /** 去掉 URL 尾部标点;括号按平衡保留(如 Wikipedia 链接含括号)。 */
88
+ /**
89
+ * 去掉 URL 尾部标点;括号按平衡保留(如 Wikipedia 链接含括号、
90
+ * IPv6 地址含 [::1]),尾部不成对的 ] 与 ) 会截掉。
91
+ */
89
92
  function trimUrl(url: string): string {
90
93
  let t = url.replace(TRIM_URL_RE, "");
91
- while (t.endsWith(")") && (t.match(/\(/g)?.length ?? 0) < (t.match(/\)/g)?.length ?? 0)) {
92
- t = t.slice(0, -1);
94
+ for (;;) {
95
+ if (t.endsWith(")") && (t.match(/\(/g)?.length ?? 0) < (t.match(/\)/g)?.length ?? 0)) {
96
+ t = t.slice(0, -1);
97
+ } else if (t.endsWith("]") && (t.match(/\[/g)?.length ?? 0) < (t.match(/\]/g)?.length ?? 0)) {
98
+ t = t.slice(0, -1);
99
+ } else {
100
+ break;
101
+ }
93
102
  }
94
103
  return t;
95
104
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-cc-extensions",
3
- "version": "0.8.58",
3
+ "version": "0.8.59",
4
4
  "license": "MIT",
5
5
  "description": "A Pi productivity suite with Claude Code-style UI, context inspection, and agent/session references",
6
6
  "type": "module",
@@ -21,6 +21,7 @@
21
21
  "files": [
22
22
  "extensions",
23
23
  "assets/readme",
24
+ "assets/video",
24
25
  "themes",
25
26
  "README.md",
26
27
  "README.en.md"
@@ -34,7 +35,7 @@
34
35
  "./themes/cc-light.json"
35
36
  ],
36
37
  "image": "https://raw.githubusercontent.com/minuque/pi-cc-extensions/main/assets/readme/welcome.webp",
37
- "video": "https://github.com/user-attachments/assets/debf76ea-a9dc-4f34-977f-aae344a9a7f8"
38
+ "video": "https://github.com/user-attachments/assets/6c858000-fdad-43f9-957f-4d0278648498"
38
39
  },
39
40
  "scripts": {
40
41
  "test": "node --test tests/**/*.test.ts",