@georgewuw/pi-chat-navi 0.1.1 → 0.1.2
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 +8 -4
- package/package.json +2 -2
- package/src/jump.ts +1 -1
- package/src/logic.ts +4 -0
package/README.md
CHANGED
|
@@ -62,7 +62,7 @@ pi -ne -e . # pi 用 jiti 直接加载 src/index.ts,无需构建
|
|
|
62
62
|
|
|
63
63
|
```
|
|
64
64
|
pnpm install # 首次需要:契约测试依赖 devDependencies 里的真实 pi 包
|
|
65
|
-
pnpm run typecheck # tsc
|
|
65
|
+
pnpm run typecheck # tsc 类型检查(含 test/,tsconfig 的 include 覆盖 src 与 test)
|
|
66
66
|
pnpm test # 逻辑单测 + 契约测试(针对 devDependencies 里装的 pi 版本)
|
|
67
67
|
pnpm run test:compat # 用 npm 上最新的 pi 版本跑契约测试
|
|
68
68
|
pnpm run test:compat -- 1.6.0 latest # 指定多个版本
|
|
@@ -70,11 +70,15 @@ pnpm run test:compat -- --keep 1.6.0 # 保留临时目录便于排查
|
|
|
70
70
|
pnpm run test:compat -- --verbose 1.6.0 # 失败时打印完整测试输出
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
-
- `test/logic.test.
|
|
74
|
-
- `test/contract.test.
|
|
75
|
-
|
|
73
|
+
- `test/logic.test.ts`:`logic.ts` 的纯函数。
|
|
74
|
+
- `test/contract.test.ts`:测试本身也是 TypeScript,用 `node --test` 直接跑(Node 22 原生类型剥离),
|
|
75
|
+
不依赖 ts-node/tsx,也不需要先构建;同时 `pnpm run typecheck` 会把它们一起检查,
|
|
76
|
+
所以 fixture 写错字段(例如构造会话条目时拼错 `stopReason`)会在编译期就报错。
|
|
77
|
+
内容上:按 pi 的挂载方式搭一段 transcript,验证 `jump.ts` 与 `logic.ts` 对 pi 的假设:布局字段是否存在、
|
|
76
78
|
OSC 133;A 标记数量与序号是否与推算一致、标记法和文本匹配兜底是否都落在正确行。
|
|
77
79
|
pi 改了内部实现时,失败信息会指出是哪个字段或规则变了。
|
|
80
|
+
(几处 `as unknown as` 是故意的:`findTranscript` 只暴露 `jump.ts` 需要的最小接口,测试要读 `ScrollView.scrollTop`
|
|
81
|
+
和 `TuiAltScreen.currentLayout` 这类内部字段,必须显式放宽类型。)
|
|
78
82
|
- 升级 pi 前后,运行 `pnpm run test:compat`;失败时先看失败信息指出的是哪条假设:跳转相关的改 `src/jump.ts`,
|
|
79
83
|
标记数量/顺序相关(OSC 133;A 由哪些消息写入)的改 `src/logic.ts` 里镜像 pi 渲染规则的部分
|
|
80
84
|
(`assistantWritesMarker`、`renderedUserText`)。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@georgewuw/pi-chat-navi",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"packageManager": "pnpm@12.15.0",
|
|
6
6
|
"description": "pi coding agent extension:TUI 提问跳转面板(/questions)",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"scripts": {
|
|
35
35
|
"typecheck": "tsc -p .",
|
|
36
36
|
"test:compat": "node scripts/compat.mjs",
|
|
37
|
-
"test": "node --test test/logic.test.
|
|
37
|
+
"test": "node --test test/logic.test.ts test/contract.test.ts",
|
|
38
38
|
"check": "pnpm run typecheck && pnpm test",
|
|
39
39
|
"prepublishOnly": "pnpm run check"
|
|
40
40
|
},
|
package/src/jump.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 跳转:把 transcript 滚动到某条用户提问。
|
|
5
5
|
* 本仓库里所有依赖 pi TUI 内部实现的代码都集中在这个文件;pi 升级后跳转失效,只需要查这里。
|
|
6
|
-
* test/contract.test.
|
|
6
|
+
* test/contract.test.ts 用真实的 pi 包验证这里的全部假设。
|
|
7
7
|
*
|
|
8
8
|
* pi 未公开暴露 transcript 组件,这里对 TUI 内部布局对象做运行时特征检测:
|
|
9
9
|
* currentLayout → 含 scrollContentLines 的 box → ScrollView.scrollTo(row)。
|
package/src/logic.ts
CHANGED
|
@@ -12,11 +12,15 @@
|
|
|
12
12
|
export interface SessionEntryLike {
|
|
13
13
|
type?: string;
|
|
14
14
|
id?: string;
|
|
15
|
+
/** 压缩条目的保留起点 */
|
|
15
16
|
firstKeptEntryId?: string;
|
|
17
|
+
/** 压缩条目的摘要文本(logic.ts 不读,但条目里确实存在) */
|
|
18
|
+
summary?: string;
|
|
16
19
|
message?: {
|
|
17
20
|
role?: string;
|
|
18
21
|
content?: unknown;
|
|
19
22
|
stopReason?: string;
|
|
23
|
+
timestamp?: number;
|
|
20
24
|
toolCallId?: string;
|
|
21
25
|
isError?: boolean;
|
|
22
26
|
command?: string;
|