pi-cc-extensions 0.8.41 → 0.8.42

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.
@@ -2,8 +2,10 @@ import * as piAi from "@earendil-works/pi-ai";
2
2
  import * as piCodingAgent from "@earendil-works/pi-coding-agent";
3
3
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
4
4
  import * as piTui from "@earendil-works/pi-tui";
5
- import { readFileSync } from "node:fs";
5
+ import { existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
6
6
  import { createRequire } from "node:module";
7
+ import { homedir } from "node:os";
8
+ import { join } from "node:path";
7
9
  import { createJiti } from "jiti";
8
10
 
9
11
  export type CompactThinkingConfig = {
@@ -186,7 +188,21 @@ export function installCompactThinking(
186
188
  host[COMPACT_THINKING_OWNER]?.stop(event, ctx);
187
189
  session = { event, ctx };
188
190
 
189
- const loaded = loadPatchedUpstream();
191
+ // upstream lib/config.ts 在模块顶层读取 compact-thinking.json,缺失时
192
+ // 会自建默认配置;预写我们的配置供其读取,加载完成后立即删除,
193
+ // 不在 .pi/agent 下残留文件(文件原本存在时保持不动)。
194
+ const agentDir = process.env.PI_CODING_AGENT_DIR ?? join(homedir(), ".pi", "agent");
195
+ const configPath = join(agentDir, "compact-thinking.json");
196
+ const fileExisted = existsSync(configPath);
197
+ if (!fileExisted) {
198
+ writeFileSync(configPath, `${JSON.stringify(initialConfig, null, 2)}\n`, "utf8");
199
+ }
200
+ let loaded: ReturnType<typeof loadPatchedUpstream>;
201
+ try {
202
+ loaded = loadPatchedUpstream();
203
+ } finally {
204
+ if (!fileExisted) rmSync(configPath, { force: true });
205
+ }
190
206
  upstreamConfig = loaded.config;
191
207
  Object.assign(upstreamConfig, initialConfig);
192
208
  delegates.clear();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-cc-extensions",
3
- "version": "0.8.41",
3
+ "version": "0.8.42",
4
4
  "license": "MIT",
5
5
  "description": "A Pi productivity suite with Claude Code-style UI, fixed editor, context inspection, and agent/session references",
6
6
  "type": "module",