{"_id":"@aliyunpolar/polarmemory","_rev":"6-979a75f985775a871d81b310e7394ccf","name":"@aliyunpolar/polarmemory","dist-tags":{"latest":"2.2.4"},"versions":{"2.1.0":{"name":"@aliyunpolar/polarmemory","version":"2.1.0","keywords":["polarmemory","memory","qoder","qoderwork","hooks"],"license":"Apache-2.0","_id":"@aliyunpolar/polarmemory@2.1.0","maintainers":[{"name":"liuchengshan","email":"liushanxian0719@gmail.com"}],"bin":{"polarmemory":"dist/cli/main.js"},"dist":{"shasum":"8d46e137ba3ff7bfa08ac4a048cd651e6d93d1a3","tarball":"https://registry.npmjs.org/@aliyunpolar/polarmemory/-/polarmemory-2.1.0.tgz","fileCount":11,"integrity":"sha512-iZxZuRoXiG1vMU/+z/izfVbm8qsJrDj+L9LDoZegHF4b9dYsgBvQg3H2pHExEjXf5p8yHycwpXaGHHO3jBEMoA==","signatures":[{"sig":"MEUCIGXSUe1ofobh/SSoJSu9ciRBZ13n7OS9ICsmd0eKpamrAiEA63eNc450eyFxYOyzqML2LNJpbUC5k7WQkYOHO5fLkik=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":62476},"main":"./dist/cli/main.js","type":"module","engines":{"node":">=20"},"gitHead":"ddbea42ba13c7388991dac78caedcff05a3fb86c","scripts":{"lint":"biome check src tests scripts","test":"vitest run","build":"tsup && node scripts/postbuild.mjs","lint:fix":"biome check --write src tests scripts","typecheck":"tsc --noEmit","test:watch":"vitest","prepublishOnly":"pnpm run build && pnpm run test"},"_npmUser":{"name":"liuchengshan","email":"liushanxian0719@gmail.com"},"_npmVersion":"10.9.7","description":"polarmemory access layer: polarmemory CLI (memory ops), one-shot setup installer for Qoder/QoderWork (hooks + SKILL), per-agent config.","directories":{},"_nodeVersion":"22.22.2","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.5","vitest":"^2.1.8","typescript":"^5.7.2","@types/node":"^22.10.0","@biomejs/biome":"^1.9.4"},"_npmOperationalInternal":{"tmp":"tmp/polarmemory_2.1.0_1786425818266_0.3207323284968513","host":"s3://npm-registry-packages-npm-production"}},"2.2.0":{"name":"@aliyunpolar/polarmemory","version":"2.2.0","keywords":["polarmemory","memory","qoder","qoderwork","hooks"],"license":"Apache-2.0","_id":"@aliyunpolar/polarmemory@2.2.0","maintainers":[{"name":"liuchengshan","email":"liushanxian0719@gmail.com"}],"bin":{"polarmemory":"dist/cli/main.js"},"dist":{"shasum":"a509dabacec0c3ff456f3e1f8cf2246d2f3a0b93","tarball":"https://registry.npmjs.org/@aliyunpolar/polarmemory/-/polarmemory-2.2.0.tgz","fileCount":20,"integrity":"sha512-sSNgxFwmOUSwoodwMH4MI5zf0RmdD8TGXS6FNyKM3qbH+PG1pWgNF7GHnq2B8OkoAvw9kTWABKzKwGM30YiLDQ==","signatures":[{"sig":"MEUCIQD/dh8aJNeosh62gWXloW0pJAcEtsgM2IexFwV5F1/fcQIgcLKJIytVL7j8MCJozH4EYhSrIy542Lke6a1xeVoWQt4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":131008},"main":"./dist/cli/main.js","type":"module","_from":"file:aliyunpolar-polarmemory-2.2.0.tgz","engines":{"node":">=20"},"scripts":{"lint":"biome check src tests scripts","test":"vitest run","build":"pnpm --dir ../polarmemory-opencode build && tsup && node scripts/postbuild.mjs","lint:fix":"biome check --write src tests scripts","typecheck":"tsc --noEmit","test:watch":"vitest"},"_npmUser":{"name":"liuchengshan","email":"liushanxian0719@gmail.com"},"_resolved":"/data/liuchengshan.lcs/mem00727/polar-cli-repo/packages/polarmemory/aliyunpolar-polarmemory-2.2.0.tgz","_integrity":"sha512-sSNgxFwmOUSwoodwMH4MI5zf0RmdD8TGXS6FNyKM3qbH+PG1pWgNF7GHnq2B8OkoAvw9kTWABKzKwGM30YiLDQ==","_npmVersion":"10.9.7","description":"polarmemory access layer: polarmemory CLI (memory ops), one-shot setup installer for Qoder/QoderWork (hooks + SKILL), per-agent config.","directories":{},"_nodeVersion":"22.22.2","dependencies":{"yaml":"^2.9.0","@aliyunpolar/polarmemory-shared":"2.1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.5","vitest":"^2.1.8","typescript":"^5.7.2","@types/node":"^22.10.0","@biomejs/biome":"^1.9.4"},"_npmOperationalInternal":{"tmp":"tmp/polarmemory_2.2.0_1786622003857_0.9760393929915576","host":"s3://npm-registry-packages-npm-production"}},"2.2.1":{"name":"@aliyunpolar/polarmemory","version":"2.2.1","keywords":["polarmemory","memory","polardb","qoder","qoderwork","claude-code","codex","opencode","hermes","openclaw","hooks","cli"],"license":"Apache-2.0","_id":"@aliyunpolar/polarmemory@2.2.1","maintainers":[{"name":"liuchengshan","email":"liushanxian0719@gmail.com"}],"bin":{"polarmemory":"dist/cli/main.js"},"dist":{"shasum":"53bd7d2ad8f3edd06e48f75d0ac5e0632dc94ec8","tarball":"https://registry.npmjs.org/@aliyunpolar/polarmemory/-/polarmemory-2.2.1.tgz","fileCount":20,"integrity":"sha512-AGSiP4+leKCFoNYHdlK0jEXuu7plsMePZIAiasLG2So+9a0GyfmuTRkpvsT6YvADnHHA4SIGGtqsd6uYTuLw8Q==","signatures":[{"sig":"MEUCIQDISMSN+GvEBgCAsMl3gTIVwO9Mb/eP63irxxGimbWneAIgScqOBfQDp6i6L+HJ3cdu7QS5M8E7iRNcIqPMt+fZyxI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":133559},"main":"./dist/cli/main.js","type":"module","_from":"file:aliyunpolar-polarmemory-2.2.1.tgz","engines":{"node":">=20"},"scripts":{"lint":"biome check src tests scripts","test":"vitest run","build":"pnpm --dir ../polarmemory-opencode build && tsup && node scripts/postbuild.mjs","lint:fix":"biome check --write src tests scripts","typecheck":"tsc --noEmit","test:watch":"vitest"},"_npmUser":{"name":"liuchengshan","email":"liushanxian0719@gmail.com"},"_resolved":"/data/liuchengshan.lcs/mem00727/polar-cli-repo/packages/polarmemory/aliyunpolar-polarmemory-2.2.1.tgz","_integrity":"sha512-AGSiP4+leKCFoNYHdlK0jEXuu7plsMePZIAiasLG2So+9a0GyfmuTRkpvsT6YvADnHHA4SIGGtqsd6uYTuLw8Q==","_npmVersion":"10.9.7","description":"polarmemory access layer: polarmemory CLI (memory ops) and one-shot setup installer for Qoder, QoderWork, Claude Code, Codex, OpenCode and Hermes (hooks/plugin + SKILL), per-agent config.","directories":{},"_nodeVersion":"22.22.2","dependencies":{"yaml":"^2.9.0","@aliyunpolar/polarmemory-shared":"2.1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.5","vitest":"^2.1.8","typescript":"^5.7.2","@types/node":"^22.10.0","@biomejs/biome":"^1.9.4"},"_npmOperationalInternal":{"tmp":"tmp/polarmemory_2.2.1_1786702474917_0.26385750918013406","host":"s3://npm-registry-packages-npm-production"}},"2.2.2":{"name":"@aliyunpolar/polarmemory","version":"2.2.2","keywords":["polarmemory","memory","polardb","qoder","qoderwork","claude-code","codex","opencode","hermes","openclaw","hooks","cli"],"license":"Apache-2.0","_id":"@aliyunpolar/polarmemory@2.2.2","maintainers":[{"name":"liuchengshan","email":"liushanxian0719@gmail.com"}],"bin":{"polarmemory":"dist/cli/main.js"},"dist":{"shasum":"d72560fab72465247008fe5c0f06cbfc865cde4f","tarball":"https://registry.npmjs.org/@aliyunpolar/polarmemory/-/polarmemory-2.2.2.tgz","fileCount":20,"integrity":"sha512-rbRcDZSYMj7QSUMRjgiFrfyMiy5xK+3hS03FAmfZXz9ip+NjSjcyHdG7leUS7MKR+KTIJaSnG2aGTqW3CX26GA==","signatures":[{"sig":"MEUCIQDws/4GYSTA+vpL4xAlQvbymY/EPCLzKUOK7wJGvJFm8gIgBgxkIeWsvcBkdJqTwXC1S6gX/sFFB6uEUuSSpSUcouA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":133538},"main":"./dist/cli/main.js","type":"module","_from":"file:aliyunpolar-polarmemory-2.2.2.tgz","engines":{"node":">=20"},"scripts":{"lint":"biome check src tests scripts","test":"vitest run","build":"pnpm --dir ../polarmemory-opencode build && tsup && node scripts/postbuild.mjs","lint:fix":"biome check --write src tests scripts","typecheck":"tsc --noEmit","test:watch":"vitest"},"_npmUser":{"name":"liuchengshan","email":"liushanxian0719@gmail.com"},"_resolved":"/data/liuchengshan.lcs/mem00727/polar-cli-repo/packages/polarmemory/aliyunpolar-polarmemory-2.2.2.tgz","_integrity":"sha512-rbRcDZSYMj7QSUMRjgiFrfyMiy5xK+3hS03FAmfZXz9ip+NjSjcyHdG7leUS7MKR+KTIJaSnG2aGTqW3CX26GA==","_npmVersion":"10.9.7","description":"polarmemory access layer: polarmemory CLI (memory ops) and one-shot setup installer for Qoder, QoderWork, Claude Code, Codex, OpenCode and Hermes (hooks/plugin + SKILL), per-agent config.","directories":{},"_nodeVersion":"22.22.2","dependencies":{"yaml":"^2.9.0","@aliyunpolar/polarmemory-shared":"2.1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.5","vitest":"^2.1.8","typescript":"^5.7.2","@types/node":"^22.10.0","@biomejs/biome":"^1.9.4"},"_npmOperationalInternal":{"tmp":"tmp/polarmemory_2.2.2_1787019708772_0.6723552392765577","host":"s3://npm-registry-packages-npm-production"}},"2.2.3":{"name":"@aliyunpolar/polarmemory","version":"2.2.3","keywords":["polarmemory","memory","polardb","qoder","qoderwork","claude-code","codex","opencode","hermes","openclaw","hooks","cli"],"license":"Apache-2.0","_id":"@aliyunpolar/polarmemory@2.2.3","maintainers":[{"name":"liuchengshan","email":"liushanxian0719@gmail.com"}],"bin":{"polarmemory":"dist/cli/main.js"},"dist":{"shasum":"7272e3bef21a04e2ef3f5806b885ea9c409f2490","tarball":"https://registry.npmjs.org/@aliyunpolar/polarmemory/-/polarmemory-2.2.3.tgz","fileCount":21,"integrity":"sha512-iB9v70UyTrsvhqF8oKZUQ39XQ+TzFTyAkys9mZvdiwwnTSEMOC2y4O+yrRh7ta7W1TfnSuxO4TseBpB6catnLQ==","signatures":[{"sig":"MEUCIAYG4xZqcAQEhhzAxGqKTswxlCtYubLVpJDwwrWZkT5+AiEA9JwqmV3/LSrEh3OfSeAEwDdKJIRA6iAcRpMWkYJfhjw=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":149896},"main":"./dist/cli/main.js","type":"module","_from":"file:aliyunpolar-polarmemory-2.2.3.tgz","engines":{"node":">=20"},"scripts":{"lint":"biome check src tests scripts","test":"vitest run","build":"pnpm --dir ../polarmemory-opencode build && tsup && node scripts/postbuild.mjs","lint:fix":"biome check --write src tests scripts","typecheck":"tsc --noEmit","test:watch":"vitest"},"_npmUser":{"name":"liuchengshan","email":"liushanxian0719@gmail.com"},"_resolved":"/data/liuchengshan.lcs/mem00727/polar-cli-repo/packages/polarmemory/aliyunpolar-polarmemory-2.2.3.tgz","_integrity":"sha512-iB9v70UyTrsvhqF8oKZUQ39XQ+TzFTyAkys9mZvdiwwnTSEMOC2y4O+yrRh7ta7W1TfnSuxO4TseBpB6catnLQ==","_npmVersion":"10.9.7","description":"polarmemory access layer: polarmemory CLI (memory ops) and one-shot setup installer for Qoder, QoderWork, Claude Code, Codex, OpenCode and Hermes (hooks/plugin + SKILL), per-agent config.","directories":{},"_nodeVersion":"22.22.2","dependencies":{"yaml":"^2.9.0","@aliyunpolar/polarmemory-shared":"2.1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.5","vitest":"^2.1.8","typescript":"^5.7.2","@types/node":"^22.10.0","@biomejs/biome":"^1.9.4"},"_npmOperationalInternal":{"tmp":"tmp/polarmemory_2.2.3_1787036951026_0.2620689849592712","host":"s3://npm-registry-packages-npm-production"}},"2.2.4":{"name":"@aliyunpolar/polarmemory","version":"2.2.4","description":"polarmemory access layer: polarmemory CLI (memory ops) and one-shot setup installer for Qoder, QoderWork, Claude Code, Codex, OpenCode and Hermes (hooks/plugin + SKILL), per-agent config.","license":"Apache-2.0","type":"module","bin":{"polarmemory":"dist/cli/main.js"},"main":"./dist/cli/main.js","engines":{"node":">=20"},"publishConfig":{"access":"public"},"keywords":["polarmemory","memory","polardb","qoder","qoderwork","claude-code","codex","opencode","hermes","openclaw","hooks","cli"],"dependencies":{"yaml":"^2.9.0","@aliyunpolar/polarmemory-shared":"2.1.0"},"devDependencies":{"@biomejs/biome":"^1.9.4","@types/node":"^22.10.0","tsup":"^8.3.5","typescript":"^5.7.2","vitest":"^2.1.8"},"scripts":{"build":"pnpm --dir ../polarmemory-opencode build && tsup && node scripts/postbuild.mjs","test":"vitest run","test:watch":"vitest","lint":"biome check src tests scripts","lint:fix":"biome check --write src tests scripts","typecheck":"tsc --noEmit"},"_id":"@aliyunpolar/polarmemory@2.2.4","_integrity":"sha512-mrJ4Du6ttcu9mkx/bGcQOX3Ok3Za4LEi6MiacPDn3Ad75LSBmIzUvYoetv8xbGjSxnBwmcQsGhUGHwbp9y+6UQ==","_resolved":"/data/liuchengshan.lcs/mem00727/polar-cli-repo/packages/polarmemory/aliyunpolar-polarmemory-2.2.4.tgz","_from":"file:aliyunpolar-polarmemory-2.2.4.tgz","_nodeVersion":"22.22.2","_npmVersion":"10.9.7","dist":{"integrity":"sha512-mrJ4Du6ttcu9mkx/bGcQOX3Ok3Za4LEi6MiacPDn3Ad75LSBmIzUvYoetv8xbGjSxnBwmcQsGhUGHwbp9y+6UQ==","shasum":"bb44633b80ab60a67ad51b7ca41cb3892b9b8853","tarball":"https://registry.npmjs.org/@aliyunpolar/polarmemory/-/polarmemory-2.2.4.tgz","fileCount":21,"unpackedSize":150590,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCGF5A0g7UEX3cBoNRJJ2mH1xxfwb9eT/qehv4fqTiQiAIhAPrY+4CnebRxcvGTkVk+Zd7uMpkekSvjnsBnsfTiz7NO"}]},"_npmUser":{"name":"liuchengshan","email":"liushanxian0719@gmail.com"},"directories":{},"maintainers":[{"name":"liuchengshan","email":"liushanxian0719@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/polarmemory_2.2.4_1787053222859_0.4222783475133409"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-11T05:23:38.130Z","modified":"2026-08-18T11:40:23.217Z","2.1.0":"2026-08-11T05:23:38.403Z","2.2.0":"2026-08-13T11:53:24.010Z","2.2.1":"2026-08-14T10:14:35.069Z","2.2.2":"2026-08-18T02:21:48.969Z","2.2.3":"2026-08-18T07:09:11.296Z","2.2.4":"2026-08-18T11:40:23.002Z"},"license":"Apache-2.0","keywords":["polarmemory","memory","polardb","qoder","qoderwork","claude-code","codex","opencode","hermes","openclaw","hooks","cli"],"description":"polarmemory access layer: polarmemory CLI (memory ops) and one-shot setup installer for Qoder, QoderWork, Claude Code, Codex, OpenCode and Hermes (hooks/plugin + SKILL), per-agent config.","maintainers":[{"name":"liuchengshan","email":"liushanxian0719@gmail.com"}],"readme":"# @aliyunpolar/polarmemory\n\nPolarDB-PG 记忆管理的统一接入层：一个 `polarmemory` CLI（记忆操作命令），一条 `setup` 命令完成多个 AI 编程助手的一键接入（配置写入、Hooks/插件注册、SKILL 安装、连通性校验）。接入后**每次提问自动召回相关记忆、每轮对话结束自动沉淀记忆**，无需手动操作。\n\n| Agent | 接入机制 | 配置文件 | SKILL 安装路径 |\n|---|---|---|---|\n| **qoder** | Hooks（UserPromptSubmit + Stop + SessionStart） | `~/.qoder/settings.json` | `~/.qoder/skills/polarmemory-memory/` |\n| **qoderwork** | Hooks（同上） | `~/.qoderwork/settings.json` | `~/.qoderwork/skills/polarmemory-memory/` |\n| **qwenwork** | Hooks（同上） | `~/.qwenwork/settings.json` | `~/.qwenwork/skills/polarmemory-memory/` |\n| **claude** | Hooks（同上） | `~/.claude/settings.json` | `~/.claude/skills/polarmemory-memory/` |\n| **codex** | Hooks（同上）+ `[features].hooks=true` | `~/.codex/hooks.json` + `config.toml` | `~/.codex/skills/polarmemory-memory/` |\n| **opencode** | 进程内插件（chat.message + system.transform） | `~/.config/opencode/plugins/polarmemory.js` | — |\n| **hermes** | Shell Hooks（pre_llm_call + post_llm_call） | `~/.hermes/config.yaml` | `~/.hermes/skills/polarmemory-memory/` |\n\nOpenClaw 使用自身插件管理系统，通过独立包 [`polarmemory_openclaw`](https://www.npmjs.com/package/polarmemory_openclaw) 接入（见下文）。\n\n配置与日志位于 `~/.polarmemory/`（`config.json` 按 agent 分节隔离，多 agent 默认共享同一记忆桶）。\n\n## 安装与接入\n\n### 方式一：一键安装脚本\n\n```sh\ncurl -fsSL <公网地址>/install.sh | sh -s -- \\\n  --agent qoder --api-key <API_KEY> --base-url http://<IP>:<PORT>\n```\n\n四阶段自动完成：检查运行时 → 安装 CLI → 配置 Agent → 校验连通性。脚本随包分发于 `bootstrap/install.sh`，另有供 Agent 阅读的手册 `bootstrap/install.md`。脚本**不会安装 Node.js**，缺失或版本过低时会停止并给出升级指引。\n\n### 方式二：手动安装\n\n```sh\nnpm install -g @aliyunpolar/polarmemory\n\npolarmemory setup --agent <agent> --api-key <API_KEY> --base-url http://<IP>:<PORT>\n\n# 验证\npolarmemory status --agent <agent> --json\n```\n\n安装成功后**重启对应 Agent**（新开会话即可）使 hooks/插件生效。\n\n- `--base-url` 必传（首次）：为一客户一部署，无统一公网域名可内置。http/https 均支持；http 时 setup 会打印一行非阻断警告（公网环境建议 HTTPS）。\n- `--user-id` 可选，默认 `\"default\"`：API Key 已隔离部署（租户），user_id 仅作部署内的记忆分桶。多人共用同一部署时请为每人指定不同 `--user-id`。\n- 重跑 `polarmemory setup --agent <a>` 可修复 hooks/skill（api-key/base-url 可省略，沿用存量配置）。\n\n### OpenClaw 接入\n\nOpenClaw 必须通过其插件管理器安装，不能直接写文件：\n\n```sh\nopenclaw plugins install npm:polarmemory_openclaw\nopenclaw plugins enable  polarmemory_openclaw\npolarmemory setup --agent openclaw --api-key <API_KEY> --base-url http://<IP>:<PORT> --no-validate\nopenclaw gateway restart\n```\n\n## setup 做了什么\n\n1. 前置检查：Node ≥ 20、agent home 存在\n2. 写配置：`~/.polarmemory/config.json` 的 `agents.<agent>` 分节\n3. 注册 Hooks / 写入插件文件（修改用户配置前自动写 `.bak-polarmemory-<TS>` 备份，保留最近 5 份；条目带 `_polarmemory` 标记，卸载时精确剥离，**不触碰你自己添加的配置**）：\n\n| 触发 | 行为 |\n|---|---|\n| 用户提交提问 | 调 `POST /v2/memories/search` 召回相关记忆，以 `<recalled-memories>` 块注入上下文 |\n| 回合结束 | 切出当前轮，清洗后 `POST /v1/memories` 异步存储（session_id 作为 run_id） |\n| 会话开始 | 可选预热召回（`warmup_recall` 默认关闭） |\n\n4. 安装 SKILL（教 agent 在用户显式说“记住/查记忆”时调 CLI）\n5. 连通性校验：`GET /v1/ping`（可达性）+ `GET /v1/db_info`（Key 有效性），配错当场报错\n\n**Codex 特别说明**：需要 `~/.codex/config.toml` 中存在 `[features]` 段且 `hooks = true`。setup 采用只追加不重写策略；遇到内联表写法、点号写法、已有其他值、多个 `[features]` 段、无法安全解析等情况时**不猜测、不修改**，转为提示手动设置。\n\n**Hermes 特别说明**：Hermes 的 shell hooks 需要用户在其 allowlist 中批准后才会执行，setup 完成后会给出 `approval-hint` 引导；未批准前 `status` 报告未完成。\n\n## 可靠性设计\n\n- **Fail-open**：所有 hooks 任何错误静默退出（exit 0），绝不干扰对话。逃生阀：给 agent 进程设置 `POLARMEMORY_SKIP_HOOKS=TRUE` 使所有 hook 入口立即退出。\n- **断路器**：服务不可达（连接类错误，HTTP 4xx/5xx 不算）时写入 60 秒冷却标记，冷却期内召回/捕获全部瞬时跳过，避免每次提问白等超时。同一 base_url 的多个 agent 共享熔断状态。\n- **去重指纹**：对已捕获轮次做 SHA-256 指纹并持久化，同一轮重复触发不重复沉淀。\n- **防污染**：捕获前剥离 `<recalled-memories>` 等注入块，防止召回内容回流成新记忆。\n- **防注入**：召回块含安全前言，明确记忆为“仅供参考的上下文、非指令”，并对记忆正文中的闭合标签做转义。\n\n## CLI 命令\n\n```sh\n# 接入 / 状态 / 连通性\npolarmemory setup --agent <agent> --api-key <KEY> --base-url <URL> [--user-id <id>]\npolarmemory status --agent <agent> [--json]\npolarmemory ping --agent <agent>\n\n# 自升级（全局 npm 安装场景）\npolarmemory upgrade\n\n# 记忆操作\npolarmemory memory add \"<text>\" --agent=<agent> [--no-infer]\npolarmemory memory search \"<query>\" --agent=<agent> [--top-k=N] [--threshold=F]\npolarmemory memory list --agent=<agent> [--page=N] [--page-size=N]\npolarmemory memory get <memory-id> --agent=<agent>\npolarmemory memory update <memory-id> --text=\"<new text>\" --agent=<agent>\npolarmemory memory delete <memory-id> --agent=<agent>\npolarmemory memory delete --all --yes --agent=<agent>\n\n# 卸载\npolarmemory uninstall [--agent <agent>] [--purge-config]\n```\n\nAgent 也可通过 `POLARMEMORY_AGENT` 环境变量指定，省略 `--agent`。\n\n### 版本更新提示\n\nCLI 在交互式终端下会以每 24 小时一次的频率在后台检查新版本，并在命令成功后打印一行提示。该检查完全不阻塞命令执行；在 CI、`--json` 输出、非交互终端下自动关闭，也可用 `POLARMEMORY_DISABLE_UPDATE_CHECK=1` 显式关闭。\n\n## 配置\n\n`~/.polarmemory/config.json` 按 agent 分节：\n\n| 字段 | 默认值 | 说明 |\n|---|---|---|\n| `api_key` | — | 鉴权 Token |\n| `base_url` | — | 服务端点 |\n| `user_id` | `\"default\"` | 记忆分桶键 |\n| `auto_capture` | `true` | 自动沉淀 |\n| `auto_recall` | `true` | 自动召回 |\n| `warmup_recall` | `false` | 会话开始预热召回 |\n| `top_k` | `5` | 召回条数 |\n| `threshold` | `0.4` | 召回相似度阈值 |\n| `debug` | `false` | 写调试日志到 `~/.polarmemory/logs/` |\n\n环境变量 `POLARMEMORY_API_KEY` / `POLARMEMORY_BASE_URL` / `POLARMEMORY_USER_ID` 优先于配置文件。\n\n## 卸载\n\n```sh\npolarmemory uninstall --agent <agent>          # 移除该 agent 的 hooks/插件与 SKILL\npolarmemory uninstall --purge-config           # 同时删除配置文件\nnpm uninstall -g @aliyunpolar/polarmemory      # 最后移除二进制\n```\n\n**顺序重要**：必须先 `polarmemory uninstall`，再 `npm uninstall`，否则 CLI 已被移除将无法清理 hooks。\n\n## 开发\n\n```sh\npnpm install\npnpm run typecheck\npnpm run test\npnpm run build\n```\n\n本仓库为 pnpm monorepo，包含三个独立发布的包：本包、[`@aliyunpolar/polarmemory-shared`](https://www.npmjs.com/package/@aliyunpolar/polarmemory-shared)（共享内核）、[`polarmemory_openclaw`](https://www.npmjs.com/package/polarmemory_openclaw)（OpenClaw 插件）。\n\n## License\n\nApache-2.0\n","readmeFilename":"README.md"}