Skip to content

Commit fc73241

Browse files
authored
Merge pull request #163 from drivecore/feature/issue-comment-action
Add GitHub Action for issue comment commands
2 parents cda1a4d + 69d347d commit fc73241

File tree

3 files changed

+157
-0
lines changed

3 files changed

+157
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: MyCoder Issue Comment Action
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
7+
permissions:
8+
contents: write
9+
issues: write
10+
pull-requests: write
11+
12+
env:
13+
PNPM_VERSION: 10.2.1
14+
15+
jobs:
16+
process-comment:
17+
runs-on: ubuntu-latest
18+
if: contains(github.event.comment.body, '/mycoder')
19+
steps:
20+
- name: Extract prompt from comment
21+
id: extract-prompt
22+
run: |
23+
COMMENT="${{ github.event.comment.body }}"
24+
if [[ "$COMMENT" =~ "/mycoder "(.+) ]]; then
25+
PROMPT="${BASH_REMATCH[1]}"
26+
elif [[ "$COMMENT" =~ "/mycoder" ]]; then
27+
# If just /mycoder with no text after, use a default prompt
28+
PROMPT="Please review this issue and suggest next steps."
29+
else
30+
echo "No valid /mycoder command found"
31+
exit 1
32+
fi
33+
echo "prompt=$PROMPT" >> $GITHUB_OUTPUT
34+
echo "comment_url=${{ github.event.comment.html_url }}" >> $GITHUB_OUTPUT
35+
echo "comment_id=${{ github.event.comment.id }}" >> $GITHUB_OUTPUT
36+
37+
- name: Checkout repository
38+
uses: actions/checkout@v3
39+
40+
- name: Set up pnpm
41+
uses: pnpm/action-setup@v2
42+
with:
43+
version: ${{ env.PNPM_VERSION }}
44+
45+
- name: Set up Node.js
46+
uses: actions/setup-node@v4
47+
with:
48+
node-version-file: .nvmrc
49+
cache: 'pnpm'
50+
51+
- name: Install MyCoder globally
52+
run: |
53+
# Skip tests when installing globally
54+
pnpm install -g mycoder --no-frozen-lockfile --ignore-scripts
55+
56+
- name: Run MyCoder with prompt
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
60+
run: |
61+
echo "Running MyCoder for issue #${{ github.event.issue.number }} with prompt: ${{ steps.extract-prompt.outputs.prompt }}"
62+
mycoder --githubMode true --userPrompt false "On issue #${{ github.event.issue.number }} the user asked: '${{ steps.extract-prompt.outputs.prompt }}' in comment ${{ steps.extract-prompt.outputs.comment_url }}. Please address this request. If you create a PR or take actions outside the scope of this issue, please report back to the issue with a comment explaining what you did."

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,21 @@ mycoder -f prompt.txt
3838
mycoder config set githubMode true
3939
```
4040

41+
### GitHub Comment Commands
42+
43+
MyCoder can be triggered directly from GitHub issue comments using the flexible `/mycoder` command:
44+
45+
```
46+
/mycoder [your instructions here]
47+
```
48+
49+
Examples:
50+
- `/mycoder implement a PR for this issue`
51+
- `/mycoder create an implementation plan`
52+
- `/mycoder suggest test cases for this feature`
53+
54+
[Learn more about GitHub comment commands](docs/github-comment-commands.md)
55+
4156
## Packages
4257

4358
- [mycoder](packages/cli) - Command-line interface for MyCoder

docs/github-comment-commands.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# GitHub Comment Commands
2+
3+
MyCoder provides automated actions in response to `/mycoder` commands in GitHub issue comments. This feature allows you to trigger MyCoder directly from GitHub issues with flexible prompts.
4+
5+
## How to Use
6+
7+
Simply add a comment to any GitHub issue with `/mycoder` followed by your instructions:
8+
9+
```
10+
/mycoder [your instructions here]
11+
```
12+
13+
MyCoder will process your instructions in the context of the issue and respond accordingly.
14+
15+
## Examples
16+
17+
### Creating a PR
18+
19+
```
20+
/mycoder implement a PR for this issue
21+
```
22+
23+
MyCoder will:
24+
1. Check out the repository
25+
2. Review the issue details
26+
3. Implement a solution according to the requirements
27+
4. Create a pull request that addresses the issue
28+
29+
### Creating an Implementation Plan
30+
31+
```
32+
/mycoder create an implementation plan for this issue
33+
```
34+
35+
MyCoder will:
36+
1. Review the issue details
37+
2. Create a comprehensive implementation plan
38+
3. Post the plan as a comment on the issue
39+
40+
### Other Use Cases
41+
42+
The `/mycoder` command is flexible and can handle various requests:
43+
44+
```
45+
/mycoder suggest test cases for this feature
46+
```
47+
48+
```
49+
/mycoder analyze the performance implications of this change
50+
```
51+
52+
```
53+
/mycoder recommend libraries we could use for this implementation
54+
```
55+
56+
## How It Works
57+
58+
This functionality is implemented as a GitHub Action that runs whenever a new comment is added to an issue. The action checks for the `/mycoder` command pattern and triggers MyCoder with the appropriate instructions.
59+
60+
MyCoder receives context about:
61+
- The issue number
62+
- The specific prompt you provided
63+
- The comment URL where the command was triggered
64+
65+
If MyCoder creates a PR or takes actions outside the scope of the issue, it will report back to the issue with a comment explaining what was done.
66+
67+
## Requirements
68+
69+
For this feature to work in your repository:
70+
71+
1. The GitHub Action workflow must be present in your repository
72+
2. You need to configure the necessary API keys as GitHub secrets:
73+
- `GITHUB_TOKEN` (automatically provided)
74+
- `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `XAI_API_KEY`, or `MISTRAL_API_KEY` (depending on your preferred model)
75+
76+
## Limitations
77+
78+
- The action runs with GitHub's default timeout limits
79+
- Complex implementations may require multiple iterations
80+
- The AI model's capabilities determine the quality of the results

0 commit comments

Comments
 (0)