Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion apps/claude-code-plugin/SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -47,6 +47,18 @@ ${CLAUDE_PLUGIN_DATA:-$HOME/.claude/plugins/data/memory-powermem-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,
Expand Down
6 changes: 1 addition & 5 deletions apps/claude-code-plugin/hooks/run-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 1 addition & 5 deletions apps/claude-code-plugin/scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 3 additions & 4 deletions apps/claude-code-plugin/scripts/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand All @@ -75,7 +72,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)

Expand Down
1 change: 1 addition & 0 deletions src/powermem/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
Expand Down
Loading