Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions .github/scripts/validate-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,25 @@ declare -a names=() results=()
failed=0

run_check() {
local name="$1"
shift
echo "==============================="
echo "=== $name"
echo "==============================="
names+=("$name")
if "$@"; then
results+=("PASS")
else
results+=("FAIL")
failed=1
fi
echo ""
local name="$1"
shift
echo "==============================="
echo "=== $name"
echo "==============================="
names+=("$name")
if "$@"; then
results+=("PASS")
else
results+=("FAIL")
failed=1
fi
echo ""
}

run_check "ci parity" bash .github/scripts/check-ci-parity.sh
run_check "plugin tests" bash test.sh
run_check "plugin structure" bash .github/scripts/validate-plugins.sh
run_check "opencode structure" bash .github/scripts/validate-opencode.sh
run_check "frontmatter" bash .github/scripts/validate-frontmatter.sh
# Not a pass/fail check (it only warns), so it is not a run_check and has no CI
# job; the note is repeated after the summary so it is not lost in the output.
Expand All @@ -51,19 +52,19 @@ echo "==============================="
echo "=== Summary"
echo "==============================="
for i in "${!names[@]}"; do
printf " %-20s [%s]\n" "${names[$i]}" "${results[$i]}"
printf " %-20s [%s]\n" "${names[$i]}" "${results[$i]}"
done
echo ""

if [[ "$rumdl_note" == WARNING* ]]; then
echo "$rumdl_note"
echo ""
echo "$rumdl_note"
echo ""
fi

if [[ $failed -eq 0 ]]; then
echo "All checks passed."
echo "All checks passed."
else
echo "Some checks failed."
echo "Some checks failed."
fi

exit "$failed"
168 changes: 168 additions & 0 deletions .github/scripts/validate-opencode.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
#!/usr/bin/env bash
# validate-opencode.sh — structural validation for the plugins-opencode/ tree.
#
# Deliberately separate from validate-plugins.sh: those checks are
# Claude/Copilot-specific (hooks.json casing, _PLUGIN_ROOT vars, marketplace
# files) and none of those artifacts exist for OpenCode.
#
# Checks:
# 1. JSON validity — all .json files under plugins-opencode parse
# 2. JSONC snippets — config snippets parse after stripping line comments
# 3. Code plugin packages — inbox/session carry a package.json whose exports
# point at files that exist
# 4. Skill frontmatter — SKILL.md files have name and description
# 5. Command bodies — command .md files have a non-empty body
# 6. No Claude leakage — no ${CLAUDE_PLUGIN_ROOT}/${CLAUDE_SESSION_ID} refs
# 7. Vendored scripts — plugins-opencode/*/scripts/* are executable
#
# Exit codes: 0 = all passed, 1 = one or more failures.

set -euo pipefail

REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
cd "$REPO_ROOT"

TARGET="plugins-opencode"
ERRORS=0
CHECKS=0

pass() {
CHECKS=$((CHECKS + 1))
echo " ✓ $1"
}
fail() {
CHECKS=$((CHECKS + 1))
ERRORS=$((ERRORS + 1))
echo " ✗ $1" >&2
}

# ---------------------------------------------------------------------------
# 1. JSON validity
# ---------------------------------------------------------------------------
echo "=== JSON validity ==="
while IFS= read -r f; do
if jq empty "$f" 2>/dev/null; then
pass "$f"
else
fail "$f — invalid JSON"
fi
done < <(find "$TARGET" -name '*.json' -type f | sort)

# ---------------------------------------------------------------------------
# 2. JSONC config snippets
# ---------------------------------------------------------------------------
echo ""
echo "=== JSONC snippet validity ==="
while IFS= read -r f; do
# Strip full-line // comments and trailing commas, then parse with node
# (CI runners have it; this is a syntax gate only, not a schema check).
if node -e '
const s = require("fs").readFileSync(process.argv[1], "utf8")
.replace(/^\s*\/\/.*$/gm, "")
.replace(/,(\s*[}\]])/g, "$1");
JSON.parse(s);
' "$f" 2>/dev/null; then
pass "$f"
else
fail "$f — invalid JSONC"
fi
done < <(find "$TARGET" -name '*.jsonc' -type f | sort)

