From d8bb961b6f0df6d8b59db839b6adc2871bdcb6a5 Mon Sep 17 00:00:00 2001 From: lightzt99 Date: Fri, 12 Jun 2026 16:03:00 +0800 Subject: [PATCH] feat(init): change default data dir to ~/.powermem - Remove CLAUDE_PLUGIN_DATA dependency from common.sh, run-hook.sh - Hardcode data directory to $HOME/.powermem - Add ~/.powermem/.env to settings.py auto-discovery candidates - Fix model prefix stripping bug in init.sh (prefix not stripped when provider detected from key) - Update SETUP.md documented default path --- apps/claude-code-plugin/SETUP.md | 2 +- apps/claude-code-plugin/hooks/run-hook.sh | 6 +----- apps/claude-code-plugin/scripts/common.sh | 6 +----- apps/claude-code-plugin/scripts/init.sh | 4 +++- src/powermem/settings.py | 1 + 5 files changed, 7 insertions(+), 12 deletions(-) mode change 100755 => 100644 apps/claude-code-plugin/scripts/common.sh mode change 100755 => 100644 apps/claude-code-plugin/scripts/init.sh diff --git a/apps/claude-code-plugin/SETUP.md b/apps/claude-code-plugin/SETUP.md index 31a9a7146..0e27eb0f7 100644 --- a/apps/claude-code-plugin/SETUP.md +++ b/apps/claude-code-plugin/SETUP.md @@ -37,7 +37,7 @@ PyPI package. Installed-plugin init is idempotent and uses plugin-local state: ```text -${CLAUDE_PLUGIN_DATA:-$HOME/.claude/plugins/data/memory-powermem-powermem}/ +$HOME/.powermem/ .env runtime.env server.pid diff --git a/apps/claude-code-plugin/hooks/run-hook.sh b/apps/claude-code-plugin/hooks/run-hook.sh index c4690d5ff..253935d7c 100644 --- a/apps/claude-code-plugin/hooks/run-hook.sh +++ b/apps/claude-code-plugin/hooks/run-hook.sh @@ -2,11 +2,7 @@ # Select the correct native binary for macOS / Linux. Pass-through args (e.g. "poll" for file watcher). ROOT=$(CDPATH= cd -- "$(dirname "$0")" && pwd) PLUGIN_ROOT=$(CDPATH= cd -- "$ROOT/.." && pwd) -if [ -n "${CLAUDE_PLUGIN_DATA:-}" ]; then - DATA_DIR=$CLAUDE_PLUGIN_DATA -else - DATA_DIR="$HOME/.claude/plugins/data/memory-powermem-powermem" -fi +DATA_DIR="$HOME/.powermem" if [ -f "$DATA_DIR/runtime.env" ]; then # shellcheck disable=SC1090 . "$DATA_DIR/runtime.env" diff --git a/apps/claude-code-plugin/scripts/common.sh b/apps/claude-code-plugin/scripts/common.sh old mode 100755 new mode 100644 index aa5f8b82a..1f3d30c44 --- a/apps/claude-code-plugin/scripts/common.sh +++ b/apps/claude-code-plugin/scripts/common.sh @@ -5,11 +5,7 @@ SCRIPT_DIR=$(CDPATH= cd -- "$(dirname "$0")" && pwd) PLUGIN_ROOT=$(CDPATH= cd -- "$SCRIPT_DIR/.." && pwd) powermem_data_dir() { - if [ -n "${CLAUDE_PLUGIN_DATA:-}" ]; then - printf '%s\n' "$CLAUDE_PLUGIN_DATA" - else - printf '%s\n' "$HOME/.claude/plugins/data/memory-powermem-powermem" - fi + printf '%s\n' "$HOME/.powermem" } DATA_DIR=$(powermem_data_dir) diff --git a/apps/claude-code-plugin/scripts/init.sh b/apps/claude-code-plugin/scripts/init.sh old mode 100755 new mode 100644 index c209bba4e..b513ca1e5 --- a/apps/claude-code-plugin/scripts/init.sh +++ b/apps/claude-code-plugin/scripts/init.sh @@ -75,7 +75,9 @@ provider = ( or key_provider or model_prefix ) -model = os.environ.get("POWERMEM_INIT_LLM_MODEL", raw_model).strip() +# Strip provider prefix from raw model name (e.g. "anthropic/claude-sonnet-4-6" -> "claude-sonnet-4-6") +raw_model_clean = raw_model.split("/", 1)[1].strip() if "/" in raw_model else raw_model +model = os.environ.get("POWERMEM_INIT_LLM_MODEL", raw_model_clean).strip() if provider and model: model = normalize_model(provider, model) diff --git a/src/powermem/settings.py b/src/powermem/settings.py index d0235974e..b5af7295d 100644 --- a/src/powermem/settings.py +++ b/src/powermem/settings.py @@ -8,6 +8,7 @@ def _get_default_env_file() -> Optional[str]: project_root = Path(__file__).resolve().parents[2] candidates = ( Path.cwd() / ".env", + Path.home() / ".powermem" / ".env", project_root / ".env", project_root / "examples" / "configs" / ".env", )