The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
chore(dep-audit): add initial audit scripts and configuration
Steven Enamakelc841338afad1
diff --git a/scripts/dep-audit/run.sh b/scripts/dep-audit/run.shnew file mode 100755index 0000000000..1c5ea61f95--- /dev/null+++ b/scripts/dep-audit/run.sh@@ -0,0 +1,156 @@+#!/usr/bin/env bash+# Dependency audit across OpenHuman and every Cargo submodule under vendor/.+#+# Runs `tinyanalyzer` (https://github.com/tinyhumansai/tinyanalyzer) once per+# Cargo root — the root workspace, the out-of-workspace `crates/openhuman-app`+# host, and every recursive git submodule that has a Cargo.toml — then folds the+# per-target JSON reports into a single Markdown report listing:+#+# * declared dependencies no source file names (candidates to delete)+# * crates resolved at more than one version (candidates to unify)+# * the direct dependencies with the largest exclusive transitive footprint+# * direct dependencies whose resolved version drifts between repositories+#+# Usage:+# scripts/dep-audit/run.sh [--out <dir>] [--top <n>] [--targets <regex>]+# [--keep-nested] [--no-report] [--verbose]+#+# --out <dir> Where JSON reports and REPORT.md land.+# Default: target/dep-audit (gitignored).+# --top <n> How many heavy direct dependencies to list per target (default 15).+# --targets <re> Only analyze targets whose name matches this regex+# (e.g. --targets '^(root|tinyagents)$').+# --keep-nested Also analyze nested submodule checkouts that are pinned at+# the same commit as a top-level one (skipped by default —+# they are the same code and produce the same report).+# --no-report Only write the JSON reports; skip REPORT.md.+# --verbose Echo each tinyanalyzer invocation.+#+# Requires: tinyanalyzer on PATH, node >= 20, git, jq (optional, for --verbose sizes).+# See scripts/dep-audit/README.md for how to read the report and what to do next.+set -euo pipefail++ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"+cd "$ROOT"++OUT_DIR="$ROOT/target/dep-audit"+TOP=15+TARGET_RE=""+KEEP_NESTED=0+WRITE_REPORT=1+VERBOSE=0++while [[ $# -gt 0 ]]; do+ case "$1" in+ --out) OUT_DIR="$2"; shift 2 ;;+ --top) TOP="$2"; shift 2 ;;+ --targets) TARGET_RE="$2"; shift 2 ;;+ --keep-nested) KEEP_NESTED=1; shift ;;+ --no-report) WRITE_REPORT=0; shift ;;+ --verbose) VERBOSE=1; shift ;;+ -h|--help) sed -n '2,30p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; exit 0 ;;+ *) echo "dep-audit: unknown argument: $1" >&2; exit 2 ;;+ esac+done++if ! command -v tinyanalyzer >/dev/null 2>&1; then+ cat >&2 <<'MSG'+dep-audit: `tinyanalyzer` is not on PATH.++Install it with:+ curl --proto '=https' --tlsv1.2 -LsSf \+ https://raw.githubusercontent.com/tinyhumansai/tinyanalyzer/main/install.sh | sh+or, from a checkout of tinyhumansai/tinyanalyzer:+ cargo install --path crates/tinyanalyzer+MSG+ exit 1+fi++CONFIG="$ROOT/scripts/dep-audit/tinyanalyzer.toml"+mkdir -p "$OUT_DIR"+case "$OUT_DIR" in /*) ;; *) OUT_DIR="$ROOT/$OUT_DIR" ;; esac++# ---------------------------------------------------------------------------+# Target discovery.+#+# Each line: <name>\t<relative path>\t<commit>\t<remote url>+# `root` is the OpenHuman workspace itself; `openhuman-app` is the Tauri host+# crate, which `Cargo.toml` excludes from the workspace and so has its own+# lockfile and dependency graph. Every recursive submodule with a Cargo.toml is+# a target named after its directory. Nested copies (vendor/x/vendor/tinybus)+# are dropped when a top-level checkout is pinned at the same commit.+# ---------------------------------------------------------------------------+TARGETS_TSV="$OUT_DIR/targets.tsv"+: > "$TARGETS_TSV"++root_sha="$(git rev-parse HEAD)"+root_remote="$(git remote get-url upstream 2>/dev/null || git remote get-url origin 2>/dev/null || echo '')"+printf 'root\t.\t%s\t%s\n' "$root_sha" "$root_remote" >> "$TARGETS_TSV"+if [[ -f crates/openhuman-app/Cargo.toml ]]; then+ printf 'openhuman-app\tcrates/openhuman-app\t%s\t%s\n' "$root_sha" "$root_remote" >> "$TARGETS_TSV"+fi++declare -A seen_by_repo_sha=()+skipped_nested=()+while read -r sha path _; do+ sha="${sha#[-+U]}"+ [[ -f "$path/Cargo.toml" ]] || continue+ name="$(basename "$path")"+ remote="$(git -C "$path" remote get-url origin 2>/dev/null || echo '')"+ key="$name@$sha"+ depth="$(awk -F/ '{print NF}' <<<"$path")"+ if [[ -n "${seen_by_repo_sha[$key]:-}" && $KEEP_NESTED -eq 0 ]]; then+ skipped_nested+=("$path (same as ${seen_by_repo_sha[$key]})")+ continue+ fi+ # Prefer the shallowest checkout as the canonical name; deeper copies pinned+ # at a *different* commit get a path-derived suffix so both show up.+ if [[ -n "${seen_by_repo_sha[$name]:-}" ]]; then+ name="$name@$(sed 's#/#_#g' <<<"$path")"+ fi+ seen_by_repo_sha[$key]="$path"+ seen_by_repo_sha[$name]="$path"+ printf '%s\t%s\t%s\t%s\n' "$name" "$path" "$sha" "$remote" >> "$TARGETS_TSV"+done < <(git submodule status --recursive | sort -k2,2 | awk '{ print $1, $2 }' | awk '{ n=split($2,p,"/"); print n, $0 }' | sort -n | cut -d' ' -f2-)++# ---------------------------------------------------------------------------+# Analysis.+# ---------------------------------------------------------------------------+analyzed=0+failed=()+while IFS=$'\t' read -r name path sha remote; do+ if [[ -n "$TARGET_RE" ]] && ! [[ "$name" =~ $TARGET_RE ]]; then+ continue+ fi+ json="$OUT_DIR/$name.json"+ log="$OUT_DIR/$name.log"+ [[ $VERBOSE -eq 1 ]] && echo "dep-audit: tinyanalyzer $path -> $json"+ # --no-dead-code and --hide-tests keep the run cheap; the dependency graph is+ # what we are after and it does not depend on either.+ if tinyanalyzer "$path" --config "$CONFIG" --output json --no-dead-code --hide-tests \+ --write "$json" >"$log" 2>&1; then+ analyzed=$((analyzed + 1))+ printf 'dep-audit: %-28s ok\n' "$name"+ else+ failed+=("$name")+ printf 'dep-audit: %-28s FAILED (see %s)\n' "$name" "$log" >&2+ rm -f "$json"+ fi+done < "$TARGETS_TSV"++echo "dep-audit: analyzed $analyzed target(s) into $OUT_DIR"+if ((${#skipped_nested[@]})); then+ echo "dep-audit: skipped ${#skipped_nested[@]} nested checkout(s) pinned at an already-analyzed commit (--keep-nested to include):"+ printf ' %s\n' "${skipped_nested[@]}"+fi+if ((${#failed[@]})); then+ echo "dep-audit: ${#failed[@]} target(s) failed: ${failed[*]}" >&2+fi++if [[ $WRITE_REPORT -eq 1 ]]; then+ node "$ROOT/scripts/dep-audit/report.mjs" --reports "$OUT_DIR" --top "$TOP" \+ --tinyanalyzer-version "$(tinyanalyzer --version)" --out "$OUT_DIR/REPORT.md"+ echo "dep-audit: report written to $OUT_DIR/REPORT.md"+fi++((${#failed[@]} == 0))diff --git a/scripts/dep-audit/tinyanalyzer.toml b/scripts/dep-audit/tinyanalyzer.tomlnew file mode 100644index 0000000000..11e91eb941--- /dev/null+++ b/scripts/dep-audit/tinyanalyzer.toml@@ -0,0 +1,27 @@+# Shared tinyanalyzer configuration for scripts/dep-audit/run.sh.+#+# It is passed with `--config` to every target so the sweep behaves the same in+# the root workspace and in each vendored submodule regardless of whether that+# repository ships its own tinyanalyzer.toml. Only dependency-related settings+# matter here; file/complexity findings are ignored by the report.++[scan]+# Submodule checkouts inside a target are separate targets of their own.+exclude = ["vendor/**", "worktrees/**", "target/**", "node_modules/**"]++[dependencies]+# Also charge test/benchmark-only dependencies so the heavy-dependency table+# reflects what CI actually compiles.+include_dev = true++# Crates that are reached exclusively through `#[derive(...)]` / attribute+# macros and so never appear in a `use` or path. tinyanalyzer's unused check is+# textual ("no source file names the crate"), so these are near-certain false+# positives. Keep the list short and justified: every entry hides a real+# finding for that crate everywhere.+ignore_unused = [+ # `#[derive(Error)]` + `#[error("...")]` when imported via `use thiserror::Error`+ # is *named*; only fully qualified `#[derive(thiserror::Error)]` is not, and+ # the codebase mixes both, so hide the noise.+ "thiserror",+]