-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopsentry.rb
More file actions
83 lines (77 loc) · 2.87 KB
/
Copy pathopsentry.rb
File metadata and controls
83 lines (77 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Homebrew formula for OpSentry
# To use: brew tap opsight-intelligence/opsentry && brew install opsentry
#
# This formula installs the OpSentry CLI wrapper + all guardrail scripts
# from the community repo. After install, run: opsentry install
class Opsentry < Formula
desc "AI agent security guardrails for engineering teams"
homepage "https://github.com/opsight-intelligence/opsentry"
url "https://github.com/opsight-intelligence/opsentry/archive/refs/tags/v1.8.9.tar.gz"
sha256 "a24f151113727a9c5b8c3a7659df6a5afe614d8e3c61dc41d0b11db26e482736"
license "Apache-2.0"
depends_on "jq"
depends_on "python@3.11"
def install
# Install the entire community repo tree into libexec. Scripts inside
# resolve their own SCRIPT_DIR relative to their own location, so
# nothing needs to be rewritten after install.
libexec.install Dir["*"]
# Create a thin CLI wrapper that dispatches to the appropriate script
# inside libexec/opsentry/. Subcommands: install, verify, update,
# patrol, test, --version, --help.
(bin/"opsentry").write <<~EOS
#!/bin/bash
set -euo pipefail
OPSENTRY_LIBEXEC="#{libexec}"
cmd="${1:-}"
if [ "$#" -gt 0 ]; then shift; fi
case "$cmd" in
install)
exec bash "$OPSENTRY_LIBEXEC/opsentry/install.sh" "$@"
;;
verify)
exec bash "$OPSENTRY_LIBEXEC/opsentry/verify.sh" "$@"
;;
update)
exec bash "$OPSENTRY_LIBEXEC/opsentry/update.sh" "$@"
;;
patrol)
exec bash "$OPSENTRY_LIBEXEC/opsentry/patrol.sh" "$@"
;;
test)
exec bash "$OPSENTRY_LIBEXEC/opsentry/test.sh" "$@"
;;
--version|-v|version)
cat "$OPSENTRY_LIBEXEC/VERSION"
;;
""|--help|-h|help)
printf '%s\\n' \\
"opsentry -- AI agent security guardrails for Claude Code" \\
"" \\
"Usage: opsentry <command> [args]" \\
"" \\
"Commands:" \\
" install Install guardrails to ~/.claude/" \\
" verify Verify installation integrity" \\
" update Pull the latest version and re-install" \\
" patrol Run the compliance patrol audit" \\
" test Run the hook test suite" \\
" --version Show installed version" \\
" --help Show this help"
exit 0
;;
*)
echo "opsentry: unknown command '$cmd'" >&2
echo "Run 'opsentry --help' for usage." >&2
exit 1
;;
esac
EOS
end
test do
# Verify the wrapper is wired up and VERSION is readable.
assert_match(/^\d+\.\d+\.\d+$/, shell_output("#{bin}/opsentry --version").strip)
# Verify the help text mentions the install subcommand.
assert_match "install", shell_output("#{bin}/opsentry --help")
end
end