Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
155 lines (125 loc) · 7 KB
/
Copy pathMakefile
File metadata and controls
155 lines (125 loc) · 7 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
.PHONY: install install-core run clean lint test test-core tui-test check docs-check shell-check benchmark agent-acceptance subagent-acceptance tui-acceptance wheel-smoke docker-smoke git-status git-diff git-log web
# Tests parse the benchmark target's stdout as JSON; do not inject GNU make's
# recursive directory banners into that machine-readable output.
MAKEFLAGS += --no-print-directory
# Prefer the known-stable Python 3.12, but use the active supported Python
# 3.13 on clean runners that do not provide 3.12. Python 3.14 remains
# intentionally out of scope because of the OpenAI SDK import deadlock.
PYTHON ?= python3.12
_PYTHON_REQUEST := $(PYTHON)
PYTHON := $(shell if [ "$(_PYTHON_REQUEST)" != "python3.12" ]; then printf '%s' "$(_PYTHON_REQUEST)"; elif command -v python >/dev/null 2>&1 && python -c 'import sys; raise SystemExit(0 if sys.version_info[:2] in ((3, 12), (3, 13)) else 1)' >/dev/null 2>&1; then command -v python; elif command -v python3.12 >/dev/null 2>&1 && python3.12 -c 'import sys; raise SystemExit(0 if sys.version_info[:2] == (3, 12) else 1)' >/dev/null 2>&1; then command -v python3.12; elif command -v python3.13 >/dev/null 2>&1 && python3.13 -c 'import sys; raise SystemExit(0 if sys.version_info[:2] == (3, 13) else 1)' >/dev/null 2>&1; then command -v python3.13; else printf '%s' "$(_PYTHON_REQUEST)"; fi)
VENV_PYTHON := $(if $(wildcard venv/bin/python),./venv/bin/python,$(PYTHON))
# Detect Windows (native cmd) and redirect to .bat files
ifeq ($(OS),Windows_NT)
$(error This Makefile is for macOS/Linux/WSL. On native Windows, use: setup.bat, run.bat)
endif
install-core:
@echo "Creating virtual environment with $(PYTHON)..."
@command -v $(PYTHON) >/dev/null 2>&1 || { echo "Error: $(PYTHON) not found. Install Python 3.12 first."; exit 1; }
$(PYTHON) -m venv venv
./venv/bin/python -m pip install --upgrade pip && ./venv/bin/python -m pip install -e '.[web,claude]'
@echo ""
@echo "OpenKyrozen core development environment installed."
# The documented development path includes every optional integration and the
# Chromium binary required by the browser integration test.
install: install-core
./venv/bin/python -m pip install -e '.[all]'
./venv/bin/python -m playwright install chromium
@echo ""
@echo "OpenKyrozen full development environment installed. Run 'make test' or 'make run'."
run:
@command -v $(PYTHON) >/dev/null 2>&1 || { echo "Error: venv requires $(PYTHON). Run 'make install' with $(PYTHON) installed."; exit 1; }
$(VENV_PYTHON) -m openkyrozen.interfaces.cli.launcher --project .
tui-test:
@if command -v go >/dev/null 2>&1; then (cd tui && go test ./...); else echo "Go toolchain not found; TUI tests skipped (install Go 1.27.1 or run install.sh)."; fi
web:
@command -v $(PYTHON) >/dev/null 2>&1 || { echo "Error: venv requires $(PYTHON)."; exit 1; }
$(VENV_PYTHON) -m pip install fastapi uvicorn -q && $(VENV_PYTHON) -m openkyrozen.interfaces.web.app --project .
debug:
@command -v $(PYTHON) >/dev/null 2>&1 || { echo "Error: venv requires $(PYTHON). Run 'make install' first."; exit 1; }
$(VENV_PYTHON) -m openkyrozen.interfaces.cli.diagnostics
init:
@command -v $(PYTHON) >/dev/null 2>&1 || { echo "Error: venv requires $(PYTHON). Run 'make install' first."; exit 1; }
$(VENV_PYTHON) -m openkyrozen.interfaces.cli.main --project . --init
# Upgrade the venv to use a different Python version (e.g. after macOS upgrade)
reinstall:
@echo "Rebuilding venv with $(PYTHON)..."
rm -rf venv
$(PYTHON) -m venv venv
./venv/bin/python -m pip install --upgrade pip && ./venv/bin/python -m pip install -r requirements.txt
clean:
rm -rf venv chroma_memory __pycache__
# Syntax check
lint:
$(VENV_PYTHON) -m compileall -q openkyrozen main.py server.py tui_launcher.py tui_backend.py main_debug.py learning_worker.py github_cli.py learning_benchmark.py migration.py scripts tests benchmarks
@echo "Python syntax OK."
@echo "All files pass syntax check."
# Unit tests
test:
KYROZEN_BROWSER_TESTS=1 $(VENV_PYTHON) -m unittest discover -s tests -p 'test_*.py' -v
# Fast non-browser path for contributors and CI jobs that intentionally omit browser binaries.
test-core:
KYROZEN_BROWSER_TESTS=0 $(VENV_PYTHON) -m unittest discover -s tests -p 'test_*.py' -v
benchmark:
@$(VENV_PYTHON) -c "import openai, requests, rich, yaml" >/dev/null 2>&1 || { echo "Error: benchmark dependencies are missing. Run 'make install' first."; exit 1; }
@benchmark_root=$$(mktemp -d "$${TMPDIR:-/tmp}/openkyrozen-benchmark.XXXXXX"); \
trap 'rm -rf "$$benchmark_root"' EXIT INT TERM; \
KYROZEN_BENCHMARK_ROOT="$$benchmark_root" KYROZEN_DB_PATH="$$benchmark_root/driver.sqlite3" KYROZEN_DISABLE_VECTOR_INDEX=1 \
$(VENV_PYTHON) -m openkyrozen.interfaces.cli.main learning benchmark \
--cases benchmarks/multi_party_memory.jsonl \
--clean-runner "$(VENV_PYTHON) benchmarks/clean_runner.py" \
--evolved-runner "$(VENV_PYTHON) benchmarks/evolved_runner.py" \
--timeout "$${BENCHMARK_TIMEOUT:-60}"
wheel-smoke:
$(VENV_PYTHON) -m pip install build -q
$(VENV_PYTHON) scripts/wheel_smoke.py
agent-acceptance:
$(VENV_PYTHON) scripts/agent_workflow_acceptance.py
subagent-acceptance:
$(VENV_PYTHON) scripts/subagent_workflow_acceptance.py
tui-acceptance:
@command -v go >/dev/null 2>&1 || { echo "Error: Go is required for TUI acceptance."; exit 1; }
@binary=$$(mktemp "$${TMPDIR:-/tmp}/openkyrozen-tui.XXXXXX"); \
trap 'rm -f "$$binary"' EXIT INT TERM; \
(cd tui && go build -o "$$binary" .) && \
$(VENV_PYTHON) scripts/tui_workflow_acceptance.py "$$binary"
docs-check:
@$(VENV_PYTHON) scripts/check_architecture.py
$(VENV_PYTHON) scripts/generate_tool_inventory.py --check
$(VENV_PYTHON) scripts/check_docs.py
$(VENV_PYTHON) scripts/check_zsh_extras.py
shell-check:
@$(VENV_PYTHON) scripts/check_architecture.py
$(VENV_PYTHON) scripts/check_zsh_extras.py
docker-smoke:
@command -v docker >/dev/null 2>&1 || { echo "Error: Docker is required for the container smoke test."; exit 1; }
docker build -t openkyrozen-smoke .
./scripts/docker_persistence_smoke.sh openkyrozen-smoke
# Quick verification
check:
@$(VENV_PYTHON) scripts/check_architecture.py
@echo "Checking Python syntax..."
@$(VENV_PYTHON) -m compileall -q openkyrozen main.py server.py tui_launcher.py tui_backend.py main_debug.py learning_worker.py github_cli.py learning_benchmark.py migration.py scripts tests benchmarks
@echo " Python modules: OK"
@echo "Checking git tools..."
@$(VENV_PYTHON) -c "from openkyrozen.tools import ToolAdapters; AVAILABLE_TOOLS = ToolAdapters().AVAILABLE_TOOLS; git = [k for k in AVAILABLE_TOOLS if k.startswith('git_')]; print(f' {len(git)} git tools, {len(AVAILABLE_TOOLS)} total tools')"
@$(VENV_PYTHON) scripts/check_zsh_extras.py
@$(MAKE) tui-test
@echo "All checks passed."
# Git helpers
git-status:
git status
git-diff:
git diff
git-log:
git log --oneline --decorate -10
# Commit & push (interactive — requires message)
commit:
@if [ -z "$(msg)" ]; then echo "Usage: make commit msg='your message'"; exit 1; fi
git add -A
git commit -m "$(msg)"
@echo "Committed. Use 'make push' to push."
push:
git push origin main
pull:
git pull origin main