safemode 2.0.0 → 2.0.1

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.
Files changed (2) hide show
  1. package/README.md +172 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,172 @@
1
+ # Safe Mode
2
+
3
+ Stop your AI coding agent from doing something you'll regret.
4
+
5
+ ```bash
6
+ npx safemode init
7
+ ```
8
+
9
+ Safe Mode is a governance layer that sits between your AI coding agent and your system. It intercepts every tool call — file writes, shell commands, git operations, API calls — and blocks the dangerous ones before they execute.
10
+
11
+ Works with **Claude Code**, **Cursor**, and **Windsurf**. Free and open source (Apache-2.0).
12
+
13
+ ## What it blocks
14
+
15
+ - `rm -rf /` and other destructive shell commands
16
+ - Secrets and API keys leaving your machine
17
+ - PII in tool call parameters
18
+ - Unauthorized git pushes, force operations
19
+ - Package installs with known vulnerabilities
20
+ - Prompt injection attempts in tool outputs
21
+ - Runaway loops and cost spikes
22
+
23
+ ## How it works
24
+
25
+ ```
26
+ Your prompt → AI Agent → Tool Call → Safe Mode → Allow/Block → System
27
+ ```
28
+
29
+ Every tool call passes through a governance pipeline:
30
+
31
+ 1. **CET Classification** — categorizes the action (read/write/delete/execute/network)
32
+ 2. **Rules Engine** — custom rules from your config
33
+ 3. **Knob Gate** — preset-based permission checks (19 knob categories)
34
+ 4. **15 Detection Engines** — loop detection, secrets scanning, PII detection, command firewall, budget caps, and more
35
+
36
+ The hook runs as an esbuild bundle. Cold start is ~50ms. You won't notice it.
37
+
38
+ ## Install
39
+
40
+ ```bash
41
+ npm install -g safemode
42
+ safemode init
43
+ ```
44
+
45
+ `safemode init` does three things:
46
+ 1. Scans your project for exposed secrets
47
+ 2. Writes a config file to `~/.safemode/config.yaml`
48
+ 3. Installs hooks into your IDE (Claude Code, Cursor, Windsurf)
49
+
50
+ Restart your IDE after init.
51
+
52
+ ## Presets
53
+
54
+ ```bash
55
+ safemode preset <name>
56
+ ```
57
+
58
+ | Preset | Description |
59
+ |--------|-------------|
60
+ | `yolo` | Log everything, block nothing |
61
+ | `coding` | Block destructive ops, allow reads/writes (default) |
62
+ | `personal` | Block secrets, PII, and destructive ops |
63
+ | `trading` | Strict financial safety — block network, packages, git |
64
+ | `strict` | Block everything that isn't a read |
65
+
66
+ ## CLI
67
+
68
+ ```bash
69
+ safemode init # Set up Safe Mode
70
+ safemode status # Hook status, preset, cloud connection
71
+ safemode doctor # Health check
72
+ safemode history # View recent events
73
+ safemode history --json # Machine-readable output
74
+ safemode preset coding # Switch preset
75
+ safemode allow secrets --once # Temporarily allow a blocked action
76
+ safemode restore # Roll back files from Time Machine
77
+ safemode restore --list # List available restore points
78
+ safemode phone --telegram # Set up block notifications
79
+ safemode uninstall # Remove hooks and restore configs
80
+ ```
81
+
82
+ ## False positive? One command.
83
+
84
+ ```bash
85
+ safemode allow <action> --once # Allow for this session
86
+ safemode allow <action> --always # Allow permanently
87
+ ```
88
+
89
+ Actions: `secrets`, `pii`, `delete`, `write`, `git`, `network`, `packages`, `commands`
90
+
91
+ ## Time Machine
92
+
93
+ Every file your AI agent modifies is snapshotted before the write happens. If something goes wrong:
94
+
95
+ ```bash
96
+ safemode restore # Restore most recent session
97
+ safemode restore 14:31 # Restore to a specific time
98
+ safemode restore -s <id> # Restore a specific session
99
+ ```
100
+
101
+ Snapshots use `git stash create` in git repos (zero worktree impact) with file copy as fallback.
102
+
103
+ ## Custom rules
104
+
105
+ Add rules to `.safemode.yaml` in your project root:
106
+
107
+ ```yaml
108
+ rules:
109
+ - name: block-production-db
110
+ conditions:
111
+ - field: parameters.command
112
+ operator: contains
113
+ value: "prod-db"
114
+ action: block
115
+ message: "No production database access"
116
+ ```
117
+
118
+ ## Phone notifications
119
+
120
+ Get notified on Telegram or Discord when Safe Mode blocks something:
121
+
122
+ ```bash
123
+ safemode phone --telegram # Set up Telegram
124
+ safemode phone --discord # Set up Discord
125
+ safemode phone --test # Send a test notification
126
+ ```
127
+
128
+ ## Detection engines
129
+
130
+ | # | Engine | What it catches |
131
+ |---|--------|----------------|
132
+ | 1 | Loop Killer | Repeated identical tool calls |
133
+ | 2 | Oscillation | Write-undo-write cycles |
134
+ | 3 | Velocity Limiter | Too many calls per minute |
135
+ | 4 | Cost Exposure | Session cost exceeding budget |
136
+ | 5 | Action Growth | Escalating permission requests |
137
+ | 6 | Latency Spike | Abnormal response times |
138
+ | 7 | Error Rate | Sustained error patterns |
139
+ | 8 | Throughput Drop | Sudden drops in success rate |
140
+ | 9 | PII Scanner | SSNs, credit cards, emails in params |
141
+ | 10 | Secrets Scanner | AWS keys, tokens, passwords |
142
+ | 11 | Prompt Injection | Injection attempts in tool outputs |
143
+ | 12 | Jailbreak | Attempts to bypass safety controls |
144
+ | 13 | Command Firewall | Dangerous shell commands (rm -rf, chmod 777, etc.) |
145
+ | 14 | Budget Cap | Hard spending limits |
146
+ | 15 | Action-Label Mismatch | Tool says "read" but actually writes |
147
+
148
+ ## Config
149
+
150
+ Personal config: `~/.safemode/config.yaml`
151
+ Project config: `.safemode.yaml` (project root, overrides personal)
152
+
153
+ Project rules are stricter — they can only tighten permissions, never loosen them.
154
+
155
+ ## Requirements
156
+
157
+ - Node.js >= 18
158
+ - One of: Claude Code, Cursor, Windsurf
159
+
160
+ ## Cloud (optional)
161
+
162
+ Connect to [TrustScope](https://trustscope.ai) for team policy management, centralized audit logs, and a dashboard:
163
+
164
+ ```bash
165
+ safemode connect -k ts_your_api_key
166
+ ```
167
+
168
+ The CLI works fully offline. Cloud is optional.
169
+
170
+ ## License
171
+
172
+ Apache-2.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "safemode",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Stop your AI coding agent from doing something you'll regret.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",