Phase 0 of plans/2026-07-12-wails-desktop-app.md. The control-room SPA is no longer embedded (web/embed.go deleted); it's a standalone static build served separately (make ui / make deploy-ui). The api process adds CORS and drops the dev-open auth bypass — every route now needs a real bearer token, including SSE (?token= query param, EventSource can't set headers) and api's own /agent proxy to nomos (previously unauthenticated by omission). nomos was an unauthenticated client of api's /mcp and approval-decision endpoints; closing dev-open would have broken it, so it now sends Authorization: Bearer $OIKOS_MCP_BEARER_TOKEN on every call back to api. SPA gets a runtime config module (config.ts) and a Config.svelte first-launch/reconfigure page, reachable afterwards via a "Connection" entry in the sidebar footer. Every fetch() in api.ts routes through fetchWithAuth so the same build works same-origin (browser prod, Vite dev proxy) or cross-origin (future Wails webview, remote access). Six gaps found against the plan and the live Caddy topology while implementing — documented in the plan's "Plan review" section, most notably: api's own /agent mount was never behind combinedAuth (fixed), and production's Authentik forward-auth needs a bearer-token bypass for API routes that this repo's Caddyfile.oikos reference copy now has, but the real dtoro/caddy-conf deploy does not yet. Verified live: cross-origin static SPA + API, CORS, bearer auth, SSE query-token auth, and localStorage persistence all confirmed working in-browser. Full Go test suite and npm run build pass with no regressions against the pre-change baseline. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
63 lines
1.7 KiB
Makefile
63 lines
1.7 KiB
Makefile
.PHONY: build webhook test test-db lint generate generate-check dev migrate seed export clean tidy ui deploy-ui
|
|
|
|
BINARY := oikos
|
|
GO ?= go
|
|
|
|
build:
|
|
$(GO) build -o $(BINARY) -tags timetzdata ./cmd/oikos
|
|
|
|
webhook:
|
|
$(GO) build -o webhook -tags timetzdata ./cmd/webhook
|
|
|
|
test:
|
|
$(GO) test -race -cover ./...
|
|
|
|
# Integration tests against the compose Postgres (starts it if needed)
|
|
test-db:
|
|
docker compose up -d postgres
|
|
@sleep 3
|
|
OIKOS_TEST_DATABASE_URL="postgres://oikos:$${OIKOS_DB_PASSWORD:-oikos_dev}@localhost:5432/oikos?sslmode=disable" \
|
|
$(GO) test -race -count=1 ./internal/db/ ./internal/httpapi/ ./internal/mcp/
|
|
|
|
lint:
|
|
$(GO) vet ./...
|
|
@command -v golangci-lint >/dev/null 2>&1 && golangci-lint run || echo "golangci-lint not installed, skipping"
|
|
|
|
generate:
|
|
$(GO) run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@v2.4.1 \
|
|
-config api/codegen.yaml api/openapi.yaml
|
|
$(GO) run github.com/sqlc-dev/sqlc/cmd/sqlc@v1.29.0 generate
|
|
|
|
# CI drift guard: regenerate and fail if the committed output changed.
|
|
generate-check: generate
|
|
@git diff --exit-code -- internal/httpapi/gen internal/db/sqlcgen \
|
|
|| (echo "generated code is stale — run 'make generate' and commit" && exit 1)
|
|
|
|
migrate:
|
|
$(GO) run ./cmd/oikos migrate
|
|
|
|
seed:
|
|
$(GO) run ./cmd/oikos seed
|
|
|
|
export:
|
|
$(GO) run ./cmd/oikos export
|
|
|
|
dev:
|
|
docker compose --profile dev up -d
|
|
|
|
# The SPA is a standalone static build, no longer embedded in the oikos
|
|
# binary (plans/2026-07-12-wails-desktop-app.md 0.1) — deployed separately.
|
|
ui:
|
|
cd web && npm run build
|
|
|
|
deploy-ui: ui
|
|
scp -r web/dist/* mac-mini:/var/www/oikos-ui/
|
|
ssh mac-mini sudo systemctl reload caddy
|
|
|
|
clean:
|
|
rm -f $(BINARY)
|
|
$(GO) clean -testcache
|
|
|
|
tidy:
|
|
$(GO) mod tidy
|