diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index 15a466b..2c9c42e 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -41,6 +41,12 @@ "source": "./claude/ci", "description": "CI integration - GitHub Actions, test automation", "version": "0.1.0" + }, + { + "name": "issue", + "source": "./claude/issue", + "description": "Integration with GitHub Issues", + "version": "0.1.0" } ] } diff --git a/claude/issue/.claude-plugin/plugin.json b/claude/issue/.claude-plugin/plugin.json new file mode 100644 index 0000000..e142010 --- /dev/null +++ b/claude/issue/.claude-plugin/plugin.json @@ -0,0 +1,22 @@ +{ + "name": "issue", + "description": "Integration with GitHub Issues", + "commands": [ + { + "name": "list", + "description": "List open issues" + }, + { + "name": "view", + "description": "View issue details" + }, + { + "name": "start", + "description": "Start working on an issue" + }, + { + "name": "close", + "description": "Close an issue with a commit" + } + ] +} diff --git a/claude/issue/commands/close.md b/claude/issue/commands/close.md new file mode 100644 index 0000000..730383b --- /dev/null +++ b/claude/issue/commands/close.md @@ -0,0 +1,11 @@ +--- +name: close +description: Close an issue with a commit +hooks: + PreToolUse: + - hooks: + - type: command + command: "${CLAUDE_PLUGIN_ROOT}/scripts/close.sh" +--- + +# Close an issue with a commit diff --git a/claude/issue/commands/list.md b/claude/issue/commands/list.md new file mode 100644 index 0000000..6a6846a --- /dev/null +++ b/claude/issue/commands/list.md @@ -0,0 +1,11 @@ +--- +name: list +description: List open issues +hooks: + PreToolUse: + - hooks: + - type: command + command: "${CLAUDE_PLUGIN_ROOT}/scripts/list.sh" +--- + +# List open issues diff --git a/claude/issue/commands/start.md b/claude/issue/commands/start.md new file mode 100644 index 0000000..a2dcead --- /dev/null +++ b/claude/issue/commands/start.md @@ -0,0 +1,11 @@ +--- +name: start +description: Start working on an issue +hooks: + PreToolUse: + - hooks: + - type: command + command: "${CLAUDE_PLUGIN_ROOT}/scripts/start.sh" +--- + +# Start working on an issue diff --git a/claude/issue/commands/view.md b/claude/issue/commands/view.md new file mode 100644 index 0000000..32e7a0b --- /dev/null +++ b/claude/issue/commands/view.md @@ -0,0 +1,11 @@ +--- +name: view +description: View issue details +hooks: + PreToolUse: + - hooks: + - type: command + command: "${CLAUDE_PLUGIN_ROOT}/scripts/view.sh" +--- + +# View issue details diff --git a/claude/issue/scripts/close.sh b/claude/issue/scripts/close.sh new file mode 100755 index 0000000..ea78aaf --- /dev/null +++ b/claude/issue/scripts/close.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +# Check if gh is installed +if ! command -v gh &> /dev/null +then + echo "GitHub CLI (gh) could not be found. Please install it to use this feature." + echo "Installation instructions: https://github.com/cli/cli#installation" + exit 1 +fi + +# Check for issue number argument +if [ -z "$1" ]; then + echo "Usage: /core:issue close " + exit 1 +fi + +ISSUE_NUMBER=$1 +CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) + +echo "Closing #${ISSUE_NUMBER}..." +echo "" + +# Get issue title +ISSUE_TITLE=$(gh issue view "${ISSUE_NUMBER}" --json title -q .title) +if [ -z "$ISSUE_TITLE" ]; then + echo "Could not find issue #${ISSUE_NUMBER}." + exit 1 +fi + +echo "Commits on branch '${CURRENT_BRANCH}':" +git log --oneline main..HEAD +echo "" + +read -p "Create PR? [Y/n] " -r +echo +if [[ ! $REPLY =~ ^[Nn]$ ]]; then + gh pr create --title "${ISSUE_TITLE}" --body "Closes #${ISSUE_NUMBER}" --base main + echo "" +fi + +read -p "Comment on issue? [Y/n] " -r +echo +if [[ ! $REPLY =~ ^[Nn]$ ]]; then + PR_URL=$(gh pr view --json url -q .url) + if [ -n "$PR_URL" ]; then + gh issue comment "${ISSUE_NUMBER}" --body "Fixed in ${PR_URL}" + echo "Commented on issue #${ISSUE_NUMBER}" + else + echo "Could not find a pull request for this branch." + fi +fi diff --git a/claude/issue/scripts/list.sh b/claude/issue/scripts/list.sh new file mode 100755 index 0000000..2de3f33 --- /dev/null +++ b/claude/issue/scripts/list.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# Check if gh is installed +if ! command -v gh &> /dev/null +then + echo "GitHub CLI (gh) could not be found. Please install it to use this feature." + echo "Installation instructions: https://github.com/cli/cli#installation" + exit 1 +fi + +# List open issues +echo "Fetching open issues from GitHub..." +gh issue list diff --git a/claude/issue/scripts/start.sh b/claude/issue/scripts/start.sh new file mode 100755 index 0000000..16887e5 --- /dev/null +++ b/claude/issue/scripts/start.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +# Check if gh is installed +if ! command -v gh &> /dev/null +then + echo "GitHub CLI (gh) could not be found. Please install it to use this feature." + echo "Installation instructions: https://github.com/cli/cli#installation" + exit 1 +fi + +# Check for issue number argument +if [ -z "$1" ]; then + echo "Usage: /core:issue start " + exit 1 +fi + +ISSUE_NUMBER=$1 + +echo "Starting work on #${ISSUE_NUMBER}..." + +# Get issue title +ISSUE_TITLE=$(gh issue view "${ISSUE_NUMBER}" --json title -q .title) +if [ -z "$ISSUE_TITLE" ]; then + echo "Could not find issue #${ISSUE_NUMBER}." + exit 1 +fi + +# Sanitize the title for the branch name +BRANCH_NAME=$(echo "$ISSUE_TITLE" | tr '[:upper:]' '[:lower:]' | sed -e 's/[^a-z0-9]/-/g' -e 's/--\+/-/g' -e 's/^-//' -e 's/-$//' | cut -c 1-50) + +FULL_BRANCH_NAME="fix/${ISSUE_NUMBER}-${BRANCH_NAME}" + +# Create and switch to the new branch +git checkout -b "${FULL_BRANCH_NAME}" + +echo "" +echo "1. Created branch: ${FULL_BRANCH_NAME}" +echo "2. Loaded issue context into session" +echo "" +echo "Issue details:" +gh issue view "${ISSUE_NUMBER}" +echo "" +echo "Ready to work. Type /core:issue close ${ISSUE_NUMBER} when done." diff --git a/claude/issue/scripts/view.sh b/claude/issue/scripts/view.sh new file mode 100755 index 0000000..bfb7368 --- /dev/null +++ b/claude/issue/scripts/view.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# Check if gh is installed +if ! command -v gh &> /dev/null +then + echo "GitHub CLI (gh) could not be found. Please install it to use this feature." + echo "Installation instructions: https://github.com/cli/cli#installation" + exit 1 +fi + +# Check for issue number argument +if [ -z "$1" ]; then + echo "Usage: /core:issue view " + exit 1 +fi + +ISSUE_NUMBER=$1 + +# View issue details +echo "Fetching details for issue #${ISSUE_NUMBER} from GitHub..." +gh issue view "${ISSUE_NUMBER}"