From fd659386fd030eaa6757a29ffe3cd5be92565691 Mon Sep 17 00:00:00 2001 From: "chenzitian.czt" Date: Fri, 12 Jun 2026 11:58:58 +0800 Subject: [PATCH 1/3] feat(init): change default data dir to ~/.powermem - Change default PowerMem data directory from ~/.claude/plugins/data/memory-powermem-powermem to ~/.powermem - Add ~/.powermem/.env to settings.py auto-discovery candidates - Update SETUP.md to reflect the new 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(-) 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 index aa5f8b82a..1f3d30c44 100755 --- 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 index c209bba4e..b513ca1e5 100755 --- 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", ) From de7eb2614bd0a98b3e8dfc3a6c51ae4a0610202c Mon Sep 17 00:00:00 2001 From: "chenzitian.czt" Date: Fri, 12 Jun 2026 17:57:41 +0800 Subject: [PATCH 2/3] docs: add CLAUDE_PLUGIN_ROOT discovery guide to SETUP.md Prevent bash scoping bug where `VAR=val sh "$VAR/..."` expands before assignment. Give the AI a two-step fallback for discovering the plugin root. --- apps/claude-code-plugin/SETUP.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/apps/claude-code-plugin/SETUP.md b/apps/claude-code-plugin/SETUP.md index 0e27eb0f7..2f5868716 100644 --- a/apps/claude-code-plugin/SETUP.md +++ b/apps/claude-code-plugin/SETUP.md @@ -47,6 +47,18 @@ $HOME/.powermem/ Follow these steps: +**Always use a two-step invocation: discover or reuse `CLAUDE_PLUGIN_ROOT` +first, then run the script.** Never write `VAR=val sh "$VAR/..."` on one line — +the shell expands `$VAR` before the assignment, producing an empty path. + +```bash +# If CLAUDE_PLUGIN_ROOT is not already set, find the plugin root: +if [ -z "${CLAUDE_PLUGIN_ROOT:-}" ]; then + export CLAUDE_PLUGIN_ROOT=$(find ~/.claude/plugins/cache/powermem/memory-powermem -maxdepth 2 -name scripts -type d 2>/dev/null | head -1 | xargs dirname) +fi +sh "$CLAUDE_PLUGIN_ROOT/scripts/..." +``` + 1. If the skill was just installed or updated, ask the user to run `/reload-plugins` first, then retry `/memory-powermem:init`. 2. Run `sh "$CLAUDE_PLUGIN_ROOT/scripts/status.sh"` and inspect whether config, From 850af4cd9609f13543eb549049636fb70a32188d Mon Sep 17 00:00:00 2001 From: "chenzitian.czt" Date: Fri, 12 Jun 2026 21:11:55 +0800 Subject: [PATCH 3/3] fix(init): remove non-Anthropic API key sources from Claude Code plugin init The plugin is installed by Claude Code so only Anthropic credentials are expected. Non-Anthropic keys (OpenAI, DeepSeek, Qwen) could be present for other tools and would cause incorrect provider detection. --- apps/claude-code-plugin/scripts/init.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/apps/claude-code-plugin/scripts/init.sh b/apps/claude-code-plugin/scripts/init.sh index b513ca1e5..a49f82d9a 100755 --- a/apps/claude-code-plugin/scripts/init.sh +++ b/apps/claude-code-plugin/scripts/init.sh @@ -55,9 +55,6 @@ KEY_SOURCES = [ ("POWERMEM_INIT_LLM_API_KEY", None), ("ANTHROPIC_AUTH_TOKEN", "anthropic"), ("ANTHROPIC_API_KEY", "anthropic"), - ("OPENAI_API_KEY", "openai"), - ("DEEPSEEK_API_KEY", "deepseek"), - ("DASHSCOPE_API_KEY", "qwen"), ] api_key = "" key_provider = ""