mirror of
https://bitbucket.org/siakitem/my-pi.git
synced 2026-10-26 10:45:22 +00:00
feat(pi-hermes-memory): 接入持久记忆扩展并移除 Hippo
用仓库内 pi-hermes-memory 替换 hippo-memory-pi,清理 Hippo 在组合包中的
全部注入点。
移除 Hippo:
- 删除 hippo-memory-pi/ 与 config/hippo-memory-version。
- extensions/plugin-init.ts 只保留 CodeGraph 初始化目标与预检。
- install.sh / update.sh / uninstall.sh 移除 Hippo CLI 的安装、升级、卸载
与版本校验逻辑;uninstall.sh 同时删除仅服务于该提示的死代码 ask_yes_no。
- 删除 tests/hippo-extension.test.ts 与 tests/hippo-scripts.test.ts。
- tests/extension-load.test.ts 反转“不得加载 Hermes”的断言为必须加载,
并断言其排在 pi-compaction 之前。
接入 pi-hermes-memory:
- package.json 增加 file:./pi-hermes-memory 依赖、files 条目与加载入口;
加载顺序位于 pi-compaction 之前,否则 flushOnCompact 会被 pi-compaction
的 { cancel: true } 静默跳过。
- 六个记忆工具在 Tool Search 中常驻:memory_search 与 session_search 连同
context_tree_query 归入 memory-recall,memory_add / memory_replace /
memory_remove / skill_manage 归入 memory-management。常驻是必需的——注入
的 memory policy 会在普通工作中指示模型调用它们,schema 不可见会让模型
静默放弃而不是去 tool_search,同时常驻也保持请求前缀缓存稳定。
- bundleDefaultsVersion 由 2 升到 3;migrate-tool-search-settings.mjs 新增
上一版快照到当前版本的迁移路径,仍只迁移完整匹配的默认快照并保留自定义
配置。
- config/pi-permission-policy.jsonc 为六个工具设置 allow:它们只写扩展自己的
agent 目录数据、不触碰工作区,且 memory_search 每轮都可能被调用,落入
默认 ask 会产生每轮 AutoReview 往返。
依赖:
- pi-hermes-memory 的 devDependencies 由上游 ^0.80.2 等范围改为与根包一致的
精确版本。上游范围与根包 0.84.2 不兼容,会让 npm 在本目录嵌套安装第二套
Pi runtime(实测 229 MB),违反“不得在组合包内再安装一套 Pi runtime”的
纪律。
- 根 allowScripts 保持只有 better-sqlite3@12.11.1。hermes 的
better-sqlite3@13 运行时 dlopen 的是包内 N-API 预编译二进制
prebuilds/<platform>.node,npm 因 binding.gyp 推断出的 node-gyp rebuild
无需执行;实测删除 build/ 目录后仍正常工作。
文档:AGENTS.md 与 README.md 改写记忆章节,新增 pi-hermes-memory 开发约定,
替换文末的 Hippo 项目记忆块。
验证:根 12 个测试文件、pi-tool-search 的 typecheck/test/build、
pi-permission-system 的 typecheck/2569 测试、pi-hermes-memory 自带的 59 个
测试文件全部通过;隔离 Pi 环境联合加载无错误并生成 bundleDefaultsVersion 3;
npm install 幂等;迁移 helper 对 v2 快照迁移、对自定义配置保留。
This commit is contained in:
@@ -11,12 +11,14 @@
|
||||
- Added limits for active groups, generated group size, and total dynamic tools, plus current-host catalog/config/LRU tests.
|
||||
- Added checked-in authoritative groups for every tool exposed by the standard my-pi bundle, eliminating first-use model generation and user caching unless unrecognized third-party tools are present.
|
||||
- Replaced the Hermes and third-party Hippo assignments with the five tools exposed by the official Hippo Pi extension, grouped into recall and management workflows.
|
||||
- Replaced the retired Hippo `hippo_*` assignments with the vendored Hermes memory extension's six tools, grouped into `memory-recall` (`memory_search`, `session_search`, `context_tree_query`) and `memory-management` (`memory_add`, `memory_replace`, `memory_remove`, `skill_manage`).
|
||||
- Added the enabled bundle's `Agent`, `get_subagent_result`, and `steer_subagent` tools to a checked-in `subagents` orchestration group.
|
||||
- Added authoritative `ssh-connection`, `ssh-remote-files`, `ssh-remote-search`, and `ssh-remote-shell` groups for the maintained `pi-ssh` tools, keeping reviewed connection, bounded discovery, structured file operations, and reviewed shell execution separate; the connection workflow now requires sequential `ssh_connect` to succeed before dependent tools.
|
||||
- Added sequential `ssh_cd` to the authoritative remote-shell workflow and direct the model to wait for a successful workspace change before dependent remote calls, avoiding both the unknown-tools fallback and cwd races.
|
||||
- Added the authoritative `user-interaction` group for the maintained `ask_user_question` TUI tool.
|
||||
- Added authoritative `chrome-navigation`, `chrome-interaction`, and `chrome-debugging` groups for all 21 tools registered by the pinned `pi-chrome` bridge after explicit session authorization.
|
||||
- Raised the bundle defaults to five active groups and 28 dynamic tools, and pinned the high-frequency Context Mode execution trio alongside CodeGraph exploration and LSP diagnostics.
|
||||
- Pinned all six Hermes memory tools in the bundle defaults and raised `bundleDefaultsVersion` to 3. The injected memory policy expects these schemas every turn, and pinning also keeps the request prefix cache-stable instead of paying a `tool_search` round trip plus a cache invalidation. `scripts/migrate-tool-search-settings.mjs` migrates the complete version-2 snapshot while leaving customized configurations untouched.
|
||||
- Added atomic multi-group activation through `tool_search.groups`, bounded to five exact group ids and rejected without state changes when the complete workflow cannot fit.
|
||||
- Weighted exact tool names, group metadata, and common SSH/Chrome/Context aliases during query routing; weak or ambiguous matches now return candidates instead of activating arbitrarily.
|
||||
- Added `/tool-search-status` for catalog source, capacity, active-group LRU order, and latest eviction diagnostics.
|
||||
|
||||
@@ -39,8 +39,8 @@ Run `/tool-search-status` to inspect the current catalog source, pinned count, d
|
||||
| `context-knowledge` | Context indexing, searching, and web-doc ingestion |
|
||||
| `context-observability` | Context stats, doctor, and Insight |
|
||||
| `context-administration` | Context upgrade and destructive purge |
|
||||
| `memory-recall` | Official Hippo recall/context/status and condensed-output recovery |
|
||||
| `memory-management` | Official Hippo remember/outcome tools |
|
||||
| `memory-recall` | Hermes memory/session search and condensed-output recovery |
|
||||
| `memory-management` | Hermes memory writes and procedural skill management |
|
||||
| `subagents` | Launch agents, collect background results, and steer running agents |
|
||||
| `user-interaction` | `ask_user_question` model-initiated TUI/RPC questions |
|
||||
| `chrome-navigation` | Chrome bridge setup, tabs, navigation, snapshots/find/inspect, waits, and screenshots |
|
||||
@@ -48,7 +48,7 @@ Run `/tool-search-status` to inspect the current catalog source, pinned count, d
|
||||
| `chrome-debugging` | Chrome page evaluation, console/network diagnostics, response retrieval, and file upload |
|
||||
| `mcp-management` | Shared MCP adapter management |
|
||||
|
||||
Pinned tools are removed from these dynamic groups at runtime. The defaults pin `codegraph_explore`, `lsp_diagnostics`, and the three high-frequency Context Mode execution tools, so none of them consume dynamic group or tool capacity.
|
||||
Pinned tools are removed from these dynamic groups at runtime. The defaults pin `codegraph_explore`, `lsp_diagnostics`, the three high-frequency Context Mode execution tools, and all six Hermes memory tools, so none of them consume dynamic group or tool capacity.
|
||||
|
||||
## Loading and eviction
|
||||
|
||||
@@ -84,21 +84,27 @@ Pi reads this configuration from `<agent-dir>/settings.json` (normally `~/.pi/ag
|
||||
"lsp_diagnostics",
|
||||
"ctx_execute",
|
||||
"ctx_execute_file",
|
||||
"ctx_batch_execute"
|
||||
"ctx_batch_execute",
|
||||
"memory_search",
|
||||
"session_search",
|
||||
"memory_add",
|
||||
"memory_replace",
|
||||
"memory_remove",
|
||||
"skill_manage"
|
||||
],
|
||||
"showToolSearchFooterStatus": false,
|
||||
"maxActiveGroups": 5,
|
||||
"maxToolsPerGroup": 8,
|
||||
"maxDynamicTools": 28,
|
||||
"groupOverrides": {},
|
||||
"bundleDefaultsVersion": 2
|
||||
"bundleDefaultsVersion": 3
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
| Key | Bundle default | Description |
|
||||
|---|---|---|
|
||||
| `alwaysEnabled` | CodeGraph explore, LSP diagnostics, Context execution trio | Exact names pinned alongside Pi core tools |
|
||||
| `alwaysEnabled` | CodeGraph explore, LSP diagnostics, Context execution trio, all six Hermes memory tools | Exact names pinned alongside Pi core tools |
|
||||
| `showToolSearchFooterStatus` | `false` | Show active tool/group counts |
|
||||
| `maxActiveGroups` | `5` | Maximum simultaneously active dynamic groups |
|
||||
| `maxToolsPerGroup` | `8` | Maximum size accepted from model-generated groups |
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
`pi-tool-search` keeps full low-frequency schemas hidden behind a compact, validated group catalog.
|
||||
|
||||
1. `session_start` activates `tool_search`, the six cross-platform Pi core tools, and configured `alwaysEnabled` names. The my-pi defaults also pin CodeGraph exploration, LSP diagnostics, and the three high-frequency Context Mode execution tools. On Windows, `powershell` is pinned beside `bash`; on non-Windows hosts it is excluded. Pinned tools do not consume the dynamic-group or dynamic-tool budget.
|
||||
1. `session_start` activates `tool_search`, the six cross-platform Pi core tools, and configured `alwaysEnabled` names. The my-pi defaults also pin CodeGraph exploration, LSP diagnostics, the three high-frequency Context Mode execution tools, and the six Hermes memory tools. On Windows, `powershell` is pinned beside `bash`; on non-Windows hosts it is excluded. Pinned tools do not consume the dynamic-group or dynamic-tool budget.
|
||||
2. Hidden definitions are hashed with grouping constraints and matched against `extensions/bundle-groups.ts`. Available standard tools receive checked-in groups; unavailable optional tools are omitted.
|
||||
3. If every hidden tool is recognized, the bundle catalog is used directly. No model call or per-user cache is required.
|
||||
4. Additional tools receive immediate deterministic prefix/source groups. A matching model-enriched cache is reused only if it preserves all checked-in bundle assignments.
|
||||
@@ -13,7 +13,7 @@
|
||||
9. Natural-language lookup gives exact tool names and workflow aliases more weight than descriptive overlap. Weak or closely tied matches return candidates without activation.
|
||||
10. `turn_start` notices tool or grouping-configuration changes by hash, resets stale dynamic groups, and reconstructs the checked-in/hybrid catalog.
|
||||
|
||||
The standard bundle assigns the official Hippo Pi extension's five `hippo_*` tools to recall and management groups, and assigns `Agent`, `get_subagent_result`, and `steer_subagent` to the `subagents` orchestration group. `context_tree_query` remains in `memory-recall` because it recovers condensed tool output; retired Hermes names and third-party `tff-memory_*` names are not seeded.
|
||||
The standard bundle assigns the Hermes memory extension's six tools to recall and management groups: `memory_search` and `session_search` join `context_tree_query` in `memory-recall`, while `memory_add`, `memory_replace`, `memory_remove`, and `skill_manage` form `memory-management`. All six are pinned by default, because the injected `<memory-policy>` tells the model to consult and write memory during normal work, and a schema the model cannot see would silently disable that loop. Third-party `tff-memory_*` names and the retired Hippo `hippo_*` names are not seeded. It also assigns `Agent`, `get_subagent_result`, and `steer_subagent` to the `subagents` orchestration group.
|
||||
The maintained `pi-ssh` tools are also split by workflow: sequential reviewed agent-controlled connection lives in `ssh-connection`, structured `ssh_read`/`ssh_write`/`ssh_edit` file operations live in `ssh-remote-files`, bounded `ssh_find`/`ssh_grep` discovery lives in `ssh-remote-search`, and sequential reviewed workspace changes plus reviewed command execution live in `ssh-remote-shell`. The workflows tell the model to call `ssh_connect` or `ssh_cd` separately and wait for success before issuing remote calls that depend on the new connection or cwd.
|
||||
The maintained `ask_user_question` tool has its own `user-interaction` group so the model can load the complete interactive schema only when a missing decision or preference must come from the user.
|
||||
The pinned `pi-chrome` bridge registers its 21 `chrome_*` tools only after explicit per-session authorization. Once registered, catalog refresh assigns them to `chrome-navigation`, `chrome-interaction`, and `chrome-debugging`; the 28-tool default allows all three groups to coexist. Revocation remains enforced inside every upstream tool execution even if a schema is later reactivated by Tool Search.
|
||||
|
||||
@@ -141,21 +141,21 @@ export const BUNDLE_GROUP_DEFINITIONS: BundleGroupDefinition[] = [
|
||||
},
|
||||
{
|
||||
id: "memory-recall",
|
||||
title: "Official Hippo memory recall",
|
||||
summary: "Recall project memories, inspect Hippo status/context, or recover pruned tool-call output.",
|
||||
useWhen: ["Past project lessons, errors, decisions, or condensed outputs may answer the question"],
|
||||
avoidWhen: ["The required evidence is already in the current visible context"],
|
||||
keywords: ["memory", "recall", "context", "status", "recover", "记忆", "召回", "恢复输出"],
|
||||
tools: ["hippo_recall", "hippo_context", "hippo_status", "context_tree_query"],
|
||||
title: "Persistent memory recall",
|
||||
summary: "Search durable user, global, project, and failure memories, search indexed past conversations, or recover pruned tool-call output.",
|
||||
useWhen: ["The task may depend on durable context from previous sessions: preferences, project conventions, prior decisions, known failures, corrections, or condensed outputs"],
|
||||
avoidWhen: ["The required evidence is already in the current visible context, or the question is a generic one-off that durable memory would not help"],
|
||||
keywords: ["memory", "recall", "search", "session", "history", "recover", "记忆", "召回", "检索", "历史会话", "恢复输出"],
|
||||
tools: ["memory_search", "session_search", "context_tree_query"],
|
||||
},
|
||||
{
|
||||
id: "memory-management",
|
||||
title: "Official Hippo memory management",
|
||||
summary: "Store durable project lessons or report whether recalled Hippo memories were useful.",
|
||||
useWhen: ["A non-obvious project lesson, error, or decision should persist, or recalled memories need feedback"],
|
||||
avoidWhen: ["The information is temporary task progress or derivable from the repository"],
|
||||
keywords: ["remember", "outcome", "lesson", "error", "记住", "反馈", "项目经验"],
|
||||
tools: ["hippo_remember", "hippo_outcome"],
|
||||
title: "Persistent memory management",
|
||||
summary: "Save, update, or remove durable memories, and create or maintain reusable procedural skills.",
|
||||
useWhen: ["A durable fact, preference, convention, correction, or non-obvious reusable procedure should persist across sessions"],
|
||||
avoidWhen: ["The information is temporary task progress, derivable from the repository, or a one-off detail that would add noise"],
|
||||
keywords: ["remember", "save", "replace", "remove", "skill", "procedure", "记住", "保存", "修改记忆", "技能", "流程"],
|
||||
tools: ["memory_add", "memory_replace", "memory_remove", "skill_manage"],
|
||||
},
|
||||
{
|
||||
id: "subagents",
|
||||
|
||||
@@ -20,6 +20,12 @@ export const BUNDLE_TOOL_SEARCH_DEFAULTS = {
|
||||
"ctx_execute",
|
||||
"ctx_execute_file",
|
||||
"ctx_batch_execute",
|
||||
"memory_search",
|
||||
"session_search",
|
||||
"memory_add",
|
||||
"memory_replace",
|
||||
"memory_remove",
|
||||
"skill_manage",
|
||||
],
|
||||
showToolSearchFooterStatus: false,
|
||||
maxActiveGroups: 5,
|
||||
@@ -28,7 +34,7 @@ export const BUNDLE_TOOL_SEARCH_DEFAULTS = {
|
||||
groupOverrides: {},
|
||||
} as const;
|
||||
|
||||
export const BUNDLE_TOOL_SEARCH_DEFAULTS_VERSION = 2;
|
||||
export const BUNDLE_TOOL_SEARCH_DEFAULTS_VERSION = 3;
|
||||
|
||||
export interface ToolSearchConfig {
|
||||
alwaysEnabled: string[];
|
||||
|
||||
@@ -27,8 +27,10 @@ test("bundle seed names are unique and cover the declared my-pi tools", () => {
|
||||
assert.equal(result.catalog.tools.length, names.length);
|
||||
assert.equal(result.catalog.tools.find((card) => card.name === "ctx_purge")?.primaryGroup, "context-administration");
|
||||
assert.equal(result.catalog.tools.find((card) => card.name === "tavily_web_fetch")?.primaryGroup, "web-tavily");
|
||||
assert.equal(result.catalog.tools.find((card) => card.name === "hippo_recall")?.primaryGroup, "memory-recall");
|
||||
assert.equal(result.catalog.tools.find((card) => card.name === "hippo_remember")?.primaryGroup, "memory-management");
|
||||
assert.equal(result.catalog.tools.find((card) => card.name === "memory_search")?.primaryGroup, "memory-recall");
|
||||
assert.equal(result.catalog.tools.find((card) => card.name === "session_search")?.primaryGroup, "memory-recall");
|
||||
assert.equal(result.catalog.tools.find((card) => card.name === "memory_add")?.primaryGroup, "memory-management");
|
||||
assert.equal(result.catalog.tools.find((card) => card.name === "skill_manage")?.primaryGroup, "memory-management");
|
||||
assert.equal(result.catalog.tools.find((card) => card.name === "Agent")?.primaryGroup, "subagents");
|
||||
assert.equal(result.catalog.tools.find((card) => card.name === "get_subagent_result")?.primaryGroup, "subagents");
|
||||
assert.equal(result.catalog.tools.find((card) => card.name === "steer_subagent")?.primaryGroup, "subagents");
|
||||
|
||||
@@ -24,6 +24,12 @@ test("writes bundle defaults when toolSearch is absent", async () => {
|
||||
"ctx_execute",
|
||||
"ctx_execute_file",
|
||||
"ctx_batch_execute",
|
||||
"memory_search",
|
||||
"session_search",
|
||||
"memory_add",
|
||||
"memory_replace",
|
||||
"memory_remove",
|
||||
"skill_manage",
|
||||
]);
|
||||
assert.deepEqual(JSON.parse(await readFile(join(agentDir, "settings.json"), "utf8")), {
|
||||
toolSearch: {
|
||||
@@ -33,7 +39,7 @@ test("writes bundle defaults when toolSearch is absent", async () => {
|
||||
maxToolsPerGroup: 8,
|
||||
maxDynamicTools: 28,
|
||||
groupOverrides: {},
|
||||
bundleDefaultsVersion: 2,
|
||||
bundleDefaultsVersion: 3,
|
||||
},
|
||||
});
|
||||
assert.equal((await stat(join(agentDir, "settings.json"))).mode & 0o777, 0o600);
|
||||
|
||||
Reference in New Issue
Block a user