Files
boshu2__agentops/tests/scripts/test-codex-plugin-install.sh
Bo e431339c40 feat(hookless)!: remove all hooks — skills + CLI only (soc-57b7f #remove-all-hooks) (#511)
## What

AgentOps 3.0 goes **fully hookless**. This removes the entire hook
product surface — the product is now skills + the `ao` CLI with **zero
hooks**. CI is the authoritative gate.

## Deleted

- `hooks/` — 46 hook scripts + `hooks.json` + examples (whole directory)
- `cli/embedded/hooks/` + embedded `hooks.json` +
`embedded/lib/hook-helpers.sh`
- `lib/hook-helpers.sh`
- `ao hooks` CLI command: `cli/cmd/ao/hooks.go`, `hooks_run.go` + 5 hook
test files; `cli/internal/bridge/hooks.go`;
`cli/internal/doctor/fix_hooks.go` + test
- Codex hook manifest (`hooks/codex-hooks.json`) + handler/audit scripts
(`scripts/audit-codex-hooks.sh`, `install-dev-hooks.sh`,
`test-hooks-output.sh`, `test-codex-hookless-lifecycle.sh`,
`test-hookless-rpi-phased.sh`)
- Hook lease surface: `docs/contracts/hook-lease-*`,
`schemas/hook-lease.v1.schema.json`,
`scripts/check-hook-lease-inventory.sh`,
`check-hook-port-replacements.sh`, `generate-hook-lease-inventory.py`
- Hook docs: `docs/HOOKS.md`, `cli/docs/HOOKS.md`,
`docs/architecture/hook-noise-audit.md`,
`docs/contracts/hook-runtime-contract.md`
- `tests/hooks/` (whole dir) + hook test scripts; 5 hook eval suites +
fixtures

## CI gates removed

`hook-preflight`, `validate-hooks-doc-parity`, `hook-output-schema-lint`
(+ scripts/bats), the hook eval suites, the `test-runtime-codex-smoke` /
`test-codex-native-install` / `test-codex-plugin-install` hook-handler
assertions, the cli-integration hook-lifecycle steps, the bats
`tests/hooks/*` glob + orphan-hooks audit, and the `--with-hooks`
install path. `embedded-sync` now validates only lib/skills. Both
summary `needs:` lists + the summary echo +
`docs/contracts/ci-jobs.yaml` updated; `validate-ci-policy-parity`
passes (66 rows). `.codex-plugin/plugin.json` drops the "Hooks"
capability.

## Load-bearing PRESERVED (reported, not forced)

- **`cli/cmd/ao/codex_runtime.go`** — the codex runtime *lifecycle
profile* (`HookCapable`/`HookConfigured` detection) is a
runtime-capability abstraction used by 6 `validate-codex-*` CI gates,
distinct from the hook product. Deleting it is a separate refactor.
- **`hooks-authoring` skill** + `schemas/hooks-manifest.v1.schema.json`
— reframed as an opt-in "author your own hooks" guide. Deleting the
skill cascades into catalog/domain-map/dispositions/context-map golden
files (skill-count sync), out of scope for the hook-product removal.
- **`scripts/pre-push-gate.sh`** — retired local gate (not in CI);
self-skips deleted hook scripts via `[[ -x ]]` guards; its 55 bats tests
still pass.
- Domain-enforcement audit keeps the `enforced`-mode schema for
backward-compatible JSON readers, but the hookless resolver only returns
`audited`/`unavailable`.

## Verification

`go build` / `go vet` clean; `go test ./...` = **11849 passed, 0
failed** (68 pkgs). gofmt clean on all touched files. Green: registry
`--check` (0 hooks), `regen-codex-hashes --check`,
`validate-ci-policy-parity`, `check-wiring-closure`,
`validate-embedded-sync`, `validate-manifests`, `validate-agents-split`,
`doc-release` (0 broken links), `generate-cli-reference --check`,
`heal.sh --strict`, codex/claude/plugin smoke tests, baseline-audit (0
stale). Diff: 231 files, +354 / −39803.

Closes-scenario: soc-57b7f#remove-all-hooks
Bounded-context: BC5-Runtime
Evidence: .github/workflows/validate.yml
2026-05-24 11:19:37 -04:00

283 lines
7.7 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
SCRIPT="$ROOT/scripts/install-codex-plugin.sh"
PASS=0
FAIL=0
pass() { echo "PASS: $1"; PASS=$((PASS + 1)); }
fail() { echo "FAIL: $1"; FAIL=$((FAIL + 1)); }
if [[ ! -f "$SCRIPT" ]]; then
echo "FAIL: missing script: $SCRIPT" >&2
exit 1
fi
TMP_DIR="$(mktemp -d)"
trap 'rm -rf "$TMP_DIR"' EXIT
setup_fixture() {
local fixture="$1"
mkdir -p \
"$fixture/.codex-plugin" \
"$fixture/lib" \
"$fixture/plugins" \
"$fixture/skills-codex/research" \
"$fixture/skills-codex/heal-skill/scripts"
cat > "$fixture/.codex-plugin/plugin.json" <<'EOF'
{
"name": "agentops",
"skills": "./skills-codex"
}
EOF
cat > "$fixture/plugins/marketplace.json" <<'EOF'
{
"name": "agentops-marketplace",
"plugins": [
{
"name": "agentops",
"source": {
"source": "local",
"path": "./"
}
}
]
}
EOF
/bin/cp "$ROOT/lib/ao-paths.sh" "$fixture/lib/ao-paths.sh"
/bin/cp "$ROOT/lib/chain-parser.sh" "$fixture/lib/chain-parser.sh"
cat > "$fixture/skills-codex/research/SKILL.md" <<'EOF'
---
name: research
description: fixture
---
EOF
cat > "$fixture/skills-codex/research/prompt.md" <<'EOF'
# research
EOF
cat > "$fixture/skills-codex/heal-skill/SKILL.md" <<'EOF'
---
name: heal-skill
description: fixture
---
EOF
cat > "$fixture/skills-codex/heal-skill/prompt.md" <<'EOF'
# heal-skill
EOF
cat > "$fixture/skills-codex/heal-skill/scripts/heal.sh" <<'EOF'
#!/usr/bin/env bash
exit 0
EOF
chmod +x "$fixture/skills-codex/heal-skill/scripts/heal.sh"
cat > "$fixture/skills-codex/research/.agentops-generated.json" <<'EOF'
{
"generator": "manual-maintained",
"source_skill": "skills/research",
"layout": "modular",
"source_hash": "fixture-source",
"generated_hash": "fixture-generated"
}
EOF
cat > "$fixture/skills-codex/heal-skill/.agentops-generated.json" <<'EOF'
{
"generator": "manual-maintained",
"source_skill": "skills/heal-skill",
"layout": "modular",
"source_hash": "fixture-source",
"generated_hash": "fixture-generated"
}
EOF
cat > "$fixture/skills-codex/.agentops-manifest.json" <<'EOF'
{
"generator": "manual-maintained",
"source_root": "skills",
"layout": "modular",
"skills": [
{
"name": "heal-skill",
"source_skill": "skills/heal-skill",
"source_hash": "fixture-source",
"generated_hash": "fixture-generated"
},
{
"name": "research",
"source_skill": "skills/research",
"source_hash": "fixture-source",
"generated_hash": "fixture-generated"
}
]
}
EOF
}
run_install() {
local fixture="$1"
local codex_home="$2"
shift 2
bash "$SCRIPT" \
--repo-root "$fixture" \
--codex-home "$codex_home" \
--version "fixture-version" \
--update-command "fixture-update" \
"$@" >/dev/null
}
test_installs_plugin_cache_and_config() {
local fixture="$TMP_DIR/install"
local codex_home="$TMP_DIR/codex-home"
local plugin_root="$codex_home/plugins/cache/agentops-marketplace/agentops/local"
local user_skills_root="$TMP_DIR/.agents/skills"
setup_fixture "$fixture"
mkdir -p "$codex_home"
cat > "$codex_home/config.toml" <<'EOF'
[features]
codex_hooks = true
EOF
if ! run_install "$fixture" "$codex_home"; then
fail "install should succeed"
return
fi
[[ -f "$plugin_root/.codex-plugin/plugin.json" ]] || {
fail "plugin manifest copied into cache"
return
}
[[ -f "$plugin_root/skills-codex/research/SKILL.md" ]] || {
fail "skills copied into plugin cache"
return
}
[[ ! -e "$user_skills_root/research/SKILL.md" ]] || {
fail "native plugin install should not leave AgentOps raw skills in ~/.agents/skills"
return
}
[[ ! -e "$codex_home/skills/research/SKILL.md" ]] || {
fail "install should not recreate CODEX_HOME/skills AgentOps mirror"
return
}
[[ -f "$plugin_root/.agentops-codex-state.json" ]] || {
fail "plugin state file written"
return
}
[[ -f "$codex_home/config.toml" ]] || {
fail "config.toml written"
return
}
if rg -q '^\[features\]$' "$codex_home/config.toml" && \
rg -q '^plugins = true$' "$codex_home/config.toml" && \
rg -q '^\[ui\]$' "$codex_home/config.toml" && \
rg -q '^suppress_unstable_features_warning = true$' "$codex_home/config.toml" && \
rg -q '^\[plugins\."agentops@agentops-marketplace"\]$' "$codex_home/config.toml" && \
rg -q '^enabled = true$' "$codex_home/config.toml" && \
! rg -q '^codex_hooks[[:space:]]*=' "$codex_home/config.toml" && \
! rg -q '^hooks = true$' "$codex_home/config.toml" && \
! [[ -f "$codex_home/hooks.json" ]] && \
rg -q '"hook_runtime": "hookless-default"' "$codex_home/.agentops-codex-install.json" && \
rg -q '"hooks_installed": false' "$codex_home/.agentops-codex-install.json" && \
rg -q '"user_skills_root": null' "$codex_home/.agentops-codex-install.json"; then
pass "installs plugin cache and migrates deprecated codex_hooks config"
else
fail "config.toml missing plugin enablement"
fi
}
test_archives_agentops_codex_home_skills_without_touching_custom_skills() {
local fixture="$TMP_DIR/archive"
local codex_home="$TMP_DIR/archive-home"
local legacy_skills="$codex_home/skills"
setup_fixture "$fixture"
mkdir -p "$legacy_skills/research" "$legacy_skills/custom-skill"
cat > "$legacy_skills/research/SKILL.md" <<'EOF'
legacy
EOF
cat > "$legacy_skills/custom-skill/SKILL.md" <<'EOF'
custom
EOF
if ! run_install "$fixture" "$codex_home"; then
fail "install with legacy raw skills should succeed"
return
fi
if [[ -e "$legacy_skills/research/SKILL.md" ]]; then
fail "managed AgentOps raw skill should be removed from ~/.codex/skills"
return
fi
if [[ ! -e "$legacy_skills/custom-skill/SKILL.md" ]]; then
fail "non-AgentOps custom skill should remain in ~/.codex/skills"
return
fi
if ! find "$codex_home" -maxdepth 1 -type d -name 'skills.backup.*' | grep -q .; then
fail "expected archived AgentOps ~/.codex/skills backup"
return
fi
pass "archives AgentOps ~/.codex/skills entries without touching custom skill folders"
}
test_archives_home_agents_agentops_skills_without_touching_custom_skills() {
local fixture="$TMP_DIR/home-agents"
local home_dir="$TMP_DIR/home-agents-root"
local codex_home="$home_dir/.codex"
local user_skills_root="$home_dir/.agents/skills"
setup_fixture "$fixture"
mkdir -p "$user_skills_root/research" "$user_skills_root/custom-skill"
cat > "$user_skills_root/.agentops-codex-state.json" <<'EOF'
{"install_mode":"managed-raw-skills"}
EOF
cat > "$user_skills_root/research/SKILL.md" <<'EOF'
official
EOF
cat > "$user_skills_root/custom-skill/SKILL.md" <<'EOF'
custom
EOF
if ! HOME="$home_dir" run_install "$fixture" "$codex_home"; then
fail "install with ~/.agents/skills should succeed"
return
fi
if [[ -e "$user_skills_root/research/SKILL.md" ]]; then
fail "plugin install should archive managed AgentOps skills out of ~/.agents/skills"
return
fi
if [[ ! -f "$user_skills_root/custom-skill/SKILL.md" ]]; then
fail "plugin install should not remove custom ~/.agents/skills folders"
return
fi
if ! find "$home_dir/.agents" -maxdepth 1 -type d -name 'skills.backup.*' | grep -q .; then
fail "expected archived AgentOps ~/.agents/skills backup"
return
fi
pass "plugin install archives AgentOps skills without touching custom ~/.agents/skills folders"
}
echo "== test-codex-plugin-install =="
test_installs_plugin_cache_and_config
test_archives_agentops_codex_home_skills_without_touching_custom_skills
test_archives_home_agents_agentops_skills_without_touching_custom_skills
echo ""
echo "Results: $PASS PASS, $FAIL FAIL"
if [[ "$FAIL" -gt 0 ]]; then
exit 1
fi
exit 0