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
3 changes: 2 additions & 1 deletion .claude-plugin/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
"hooks": {
"Stop": "hooks/session-end.sh",
"PreToolUse": "hooks/session-start.sh"
}
},
"statusline": "statusline/zerodb-status.sh"
}
5 changes: 5 additions & 0 deletions hooks/session-end.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ fi
# Read hook input (Claude Code passes event context via stdin)
INPUT=$(cat 2>/dev/null || echo "{}")

# Update status cache — mark as saving while persist runs
CACHE_DIR="${TMPDIR:-/tmp}/zerodb-status"
mkdir -p "$CACHE_DIR"
echo '{"count": null, "state": "saving", "last_updated": "'"$(date -u +%Y-%m-%dT%H:%M:%SZ)"'"}' > "${CACHE_DIR}/status.json"

# Output the trigger payload for Claude to act on.
# Claude Code's Stop hook output is surfaced to Claude, which will then
# use the zerodb-memory-guide skill to run the actual memory extraction
Expand Down
5 changes: 5 additions & 0 deletions hooks/session-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ if git rev-parse --git-dir > /dev/null 2>&1; then
fi
fi

# Update status cache — mark as synced after recall completes
CACHE_DIR="${TMPDIR:-/tmp}/zerodb-status"
mkdir -p "$CACHE_DIR"
echo '{"count": null, "state": "synced", "last_updated": "'"$(date -u +%Y-%m-%dT%H:%M:%SZ)"'"}' > "${CACHE_DIR}/status.json"

# Output trigger payload. Claude will call zerodb_get_context and
# zerodb_semantic_search via MCP, then inject memories as context.
cat <<EOF
Expand Down
41 changes: 41 additions & 0 deletions statusline/zerodb-status.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
# statusline/zerodb-status.sh — ZeroDB memory status bar widget
# Called periodically by Claude Code to update the status bar.
# Reads from a local cache file to avoid hitting the API on every poll.
# Refs #11

CACHE_DIR="${TMPDIR:-/tmp}/zerodb-status"
CACHE_FILE="${CACHE_DIR}/status.json"

# If no API key configured, show nothing (don't pollute status bar)
if [ -z "${ZERODB_API_KEY:-}" ]; then
exit 0
fi

# Read from cache (written by hooks after each session operation)
if [ -f "$CACHE_FILE" ]; then
COUNT=$(python3 -c "import json,sys; d=json.load(open('$CACHE_FILE')); print(d.get('count', '?'))" 2>/dev/null || echo "?")
STATE=$(python3 -c "import json,sys; d=json.load(open('$CACHE_FILE')); print(d.get('state', 'synced'))" 2>/dev/null || echo "synced")

case "$STATE" in
saving)
echo "ZeroDB: saving..."
;;
synced)
if [ "$COUNT" = "0" ] || [ "$COUNT" = "None" ]; then
echo "ZeroDB: 0 memories"
else
echo "ZeroDB: $COUNT memories ✓"
fi
;;
error)
echo "ZeroDB: offline"
;;
*)
echo "ZeroDB: $COUNT memories"
;;
esac
else
# No cache yet — first session, show ready state
echo "ZeroDB: ready"
fi
Loading