Skip to content
Merged
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: 1 addition & 12 deletions plugins/asta-preview/hooks/approve-asta-bash.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
#!/bin/bash
# Auto-approve Bash commands that operate on ~/.asta/ directories or use asta CLI
# Auto-approve the asta CLI itself.

INPUT=$(cat)
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // ""')

# Auto-approve asta CLI commands (literature and papers)
if [[ "$COMMAND" == asta\ * ]]; then
echo '{"hookSpecificOutput":{"hookEventName":"PermissionRequest","decision":{"behavior":"allow"}}}'
exit 0
fi

# Check if command references ~/.asta/ or $HOME/.asta/ paths
if [[ "$COMMAND" == *"/.asta/"* ]] || [[ "$COMMAND" == *'~/.asta/'* ]]; then
# Additional safety: only approve read-only commands like jq, cat, ls
# or directory creation like mkdir
if [[ "$COMMAND" == jq* ]] || [[ "$COMMAND" == "mkdir -p ~/.asta"* ]] || [[ "$COMMAND" == *"| jq"* ]]; then
echo '{"hookSpecificOutput":{"hookEventName":"PermissionRequest","decision":{"behavior":"allow"}}}'
exit 0
fi
fi

echo '{}'
25 changes: 19 additions & 6 deletions plugins/asta-preview/hooks/approve-asta-files.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
#!/bin/bash
# Auto-approve Read/Write/Edit operations on ~/.asta/ directories
# Auto-approve any tool operation targeting a .asta/ directory under
# the user's home directory ($HOME / ~) or the current working directory.
# Handles Read/Write/Edit via file_path/path and Bash via the command string.

INPUT=$(cat)
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.path // ""')
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // ""')

# Expand ~ to $HOME for comparison
# Expand a leading ~ in FILE_PATH for the home-directory check.
EXPANDED_PATH="${FILE_PATH/#\~/$HOME}"

# Check if path is under ~/.asta/ (handles both ~/... and /Users/.../... forms)
if [[ "$EXPANDED_PATH" == "$HOME/.asta/"* ]] || [[ "$FILE_PATH" == *"/.asta/"* ]]; then
# FILE_PATH: under HOME (after ~ expansion) or CWD-relative.
if [[ "$EXPANDED_PATH" == "$HOME/.asta/"* ]] \
|| [[ "$FILE_PATH" == ".asta/"* ]] \
|| [[ "$FILE_PATH" == "./.asta/"* ]]; then
echo '{"hookSpecificOutput":{"hookEventName":"PermissionRequest","decision":{"behavior":"allow"}}}'
else
echo '{}'
exit 0
fi

# COMMAND: a token (at start or after whitespace) that names .asta/ under
# HOME (~/.asta/ or $HOME/.asta/) or CWD (.asta/ or ./.asta/).
if [[ "$COMMAND" =~ (^|[[:space:]])(~/|${HOME}/|\./)?\.asta/ ]]; then
echo '{"hookSpecificOutput":{"hookEventName":"PermissionRequest","decision":{"behavior":"allow"}}}'
exit 0
fi

echo '{}'
12 changes: 12 additions & 0 deletions plugins/asta-preview/hooks/approve-bd-bash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
# Auto-approve beads CLI commands (research-step skill uses bd dozens of times per session)

INPUT=$(cat)
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // ""')

if [[ "$COMMAND" == bd\ * ]]; then
echo '{"hookSpecificOutput":{"hookEventName":"PermissionRequest","decision":{"behavior":"allow"}}}'
exit 0
fi

