@qltk/pi-mnemo 0.2.0 → 0.2.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.1 — 2026-09-05
4
+
5
+ worker 可观测性:stderr 落盘。
6
+
7
+ ### 修复/改进
8
+ - spawnWorker 的 stderr 从 `ignore` 改为 append 到 `~/.pi/agent/mnemo/.worker.log`(同 logMaxBytes 滚动阈值)。workers 是 fire-and-forget,stderr 静默丢弃意味着静默死亡无法诊断(2026-09-05 一次 321 行大抽取无声消失,无产物/无 exit 日志/无进程,排查时发现该盲区)。
3
9
  ## 0.2.0 — 2026-09-05
4
10
 
5
11
  配置文件 seam:`~/.pi/agent/mnemo.json`(或 `$PI_MNEMO_CONFIG`),优先级 文件 > env > 默认。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qltk/pi-mnemo",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Persistent memory for the pi coding agent — auto recall/extract/dream, file-based (MEMORY.md index + topic files), global + project dual scope. Port of mnemo (opencode).",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -8,8 +8,8 @@
8
8
  // so no transcript copying is needed — the prompt just points at the session file.
9
9
 
10
10
  import { spawn } from "node:child_process";
11
- import { statSync } from "node:fs";
12
- import { basename } from "node:path";
11
+ import { openSync, statSync, renameSync } from "node:fs";
12
+ import { join, basename } from "node:path";
13
13
  import { CONFIG } from "./config.js";
14
14
  import { projectDir, readPrompt } from "./io.js";
15
15
  import { fillPrompt } from "./prompt.js";
@@ -56,10 +56,23 @@ export function spawnWorker(opts: WorkerOpts): void {
56
56
  if (opts.model) args.push("--model", opts.model); // pi 的 flag 是 --model(无 -m 短写)
57
57
  log("spawn worker:", piBin(), args.join(" "));
58
58
 
59
+ // stderr → ~/.pi/agent/mnemo/.worker.log (rotation-capped): workers are fire-and-forget,
60
+ // silent stderr means silent deaths — this log is the only post-mortem.
61
+ let errFd: number | "ignore";
62
+ try {
63
+ const wl = join(CONFIG.memoryRoot, ".worker.log");
64
+ try {
65
+ if (statSync(wl).size > CONFIG.logMaxBytes) renameSync(wl, wl + ".1");
66
+ } catch { /* not created yet */ }
67
+ errFd = openSync(wl, "a");
68
+ } catch {
69
+ errFd = "ignore";
70
+ }
71
+
59
72
  const child = spawn(piBin(), args, {
60
73
  cwd: opts.cwd,
61
74
  detached: true,
62
- stdio: ["pipe", "ignore", "ignore"],
75
+ stdio: ["pipe", "ignore", errFd],
63
76
  env: { ...process.env, PI_MNEMO_WORKER: "1" },
64
77
  });
65
78
  child.unref();