#!/usr/bin/env bash set -euo pipefail ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" failures=0 warnings=0 ok() { printf "ok: %s\n" "$1" } warn() { warnings=$((warnings + 1)) printf "warn: %s\n" "$1" } fail() { failures=$((failures + 1)) printf "fail: %s\n" "$1" } check_cmd() { local cmd="$1" if command -v "$cmd" >/dev/null 2>&1; then ok "found command: $cmd" else fail "missing required command: $cmd" fi } check_optional_cmd() { local cmd="$1" local reason="$2" if command -v "$cmd" >/dev/null 2>&1; then ok "found optional command: $cmd" else warn "missing optional command: $cmd ($reason)" fi } check_file() { local path="$1" if [ -e "$ROOT_DIR/$path" ]; then ok "found file: $path" else fail "missing required file: $path" fi } check_absent() { local path="$1" local reason="$2" if [ -e "$ROOT_DIR/$path" ]; then fail "unexpected file: $path ($reason)" else ok "absent as expected: $path" fi } main() { cd "$ROOT_DIR" check_file README.md check_file rules.md check_file project_context.md check_file agents.md check_file AGENTS.md check_file CODEMAP.md check_file docs/HARNESS.md check_file docs/harness-audit.md check_file docs/documentation-coverage-rules.md check_file planet.sh check_file pyproject.toml check_file frontend/package.json check_file .gitea/workflows/ci.yaml check_cmd git check_cmd zsh check_cmd uv check_cmd bun check_optional_cmd docker "needed for local stack and optional image smoke builds" check_optional_cmd helm "needed for optional Helm delivery smoke checks" check_absent frontend/package-lock.json "frontend package management is Bun-only" check_absent frontend/pnpm-lock.yaml "frontend package management is Bun-only" check_absent frontend/yarn.lock "frontend package management is Bun-only" if [ ! -x "$ROOT_DIR/planet.sh" ]; then warn "planet.sh is not executable; run it with zsh or restore executable bit" else ok "planet.sh is executable" fi if [ "$failures" -gt 0 ]; then printf "harness doctor failed: %d failure(s), %d warning(s)\n" "$failures" "$warnings" exit 1 fi printf "harness doctor passed: %d warning(s)\n" "$warnings" } main "$@"