echo '{}'
6 changes: 5 additions & 1 deletion plugins/asta-preview/hooks/hooks.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
],
"PermissionRequest": [
{
"matcher": "Read|Write|Edit",
"matcher": "Read|Write|Edit|Bash",
"hooks": [
{
"type": "command",
Expand All @@ -31,6 +31,10 @@
{
"type": "command",
"command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/approve-asta-bash.sh"
},
{
"type": "command",
"command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/approve-bd-bash.sh"
}
]
}
Expand Down
13 changes: 1 addition & 12 deletions plugins/asta/hooks/approve-asta-bash.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
#!/bin/bash
# Auto-approve Bash commands that operate on ~/.asta/ directories or use asta CLI
# Auto-approve the asta CLI itself.

INPUT=$(cat)
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // ""')

# Auto-approve asta CLI commands (literature and papers)
if [[ "$COMMAND" == asta\ * ]]; then
echo '{"hookSpecificOutput":{"hookEventName":"PermissionRequest","decision":{"behavior":"allow"}}}'
exit 0
fi

# Check if command references ~/.asta/ or $HOME/.asta/ paths
if [[ "$COMMAND" == *"/.asta/"* ]] || [[ "$COMMAND" == *'~/.asta/'* ]]; then
# Additional safety: only approve read-only commands like jq, cat, ls
# or directory creation like mkdir
if [[ "$COMMAND" == jq* ]] || [[ "$COMMAND" == "mkdir -p ~/.asta"* ]] || [[ "$COMMAND" == *"| jq"* ]]; then
echo '{"hookSpecificOutput":{"hookEventName":"PermissionRequest","decision":{"behavior":"allow"}}}'
exit 0
fi
fi

echo '{}'
25 changes: 19 additions & 6 deletions plugins/asta/hooks/approve-asta-files.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
#!/bin/bash
# Auto-approve Read/Write/Edit operations on ~/.asta/ directories
# Auto-approve any tool operation targeting a .asta/ directory under
# the user's home directory ($HOME / ~) or the current working directory.
# Handles Read/Write/Edit via file_path/path and Bash via the command string.

INPUT=$(cat)
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.path // ""')
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // ""')

# Expand ~ to $HOME for comparison
# Expand a leading ~ in FILE_PATH for the home-directory check.
EXPANDED_PATH="${FILE_PATH/#\~/$HOME}"

# Check if path is under ~/.asta/ (handles both ~/... and /Users/.../... forms)
if [[ "$EXPANDED_PATH" == "$HOME/.asta/"* ]] || [[ "$FILE_PATH" == *"/.asta/"* ]]; then
# FILE_PATH: under HOME (after ~ expansion) or CWD-relative.
if [[ "$EXPANDED_PATH" == "$HOME/.asta/"* ]] \
|| [[ "$FILE_PATH" == ".asta/"* ]] \
|| [[ "$FILE_PATH" == "./.asta/"* ]]; then
echo '{"hookSpecificOutput":{"hookEventName":"PermissionRequest","decision":{"behavior":"allow"}}}'
else
echo '{}'
exit 0
fi

# COMMAND: a token (at start or after whitespace) that names .asta/ under
# HOME (~/.asta/ or $HOME/.asta/) or CWD (.asta/ or ./.asta/).
if [[ "$COMMAND" =~ (^|[[:space:]])(~/|${HOME}/|\./)?\.asta/ ]]; then
echo '{"hookSpecificOutput":{"hookEventName":"PermissionRequest","decision":{"behavior":"allow"}}}'
exit 0
fi

echo '{}'
12 changes: 12 additions & 0 deletions plugins/asta/hooks/approve-bd-bash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
# Auto-approve beads CLI commands (research-step skill uses bd dozens of times per session)

INPUT=$(cat)
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // ""')

if [[ "$COMMAND" == bd\ * ]]; then
echo '{"hookSpecificOutput":{"hookEventName":"PermissionRequest","decision":{"behavior":"allow"}}}'
exit 0
fi

echo '{}'
6 changes: 5 additions & 1 deletion plugins/asta/hooks/hooks.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
],
"PermissionRequest": [
{
"matcher": "Read|Write|Edit",
"matcher": "Read|Write|Edit|Bash",
"hooks": [
{
"type": "command",
Expand All @@ -31,6 +31,10 @@
{
"type": "command",
"command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/approve-asta-bash.sh"
},
{
"type": "command",
"command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/approve-bd-bash.sh"
}
]
}
Expand Down
Loading
Loading