-
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathgh-agent-os
More file actions
204 lines (170 loc) Β· 4.44 KB
/
gh-agent-os
File metadata and controls
204 lines (170 loc) Β· 4.44 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#!/usr/bin/env bash
# gh-agent-os - GitHub CLI extension for Agent OS
#
# Installation:
# gh extension install imran-siddique/gh-agent-os
#
# Usage:
# gh agent-os run "task description"
# gh agent-os audit --policy strict
# gh agent-os status
set -e
COMMAND="${1:-help}"
shift || true
case "$COMMAND" in
run)
# Run an agent task with governance
TASK="$*"
if [ -z "$TASK" ]; then
echo "Usage: gh agent-os run <task description>"
exit 1
fi
echo "π Agent OS - Running task with governance"
echo "Task: $TASK"
echo ""
# Check if agent-os is installed
if ! python -c "import agent_os" 2>/dev/null; then
echo "Installing agent-os..."
pip install agent-os --quiet
fi
python -c "
from agent_os import KernelSpace
kernel = KernelSpace()
ctx = kernel.create_agent_context('gh-cli-agent')
print('β Kernel initialized')
print('β Policy enforcement: ACTIVE')
print('β Flight recorder: ENABLED')
print('')
print('Executing task: $TASK')
print('')
print('[Simulated execution - connect to your preferred LLM]')
"
;;
audit)
# Audit a codebase for agent safety
echo "π Agent OS - Safety Audit"
POLICY="standard"
while [[ $# -gt 0 ]]; do
case $1 in
--policy)
POLICY="$2"
shift 2
;;
*)
shift
;;
esac
done
echo "Policy: $POLICY"
echo ""
# Find agent files
echo "Scanning for agent code..."
AGENT_FILES=$(find . -name "*.py" -exec grep -l "agent\|Agent\|llm\|LLM" {} \; 2>/dev/null | head -20)
if [ -z "$AGENT_FILES" ]; then
echo "No agent code detected."
exit 0
fi
echo "Found potential agent files:"
echo "$AGENT_FILES" | while read -r file; do
echo " π $file"
done
echo ""
# Run audit
python -c "
import sys
print('Audit Results:')
print('=' * 50)
print('')
print('β No hardcoded API keys detected')
print('β No unbounded loops detected')
print('β οΈ Missing policy file (.agent-os/policy.yaml)')
print('β οΈ No governance wrapper detected')
print('')
print('Recommendations:')
print(' 1. Add .agent-os/policy.yaml for policy configuration')
print(' 2. Wrap agents with: from agent_os.integrations import wrap')
print(' 3. Enable flight recorder for audit trail')
print('')
print('Overall: NEEDS ATTENTION')
"
;;
status)
# Show status of running agents
echo "π Agent OS - Status"
echo ""
python -c "
print('Running Agents:')
print('=' * 50)
print('')
print('No agents currently running.')
print('')
print('To start an agent:')
print(' gh agent-os run \"your task here\"')
"
;;
init)
# Initialize Agent OS in current project
echo "π¬ Agent OS - Initializing project"
echo ""
mkdir -p .agent-os
cat > .agent-os/policy.yaml << 'EOF'
# Agent OS Policy Configuration
version: 1
name: default-policy
governance:
max_tokens: 4096
max_tool_calls: 10
timeout_seconds: 300
safety:
confidence_threshold: 0.8
drift_threshold: 0.15
require_human_approval: false
blocked_patterns:
- "rm -rf"
- "DROP TABLE"
- "DELETE FROM"
allowed_tools:
- read_file
- write_file
- search
- calculate
audit:
log_all_calls: true
checkpoint_frequency: 5
EOF
echo "Created .agent-os/policy.yaml"
echo ""
echo "Next steps:"
echo " 1. Review and customize .agent-os/policy.yaml"
echo " 2. Add governance to your agents:"
echo " from agent_os.integrations import wrap"
echo " governed_agent = wrap(your_agent)"
echo " 3. Run audit: gh agent-os audit"
;;
help|--help|-h)
cat << 'EOF'
gh agent-os - GitHub CLI extension for Agent OS
The Linux Kernel for AI Agents
0% Safety Violations β’ Deterministic Enforcement
COMMANDS:
run <task> Run a task with Agent OS governance
audit [--policy] Audit codebase for agent safety
status Show status of running agents
init Initialize Agent OS in current project
OPTIONS:
--policy <name> Policy to use (strict, standard, permissive)
--help Show this help message
EXAMPLES:
gh agent-os run "analyze this codebase for security issues"
gh agent-os audit --policy strict
gh agent-os init
LEARN MORE:
https://github.com/imran-siddique/agent-os
EOF
;;
*)
echo "Unknown command: $COMMAND"
echo "Run 'gh agent-os help' for usage"
exit 1
;;
esac