-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathJustfile
More file actions
1678 lines (1407 loc) · 56.3 KB
/
Justfile
File metadata and controls
1678 lines (1407 loc) · 56.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
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
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# OmoiOS Justfile
# Task runner for development, testing, and deployment
# Install just: https://github.com/casey/just
# Use bash for all recipes
set shell := ["bash", "-uc"]
# Load .env file automatically
set dotenv-load := true
# Set default environment
export OMOIOS_ENV := env_var_or_default("OMOIOS_ENV", "local")
# ============================================================================
# Variables
# ============================================================================
# Backend directory
backend_dir := "backend"
# Frontend directory
frontend_dir := "frontend"
# Frontend port
frontend_port := env_var_or_default("FRONTEND_PORT", "3000")
# Python command (runs in backend directory)
python := "uv run python"
# Pytest command (runs in backend directory)
pytest := "uv run pytest"
# Coverage threshold
coverage_threshold := "80"
# API port
api_port := env_var_or_default("API_PORT", "18000")
# ============================================================================
# Default Recipe (show help)
# ============================================================================
default:
@just --list
# ============================================================================
# Development Setup
# ============================================================================
# Install all dependencies (including test)
install:
cd {{backend_dir}} && uv sync --active --group test
# Install with dev and test dependencies
[group('setup')]
install-all:
cd {{backend_dir}} && uv sync --active --group dev --group test
# Sync all monorepo dependencies (backend + frontend + migrations)
[group('setup')]
sync:
#!/usr/bin/env bash
set -e
echo "🔄 Syncing OmoiOS monorepo..."
echo ""
# --- Backend dependencies ---
echo "🐍 Installing backend dependencies..."
cd {{backend_dir}} && uv sync --active --group dev --group test
cd ..
echo " ✅ Backend synced"
echo ""
# --- Frontend dependencies ---
echo "⚡ Installing frontend dependencies..."
cd {{frontend_dir}} && pnpm install
cd ..
echo " ✅ Frontend synced"
echo ""
# --- Database migrations ---
echo "🗄️ Running database migrations..."
cd {{backend_dir}} && uv run python -m alembic upgrade head
cd ..
echo " ✅ Migrations applied"
echo ""
echo "═══════════════════════════════════════════════════════════"
echo "✅ Monorepo sync complete!"
echo ""
echo "Start developing:"
echo " just dev-all # Start API + frontend"
echo " just watch # Backend with hot-reload"
echo " just test # Run tests"
# Setup test environment (create .env.test, config/test.yaml)
[group('setup')]
setup-test:
cd {{backend_dir}} && ./scripts/setup_test_environment.sh
# Complete first-time setup
[group('setup')]
setup: install-all setup-test
@echo "✅ Setup complete!"
@echo ""
@echo "Next steps:"
@echo " just docker-up # Start services"
@echo " just db-migrate # Run migrations"
@echo " just test # Run tests"
# One-command quickstart: env files, Docker services, deps, migrations, everything
[group('setup')]
quickstart:
#!/usr/bin/env bash
set -e
echo ""
echo "🚀 OmoiOS Quickstart"
echo "═══════════════════════════════════════════════════════════"
echo ""
# --- Step 1: Environment files ---
echo "📋 Step 1/5: Environment files"
if [ ! -f .env.local ]; then
cp .env.example .env.local
echo " Created .env.local from .env.example"
echo " ⚠️ Edit .env.local later to add your API keys (LLM_API_KEY, etc.)"
else
echo " ✅ .env.local already exists"
fi
if [ ! -f frontend/.env.local ]; then
cp frontend/.env.example frontend/.env.local
echo " Created frontend/.env.local from frontend/.env.example"
else
echo " ✅ frontend/.env.local already exists"
fi
echo ""
# --- Step 2: Start Docker services (Postgres + Redis) ---
echo "🐳 Step 2/5: Starting database services (PostgreSQL + Redis)"
echo " Waiting for services to be healthy..."
cd {{backend_dir}} && docker compose up -d --wait postgres redis
echo " ✅ PostgreSQL (port 15432) and Redis (port 16379) are healthy"
cd ..
echo ""
# --- Step 3: Install backend dependencies ---
echo "🐍 Step 3/5: Installing backend dependencies"
cd {{backend_dir}} && uv sync --group test
cd ..
echo " ✅ Backend dependencies installed"
echo ""
# --- Step 4: Run database migrations ---
echo "🗄️ Step 4/5: Running database migrations"
cd {{backend_dir}} && uv run python -m alembic upgrade head
cd ..
echo " ✅ Database migrations applied"
echo ""
# --- Step 5: Install frontend dependencies ---
echo "⚡ Step 5/5: Installing frontend dependencies"
cd {{frontend_dir}} && pnpm install
cd ..
echo " ✅ Frontend dependencies installed"
echo ""
# --- Done ---
echo "═══════════════════════════════════════════════════════════"
echo "✅ OmoiOS is ready!"
echo ""
echo "Start developing:"
echo " just dev-all # Start everything (API + frontend)"
echo " just watch # Backend with hot-reload (Docker)"
echo " just frontend-dev # Frontend only"
echo " just backend-api # Backend API only"
echo ""
echo "Other useful commands:"
echo " just test # Run tests"
echo " just bootstrap # Check environment health"
echo " just --list # See all commands"
echo ""
echo "💡 Don't forget to edit .env.local with your API keys!"
echo ""
# ============================================================================
# Git Worktree Management
# ============================================================================
#
# Worktrees let you work on multiple branches simultaneously in separate
# directories, each with its own working tree but sharing the same .git.
#
# Typical workflow:
# just worktree-create feature-xyz ../feature-xyz
# cd ../feature-xyz
# just dev-all
#
# For isolated worktrees (env changes won't affect the original repo):
# just worktree-create feature-xyz ../feature-xyz --copy
#
# Symlink .env files into a git worktree (default) or copy them (--copy).
# Automatically finds the main working tree to source .env files from.
# Usage: just worktree-env [path] # path defaults to "."
# just worktree-env ../my-feature-branch
# just worktree-env --copy
[group('setup')]
worktree-env worktree_path='.' *flags:
#!/usr/bin/env bash
set -euo pipefail
WORKTREE="{{worktree_path}}"
# Parse flags
COPY_MODE=false
for flag in {{flags}}; do
case "$flag" in
--copy) COPY_MODE=true ;;
*) echo "Unknown flag: $flag" >&2; exit 1 ;;
esac
done
# Resolve worktree path to absolute
if [[ ! "$WORKTREE" = /* ]]; then
WORKTREE="$(cd "$WORKTREE" && pwd)"
fi
if [ ! -d "$WORKTREE" ]; then
echo "❌ Worktree directory not found: $WORKTREE" >&2
echo " Create it first: git worktree add $WORKTREE <branch>" >&2
exit 1
fi
# Find the main working tree (source of .env files).
# In a worktree, .git is a file pointing to the main repo's .git/worktrees/<name>/.
# In the main repo, .git is a directory.
# We need the main repo's root — that's where the authoritative .env files live.
MAIN_REPO=""
if [ -f "$WORKTREE/.git" ]; then
# We're in a worktree — extract main repo path from .git file
# .git contains: gitdir: /path/to/main-repo/.git/worktrees/<name>
GITDIR_LINE="$(cat "$WORKTREE/.git")"
GITDIR_PATH="${GITDIR_LINE#gitdir: }"
# Derive main repo root: go up from .git/worktrees/<name> to the repo root
# e.g., /path/to/main-repo/.git/worktrees/feature-xyz → /path/to/main-repo
MAIN_REPO="$(cd "$(dirname "$(dirname "$(dirname "$GITDIR_PATH")")")" && pwd)"
else
# We're in the main repo (or a bare repo) — find the root normally
MAIN_REPO="$(git -C "$WORKTREE" rev-parse --show-toplevel)"
fi
if [ "$MAIN_REPO" = "$WORKTREE" ]; then
echo "ℹ️ Worktree is the main repo — no .env linking needed."
echo " .env files are already in place."
exit 0
fi
echo "📁 Main repo: $MAIN_REPO"
echo "🌳 Worktree: $WORKTREE"
if [ "$COPY_MODE" = true ]; then
echo "📋 Copying .env files from main repo to worktree"
else
echo "🔗 Symlinking .env files from main repo to worktree"
fi
echo ""
# Find all .env files in the MAIN repo (excluding examples, backups, node_modules, .venv)
cd "$MAIN_REPO"
FOUND=0
fd --hidden --type f '^\.env' \
--exclude '*.example' \
--exclude '*.backup*' \
--exclude 'node_modules' \
--exclude '.venv' \
--exclude '.git' \
--exclude '__pycache__' \
--exclude '.next' \
| while read -r envfile; do
target="$WORKTREE/$envfile"
# Create parent directory in worktree if needed
mkdir -p "$(dirname "$target")"
# Use absolute paths for symlinks to survive directory changes
abs_source="$(cd "$(dirname "$envfile")" && pwd)/$(basename "$envfile")"
if [ -L "$target" ] || [ -f "$target" ]; then
echo " ⚠️ $envfile already exists in worktree, skipping"
elif [ "$COPY_MODE" = true ]; then
cp "$abs_source" "$target"
echo " ✅ $envfile (copied) → $target"
else
ln -s "$abs_source" "$target"
echo " ✅ $envfile (symlinked) → $target"
fi
done \
| { output=$(cat); count=$(echo "$output" | grep -c '✅\|⚠️' 2>/dev/null || echo 0); echo "$output"; echo "FILES_SYNCED=$count"; }
echo ""
if [ "$COPY_MODE" = true ]; then
echo "Done. .env files are copied to worktree (edits are isolated)."
else
echo "Done. .env files are symlinked from main repo (edits sync back)."
echo "💡 Use --copy for isolated env (worktree edits won't affect original)."
fi
# Install all dependencies inside a worktree (Python + Node.js).
# Runs env sync, uv sync on all workspace members, and pnpm install in frontend.
# Defaults to current directory if no path given.
# Automatically finds .env files from the main repo.
# Usage: just worktree-setup # in the worktree dir
# just worktree-setup ../my-feature-branch
# just worktree-setup --copy
[group('setup')]
worktree-setup worktree_path='.' *flags:
#!/usr/bin/env bash
set -euo pipefail
WORKTREE="{{worktree_path}}"
# Resolve relative to absolute path
if [[ ! "$WORKTREE" = /* ]]; then
WORKTREE="$(cd "$WORKTREE" && pwd)"
fi
if [ ! -d "$WORKTREE" ]; then
echo "❌ Worktree directory not found: $WORKTREE" >&2
exit 1
fi
echo "🔧 Setting up worktree dependencies: $WORKTREE"
echo ""
echo "═══════════════════════════════════════════════════════════"
# --- Step 1: Environment files ---
echo ""
echo "📋 Step 1/4: Environment files"
FLAGS=""
for flag in {{flags}}; do FLAGS="$FLAGS $flag"; done
just worktree-env "$WORKTREE" $FLAGS
# --- Step 2: Backend Python dependencies (uv workspace) ---
echo ""
echo "🐍 Step 2/4: Installing backend dependencies (uv sync)"
if [ -f "$WORKTREE/backend/pyproject.toml" ]; then
cd "$WORKTREE/backend" && uv sync --group test
echo " ✅ Backend dependencies installed"
else
echo " ⚠️ No backend/pyproject.toml found, skipping"
fi
# --- Step 3: SDK Python dependencies ---
echo ""
echo "📦 Step 3/4: Installing SDK dependencies"
if [ -f "$WORKTREE/sdk/python/pyproject.toml" ]; then
cd "$WORKTREE/sdk/python" && uv sync
echo " ✅ SDK dependencies installed"
else
echo " ⚠️ No sdk/python/pyproject.toml found, skipping"
fi
# --- Step 4: Frontend Node.js dependencies ---
echo ""
echo "⚡ Step 4/4: Installing frontend dependencies (pnpm install)"
if [ -f "$WORKTREE/frontend/package.json" ]; then
cd "$WORKTREE/frontend" && pnpm install
echo " ✅ Frontend dependencies installed"
else
echo " ⚠️ No frontend/package.json found, skipping"
fi
echo ""
echo "═══════════════════════════════════════════════════════════"
echo "✅ Worktree setup complete: $WORKTREE"
echo ""
echo "Start developing:"
echo " cd $WORKTREE"
echo " just docker-up # Start Postgres + Redis"
echo " just dev-all # Start API + frontend"
echo " just test # Run tests"
# Create a git worktree and set it up in one step.
# Creates the worktree, symlinks .env files, and installs all dependencies.
# Usage: just worktree-create feature-xyz ../feature-xyz
# just worktree-create feature-xyz ../feature-xyz --copy
[group('setup')]
worktree-create branch path *flags:
#!/usr/bin/env bash
set -euo pipefail
# Parse flags
COPY_FLAG=""
for flag in {{flags}}; do
case "$flag" in
--copy) COPY_FLAG="--copy" ;;
*) echo "Unknown flag: $flag" >&2; exit 1 ;;
esac
done
echo "🌳 Creating git worktree: {{path}} (branch: {{branch}})"
echo ""
# Create the worktree
git worktree add "{{path}}" "{{branch}}"
echo "✅ Worktree created at {{path}}"
echo ""
# Run full setup (env + dependencies)
just worktree-env "{{path}}" $COPY_FLAG
just worktree-setup "{{path}}"
# Check all development dependencies
[group('setup')]
bootstrap:
cd {{backend_dir}} && {{python}} -m omoi_os.cli.bootstrap check
# Show live health dashboard
[group('setup')]
health:
cd {{backend_dir}} && {{python}} -m omoi_os.cli.bootstrap health
# Start all services in local-only mode (no external APIs needed)
[group('dev')]
dev-local:
OMOIOS_ENV=local just dev-all
# Inspect task context (what an agent would receive)
[group('dev')]
inspect-context task_id format="markdown":
cd {{backend_dir}} && {{python}} -m omoi_os.cli.inspect_context {{task_id}} --format {{format}}
# Stream live orchestration events from Redis
[group('dev')]
event-stream *args='':
cd {{backend_dir}} && {{python}} -m omoi_os.cli.event_stream {{args}}
# Replay monitoring sessions through Guardian/Conductor
[group('dev')]
monitoring-replay *ARGS:
cd {{backend_dir}} && {{python}} -m omoi_os.cli.monitoring_replay {{ARGS}}
# Run spec pipeline in fixture mode
[group('dev')]
spec-fixture *args='':
cd {{backend_dir}} && {{python}} -m omoi_os.cli.spec_fixture {{args}}
#NJ|
# Preview branch strategy for a spec
[group('dev')]
branch-preview *ARGS:
cd {{backend_dir}} && {{python}} -m omoi_os.cli.branch_preview {{ARGS}}
# ============================================================================
# Testing (with pytest-testmon)
# ============================================================================
# Default: run unit tests (fast, no external deps)
[group('test')]
test pattern="":
cd {{backend_dir}} && {{pytest}} tests/unit/ {{pattern}} -x -q
# Run all affected tests (uses testmon, may hit DB/Redis)
[group('test')]
test-affected pattern="":
cd {{backend_dir}} && {{pytest}} {{pattern}} --testmon -x
# Run unit tests only (verbose)
[group('test')]
test-unit:
cd {{backend_dir}} && {{pytest}} tests/unit/ -v
# Run integration tests
[group('test')]
test-integration:
cd {{backend_dir}} && {{pytest}} tests/integration/ --testmon -v
# Run end-to-end tests
[group('test')]
test-e2e:
cd {{backend_dir}} && {{pytest}} tests/e2e/ --testmon -v
# Run performance tests
[group('test')]
test-performance:
cd {{backend_dir}} && {{pytest}} tests/performance/ --testmon -v
# Run ALL tests (no testmon, full suite)
[group('test')]
test-all:
cd {{backend_dir}} && {{pytest}} --no-testmon --cov
# Run fast tests in parallel (unit tests, not slow)
[group('test')]
test-fast:
cd {{backend_dir}} && {{pytest}} -m "unit and not slow" --testmon -x -n auto
# Run tests in parallel
[group('test')]
test-parallel workers="auto":
cd {{backend_dir}} && {{pytest}} --testmon -n {{workers}}
# Generate HTML coverage report
[group('test')]
test-coverage:
cd {{backend_dir}} && {{pytest}} --no-testmon --cov --cov-report=html --cov-report=term
@echo ""
@echo "📊 Coverage report: {{backend_dir}}/htmlcov/index.html"
@command -v open >/dev/null && open {{backend_dir}}/htmlcov/index.html || \
command -v xdg-open >/dev/null && xdg-open {{backend_dir}}/htmlcov/index.html || true
# Re-run only failed tests
[group('test')]
test-failed:
cd {{backend_dir}} && {{pytest}} --lf --testmon -x
# Run tests matching a keyword
[group('test')]
test-match keyword:
cd {{backend_dir}} && {{pytest}} -k {{keyword}} --testmon -v
# Run tests with specific marker
[group('test')]
test-mark marker:
cd {{backend_dir}} && {{pytest}} -m {{marker}} --testmon -v
# Rebuild testmon dependency cache
[group('test')]
test-rebuild:
@echo "🔄 Rebuilding testmon cache..."
cd {{backend_dir}} && rm -rf .testmondata
cd {{backend_dir}} && {{pytest}} --testmon
# Clean all test artifacts
[group('test')]
test-clean:
@echo "🧹 Cleaning test artifacts..."
cd {{backend_dir}} && rm -rf .testmondata .pytest_cache htmlcov .coverage coverage.xml
cd {{backend_dir}} && find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
# Run smoke test (critical path only)
[group('test')]
test-smoke:
cd {{backend_dir}} && {{pytest}} -m critical --testmon -x
# Show what tests would run (dry-run)
[group('test')]
test-dry:
cd {{backend_dir}} && {{pytest}} --testmon --collect-only
# Watch mode (requires pytest-watch)
[group('test')]
test-watch:
cd {{backend_dir}} && uv run ptw -- --testmon -x
# ============================================================================
# Code Quality
# ============================================================================
# Format code with ruff
[group('quality')]
format:
cd {{backend_dir}} && uv run ruff check --fix .
cd {{backend_dir}} && uv run ruff format .
# Lint code with ruff (check only, no fixes)
[group('quality')]
lint:
cd {{backend_dir}} && uv run ruff check .
# Type check with mypy
[group('quality')]
type-check:
cd {{backend_dir}} && uv run mypy omoi_os
# Run quality checks (fix + format with ruff)
[group('quality')]
check:
cd {{backend_dir}} && uv run ruff check --fix .
cd {{backend_dir}} && uv run ruff format .
# Fix all auto-fixable issues (alias for check)
[group('quality')]
fix:
cd {{backend_dir}} && uv run ruff check --fix .
cd {{backend_dir}} && uv run ruff format .
@echo "✅ Auto-fixes applied"
# ============================================================================
# Database Operations
# ============================================================================
# Run all migrations
[group('database')]
db-migrate:
cd {{backend_dir}} && uv run alembic upgrade head
# Create new migration
[group('database')]
db-revision message:
cd {{backend_dir}} && uv run alembic revision -m "{{message}}"
# Rollback one migration
[group('database')]
db-downgrade count="1":
cd {{backend_dir}} && uv run alembic downgrade -{{count}}
# Show migration history
[group('database')]
db-history:
cd {{backend_dir}} && uv run alembic history
# Show current migration
[group('database')]
db-current:
cd {{backend_dir}} && uv run alembic current
# Start a local Postgres (pg0, no Docker) on the test port; creates app_db
[group('database')]
pg0-up:
bash scripts/pg0_up.sh
# Apply migrations to the local pg0 instance (app_db)
[group('database')]
pg0-migrate: pg0-up
cd {{backend_dir}} && DATABASE_URL="postgresql+psycopg://postgres:postgres@127.0.0.1:15432/app_db" uv run alembic upgrade head
# Stop the local pg0 instance (data persists at ~/.pg0/instances/omoi-os/)
[group('database')]
pg0-down:
${HOME}/.local/bin/pg0 stop --name omoi-os || true
# Drop the local pg0 instance entirely (deletes data; irreversible)
[group('database')]
pg0-nuke:
${HOME}/.local/bin/pg0 drop --name omoi-os
# Status of the local pg0 instance
[group('database')]
pg0-info:
${HOME}/.local/bin/pg0 info --name omoi-os
# ============================================================================
# Docker Operations
# ============================================================================
# Start all services
[group('docker')]
docker-up:
cd {{backend_dir}} && docker-compose up -d
# Stop all services
[group('docker')]
docker-down:
cd {{backend_dir}} && docker-compose down
# View logs (optionally specify service)
[group('docker')]
docker-logs service="":
#!/usr/bin/env bash
cd {{backend_dir}}
if [ -z "{{service}}" ]; then
docker-compose logs -f
else
docker-compose logs -f {{service}}
fi
# Rebuild and restart services
[group('docker')]
docker-rebuild:
cd {{backend_dir}} && docker-compose up -d --build
# Clean Docker volumes and rebuild
[group('docker')]
docker-clean:
cd {{backend_dir}} && docker-compose down -v
cd {{backend_dir}} && docker-compose up -d --build
# ============================================================================
# Docker Compose Watch (Hot-Reload Development)
# ============================================================================
# Start all backend services with hot-reload (recommended for development)
[group('docker')]
watch:
@echo "🚀 Starting all backend services with hot-reload..."
@echo " API: http://localhost:{{api_port}}"
@echo " Press Ctrl+C to stop"
cd {{backend_dir}} && docker compose watch
# Start only API + infrastructure (no background workers)
[group('docker')]
watch-api:
@echo "🚀 Starting API with hot-reload (no workers)..."
cd {{backend_dir}} && docker compose watch api postgres redis
# Start orchestrator worker only
[group('docker')]
watch-orchestrator:
@echo "🚀 Starting orchestrator worker with hot-reload..."
cd {{backend_dir}} && docker compose watch orchestrator postgres redis
# Start monitoring worker only
[group('docker')]
watch-monitoring:
@echo "🚀 Starting monitoring worker with hot-reload..."
cd {{backend_dir}} && docker compose watch monitoring postgres redis
# ============================================================================
# Service Utilities
# ============================================================================
# Check if a port is in use
[group('services')]
check-port port:
#!/usr/bin/env bash
if lsof -Pi :{{port}} -sTCP:LISTEN -t >/dev/null 2>&1 ; then
echo "⚠️ Port {{port}} is already in use"
echo "Process using port {{port}}:"
lsof -Pi :{{port}} -sTCP:LISTEN
exit 1
else
echo "✅ Port {{port}} is available"
exit 0
fi
# Kill process on a specific port
[group('services')]
kill-port port:
#!/usr/bin/env bash
PID=$(lsof -ti:{{port}})
if [ -z "$PID" ]; then
echo "ℹ️ No process found on port {{port}}"
else
echo "🛑 Killing process $PID on port {{port}}..."
kill -9 $PID
echo "✅ Process killed"
fi
# Check status of all services (ports and health endpoints)
[group('services')]
status:
#!/usr/bin/env bash
echo "📊 Service Status"
echo "=================="
echo ""
echo "Port {{api_port}} (Backend API):"
if lsof -Pi :{{api_port}} -sTCP:LISTEN -t >/dev/null 2>&1 ; then
echo " ✅ Running"
PID=$(lsof -ti:{{api_port}})
echo " PID: $PID"
if curl -s http://localhost:{{api_port}}/health >/dev/null 2>&1 ; then
echo " ✅ Health check: OK"
HEALTH=$(curl -s http://localhost:{{api_port}}/health | head -c 100)
echo " Response: $HEALTH..."
else
echo " ⚠️ Health check: FAILED"
fi
else
echo " ❌ Not running"
fi
echo ""
echo "Port {{frontend_port}} (Frontend):"
if lsof -Pi :{{frontend_port}} -sTCP:LISTEN -t >/dev/null 2>&1 ; then
echo " ✅ Running"
PID=$(lsof -ti:{{frontend_port}})
echo " PID: $PID"
if curl -s http://localhost:{{frontend_port}} >/dev/null 2>&1 ; then
echo " ✅ Health check: OK"
else
echo " ⚠️ Health check: FAILED"
fi
else
echo " ❌ Not running"
fi
echo ""
echo "Worker processes:"
WORKER_COUNT=$(ps aux | grep -c "[p]ython -m omoi_os.worker" || echo "0")
if [ "$WORKER_COUNT" -gt 0 ]; then
echo " ✅ $WORKER_COUNT worker(s) running"
ps aux | grep "[p]ython -m omoi_os.worker" | awk '{print " PID: " $2}'
else
echo " ❌ No workers running"
fi
# Health check for backend API
[group('services')]
health-api:
#!/usr/bin/env bash
echo "🏥 Checking backend API health..."
if curl -s http://localhost:{{api_port}}/health ; then
echo ""
echo "✅ Backend API is healthy"
else
echo "❌ Backend API health check failed"
exit 1
fi
# Health check for frontend
[group('services')]
health-frontend:
#!/usr/bin/env bash
echo "🏥 Checking frontend health..."
if curl -s http://localhost:{{frontend_port}} >/dev/null 2>&1 ; then
echo "✅ Frontend is healthy"
else
echo "❌ Frontend health check failed"
exit 1
fi
# Health check for all services
[group('services')]
health-all: health-api health-frontend
@echo "✅ All services are healthy"
# Stop all running services
[group('services')]
stop-all:
#!/usr/bin/env bash
echo "🛑 Stopping all services..."
echo ""
# Kill API server
API_PID=$(lsof -ti:{{api_port}} 2>/dev/null || true)
if [ -n "$API_PID" ]; then
echo " Stopping API server (PID: $API_PID)..."
kill -9 $API_PID 2>/dev/null || true
echo " ✅ API server stopped"
else
echo " ℹ️ API server not running"
fi
# Kill frontend
FRONTEND_PID=$(lsof -ti:{{frontend_port}} 2>/dev/null || true)
if [ -n "$FRONTEND_PID" ]; then
echo " Stopping frontend (PID: $FRONTEND_PID)..."
kill -9 $FRONTEND_PID 2>/dev/null || true
echo " ✅ Frontend stopped"
else
echo " ℹ️ Frontend not running"
fi
# Kill workers
WORKER_COUNT=$(pgrep -f "python -m omoi_os.worker" 2>/dev/null | wc -l | tr -d ' ' || echo "0")
if [ "$WORKER_COUNT" -gt 0 ]; then
echo " Stopping $WORKER_COUNT worker(s)..."
pkill -9 -f "python -m omoi_os.worker" 2>/dev/null || true
echo " ✅ Workers stopped"
else
echo " ℹ️ No workers running"
fi
echo ""
echo "✅ All services stopped"
# Restart all services (stop then start)
[group('services')]
restart-all:
just stop-all
sleep 2
just dev-all
# ============================================================================
# Running Services
# ============================================================================
# Start API server (development mode with reload)
[group('services')]
api port=api_port:
cd {{backend_dir}} && uv run uvicorn omoi_os.api.main:app --host 0.0.0.0 --port {{port}} --reload
# Start worker process
[group('services')]
worker:
cd {{backend_dir}} && uv run python -m omoi_os.worker
# Run smoke test
[group('services')]
smoke:
cd {{backend_dir}} && uv run python scripts/smoke_test.py
# Start API and worker in parallel (requires tmux or separate terminals)
[group('services')]
dev:
@echo "Starting services..."
@echo "API will be at http://localhost:{{api_port}}"
@just api &
@sleep 2
@just worker
# Start both backend services (API and worker) in separate terminals
# Note: This runs them in background - use 'backend-api' and 'backend-worker'
# in separate terminal windows for better control
[group('services')]
backend-dev:
@echo "🚀 Starting backend services..."
@echo ""
@echo "Starting API server..."
@cd {{backend_dir}} && uv run uvicorn omoi_os.api.main:app --host 0.0.0.0 --port {{api_port}} --reload &
@sleep 2
@echo "Starting worker..."
@cd {{backend_dir}} && uv run python -m omoi_os.worker
# Start only the API server (runs in backend directory)
[group('services')]
backend-api:
@echo "🚀 Starting API server on port {{api_port}}..."
@echo "API will be at http://localhost:{{api_port}}"
cd {{backend_dir}} && uv run uvicorn omoi_os.api.main:app --host 0.0.0.0 --port {{api_port}} --reload
# Start only the worker (runs in backend directory)
[group('services')]
backend-worker:
@echo "🚀 Starting worker..."
cd {{backend_dir}} && uv run python -m omoi_os.worker
# ============================================================================
# Separate Process Development (No Docker)
# ============================================================================
# Quick local API - all background loops disabled
[group('services')]
api-light port=api_port:
@echo "🚀 Starting lightweight API (no background loops)..."
cd {{backend_dir}} && MONITORING_ENABLED=false ORCHESTRATOR_ENABLED=false MCP_ENABLED=false \
DAYTONA_SANDBOX_EXECUTION=true \
uv run uvicorn omoi_os.api.main:app --host 0.0.0.0 --port {{port}} --reload
# Start orchestrator as separate process (local, no Docker)
[group('services')]
orchestrator:
@echo "🚀 Starting orchestrator worker..."
cd {{backend_dir}} && uv run python -m omoi_os.workers.orchestrator_worker
# Start monitoring as separate process (local, no Docker)
[group('services')]
monitoring:
@echo "🚀 Starting monitoring worker..."
cd {{backend_dir}} && uv run python -m omoi_os.workers.monitoring_worker
# ============================================================================
# Full Stack Development
# ============================================================================
# Start everything: backend (docker watch) + frontend
[group('services')]
dev-watch:
#!/usr/bin/env bash
set -e
echo "🚀 Starting full stack with hot-reload..."
echo ""
echo "Backend API: http://localhost:{{api_port}}"
echo "Frontend: http://localhost:{{frontend_port}}"
echo ""
# Start backend in background
cd {{backend_dir}} && docker compose watch &
BACKEND_PID=$!
# Wait for API to be ready
echo "Waiting for backend..."
sleep 5
# Start frontend in foreground
echo "Starting frontend..."
cd {{frontend_dir}} && NODE_OPTIONS="--max-old-space-size=4096" pnpm exec next dev --port {{frontend_port}}
# Cleanup on exit
kill $BACKEND_PID 2>/dev/null || true
# ============================================================================
# Frontend Services
# ============================================================================
# Install frontend dependencies
[group('frontend')]
frontend-install:
@echo "📦 Installing frontend dependencies..."
cd {{frontend_dir}} && pnpm install
# Start frontend development server
[group('frontend')]
frontend-dev port=frontend_port:
@echo "🚀 Starting frontend development server..."
@echo "Frontend will be at http://localhost:{{port}}"
cd {{frontend_dir}} && NODE_OPTIONS="--max-old-space-size=4096" pnpm exec next dev --port {{port}}
# Build frontend for production
[group('frontend')]
frontend-build:
@echo "🏗️ Building frontend for production..."
cd {{frontend_dir}} && pnpm build
# Start frontend production server
[group('frontend')]
frontend-start port=frontend_port:
@echo "🚀 Starting frontend production server..."
@echo "Frontend will be at http://localhost:{{port}}"
cd {{frontend_dir}} && pnpm start -- -p {{port}}
# Format frontend code with Prettier
[group('frontend')]
frontend-format:
@echo "🔧 Formatting frontend code..."