pi-kimi-keepalive 0.3.0 → 0.3.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 CHANGED
@@ -15,18 +15,32 @@ Replayed requests are sent directly to the provider endpoint. They do not pass t
15
15
 
16
16
  ## Install
17
17
 
18
+ ### Option 1 — npm (recommended; receives updates)
19
+
20
+ ```bash
21
+ pi install npm:pi-kimi-keepalive
22
+ ```
23
+
24
+ The package is published on npm and picks up new releases with:
25
+
18
26
  ```bash
19
- git clone https://github.com/realoliversama/pi-kimi-keepalive
20
- pi install /path/to/pi-kimi-keepalive
27
+ pi update npm:pi-kimi-keepalive
21
28
  ```
22
29
 
23
- For a single session without installing:
30
+ ### Option 2 GitHub (if you don't use npm; no update channel)
24
31
 
25
32
  ```bash
26
- pi -e /path/to/pi-kimi-keepalive/src/index.ts
33
+ pi install git:github.com/realoliversama/pi-kimi-keepalive
27
34
  ```
28
35
 
29
- After the package is published to npm: `pi install npm:pi-kimi-keepalive`.
36
+ This installs whatever is on the repository's default branch at install time. It does **not** receive updates — to move to a newer version, re-run the same install command (or `pi remove git:github.com/realoliversama/pi-kimi-keepalive` first).
37
+
38
+ ### Single session without installing
39
+
40
+ ```bash
41
+ pi -e npm:pi-kimi-keepalive # from npm
42
+ pi -e git:github.com/realoliversama/pi-kimi-keepalive # from GitHub
43
+ ```
30
44
 
31
45
  ## Setup
32
46
 
package/README.zh-CN.md CHANGED
@@ -15,18 +15,32 @@ Kimi 的自动 prompt 缓存名义上在空闲 ~5 分钟后过期,但实测实
15
15
 
16
16
  ## 安装
17
17
 
18
+ ### 方案一:npm 安装(推荐;可收到更新)
19
+
20
+ ```bash
21
+ pi install npm:pi-kimi-keepalive
22
+ ```
23
+
24
+ 包已发布到 npm,新版本发布后可随时更新:
25
+
18
26
  ```bash
19
- git clone https://github.com/realoliversama/pi-kimi-keepalive
20
- pi install /path/to/pi-kimi-keepalive
27
+ pi update npm:pi-kimi-keepalive
21
28
  ```
22
29
 
23
- 单次会话试运行(不安装):
30
+ ### 方案二:GitHub 安装(不用 npm 时;无更新渠道)
24
31
 
25
32
  ```bash
26
- pi -e /path/to/pi-kimi-keepalive/src/index.ts
33
+ pi install git:github.com/realoliversama/pi-kimi-keepalive
27
34
  ```
28
35
 
29
- npm 发布后可使用 `pi install npm:pi-kimi-keepalive`。
36
+ 该方式安装的是仓库默认分支在安装时刻的状态,**不会收到更新**——想升级需重新执行同一安装命令(或先 `pi remove git:github.com/realoliversama/pi-kimi-keepalive`)。
37
+
38
+ ### 单次会话试运行(不安装)
39
+
40
+ ```bash
41
+ pi -e npm:pi-kimi-keepalive # 从 npm
42
+ pi -e git:github.com/realoliversama/pi-kimi-keepalive # 从 GitHub
43
+ ```
30
44
 
31
45
  ## 初始化
32
46
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-kimi-keepalive",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Prompt-cache keepalive for Kimi (kimi-coding) sessions in the Pi coding agent. Replays the last real provider request while idle so the automatic prefix cache never expires.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/index.ts CHANGED
@@ -202,7 +202,7 @@ export default function (pi: ExtensionAPI) {
202
202
  maxMissStreak: int(raw.maxMissStreak, DEFAULT_CONFIG.maxMissStreak, 1),
203
203
  maxErrorStreak: int(raw.maxErrorStreak, DEFAULT_CONFIG.maxErrorStreak, 1),
204
204
  mode: raw.mode === "smart" ? "smart" : "default",
205
- initialized: raw.initialized === true,
205
+ initialized: raw.initialized === true,
206
206
  };
207
207
  } catch {
208
208
  config = { ...DEFAULT_CONFIG };
@@ -233,8 +233,10 @@ export default function (pi: ExtensionAPI) {
233
233
  }
234
234
 
235
235
  const confirmNext = await wizardCtx.ui.confirm(
236
- "pi-kimi-keepalive — first-time setup",
237
- "Set the keepalive guardrails. Press Esc at any prompt to keep the default. " +
236
+ opts.firstRun
237
+ ? "pi-kimi-keepalive first-time setup"
238
+ : "pi-kimi-keepalive — reconfigure",
239
+ "Set the keepalive guardrails. Press Esc at any prompt to keep the current value. " +
238
240
  "All values are saved to ~/.pi/cache-keepalive/state.json and can be changed later " +
239
241
  "via /keepalive <setting>.",
240
242
  );
@@ -670,6 +672,11 @@ export default function (pi: ExtensionAPI) {
670
672
  errorStreak += 1;
671
673
  debug("probe failed:", message);
672
674
  if (/^HTTP 40[13]\b/.test(message)) {
675
+ // Credentials are dead regardless of history; clear the streaks so the
676
+ // automatic recovery after the next real turn starts from a clean slate.
677
+ missStreak = 0;
678
+ errorStreak = 0;
679
+ smartHitStreak = 0;
673
680
  pause("captured credentials rejected; will recapture after your next real turn");
674
681
  return;
675
682
  }
@@ -843,6 +850,7 @@ export default function (pi: ExtensionAPI) {
843
850
  notify("usage: /keepalive maxidle=30m (0 disables the cutoff)", "error");
844
851
  break;
845
852
  }
853
+ config.maxIdleMs = ms;
846
854
  persistConfig();
847
855
  notify(ms === 0 ? "maxidle disabled — probing continues while idle" : `maxidle set to ${formatDuration(ms)}`, "info");
848
856
  break;