Skip to content
Open
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
12 changes: 7 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ SLACK_APP_TOKEN=xapp-your-app-token-here
# 3. Slack channel for notifications (optional, defaults to #claude-sessions)
SLACK_CHANNEL=#your-channel-here

# Multi-Session Configuration (Phase 2.5)
# These have sensible defaults, usually don't need to change
SLACK_SOCKET_DIR=/tmp/claude_socks
REGISTRY_DB_PATH=/tmp/claude_sessions/registry.db
SLACK_LOG_DIR=/tmp
# Multi-Session Configuration
# These have sensible defaults in ~/.claude/slack/, usually don't need to change
# Uncomment and modify only if you need custom paths
#
# SLACK_SOCKET_DIR=${HOME}/.claude/slack/sockets
# REGISTRY_DB_PATH=${HOME}/.claude/slack/registry.db
# SLACK_LOG_DIR=${HOME}/.claude/slack/logs

# Optional: VibeTunnel Integration (leave commented unless using VibeTunnel)
# VIBE_TUNNEL_API_URL=https://your-vibetunnel-server.com
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,13 @@ If you still experience issues, ensure your Slack app has all the scopes and eve

```bash
# Check listener logs
tail -f /tmp/slack_listener.log
tail -f ~/.claude/slack/logs/slack_listener.log

# Check hook execution logs
tail -f /tmp/stop_hook_debug.log
tail -f ~/.claude/slack/logs/notification_hook_debug.log

# Check session registry
sqlite3 /tmp/claude_sessions/registry.db "SELECT * FROM sessions;"
sqlite3 ~/.claude/slack/registry.db "SELECT * FROM sessions;"
```

### Common Issues
Expand Down
4 changes: 2 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ grep -E "xoxb-|xapp-" /tmp/*.log
#### Active Session Monitoring
```bash
# List active sessions
sqlite3 /tmp/claude_sessions/registry.db "SELECT * FROM sessions;"
sqlite3 ~/.claude/slack/registry.db "SELECT * FROM sessions;"

# Check for stale sessions
sqlite3 /tmp/claude_sessions/registry.db "SELECT * FROM sessions WHERE updated_at < datetime('now', '-24 hours');"
sqlite3 ~/.claude/slack/registry.db "SELECT * FROM sessions WHERE updated_at < datetime('now', '-24 hours');"
```

### Development Security
Expand Down
43 changes: 41 additions & 2 deletions bin/claude-slack
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,38 @@ YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color

# Parse arguments
SESSION_DESCRIPTION=""
CLAUDE_ARGS=()

while [[ $# -gt 0 ]]; do
case $1 in
-d|--description)
SESSION_DESCRIPTION="$2"
shift 2
;;
-h|--help)
echo "Usage: claude-slack [OPTIONS] [CLAUDE_ARGS...]"
echo ""
echo "Launch Claude Code with Slack integration"
echo ""
echo "Options:"
echo " -d, --description TEXT Optional description for the Slack thread"
echo " -h, --help Show this help message"
echo ""
echo "Examples:"
echo " claude-slack"
echo " claude-slack -d \"Working on auth feature\""
echo " claude-slack --description \"Bug fix for issue #123\""
exit 0
;;
*)
CLAUDE_ARGS+=("$1")
shift
;;
esac
done

# Step 1: Ensure listener is ready
echo -e "${BLUE}Checking Slack integration...${NC}"
if ! "${SCRIPT_DIR}/claude-slack-ensure"; then
Expand Down Expand Up @@ -144,8 +176,15 @@ sleep 2

# Step 4: Launch Claude with the hybrid wrapper
echo -e "${GREEN}Starting Claude with Slack integration...${NC}"
if [ -n "$SESSION_DESCRIPTION" ]; then
echo -e "${BLUE}Description: ${SESSION_DESCRIPTION}${NC}"
fi
echo ""

# Pass all arguments through to the Python wrapper
# Pass description and Claude args to the Python wrapper
cd "$PROJECT_DIR"
exec python3 "$CORE_DIR/claude_wrapper_hybrid.py" "$@"
if [ -n "$SESSION_DESCRIPTION" ]; then
exec python3 "$CORE_DIR/claude_wrapper_hybrid.py" --description "$SESSION_DESCRIPTION" "${CLAUDE_ARGS[@]}"
else
exec python3 "$CORE_DIR/claude_wrapper_hybrid.py" "${CLAUDE_ARGS[@]}"
fi
4 changes: 2 additions & 2 deletions bin/claude-slack-debug
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fi
echo ""

echo "4. Latest Wrapper Log"
LOG_DIR="${HOME}/.local/share/claude-code-integration/logs"
LOG_DIR="${SLACK_LOG_DIR:-$HOME/.claude/slack/logs}"
LATEST_LOG=$(ls -t "$LOG_DIR"/wrapper_*.log 2>/dev/null | head -1)
if [ -n "$LATEST_LOG" ]; then
echo " Log: $LATEST_LOG"
Expand All @@ -51,7 +51,7 @@ fi
echo ""

echo "5. Active Sessions"
SOCKET_DIR="${HOME}/.local/share/claude-code-integration/sockets"
SOCKET_DIR="${SLACK_SOCKET_DIR:-$HOME/.claude/slack/sockets}"
if [ -d "$SOCKET_DIR" ]; then
echo " Sockets in $SOCKET_DIR:"
ls -lh "$SOCKET_DIR"/*.sock 2>/dev/null || echo " No active sessions"
Expand Down
6 changes: 3 additions & 3 deletions bin/claude-slack-listener
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ echo -e "${BLUE}Starting slack_listener.py...${NC}"
LISTENER_LOG="$SLACK_LOG_DIR/slack_listener.log"
> "$LISTENER_LOG" 2>/dev/null || true

# Monitor expects logs at /tmp/slack_listener.log (for event starvation detection)
MONITOR_LOG="/tmp/slack_listener.log"
# Monitor log (same directory as other logs)
MONITOR_LOG="$SLACK_LOG_DIR/slack_listener_monitor.log"
> "$MONITOR_LOG" 2>/dev/null || true

# Start the listener in the background
# NOTE: Removed 'nohup' - it was interfering with Socket Mode WebSocket connections
# Using 'tee' to write to both startup log and monitor log (monitor watches /tmp/slack_listener.log)
# Using 'tee' to write to both startup log and monitor log
cd "$CORE_DIR"
python3 -u slack_listener.py 2>&1 | tee "$MONITOR_LOG" > "$LISTENER_LOG" &
NEW_PID=$!
Expand Down
18 changes: 15 additions & 3 deletions bin/claude-slack-monitor
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,21 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
INTEGRATION_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
CORE_DIR="$INTEGRATION_DIR/core"

# Environment variables (use /tmp for compatibility with original)
LOG_FILE="/tmp/slack_listener.log"
MONITOR_LOG="/tmp/slack_monitor.log"
# Load environment variables from .env file
ENV_FILE="$INTEGRATION_DIR/.env"
if [ -f "$ENV_FILE" ]; then
set -a
source "$ENV_FILE"
set +a
fi

# Log directory (defaults to ~/.claude/slack/logs)
SLACK_LOG_DIR=${SLACK_LOG_DIR:-"$HOME/.claude/slack/logs"}
mkdir -p "$SLACK_LOG_DIR"

# Log files
LOG_FILE="$SLACK_LOG_DIR/slack_listener_monitor.log"
MONITOR_LOG="$SLACK_LOG_DIR/slack_monitor.log"
CHECK_INTERVAL=180 # Check every 3 minutes
EVENT_TIMEOUT=300 # Restart if no events for 5 minutes

Expand Down
Loading