Files
ruflo/plugins/ruflo-console/scripts/smoke.sh
T
ruv ddb39aca18 feat(ruflo-console): the Missions list shows one line a mission, attention first, and flags a stale record (ADR 425, 0.26.0)
The list drew six missions as blocks of four or more lines, in update order, with no way to reach the rest. It now draws one line a mission, sorts blocked and failed first, counts what needs attention, scrolls a window of ten with j and k, and expands the cursor's mission below. A record older than ten minutes is flagged as possibly stale.

The ordering, freshness, row text and window are a pure module (hooks/mission-list.ts) with tests/mission-list.spec.ts, so they run without the claude-code test kit. Read-only: no mission action is added.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-03 15:55:43 -04:00

85 lines
5.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Structural + security smoke for ruflo-console. Static checks first (CI has no Claude Code), then the pure vitest
# specs. The hooks module's behaviour is held by `claude plugin test plugins/ruflo-console` where function hooks are on.
set -u
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
REPO="$(cd "$ROOT/../.." && pwd)"
HOOKS="$ROOT/hooks"
PASS=0
FAIL=0
step() { printf "→ %s ... " "$1"; }
ok() { printf "PASS\n"; PASS=$((PASS+1)); }
bad() { printf "FAIL: %s\n" "$1"; FAIL=$((FAIL+1)); }
step "1. plugin.json declares ruflo-console 0.26.0"
grep -q '"name": "ruflo-console"' "$ROOT/.claude-plugin/plugin.json" \
&& grep -q '"version": "0.26.0"' "$ROOT/.claude-plugin/plugin.json" && ok || bad "name/version"
step "2. hooks.json names exactly one module and no classic hook commands"
grep -q '"modules": \["./register.ts"\]' "$HOOKS/hooks.json" && ! grep -q '"command"' "$HOOKS/hooks.json" \
&& ok || bad "hooks.json must be modules-only"
step "3. no Node, Buffer or dynamic import in the module"
hits=$(grep -rnE "from ['\"]node:|\bBuffer\b|\bimport\(|require\(" "$HOOKS" || true)
[[ -z "$hits" ]] && ok || bad "$hits"
step "4. no import reaches outside the plugin folder"
deep=$(grep -rnE "from ['\"](\.\./){3,}" "$HOOKS" || true)
[[ -z "$deep" ]] && ok || bad "$deep"
step "5. no network call from the module (\$.http) and \$ is touched in register.ts only"
http=$(grep -rnE '\$\.http\.' "$HOOKS" || true)
# Code lines only: comments may name the calls they explain.
outside=$(grep -rnE '\$\.(fs|process|ui|clock|store|env|ruflo|tool|session|settings|command)\.' "$HOOKS" | grep -vE '^[^:]+:[0-9]+:\s*(\*|//|/\*)' | grep -v '/register.ts:' || true)
[[ -z "$http" && -z "$outside" ]] && ok || bad "http: $http outside: $outside"
step "6. never runs plugins list or verify (network); roster, registry, claims and sync are the network probes, all behind the federationNetwork option"
cmds=$(grep -nE "args: \['(plugins|verify)'" "$HOOKS/data/cli.ts" || true)
net=$(grep -rc "isNetwork: true" "$HOOKS/data" | awk -F: '{ n += $2 } END { print n }')
[[ -z "$cmds" && "$net" == "4" ]] && grep -q "federationNetwork" "$HOOKS/controller.ts" && ok || bad "cmds: $cmds network probes: $net"
step "7. private key files are never read paths"
# The federation folder is listed for its file names (node ids); a key file's path never reaches fs.read.
keys=$(grep -nE "(key-[^'\"]*\.json|channels\.json|nostr\.key)" "$HOOKS/data/files.ts" | grep -vE "^\s*[0-9]+:\s*(\*|//)|NOSTR_KEY = |test\(entry\.name\)" || true)
grep -q "fs.stat(under(home, NOSTR_KEY))" "$HOOKS/data/files.ts" && [[ -z "$keys" ]] && ok || bad "$keys"
step "8. mutations only through fixed argv (claims_* via JSON.stringify), behind a confirm"
grep -q "JSON.stringify(params)" "$HOOKS/actions.ts" \
&& [[ "$(grep -ohE "exec\('claims_[a-z-]+'" "$HOOKS/actions.ts" "$HOOKS/ops.ts" | sort -u | tr '\n' ' ')" == "exec('claims_claim' exec('claims_handoff' exec('claims_release' exec('claims_status' exec('claims_steal' " ]] \
&& grep -q "state.pending = " "$HOOKS/runner.ts" && ! grep -qE "'(sh|bash)', '-c'" -r "$HOOKS" && ok || bad "action surface changed"
step "9. plugin.register and tool.call are observed, never answered"
reg=$(awk '/on\(.plugin.register./,/^ }\)/' "$HOOKS/register.ts" | grep -cE "refuse:|deny:")
tool=$(awk '/on\(.tool.call./,/^ }\)/' "$HOOKS/register.ts" | grep -cE "deny|result:")
[[ "$reg" == "0" && "$tool" == "0" ]] && ok || bad "plugin.register answers: $reg tool.call answers: $tool"
step "10. no secrets or credentials in the module"
sec=$(grep -rniE "(api[_-]?key|secret|password|token)\s*[:=]\s*['\"][^'\"]{8,}" "$HOOKS" || true)
[[ -z "$sec" ]] && ok || bad "$sec"
step "11. every source file is under 500 lines"
long=$(find "$HOOKS" "$ROOT/tests" "$ROOT/scripts" -name '*.ts' -not -path '*/fixtures/ruflo-run.ts' -exec awk 'END { if (NR > 500) print FILENAME }' {} \;)
[[ -z "$long" ]] && ok || bad "$long"
step "12. kit tests are in the CI baseline (root vitest cannot resolve claude-code/testing)"
miss=""
for f in "$ROOT"/tests/*.test.ts; do
grep -qx "plugins/ruflo-console/tests/$(basename "$f")" "$REPO/scripts/ci-test-baseline.txt" || miss="$miss $(basename "$f")"
done
[[ -z "$miss" ]] && ok || bad "not in baseline:$miss"
step "13. marketplace lists ruflo-console"
grep -q '"name": "ruflo-console"' "$REPO/.claude-plugin/marketplace.json" && ok || bad "missing marketplace entry"
step "14. every pure spec passes under vitest"
if (cd "$REPO" && npx vitest run plugins/ruflo-console/tests/ --exclude '**/*.test.ts' >/dev/null 2>&1); then ok; else bad "vitest specs failed"; fi
step "15. the live no-spend e2e smoke exists, is executable and skips cleanly without RUFLO_E2E_LIVE"
if [[ -x "$ROOT/scripts/e2e-smoke.sh" ]] && bash "$ROOT/scripts/e2e-smoke.sh" 2>&1 | grep -q '^SKIP'; then ok; else bad "e2e-smoke.sh"; fi
step "16. every view has a matrix entry and an ask entry"
if [[ "$(grep -c "{ id: '[a-z]*', key: '[0-9a-z]'" "$ROOT/hooks/state.ts")" -eq "$(grep -cE "^ [a-z]+: \{ default:" "$ROOT/hooks/ask-claude.ts" | awk '{print $1 - 1}')" ]]; then ok; else bad "VIEW_ASK does not cover VIEWS"; fi
printf "\n%d passed, %d failed\n" "$PASS" "$FAIL"
[[ $FAIL -eq 0 ]]