-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjustfile
More file actions
258 lines (211 loc) · 10.3 KB
/
justfile
File metadata and controls
258 lines (211 loc) · 10.3 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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# hivedev: always runs the LOCAL dev build (not the global `hive` install)
hivedev := "uv run python -m keephive"
# List available recipes
default:
@just --list
# ── Dev ──────────────────────────────────────────────────────────────────────
# Run tests (fast, no LLM)
test:
uv run pytest
# Run terminal E2E tests (real tmux, ~65s)
test-e2e:
uv run pytest -m terminal -v -o "addopts="
# Run installer E2E tests (opt-in: requires network + uv install)
test-install-e2e:
HIVE_RUN_INSTALL_E2E=1 uv run pytest tests/test_e2e_install.py -v -o "addopts="
# Regenerate golden file baselines
test-golden:
uv run pytest -m terminal --update-golden -o "addopts="
# Run LLM integration tests (slow, requires claude CLI)
test-llm:
uv run pytest -m llm -v -o "addopts="
# Run integration (multi-step state machine) tests
test-integration:
uv run pytest -m integration -v -o "addopts="
# Run a single test file or pattern (e.g. just test-one tests/test_smoke.py)
test-one target:
uv run pytest {{target}} -xvs
# Run terminal driver self-tests only (fast sanity check for tmux driver)
test-driver:
uv run pytest tests/test_terminal_driver.py -xvs -o "addopts="
# Run TODO/nudge E2E tests only
test-todo:
uv run pytest tests/test_e2e_todo_nudge.py -v -o "addopts="
# Run adversarial E2E tests only
test-adversarial:
uv run pytest tests/test_e2e_adversarial.py -v -o "addopts="
# Run only previously-failing tests (for debugging regressions)
test-fail:
uv run pytest --lf -xvs -o "addopts="
# Run all non-LLM tests (unit + integration + terminal E2E)
test-all: test test-e2e
# Coverage report (html in htmlcov/)
test-cov:
uv run pytest --cov=keephive --cov-report=term-missing --cov-report=html -o "addopts=-m 'not llm and not terminal' --strict-markers"
# Run quick smoke tests only
test-smoke:
uv run pytest tests/test_smoke.py tests/test_cli_dispatch.py -xvs
# Profile test timing (find slow tests)
test-timing:
uv run pytest --durations=20 -q
# Run tests and save results to .test-results.txt (for Claude Code / CI output capture)
test-save:
#!/usr/bin/env bash
set -euo pipefail
ts=$(date +%Y%m%d_%H%M%S)
echo "=== Test run: $ts ===" | tee .test-results.txt
uv run pytest -q 2>&1 | tee -a .test-results.txt
echo "EXIT:$?" >> .test-results.txt
echo "Results saved to .test-results.txt"
# Run specific tests and save results (e.g. just test-save-one tests/test_stats.py)
test-save-one target:
#!/usr/bin/env bash
set -euo pipefail
ts=$(date +%Y%m%d_%H%M%S)
echo "=== Test run: $ts — {{target}} ===" | tee .test-results.txt
uv run pytest {{target}} -xvs 2>&1 | tee -a .test-results.txt
echo "EXIT:$?" >> .test-results.txt
echo "Results saved to .test-results.txt"
# Run E2E tests and save results (terminal tests need -o "addopts=" to override pyproject)
test-save-e2e:
#!/usr/bin/env bash
set -euo pipefail
ts=$(date +%Y%m%d_%H%M%S)
echo "=== E2E run: $ts ===" | tee .test-results.txt
uv run pytest -m terminal -v --tb=short -o "addopts=" 2>&1 | tee -a .test-results.txt
echo "EXIT:$?" >> .test-results.txt
echo "Results saved to .test-results.txt"
# Lint with ruff
lint:
uv run ruff check src/ tests/
uv run ruff format --check src/ tests/
# Format in place
fmt:
uv run ruff format src/ tests/
# ── Quality Gates ────────────────────────────────────────────────────────────
# Fast pre-flight: format + lint + secrets (runs in ~2s, catches most issues)
pre-flight: fmt lint check-private
# Run all checks (test + lint + privacy scan)
check: test lint check-private
# Full pre-release check: pre-flight + all tests including terminal E2E
check-release: pre-flight test test-e2e
# Check for accidentally committed secrets / private data
check-private:
@echo "Scanning for secrets..."
@! grep -rn "sk-ant-api" src/ tests/ 2>/dev/null || (echo "ERROR: Anthropic key found" && exit 1)
@! grep -rn "-----BEGIN.*PRIVATE KEY" src/ tests/ 2>/dev/null || (echo "ERROR: Private key found" && exit 1)
@! grep -rn "ANTHROPIC_API_KEY\s*=" src/ tests/ --exclude="*.md" 2>/dev/null || (echo "ERROR: API key assignment found" && exit 1)
@echo "OK: no secrets found"
# ── Install & Sync ───────────────────────────────────────────────────────────
# Upgrade global install + sync hooks/MCP (run after release or pulling updates)
upgrade:
uv tool upgrade keephive
keephive setup
@echo "Global install upgraded and synced"
# Sync dev environment (deps + local editable install)
sync:
uv sync
@echo "Dev environment synced"
# ── Dashboard ────────────────────────────────────────────────────────────────
# Production health check against real HIVE_HOME data
checkup:
{{hivedev}} checkup
# Live dashboard with hot reload
serve:
{{hivedev}} serve --hot
# ── Watch Mode ─────────────────────────────────────────────────────────────
# Status in live-watch mode (auto-refresh on changes)
watch:
{{hivedev}} s --watch
# Log in live-watch mode
watch-log:
{{hivedev}} l --watch
# TODOs in live-watch mode
watch-todo:
{{hivedev}} todo --watch
# ── Demo Assets ────────────────────────────────────────────────────────────
# Reset demo profile with rich seed data (60 days)
demo-seed:
HIVE_HOME="$HOME/.claude/hive-demo" {{hivedev}} seed --force --days 60
# Record CLI demo GIF (requires vhs: brew install charmbracelet/tap/vhs)
demo-gif: demo-seed
HIVE_HOME="$HOME/.claude/hive-demo" vhs assets/demo.tape
gifsicle --optimize=3 --lossy=80 --colors=128 assets/cli-demo.gif -o assets/cli-demo.gif
@ls -lh assets/cli-demo.gif
# Record F1 maintenance flow demo GIF (requires vhs: brew install charmbracelet/tap/vhs)
demo-f1: demo-seed
HIVE_HOME="$HOME/.claude/hive-demo" vhs assets/demo-f1.tape
gifsicle --optimize=3 --lossy=80 --colors=128 assets/cli-demo-f1.gif -o assets/cli-demo-f1.gif
@ls -lh assets/cli-demo-f1.gif
# Record F2 KB channel + checkup Stage 3 demo GIF (requires vhs)
demo-f2: demo-seed
HIVE_HOME="$HOME/.claude/hive-demo" vhs assets/demo-f2.tape
gifsicle --optimize=3 --lossy=80 --colors=128 assets/cli-demo-f2.gif -o assets/cli-demo-f2.gif
@ls -lh assets/cli-demo-f2.gif
# Take dashboard screenshots (requires shot-scraper: uv tool install shot-scraper)
demo-screenshots: demo-seed
#!/usr/bin/env bash
set -euo pipefail
export HIVE_HOME="$HOME/.claude/hive-demo"
# Start serve in background
{{hivedev}} serve 13847 &
SERVER_PID=$!
# Wait for ready
for i in $(seq 1 20); do
curl -sf http://localhost:13847/ > /dev/null && break || sleep 0.5
done
# Capture screenshots
shot-scraper http://localhost:13847/brain -o assets/dashboard-brain.png --width 1200 --height 900
shot-scraper http://localhost:13847/stats -o assets/dashboard-stats.png --width 1200 --height 900
shot-scraper http://localhost:13847/know -o assets/dashboard-knowledge.png --width 1200 --height 900
shot-scraper http://localhost:13847/ -o assets/dashboard-home.png --width 1200 --height 900
shot-scraper http://localhost:13847/play -o assets/dashboard-play.png --width 1200 --height 900
# Cleanup
kill $SERVER_PID 2>/dev/null || true
@echo "Screenshots captured:"
@ls -lh assets/dashboard-*.png
# Regenerate all demo assets in parallel (GIF recordings concurrent, screenshots last)
demo-assets: demo-seed
#!/usr/bin/env bash
set -euo pipefail
# Run gif recordings in parallel
HIVE_HOME="$HOME/.claude/hive-demo" vhs assets/demo.tape &
HIVE_HOME="$HOME/.claude/hive-demo" vhs assets/demo-f1.tape &
HIVE_HOME="$HOME/.claude/hive-demo" vhs assets/demo-f2.tape &
wait
# Optimize all at once
gifsicle --optimize=3 --lossy=80 --colors=128 assets/cli-demo.gif -o assets/cli-demo.gif
gifsicle --optimize=3 --lossy=80 --colors=128 assets/cli-demo-f1.gif -o assets/cli-demo-f1.gif
gifsicle --optimize=3 --lossy=80 --colors=128 assets/cli-demo-f2.gif -o assets/cli-demo-f2.gif
# Screenshots last (needs serve running)
just demo-screenshots
echo "All demo assets regenerated"
# ── Release ───────────────────────────────────────────────────────────────────
# Bump version in __init__.py and pyproject.toml
bump version:
sed -i '' 's/__version__ = ".*"/__version__ = "{{version}}"/' src/keephive/__init__.py
sed -i '' 's/^version = ".*"/version = "{{version}}"/' pyproject.toml
@echo "Bumped to {{version}}"
@grep -E "__version__|^version" src/keephive/__init__.py pyproject.toml
# Full release to PyPI + GitHub. Pre-flight runs first; ruff rewrites auto-committed.
release version desc:
@echo "── Pre-flight: lint + format + secrets ──"
just pre-flight
@# Commit only src/ and tests/ to avoid accidentally staging unrelated local files.
@# Without this step, ruff-reformatted files stay unstaged and CI fails on the release tag.
git diff --quiet src/ tests/ || (git add src/ tests/ && git commit -m "chore: ruff fmt")
@echo "── Bump version ──"
just bump {{version}}
just sync
@echo "── Tests ──"
just test
git add src/keephive/__init__.py pyproject.toml uv.lock
git diff --cached --quiet || git commit -m "v{{version}}: {{desc}}"
uv build
uv run --with twine twine upload dist/keephive-{{version}}-py3-none-any.whl dist/keephive-{{version}}.tar.gz
git push
gh release create "v{{version}}" dist/keephive-{{version}}-py3-none-any.whl dist/keephive-{{version}}.tar.gz \
--title "v{{version}}: {{desc}}" \
--notes "{{desc}}"
just upgrade
@echo "Released v{{version}} to PyPI and GitHub"