Browse Source

chore: remove obsolete shell script and update documentation #26

- Removed scripts/handle-issue-ts.sh (obsolete after TypeScript migration)
- Updated commands.json.example to call TypeScript client directly (type: node)
- Updated README.md to remove shell script reference from project structure

All issue/comment handlers now use the TypeScript client directly via Node.js,
eliminating the need for shell script wrappers.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Claude 9 months ago
parent
commit
43568b5ad9
3 changed files with 7 additions and 141 deletions
  1. 1 2
      README.md
  2. 6 6
      commands.json.example
  3. 0 133
      scripts/handle-issue-ts.sh

+ 1 - 2
README.md

@@ -461,8 +461,7 @@ node examples/with-callbacks.js
 │   │   ├── mcpConfigManager.ts   # MCP configuration manager
 │   │   └── types.ts              # TypeScript type definitions
 │   └── dist/              # Compiled JavaScript (auto-generated)
-├── scripts/
-│   └── handle-issue-ts.sh # TypeScript issue handler script
+├── scripts/               # Utility scripts
 ├── examples/
 │   ├── with-callbacks.js         # Example with custom callbacks
 │   ├── mcp-config-default.json   # Example default MCP config

+ 6 - 6
commands.json.example

@@ -97,10 +97,10 @@
       {
         "name": "claude-issue-handler",
         "description": "Automatically handle issues assigned to Claude with Claude Agent SDK TypeScript client",
-        "type": "shell",
-        "command": "/data/agent-manager/scripts/handle-issue-ts.sh",
+        "type": "node",
+        "command": "/data/agent-manager/client/dist/index.js",
         "args": ["{{repo_owner}}", "{{repo}}", "{{pusher}}", "{{issue_number}}", "{{issue_title}}", "{{issue_body}}", "{{issue_action}}", "", "{{issue_assignee}}"],
-        "cwd": "~",
+        "cwd": null,
         "timeout": 600000,
         "filterBranch": null,
         "filterActions": ["assigned", "opened", "reopened"],
@@ -141,10 +141,10 @@
       {
         "name": "claude-comment-handler",
         "description": "Automatically handle issue comments for issues assigned to Claude with Claude Agent SDK TypeScript client",
-        "type": "shell",
-        "command": "/data/agent-manager/scripts/handle-issue-ts.sh",
+        "type": "node",
+        "command": "/data/agent-manager/client/dist/index.js",
         "args": ["{{repo_owner}}", "{{repo}}", "{{pusher}}", "{{issue_number}}", "{{issue_title}}", "{{issue_body}}", "{{issue_action}}", "{{comment_body}}", "{{issue_assignee}}"],
-        "cwd": "~",
+        "cwd": null,
         "timeout": 600000,
         "filterBranch": null,
         "filterActions": ["created"],

+ 0 - 133
scripts/handle-issue-ts.sh

@@ -1,133 +0,0 @@
-#!/bin/bash
-
-# TypeScript-based issue handler using Claude Agent SDK
-# This script replaces the old bash-based Claude Code implementation
-
-# Ensure HOME is set (systemd might not set it)
-if [ -z "$HOME" ]; then
-    export HOME=$(getent passwd "$(whoami)" | cut -d: -f6)
-fi
-
-# Add NODE to PATH
-export PATH="$HOME/.local/bin:$PATH"
-
-# Ensure Claude Code has writable directories for cache and config
-export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
-export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
-export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
-export XDG_STATE_HOME="${XDG_STATE_HOME:-$HOME/.local/state}"
-
-# Create these directories if they don't exist
-mkdir -p "$XDG_CACHE_HOME" "$XDG_CONFIG_HOME" "$XDG_DATA_HOME" "$XDG_STATE_HOME"
-
-# Parse arguments
-OWNER="$1"
-REPO="$2"
-PUSHER="$3"
-ISSUE_NUMBER="$4"
-ISSUE_TITLE="$5"
-ISSUE_BODY="$6"
-ISSUE_ACTION="$7"
-COMMENT_BODY="$8"
-ASSIGNEE="$9"
-
-# Exit if pusher is claude AND assignee is NOT claude (avoid loops)
-# Allow Claude to work on issues it created and assigned to itself
-if [ "$PUSHER" = "claude" ] && [ "$ASSIGNEE" != "claude" ]; then
-    echo "Pusher is claude and issue not assigned to claude, skipping automation to avoid loops"
-    exit 0
-fi
-
-# Exit if issue is not assigned to claude
-if [ "$ASSIGNEE" != "claude" ]; then
-    echo "Issue not assigned to claude (assignee: $ASSIGNEE), skipping"
-    exit 0
-fi
-
-# Exit if issue action is 'closed' (but allow 'reopened')
-if [ "$ISSUE_ACTION" = "closed" ]; then
-    echo "Issue action is 'closed', skipping automation"
-    exit 0
-fi
-
-# Determine repo path
-REPO_PATH="$HOME/$REPO"
-
-# Check if repo exists, if not clone it
-if [ ! -d "$REPO_PATH" ]; then
-    echo "Repository not found at $REPO_PATH, cloning..."
-    mkdir -p "$HOME"
-    GIT_URL="ssh://git@207.154.220.231:10022/$OWNER/$REPO.git"
-    git clone "$GIT_URL" "$REPO_PATH"
-
-    if [ $? -ne 0 ]; then
-        echo "Failed to clone repository"
-        exit 1
-    fi
-    echo "Repository cloned successfully"
-else
-    echo "Repository found at $REPO_PATH"
-    # Pull latest changes
-    cd "$REPO_PATH" || exit 1
-    echo "Pulling latest changes..."
-    # Try to pull, but don't fail if it errors (might be file system issues)
-    if ! git pull 2>&1; then
-        echo "Warning: git pull failed, continuing with existing repository state"
-    fi
-fi
-
-# Change to repo directory
-cd "$REPO_PATH" || exit 1
-echo "Working directory: $(pwd)"
-
-# Load AGENT_MANAGER_PATH from project .env file
-# Try multiple possible locations for the agent-manager .env file
-AGENT_MANAGER_ENV_PATHS=(
-    "/home/claude/agent-manager/.env"
-    "/data/agent-manager/.env"
-    "$HOME/agent-manager/.env"
-)
-
-AGENT_MANAGER_PATH=""
-for ENV_PATH in "${AGENT_MANAGER_ENV_PATHS[@]}"; do
-    if [ -f "$ENV_PATH" ]; then
-        # Load AGENT_MANAGER_PATH from .env if it exists
-        AGENT_MANAGER_PATH=$(grep -E "^AGENT_MANAGER_PATH=" "$ENV_PATH" | cut -d '=' -f2-)
-        if [ -n "$AGENT_MANAGER_PATH" ]; then
-            echo "Loaded AGENT_MANAGER_PATH from: $ENV_PATH"
-            break
-        fi
-    fi
-done
-
-# Fallback: try to detect from script location
-if [ -z "$AGENT_MANAGER_PATH" ]; then
-    # Get the directory where this script is located
-    SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
-    # Go up one level from scripts/ to get agent-manager root
-    AGENT_MANAGER_PATH="$(dirname "$SCRIPT_DIR")"
-    echo "Using detected path from script location: $AGENT_MANAGER_PATH"
-fi
-
-echo "Calling Claude Agent SDK TypeScript client..."
-echo "Agent Manager Path: $AGENT_MANAGER_PATH"
-echo "---"
-
-# Call the TypeScript client
-node "$AGENT_MANAGER_PATH/client/dist/index.js" \
-    "$OWNER" \
-    "$REPO" \
-    "$PUSHER" \
-    "$ISSUE_NUMBER" \
-    "$ISSUE_TITLE" \
-    "$ISSUE_BODY" \
-    "$ISSUE_ACTION" \
-    "${COMMENT_BODY:-}" \
-    "${ASSIGNEE:-}"
-
-EXIT_CODE=$?
-
-echo "---"
-echo "Claude Agent SDK execution completed (exit code: $EXIT_CODE)"
-
-exit $EXIT_CODE