Something went wrong. Try again.
An agentic programming framework for people that don't trust an AI agent
Something went wrong. Try again.
3.9 kB · 115 lines
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116#!/usr/bin/env bash# det-gate — the deterministic gate (phase 5). Runs the cheap, ungameable checks# (lint, format, typecheck, tests) BEFORE any LLM reviewer is spawned, because# they catch the bulk of issues for free.## Auto-detects the stack. Runs every check that applies, collects failures, and# exits non-zero if ANY failed. Customize per-project by creating an executable# `.skepticism/det-gate.sh` at the repo root — if present, it is run instead.## One check is NOT overridable: leak-check runs first, before the project hook,# because Iron Rule 6 (leave no trace) must not be switchable off by a config# file the user forgot they wrote.## Usage: det-gate [base-ref] (run from the project repo root)# base-ref, when given, is forwarded to leak-check so it can also scan the# commit messages in base..HEAD.set -uo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"LEAK_CHECK="${SCRIPT_DIR}/leak-check"base="${1:-}"
# Transparency gate (not overridable) ----------------------------------------if [[ -x "$LEAK_CHECK" ]]; then if ! "$LEAK_CHECK" ${base:+"$base"}; then echo echo "════════════════════════════════════════════" echo "det-gate: FAILED → leak-check" exit 1 fi echofi
# Project override hook ------------------------------------------------------if [[ -x ".skepticism/det-gate.sh" ]]; then exec ./.skepticism/det-gate.shfi
failures=()ran_any=0
run() { local label="$1"; shift ran_any=1 echo "──► ${label}: $*" if "$@"; then echo " ✓ ${label} passed" else echo " ✗ ${label} FAILED" failures+=("$label") fi echo}
have() { command -v "$1" >/dev/null 2>&1; }
# Pick the JS package manager if this is a Node project.js_pm() { if [[ -f pnpm-lock.yaml ]] && have pnpm; then echo pnpm elif [[ -f yarn.lock ]] && have yarn; then echo yarn elif have npm; then echo npm fi}# Run an npm script only if it is defined in package.json.js_script() { # <pm> <script> local pm="$1" script="$2" node -e "process.exit(require('./package.json').scripts?.['$script']?0:1)" 2>/dev/null \ && run "$script" "$pm" run "$script"}
# --- Node / TypeScript ------------------------------------------------------if [[ -f package.json ]]; then pm="$(js_pm)" if [[ -n "${pm:-}" ]]; then js_script "$pm" lint js_script "$pm" format:check js_script "$pm" typecheck js_script "$pm" test fifi
# --- Python -----------------------------------------------------------------if [[ -f pyproject.toml || -f setup.cfg || -n "$(ls -1 *.py 2>/dev/null)" ]]; then have ruff && run "ruff" ruff check . have ruff && run "ruff-format" ruff format --check . have mypy && run "mypy" mypy . have pytest && run "pytest" pytest -qfi
# --- Rust -------------------------------------------------------------------if [[ -f Cargo.toml ]] && have cargo; then run "cargo-fmt" cargo fmt --check run "cargo-clippy" cargo clippy -- -D warnings run "cargo-test" cargo testfi
# --- Go ---------------------------------------------------------------------if [[ -f go.mod ]] && have go; then run "gofmt" bash -c '[[ -z "$(gofmt -l .)" ]]' run "go-vet" go vet ./... run "go-test" go test ./...fi
# --- Verdict ----------------------------------------------------------------echo "════════════════════════════════════════════"if [[ "$ran_any" -eq 0 ]]; then echo "det-gate: no known checks detected for this project." echo "Add an executable .skepticism/det-gate.sh to define your own." exit 0fiif [[ "${#failures[@]}" -gt 0 ]]; then echo "det-gate: FAILED → ${failures[*]}" exit 1fiecho "det-gate: all checks passed ✓"