The pipeline is a collection of small, single-purpose scripts under scripts/. Each one owns a narrow job — a phase transition, a model invocation, a state write — and the orchestrator wires them together. This page catalogs the ones you will reach for most often, grouped by function.
Source of truth
This page summarizes the catalog for public reference. The authoritative, always-current version lives in the private repo at docs/scripts-reference.md. For the complete list, run ls scripts/.
Pipeline core
Script
What it does
orchestrate.sh
Handles phase transitions and global pipeline state. Writes to state/STATE.json (active phase, active agent, locks). Invoked by every phase command. Not to be confused with the per-issue state/pipeline/<issue>.json.
run.js
Secure proxy for executing bash scripts inside the Claude Code sandbox. Fixes the fd mismatch on Windows/WSL by spawning bash with correct pipes, and kills stalled scripts after JKZ_STALL_TIMEOUT_MS. Always prefer this over bash script.sh.
json-helper.js
Reads and writes per-issue state fields (state/pipeline/<issue>.json) without racing on concurrent writes.
worktree.sh
Creates, manages, and cleans up the per-issue Git worktree (../jkz-worktree-<issue>), isolated from the main repo. Tracks stages via .jkz-checkpoint.
Entry point for invoking any external agent. Cascade: JKZ_<ROLE>_ENDPOINT → api-wrapper.sh, then JKZ_API_ENDPOINT → api-wrapper.sh, then the native model CLI.
codex-wrapper.sh
Wrapper for the Codex CLI. Per-role session memory, Accumulated Patterns extraction, 5-minute stall detection, rate-limit retry with exit 75.
gemini-wrapper.sh
Wrapper for the Gemini CLI. Streaming JSONL, multi-format parsing, exponential rate-limit retry, format fallback.
api-wrapper.sh
Wrapper for OpenAI-compatible endpoints. Used when JKZ_<ROLE>_ENDPOINT or JKZ_API_ENDPOINT are set.
resolve-provider-fallback.sh
Resolves the fallback provider when a wrapper exits 75 (rate limit). Defaults: auditor/lens → sonnet; curator/inspector/judge/sentinel → opus.
parse-gemini-stream.js
Normalizes Gemini CLI output to a unified {response, session_id, tokens, format} shape. Used internally by gemini-wrapper.sh.
Validators
Script
What it does
scripts/validators/run.js
Pre-validated checks runner. Receives the diff via stdin, returns { checks, skipped }. Output is injected as === PRE-VALIDATED CHECKS === into Judge and Sentinel prompts. Full reference → Validators.
scripts/validators/config.json
Rule configuration: enabled, severity (fail/warn), type (diff-safe/worktree-required). Toggle rules without touching code.
Infrastructure and monitoring
Script
What it does
health-check.sh
Full system health check: CLI versions, auth, MCP servers, tests, npm audit, stale worktrees, service status. --fix updates outdated CLIs; --deep adds auth, MCP, and notifications.
circuit-breaker.js
Protects the pipeline from downed services. States: closed → open (after 3 consecutive failures) → half_open → closed. State in state/circuit/<service>.json.
telegram-bot.js
Monitoring and remote-control bot: 11 health checks every 10 min, task discovery every 30 min, inline commands. Requires JKZ_NOTIFY_BACKEND=telegram.
monitoring-checks.js
The 9 async checks behind the monitoring loop (agent idle, CI status, stale worktrees, rate limits, SLO compliance, groupthink, and more).
slo-check.js
Evaluates pipelines against the 4 SLOs in scripts/slos.json over a 30-day window.
Pipeline utilities
Script
What it does
loop-guard.js
Detects duplicate Doctor fix attempts via SHA256 (exact) and Jaccard similarity (≥80% near-duplicate). Advisory — injects a warning, does not block.
resume-diagnose.js
Diagnoses pipeline interruptions (crash, fail, blocked, running, stopped, completed) and determines the resume point. Releases expired locks.
postmortem-generate.js
Generates a postmortem when the pipeline reaches jkz:blocked: event timeline, failure patterns, 5-whys template.
pipeline-cost-report.js
Builds a cost table by phase/role/iteration from tokens._runs[] in pipeline state, priced via scripts/pricing.json.
pipeline-notify.sh
Sends phase-transition notifications. Respects JKZ_NOTIFY_FORCE_DISABLE=1 for tests.
step-gate.js
DAG of dependencies between pipeline steps. Commands call begin/complete to track progress and guard crash recovery.