feat(plugin): add github issues integration (#69)
This commit introduces a new plugin for integrating with GitHub Issues. The `issue` plugin provides the following commands: - `/core:issue list`: List open issues. - `/core:issue view <number>`: View the details of a specific issue. - `/core:issue start <number>`: Start working on an issue by creating a feature branch. - `/core:issue close <number>`: Close an issue by creating a pull request. The plugin uses the GitHub CLI (`gh`) to interact with the GitHub API.
This commit is contained in:
parent
36028cdf39
commit
0e86ec4996
10 changed files with 200 additions and 0 deletions
|
|
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
22
claude/issue/.claude-plugin/plugin.json
Normal file
22
claude/issue/.claude-plugin/plugin.json
Normal file
|
|
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
11
claude/issue/commands/close.md
Normal file
11
claude/issue/commands/close.md
Normal file
|
|
@ -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
|
||||
11
claude/issue/commands/list.md
Normal file
11
claude/issue/commands/list.md
Normal file
|
|
@ -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
|
||||
11
claude/issue/commands/start.md
Normal file
11
claude/issue/commands/start.md
Normal file
|
|
@ -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
|
||||
11
claude/issue/commands/view.md
Normal file
11
claude/issue/commands/view.md
Normal file
|
|
@ -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
|
||||
51
claude/issue/scripts/close.sh
Executable file
51
claude/issue/scripts/close.sh
Executable file
|
|
@ -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 <issue-number>"
|
||||
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
|
||||
13
claude/issue/scripts/list.sh
Executable file
13
claude/issue/scripts/list.sh
Executable file
|
|
@ -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
|
||||
43
claude/issue/scripts/start.sh
Executable file
43
claude/issue/scripts/start.sh
Executable file
|
|
@ -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 <issue-number>"
|
||||
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."
|
||||
21
claude/issue/scripts/view.sh
Executable file
21
claude/issue/scripts/view.sh
Executable file
|
|
@ -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 <issue-number>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ISSUE_NUMBER=$1
|
||||
|
||||
# View issue details
|
||||
echo "Fetching details for issue #${ISSUE_NUMBER} from GitHub..."
|
||||
gh issue view "${ISSUE_NUMBER}"
|
||||
Loading…
Add table
Reference in a new issue