deliberate 1.0.2 → 1.0.4
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.
- package/README.md +12 -3
- package/bin/cli.js +50 -16
- package/hooks/__pycache__/deliberate-changes.cpython-312.pyc +0 -0
- package/hooks/__pycache__/deliberate-commands.cpython-312.pyc +0 -0
- package/hooks/deliberate-commands.py +171 -217
- package/opencode/deliberate-changes-plugin.js +170 -0
- package/opencode/deliberate-plugin.js +174 -0
- package/package.json +2 -1
- package/src/install.js +134 -2
- package/src/uninstall.js +62 -7
package/README.md
CHANGED
|
@@ -111,7 +111,7 @@ npm install -g deliberate
|
|
|
111
111
|
deliberate install
|
|
112
112
|
```
|
|
113
113
|
|
|
114
|
-
The installer walks you through LLM provider setup (Claude, Anthropic API, or Ollama).
|
|
114
|
+
The installer sets up Claude Code hooks and the OpenCode plugin, then walks you through LLM provider setup (Claude, Anthropic API, or Ollama). If OpenCode is installed, it registers two `file://` plugins (commands + changes) in `~/.config/opencode/opencode.json`.
|
|
115
115
|
|
|
116
116
|
### Dependencies
|
|
117
117
|
|
|
@@ -126,7 +126,7 @@ The CmdCaliper embedding model (~419MB) downloads on first use.
|
|
|
126
126
|
## CLI
|
|
127
127
|
|
|
128
128
|
```bash
|
|
129
|
-
deliberate install # Install hooks, configure LLM
|
|
129
|
+
deliberate install # Install Claude Code hooks + OpenCode plugin, configure LLM
|
|
130
130
|
deliberate status # Check installation
|
|
131
131
|
deliberate classify "rm -rf /" # Test classification → DANGEROUS
|
|
132
132
|
deliberate serve # Start classifier server (faster)
|
|
@@ -159,10 +159,19 @@ python training/build_classifier.py --model base # Retrain
|
|
|
159
159
|
|
|
160
160
|
- Node.js 18+
|
|
161
161
|
- Python 3.9+
|
|
162
|
-
- Claude Code
|
|
162
|
+
- Claude Code or OpenCode 1.0+
|
|
163
163
|
|
|
164
164
|
Works on macOS, Linux, and Windows.
|
|
165
165
|
|
|
166
|
+
## OpenCode
|
|
167
|
+
|
|
168
|
+
OpenCode support is installed by `deliberate install`. It registers two plugins in `~/.config/opencode/opencode.json`:
|
|
169
|
+
|
|
170
|
+
- `file://~/.config/opencode/plugins/deliberate.js` (command safety)
|
|
171
|
+
- `file://~/.config/opencode/plugins/deliberate-changes.js` (edit/change summaries)
|
|
172
|
+
|
|
173
|
+
After install, restart OpenCode to load the plugins. For edit/change summaries, OpenCode must be configured to allow edit tools (write/edit/patch/multiedit) so the plugin can read tool metadata. The plugins call the same Deliberate hook scripts, so LLM explanations behave the same as Claude Code.
|
|
174
|
+
|
|
166
175
|
## Uninstall
|
|
167
176
|
|
|
168
177
|
```bash
|
package/bin/cli.js
CHANGED
|
@@ -21,7 +21,7 @@ program
|
|
|
21
21
|
|
|
22
22
|
program
|
|
23
23
|
.command('install')
|
|
24
|
-
.description('Install hooks and configure Claude Code integration')
|
|
24
|
+
.description('Install hooks and configure Claude Code/OpenCode integration')
|
|
25
25
|
.action(async () => {
|
|
26
26
|
await install();
|
|
27
27
|
});
|
|
@@ -49,7 +49,7 @@ program
|
|
|
49
49
|
.action(async () => {
|
|
50
50
|
console.log('Deliberate Status\n');
|
|
51
51
|
|
|
52
|
-
// Check hooks installation
|
|
52
|
+
// Check Claude Code hooks installation
|
|
53
53
|
const claudeSettingsPath = join(homedir(), '.claude', 'settings.json');
|
|
54
54
|
let hooksInstalled = false;
|
|
55
55
|
|
|
@@ -60,21 +60,20 @@ program
|
|
|
60
60
|
const preToolUse = hooks.PreToolUse || [];
|
|
61
61
|
const postToolUse = hooks.PostToolUse || [];
|
|
62
62
|
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
h.command && h.command.includes('explain-changes')
|
|
68
|
-
);
|
|
63
|
+
const hasHookCommand = (entries, needle) =>
|
|
64
|
+
entries.some(entry => Array.isArray(entry.hooks) && entry.hooks.some(hook =>
|
|
65
|
+
hook.command && hook.command.includes(needle)
|
|
66
|
+
));
|
|
69
67
|
|
|
70
|
-
|
|
68
|
+
const hasCommandHook = hasHookCommand(preToolUse, 'deliberate-commands');
|
|
69
|
+
const hasChangesHook = hasHookCommand(postToolUse, 'deliberate-changes');
|
|
70
|
+
const hasCommandPostHook = hasHookCommand(postToolUse, 'deliberate-commands-post');
|
|
71
|
+
|
|
72
|
+
if (hasCommandHook && hasChangesHook && hasCommandPostHook) {
|
|
71
73
|
console.log('Hooks: ✅ Installed (PreToolUse + PostToolUse)');
|
|
72
74
|
hooksInstalled = true;
|
|
73
|
-
} else if (hasCommandHook) {
|
|
74
|
-
console.log('Hooks: ⚠️ Partial (
|
|
75
|
-
hooksInstalled = true;
|
|
76
|
-
} else if (hasChangesHook) {
|
|
77
|
-
console.log('Hooks: ⚠️ Partial (PostToolUse only)');
|
|
75
|
+
} else if (hasCommandHook || hasChangesHook || hasCommandPostHook) {
|
|
76
|
+
console.log('Hooks: ⚠️ Partial (missing some hooks)');
|
|
78
77
|
hooksInstalled = true;
|
|
79
78
|
} else {
|
|
80
79
|
console.log('Hooks: ❌ Not installed');
|
|
@@ -86,6 +85,41 @@ program
|
|
|
86
85
|
console.log('Hooks: ❌ Claude settings not found');
|
|
87
86
|
}
|
|
88
87
|
|
|
88
|
+
// Check OpenCode plugin installation
|
|
89
|
+
const openCodeConfigDir = join(homedir(), '.config', 'opencode');
|
|
90
|
+
const openCodeConfigPaths = [join(openCodeConfigDir, 'opencode.json'), join(openCodeConfigDir, 'opencode.jsonc')];
|
|
91
|
+
const openCodePluginPaths = [
|
|
92
|
+
join(openCodeConfigDir, 'plugins', 'deliberate.js'),
|
|
93
|
+
join(openCodeConfigDir, 'plugins', 'deliberate-changes.js')
|
|
94
|
+
];
|
|
95
|
+
|
|
96
|
+
let openCodeInstalled = false;
|
|
97
|
+
const configPath = openCodeConfigPaths.find(path => existsSync(path));
|
|
98
|
+
|
|
99
|
+
if (configPath) {
|
|
100
|
+
try {
|
|
101
|
+
const config = JSON.parse(readFileSync(configPath, 'utf-8'));
|
|
102
|
+
const plugins = Array.isArray(config.plugin) ? config.plugin.map(String) : [];
|
|
103
|
+
const commandPlugin = plugins.some(entry => entry.includes('deliberate.js'));
|
|
104
|
+
const changesPlugin = plugins.some(entry => entry.includes('deliberate-changes.js'));
|
|
105
|
+
const filesPresent = openCodePluginPaths.every(path => existsSync(path));
|
|
106
|
+
|
|
107
|
+
if (commandPlugin && changesPlugin && filesPresent) {
|
|
108
|
+
console.log('OpenCode: ✅ Installed (commands + changes)');
|
|
109
|
+
openCodeInstalled = true;
|
|
110
|
+
} else if (commandPlugin || changesPlugin || filesPresent) {
|
|
111
|
+
console.log('OpenCode: ⚠️ Partial install');
|
|
112
|
+
openCodeInstalled = true;
|
|
113
|
+
} else {
|
|
114
|
+
console.log('OpenCode: ❌ Not installed');
|
|
115
|
+
}
|
|
116
|
+
} catch (e) {
|
|
117
|
+
console.log('OpenCode: ❌ Error reading opencode.json');
|
|
118
|
+
}
|
|
119
|
+
} else {
|
|
120
|
+
console.log('OpenCode: ❌ Config not found');
|
|
121
|
+
}
|
|
122
|
+
|
|
89
123
|
// Check classifier status
|
|
90
124
|
const classifierStatus = getStatus();
|
|
91
125
|
|
|
@@ -103,8 +137,8 @@ program
|
|
|
103
137
|
|
|
104
138
|
// Overall status
|
|
105
139
|
console.log('');
|
|
106
|
-
if (hooksInstalled) {
|
|
107
|
-
console.log('Status: Ready to protect your
|
|
140
|
+
if (hooksInstalled || openCodeInstalled) {
|
|
141
|
+
console.log('Status: Ready to protect your agent sessions');
|
|
108
142
|
} else {
|
|
109
143
|
console.log('Status: Run "deliberate install" to set up hooks');
|
|
110
144
|
}
|
|
Binary file
|
|
Binary file
|