mirror of
https://github.com/boshu2/agentops.git
synced 2026-09-14 15:08:13 +08:00
606c00e484
Trunk on main has been RED since 2026-06-08 (last greenc9c3e270). Restores every blocking gate to green on a branch. Five fix categories: 1. security / dangerous-pattern: add install-claude.sh, install-agy.sh, and install.sh to the curl|bash --exclude list in validate.yml. install.sh gained an AGY install-instructions echo (curl|bash) on 2026-06-09; the two new install scripts mirror the already-excluded install-codex/opencode set. 2. lint / markdownlint: fix 3 pre-existing failures without deleting content — MD037 (backtick the glob paths so * isn't read as emphasis) in dirty-main-attribution; two MD004 (rewrap so a continuation '+' isn't read as a plus-style bullet) in ag-s43tg-resume + skill-prune-phase2. 3. skill-flow danglers: the Phase-2 skill prune (40ee1c34f) deleted brainstorm/design/complexity/ratchet/audit-report/learning/ operating-loop-skill/cass-memory but left consumes/metadata.dependencies/ context_rel edges pointing at them. Removed the dangling edges from discovery, refactor, eval-outcomes, rpi, operationalize, agy-native, perf, test, acfs. converge (thin memo) now consumes the whitelisted command-help artifact; converge + beads-bv (orphaned when operating-loop-skill was pruned) added to skill-flow-standalone.txt with rationale. 4. derived-artifact drift: regenerated catalog.json, registry.json, context-map.md, and the 10 skills-codex .agentops-generated.json twins + manifest via scripts/regen-all.sh after the frontmatter edits. 5. stale bats: brainstorm-discovery-ideation.bats followed the deliberate bd->br tracker migration (f650d41bb) — assert br / ban bd — and the codex anti-leak guard now targets the real codex twin (skills-codex/discovery) instead of the shared Claude reference (which legitimately uses AskUserQuestion). install-sh-runtime-detection.bats updated to the new multi-vendor install-suggestion output format. Did NOT touch tests/scripts/validate-skill-disposition-schema.bats: its "bad revision origin/main" failure is a CI-env artifact (checkout lacks the origin/main named ref); all 24 cases pass locally with the ref present and the 4 guarded files unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
124 lines
4.7 KiB
Bash
124 lines
4.7 KiB
Bash
#!/usr/bin/env bats
|
|
# Regression tests for scripts/install.sh runtime-detection block (soc-vuu6.31).
|
|
#
|
|
# We can't run install.sh end-to-end in CI — it expects network access and
|
|
# rewrites ~/.claude. Instead we stub `claude`, `codex`, and `curl` on PATH
|
|
# and run the real install.sh; the script exits at the curl call once it
|
|
# moves past the detection block, so we capture stdout up to that point.
|
|
#
|
|
# What we assert: the script prints runtime-by-runtime detection lines and
|
|
# the correct mode line for each combination (both / claude-only /
|
|
# codex-only / neither).
|
|
|
|
setup() {
|
|
REPO_ROOT="$(git rev-parse --show-toplevel)"
|
|
INSTALL_SH="$REPO_ROOT/scripts/install.sh"
|
|
TMP="$(mktemp -d)"
|
|
ORIG_PATH="$PATH"
|
|
ORIG_DIR="$PWD"
|
|
mkdir -p "$TMP/bin"
|
|
# Stub curl so the script exits after the detection block without
|
|
# touching the network. Returning 1 causes set -e + pipefail to bail.
|
|
cat >"$TMP/bin/curl" <<'EOF'
|
|
#!/usr/bin/env bash
|
|
echo "[stubbed-curl] $*" >&2
|
|
exit 1
|
|
EOF
|
|
chmod +x "$TMP/bin/curl"
|
|
# Keep coreutils on PATH (sed/awk/cat/etc). We add stubs at the front.
|
|
COREUTILS_PATH="$ORIG_PATH"
|
|
}
|
|
|
|
teardown() {
|
|
cd "$ORIG_DIR" 2>/dev/null || true
|
|
export PATH="$ORIG_PATH"
|
|
rm -rf "$TMP"
|
|
}
|
|
|
|
stub_runtime() {
|
|
local name="$1"
|
|
cat >"$TMP/bin/$name" <<EOF
|
|
#!/usr/bin/env bash
|
|
echo "[stubbed-$name] \$*"
|
|
exit 0
|
|
EOF
|
|
chmod +x "$TMP/bin/$name"
|
|
}
|
|
|
|
run_install_with_path() {
|
|
cd "$TMP"
|
|
export PATH="$1"
|
|
# The script's `set -e` will exit non-zero at curl; that's fine.
|
|
run bash "$INSTALL_SH"
|
|
}
|
|
|
|
@test "both claude and codex present: mixed-model mode" {
|
|
stub_runtime claude
|
|
stub_runtime codex
|
|
run_install_with_path "$TMP/bin:$COREUTILS_PATH"
|
|
[[ "$output" == *"Detected Claude Code: yes"* ]]
|
|
[[ "$output" == *"Detected Codex CLI: yes"* ]]
|
|
[[ "$output" == *"mixed-model mode"* ]]
|
|
}
|
|
|
|
@test "claude only: single-runtime + Codex install suggestion" {
|
|
stub_runtime claude
|
|
# Do NOT stub codex; absent in $TMP/bin → also absent in PATH after we
|
|
# restrict to $TMP/bin + a coreutils-only shim.
|
|
mkdir -p "$TMP/coreutils-only"
|
|
for cmd in bash sh sed awk grep tr sort cat mkdir mv rm cp ls wc dirname basename head tail printf jq mktemp tar id chmod; do
|
|
full="$(command -v "$cmd" 2>/dev/null || true)"
|
|
[ -n "$full" ] && ln -sf "$full" "$TMP/coreutils-only/$cmd"
|
|
done
|
|
run_install_with_path "$TMP/bin:$TMP/coreutils-only"
|
|
[[ "$output" == *"Detected Claude Code: yes"* ]]
|
|
[[ "$output" == *"Detected Codex CLI: no"* ]]
|
|
[[ "$output" == *"single-runtime mode (Claude Code only)"* ]]
|
|
# install.sh now points single-runtime users at the other runtimes' install
|
|
# links (multi-vendor: Codex + Gemini/AGY) under a "install another runtime"
|
|
# banner. Assert the Codex link is offered.
|
|
[[ "$output" == *"Codex CLI: https://github.com/openai/codex"* ]]
|
|
}
|
|
|
|
@test "codex only: single-runtime + Claude install suggestion" {
|
|
stub_runtime codex
|
|
mkdir -p "$TMP/coreutils-only"
|
|
for cmd in bash sh sed awk grep tr sort cat mkdir mv rm cp ls wc dirname basename head tail printf jq mktemp tar id chmod; do
|
|
full="$(command -v "$cmd" 2>/dev/null || true)"
|
|
[ -n "$full" ] && ln -sf "$full" "$TMP/coreutils-only/$cmd"
|
|
done
|
|
run_install_with_path "$TMP/bin:$TMP/coreutils-only"
|
|
[[ "$output" == *"Detected Claude Code: no"* ]]
|
|
[[ "$output" == *"Detected Codex CLI: yes"* ]]
|
|
[[ "$output" == *"single-runtime mode (Codex CLI only)"* ]]
|
|
# Assert the Claude install link is offered to the single-runtime Codex user.
|
|
[[ "$output" == *"Claude Code: https://docs.anthropic.com/en/docs/claude-code"* ]]
|
|
}
|
|
|
|
@test "neither present: warning + both install links" {
|
|
# No runtime stubs; PATH points only at coreutils + curl stub.
|
|
mkdir -p "$TMP/coreutils-only"
|
|
for cmd in bash sh sed awk grep tr sort cat mkdir mv rm cp ls wc dirname basename head tail printf jq mktemp tar id chmod; do
|
|
full="$(command -v "$cmd" 2>/dev/null || true)"
|
|
[ -n "$full" ] && ln -sf "$full" "$TMP/coreutils-only/$cmd"
|
|
done
|
|
run_install_with_path "$TMP/bin:$TMP/coreutils-only"
|
|
[[ "$output" == *"Detected Claude Code: no"* ]]
|
|
[[ "$output" == *"Detected Codex CLI: no"* ]]
|
|
[[ "$output" == *"No supported coding agent found"* ]]
|
|
[[ "$output" == *"docs.anthropic.com/en/docs/claude-code"* ]]
|
|
[[ "$output" == *"github.com/openai/codex"* ]]
|
|
[[ "$output" == *"Continuing anyway"* ]]
|
|
}
|
|
|
|
@test "detection lines appear before any 'Step 1' install banner" {
|
|
stub_runtime claude
|
|
stub_runtime codex
|
|
run_install_with_path "$TMP/bin:$COREUTILS_PATH"
|
|
detect_line="$(printf '%s\n' "$output" | grep -n 'Detected Claude Code' | head -1 | cut -d: -f1)"
|
|
step_line="$(printf '%s\n' "$output" | grep -n 'Step 1' | head -1 | cut -d: -f1)"
|
|
[ -n "$detect_line" ]
|
|
[ -n "$step_line" ]
|
|
[ "$detect_line" -lt "$step_line" ]
|
|
}
|