This repo now has two layers:
primary_compute.py: step-by-step heavy compute offload with 6 cores / 14 GiB and daily budget tracking.modal_tasks.py+ shell shims: offload as many CLI commands as possible to Modal.
make setup
make authprimary_compute.py defines:
heavy_task(payload)running in Modal with:cpu=6memory=14 * 1024MiB
do_heavy_stuff(payload)as the expensive CPU logic
The function resource config is pinned by:
CPU_CORES = 6
MEMORY_MB = 14 * 1024Local state file:
~/.primary_compute_modal_usage.json
Tracked values:
day(YYYY-MM-DD)used_min(Modal runtime minutes measured locally)
Default budget:
MAX_MIN_PER_DAY = 180(3 hours/day)
Override with env var:
export PRIMARY_MODAL_MAX_MIN_PER_DAY=120Auto mode (recommended): Modal until daily budget is reached.
make heavy PAYLOAD='{"iterations":24000000,"workers":6}'Force Modal:
make heavy-modal PAYLOAD='{"iterations":24000000,"workers":6}'Force local:
make heavy-local PAYLOAD='{"iterations":24000000,"workers":6}'Show tracked usage:
make usage-showReset tracked usage:
make usage-resetiterations: total compute loop countworkers: parallel worker processes (6recommended for this setup)salt: checksum variation integer
Example:
make heavy PAYLOAD='{"iterations":30000000,"workers":6,"salt":23}'- This offloads CPU-heavy tasks well (backtests, pipelines, heavy notebook cells).
- macOS UI apps (Safari, Finder, TradingView, TWS UI) still run locally by design.
- Keep expensive logic inside
do_heavy_stuff(...)and always call viarun_heavy(...).
Run directly through the command gateway:
./scripts/modal_exec.sh -- <command> [args...]
./scripts/modal_exec.sh -c "<shell command>"Examples:
./scripts/modal_exec.sh -- rg "TODO" .
./scripts/modal_exec.sh -- python -m pytest -q
./scripts/modal_exec.sh --no-sync-back -- cat README.mdEnable strict auto-routing shims:
./scripts/install_modal_shims.sh
source ./scripts/activate_modal_only.shAfter activation, most executable commands are automatically forwarded to Modal.
Expected local-only exceptions are GUI/UI apps, shell builtins, git, and Modal control-plane commands.
Install a global terminal runner once:
make agent-runner-installThis creates:
$HOME/.local/bin/modal-agent-runnerPoint each agent's terminal tool/command runner to that binary.
It forwards terminal commands to scripts/modal_exec.sh, so command execution is Modal-backed.
Model chat/inference stays on the agent provider side; this enforces terminal command execution only.
Command templates:
$HOME/.local/bin/modal-agent-runner -c "<raw command string>"
$HOME/.local/bin/modal-agent-runner -- <binary> <args...>Quick verification:
make agent-runner-checkRemote-only mode (no local repo clone):
# created by make agent-runner-install
cat ~/.config/modal-agent-runner/config.env
# ensure Modal has github-token secret
/usr/bin/python3 -m modal secret create github-token GITHUB_TOKEN="$(gh auth token)" --force
# run from anywhere (for example /tmp)
cd /tmp
$HOME/.local/bin/modal-agent-runner -c "hostname && pwd"In remote-only mode, the runner clones MODAL_REMOTE_REPO_URL inside Modal and executes there.
Canonical policy file:
ANTIGRAVITY.mdInstall workspace + Antigravity user-level policy wiring:
make antigravity-policy-installThis installs:
- workspace
AGENTS.mdmirror fromANTIGRAVITY.md - workspace
.clinerulesmirror fromANTIGRAVITY.mdfor Cline - workspace
.rules/antigravity.rulesand.rules/codex.rulesfor Codex - workspace
.vscode/settings.jsonupdate forgeminicodeassist.rulesandgeminicodeassist.agentYoloMode=false - workspace Gemini hard-routing files:
.gemini/bin/bash(wrapsbash -c ...tomodal-agent-runner).gemini/.env(prepends.gemini/bintoPATH, setsGEMINI_YOLO_MODE=false)
- user files (when run outside Modal):
~/Library/Application Support/Antigravity/User/ANTIGRAVITY.md~/Library/Application Support/Antigravity/User/AGENTS.md(symlink)~/Library/Application Support/Antigravity/User/CLAUDE.md(symlink)
- Antigravity settings updates for Kilo/Roo/Claude plus Gemini rules and
geminicodeassist.agentYoloMode=false
Check policy + routing:
make antigravity-policy-checkSome agents execute commands in non-interactive zsh without sourcing repo scripts.
Install repo-scoped shell bootstrap once:
make shell-bootstrapThis writes guarded blocks to ~/.zshenv, ~/.zprofile, ~/.zshrc, ~/.bashrc, and ~/.profile so sessions that start in this repo automatically prepend .modal-shims.
For zsh, it also wraps common absolute binary paths (for example /bin/ls and /usr/bin/python3) to force Modal routing.
Run a verification for shell-level auto-routing:
make doctor