From f3f2d1c9e2fe6407a3849c5eeb9ea43bda5e9470 Mon Sep 17 00:00:00 2001 From: Evan Senter Date: Sun, 25 Jan 2026 09:31:32 +0000 Subject: [PATCH 1/3] feat: Add install-server and install-client Makefile targets Mirrors the agent-event-bus pattern for multi-machine setups: - install-server: Full local installation with LaunchAgent/systemd + MCP - install-client: CLI + remote MCP config (requires REMOTE_URL) - install: Backwards-compatible alias for install-server Part of #93 (deploy to speck-vm) Co-Authored-By: Claude Opus 4.5 --- Makefile | 50 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 175da9d..4d2931f 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: check fmt lint test clean install uninstall restart reinstall dev venv +.PHONY: check fmt lint test clean install install-server install-client uninstall restart reinstall dev venv # Run all quality gates (format check, lint, tests) check: fmt lint test @@ -28,9 +28,10 @@ venv: dev: uv sync --extra dev -# Full installation: venv + deps + service + CLI + MCP -install: - @echo "Installing dependencies..." +# Server installation: runs session-analytics service locally +# Use this on the machine that will host the database +install-server: + @echo "Installing server..." uv sync @echo "" @if [ "$$(uname)" = "Darwin" ]; then \ @@ -52,10 +53,45 @@ install: echo " claude mcp add --transport http --scope user agent-session-analytics http://localhost:8081/mcp"; \ fi @echo "" - @echo "Installation complete!" + @echo "Server installation complete!" + @if ! echo "$$PATH" | tr ':' '\n' | grep -q "$$HOME/.local/bin"; then \ + echo ""; \ + echo "Make sure ~/.local/bin is in your PATH:"; \ + echo ' export PATH="$$HOME/.local/bin:$$PATH"'; \ + fi + +# Client installation: connects to a remote session-analytics server +# Usage: make install-client REMOTE_URL=https://your-server.tailnet.ts.net/mcp +install-client: + @if [ -z "$(REMOTE_URL)" ]; then \ + echo "Error: REMOTE_URL is required"; \ + echo "Usage: make install-client REMOTE_URL=https://your-server.tailnet.ts.net/mcp"; \ + exit 1; \ + fi + @echo "Installing client (connecting to $(REMOTE_URL))..." + uv sync @echo "" - @echo "Make sure ~/.local/bin is in your PATH:" - @echo ' export PATH="$$HOME/.local/bin:$$PATH"' + @echo "Installing CLI..." + ./scripts/install-cli.sh + @echo "" + @echo "Configuring Claude Code MCP..." + @CLAUDE_CMD=$$(command -v claude || echo "$$HOME/.local/bin/claude"); \ + if [ -x "$$CLAUDE_CMD" ]; then \ + $$CLAUDE_CMD mcp remove --scope user agent-session-analytics 2>/dev/null || true; \ + $$CLAUDE_CMD mcp add --transport http --scope user agent-session-analytics "$(REMOTE_URL)" && \ + echo "Added agent-session-analytics to Claude Code ($(REMOTE_URL))"; \ + else \ + echo "Note: claude not found. Run manually:"; \ + echo " claude mcp add --transport http --scope user agent-session-analytics $(REMOTE_URL)"; \ + fi + @echo "" + @echo "Client installation complete!" + @echo "" + @echo "Add to your shell profile (~/.zshrc, ~/.bashrc, or ~/.extra):" + @echo ' export AGENT_SESSION_ANALYTICS_URL="$(REMOTE_URL)"' + +# Alias for install-server (backwards compatibility) +install: install-server # Restart the service (pick up code changes) restart: From 92a8ef22cc27f504ea100fefffac9684c11de2bb Mon Sep 17 00:00:00 2001 From: Evan Senter Date: Sun, 25 Jan 2026 09:41:12 +0000 Subject: [PATCH 2/3] refactor: Remove reinstall, mark install-* idempotent, add logs - Remove reinstall target (install-server is idempotent and restarts) - Document that install-server/install-client are idempotent - Add logs target for tailing server logs - Fix restart message to say "make install-server" Co-Authored-By: Claude Opus 4.5 --- Makefile | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 4d2931f..c12f733 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: check fmt lint test clean install install-server install-client uninstall restart reinstall dev venv +.PHONY: check fmt lint test clean install install-server install-client uninstall restart dev venv logs # Run all quality gates (format check, lint, tests) check: fmt lint test @@ -28,8 +28,9 @@ venv: dev: uv sync --extra dev -# Server installation: runs session-analytics service locally +# Server installation: runs session-analytics service locally (idempotent) # Use this on the machine that will host the database +# Re-run to pick up code changes (restarts service automatically) install-server: @echo "Installing server..." uv sync @@ -60,8 +61,9 @@ install-server: echo ' export PATH="$$HOME/.local/bin:$$PATH"'; \ fi -# Client installation: connects to a remote session-analytics server +# Client installation: connects to a remote session-analytics server (idempotent) # Usage: make install-client REMOTE_URL=https://your-server.tailnet.ts.net/mcp +# Re-run to update remote URL or pick up CLI changes install-client: @if [ -z "$(REMOTE_URL)" ]; then \ echo "Error: REMOTE_URL is required"; \ @@ -93,7 +95,7 @@ install-client: # Alias for install-server (backwards compatibility) install: install-server -# Restart the service (pick up code changes) +# Restart the service (server only, lightweight alternative to install-server) restart: @if [ "$$(uname)" = "Darwin" ]; then \ PLIST="$$HOME/Library/LaunchAgents/com.evansenter.agent-session-analytics.plist"; \ @@ -109,7 +111,7 @@ restart: exit 1; \ fi; \ else \ - echo "LaunchAgent not installed. Run: make install"; \ + echo "LaunchAgent not installed. Run: make install-server"; \ exit 1; \ fi; \ else \ @@ -124,12 +126,6 @@ restart: fi; \ fi -# Reinstall: uv sync + restart service (picks up code changes) -reinstall: - @echo "Reinstalling package..." - uv sync - @$(MAKE) restart - # Uninstall: service + CLI + MCP config uninstall: @echo "Uninstalling..." @@ -149,3 +145,7 @@ uninstall: @echo "" @echo "Uninstall complete!" @echo "Note: venv and source code remain in place." + +# Tail the server log (server only) +logs: + @tail -f ~/.claude/contrib/agent-session-analytics/agent-session-analytics.log From c7333785b6c7d9cde09d6fe2f1564e7c90fe5c6b Mon Sep 17 00:00:00 2001 From: Evan Senter Date: Sun, 25 Jan 2026 10:00:01 +0000 Subject: [PATCH 3/3] docs: Update CLAUDE.md for Makefile changes - Replace reinstall with install-server (idempotent) - Add logs target to command list - Update "When to Restart" table Addresses reviewer feedback. Co-Authored-By: Claude Opus 4.5 --- CLAUDE.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index a3da538..9d6a0c7 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -44,19 +44,19 @@ This API is consumed by LLMs. Design with that in mind: ## Commands ```bash -make check # fmt, lint, test -make install # LaunchAgent + CLI + MCP config -make restart # Restart LaunchAgent for code changes -make reinstall # pip install -e . + restart (for pyproject.toml) +make check # fmt, lint, test +make install-server # LaunchAgent + CLI + MCP config (idempotent, restarts service) +make restart # Lightweight service restart (no dependency sync) +make logs # Tail server logs ``` ### When to Restart | Change | Action | |--------|--------| -| `server.py`, `queries.py`, `patterns.py`, `storage.py` | `make restart` | +| `server.py`, `queries.py`, `patterns.py`, `storage.py` | `make install-server` (or `make restart`) | | `cli.py` only | None (CLI runs fresh) | -| `pyproject.toml` | `make reinstall` | +| `pyproject.toml` | `make install-server` | ---