Skip to content

Dispatch Scripts

Ankit Jha edited this page May 29, 2026 · 1 revision

Dispatch Scripts

All execution scripts live in dispatch/. Together they form the backbone of Hydra's routing, editing, reviewing, and cost-tracking.


hydra.sh — Developer CLI

Single entry point for developer commands.

./dispatch/hydra.sh status
./dispatch/hydra.sh list
./dispatch/hydra.sh do SIMPLE "write a User DTO"
./dispatch/hydra.sh duck "$(cat src/auth.ts)"
./dispatch/hydra.sh set-pct 52

route.sh — Core Router

Resolves enum keys to model tiers, handles fallbacks, skips exhausted pools. Writes cost records to logs/cost.jsonl. See Routing Protocol.

agy.sh — Antigravity Wrapper

Wraps agy --print to target a specific model by swapping the model in ~/.gemini/antigravity-cli/settings.json, restoring it on exit. Parses stderr for browser auth URLs.

ollama.sh — Local LLM Wrapper

Executes prompts against local Ollama (Qwen2.5-Coder by default). Checks daemon health, starts it if needed. Extracts token counts from the JSON response.

scope.sh — Workspace Validator

Guards workspace directory permissions before any write. Checks allowed_globs/denied_globs from registry/workspace.yaml.

dispatch/scope.sh /absolute/path/to/file.ts
# exits 0 if allowed, exits 1 if denied

decide.sh — Policy Evaluator

Reads registry/policy.yaml and evaluates rules against a task spec to output execution flags for edit.sh:

{ "edit_mode": "sr-blocks", "retry_limit": 3 }

Files over 400 lines get sr-blocks (search-replace diffs) instead of full rewrite.

edit.sh — Atomic File Writer

Applies model-generated edits atomically with backup and rollback.

  • Creates .hydra-bak snapshot
  • Applies edit (full rewrite or search-replace blocks)
  • Runs file validator (node --check, bash -n, etc.)
  • If validation fails → rolls back from .hydra-bak

review.sh — Git Review Harness

dispatch/review.sh summary   # JSON list of modified files
dispatch/review.sh diff      # unified diff
dispatch/review.sh approve   # stage changes, remove backups
dispatch/review.sh reject    # rollback all changes
dispatch/review.sh qa        # dispatch diff to a QA tier

parallel.sh — Concurrent Fan-out

Fans out multiple independent tasks as background jobs, aggregates results into a unified JSON array. Saves to logs/last_parallel.json.

dispatch/parallel.sh '[
  {"enum": "SIMPLE", "prompt": "write UserDTO", "file": "src/user.dto.ts"},
  {"enum": "SIMPLE", "prompt": "write PostDTO", "file": "src/post.dto.ts"}
]'

company.sh — Playbook Runner

Executes multi-stage playbooks from registry/playbooks.yaml.

dispatch/company.sh start refactor-sweep
dispatch/company.sh next
dispatch/company.sh status

repo-map.sh — Symbol Extractor

Scans workspace directories and builds compressed code signature maps for injection into model prompts. Supports TS, JS, Rust, Go, Python, Shell.

dispatch/repo-map.sh src/

cost.sh — Spend Analyzer

dispatch/cost.sh by-tier
dispatch/cost.sh by-day
dispatch/cost.sh by-run