-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
194 lines (161 loc) · 7.74 KB
/
Copy pathMakefile
File metadata and controls
194 lines (161 loc) · 7.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
BINARY := observer
PKG := github.com/marmutapp/superbased-observer
CMD := ./cmd/observer
ORG_BINARY := observer-org
ORG_CMD := ./cmd/observer-org
GO ?= go
GOFLAGS ?=
BUILD_DIR := bin
COVER_OUT := coverage.txt
WEB_DIR := web
WEB_DIST := $(WEB_DIR)/dist
WEB_EMBED_DIST := internal/intelligence/dashboard/webapp/dist
WEB2_DIR := web2
WEB2_DIST := $(WEB2_DIR)/dist
WEB2_EMBED_DIST := internal/orgserver/dashboard/webapp/dist
OPENAPI_SPEC := docs/openapi/orgserver.yaml
OAPI := $(GO) tool oapi-codegen
.PHONY: all build test test-race test-invariant lint fmt vet tidy clean run cover \
gen-openapi verify-openapi build-orgserver \
web-install web-dev web-build web-clean docs-build \
sync-distribution-readmes verify-distribution-readmes
all: fmt vet lint test build
build: build-observer build-antigravity-bridge build-orgserver
build-observer:
@mkdir -p $(BUILD_DIR)
$(GO) build $(GOFLAGS) -o $(BUILD_DIR)/$(BINARY) $(CMD)
# Build the org server binary (cmd/observer-org). Separate binary, separate
# deployment from the agent; built as part of `make build` so CI covers it.
build-orgserver:
@mkdir -p $(BUILD_DIR)
$(GO) build $(GOFLAGS) -o $(BUILD_DIR)/$(ORG_BINARY) $(ORG_CMD)
# Cross-compile the Antigravity Windows-side gRPC bridge. Used by
# observer-on-WSL2 to reach Antigravity's local language_server,
# which binds to Windows-side 127.0.0.1 and isn't reachable from
# inside a WSL distro under default networking. The bridge is a
# tiny Go binary (~8 MB) that runs Windows-side under powershell.exe,
# does process discovery + the gRPC call, and returns Markdown via
# stdout. Skipped silently on non-Linux build hosts where it'd
# never be invoked.
build-antigravity-bridge:
@mkdir -p $(BUILD_DIR)
GOOS=windows GOARCH=amd64 $(GO) build $(GOFLAGS) -o $(BUILD_DIR)/antigravity-bridge.exe ./cmd/antigravity-bridge
run: build
$(BUILD_DIR)/$(BINARY)
test:
$(GO) test $(GOFLAGS) ./...
test-race:
$(GO) test $(GOFLAGS) -race ./...
# Single-user-local invariant net: seeds a fixed corpus, drives the
# dashboard's headline endpoints, and diffs the canonicalised JSON
# against goldens captured before the org-mode (Teams) code landed. A
# non-empty diff means an additive change leaked into a solo-local
# response — the one thing the Teams feature must never do. Regenerate
# the goldens intentionally with `go test ./tests/invariant -update`.
test-invariant:
$(GO) test $(GOFLAGS) ./tests/invariant/...
# Regenerate the org server's agent-protocol stubs from the OpenAPI spec.
# The OpenAPI doc is the source of truth (spec §2.5); the client stubs
# (internal/orgclient/gen) and the server interface
# (internal/orgserver/api/gen) are committed, generated artefacts.
gen-openapi:
$(OAPI) -config internal/orgclient/gen/cfg.yaml $(OPENAPI_SPEC)
$(OAPI) -config internal/orgserver/api/gen/cfg.yaml $(OPENAPI_SPEC)
$(OAPI) -config internal/orgserver/dashboard/gen/cfg.yaml $(OPENAPI_SPEC)
# Fail if the committed stubs drift from what the spec generates.
# oapi-codegen v2 has no `--validate-strict` flag (the literal flag the
# spec mentions does not exist); regenerating and diffing is the
# equivalent, stronger guarantee — a divergent handler/spec is caught at
# CI time. Checks both modified tracked files and any new untracked file.
verify-openapi: gen-openapi
@if ! git diff --quiet -- internal/orgclient/gen internal/orgserver/api/gen internal/orgserver/dashboard/gen || \
[ -n "$$(git ls-files --others --exclude-standard internal/orgclient/gen internal/orgserver/api/gen internal/orgserver/dashboard/gen)" ]; then \
echo "openapi codegen drift: run 'make gen-openapi' and commit the result"; \
git --no-pager diff -- internal/orgclient/gen internal/orgserver/api/gen internal/orgserver/dashboard/gen; \
exit 1; \
fi
@echo "openapi: generated stubs match $(OPENAPI_SPEC)"
# Regenerate npm/observer/README.md + pypi/observer/README.md from the
# channel-specific templates by substituting the shared body block
# (docs/distribution/README-body.md). The body is the canonical source
# for everything from "Per-AI-client setup" through "Configuration"; the
# templates own each channel's title, badges, install, quickstart step 1,
# and channel-specific troubleshooting + footer.
sync-distribution-readmes:
scripts/build-distribution-readmes.sh
# Drift gate for the distribution READMEs: regenerates into temp files
# and diffs against the committed READMEs. Fails if either drifts. Runs
# in CI so an edit to one channel's README directly (instead of the
# shared body or template) fails fast with the diff and a remediation
# hint. Never mutates the working tree, so a stale local README during
# `make verify-distribution-readmes` is still surfaced.
verify-distribution-readmes:
@scripts/verify-distribution-readmes.sh
cover:
$(GO) test $(GOFLAGS) -race -coverprofile=$(COVER_OUT) -covermode=atomic ./...
$(GO) tool cover -func=$(COVER_OUT) | tail -1
lint:
@command -v golangci-lint >/dev/null 2>&1 || { echo "golangci-lint not installed — see https://golangci-lint.run/"; exit 0; }
golangci-lint run ./...
fmt:
$(GO) tool gofumpt -w .
vet:
$(GO) vet ./...
tidy:
$(GO) mod tidy
clean:
rm -rf $(BUILD_DIR) $(COVER_OUT)
# ---------------------------------------------------------------
# Web (redesigned React/Vite dashboard, mounted at /v2/).
#
# `make build` stays pure-Go and does NOT require Node. The built
# artifacts at $(WEB_EMBED_DIST) are committed; regenerate them
# via `make web-build` whenever you touch web/ sources, before
# committing.
# ---------------------------------------------------------------
web-install:
cd $(WEB_DIR) && npm ci
web-dev:
cd $(WEB_DIR) && npm run dev
web-build:
cd $(WEB_DIR) && npm ci --silent && npm run build
@rm -rf $(WEB_EMBED_DIST)
@mkdir -p $(WEB_EMBED_DIST)
@cp -R $(WEB_DIST)/. $(WEB_EMBED_DIST)/
@echo "web: rebuilt $(WEB_EMBED_DIST) from $(WEB_DIST)"
web-clean:
rm -rf $(WEB_DIST) $(WEB_DIR)/node_modules
# Build the org dashboard SPA (web2/) and refresh its embedded dist. Mirrors
# web-build; the artifacts at $(WEB2_EMBED_DIST) are committed and embedded
# into the observer-org binary.
web-build-org:
cd $(WEB2_DIR) && npm ci --silent && npm run build
@rm -rf $(WEB2_EMBED_DIST)
@mkdir -p $(WEB2_EMBED_DIST)
@cp -R $(WEB2_DIST)/. $(WEB2_EMBED_DIST)/
@echo "web-org: rebuilt $(WEB2_EMBED_DIST) from $(WEB2_DIST)"
web-org-clean:
rm -rf $(WEB2_DIST) $(WEB2_DIR)/node_modules
# ---------------------------------------------------------------
# Marketing-site documentation (/docs). Renders curated Markdown
# from website/docs-src into the live site shell under
# website/docs/, plus the search index + syntax-highlight CSS.
# The generator is a self-contained module (its deps never touch
# the observer binary). Output is committed; the Cloudflare Pages
# deploy ships it as static files. Run after editing docs-src.
#
# changeloggen runs first: it derives website/docs-src/changelog.md
# + website/feed.xml (Atom) from the repo's own CHANGELOG.md, and
# keeps nav.toml + sitemap.xml's marker-delimited blocks in sync —
# so `gen` then renders the changelog page like any other docs page.
# ---------------------------------------------------------------
docs-build:
cd website/docs-tools && go run ./changeloggen -changelog ../../CHANGELOG.md -src ../docs-src -sitemap ../sitemap.xml -feed ../feed.xml
cd website/docs-tools && go run ./gen -src ../docs-src -out ../docs -assets ../assets
# Generates the on-brand, dark-theme 1200x630 OG/social cards used by the
# generated docs pages (per-section, not per-page — see ogImageFor in
# website/docs-tools/gen/main.go). Uses Playwright/Chromium, already a
# devDependency of website/tools (no new dependency added). Run after
# docs-build if the Compare/Track/Changelog page roster changed.
docs-og:
cd website/tools && node og-gen.mjs