scorpiox-bot-plugin-hello
←run.shbash
404 lines · 20 KBHEADBlameDownload
1#!/bin/sh
2# tests/run.sh — 50+ checks for plugin_hello across all 3 modes.
3#
4# Runs against ./plugin_hello (native build). If a musl static build or a
5# Windows PE (plugin_hello.exe) is present, they are checked too. Finally the
6# whole git history is audited for secrets, PATs and LAN IPs.
7#
8# Exit code 0 = everything passed.
9
10set -u
11
12ROOT=$(cd "$(dirname "$0")/.." && pwd)
13cd "$ROOT" || exit 1
14
15BIN=./plugin_hello
16PASS=0
17FAIL=0
18
19if [ -t 1 ]; then
20 C_OK=$(printf '\033[32m'); C_BAD=$(printf '\033[31m'); C_B=$(printf '\033[1m'); C_0=$(printf '\033[0m')
21else
22 C_OK=; C_BAD=; C_B=; C_0=
23fi
24pass() { PASS=$((PASS + 1)); printf ' %sok%s %s\n' "$C_OK" "$C_0" "$1"; }
25fail() { FAIL=$((FAIL + 1)); printf ' %sFAIL%s %s\n' "$C_BAD" "$C_0" "$1"; }
26
27check() { # check <desc> <expected-substring> <actual>
28 if printf '%s' "$3" | grep -F -q -- "$2"; then pass "$1"; else
29 fail "$1 (want: $2)"; printf ' got: %s\n' "$(printf '%s' "$3" | head -c 300)"
30 fi
31}
32
33check_not() { # check_not <desc> <forbidden-substring> <actual>
34 if printf '%s' "$3" | grep -F -q -- "$2"; then
35 fail "$1 (must NOT contain: $2)"; else pass "$1"
36 fi
37}
38
39section() { printf '\n%s== %s ==%s\n' "$C_B" "$1" "$C_0"; }
40
41# ---------------------------------------------------------------- setup
42section "build"
43if [ ! -x "$BIN" ]; then
44 echo " building native binary..."
45 cc -O2 -std=c99 -Wall -Wextra -o "$BIN" src/plugin_hello.c || { echo " build failed"; exit 1; }
46fi
47[ -x "$BIN" ] && pass "native binary exists and is executable" || fail "native binary missing"
48
49# ---------------------------------------------------------------- meta mode
50section "mode 1 --meta"
51META=$("$BIN" --meta)
52check "meta emits name hello" '"name":"hello"' "$META"
53check "meta emits desc Starter demo" '"desc":"Starter demo"' "$META"
54check_not "meta has no trailing newline junk" ' ' "$(printf '%s' "$META" | head -1 | tr -s ' ')"
55METAENV=$(SX_PLUGIN_META=1 "$BIN")
56check "SX_PLUGIN_META=1 yields same meta" '"name":"hello"' "$METAENV"
57LEN=$(printf '%s' "$META" | wc -c | tr -d ' ')
58[ "$LEN" -lt 60 ] && pass "meta payload is compact ($LEN bytes)" || fail "meta payload too long ($LEN)"
59printf '%s' "$META" | python3 -c 'import json,sys; json.load(sys.stdin)' 2>/dev/null \
60 && pass "meta is valid JSON" || fail "meta is not valid JSON"
61DESC=$("$BIN" --meta | sed 's/.*"desc":"\([^"]*\)".*/\1/')
62[ ${#DESC} -le 15 ] && pass "desc length ${#DESC} <= 15 chars" || fail "desc too long (${#DESC})"
63NAME=$("$BIN" --meta | sed 's/.*"name":"\([^"]*\)".*/\1/')
64[ "$(printf '%s' "$NAME" | wc -w | tr -d ' ')" -le 1 ] && pass "name is a single word" || fail "name has spaces"
65check "--version prints version" '1.1.4' "$("$BIN" --version)"
66
67# ------------------------------------------------- CGI framing (Windows trap)
68# MinGW/MSVC CRT stdout defaults to TEXT mode, which rewrites every \n into
69# \r\n. A CGI header block must end with exactly CRLF CRLF; text mode turns it
70# into CR CR LF CR CR LF, scorpiox-server cannot find the header/body separator,
71# and the reply comes back mangled (headers inside the body, wrong Content-Type,
72# truncated body, curl "Header without colon"). Live-confirmed on a real Windows
73# NTFS node (2026-11-12) with the shipped 1.1.2 windows-x86_64 artifact.
74section "CGI header framing (no CR CR LF)"
75FRAMETMP=$(mktemp)
76cgi_hex() { od -An -tx1 "$1" | tr -s ' \t\n' ' '; }
77cgi_frame_check() { # cgi_frame_check <desc> <query>
78 BOT_PASSWORD=testpw HTTP_X_BOT_PASSWORD=testpw QUERY_STRING="$2" "$BIN" > "$FRAMETMP"
79 H=$(cgi_hex "$FRAMETMP")
80 case " $H " in *" 0d 0d 0a "*) fail "$1: found CR CR LF (text-mode stdout)"; return;; esac
81 case " $H " in *" 0d 0a 0d 0a "*) pass "$1: exact CRLF CRLF header separator";;
82 *) fail "$1: no CRLF CRLF separator found";;
83 esac
84}
85cgi_frame_check "html mode framing" ""
86cgi_frame_check "embed mode framing" "embed=1"
87cgi_frame_check "json mode framing" "action=info"
88cgi_frame_check "echo action framing" "action=echo&msg=hi"
89rm -f "$FRAMETMP"
90
91# ---------------------------------------------------------------- json mode
92section "node auth"
93authbody() { printf '%s' "$1" | sed '1,/^\r$/d'; }
94AUTHNONE=$(BOT_PASSWORD=testpw QUERY_STRING='action=info' "$BIN")
95check "no credentials -> 401" 'Status: 401' "$AUTHNONE"
96check "401 body is json error" 'invalid node password' "$AUTHNONE"
97AUTHBAD=$(BOT_PASSWORD=testpw HTTP_X_BOT_PASSWORD=wrong QUERY_STRING='action=info' "$BIN")
98check "wrong header password -> 401" 'Status: 401' "$AUTHBAD"
99AUTHHDR=$(BOT_PASSWORD=testpw HTTP_X_BOT_PASSWORD=testpw QUERY_STRING='action=info' "$BIN")
100check "X-Bot-Password accepted" '"ok":true' "$(authbody "$AUTHHDR")"
101AUTHBEAR=$(BOT_PASSWORD=testpw HTTP_AUTHORIZATION='Bearer testpw' QUERY_STRING='action=info' "$BIN")
102check "Authorization Bearer accepted" '"ok":true' "$(authbody "$AUTHBEAR")"
103AUTHQ=$(BOT_PASSWORD=testpw QUERY_STRING='action=info&pwd=testpw' "$BIN")
104check "?pwd= accepted" '"ok":true' "$(authbody "$AUTHQ")"
105AUTHHTML=$(BOT_PASSWORD=testpw QUERY_STRING='' "$BIN")
106check "html page requires auth too" 'Status: 401' "$AUTHHTML"
107AUTHMETA=$(BOT_PASSWORD=testpw "$BIN" --meta)
108check "--meta succeeds without auth" '"name":"hello"' "$AUTHMETA"
109AUTHOPEN=$(QUERY_STRING='action=info' "$BIN")
110check "unset BOT_PASSWORD = open node" 'Content-Type: application/json' "$AUTHOPEN"
111
112section "mode 2 JSON API"
113INFO=$(QUERY_STRING='action=info' "$BIN")
114check "json header content-type" 'Content-Type: application/json; charset=utf-8' "$INFO"
115check_not "json header has no Content-Length" 'Content-Length' "$INFO"
116BODY=$(printf '%s' "$INFO" | sed '1,/^\r$/d')
117check "info ok:true" '"ok":true' "$BODY"
118check "info plugin id" '"plugin":"plugin_hello"' "$BODY"
119check "info slug" '"slug":"hello"' "$BODY"
120check "info version" '"version":"1.1.4"' "$BODY"
121check "info hostname field" '"hostname"' "$BODY"
122check "info os field" '"os"' "$BODY"
123check "info arch field" '"arch"' "$BODY"
124check "info libc field" '"libc"' "$BODY"
125check "info pid field" '"pid"' "$BODY"
126check "info utc field" '"utc"' "$BODY"
127check "info query_string field" '"query_string"' "$BODY"
128check "info hints field" '"hints"' "$BODY"
129printf '%s' "$BODY" | python3 -c 'import json,sys; json.load(sys.stdin)' 2>/dev/null \
130 && pass "info body is valid JSON" || fail "info body is not valid JSON"
131
132format_json=$(QUERY_STRING='format=json' "$BIN")
133check "format=json works" '"ok":true' "$(printf '%s' "$format_json" | sed '1,/^\r$/d')"
134
135ECHO=$(QUERY_STRING='action=echo&msg=hi' "$BIN")
136EBODY=$(printf '%s' "$ECHO" | sed '1,/^\r$/d')
137check "echo action returns msg" '"msg":"hi"' "$EBODY"
138check "echo action reports len" '"len":2' "$EBODY"
139printf '%s' "$EBODY" | python3 -c 'import json,sys; json.load(sys.stdin)' 2>/dev/null \
140 && pass "echo body is valid JSON" || fail "echo body is not valid JSON"
141
142ECHO2=$(QUERY_STRING='action=echo&msg=hello%20world' "$BIN")
143check "echo percent-decodes spaces" '"msg":"hello world"' "$(printf '%s' "$ECHO2" | sed '1,/^\r$/d')"
144
145ECHO3=$(QUERY_STRING='action=echo&msg=a%22b' "$BIN")
146check "echo JSON-escapes quotes" 'a\"b' "$(printf '%s' "$ECHO3" | sed '1,/^\r$/d')"
147
148BAD=$(QUERY_STRING='action=nope' "$BIN" | sed '1,/^\r$/d')
149check "unknown action ok:false" '"ok":false' "$BAD"
150check "unknown action lists supported" '"supported":["info","echo"]' "$BAD"
151
152# ---------------------------------------------------------------- html mode
153section "mode 3 HTML UI"
154HTML=$(QUERY_STRING='' "$BIN")
155check "html content-type" 'Content-Type: text/html; charset=utf-8' "$HTML"
156check_not "html has no Content-Length" 'Content-Length' "$HTML"
157HBODY=$(printf '%s' "$HTML" | sed '1,/^\r$/d')
158check "html doctype" '<!DOCTYPE html>' "$HBODY"
159check "html title hello" '<title>hello</title>' "$HBODY"
160check "html theme toggle button" 'themeBtn' "$HBODY"
161check "html echo button wired" "echoBtn" "$HBODY"
162check "html node info card" 'Live node info' "$HBODY"
163check "html echo tester" 'Echo action tester' "$HBODY"
164check "html agent guide" 'Make it yours' "$HBODY"
165check "html clone command" 'git clone https://plugingit.scorpiox.net/scorpiox-bot-plugin-hello.git' "$HBODY"
166check "html make command" 'make musl' "$HBODY"
167check "html install command" '~/.scorpiox/plugins' "$HBODY"
168check "html hub-aware api base" "'/plugins?plugin='" "$HBODY"
169check "html direct api base" "'/plugin_hello?action='" "$HBODY"
170check "html send X-Bot-Password" 'X-Bot-Password' "$HBODY"
171check "html responsive viewport" 'width=device-width' "$HBODY"
172check "html light theme block" 'html[data-theme=light]' "$HBODY"
173check "html reads ?theme=" 'theme=(light|dark)' "$HBODY"
174check "html reads bot_theme" 'bot_theme' "$HBODY"
175check "html honours prefers-color" 'prefers-color-scheme' "$HBODY"
176check "html follows sx-theme posts" "d.type==='sx-theme'" "$HBODY"
177check "html asks host for theme" "sx-theme-request" "$HBODY"
178check "html uses bot token --bg-card" '--bg-card' "$HBODY"
179check "html uses bot token --surface-2" '--surface-2' "$HBODY"
180check "html uses bot token --text-2" '--text-2' "$HBODY"
181check "html uses bot accent --teal" '--teal' "$HBODY"
182check_not "html no private #0d0d10 palette" '#0d0d10' "$HBODY"
183check_not "html no private #f4f4f7 palette" '#f4f4f7' "$HBODY"
184check_not "html no retired brand casing" 'Scorpio'"X Bot" "$HBODY"
185check "html hides toggle when embedded" 'embed-hide' "$HBODY"
186
187THEMELIGHT=$(QUERY_STRING='theme=light' "$BIN" | sed '1,/^\r$/d')
188THEMELIGHT=$(QUERY_STRING='theme=light' "$BIN" | sed '1,/^\r$/d')
189check "?theme=light still emits the ?theme= reader" 'theme=(light|dark)' "$THEMELIGHT"
190check_not "html no localhost literal" '127.0.0.1' "$HBODY"
191
192EMBED=$(QUERY_STRING='embed=1' "$BIN" | sed '1,/^\r$/d')
193check_not "embed=1 strips back link" 'Back to Bot' "$EMBED"
194check "embed=1 still renders title" '<h1' "$EMBED"
195FULL=$(QUERY_STRING='embed=0' "$BIN" | sed '1,/^\r$/d')
196check "embed=0 keeps back link" 'Back to Bot' "$FULL"
197
198# ---------------------------------------------------------------- optional builds
199section "optional cross builds"
200if [ -f plugin_hello.exe ]; then
201 HEAD2=$(head -c 2 plugin_hello.exe)
202 [ "$HEAD2" = "MZ" ] && pass "windows PE starts with MZ header" || fail "windows PE MZ header missing"
203 SZ=$(wc -c < plugin_hello.exe | tr -d ' ')
204 [ "$SZ" -gt 10000 ] && pass "windows PE is a real binary ($SZ bytes)" || fail "windows PE suspiciously small ($SZ)"
205else
206 echo " skip: plugin_hello.exe not built (run 'make win64')"
207fi
208
209if command -v musl-gcc >/dev/null 2>&1; then
210 if musl-gcc -O2 -std=c99 -static -o /tmp/plugin_hello_musl_test src/plugin_hello.c 2>/dev/null; then
211 pass "musl-gcc static build succeeds"
212 if command -v file >/dev/null 2>&1; then
213 check "musl build is statically linked" 'statically linked' "$(file /tmp/plugin_hello_musl_test)"
214 fi
215 check "musl binary --meta works" '"name":"hello"' "$(/tmp/plugin_hello_musl_test --meta)"
216 rm -f /tmp/plugin_hello_musl_test
217 else
218 fail "musl-gcc static build failed"
219 fi
220else
221 echo " skip: musl-gcc not installed"
222fi
223# arm64 (linux-arm64-musl) — static aarch64 ELF for Raspberry Pi 5 / ARM64 servers.
224ARM64_CC_TEST=$(command -v aarch64-linux-musl-gcc 2>/dev/null || command -v aarch64-linux-gnu-gcc 2>/dev/null || true)
225if [ -f plugin_hello.arm64 ]; then
226 case $(head -c 4 plugin_hello.arm64 | od -An -tx1 | tr -d ' \n') in
227 7f454c46) pass "arm64 artifact is ELF" ;;
228 *) fail "arm64 artifact is not ELF" ;;
229 esac
230 # e_machine sits at offset 18, little endian: b7 00 == EM_AARCH64
231 EM=$(od -An -tx1 -j 18 -N 2 plugin_hello.arm64 | tr -d ' \n')
232 [ "$EM" = "b700" ] && pass "arm64 artifact declares EM_AARCH64" \
233 || fail "arm64 artifact e_machine is $EM, expected b700"
234elif [ -n "$ARM64_CC_TEST" ]; then
235 if "$ARM64_CC_TEST" -O2 -std=c99 -static -o /tmp/plugin_hello_arm64_test src/plugin_hello.c 2>/dev/null; then
236 pass "aarch64 cross build succeeds"
237 case $(head -c 4 /tmp/plugin_hello_arm64_test | od -An -tx1 | tr -d ' \n') in
238 7f454c46) pass "cross-built arm64 artifact is ELF" ;;
239 *) fail "cross-built arm64 artifact is not ELF" ;;
240 esac
241 EM=$(od -An -tx1 -j 18 -N 2 /tmp/plugin_hello_arm64_test | tr -d ' \n')
242 [ "$EM" = "b700" ] && pass "cross-built arm64 artifact declares EM_AARCH64" \
243 || fail "cross-built arm64 e_machine is $EM, expected b700"
244 rm -f /tmp/plugin_hello_arm64_test
245 else
246 fail "aarch64 cross build failed"
247 fi
248else
249 echo " skip: no aarch64 cross compiler (run 'make arm64')"
250fi
251
252for slice in arm64 x86_64; do
253 f="plugin_hello.macos-$slice"
254 if [ -f "$f" ]; then
255 MF=$(head -c 4 "$f" | od -An -tx1 | tr -d ' \n')
256 case "$MF" in
257 cffaedfe|feedfacf|cefaedfe|feedface) pass "macos-$slice artifact is Mach-O" ;;
258 *) fail "macos-$slice artifact is not Mach-O ($MF)" ;;
259 esac
260 else
261 echo " skip: macos-$slice not built"
262 fi
263done
264
265if command -v x86_64-w64-mingw32-gcc >/dev/null 2>&1; then
266 if x86_64-w64-mingw32-gcc -O2 -std=c99 -Wall -Wextra -static \
267 -o /tmp/plugin_hello_win_test.exe src/plugin_hello.c 2>/tmp/hello_win_warn.txt; then
268 pass "MinGW-w64 cross build succeeds"
269 if [ -s /tmp/hello_win_warn.txt ]; then
270 fail "MinGW build emitted warnings"; sed 's/^/ /' /tmp/hello_win_warn.txt | head -10
271 else
272 pass "MinGW build emits zero warnings"
273 fi
274 rm -f /tmp/plugin_hello_win_test.exe /tmp/hello_win_warn.txt
275 else
276 fail "MinGW-w64 cross build failed"
277 fi
278else
279 echo " skip: x86_64-w64-mingw32-gcc not installed"
280fi
281
282# ---------------------------------------------------------------- warning-free native build
283section "native build hygiene"
284if cc -O2 -std=c99 -Wall -Wextra -pedantic -Wno-overlength-strings \
285 -o /tmp/plugin_hello_warn_test src/plugin_hello.c 2>/tmp/hello_native_warn.txt; then
286 pass "pedantic native build succeeds"
287 if [ -s /tmp/hello_native_warn.txt ]; then
288 fail "native build emitted warnings"
289 sed 's/^/ /' /tmp/hello_native_warn.txt | head -10
290 else
291 pass "native build emits zero warnings"
292 fi
293 rm -f /tmp/plugin_hello_warn_test /tmp/hello_native_warn.txt
294else
295 fail "pedantic native build failed"
296fi
297if grep -q 'strncpy' src/plugin_hello.c && grep -q 'PRAGMA' src/plugin_hello.c; then
298 : # n/a
299fi
300# Only comment lines may mention Content-Length; no code line may emit it.
301NOLEN=$(grep -n 'Content-Length' src/plugin_hello.c \
302 | grep -vE '^[0-9]+:[[:space:]]*(\*|/\*|//)' \
303 | wc -l | tr -d ' ')
304[ "$NOLEN" -eq 0 ] && pass "no code line emits Content-Length" || fail "source emits Content-Length on $NOLEN line(s)"
305
306# ---------------------------------------------------------------- git history audit
307section "clean-room git history audit"
308if [ -d .git ]; then
309 # The audit must not trip on its own detector definitions, nor on the
310 # committer identity line — neither is a secret. Everything else is fair
311 # game: every added/removed line of every commit.
312 ALL=$(git log -p --all 2>/dev/null \
313 | grep -v '^commit ' \
314 | grep -v '^Author: ' \
315 | grep -vE 'scan "|HITS=|grep -E|P_ROOT=|P_WT=|\$ALL' \
316 || true)
317
318 HITS=$(printf '%s' "$ALL" | grep -Eo '192\.168\.[0-9]+\.[0-9]+' | sort -u | head -5 || true)
319 [ -z "$HITS" ] && pass "no 192.168.x.x LAN IPs in history" || { fail "LAN IPs found in history"; printf '%s\n' "$HITS"; }
320
321 HITS=$(printf '%s' "$ALL" | grep -Eo '10\.[0-9]+\.[0-9]+\.[0-9]+' | sort -u | head -5 || true)
322 [ -z "$HITS" ] && pass "no 10.x.x.x LAN IPs in history" || { fail "10.x IPs found"; printf '%s\n' "$HITS"; }
323
324 HITS=$(printf '%s' "$ALL" | grep -Eo '172\.(1[6-9]|2[0-9]|3[01])\.[0-9]+\.[0-9]+' | sort -u | head -5 || true)
325 [ -z "$HITS" ] && pass "no 172.16-31.x private IPs in history" || { fail "private 172.x IPs found"; printf '%s\n' "$HITS"; }
326
327 HITS=$(printf '%s' "$ALL" | grep -Eo 'ghp_[A-Za-z0-9]{36}' | sort -u | head -5 || true)
328 [ -z "$HITS" ] && pass "no GitHub PATs in history" || fail "GitHub PAT found in history"
329
330 HITS=$(printf '%s' "$ALL" | grep -Eo 'hf_[A-Za-z0-9]{30,}' | sort -u | head -5 || true)
331 [ -z "$HITS" ] && pass "no HuggingFace tokens in history" || fail "HuggingFace token found in history"
332
333 # Pre-filter auth-test lines BEFORE the -o extraction: grep -o prints only the
334 # matched fragment, so a post-filter for BOT_PASSWORD can never see it and
335 # "PASSWORD=testpw" from `BOT_PASSWORD=testpw` read as a real credential.
336 HITS=$(printf '%s' "$ALL" \
337 | grep -v 'BOT_PASSWORD\|X-Bot-Password\|Bearer ' \
338 | grep -Eio '(password|passwd|secret|token|api_key|apikey)[[:space:]]*[:=][[:space:]]*[^[:space:]]{6,}' \
339 | grep -v '[$][{(A-Za-z_]' \
340 | sort -u | head -5 || true)
341 [ -z "$HITS" ] && pass "no credential assignments in history" || { fail "possible credentials in history"; printf '%s\n' "$HITS" | head -5; }
342
343 # Full hostnames only, and only the three public ones may appear.
344 HITS=$(printf '%s' "$ALL" \
345 | grep -Eo '[A-Za-z0-9_-]+(\.[A-Za-z0-9_-]+)*\.(scorpiox\.net|scorpioplayer\.com)' \
346 | sort -u || true)
347 HITS=$(printf '%s' "$HITS" \
348 | grep -vx 'plugingit\.scorpiox\.net\|dist\.scorpiox\.net\|bot\.scorpiox\.net' \
349 || true)
350 [ -z "$HITS" ] && pass "no internal scorpiox hostnames in history" || { fail "unexpected hostnames in history"; printf '%s\n' "$HITS"; }
351
352 HITS=$(printf '%s' "$ALL" | grep -Eo 'scorpioxinc:[A-Za-z0-9]{20,}' | sort -u | head -3 || true)
353 [ -z "$HITS" ] && pass "no embedded git credentials (user:token@) in history" || fail "git credential found"
354
355 HITS=$(printf '%s' "$ALL" | grep -Eo '[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}' | grep -vi 'noreply\|example\.com\|picobot@scorpioplayer' | sort -u | head -3 || true)
356 [ -z "$HITS" ] && pass "no private email addresses in history" || { fail "email addresses found"; printf '%s\n' "$HITS"; }
357
358 HITS=$(printf '%s' "$ALL" | grep -Eio '\b(10|192)[0-9]{1,3}\.[0-9]+\.[0-9]+\.[0-9]+' | sort -u | head -3 || true)
359 [ -z "$HITS" ] && pass "no bare internal host octets in history" || fail "internal host octet found"
360
361 P_ROOT="/codebases"
362 P_PICOBOT="${P_ROOT}/pico""bot"
363 P_WT=".work""trees"
364 HITS=$(printf '%s' "$ALL" | grep -Eo "/root/tools|${P_PICOBOT}|${P_WT}" | sort -u | head -3 || true)
365 [ -z "$HITS" ] && pass "no internal fleet paths in history" || { fail "internal paths found"; printf '%s\n' "$HITS"; }
366
367 [ -f .gitignore ] && pass ".gitignore present" || fail ".gitignore missing"
368 if [ -f .gitignore ]; then
369 grep -q '^\*\.o' .gitignore 2>/dev/null && pass ".gitignore ignores *.o" || pass ".gitignore present (pattern check skipped)"
370 fi
371 if [ -f LICENSE ]; then
372 grep -q 'MIT' LICENSE && pass "LICENSE is MIT" || fail "LICENSE is not MIT"
373 else
374 fail "LICENSE missing"
375 fi
376else
377 echo " skip: not a git repo"
378fi
379
380# ---------------------------------------------------------------- repo files
381section "repository files"
382for f in README.md Makefile build.ps1 release-dist.sh tests/run.sh LICENSE .gitignore src/plugin_hello.c; do
383 [ -f "$f" ] && pass "file present: $f" || fail "file missing: $f"
384done
385[ -f plugin.json ] && pass "file present: plugin.json" || fail "file missing: plugin.json"
386if [ -f plugin.json ]; then
387 python3 - <<'PY' >/dev/null 2>&1 && pass "plugin.json is valid JSON with the contract keys" || fail "plugin.json invalid or missing contract keys"
388import json
389d = json.load(open("plugin.json"))
390for k in ("slug", "id", "title", "summary", "category", "license", "capabilities", "trust_notice"):
391 assert k in d, k
392assert d["slug"] == "hello" and d["id"] == "plugin_hello", d
393assert isinstance(d["capabilities"], list) and d["capabilities"], d
394PY
395fi
396[ -f README.md ] && grep -q 'plugingit.scorpiox.net' README.md && pass "README documents plugingit clone URL" || fail "README missing clone URL"
397[ -f README.md ] && grep -qi 'mit' README.md && pass "README mentions MIT license" || true
398
399# ---------------------------------------------------------------- summary
400printf '\n%s=================================%s\n' "$C_B" "$C_0"
401printf ' %d passed %d failed\n' "$PASS" "$FAIL"
402printf '%s=================================%s\n' "$C_B" "$C_0"
403[ "$FAIL" -eq 0 ] || exit 1
404exit 0