Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions claude-code/bundle/pre-tool-use.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,15 +438,12 @@ function getShellCommand(toolName, toolInput) {
const cmd = toolInput.command;
if (!cmd || !touchesMemory(cmd))
break;
{
const rewritten = rewritePaths(cmd);
if (!isSafe(rewritten)) {
log3(`unsafe command blocked: ${rewritten}`);
return null;
}
return rewritten;
const rewritten = rewritePaths(cmd);
if (!isSafe(rewritten)) {
log3(`unsafe command blocked: ${rewritten}`);
return null;
}
break;
return rewritten;
}
case "Glob": {
const p = toolInput.path;
Expand Down
19 changes: 6 additions & 13 deletions src/hooks/pre-tool-use.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node

import { existsSync } from "node:fs";
import { appendFileSync, existsSync } from "node:fs";
import { join } from "node:path";
import { homedir } from "node:os";
import { fileURLToPath } from "node:url";
Expand Down Expand Up @@ -107,15 +107,12 @@ function getShellCommand(toolName: string, toolInput: Record<string, unknown>):
case "Bash": {
const cmd = toolInput.command as string | undefined;
if (!cmd || !touchesMemory(cmd)) break;
{
const rewritten = rewritePaths(cmd);
if (!isSafe(rewritten)) {
log(`unsafe command blocked: ${rewritten}`);
return null;
}
return rewritten;
const rewritten = rewritePaths(cmd);
if (!isSafe(rewritten)) {
log(`unsafe command blocked: ${rewritten}`);
return null;
}
break;
return rewritten;
}
case "Glob": {
const p = toolInput.path as string | undefined;
Expand All @@ -138,10 +135,6 @@ async function main(): Promise<void> {
// Also check non-Bash tools (Read/Write/Edit/Glob/Grep) that touch memory but didn't get a shellCmd
const toolPath = (input.tool_input.file_path ?? input.tool_input.path ?? "") as string;
if (!shellCmd && (touchesMemory(cmd) || touchesMemory(toolPath))) {
// Instead of denying (which triggers alarm loops in Claude Code), return
// an "allow" with guidance that tells the agent to retry with bash.
// Uses stdout so the agent sees it as output (not a fatal error), but
// prefixed with [RETRY] to signal it should try again differently.
const guidance = "[RETRY REQUIRED] The command you tried is not available for ~/.deeplake/memory/. " +
"This virtual filesystem only supports bash builtins: cat, ls, grep, echo, jq, head, tail, sed, awk, wc, sort, find, etc. " +
"python, python3, node, and curl are NOT available. " +
Expand Down
Loading