# ---------------------------------------------------------------------------
# 3. Code plugin packages
# ---------------------------------------------------------------------------
echo ""
echo "=== Code plugin packages ==="
for plugin in inbox session; do
pj="$TARGET/$plugin/package.json"
if [[ ! -f "$pj" ]]; then
fail "$pj missing (behavioral plugins ship a package.json)"
continue
fi
name=$(jq -r '.name // empty' "$pj")
type_=$(jq -r '.type // empty' "$pj")
if [[ -z "$name" ]]; then
fail "$pj — missing name"
elif [[ "$type_" != "module" ]]; then
fail "$pj — type must be \"module\" (got: ${type_:-missing})"
else
pass "$pj — name=$name type=module"
fi
while IFS= read -r target; do
[[ -z "$target" ]] && continue
if [[ -f "$TARGET/$plugin/${target#./}" ]]; then
pass "$plugin export → $target"
else
fail "$plugin export target missing: $target"
fi
done < <(jq -r '.exports[]? // empty' "$pj")
done

# ---------------------------------------------------------------------------
# 4. Skill frontmatter
# ---------------------------------------------------------------------------
echo ""
echo "=== Skill frontmatter ==="
while IFS= read -r f; do
fm=$(awk '/^---$/ { n++; next } n==1 { print } n>=2 { exit }' "$f")
if [[ -z "$fm" ]]; then
fail "$f — no frontmatter found"
continue
fi
ok=1
for field in name description; do
if ! echo "$fm" | grep -q "^${field}:"; then
fail "$f — missing required field: $field"
ok=0
fi
done
[[ $ok -eq 1 ]] && pass "$f"
done < <(find "$TARGET" -path '*/skills/*/SKILL.md' -type f | sort)

# ---------------------------------------------------------------------------
# 5. Command bodies
# ---------------------------------------------------------------------------
echo ""
echo "=== Command bodies ==="
while IFS= read -r f; do
body=$(awk '/^---$/{n++; next} n>=2' "$f" | sed '/./,$!d')
if [[ -n "$body" ]]; then
pass "$f"
else
fail "$f — empty command body (the body is the prompt template)"
fi
done < <(find "$TARGET" -path '*/commands/*.md' -type f | sort)

# ---------------------------------------------------------------------------
# 6. No Claude harness leakage
# ---------------------------------------------------------------------------
echo ""
echo "=== No Claude harness leakage ==="
if hits=$(grep -rn 'CLAUDE_PLUGIN_ROOT\|CLAUDE_SESSION_ID' "$TARGET" 2>/dev/null); then
while IFS= read -r line; do
fail "Claude var in OpenCode tree: $line"
done <<<"$hits"
else
pass "no \${CLAUDE_*} vars under $TARGET"
fi

# ---------------------------------------------------------------------------
# 7. Vendored scripts executable
# ---------------------------------------------------------------------------
echo ""
echo "=== Vendored scripts executable ==="
while IFS= read -r f; do
if [[ -x "$f" ]]; then
pass "$f"
else
fail "$f — not executable"
fi
done < <(find "$TARGET" -path '*/scripts/*' -type f | sort)

# ---------------------------------------------------------------------------
# Summary
# ---------------------------------------------------------------------------
echo ""
echo "=== Summary ==="
echo "$CHECKS checks, $ERRORS failures"
exit "$([[ "$ERRORS" -eq 0 ]] && echo 0 || echo 1)"
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ jobs:
run: sudo apt-get update && sudo apt-get install -y jq
- name: Validate plugins
run: bash .github/scripts/validate-plugins.sh
- name: Validate OpenCode plugins
run: bash .github/scripts/validate-opencode.sh
- name: Check CI/validate-all parity
run: bash .github/scripts/check-ci-parity.sh

Expand Down
38 changes: 29 additions & 9 deletions plugins-claude/inbox/scripts/inbox
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ except for 'prune' and help).
Items are referenced as Q<n> (question), D<n> (decision) or F<n> (followup).

Commands:
add question --title T [--context C] [--option O]... [--recommend R] [--new]
add question --title T [--context C] [--option O]... [--recommend R] [--blocking] [--new]
Park a question that blocks on the user. Refused (exit 3) if a similar
open question exists unless --new is given.
open question exists unless --new is given. --blocking marks the rare
"I cannot proceed at all" stop; harnesses may ping on blocking
questions only. Default false: record the question, state the
assumption, and keep working.
add decision --title T [--context C] [--option O]... [--chosen X] [--new]
Record a decision already made on a default; --chosen is what was
picked, --option the alternatives considered. Refused (exit 3) if a
Expand All @@ -35,6 +38,7 @@ Commands:
Refused (exit 3) if a similar open followup exists unless --new.
update <Q<n>|D<n>|F<n>> [--title T] [--context C] [--option O]...
[--recommend R (question)] [--chosen X (decision)]
[--blocking | --no-blocking (question)]
Replace provided fields (any --option replaces the options list).
answer Q<n> [--note N]
Remove a question. --note is reserved and currently ignored.
Expand Down Expand Up @@ -115,10 +119,14 @@ lock() {
flock 9
}

