-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
416 lines (343 loc) · 12.2 KB
/
justfile
File metadata and controls
416 lines (343 loc) · 12.2 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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
# Bond Agent UI - Command Runner
# Forensic timeline viewer for Bond agent traces
# Run `just` to see all available commands
# =============================================================================
# Configuration
# =============================================================================
# Default ports
ui_port := "5173"
backend_port := "8000"
# Project paths (relative to this justfile)
project_root := justfile_directory()
ui_dir := justfile_directory() / "ui"
# =============================================================================
# Default & Help
# =============================================================================
# List all available commands
default:
@just --list
# Show detailed help for demo setup
help:
@echo "Bond Agent UI - Forensic Timeline Viewer"
@echo "========================================="
@echo ""
@echo "Quick Start:"
@echo " just setup Install all dependencies"
@echo " just demo Run full demo (backend + frontend)"
@echo " just demo-stop Stop all running services"
@echo ""
@echo "Development:"
@echo " just dev-ui Run frontend only (Vite)"
@echo " just dev-backend Run backend only (uvicorn)"
@echo " just dev Run both frontend and backend"
@echo ""
@echo "Ports:"
@echo " Frontend: http://localhost:{{ui_port}}"
@echo " Backend: http://localhost:{{backend_port}}"
@echo ""
@echo "Usage:"
@echo " 1. Click 'Connect' in the UI"
@echo " 2. Server URL: http://localhost:8000"
@echo " 3. Enter a prompt and chat!"
# =============================================================================
# Setup Commands
# =============================================================================
# Install all dependencies (Python + Node)
setup: setup-python setup-node setup-pre-commit
@echo ""
@echo "Setup complete! Run 'just demo' to start."
# Install Python dependencies
setup-python:
@echo "Installing Python dependencies..."
uv sync --extra server --extra dev
@echo "Python dependencies installed."
# Install Node dependencies (pnpm)
setup-node:
@echo "Installing Node dependencies..."
cd {{ui_dir}} && pnpm install
@echo "Node dependencies installed."
# Install pre-commit hooks
setup-pre-commit:
@echo "Installing pre-commit hooks..."
uv run pre-commit install || true
@echo "Pre-commit hooks installed."
# =============================================================================
# Demo Commands
# =============================================================================
# Run full demo stack (backend + frontend + auto-open browser)
demo: check-env
#!/usr/bin/env bash
set -euo pipefail
echo "Starting Bond Agent Demo..."
echo ""
# Kill any existing processes on our ports
lsof -ti:{{ui_port}} | xargs kill -9 2>/dev/null || true
lsof -ti:{{backend_port}} | xargs kill -9 2>/dev/null || true
# Trap to clean up on exit
trap 'kill 0 2>/dev/null' EXIT
echo "========================================="
echo " Bond Agent Demo"
echo "========================================="
echo ""
echo " Frontend: http://localhost:{{ui_port}}"
echo " Backend: http://localhost:{{backend_port}}"
echo ""
echo " Press Ctrl+C to stop all services"
echo "========================================="
echo ""
# Start backend
(uv run python test_server.py) &
BACKEND_PID=$!
# Wait for backend to be ready
echo "Waiting for backend to be ready..."
for i in {1..30}; do
if curl -s http://localhost:{{backend_port}}/health > /dev/null 2>&1; then
echo "Backend ready!"
break
fi
sleep 1
done
# Open browser after frontend is ready
(
sleep 3
if command -v open &> /dev/null; then
open "http://localhost:{{ui_port}}"
elif command -v xdg-open &> /dev/null; then
xdg-open "http://localhost:{{ui_port}}" &
fi
) &
# Start frontend (this blocks)
cd {{ui_dir}} && pnpm dev --port {{ui_port}}
# Run demo without opening browser
demo-headless: check-env
#!/usr/bin/env bash
set -euo pipefail
echo "Starting Bond Agent Demo (headless)..."
# Kill any existing processes on our ports
lsof -ti:{{ui_port}} | xargs kill -9 2>/dev/null || true
lsof -ti:{{backend_port}} | xargs kill -9 2>/dev/null || true
trap 'kill 0 2>/dev/null' EXIT
echo ""
echo " Frontend: http://localhost:{{ui_port}}"
echo " Backend: http://localhost:{{backend_port}}"
echo ""
# Start backend
(uv run python test_server.py) &
# Start frontend
cd {{ui_dir}} && pnpm dev --port {{ui_port}}
# Stop all demo services
demo-stop:
#!/usr/bin/env bash
echo "Stopping demo services..."
# Kill by process name
pkill -f "uvicorn.*test_server" 2>/dev/null || true
pkill -f "python.*test_server" 2>/dev/null || true
pkill -f "vite" 2>/dev/null || true
pkill -f "pnpm dev" 2>/dev/null || true
# Kill by port (fallback)
lsof -ti:{{ui_port}} | xargs kill -9 2>/dev/null || true
lsof -ti:{{backend_port}} | xargs kill -9 2>/dev/null || true
# Kill orphaned Vite processes on nearby ports
for port in 5173 5174 5175 5176 5177 5178 5179; do
lsof -ti:$port | xargs kill -9 2>/dev/null || true
done
echo "Done. All services stopped."
# Show what's running on demo ports
demo-status:
#!/usr/bin/env bash
echo "Port Status:"
echo "============"
echo ""
echo "Frontend ({{ui_port}}):"
lsof -i :{{ui_port}} 2>/dev/null || echo " Not running"
echo ""
echo "Backend ({{backend_port}}):"
lsof -i :{{backend_port}} 2>/dev/null || echo " Not running"
echo ""
echo "Other Vite ports (5173-5179):"
lsof -i :5173 -i :5174 -i :5175 -i :5176 -i :5177 -i :5178 -i :5179 2>/dev/null || echo " None"
# =============================================================================
# Development Commands
# =============================================================================
# Run frontend only (Vite dev server)
dev-ui:
#!/usr/bin/env bash
# Kill any existing Vite on our port
lsof -ti:{{ui_port}} | xargs kill -9 2>/dev/null || true
echo "Starting UI on http://localhost:{{ui_port}}..."
cd {{ui_dir}} && pnpm dev --port {{ui_port}}
# Run backend only (test server)
dev-backend: check-env
#!/usr/bin/env bash
lsof -ti:{{backend_port}} | xargs kill -9 2>/dev/null || true
echo "Starting backend on http://localhost:{{backend_port}}..."
uv run python test_server.py
# Run both frontend and backend (alias for demo-headless)
dev: demo-headless
# Run frontend with specific port
dev-ui-port port:
#!/usr/bin/env bash
lsof -ti:{{port}} | xargs kill -9 2>/dev/null || true
echo "Starting UI on http://localhost:{{port}}..."
cd {{ui_dir}} && pnpm dev --port {{port}}
# =============================================================================
# Build Commands
# =============================================================================
# Build production bundle
build:
@echo "Building production bundle..."
cd {{ui_dir}} && pnpm build
@echo "Build complete! Output in ui/dist/"
# Preview production build
preview:
@echo "Starting preview server..."
cd {{ui_dir}} && pnpm preview
# Build and preview
build-preview: build preview
# =============================================================================
# Code Quality Commands
# =============================================================================
# Run ESLint
lint:
@echo "Running ESLint..."
cd {{ui_dir}} && pnpm lint
# Run ESLint with auto-fix
lint-fix:
@echo "Running ESLint with auto-fix..."
cd {{ui_dir}} && pnpm lint --fix
# Type check (TypeScript)
typecheck:
@echo "Running TypeScript type check..."
cd {{ui_dir}} && pnpm exec tsc --noEmit
# Run all checks (lint + typecheck)
check: lint typecheck
@echo "All checks passed!"
# =============================================================================
# Python Backend Commands
# =============================================================================
# Run Python tests
test-python:
@echo "Running Python tests..."
uv run pytest
# Run Python tests with coverage
test-python-cov:
@echo "Running Python tests with coverage..."
uv run pytest --cov=src/bond --cov-report=html
@echo "Coverage report: htmlcov/index.html"
# Run Python linting (ruff)
lint-python:
@echo "Running ruff..."
uv run ruff check src tests
# Format Python code
format-python:
@echo "Formatting Python code..."
uv run ruff format src tests
# Run Python type checking (mypy)
typecheck-python:
@echo "Running mypy..."
uv run mypy src/bond
# Run all Python checks
check-python: lint-python typecheck-python
@echo "All Python checks passed!"
# =============================================================================
# Pre-commit & CI
# =============================================================================
# Run pre-commit on all files
pre-commit:
@echo "Running pre-commit hooks..."
uv run pre-commit run --all-files
# Run full CI pipeline locally
ci: check check-python test-python build
@echo ""
@echo "CI pipeline passed!"
# =============================================================================
# Clean Commands
# =============================================================================
# Clean build artifacts
clean:
@echo "Cleaning build artifacts..."
rm -rf {{ui_dir}}/dist
rm -rf {{ui_dir}}/node_modules/.cache
rm -rf {{ui_dir}}/node_modules/.vite
@echo "Clean complete."
# Clean all (including node_modules)
clean-all: clean
@echo "Removing node_modules..."
rm -rf {{ui_dir}}/node_modules
@echo "Full clean complete. Run 'just setup-node' to reinstall."
# Clean Python artifacts
clean-python:
@echo "Cleaning Python artifacts..."
rm -rf .pytest_cache .mypy_cache .ruff_cache .coverage htmlcov dist
@echo "Python clean complete."
# =============================================================================
# Documentation
# =============================================================================
# Serve docs locally
docs:
@echo "Starting docs server..."
uv run mkdocs serve
# Build docs
docs-build:
@echo "Building docs..."
uv run mkdocs build
@echo "Docs built! Output in site/"
# =============================================================================
# Utility Commands
# =============================================================================
# Check environment is ready
check-env:
#!/usr/bin/env bash
echo "Checking environment..."
# Check for OPENAI_API_KEY
if [ -z "${OPENAI_API_KEY:-}" ]; then
echo ""
echo "WARNING: OPENAI_API_KEY not set!"
echo "The backend will fail to generate AI responses."
echo ""
echo "Set it with:"
echo " export OPENAI_API_KEY=sk-..."
echo ""
echo "Or create a .env file:"
echo " echo 'OPENAI_API_KEY=sk-...' > .env"
echo ""
# Don't exit - allow demo to run without API key
else
echo "OPENAI_API_KEY is set."
fi
# Check for required tools
for cmd in node pnpm uv; do
if ! command -v $cmd &> /dev/null; then
echo "ERROR: $cmd is required but not installed."
exit 1
fi
done
echo "Environment check passed."
# Open project in browser
open-ui:
#!/usr/bin/env bash
if command -v open &> /dev/null; then
open "http://localhost:{{ui_port}}"
elif command -v xdg-open &> /dev/null; then
xdg-open "http://localhost:{{ui_port}}" &
else
echo "Open http://localhost:{{ui_port}} in your browser"
fi
# Show project info
info:
@echo "Bond Agent UI"
@echo "============="
@echo ""
@echo "Project: {{project_root}}"
@echo "UI Dir: {{ui_dir}}"
@echo ""
@echo "Node: $(node --version)"
@echo "pnpm: $(pnpm --version)"
@echo "uv: $(uv --version)"
@echo ""
@echo "Run 'just help' for usage instructions."
# Concatenate all source files (for context/review)
concat:
@echo "Concatenating source files..."
python scripts/concat_files.py
@echo "Output: all_code_and_configs.txt"