improved tools for ai

This commit is contained in:
2026-04-15 16:36:21 -06:00
parent 4f90750497
commit d11e26cf2d
25 changed files with 2618 additions and 33 deletions

72
scripts/collect-diagnostics.sh Executable file
View File

@ -0,0 +1,72 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
OUT_BASE="$ROOT_DIR/.diagnostics"
TS="$(date +%Y%m%d_%H%M%S)"
OUT_DIR="$OUT_BASE/diag_$TS"
mkdir -p "$OUT_DIR"
log() {
printf '[collect-diagnostics] %s\n' "$1"
}
capture_cmd() {
local name="$1"
shift
{
echo "# $name"
echo "# cmd: $*"
"$@"
} >"$OUT_DIR/$name.txt" 2>&1 || true
}
log "output: $OUT_DIR"
capture_cmd "env_uname" uname -a
capture_cmd "env_node_version" node --version
capture_cmd "env_npm_version" npm --version
capture_cmd "env_git_status" git -C "$ROOT_DIR" status --short
capture_cmd "env_git_head" git -C "$ROOT_DIR" rev-parse --short HEAD
if [[ -f "$ROOT_DIR/webview.log" ]]; then
cp "$ROOT_DIR/webview.log" "$OUT_DIR/webview.log" || true
fi
if [[ -f "$ROOT_DIR/backend.log" ]]; then
cp "$ROOT_DIR/backend.log" "$OUT_DIR/backend.log" || true
fi
if [[ -f "$ROOT_DIR/frontend/package.json" ]]; then
capture_cmd "frontend_lint" bash -lc "cd '$ROOT_DIR/frontend' && npm run -s lint"
capture_cmd "frontend_build" bash -lc "cd '$ROOT_DIR/frontend' && npm run -s build"
fi
PY=""
for p in \
"$ROOT_DIR/.venv312/bin/python3.12" \
"$ROOT_DIR/.venv312/bin/python" \
"$ROOT_DIR/.venv/bin/python3" \
"$ROOT_DIR/.venv/bin/python" \
"$ROOT_DIR/venv/bin/python3" \
"$ROOT_DIR/venv/bin/python"; do
if [[ -x "$p" ]]; then
PY="$p"
break
fi
done
if [[ -n "$PY" ]]; then
capture_cmd "backend_python_version" "$PY" --version
capture_cmd "backend_health_check" "$PY" -c "import importlib; importlib.import_module('backend.main'); print('backend import OK')"
fi
capture_cmd "list_recent_files" find "$ROOT_DIR" -maxdepth 2 -type f | head -n 200
if command -v tar >/dev/null 2>&1; then
tar -czf "$OUT_DIR.tar.gz" -C "$OUT_BASE" "diag_$TS"
log "archive: $OUT_DIR.tar.gz"
fi
log "done"

93
scripts/validate-all.sh Executable file
View File

@ -0,0 +1,93 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
log() {
printf '[validate-all] %s\n' "$1"
}
run_if_present() {
local cmd="$1"
if command -v ${cmd%% *} >/dev/null 2>&1; then
eval "$cmd"
return 0
fi
return 1
}
log "root: $ROOT_DIR"
cd "$ROOT_DIR"
log "Step 1/5: frontend dependency check"
if [[ ! -d "frontend/node_modules" ]]; then
log "frontend/node_modules missing; install with: cd frontend && npm install"
fi
log "Step 2/5: frontend lint"
if [[ -f "frontend/package.json" ]]; then
(
cd frontend
if npm run -s lint; then
log "frontend lint: OK"
else
log "frontend lint failed"
exit 1
fi
)
else
log "frontend/package.json not found; skipping"
fi
log "Step 3/5: frontend build"
if [[ -f "frontend/package.json" ]]; then
(
cd frontend
if npm run -s build; then
log "frontend build: OK"
else
log "frontend build failed"
exit 1
fi
)
fi
log "Step 4/5: backend syntax check"
PY=""
for p in \
"$ROOT_DIR/.venv312/bin/python3.12" \
"$ROOT_DIR/.venv312/bin/python" \
"$ROOT_DIR/.venv/bin/python3" \
"$ROOT_DIR/.venv/bin/python" \
"$ROOT_DIR/venv/bin/python3" \
"$ROOT_DIR/venv/bin/python"; do
if [[ -x "$p" ]]; then
PY="$p"
break
fi
done
if [[ -n "$PY" ]]; then
log "using python: $PY"
"$PY" -m py_compile "$ROOT_DIR/backend/main.py" "$ROOT_DIR/backend/routers/export.py"
log "backend syntax check: OK"
else
log "no project python found (.venv312/.venv/venv); skipping backend syntax check"
fi
log "Step 5/5: backend health import smoke"
if [[ -n "$PY" ]]; then
"$PY" - <<'PYCODE'
import importlib
mods = [
"backend.main",
"backend.routers.export",
"backend.services.video_editor",
]
for m in mods:
importlib.import_module(m)
print("backend import smoke: OK")
PYCODE
fi
log "Validation complete"