safe-agent-cli 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- safe_agent_cli-0.2.0/.github/workflows/analytics.yml +42 -0
- safe_agent_cli-0.2.0/.github/workflows/safe-agent-preview.yml +42 -0
- safe_agent_cli-0.2.0/.gitignore +47 -0
- safe_agent_cli-0.2.0/.well-known/agent.json +33 -0
- safe_agent_cli-0.2.0/AGENTS.md +53 -0
- safe_agent_cli-0.2.0/LICENSE +21 -0
- safe_agent_cli-0.2.0/PKG-INFO +11 -0
- safe_agent_cli-0.2.0/README.md +214 -0
- safe_agent_cli-0.2.0/experiments/experiments.csv +2 -0
- safe_agent_cli-0.2.0/llms.txt +48 -0
- safe_agent_cli-0.2.0/marketing/README.md +7 -0
- safe_agent_cli-0.2.0/marketing/demo.cast +27 -0
- safe_agent_cli-0.2.0/marketing/demo.gif +0 -0
- safe_agent_cli-0.2.0/moltbook-skill.json +72 -0
- safe_agent_cli-0.2.0/pyproject.toml +59 -0
- safe_agent_cli-0.2.0/server.json +29 -0
- safe_agent_cli-0.2.0/src/safe_agent/__init__.py +12 -0
- safe_agent_cli-0.2.0/src/safe_agent/agent.py +309 -0
- safe_agent_cli-0.2.0/src/safe_agent/cli.py +107 -0
- safe_agent_cli-0.2.0/src/safe_agent/demo.py +123 -0
- safe_agent_cli-0.2.0/src/safe_agent/demo_cli.py +98 -0
- safe_agent_cli-0.2.0/src/safe_agent/marketing.py +431 -0
- safe_agent_cli-0.2.0/src/safe_agent/marketing_cli.py +197 -0
- safe_agent_cli-0.2.0/src/safe_agent/mcp_server.py +284 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
name: Safe Agent Analytics (scheduled)
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
schedule:
|
|
5
|
+
- cron: "0 14 * * 1-5" # 09:00 US Eastern Mon-Fri
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
concurrency:
|
|
12
|
+
group: safe-agent-analytics
|
|
13
|
+
cancel-in-progress: true
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
analytics:
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
steps:
|
|
19
|
+
- name: Checkout
|
|
20
|
+
uses: actions/checkout@v4
|
|
21
|
+
|
|
22
|
+
- name: Set up Python
|
|
23
|
+
uses: actions/setup-python@v5
|
|
24
|
+
with:
|
|
25
|
+
python-version: "3.11"
|
|
26
|
+
|
|
27
|
+
- name: Install Safe Agent
|
|
28
|
+
run: |
|
|
29
|
+
python -m pip install --upgrade pip
|
|
30
|
+
pip install .
|
|
31
|
+
|
|
32
|
+
- name: Run analytics
|
|
33
|
+
env:
|
|
34
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
35
|
+
run: |
|
|
36
|
+
safe-agent-marketing analytics --repo agent-polis/safe-agent --log experiments/experiments.csv
|
|
37
|
+
|
|
38
|
+
- name: Upload analytics log
|
|
39
|
+
uses: actions/upload-artifact@v4
|
|
40
|
+
with:
|
|
41
|
+
name: experiments-log-${{ github.run_id }}
|
|
42
|
+
path: experiments/experiments.csv
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
name: Safe Agent Preview (manual)
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
inputs:
|
|
6
|
+
task:
|
|
7
|
+
description: "Task for Safe Agent to dry-run"
|
|
8
|
+
required: true
|
|
9
|
+
default: "scan repository for risky configuration changes; DO NOT edit files, only preview"
|
|
10
|
+
|
|
11
|
+
concurrency:
|
|
12
|
+
group: safe-agent-preview-${{ github.ref }}
|
|
13
|
+
cancel-in-progress: false
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
preview:
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
steps:
|
|
19
|
+
- name: Checkout
|
|
20
|
+
uses: actions/checkout@v4
|
|
21
|
+
|
|
22
|
+
- name: Set up Python
|
|
23
|
+
uses: actions/setup-python@v5
|
|
24
|
+
with:
|
|
25
|
+
python-version: "3.11"
|
|
26
|
+
|
|
27
|
+
- name: Install Safe Agent
|
|
28
|
+
run: |
|
|
29
|
+
python -m pip install --upgrade pip
|
|
30
|
+
pip install .
|
|
31
|
+
|
|
32
|
+
- name: Run Safe Agent (dry-run)
|
|
33
|
+
env:
|
|
34
|
+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
35
|
+
run: |
|
|
36
|
+
safe-agent --dry-run "${{ github.event.inputs.task }}" | tee safe-agent.log
|
|
37
|
+
|
|
38
|
+
- name: Upload log
|
|
39
|
+
uses: actions/upload-artifact@v4
|
|
40
|
+
with:
|
|
41
|
+
name: safe-agent-preview-log
|
|
42
|
+
path: safe-agent.log
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
.Python
|
|
7
|
+
build/
|
|
8
|
+
develop-eggs/
|
|
9
|
+
dist/
|
|
10
|
+
downloads/
|
|
11
|
+
eggs/
|
|
12
|
+
.eggs/
|
|
13
|
+
lib/
|
|
14
|
+
lib64/
|
|
15
|
+
parts/
|
|
16
|
+
sdist/
|
|
17
|
+
var/
|
|
18
|
+
wheels/
|
|
19
|
+
*.egg-info/
|
|
20
|
+
.installed.cfg
|
|
21
|
+
*.egg
|
|
22
|
+
|
|
23
|
+
# Virtual environments
|
|
24
|
+
.env
|
|
25
|
+
.venv
|
|
26
|
+
env/
|
|
27
|
+
venv/
|
|
28
|
+
ENV/
|
|
29
|
+
|
|
30
|
+
# IDE
|
|
31
|
+
.idea/
|
|
32
|
+
.vscode/
|
|
33
|
+
*.swp
|
|
34
|
+
*.swo
|
|
35
|
+
|
|
36
|
+
# Testing
|
|
37
|
+
.pytest_cache/
|
|
38
|
+
.coverage
|
|
39
|
+
htmlcov/
|
|
40
|
+
|
|
41
|
+
# OS
|
|
42
|
+
.DS_Store
|
|
43
|
+
Thumbs.db
|
|
44
|
+
|
|
45
|
+
# Project specific
|
|
46
|
+
*.log
|
|
47
|
+
cursor_digital_polis_for_agents_concept.md
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Safe Agent",
|
|
3
|
+
"description": "An AI coding agent with built-in impact preview - see exactly what will change before any file is modified",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"url": "https://github.com/agent-polis/safe-agent",
|
|
6
|
+
"capabilities": [
|
|
7
|
+
"code_generation",
|
|
8
|
+
"file_modification",
|
|
9
|
+
"impact_preview",
|
|
10
|
+
"risk_assessment"
|
|
11
|
+
],
|
|
12
|
+
"installation": {
|
|
13
|
+
"method": "pip",
|
|
14
|
+
"command": "pip install safe-agent"
|
|
15
|
+
},
|
|
16
|
+
"usage": {
|
|
17
|
+
"cli": "safe-agent \"your task here\"",
|
|
18
|
+
"python": "from safe_agent import SafeAgent; agent = SafeAgent(); await agent.run(task)"
|
|
19
|
+
},
|
|
20
|
+
"requires": {
|
|
21
|
+
"api_key": "ANTHROPIC_API_KEY",
|
|
22
|
+
"python": ">=3.11"
|
|
23
|
+
},
|
|
24
|
+
"author": "Agent Polis Contributors",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"related": [
|
|
27
|
+
{
|
|
28
|
+
"name": "impact-preview",
|
|
29
|
+
"url": "https://github.com/agent-polis/impact-preview",
|
|
30
|
+
"relationship": "dependency"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Agent Instructions for Safe Agent
|
|
2
|
+
|
|
3
|
+
This file provides instructions for AI agents (like Cursor, Claude, GPT) working with this codebase.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
Safe Agent is an AI coding assistant with built-in safety checks. It uses the `impact-preview` library to analyze file changes before executing them.
|
|
8
|
+
|
|
9
|
+
## Architecture
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
safe-agent/
|
|
13
|
+
├── src/safe_agent/
|
|
14
|
+
│ ├── __init__.py # Exports SafeAgent class
|
|
15
|
+
│ ├── cli.py # Click-based CLI entry point
|
|
16
|
+
│ └── agent.py # Core SafeAgent class with Claude integration
|
|
17
|
+
├── pyproject.toml # Package config, dependencies
|
|
18
|
+
└── README.md # User documentation
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Key Components
|
|
22
|
+
|
|
23
|
+
### SafeAgent Class (`agent.py`)
|
|
24
|
+
|
|
25
|
+
The main class that orchestrates:
|
|
26
|
+
1. Task planning via Claude API
|
|
27
|
+
2. Impact analysis via `agent_polis.actions.analyzer`
|
|
28
|
+
3. User approval flow via Rich console
|
|
29
|
+
4. File execution
|
|
30
|
+
|
|
31
|
+
### CLI (`cli.py`)
|
|
32
|
+
|
|
33
|
+
Entry point `safe-agent` with options:
|
|
34
|
+
- `--dry-run`: Preview only
|
|
35
|
+
- `--auto-approve-low`: Skip approval for low-risk changes
|
|
36
|
+
- `--interactive`: Multi-line input mode
|
|
37
|
+
|
|
38
|
+
## Development Guidelines
|
|
39
|
+
|
|
40
|
+
1. **Imports**: The package `impact-preview` on PyPI uses module name `agent_polis` internally
|
|
41
|
+
2. **Async**: The `SafeAgent.run()` method is async
|
|
42
|
+
3. **Testing**: Use `--dry-run` flag to test without making changes
|
|
43
|
+
|
|
44
|
+
## How to Extend
|
|
45
|
+
|
|
46
|
+
To add new action types:
|
|
47
|
+
1. Add handling in `_preview_and_approve()` method
|
|
48
|
+
2. Map to appropriate `ActionType` from `agent_polis.actions.models`
|
|
49
|
+
|
|
50
|
+
## Related Projects
|
|
51
|
+
|
|
52
|
+
- `impact-preview`: Safety analysis library (https://github.com/agent-polis/impact-preview)
|
|
53
|
+
- MCP server available in impact-preview for Claude Desktop integration
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Agent Polis Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: safe-agent-cli
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: An AI coding agent you can actually trust - with built-in impact preview
|
|
5
|
+
Project-URL: Homepage, https://github.com/agent-polis/safe-agent
|
|
6
|
+
Project-URL: Repository, https://github.com/agent-polis/safe-agent
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Provides-Extra: dev
|
|
9
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
|
|
10
|
+
Requires-Dist: pytest>=7.4.0; extra == 'dev'
|
|
11
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# 🛡️ Safe Agent
|
|
2
|
+
|
|
3
|
+
<!-- HERO_START -->
|
|
4
|
+
**Guardrails for AI code agents.**
|
|
5
|
+
|
|
6
|
+
Safe Agent previews every file edit with [impact-preview](https://github.com/agent-polis/impact-preview) so AI helpers can’t quietly ship risky changes. Drop it into CI or run locally and require approvals before writes.
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
pip install safe-agent
|
|
10
|
+
safe-agent "add error handling to api.py" --dry-run
|
|
11
|
+
```
|
|
12
|
+
<!-- HERO_END -->
|
|
13
|
+
|
|
14
|
+
## The Problem
|
|
15
|
+
|
|
16
|
+
AI coding agents are powerful but dangerous:
|
|
17
|
+
- **Replit Agent** deleted a production database
|
|
18
|
+
- **Cursor YOLO mode** deleted an entire system
|
|
19
|
+
- You can't see what's about to happen until it's too late
|
|
20
|
+
|
|
21
|
+
## The Solution
|
|
22
|
+
|
|
23
|
+
Safe Agent previews every change before execution:
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
$ safe-agent "update database config to use production"
|
|
27
|
+
|
|
28
|
+
📋 Task: update database config to use production
|
|
29
|
+
|
|
30
|
+
📝 Planned Changes
|
|
31
|
+
┌────────┬─────────────────┬─────────────────────────┐
|
|
32
|
+
│ Action │ File │ Description │
|
|
33
|
+
├────────┼─────────────────┼─────────────────────────┤
|
|
34
|
+
│ MODIFY │ config/db.yaml │ Update database URL │
|
|
35
|
+
└────────┴─────────────────┴─────────────────────────┘
|
|
36
|
+
|
|
37
|
+
Step 1/1
|
|
38
|
+
|
|
39
|
+
╭─────────────── Impact Preview ───────────────╮
|
|
40
|
+
│ Update database URL │
|
|
41
|
+
│ │
|
|
42
|
+
│ **File:** `config/db.yaml` │
|
|
43
|
+
│ **Action:** MODIFY │
|
|
44
|
+
│ **Risk:** 🔴 CRITICAL │
|
|
45
|
+
╰──────────────────────────────────────────────╯
|
|
46
|
+
|
|
47
|
+
Risk Factors:
|
|
48
|
+
⚠️ Production pattern detected: production
|
|
49
|
+
⚠️ Database configuration change
|
|
50
|
+
|
|
51
|
+
Diff:
|
|
52
|
+
- url: postgresql://localhost:5432/dev
|
|
53
|
+
+ url: postgresql://prod-server:5432/production
|
|
54
|
+
|
|
55
|
+
⚠️ CRITICAL RISK - Please review carefully!
|
|
56
|
+
Apply this change? [y/N]:
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Installation
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
pip install safe-agent
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Set your Anthropic API key:
|
|
66
|
+
```bash
|
|
67
|
+
export ANTHROPIC_API_KEY=your-key-here
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Usage
|
|
71
|
+
|
|
72
|
+
### Basic Usage
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
# Run a coding task
|
|
76
|
+
safe-agent "add input validation to user registration"
|
|
77
|
+
|
|
78
|
+
# Preview only (no execution)
|
|
79
|
+
safe-agent "refactor auth module" --dry-run
|
|
80
|
+
|
|
81
|
+
# Auto-approve low-risk changes
|
|
82
|
+
safe-agent "add docstrings" --auto-approve-low
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Interactive Mode
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
safe-agent --interactive
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### From File
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
safe-agent --file task.md
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## How It Works
|
|
98
|
+
|
|
99
|
+
1. **Plan** - Claude analyzes your task and plans file changes
|
|
100
|
+
2. **Preview** - Each change runs through impact-preview for risk analysis
|
|
101
|
+
3. **Approve** - You see the diff and risk level before anything executes
|
|
102
|
+
4. **Execute** - Only approved changes are applied
|
|
103
|
+
|
|
104
|
+
## Options
|
|
105
|
+
|
|
106
|
+
| Flag | Description |
|
|
107
|
+
|------|-------------|
|
|
108
|
+
| `--dry-run` | Preview changes without executing |
|
|
109
|
+
| `--auto-approve-low` | Auto-approve low-risk changes |
|
|
110
|
+
| `--interactive`, `-i` | Interactive mode |
|
|
111
|
+
| `--file`, `-f` | Read task from file |
|
|
112
|
+
| `--model` | Claude model to use (default: claude-sonnet-4-20250514) |
|
|
113
|
+
|
|
114
|
+
## MCP Server (For Other AI Agents)
|
|
115
|
+
|
|
116
|
+
Safe Agent can be used as an MCP server, letting other AI agents delegate coding tasks safely.
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
# Start the MCP server
|
|
120
|
+
safe-agent-mcp
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Claude Desktop Integration
|
|
124
|
+
|
|
125
|
+
Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
|
|
126
|
+
|
|
127
|
+
```json
|
|
128
|
+
{
|
|
129
|
+
"mcpServers": {
|
|
130
|
+
"safe-agent": {
|
|
131
|
+
"command": "safe-agent-mcp"
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Available MCP Tools
|
|
138
|
+
|
|
139
|
+
| Tool | Description | Safety |
|
|
140
|
+
|------|-------------|--------|
|
|
141
|
+
| `run_coding_task` | Execute a coding task with preview | 🔴 Destructive |
|
|
142
|
+
| `preview_coding_task` | Preview changes without executing | 🟢 Read-only |
|
|
143
|
+
| `get_agent_status` | Check agent status and capabilities | 🟢 Read-only |
|
|
144
|
+
|
|
145
|
+
## Moltbook Integration
|
|
146
|
+
|
|
147
|
+
Safe Agent is available as a [Moltbook](https://moltbook.com) skill for AI agent networks.
|
|
148
|
+
|
|
149
|
+
See `moltbook-skill.json` for the skill definition.
|
|
150
|
+
|
|
151
|
+
## Demo Producer
|
|
152
|
+
|
|
153
|
+
Set up a canned risky-edit scenario and print recording commands:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
safe-agent-demo prepare # creates a demo repo with config/db.yaml
|
|
157
|
+
cd /tmp/safe-agent-demo-* # or your chosen path
|
|
158
|
+
safe-agent-demo record # shows asciinema + GIF commands
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
By default the demo runs `safe-agent --dry-run "switch database config to production"` against the prepared repo.
|
|
162
|
+
|
|
163
|
+

|
|
164
|
+
|
|
165
|
+
## For AI Agents
|
|
166
|
+
|
|
167
|
+
If you're an AI agent wanting to use Safe Agent programmatically:
|
|
168
|
+
|
|
169
|
+
```python
|
|
170
|
+
from safe_agent import SafeAgent
|
|
171
|
+
|
|
172
|
+
agent = SafeAgent(
|
|
173
|
+
auto_approve_low_risk=True, # Skip approval for low-risk changes
|
|
174
|
+
dry_run=False, # Set True to preview only
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
result = await agent.run("add error handling to api.py")
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Powered By
|
|
181
|
+
|
|
182
|
+
- [impact-preview](https://github.com/agent-polis/impact-preview) - Impact analysis and diff generation
|
|
183
|
+
- [Claude](https://anthropic.com) - AI planning and code generation
|
|
184
|
+
- [Rich](https://github.com/Textualize/rich) - Beautiful terminal output
|
|
185
|
+
- [MCP](https://modelcontextprotocol.io) - Model Context Protocol for agent interoperability
|
|
186
|
+
|
|
187
|
+
## Marketing Helpers
|
|
188
|
+
|
|
189
|
+
A lightweight CLI to generate headline variants, channel-specific copy (HN, Twitter/X, LinkedIn), and README hero blocks:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
safe-agent-marketing generate --audience "Teams running AI code agents in CI" \
|
|
193
|
+
--hypothesis "Guardrail that blocks risky edits" --update-readme
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
This writes JSON/Markdown bundles to `marketing/` and (optionally) refreshes the README hero block. Queue posts with:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
safe-agent-marketing queue --slot 2026-02-05T15:00:00Z --slot 2026-02-05T20:00:00Z
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Log traction daily:
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
safe-agent-marketing analytics --repo agent-polis/safe-agent --log experiments/experiments.csv
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## License
|
|
209
|
+
|
|
210
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
Built by developers who want AI agents they can actually trust.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Safe Agent
|
|
2
|
+
|
|
3
|
+
> An AI coding agent you can actually trust - with built-in impact preview.
|
|
4
|
+
|
|
5
|
+
## What This Is
|
|
6
|
+
|
|
7
|
+
Safe Agent is a CLI tool that wraps AI coding tasks with safety checks. Before any file is modified, it shows you exactly what will change and asks for approval.
|
|
8
|
+
|
|
9
|
+
## How to Use
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install safe-agent
|
|
13
|
+
export ANTHROPIC_API_KEY=your-key
|
|
14
|
+
safe-agent "add error handling to api.py"
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Key Features
|
|
18
|
+
|
|
19
|
+
- **Impact Preview**: See diffs before any file changes
|
|
20
|
+
- **Risk Assessment**: Files like `.env`, `production.py`, credentials flagged as high-risk
|
|
21
|
+
- **Approval Flow**: Approve, reject, or auto-approve low-risk changes
|
|
22
|
+
- **Dry Run Mode**: Preview without executing
|
|
23
|
+
|
|
24
|
+
## For AI Agents
|
|
25
|
+
|
|
26
|
+
If you are an AI agent that wants to use Safe Agent:
|
|
27
|
+
|
|
28
|
+
1. Install: `pip install safe-agent`
|
|
29
|
+
2. Set `ANTHROPIC_API_KEY` environment variable
|
|
30
|
+
3. Call via subprocess or import `SafeAgent` class directly
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from safe_agent import SafeAgent
|
|
34
|
+
|
|
35
|
+
agent = SafeAgent(auto_approve_low_risk=True)
|
|
36
|
+
result = await agent.run("your task here")
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Dependencies
|
|
40
|
+
|
|
41
|
+
- impact-preview: The underlying safety library (https://pypi.org/project/impact-preview/)
|
|
42
|
+
- anthropic: Claude API client
|
|
43
|
+
|
|
44
|
+
## Links
|
|
45
|
+
|
|
46
|
+
- GitHub: https://github.com/agent-polis/safe-agent
|
|
47
|
+
- PyPI: https://pypi.org/project/safe-agent/ (coming soon)
|
|
48
|
+
- Parent project: https://github.com/agent-polis/impact-preview
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Marketing artifacts live here:
|
|
2
|
+
- `latest_assets.json` — structured output from `safe-agent-marketing generate`
|
|
3
|
+
- `latest_assets.md` — readable summary of the same bundle
|
|
4
|
+
- `queue.csv` — posting queue generated by `safe-agent-marketing queue`
|
|
5
|
+
- `demo.cast` / `demo.gif` — recorded Safe Agent demo (generated via `safe-agent-demo`)
|
|
6
|
+
|
|
7
|
+
These files are generated; feel free to delete/regenerate as experiments evolve.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{"version":3,"term":{"cols":80,"rows":24},"timestamp":1770088287,"command":"safe-agent --dry-run 'switch database config to production'","title":"Safe Agent Guardrail Demo","env":{"SHELL":"/bin/zsh"}}
|
|
2
|
+
[0.901, "o", "\u001b[34m╭─\u001b[0m\u001b[34m─────────────────────────────────\u001b[0m\u001b[34m 📋 Task \u001b[0m\u001b[34m──────────────────────────────────\u001b[0m\u001b[34m─╮\u001b[0m\r\n\u001b[34m│\u001b[0m switch database config to production \u001b[34m│\u001b[0m\r\n\u001b[34m╰──────────────────────────────────────────────────────────────────────────────╯\u001b[0m\r\n"]
|
|
3
|
+
[0.029, "o", "\r\n\u001b[1m🤖 Planning changes\u001b[0m\u001b[1;33m...\u001b[0m\r\n\r\n"]
|
|
4
|
+
[4.012, "o", "HTTP Request: POST https://api.anthropic.com/v1/messages \"HTTP/1.1 200 OK\"\r\n"]
|
|
5
|
+
[0.016, "o", "\u001b[3m 📝 Planned Changes \u001b[0m\r\n┏━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\r\n┃\u001b[1m \u001b[0m\u001b[1mAction\u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1mFile \u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1mDescription \u001b[0m\u001b[1m \u001b[0m┃\r\n┡━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩\r\n│\u001b[36m \u001b[0m\u001b[33mMODIFY\u001b[0m\u001b[36m \u001b[0m│\u001b[37m \u001b[0m\u001b[37mconfig/db.yaml\u001b[0m\u001b[37m \u001b[0m│\u001b[2m \u001b[0m\u001b[2mUpdate database configuration to use production se\u001b[0m\u001b[2m \u001b[0m│\r\n└────────┴────────────────┴────────────"]
|
|
6
|
+
[0.000, "o", "────────────────────────────────────────┘\r\n"]
|
|
7
|
+
[0.001, "o", "\r\n\u001b[1mStep \u001b[0m\u001b[1;36m1\u001b[0m\u001b[1m/\u001b[0m\u001b[1;36m1\u001b[0m\r\n"]
|
|
8
|
+
[0.000, "o", "{\"action_type\": \"file_write\", \"target\": \"/private/tmp/safe-agent-demo/config/db.yaml\", \"event\": \"Analyzing action\", \"level\": \"info\", \"logger\": \"agent_polis.actions.analyzer\", \"timestamp\": \"2026-02-03T03:11:32.385166Z\"}\r\n"]
|
|
9
|
+
[0.003, "o", "\u001b[33m╭─\u001b[0m\u001b[33m──────────────────────────────\u001b[0m\u001b[33m Impact Preview \u001b[0m\u001b[33m──────────────────────────────\u001b[0m\u001b[33m─╮\u001b[0m\r\n\u001b[33m│\u001b[0m \u001b[1mUpdate database configuration to use production settings\u001b[0m \u001b[33m│\u001b[0m\r\n\u001b[33m│\u001b[0m \u001b[33m│\u001b[0m\r\n\u001b[33m│\u001b[0m **File:** `config/db.yaml` \u001b[33m│\u001b[0m\r\n\u001b[33m│\u001b[0m **Action:** MODIFY \u001b[33m│\u001b[0m\r\n\u001b[33m│\u001b[0m **Risk:** 🟠 HIGH \u001b[33m│\u001b[0m\r\n\u001b[33m╰─────────────────────────────────────────────────────────────────────────────"]
|
|
10
|
+
[0.000, "o", "─╯\u001b[0m\r\n"]
|
|
11
|
+
[0.000, "o", "\u001b[1mRisk Factors:\u001b[0m\r\n"]
|
|
12
|
+
[0.001, "o", " ⚠️ Critical pattern detected: production\r\n"]
|
|
13
|
+
[0.000, "o", " ⚠️ Critical pattern detected: database\r\n"]
|
|
14
|
+
[0.000, "o", " ⚠️ Critical pattern detected: db_password\r\n"]
|
|
15
|
+
[0.000, "o", " ⚠️ System directory\r\n"]
|
|
16
|
+
[0.000, "o", "\r\n\u001b[1mDiff:\u001b[0m\r\n"]
|
|
17
|
+
[0.005, "o", "\u001b[97;40m============================================================\u001b[0m\u001b[40m \u001b[0m\r\n\u001b[97;40mFile: /private/tmp/safe-agent-demo/config/db.yaml\u001b[0m\u001b[40m \u001b[0m\r\n\u001b[97;40mOperation: modify\u001b[0m\u001b[40m \u001b[0m\r\n\u001b[97;40mChanges: +10 -1\u001b[0m\u001b[40m \u001b[0m\r\n\u001b[40m \u001b[0m\r\n\u001b[91;40m--- a//private/tmp/safe-agent-demo/config/db.yaml\u001b[0m\u001b[40m \u001b[0m\r\n\u001b[92;40m+++ b//private/tmp/safe-agent-demo/config/db.yaml\u001b[0m\u001b[40m \u001b[0m\r\n\u001b[37;40m@@ -1 +1,10 @@\u001b[0m\u001b[40m \u001b[0m\r\n\u001b[91;40m-url: postgresql://localhost:5432/dev\u001b[0m\u001b[40m \u001b[0m\r\n\u001b[92;40m+database:\u001b[0m\u001b[40m \u001b[0m\r\n\u001b[92;4"]
|
|
18
|
+
[0.000, "o", "0m+ host: prod-db.example.com\u001b[0m\u001b[40m \u001b[0m\r\n\u001b[92;40m+ port: 5432\u001b[0m\u001b[40m \u001b[0m\r\n\u001b[92;40m+ name: production_db\u001b[0m\u001b[40m \u001b[0m\r\n\u001b[92;40m+ user: prod_user\u001b[0m\u001b[40m \u001b[0m\r\n\u001b[92;40m+ password: ${PROD_DB_PASSWORD}\u001b[0m\u001b[40m \u001b[0m\r\n\u001b[92;40m+ ssl: true\u001b[0m\u001b[40m \u001b[0m\r\n\u001b[92;40m+ pool_size: 20\u001b[0m\u001b[40m \u001b[0m\r\n\u001b[92;40m+ timeout: 30\u001b[0m\u001b[40m \u001b[0m\r\n\u001b[92;40m+ environment: production\u001b[0m\u001b[40m \u001b[0m\r\n\u001b[40m \u001b[0m\r\n\u001b[40m "]
|
|
19
|
+
[0.000, "o", " \u001b[0m\r\n"]
|
|
20
|
+
[0.000, "o", "\r\n"]
|
|
21
|
+
[0.000, "o", "\u001b[33mDry run - not executing\u001b[0m\r\n"]
|
|
22
|
+
[0.000, "o", "\u001b[33mSkipped\u001b[0m\r\n"]
|
|
23
|
+
[0.001, "o", "\r\n==================================================\r\n"]
|
|
24
|
+
[0.000, "o", "\u001b[1mSummary\u001b[0m\r\n\r\n"]
|
|
25
|
+
[0.000, "o", "\u001b[33m⊘ \u001b[0m\u001b[1;33m1\u001b[0m\u001b[33m changes skipped\u001b[0m\r\n"]
|
|
26
|
+
[0.000, "o", " - modify: config/db.yaml\r\n"]
|
|
27
|
+
[0.220, "x", "0"]
|
|
Binary file
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://moltbook.com/schemas/skill-v1.json",
|
|
3
|
+
"name": "safe-agent",
|
|
4
|
+
"display_name": "Safe Agent",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"description": "Delegate coding tasks to a trusted AI agent with built-in impact preview. See exactly what will change before any file is modified.",
|
|
7
|
+
"author": "agent-polis",
|
|
8
|
+
"homepage": "https://github.com/agent-polis/safe-agent",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
|
|
11
|
+
"capabilities": [
|
|
12
|
+
"code_generation",
|
|
13
|
+
"file_modification",
|
|
14
|
+
"impact_preview",
|
|
15
|
+
"risk_assessment"
|
|
16
|
+
],
|
|
17
|
+
|
|
18
|
+
"tags": ["coding", "safety", "developer-tools", "automation", "file-management"],
|
|
19
|
+
|
|
20
|
+
"installation": {
|
|
21
|
+
"method": "pip",
|
|
22
|
+
"package": "safe-agent",
|
|
23
|
+
"command": "pip install safe-agent"
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
"configuration": {
|
|
27
|
+
"required_env": ["ANTHROPIC_API_KEY"],
|
|
28
|
+
"optional_env": []
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
"mcp_server": {
|
|
32
|
+
"command": "safe-agent-mcp",
|
|
33
|
+
"transport": "stdio"
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
"tools": [
|
|
37
|
+
{
|
|
38
|
+
"name": "run_coding_task",
|
|
39
|
+
"description": "Execute a coding task with safety checks and impact preview",
|
|
40
|
+
"destructive": true,
|
|
41
|
+
"requires_approval": true
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"name": "preview_coding_task",
|
|
45
|
+
"description": "Preview what changes a task would make without executing",
|
|
46
|
+
"destructive": false,
|
|
47
|
+
"requires_approval": false
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"name": "get_agent_status",
|
|
51
|
+
"description": "Check safe-agent status and capabilities",
|
|
52
|
+
"destructive": false,
|
|
53
|
+
"requires_approval": false
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
|
|
57
|
+
"prompts": {
|
|
58
|
+
"system_addition": "You have access to Safe Agent, a coding assistant with built-in safety checks. Before making file changes, always use preview_coding_task to see what will change. Only use run_coding_task when you're confident the changes are correct.",
|
|
59
|
+
"usage_hint": "When delegating coding work, prefer preview_coding_task first to understand the scope, then run_coding_task with dry_run=true, then finally run_coding_task to execute."
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
"trust_level": "verified",
|
|
63
|
+
"safety_rating": "high",
|
|
64
|
+
|
|
65
|
+
"related_skills": [
|
|
66
|
+
{
|
|
67
|
+
"name": "impact-preview",
|
|
68
|
+
"relationship": "dependency",
|
|
69
|
+
"url": "https://github.com/agent-polis/impact-preview"
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
}
|