diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json index 5146cc8..954667e 100644 --- a/.claude-plugin/plugin.json +++ b/.claude-plugin/plugin.json @@ -15,5 +15,6 @@ "hooks": { "Stop": "hooks/session-end.sh", "PreToolUse": "hooks/session-start.sh" - } + }, + "statusline": "statusline/zerodb-status.sh" } diff --git a/hooks/session-end.sh b/hooks/session-end.sh index 7996ea5..7cd8526 100755 --- a/hooks/session-end.sh +++ b/hooks/session-end.sh @@ -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 diff --git a/hooks/session-start.sh b/hooks/session-start.sh index 885fb45..29473a7 100755 --- a/hooks/session-start.sh +++ b/hooks/session-start.sh @@ -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 </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