Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
set positional-arguments
# Android: fetch pinned Firebase config and provision missing release signing from Doppler.
android-dev *ARGS:
bash scripts/android.sh dev "$@"
android-build *ARGS:
bash scripts/android.sh build "$@"
# Increment the versionCode and commit before preparing the next native APK or
# Play AAB release. Also raises the Android floor in min-native-build.json to
# the new versionCode, so the next prod web deploy stops serving shared JS to
# older Android installs and prompts them to update. --no-min keeps the floor
# for a release older installs don't need.
android-bump *ARGS:
bun scripts/android-release.ts bump {{ARGS}}
# iOS: dev-facing, for testing in Simulator. Honors PORT like the web dev
# server (`PORT=3001 just ios-dev`): the vite server picks PORT up through
# beforeDevCommand's environment, and the --config merge points the webview's
# devUrl at the same port.
ios-dev: ios-prepare
bash scripts/ios-dev.sh
# Compatibility alias for `just ios-build --no-update`.
ios-build-no-update: (ios-build "--no-update")
# iOS: build for release; --no-update disables automatic bundle updates.
ios-build *ARGS: ios-prepare
bash scripts/ios-build.sh "$@"
# iOS: arm64 Simulator .app for the Appetize PR preview (the `ios_preview`
# workflow). Simulator builds need no signing, and --no-default-features keeps
# the bundle auto-updater off so a preview cannot quietly replace itself with
# the production bundle.
#
# The frontend is built as a separate step rather than through Tauri's
# beforeBuildCommand hook: the web and wasm builds want the nix toolchain,
# while everything Xcode drives wants Apple's, and running both under one set
# of compiler flags breaks whichever one loses. CI builds the frontend in a
# clean nix shell and then calls this with prebuilt=true.
#
# Output: tauri/src-tauri/gen/apple/build/arm64-sim/macro.app
ios-build-sim prebuilt="false": ios-prepare
#!/usr/bin/env bash
set -euo pipefail
if [ "{{prebuilt}}" != "true" ]; then just build-tauri-dev; fi
export TMPDIR="$(/usr/bin/getconf DARWIN_USER_TEMP_DIR)"
# frontendDist is restated because this override replaces the build table:
# dropping it silently produces an app with an empty assets/ and no
# index.html, which installs and launches to a black screen.
# Release, like every other iOS recipe here. A debug build links a ~240MB
# unoptimised binary, which a real Mac starts fine but Appetize's
# virtualised device does not — the preview launched to a black screen
# while the identical debug build rendered in CI's simulator.
cd tauri/src-tauri && cargo tauri ios build \
--target aarch64-sim --ci --no-sign -v \
--config '{"build":{"beforeBuildCommand":"","frontendDist":"../../dist"}}' \
-- --no-default-features
# iOS: full release — build, upload to App Store Connect/TestFlight, and set
# export compliance, no Xcode UI. Requires APPLE_API_KEY + APPLE_API_ISSUER
# (one-time setup in the script header). Flags: --no-bump --skip-validate --no-wait
ios-release *ARGS:
bash scripts/ios-release.sh {{ARGS}}
# iOS: bump the release numbers for an App Store release (build number, the
# iOS floor in min-native-build.json, and the marketing version if the
# committed one has already shipped) and sync gen/apple metadata. Run it
# through Doppler so it can ask App Store Connect (`doppler run --project
# ios-release --config prd -- just ios-bump`), then commit the result before
# adding the `ios-update` label to a PR with breaking native changes. Flags:
# --no-min (non-breaking App Store release) --build-only (TestFlight iteration)
ios-bump *ARGS:
bun scripts/ios-bump-version.mjs {{ARGS}}
# iOS generated project prep. Keep native bundle metadata in sync with
# tauri.ios.conf.json, then prepare ignored local Swift dependencies.
ios-prepare:
bun scripts/sync-ios-bundle-metadata.mjs
bun scripts/prepare-tauri-ios-api.mjs
# Xcode resolves SwiftPM packages before Tauri's Rust build script can generate
# local plugin Swift dependencies, so prepare the ignored Tauri iOS API first.
ios-prepare-tauri-api:
bun scripts/prepare-tauri-ios-api.mjs
# Tauri build hook (run automatically via beforeDevCommand) — not meant to be run directly
[private]
dev-tauri: ensure-cache-wasm
printf development > tauri/src-tauri/.macro-tauri-env
bun run --bun dev
# iOS prepares WASM before switching to Apple's native compiler and linker.
[private]
dev-tauri-prepared:
printf development > tauri/src-tauri/.macro-tauri-env
bun run --bun dev:server
# List available local service names
local-services:
@sed -n "s/.*'\([a-z][-a-z]*\)':.*/\1/p" src/lib/core/constant/servers.ts | sort -u
# Run the app with local services (defaults to ALL)
# This assumes you have followed the docs/development/running-locally.md instructions
servers := 'ALL'
port := '3000'
local:
PORT='{{port}}' VITE_LOCAL_SERVERS='{{servers}}' bun run --bun dev
local-sync-playground:
VITE_LOCAL_SERVERS='ALL' VITE_SYNC_SERVICE_HOST='sync-service-playground.macroverse.workers.dev' bun run --bun dev
local-dcs:
VITE_LOCAL_SERVERS='cognition-service,cognition-websocket-service' bun run --bun dev
local-dss:
VITE_LOCAL_SERVERS='document-storage-service' bun run --bun dev
local-search: ensure-cache-wasm
VITE_LOCAL_SERVERS='search-service' bun run --bun dev
local-email: ensure-cache-wasm
VITE_LOCAL_SERVERS='email-service' bun run --bun dev
# All app builds need the gitignored wasm pkg (src/lib/graphql-cache/wasm):
# without it the cache worker's dynamic import 404s at runtime and the
# normalized cache silently degrades to network-only.
#
# The two wasm-pack crates do not share artifacts. Build them in parallel
# with distinct CARGO_TARGET_DIR values so they do not serialize on the
# workspace cargo lock. CI still always rebuilds (schema/engine changes can
# alter wasm without a version bump); Namespace `web-ci` sccache makes the
# rustc invocations cheap across deploys.
#
# Vite's chunk-rendering can exceed 6GB as the app grows. Leave headroom
# above that peak; CI builds use the same mid-size runner as preview deploys.
node_heap := "--max-old-space-size=8192"
cache_wasm_target := justfile_directory() / "../../target/cache-wasm"
agent_fold_wasm_target := justfile_directory() / "../../target/agent-fold-wasm"
database_sql_wasm_target := justfile_directory() / "../../target/database-sql-wasm"
pptx_engine_wasm_target := justfile_directory() / "../../target/pptx-engine-wasm"
docx_engine_wasm_target := justfile_directory() / "../../target/docx-engine-wasm"
fig_engine_wasm_target := justfile_directory() / "../../target/fig-engine-wasm"
psd_engine_wasm_target := justfile_directory() / "../../target/psd-engine-wasm"
ai_engine_wasm_target := justfile_directory() / "../../target/ai-engine-wasm"
[parallel]
build-wasm: build-cache-wasm build-agent-fold-wasm build-database-sql-wasm build-pptx-engine-wasm build-docx-engine-wasm build-fig-engine-wasm build-psd-engine-wasm build-ai-engine-wasm
build-dev: build-wasm
MODE=development NODE_ENV=production NODE_OPTIONS="{{node_heap}}" bun run --bun build
bun scripts/cache-wasm/cli.ts package-dist --dist dist
build-staging: build-wasm
MODE=staging NODE_ENV=production NODE_OPTIONS="{{node_heap}}" bun run --bun build
bun scripts/cache-wasm/cli.ts package-dist --dist dist
# Production bundles carry the native build floors checked in at
# min-native-build.json (schema 3 manifest, see scripts/write-bundle-manifest.mjs);
# `just ios-bump` raises the iOS one and `just android-bump` the Android one.
# Explicit MIN_NATIVE_BUILD_* env still wins.
build-prod: build-wasm
#!/usr/bin/env bash
set -euo pipefail
export MIN_NATIVE_BUILD_ANDROID="${MIN_NATIVE_BUILD_ANDROID:-$(bun -e "console.log(require('./min-native-build.json').android)")}"
export MIN_NATIVE_BUILD_IOS="${MIN_NATIVE_BUILD_IOS:-$(bun -e "console.log(require('./min-native-build.json').ios)")}"
MODE=production NODE_ENV=production NODE_OPTIONS="{{node_heap}}" bun run --bun build
bun scripts/cache-wasm/cli.ts package-dist --dist dist
# Tauri build hook (run automatically via beforeBuildCommand) — not meant to be run directly
[private]
build-tauri: build-wasm
printf production > tauri/src-tauri/.macro-tauri-env
MODE=production NODE_ENV=production NODE_OPTIONS="{{node_heap}}" bun run --bun build
bun scripts/cache-wasm/cli.ts package-dist --dist dist
bun scripts/cache-wasm/cli.ts remove-sidecar --dist dist
# As build-tauri, but MODE=development so the bundle talks to dev.macro.com.
# Used by `ios-build-sim`: a PR preview must never be wired to production.
[private]
build-tauri-dev: build-cache-wasm build-agent-fold-wasm
printf development > tauri/src-tauri/.macro-tauri-env
MODE=development NODE_ENV=production NODE_OPTIONS="{{node_heap}}" bun run --bun build
bun scripts/cache-wasm/cli.ts package-dist --dist dist
bun scripts/cache-wasm/cli.ts remove-sidecar --dist dist
# Build the bundle, zip it, and install it at
# tooling/native_app_server/app-archive.zip for the bundle
# updater test server. The server hashes the archive at request time, so no
# checksum wiring is needed.
dist-archive: build-prod
#!/usr/bin/env bash
set -euo pipefail
TARGET="$(cd {{ justfile_directory() }}/../../tooling/native_app_server && pwd)/app-archive.zip"
rm -f "$TARGET"
(cd dist && zip -qr "$TARGET" . -x '*cache_wasm_bg*.wasm.br')
echo "Archive: $TARGET"
bundle-smoke-server *ARGS:
# Local manual OTA smoke server. Example:
# just bundle-smoke-server older --host 0.0.0.0 --port 3001
bun scripts/smoke-bundle-updater-server.ts {{ARGS}}
test-watch:
bunx --bun vitest
# Sign-in, sign-up, and onboarding in Chromium against fake backends (no network).
# Flags pass through to Playwright: `--ui` to watch and step through, `--headed`
# to see the browser. With --ui, closing the onboarding window opens auth's.
# The Linux dev shell points LD_LIBRARY_PATH at Nix libraries, which Playwright's
# system-glibc Chromium can't load; Nix binaries find theirs through RPATH.
test-signup-browser *ARGS:
env -u LD_LIBRARY_PATH bunx playwright test --config src/features/onboarding/browser-test/playwright.config.ts {{ARGS}}
env -u LD_LIBRARY_PATH bunx playwright test --config src/features/auth/browser-test/playwright.config.ts {{ARGS}}
# Menus in every interface language, failing on clipped labels. Same
# LD_LIBRARY_PATH caveat as the sign-up browser tests above.
test-i18n-browser *ARGS:
env -u LD_LIBRARY_PATH bunx playwright test --config src/lib/i18n/browser-test/playwright.config.ts {{ARGS}}
# Database grid layout under remote presence, in Chromium. Same
# LD_LIBRARY_PATH caveat as the sign-up browser tests above.
test-database-browser *ARGS:
env -u LD_LIBRARY_PATH bunx playwright test --config src/features/database/browser-test/playwright.config.ts {{ARGS}}
# Event details placement and guest editors on desktop and phone, in Chromium
# over preview adapters. Same LD_LIBRARY_PATH caveat as the sign-up browser
# tests above.
test-calendar-details-browser *ARGS:
env -u LD_LIBRARY_PATH bunx playwright test --config src/features/calendar-view/browser-test/playwright.config.ts {{ARGS}}
# Optimistic mutations through the real worker/WASM cache in Chromium. Same
# LD_LIBRARY_PATH caveat as the sign-up browser tests above.
test-functional *ARGS:
env -u LD_LIBRARY_PATH bunx playwright test --config tests/functional/playwright.config.ts {{ARGS}}
test-email-rendering:
bun run --cwd ../../packages/email-renderer test
bun run --cwd ../../packages/email-renderer test:browser
test-email-rendering-update:
bun run --cwd ../../packages/email-renderer test:browser --update-snapshots
preview-prod:
MODE=production NODE_ENV=production bun run preview:prod
lint-staged:
bunx --bun biome lint --staged
lint-ci:
bunx --bun biome ci --changed
storybook:
cd src/components/ui && bun run storybook
build-storybook:
cd src/components/ui && bun run build-storybook
java-build:
bun scripts/createBackend.js
csharp-build:
bun scripts/publish-docx-server.js
# Codegen
gen-api *SERVICES:
bun scripts/generate-api-schema.ts {{SERVICES}}
gen-dcs-types:
bun scripts/generate-dcs-types.ts
gen-dcs-types-local:
MODE=local bun scripts/generate-dcs-types.ts
gen-dcs-tools:
bun scripts/generate-dcs-tools.ts
gen-dcs-models:
bun scripts/generate-dcs-models.ts
clean-env:
bun scripts/clean-env.js
fix-lock:
cd {{ justfile_directory() }}/../.. && git fetch origin dev:dev && git checkout dev -- bun.lock && bun i && git add bun.lock
# Analysis
cycles:
bunx --bun biome lint --only=suspicious/noImportCycles
cycles-ci:
bunx --bun biome lint --changed --only=suspicious/noImportCycles
# Build the GraphQL cache wasm module into src/lib/graphql-cache/wasm
# (gitignored). Unconditional — CI app builds must never skip it (schema or
# engine changes alter the wasm without a cache-wasm version bump).
build-cache-wasm:
scripts/cached-wasm-build.sh cache-wasm {{justfile_directory()}}/src/lib/graphql-cache/wasm -- env CARGO_TARGET_DIR="{{cache_wasm_target}}" wasm-pack build {{justfile_directory()}}/../../crates/client/cache-wasm --target web --release --out-dir {{justfile_directory()}}/src/lib/graphql-cache/wasm
# Build the production browser harness served by Vite preview.
build-cache-wasm-browser-production: build-cache-wasm build-cache-wasm-browser-test-hooks
bunx --bun vite build --config src/lib/graphql-cache/worker/browser-test/vite.config.ts
bun scripts/cache-wasm/cli.ts package-dist --dist src/lib/graphql-cache/worker/browser-test/.dist-production
# Build the separate destructive-hook WASM used only by cache recovery tests.
# Its distinct name keeps it outside the one-production-cache-WASM deploy gate.
[private]
build-cache-wasm-browser-test-hooks:
CARGO_TARGET_DIR="{{cache_wasm_target}}" wasm-pack build {{justfile_directory()}}/../../crates/client/cache-wasm \
--target web --release \
--out-name cache_wasm_browser_test_hooks \
--out-dir {{justfile_directory()}}/src/lib/graphql-cache/wasm-browser-test \
--features browser-test-hooks
# Exercise development and production asset URLs, lazy election, MIME,
# fresh-scope startup, DB-ready, first-ready, and linear-memory budgets.
test-cache-wasm-browser:
bunx --bun playwright test --config src/lib/graphql-cache/worker/browser-test/playwright.config.ts --project chromium --project firefox
bunx --bun playwright test --config src/lib/queries/soup/graphql/browser-test/playwright.config.ts --project chromium
bunx --bun playwright test --config src/lib/graphql-cache/worker/browser-test/playwright.production.config.ts --project chromium-production --project firefox-production
# Local profiling build: retain Rust symbols and DWARF source locations so an
# exported Firefox profile can be symbolicated back to Rust files and lines.
# This overwrites the gitignored release wasm package and is intentionally not
# used by application or CI builds.
build-cache-wasm-profile:
CARGO_TARGET_DIR="{{cache_wasm_target}}" wasm-pack build {{justfile_directory()}}/../../crates/client/cache-wasm --target web --profile cache-wasm-profiling --out-dir {{justfile_directory()}}/src/lib/graphql-cache/wasm
# Build the agent-fold wasm module into src/lib/core/agent-fold/wasm
# (gitignored). `--no-default-features` drops the crate's `cli` feature, whose
# tokio/clap do not build for wasm32; the fold itself needs neither.
build-agent-fold-wasm:
scripts/cached-wasm-build.sh agent_fold {{justfile_directory()}}/src/lib/core/agent-fold/wasm -- env CARGO_TARGET_DIR="{{agent_fold_wasm_target}}" wasm-pack build {{justfile_directory()}}/../../crates/folds/agent_fold --target web --release --out-dir {{justfile_directory()}}/src/lib/core/agent-fold/wasm -- --no-default-features
# Dev fast path: build the agent-fold wasm pkg only when it is missing or any
# fold source is newer than the built artifact. A stale artifact folds with the
# wrong wire shape, which renders as chips silently stuck on their last event.
ensure-agent-fold-wasm:
#!/usr/bin/env bash
set -euo pipefail
WASM="{{justfile_directory()}}/src/lib/core/agent-fold/wasm/agent_fold_bg.wasm"
CRATE="{{justfile_directory()}}/../../crates/folds/agent_fold"
if [ ! -f "$WASM" ] || [ -n "$(find "$CRATE/src" "$CRATE/Cargo.toml" -newer "$WASM" -print -quit)" ]; then
just --justfile "{{justfile()}}" build-agent-fold-wasm
fi
# Build the database-sql wasm module (the SQL engine's staged `Query`) into
# src/lib/core/database-sql/wasm (gitignored).
build-database-sql-wasm:
scripts/cached-wasm-build.sh database_sql {{justfile_directory()}}/src/lib/core/database-sql/wasm -- env CARGO_TARGET_DIR="{{database_sql_wasm_target}}" wasm-pack build {{justfile_directory()}}/../../crates/database_sql --target web --release --out-dir {{justfile_directory()}}/src/lib/core/database-sql/wasm
# Dev fast path: build the database-sql wasm pkg only when it is missing or
# any source it is compiled from is newer than the built artifact: the
# engine's own and every workspace crate it depends on (the ops come from
# models_databases), so a changed export is never served stale.
ensure-database-sql-wasm:
#!/usr/bin/env bash
set -euo pipefail
WASM="{{justfile_directory()}}/src/lib/core/database-sql/wasm/database_sql_bg.wasm"
ROOT="{{justfile_directory()}}/../.."
if [ ! -f "$WASM" ]; then
just --justfile "{{justfile()}}" build-database-sql-wasm
exit 0
fi
CRATES=$(cd "$ROOT" && cargo tree -p database_sql --target wasm32-unknown-unknown -e normal --prefix none --format '{p}' | sed -n 's/.*(\(\/[^)]*\)).*/\1/p' | sort -u)
SOURCES=()
for crate in $CRATES; do
SOURCES+=("$crate/Cargo.toml")
[ -d "$crate/src" ] && SOURCES+=("$crate/src")
done
if [ -n "$(find "${SOURCES[@]}" -newer "$WASM" -print -quit)" ]; then
just --justfile "{{justfile()}}" build-database-sql-wasm
fi
# Build the pptx-engine wasm module (PPTX rendering and editing, hosted in a
# worker by the pptx block) into src/lib/core/pptx-engine/wasm (gitignored).
# SIMD speeds up rasterization; every browser the app supports has it.
build-pptx-engine-wasm:
scripts/cached-wasm-build.sh pptx_engine {{justfile_directory()}}/src/lib/core/pptx-engine/wasm -- env CARGO_TARGET_DIR="{{pptx_engine_wasm_target}}" CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUSTFLAGS="-C target-feature=+simd128" wasm-pack build {{justfile_directory()}}/../../crates/pptx_engine --target web --release --out-dir {{justfile_directory()}}/src/lib/core/pptx-engine/wasm
# Dev fast path: build the pptx-engine wasm pkg only when it is missing or any
# engine source is newer than the built artifact.
ensure-pptx-engine-wasm:
#!/usr/bin/env bash
set -euo pipefail
WASM="{{justfile_directory()}}/src/lib/core/pptx-engine/wasm/pptx_engine_bg.wasm"
CRATE="{{justfile_directory()}}/../../crates/pptx_engine"
if [ ! -f "$WASM" ] || [ -n "$(find "$CRATE/src" "$CRATE/fonts" "$CRATE/assets" "$CRATE/Cargo.toml" -newer "$WASM" -print -quit)" ]; then
just --justfile "{{justfile()}}" build-pptx-engine-wasm
fi
# Build the docx-engine wasm module (DOCX layout, rendering and editing, hosted
# in a worker by the write block) into src/lib/core/docx-engine/wasm (gitignored).
build-docx-engine-wasm:
scripts/cached-wasm-build.sh docx_engine {{justfile_directory()}}/src/lib/core/docx-engine/wasm -- env CARGO_TARGET_DIR="{{docx_engine_wasm_target}}" CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUSTFLAGS="-C target-feature=+simd128" wasm-pack build {{justfile_directory()}}/../../crates/docx_engine --target web --release --out-dir {{justfile_directory()}}/src/lib/core/docx-engine/wasm
# Dev fast path: build the docx-engine wasm pkg only when it is missing or any
# engine source (including the pptx engine it builds on) is newer than it.
ensure-docx-engine-wasm:
#!/usr/bin/env bash
set -euo pipefail
WASM="{{justfile_directory()}}/src/lib/core/docx-engine/wasm/docx_engine_bg.wasm"
CRATE="{{justfile_directory()}}/../../crates/docx_engine"
PPTX="{{justfile_directory()}}/../../crates/pptx_engine"
if [ ! -f "$WASM" ] || [ -n "$(find "$CRATE/src" "$CRATE/Cargo.toml" "$PPTX/src" "$PPTX/fonts" "$PPTX/Cargo.toml" -newer "$WASM" -print -quit)" ]; then
just --justfile "{{justfile()}}" build-docx-engine-wasm
fi
# Build the fig-engine wasm module (.fig parsing and tile rasterization, hosted
# in workers by the fig block) into src/lib/core/fig-engine/wasm (gitignored).
build-fig-engine-wasm:
scripts/cached-wasm-build.sh fig_engine {{justfile_directory()}}/src/lib/core/fig-engine/wasm -- env CARGO_TARGET_DIR="{{fig_engine_wasm_target}}" CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUSTFLAGS="-C target-feature=+simd128" wasm-pack build {{justfile_directory()}}/../../crates/fig_engine --target web --profile fig-engine-wasm --out-dir {{justfile_directory()}}/src/lib/core/fig-engine/wasm
# Dev fast path: build the fig-engine wasm pkg only when it is missing or any
# engine source is newer than the built artifact.
ensure-fig-engine-wasm:
#!/usr/bin/env bash
set -euo pipefail
WASM="{{justfile_directory()}}/src/lib/core/fig-engine/wasm/fig_engine_bg.wasm"
CRATE="{{justfile_directory()}}/../../crates/fig_engine"
if [ ! -f "$WASM" ] || [ -n "$(find "$CRATE/src" "$CRATE/Cargo.toml" -newer "$WASM" -print -quit)" ]; then
just --justfile "{{justfile()}}" build-fig-engine-wasm
fi
# Build the psd-engine wasm module (.psd reading, editing, and tile
# compositing, hosted in workers by the psd block) into
# src/lib/core/psd-engine/wasm (gitignored).
build-psd-engine-wasm:
scripts/cached-wasm-build.sh psd_engine {{justfile_directory()}}/src/lib/core/psd-engine/wasm -- env CARGO_TARGET_DIR="{{psd_engine_wasm_target}}" CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUSTFLAGS="-C target-feature=+simd128" wasm-pack build {{justfile_directory()}}/../../crates/psd_engine --target web --profile psd-engine-wasm --out-dir {{justfile_directory()}}/src/lib/core/psd-engine/wasm
# Dev fast path: build the psd-engine wasm pkg only when it is missing or any
# engine source (or the fig engine it draws text with) is newer than it.
ensure-psd-engine-wasm:
#!/usr/bin/env bash
set -euo pipefail
WASM="{{justfile_directory()}}/src/lib/core/psd-engine/wasm/psd_engine_bg.wasm"
CRATE="{{justfile_directory()}}/../../crates/psd_engine"
FIG="{{justfile_directory()}}/../../crates/fig_engine"
if [ ! -f "$WASM" ] || [ -n "$(find "$CRATE/src" "$CRATE/Cargo.toml" "$FIG/src" "$FIG/Cargo.toml" -newer "$WASM" -print -quit)" ]; then
just --justfile "{{justfile()}}" build-psd-engine-wasm
fi
# Build the ai-engine wasm module (.ai/PDF reading, editing, and tile
# rendering, hosted in workers by the ai block) into
# src/lib/core/ai-engine/wasm (gitignored).
build-ai-engine-wasm:
scripts/cached-wasm-build.sh ai_engine {{justfile_directory()}}/src/lib/core/ai-engine/wasm -- env CARGO_TARGET_DIR="{{ai_engine_wasm_target}}" CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUSTFLAGS="-C target-feature=+simd128" wasm-pack build {{justfile_directory()}}/../../crates/ai_engine --target web --profile ai-engine-wasm --out-dir {{justfile_directory()}}/src/lib/core/ai-engine/wasm
# Dev fast path: build the ai-engine wasm pkg only when it is missing or any
# engine source (or the fig engine it draws text with) is newer than it.
ensure-ai-engine-wasm:
#!/usr/bin/env bash
set -euo pipefail
WASM="{{justfile_directory()}}/src/lib/core/ai-engine/wasm/ai_engine_bg.wasm"
CRATE="{{justfile_directory()}}/../../crates/ai_engine"
FIG="{{justfile_directory()}}/../../crates/fig_engine"
if [ ! -f "$WASM" ] || [ -n "$(find "$CRATE/src" "$CRATE/Cargo.toml" "$FIG/src" "$FIG/Cargo.toml" -newer "$WASM" -print -quit)" ]; then
just --justfile "{{justfile()}}" build-ai-engine-wasm
fi
# Regenerate src/lib/service-clients/service-agent-fold/generated/types.ts (and
# the SDK's packages/sdk/generated/agent-fold/index.ts)
# from agent_fold's Rust wire types with specta. Run after changing anything
# under crates/folds/agent_fold/src/inbound/wire.rs. Specta's own output is tabs and
# commas, not this project's style, so biome reformats it in place - without
# that, every regeneration would be a diff-format mismatch even with no real
# change.
gen-agent-fold-types:
if [ -n "${SPECTA_BIN_DIR:-}" ]; then "$SPECTA_BIN_DIR/agent_fold_types"; else cargo run -p agent_fold --bin agent_fold_types; fi
bunx biome format --write {{justfile_directory()}}/src/lib/service-clients/service-agent-fold/generated/types.ts
# Regenerate src/lib/service-clients/service-agent-reviews/generated/types.ts
# (and the SDK's packages/sdk/generated/agent-reviews/index.ts) from
# agent_code_mode's review types with specta. Run after changing a review type
# or a type a review draft or result reuses (SendEmail, CreateCalendarEvent,
# their responses, the import report); biome reformats specta's output for the
# same reason as gen-agent-fold-types.
gen-agent-review-types:
if [ -n "${SPECTA_BIN_DIR:-}" ]; then "$SPECTA_BIN_DIR/export_review_types"; else SQLX_OFFLINE=true cargo run -p agent_code_mode --bin export_review_types; fi
bunx biome format --write {{justfile_directory()}}/src/lib/service-clients/service-agent-reviews/generated/types.ts
# Regenerate the dynamic-UI view types (src/features/dynamic-ui/generated/types.ts
# and lexical-core's copy) from `crates/dynamic_ui` with specta. Run after
# changing a widget; biome reformats specta's output as in gen-agent-fold-types.
gen-dynamic-ui-types:
cargo run -p dynamic_ui --features cli --bin export_view_types
bunx biome format --write {{justfile_directory()}}/src/features/dynamic-ui/generated/types.ts {{justfile_directory()}}/../../packages/lexical-core/generated/dynamic-ui.ts
# Regenerate src/lib/core/database-sql/generated/types.ts from the
# database_sql engine's wire types with specta. Run after changing any type
# that crosses the wasm boundary (see crates/database_sql/src/wasm.rs); biome
# reformats specta's output for the same reason as gen-agent-fold-types.
gen-database-sql-types:
cargo run -p database_sql --features cli --bin database_sql_types
bunx biome format --write {{justfile_directory()}}/src/lib/core/database-sql/generated/types.ts
# Dev fast path: build the wasm pkg only when missing or its version drifts
# from client/cache-wasm/Cargo.toml (bump that version to push a rebuild to
# dev machines). See tooling/xtask/crates/xtask_cache_wasm/src/main.rs.
ensure-cache-wasm:
cd {{justfile_directory()}}/../.. && SQLX_OFFLINE=true cargo run -q -p xtask -- cache-wasm