start-vibing 2.0.32 → 2.0.33
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/package.json
CHANGED
|
@@ -1225,7 +1225,7 @@ WORKFLOW
|
|
|
1225
1225
|
// continue: true tells Claude to KEEP WORKING after receiving this block
|
|
1226
1226
|
const result: HookResult = { continue: true, decision: 'block', reason: blockReason.trim() };
|
|
1227
1227
|
console.log(JSON.stringify(result));
|
|
1228
|
-
process.exit(
|
|
1228
|
+
process.exit(0); // Must be 0 for JSON to be processed - exit 2 ignores JSON!
|
|
1229
1229
|
}
|
|
1230
1230
|
|
|
1231
1231
|
// All validations passed
|
|
@@ -107,10 +107,12 @@ Event-specific fields:
|
|
|
107
107
|
|
|
108
108
|
| Code | Meaning | Behavior |
|
|
109
109
|
|------|---------|----------|
|
|
110
|
-
| 0 | Success | stdout
|
|
111
|
-
| 2 | Blocking error | stderr
|
|
110
|
+
| 0 | Success | JSON stdout is processed (decision, reason, continue fields) |
|
|
111
|
+
| 2 | Blocking error | JSON stdout is IGNORED, only stderr shown to Claude |
|
|
112
112
|
| Other | Non-blocking error | Hook failed, but doesn't block |
|
|
113
113
|
|
|
114
|
+
**IMPORTANT for Stop Hooks:** To make Claude CONTINUE working after a block, use exit(0) with `decision: "block"` in JSON. Exit code 2 ignores JSON, so Claude just stops instead of fixing issues.
|
|
115
|
+
|
|
114
116
|
---
|
|
115
117
|
|
|
116
118
|
## Environment Variables
|
|
@@ -164,13 +166,20 @@ const cmd = `cat ${filePath}`; // WRONG - injection risk
|
|
|
164
166
|
### Error Handling
|
|
165
167
|
|
|
166
168
|
```typescript
|
|
167
|
-
// For
|
|
169
|
+
// For Stop hooks - use JSON with decision: "block" + exit(0)
|
|
170
|
+
// This makes Claude CONTINUE working to fix the issues
|
|
168
171
|
if (validationFailed) {
|
|
169
|
-
|
|
170
|
-
process.exit(
|
|
172
|
+
console.log(JSON.stringify({ decision: 'block', reason: errorMessage }));
|
|
173
|
+
process.exit(0); // Must be 0 for JSON to be processed!
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// For PreToolUse hooks - exit(2) blocks the specific tool operation
|
|
177
|
+
if (dangerousOperation) {
|
|
178
|
+
process.stderr.write('BLOCKED: Dangerous operation');
|
|
179
|
+
process.exit(2); // Blocks this tool call only
|
|
171
180
|
}
|
|
172
181
|
|
|
173
|
-
// For non-blocking
|
|
182
|
+
// For non-blocking warnings
|
|
174
183
|
if (warningCondition) {
|
|
175
184
|
console.error('Warning:', message);
|
|
176
185
|
process.exit(1); // Logs but doesn't block
|
|
@@ -199,20 +208,24 @@ async function main(): Promise<void> {
|
|
|
199
208
|
const error = validateSomething();
|
|
200
209
|
|
|
201
210
|
if (error) {
|
|
202
|
-
// Block
|
|
203
|
-
|
|
211
|
+
// Block and make Claude CONTINUE working to fix the issue
|
|
212
|
+
// IMPORTANT: Use exit(0) so JSON is processed. exit(2) ignores JSON!
|
|
213
|
+
const result: HookResult = {
|
|
214
|
+
decision: 'block',
|
|
215
|
+
reason: `
|
|
204
216
|
ERROR: ${error.type}
|
|
205
217
|
|
|
206
218
|
${error.message}
|
|
207
219
|
|
|
208
220
|
REQUIRED ACTION:
|
|
209
221
|
Task(subagent_type="${error.agent}", prompt="${error.prompt}")
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
222
|
+
`
|
|
223
|
+
};
|
|
224
|
+
console.log(JSON.stringify(result));
|
|
225
|
+
process.exit(0); // Must be 0 for JSON to be processed!
|
|
213
226
|
}
|
|
214
227
|
|
|
215
|
-
// Success
|
|
228
|
+
// Success - allow task completion
|
|
216
229
|
const result: HookResult = { decision: 'approve', reason: 'All checks passed' };
|
|
217
230
|
console.log(JSON.stringify(result));
|
|
218
231
|
process.exit(0);
|
|
@@ -289,8 +302,12 @@ const validations = [
|
|
|
289
302
|
|
|
290
303
|
const firstError = validations.find(v => v !== null);
|
|
291
304
|
if (firstError) {
|
|
292
|
-
|
|
293
|
-
|
|
305
|
+
// Use JSON with decision: "block" + exit(0) so Claude CONTINUES fixing
|
|
306
|
+
console.log(JSON.stringify({
|
|
307
|
+
decision: 'block',
|
|
308
|
+
reason: formatError(firstError)
|
|
309
|
+
}));
|
|
310
|
+
process.exit(0); // NOT exit(2) - that ignores JSON!
|
|
294
311
|
}
|
|
295
312
|
```
|
|
296
313
|
|