pi-ate-memory 1.2.0 → 1.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.
@@ -5,7 +5,7 @@
5
5
  import { mkdirSync, appendFileSync } from "node:fs";
6
6
  import { join } from "node:path";
7
7
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
8
- import { MemoryRouter, routingJudge, loadConfig } from "./routing";
8
+ import { MemoryRouter, routingJudge, loadConfig, setRoutingConfig } from "./routing";
9
9
 
10
10
  const AGENT_DIR = process.env.PI_AGENT_DIR ?? join(process.env.HOME ?? "", ".pi", "agent");
11
11
 
@@ -49,11 +49,14 @@ export function registerRouting(pi: ExtensionAPI): void {
49
49
  if (!notify) return;
50
50
  const cfg = loadConfig(process.cwd());
51
51
  if (/^\d+$/.test(sub)) {
52
- router.setConfig({ batchSize: Number(sub) });
53
- notify(`memoryRouting.batchSize = ${sub}`);
52
+ const n = Math.max(1, Math.min(20, Number(sub)));
53
+ const updated = setRoutingConfig({ batchSize: n });
54
+ router.setConfig({ batchSize: updated.batchSize });
55
+ notify(`✅ memoryRouting.batchSize = ${updated.batchSize}(已持久化 settings.json,重启后保留)`);
54
56
  } else if (sub === "off" || sub === "on") {
55
- router.setConfig({ enabled: sub === "on" });
56
- notify(`memoryRouting.enabled = ${sub === "on"}`);
57
+ const updated = setRoutingConfig({ enabled: sub === "on" });
58
+ router.setConfig({ enabled: updated.enabled });
59
+ notify(`✅ memoryRouting.enabled = ${updated.enabled}(已持久化 settings.json,重启后保留)`);
57
60
  } else {
58
61
  notify(
59
62
  `memory-routing: enabled=${cfg.enabled} batchSize=${cfg.batchSize} ` +
package/lib/routing.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import { createHash } from "node:crypto";
6
6
  import { join } from "node:path";
7
- import { getEffectiveConfig } from "@pi-atelier/shared-utils";
7
+ import { getEffectiveConfig, patchSettingsSection } from "@pi-atelier/shared-utils";
8
8
  import { createJudge } from "@pi-atelier/shared-utils/judge";
9
9
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
10
10
  import {
@@ -40,6 +40,15 @@ export function loadConfig(cwd: string): RoutingConfig {
40
40
  };
41
41
  }
42
42
 
43
+ /** 持久化配置到 settings.json(全局层;读仍三层合并,与生态 /aging-config 同形态) */
44
+ export function setRoutingConfig(patch: Partial<RoutingConfig>): RoutingConfig {
45
+ return patchSettingsSection<RoutingConfig>(
46
+ "memoryRouting",
47
+ patch,
48
+ { enabled: true, batchSize: 5, includeSpecs: true, judgeModel: "" },
49
+ );
50
+ }
51
+
43
52
  const SYSTEM_PROMPT =
44
53
  "你是知识资产路由判定器。根据会话最近的 AI 叙述,判断与哪些【未读】资产强相关。\n" +
45
54
  "输出格式:每行一个路径(逐字取自清单),最多 3 条;无相关则只输出「无」。\n" +
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-ate-memory",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "File-based persistent memory for AI coding agents",
5
5
  "keywords": [
6
6
  "pi-package"