# Fill in any keys an older (questions-only) state file lacks.
# Fill in any keys an older (questions-only) state file lacks. Questions also
# get the `blocking` field backfilled (see below): an item is only `blocking`
# when the agent explicitly parked it with --blocking; everything recorded
# before the field existed defaults to false. Consumers that count questions
# (notify-on-stop, statusline) ignore this field entirely.
NORMALIZE='. + {
next_id: (.next_id // 1),
questions: (.questions // []),
questions: ((.questions // []) | map(if has("blocking") then . else . + {blocking: false} end)),
next_decision_id: (.next_decision_id // 1),
decisions: (.decisions // []),
next_followup_id: (.next_followup_id // 1),
Expand Down Expand Up @@ -196,7 +204,7 @@ cmd_add() {
*) die "add: expected 'question', 'decision' or 'followup', got '$kind'" 2 ;;
esac
kind_keys "$kind"
local title="" context="" extra="" force=0
local title="" context="" extra="" force=0 blocking=0
local -a opts=()
while [[ $# -gt 0 ]]; do
case "$1" in
Expand All @@ -211,6 +219,9 @@ cmd_add() {
--chosen)
[[ "$kind" == decision ]] || die "add $kind: --chosen is only for decisions" 2
extra="${2:?--chosen needs a value}"; shift 2 ;;
--blocking)
[[ "$kind" == question ]] || die "add $kind: --blocking is only for questions" 2
blocking=1; shift ;;
--new) force=1; shift ;;
*) die "add $kind: unknown argument: $1" 2 ;;
esac
Expand Down Expand Up @@ -242,8 +253,9 @@ cmd_add() {
id=$(jq -r --arg c "$CTR" '.[$c]' <<<"$state")
new=$(jq --arg k "$ARR" --arg c "$CTR" --arg kind "$kind" \
--arg t "$title" --arg x "$context" --arg e "$extra" \
--argjson o "$opts_json" --argjson now "$(date +%s)" '
(if $kind == "question" then {options: $o, recommendation: $e}
--argjson o "$opts_json" --argjson now "$(date +%s)" \
--argjson blocking "$( [[ $blocking -eq 1 ]] && echo true || echo false )" '
(if $kind == "question" then {options: $o, recommendation: $e, blocking: $blocking}
elif $kind == "decision" then {options: $o, chosen: $e}
else {} end) as $extra
| .[$k] += [{id: .[$c], title: $t, context: $x} + $extra + {added: $now}]
Expand All @@ -257,7 +269,7 @@ cmd_update() {
shift
local kind="$REF_KIND" id="$REF_ID"
kind_keys "$kind"
local title="" context="" extra="" have_t=0 have_c=0 have_e=0
local title="" context="" extra="" have_t=0 have_c=0 have_e=0 blocking=0 have_b=0
local -a opts=()
while [[ $# -gt 0 ]]; do
case "$1" in
Expand All @@ -272,6 +284,12 @@ cmd_update() {
--chosen)
[[ "$kind" == decision ]] || die "update $PFX$id: --chosen applies to decisions only (use --recommend)" 1
extra="${2:?--chosen needs a value}"; have_e=1; shift 2 ;;
--blocking)
[[ "$kind" == question ]] || die "update $PFX$id: --blocking applies to questions only" 1
blocking=1; have_b=1; shift ;;
--no-blocking)
[[ "$kind" == question ]] || die "update $PFX$id: --no-blocking applies to questions only" 1
blocking=0; have_b=1; shift ;;
*) die "update: unknown argument: $1" 2 ;;
esac
done
Expand All @@ -287,13 +305,15 @@ cmd_update() {
local new
new=$(jq --arg k "$ARR" --arg kind "$kind" --argjson id "$id" \
--arg t "$title" --arg c "$context" --arg e "$extra" \
--argjson ht "$have_t" --argjson hc "$have_c" --argjson he "$have_e" --argjson o "$opts_json" '
--argjson ht "$have_t" --argjson hc "$have_c" --argjson he "$have_e" --argjson o "$opts_json" \
--argjson b "$blocking" --argjson hb "$have_b" '
(if $kind == "question" then "recommendation" else "chosen" end) as $ek
| .[$k] |= map(if .id == $id then
(if $ht == 1 then .title = $t else . end)
| (if $hc == 1 then .context = $c else . end)
| (if $he == 1 then .[$ek] = $e else . end)
| (if $o != null then .options = $o else . end)
| (if $hb == 1 then .blocking = ($b == 1) else . end)
else . end)' <<<"$state")
write_state "$new"
echo "$PFX$id updated"
Expand Down
Loading
Loading