Add a new "Runtimes" sidebar tab to manage local agent runtimes with three main capabilities: runtime status overview, token usage tracking (reading Claude Code and Codex CLI local JSONL logs via daemon), and an interactive connection test that sends a ping through the daemon to verify end-to-end agent CLI connectivity. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
155 lines
4.2 KiB
Makefile
155 lines
4.2 KiB
Makefile
.PHONY: dev daemon cli build test migrate-up migrate-down sqlc seed clean setup start stop check worktree-env setup-main start-main stop-main check-main setup-worktree start-worktree stop-worktree check-worktree db-up db-down
|
|
|
|
MAIN_ENV_FILE ?= .env
|
|
WORKTREE_ENV_FILE ?= .env.worktree
|
|
ENV_FILE ?= $(if $(wildcard $(MAIN_ENV_FILE)),$(MAIN_ENV_FILE),$(if $(wildcard $(WORKTREE_ENV_FILE)),$(WORKTREE_ENV_FILE),$(MAIN_ENV_FILE)))
|
|
|
|
ifneq ($(wildcard $(ENV_FILE)),)
|
|
include $(ENV_FILE)
|
|
endif
|
|
|
|
POSTGRES_DB ?= multica
|
|
POSTGRES_USER ?= multica
|
|
POSTGRES_PASSWORD ?= multica
|
|
POSTGRES_PORT ?= 5432
|
|
PORT ?= 8080
|
|
FRONTEND_PORT ?= 3000
|
|
FRONTEND_ORIGIN ?= http://localhost:$(FRONTEND_PORT)
|
|
DATABASE_URL ?= postgres://$(POSTGRES_USER):$(POSTGRES_PASSWORD)@localhost:$(POSTGRES_PORT)/$(POSTGRES_DB)?sslmode=disable
|
|
NEXT_PUBLIC_API_URL ?= http://localhost:$(PORT)
|
|
NEXT_PUBLIC_WS_URL ?= ws://localhost:$(PORT)/ws
|
|
GOOGLE_REDIRECT_URI ?= $(FRONTEND_ORIGIN)/auth/callback
|
|
MULTICA_SERVER_URL ?= ws://localhost:$(PORT)/ws
|
|
|
|
export
|
|
|
|
COMPOSE := docker compose
|
|
|
|
define REQUIRE_ENV
|
|
@if [ ! -f "$(ENV_FILE)" ]; then \
|
|
echo "Missing env file: $(ENV_FILE)"; \
|
|
echo "Create .env from .env.example, or run 'make worktree-env' and use .env.worktree."; \
|
|
exit 1; \
|
|
fi
|
|
endef
|
|
|
|
# ---------- One-click commands ----------
|
|
|
|
# First-time setup: install deps, start DB, run migrations
|
|
setup:
|
|
$(REQUIRE_ENV)
|
|
@echo "==> Using env file: $(ENV_FILE)"
|
|
@echo "==> Installing dependencies..."
|
|
pnpm install
|
|
@bash scripts/ensure-postgres.sh "$(ENV_FILE)"
|
|
@echo "==> Running migrations..."
|
|
cd server && go run ./cmd/migrate up
|
|
@echo ""
|
|
@echo "✓ Setup complete! Run 'make start' to launch the app."
|
|
|
|
# Start all services (backend + frontend)
|
|
start:
|
|
$(REQUIRE_ENV)
|
|
@echo "Using env file: $(ENV_FILE)"
|
|
@echo "Backend: http://localhost:$(PORT)"
|
|
@echo "Frontend: http://localhost:$(FRONTEND_PORT)"
|
|
@bash scripts/ensure-postgres.sh "$(ENV_FILE)"
|
|
@echo "Starting backend and frontend..."
|
|
@trap 'kill 0' EXIT; \
|
|
(cd server && go run ./cmd/server) & \
|
|
pnpm dev:web & \
|
|
wait
|
|
|
|
# Stop all services
|
|
stop:
|
|
$(REQUIRE_ENV)
|
|
@echo "Stopping services..."
|
|
@-lsof -ti:$(PORT) | xargs kill -9 2>/dev/null
|
|
@-lsof -ti:$(FRONTEND_PORT) | xargs kill -9 2>/dev/null
|
|
@echo "✓ App processes stopped. Shared PostgreSQL is still running on localhost:5432."
|
|
|
|
# Full verification: typecheck + unit tests + Go tests + E2E
|
|
check:
|
|
$(REQUIRE_ENV)
|
|
@ENV_FILE="$(ENV_FILE)" bash scripts/check.sh
|
|
|
|
db-up:
|
|
@$(COMPOSE) up -d postgres
|
|
|
|
db-down:
|
|
@$(COMPOSE) down
|
|
|
|
worktree-env:
|
|
@bash scripts/init-worktree-env.sh .env.worktree
|
|
|
|
setup-main:
|
|
@$(MAKE) setup ENV_FILE=$(MAIN_ENV_FILE)
|
|
|
|
start-main:
|
|
@$(MAKE) start ENV_FILE=$(MAIN_ENV_FILE)
|
|
|
|
stop-main:
|
|
@$(MAKE) stop ENV_FILE=$(MAIN_ENV_FILE)
|
|
|
|
check-main:
|
|
@ENV_FILE=$(MAIN_ENV_FILE) bash scripts/check.sh
|
|
|
|
setup-worktree:
|
|
@if [ ! -f "$(WORKTREE_ENV_FILE)" ]; then \
|
|
echo "==> No $(WORKTREE_ENV_FILE) found, generating..."; \
|
|
bash scripts/init-worktree-env.sh $(WORKTREE_ENV_FILE); \
|
|
fi
|
|
@$(MAKE) setup ENV_FILE=$(WORKTREE_ENV_FILE)
|
|
|
|
start-worktree:
|
|
@$(MAKE) start ENV_FILE=$(WORKTREE_ENV_FILE)
|
|
|
|
stop-worktree:
|
|
@$(MAKE) stop ENV_FILE=$(WORKTREE_ENV_FILE)
|
|
|
|
check-worktree:
|
|
@ENV_FILE=$(WORKTREE_ENV_FILE) bash scripts/check.sh
|
|
|
|
# ---------- Individual commands ----------
|
|
|
|
# Go server
|
|
dev:
|
|
$(REQUIRE_ENV)
|
|
@bash scripts/ensure-postgres.sh "$(ENV_FILE)"
|
|
cd server && go run ./cmd/server
|
|
|
|
daemon:
|
|
cd server && MULTICA_REPOS_ROOT="${MULTICA_REPOS_ROOT:-$(abspath .)}" go run ./cmd/multica daemon
|
|
|
|
cli:
|
|
cd server && go run ./cmd/multica $(ARGS)
|
|
|
|
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
|
|
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
|
|
|
|
build:
|
|
cd server && go build -o bin/server ./cmd/server
|
|
cd server && go build -ldflags "-X main.version=$(VERSION) -X main.commit=$(COMMIT)" -o bin/multica ./cmd/multica
|
|
|
|
test:
|
|
$(REQUIRE_ENV)
|
|
@bash scripts/ensure-postgres.sh "$(ENV_FILE)"
|
|
cd server && go test ./...
|
|
|
|
# Database
|
|
migrate-up:
|
|
$(REQUIRE_ENV)
|
|
@bash scripts/ensure-postgres.sh "$(ENV_FILE)"
|
|
cd server && go run ./cmd/migrate up
|
|
|
|
migrate-down:
|
|
$(REQUIRE_ENV)
|
|
@bash scripts/ensure-postgres.sh "$(ENV_FILE)"
|
|
cd server && go run ./cmd/migrate down
|
|
|
|
sqlc:
|
|
cd server && sqlc generate
|
|
|
|
# Cleanup
|
|
clean:
|
|
rm -rf server/bin server/tmp
|