@zhushanwen/pi-plan 0.4.2 → 0.4.4
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/package.json +4 -3
- package/src/compact.ts +25 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhushanwen/pi-plan",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "Lightweight plan mode for Pi coding agent",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.ts",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"@earendil-works/pi-coding-agent": ">=0.73.0",
|
|
22
22
|
"typebox": "*",
|
|
23
23
|
"@earendil-works/pi-ai": "^0.84.4",
|
|
24
|
-
"@zhushanwen/pi-goal": "0.
|
|
24
|
+
"@zhushanwen/pi-goal": "0.14.0"
|
|
25
25
|
},
|
|
26
26
|
"peerDependenciesMeta": {
|
|
27
27
|
"@earendil-works/pi-ai": {
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
"templates/"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@zhushanwen/pi-
|
|
41
|
+
"@zhushanwen/pi-ext-guards": "0.3.0",
|
|
42
|
+
"@zhushanwen/pi-extension-logger": "0.6.0"
|
|
42
43
|
},
|
|
43
44
|
"scripts": {
|
|
44
45
|
"typecheck": "npx tsc --noEmit",
|
package/src/compact.ts
CHANGED
|
@@ -2,11 +2,15 @@ import * as fs from "node:fs";
|
|
|
2
2
|
import { basename } from "node:path";
|
|
3
3
|
|
|
4
4
|
import type { ExtensionAPI, ExtensionContext, SessionBeforeCompactEvent, SessionBeforeTreeEvent } from "@earendil-works/pi-coding-agent";
|
|
5
|
+
import { guardStaleCtx, toErrorMessage } from "@zhushanwen/pi-ext-guards";
|
|
5
6
|
import type { GoalInitFn } from "@zhushanwen/pi-goal";
|
|
7
|
+
import { getLogger } from "@zhushanwen/pi-extension-logger";
|
|
6
8
|
|
|
7
9
|
import type { PlanSessionMap, PlanState } from "./state.js";
|
|
8
10
|
import { getPlanState } from "./state.js";
|
|
9
11
|
|
|
12
|
+
const logger = getLogger("pi-plan");
|
|
13
|
+
|
|
10
14
|
export function registerPlanEventHandlers(
|
|
11
15
|
pi: ExtensionAPI,
|
|
12
16
|
sessions: PlanSessionMap,
|
|
@@ -217,14 +221,30 @@ export function handlePlanComplete(
|
|
|
217
221
|
case "compact": {
|
|
218
222
|
ctx.compact({
|
|
219
223
|
customInstructions: `Plan file: ${planFilePath}. Read plan and execute implementation.`,
|
|
224
|
+
// E1 同构崩溃点(crash-resilience D1):onComplete/onError 由 compact 内部
|
|
225
|
+
// Promise 链异步调用、不在 pi runner emit() 的 try/catch 内——压缩进行中用户
|
|
226
|
+
// 切换/重载 session 后,回调触碰捕获的 pi/ctx 命中 stale 同步抛错即杀 pi 进程。
|
|
227
|
+
// 守卫 stale 静默降级(执行消息不投递,用户可手动 Read plan 文件执行),非
|
|
228
|
+
// stale 错误原样上抛。plan 未注入代际计数器(低频路径),分诊依赖 PS-30 门禁
|
|
229
|
+
// 守卫的 stale 文案兜底(D1 降级语义声明的合法形态)。
|
|
220
230
|
onComplete: () => {
|
|
221
|
-
|
|
222
|
-
|
|
231
|
+
guardStaleCtx(() => {
|
|
232
|
+
pi.sendUserMessage(executeMessage, { deliverAs: "steer" });
|
|
233
|
+
tryGoalInit(pi, planFilePath, ctx);
|
|
234
|
+
}, {
|
|
235
|
+
label: "plan:compact-onComplete",
|
|
236
|
+
onStale: (error) => logger.warn("plan execution notice delivery skipped (stale ctx)", { error: toErrorMessage(error) }),
|
|
237
|
+
});
|
|
223
238
|
},
|
|
224
239
|
onError: (_error: Error) => {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
240
|
+
guardStaleCtx(() => {
|
|
241
|
+
ctx.ui.notify("Compact failed, continuing without isolation.", "warning");
|
|
242
|
+
pi.sendUserMessage(executeMessage, { deliverAs: "steer" });
|
|
243
|
+
tryGoalInit(pi, planFilePath, ctx);
|
|
244
|
+
}, {
|
|
245
|
+
label: "plan:compact-onError",
|
|
246
|
+
onStale: (error) => logger.warn("plan execution notice delivery skipped (stale ctx)", { error: toErrorMessage(error) }),
|
|
247
|
+
});
|
|
228
248
|
},
|
|
229
249
|
});
|
|
230
250
|
break;
|