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:
@@ -13,7 +13,6 @@ fi
|
||||
|
||||
PACKAGE_SOURCE=${PI_PACKAGE_SOURCE:-git:git@bitbucket.org:siakitem/my-pi.git}
|
||||
POWERLEVEL10K_PRESET_FILE=$SCRIPT_DIR/config/p10k.zsh
|
||||
HIPPO_MEMORY_VERSION_FILE=$SCRIPT_DIR/config/hippo-memory-version
|
||||
CODEGRAPH_INSTALL_URL=https://raw.githubusercontent.com/colbymchenry/codegraph/main/install.sh
|
||||
CODEGRAPH_LATEST_RELEASE_URL=https://github.com/colbymchenry/codegraph/releases/latest
|
||||
KITTY_INSTALL_URL=https://sw.kovidgoyal.net/kitty/installer.sh
|
||||
@@ -50,7 +49,6 @@ select_updated_bundle_config() {
|
||||
|
||||
if [ -n "$updated_bundle_dir" ] && [ -f "$updated_bundle_dir/config/p10k.zsh" ]; then
|
||||
POWERLEVEL10K_PRESET_FILE=$updated_bundle_dir/config/p10k.zsh
|
||||
HIPPO_MEMORY_VERSION_FILE=$updated_bundle_dir/config/hippo-memory-version
|
||||
elif [ ! -f "$POWERLEVEL10K_PRESET_FILE" ]; then
|
||||
warn "无法定位升级后的组合包配置,找不到 ${POWERLEVEL10K_PRESET_FILE}。"
|
||||
return 1
|
||||
@@ -122,7 +120,7 @@ migrate_tool_search_settings() {
|
||||
migration_result=$(node "$migration_helper" "$settings_file") || return 1
|
||||
case $migration_result in
|
||||
migrated:*)
|
||||
say "✓ Tool Search 旧版默认配置已迁移到 5 个动态组 / 28 个动态工具。"
|
||||
say "✓ Tool Search 旧版默认配置已迁移到当前组合包默认值。"
|
||||
say " 原配置备份:${migration_result#migrated:}"
|
||||
;;
|
||||
current)
|
||||
@@ -396,62 +394,6 @@ update_codegraph() {
|
||||
rm -f "$installer_file"
|
||||
}
|
||||
|
||||
read_hippo_memory_version() {
|
||||
if [ ! -f "$HIPPO_MEMORY_VERSION_FILE" ]; then
|
||||
warn "找不到 Hippo Memory 版本文件:$HIPPO_MEMORY_VERSION_FILE"
|
||||
return 1
|
||||
fi
|
||||
hippo_target_version=$(sed -n '1p' "$HIPPO_MEMORY_VERSION_FILE")
|
||||
case $hippo_target_version in
|
||||
''|*[!0-9.]*)
|
||||
warn "Hippo Memory 版本文件内容无效:$hippo_target_version"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
printf '%s\n' "$hippo_target_version"
|
||||
}
|
||||
|
||||
installed_hippo_memory_version() {
|
||||
hippo --version 2>/dev/null | sed -n 's/^[^0-9]*\([0-9][0-9.]*\).*$/\1/p' | sed -n '1p'
|
||||
}
|
||||
|
||||
update_hippo_memory() {
|
||||
if ! command -v hippo >/dev/null 2>&1; then
|
||||
say "- Hippo Memory CLI 未安装,升级流程跳过。"
|
||||
return 0
|
||||
fi
|
||||
if ! command -v npm >/dev/null 2>&1; then
|
||||
warn "升级 Hippo Memory CLI 需要 npm。"
|
||||
return 1
|
||||
fi
|
||||
hippo_target_version=$(read_hippo_memory_version) || return 1
|
||||
hippo_published_version=$(npm view "hippo-memory@$hippo_target_version" version 2>/dev/null) || hippo_published_version=
|
||||
if [ "$hippo_published_version" != "$hippo_target_version" ]; then
|
||||
warn "无法确认 npm 上的 Hippo Memory 目标版本 $hippo_target_version,已保留现状。"
|
||||
return 1
|
||||
fi
|
||||
hippo_installed_version=$(installed_hippo_memory_version)
|
||||
if [ -z "$hippo_installed_version" ]; then
|
||||
warn "无法读取 Hippo Memory CLI 本地版本,已保留现状。"
|
||||
return 1
|
||||
fi
|
||||
if [ "$hippo_installed_version" = "$hippo_target_version" ]; then
|
||||
say "✓ Hippo Memory CLI $hippo_installed_version 已是组合包目标版本。"
|
||||
return 0
|
||||
fi
|
||||
if ! npm list -g --depth=0 hippo-memory >/dev/null 2>&1; then
|
||||
warn "检测到 hippo,但它不属于 npm 全局 hippo-memory 安装;已保留现状。"
|
||||
return 1
|
||||
fi
|
||||
say "发现 Hippo Memory CLI ${hippo_target_version}(当前 ${hippo_installed_version}),正在升级。"
|
||||
npm install -g "hippo-memory@$hippo_target_version" || return 1
|
||||
hippo_updated_version=$(installed_hippo_memory_version)
|
||||
if [ "$hippo_updated_version" != "$hippo_target_version" ]; then
|
||||
warn "Hippo Memory CLI 升级后版本校验失败:期望 $hippo_target_version,实际 ${hippo_updated_version:-未知}。"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
update_zsh_environment() {
|
||||
resolve_zsh_paths
|
||||
if [ ! -f "$oh_my_zsh_dir/oh-my-zsh.sh" ]; then
|
||||
@@ -548,7 +490,6 @@ say "组合包升级完成,开始升级已安装的终端环境和机器级 CL
|
||||
update_kitty || record_update_failure "Kitty"
|
||||
update_zsh_environment || record_update_failure "Zsh 环境"
|
||||
update_codegraph || record_update_failure "CodeGraph"
|
||||
update_hippo_memory || record_update_failure "Hippo Memory CLI"
|
||||
update_brew_formula_if_installed "kotlin-lsp" "kotlin-lsp" "kotlin-lsp"
|
||||
update_brew_formula_if_installed "openjdk@21" "Java 21" "java"
|
||||
update_brew_formula_if_installed "jdtls" "jdtls" "jdtls"
|
||||
|
||||
Reference in New Issue
Block a user