feat: vendor official hippo memory extension

This commit is contained in:
云服务部-叶林立
2026-08-19 21:07:23 +08:00
parent 9b2ec36a2d
commit 3cdcc3510b
21 changed files with 975 additions and 106 deletions
+59
View File
@@ -13,6 +13,7 @@ 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
@@ -49,6 +50,7 @@ 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
@@ -264,6 +266,62 @@ 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
@@ -340,6 +398,7 @@ 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"