1414 @ echo " ✓ Development environment ready!"
1515
1616# Build everything
17- build : build-rust build-node
17+ build : build-rust build-node build-opencode build-opencode-broker
1818
1919# Compile and run the occ binary (arguments automatically get passed to the binary)
2020# Example: just run --version
@@ -46,6 +46,71 @@ build-node:
4646 pnpm -C packages/ core build
4747 pnpm -r --filter=" !@opencode-cloud/core" build
4848
49+ # --- opencode Submodule Checks ---
50+
51+ # Ensure opencode submodule is initialized in this worktree
52+ opencode-submodule-check :
53+ @ if [ -f packages/ opencode/ .git ] || [ -d packages/ opencode/ .git ]; then \
54+ :; \
55+ else \
56+ echo " Submodule packages/opencode is not initialized." ; \
57+ echo " Run: git submodule update --init --recursive" ; \
58+ exit 1 ; \
59+ fi
60+
61+ # Install opencode dependencies when missing
62+ opencode-install-if-needed : opencode-submodule-check
63+ @ if [ ! -d packages/ opencode/ node_modules ]; then \
64+ echo " Installing opencode submodule dependencies..." ; \
65+ bun install --cwd packages/ opencode --frozen-lockfile; \
66+ else \
67+ echo " opencode submodule dependencies already installed." ; \
68+ fi
69+
70+ # Typecheck opencode workspace
71+ lint-opencode : opencode-install-if-needed
72+ bun --cwd packages/ opencode turbo typecheck
73+
74+ # Build the shared app package
75+ build-opencode-app : opencode-install-if-needed
76+ bun run --cwd packages/ opencode/ packages/ app build
77+
78+ # Build opencode single-ui artifact using local models fixture for deterministic output
79+ build-opencode-single-ui : opencode-install-if-needed
80+ @ tmpfile=" $(mktemp)" ; \
81+ trap ' rm -f "$tmpfile"' EXIT; \
82+ perl -pe ' chomp if eof' " {{ justfile_directory ()}} /packages/opencode/packages/opencode/test/tool/fixtures/models-api.json" > " $tmpfile" ; \
83+ MODELS_DEV_API_JSON=" $tmpfile" bun run --cwd packages/ opencode/ packages/ opencode build-single-ui
84+
85+ # Build opencode app and opencode binary/ui artifact
86+ build-opencode : build-opencode-app build-opencode-single-ui
87+
88+ # Lint opencode-broker Rust crate
89+ lint-opencode-broker : opencode-submodule-check
90+ cargo fmt --manifest-path packages/ opencode/ packages/ opencode-broker/ Cargo.toml --all -- --check
91+ cargo clippy --manifest-path packages/ opencode/ packages/ opencode-broker/ Cargo.toml --all-targets -- -D warnings
92+
93+ # Build opencode-broker Rust crate
94+ build-opencode-broker : opencode-submodule-check
95+ cargo build --manifest-path packages/ opencode/ packages/ opencode-broker/ Cargo.toml
96+
97+ # Test opencode-broker Rust crate
98+ test-opencode-broker : opencode-submodule-check
99+ cargo test --manifest-path packages/ opencode/ packages/ opencode-broker/ Cargo.toml
100+
101+ # Optional app unit test gate (not part of default pre-commit)
102+ test-opencode-ui : opencode-install-if-needed
103+ bun run --cwd packages/ opencode/ packages/ app test:unit
104+
105+ # Optional submodule drift and dirty state check
106+ check-opencode-submodule-drift :
107+ git submodule status --recursive
108+ git submodule foreach --recursive ' git status --short --branch'
109+
110+ # Update opencode submodule + Dockerfile OPENCODE_COMMIT pin
111+ update-opencode-commit :
112+ ./ scripts/ update-opencode-commit.sh
113+
49114# --- Docker Sandbox Image ---
50115
51116# Build Docker sandbox image with BuildKit caching (amd64 only, for local dev)
@@ -88,10 +153,10 @@ check-docker:
88153 @ echo " ✓ Dockerfile check passed"
89154
90155# Run all tests (fast)
91- test-all-fast : test-rust-fast test-node
156+ test-all-fast : test-rust-fast test-node test-opencode-broker
92157
93158# Run all tests (slow, includes doc-tests)
94- test-all-slow : test-rust test-node
159+ test-all-slow : test-rust test-node test-opencode-broker
95160
96161# Run all tests (fast)
97162test : test-all-fast
@@ -115,7 +180,7 @@ test-doc-slow:
115180 cargo test --workspace --doc
116181
117182# Lint everything
118- lint : lint-rust lint-node lint-shell
183+ lint : lint-rust lint-node lint-shell lint-opencode lint-opencode-broker
119184
120185# Lint Rust code
121186lint-rust :
0 commit comments