-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Expand file tree
/
Copy pathMakefile
More file actions
186 lines (155 loc) · 8.44 KB
/
Copy pathMakefile
File metadata and controls
186 lines (155 loc) · 8.44 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
FRONTEND := frontend
API := backend/core_api
AGENT := backend/core_agent
VAULT := backend/data-vault
_NPM_STAMP := $(FRONTEND)/node_modules/.package-lock.json
_API_STAMP := $(API)/.venv
_AGENT_STAMP := $(AGENT)/.venv
# ── Feature-branch selection ─────────────────────────────────────────────
# Per-developer ref choice lives in `dev.env` (gitignored — never committed),
# so each dev works on their own module branches without touching shared
# files or CI. Example dev.env:
# REF=feat/my-thing # all modules…
# API_REF=feat/server-thing # …or override per module
-include dev.env
REF ?= main
API_REF ?= $(REF)
AGENT_REF ?= $(REF)
FRONTEND_REF ?= $(REF)
# Both run paths follow the same refs:
# • `make dev`/`dev-web` run the LOCAL submodule source, so they follow
# whatever branch is checked out (use `make use` to switch).
# • the Electron desktop server is a uv-tool install keyed by these env
# vars (frontend/src/main/server-source.ts) — exported here so `make app`
# / `make server` install the matching branch.
export COWORK_SERVER_REF := $(API_REF)
export ANTON_REF := $(AGENT_REF)
# Only inject a non-default anton override (uv rejects a redundant --with).
_ANTON_WITH := $(if $(filter-out main,$(AGENT_REF)),--with "anton-agent @ git+https://github.com/mindsdb/anton.git@$(AGENT_REF)",)
.PHONY: help setup dev dev-web build dist-mac dist-win docker-build docker-up docker-down flush use pin baseline server server-local app app-local pack-local watch refs
.DEFAULT_GOAL := help
help: ## list available targets
@echo "Minds Platform — make targets:"
@grep -hE '^[a-zA-Z_-]+:.*?## ' $(MAKEFILE_LIST) \
| sort \
| awk 'BEGIN{FS=":.*?## "}{printf " \033[36m%-10s\033[0m %s\n", $$1, $$2}'
@echo ""
@echo "Module branches: set refs in dev.env (see dev.env.example), then 'make use'."
@echo "Current refs → frontend=$(FRONTEND_REF) core_api=$(API_REF) core_agent=$(AGENT_REF)"
$(_NPM_STAMP): $(FRONTEND)/package-lock.json
npm --prefix $(FRONTEND) ci
$(_API_STAMP): $(API)/uv.lock
uv sync --directory $(API)
$(_AGENT_STAMP): $(AGENT)/uv.lock
uv sync --directory $(AGENT)
setup: $(_NPM_STAMP) $(_API_STAMP) $(_AGENT_STAMP) ## install all module dependencies (npm + uv venvs)
dev: $(_NPM_STAMP) $(_API_STAMP) $(_AGENT_STAMP) ## run desktop dev from local module source (hot reload)
@trap 'kill 0' SIGINT SIGTERM EXIT; \
uv run --directory $(API) uvicorn cowork.server:app --reload \
--reload-dir $(CURDIR)/$(API)/cowork \
--reload-dir $(CURDIR)/$(AGENT)/anton & \
npm --prefix $(FRONTEND) run dev
dev-web: $(_NPM_STAMP) $(_API_STAMP) $(_AGENT_STAMP) ## run web dev in the browser from local module source
@trap 'kill 0' SIGINT SIGTERM EXIT; \
uv run --directory $(API) uvicorn cowork.server:app --reload \
--reload-dir $(CURDIR)/$(API)/cowork \
--reload-dir $(CURDIR)/$(AGENT)/anton & \
cd $(FRONTEND) && BUILD_TARGET=web npm run dev:renderer -- --open
build: $(_NPM_STAMP) ## production renderer build
npm --prefix $(FRONTEND) run build
dist-mac: $(_NPM_STAMP) ## package the macOS desktop app
npm --prefix $(FRONTEND) run dist:mac
dist-win: $(_NPM_STAMP) ## package the Windows desktop app
npm --prefix $(FRONTEND) run dist:win
docker-build: ## build the docker images
docker compose build
docker-up: ## start the docker stack
docker compose up
docker-down: ## stop the docker stack
docker compose down
# Wipe every local install + all app state, returning the machine to a
# pre-install state. Covers BOTH runtime models (the Makefile dev venvs
# AND the Electron app's `uv tool install cowork-server`) plus user data.
# Removes:
# • cowork-server uv tool (and the legacy anton-agent tool)
# • submodule venvs: $(API)/.venv, $(AGENT)/.venv
# • ~/.anton — provider keys / .env
# • ~/.cowork — database, hermes, projects
# The next `make setup` (or app launch) reinstalls from scratch.
# Set FORCE=1 to skip the confirmation prompt (CI / scripts).
flush: ## wipe all local installs + app state (fresh start; FORCE=1 to skip prompt)
@echo "This will PERMANENTLY remove:"
@echo " • cowork-server uv tool (+ legacy anton-agent)"
@echo " • $(API)/.venv and $(AGENT)/.venv"
@echo " • ~/.anton (provider keys / .env)"
@echo " • ~/.cowork (database, hermes, projects)"
@if [ "$(FORCE)" != "1" ]; then \
read -p "Proceed? [y/N] " ans; [ "$$ans" = y ] || [ "$$ans" = Y ] || { echo "Aborted."; exit 1; }; \
fi
-uv tool uninstall cowork-server
-uv tool uninstall anton-agent
rm -rf $(API)/.venv $(AGENT)/.venv
rm -rf $$HOME/.anton $$HOME/.cowork
@echo "✓ Flushed. Run 'make setup' (or relaunch the app) for a fresh install."
# ── Module-branch workflow ───────────────────────────────────────────────
# The superproject pins each submodule to a commit; `.gitmodules` sets
# `ignore = all` so day-to-day branch work never shows up as superproject
# changes (git stays clean). Pins move ONLY via `make pin` — a deliberate,
# reviewable commit. See CLAUDE.md for the full workflow.
refs: ## print the refs the next make/run will use
@echo "frontend : $(FRONTEND_REF)"
@echo "core_api : $(API_REF)"
@echo "core_agent: $(AGENT_REF)"
use: ## check out the configured refs across submodules (REF=… or dev.env)
-git -C $(FRONTEND) fetch -q origin $(FRONTEND_REF)
-git -C $(FRONTEND) checkout $(FRONTEND_REF)
-git -C $(API) fetch -q origin $(API_REF)
-git -C $(API) checkout $(API_REF)
-git -C $(AGENT) fetch -q origin $(AGENT_REF)
-git -C $(AGENT) checkout $(AGENT_REF)
@echo "✓ on: frontend=$(FRONTEND_REF) core_api=$(API_REF) core_agent=$(AGENT_REF)"
baseline: ## snap every submodule back to the superproject's pinned commits
git submodule update --init --recursive
@echo "✓ submodules reset to pinned baseline."
pin: ## record the submodules' CURRENT commits as the superproject pins
git add $(FRONTEND) $(API) $(AGENT) $(VAULT)
@git diff --cached --quiet -- $(FRONTEND) $(API) $(AGENT) $(VAULT) \
&& echo "Nothing to pin — submodule commits already match." \
|| git commit -m "chore: bump submodule pins"
@echo "→ push the superproject to share the new pins."
server: ## (re)install the Electron desktop server from the configured API_REF/AGENT_REF
UV_PYTHON_PREFERENCE=only-managed uv tool install \
"git+https://github.com/mindsdb/cowork-server.git@$(API_REF)" $(_ANTON_WITH) \
--force --reinstall --python '>=3.12,<3.14'
@echo "✓ desktop server installed from core_api@$(API_REF)."
server-local: ## install Electron desktop server from LOCAL uncommitted source (no push needed)
UV_PYTHON_PREFERENCE=only-managed uv tool install \
"$(CURDIR)/$(API)" \
--force --reinstall --python '>=3.12,<3.14'
@echo "✓ desktop server installed from local source: $(CURDIR)/$(API)"
@echo " anton resolved from core_api/pyproject.toml [tool.uv.sources]"
@echo " To also use local core_agent, set:"
@echo " [tool.uv.sources] anton-agent = { path = \"../../core_agent\" }"
@echo " in backend/core_api/pyproject.toml, then re-run server-local."
app: $(_NPM_STAMP) ## run the Electron desktop app against the configured branch (no auto-update)
cd $(FRONTEND) && COWORK_SERVER_DISABLE_AUTOUPDATE=1 npm run dev
app-local: $(_NPM_STAMP) ## run the Electron desktop app using LOCAL source (implies server-local)
$(MAKE) server-local
cd $(FRONTEND) && COWORK_SERVER_DISABLE_AUTOUPDATE=1 \
COWORK_SERVER_PACKAGE="$(CURDIR)/$(API)" npm run dev
pack-local: $(_NPM_STAMP) ## build macOS .app from LOCAL uncommitted source, iCloud-safe (no DMG)
$(MAKE) server-local
cd $(FRONTEND) && PATH="/opt/homebrew/opt/node@20/bin:$$PATH" \
npm run build && \
npx electron-builder --mac --arm64 --dir \
--config.directories.output=/tmp/minds-build
rm -rf $(FRONTEND)/release/mac-arm64
cp -R /tmp/minds-build/mac-arm64 $(FRONTEND)/release/
@echo "✓ Built: $(FRONTEND)/release/mac-arm64/MindsHub Cowork.app"
@echo " Launch: COWORK_SERVER_DISABLE_AUTOUPDATE=1 '$(CURDIR)/$(FRONTEND)/release/mac-arm64/MindsHub Cowork.app/Contents/MacOS/MindsHub Cowork' &"
watch: $(_NPM_STAMP) $(_API_STAMP) $(_AGENT_STAMP) ## live reload — Electron app + Python hot-reload (alias for dev)
@trap 'kill 0' SIGINT SIGTERM EXIT; \
uv run --directory $(API) uvicorn cowork.server:app --reload \
--reload-dir $(CURDIR)/$(API)/cowork \
--reload-dir $(CURDIR)/$(AGENT)/anton & \
npm --prefix $(FRONTEND) run dev