Skip to content

Commit 69d347d

Browse files
committed
Make /mycoder command more flexible and context-aware
1 parent 42831a4 commit 69d347d

File tree

3 files changed

+72
-34
lines changed

3 files changed

+72
-34
lines changed

.github/workflows/issue-comment.yml

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,25 @@ env:
1515
jobs:
1616
process-comment:
1717
runs-on: ubuntu-latest
18-
if: contains(github.event.comment.body, '/mycoder pr') || contains(github.event.comment.body, '/mycoder plan')
18+
if: contains(github.event.comment.body, '/mycoder')
1919
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+
2037
- name: Checkout repository
2138
uses: actions/checkout@v3
2239

@@ -36,20 +53,10 @@ jobs:
3653
# Skip tests when installing globally
3754
pnpm install -g mycoder --no-frozen-lockfile --ignore-scripts
3855
39-
- name: Run MyCoder PR command
40-
if: contains(github.event.comment.body, '/mycoder pr')
41-
env:
42-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43-
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
44-
run: |
45-
echo "Running MyCoder to implement PR for issue #${{ github.event.issue.number }}"
46-
mycoder --githubMode true --userPrompt false "Implement a PR for GitHub issue #${{ github.event.issue.number }}. Please review the issue details and implement a solution according to the requirements. After implementation, create a pull request that addresses this issue."
47-
48-
- name: Run MyCoder Plan command
49-
if: contains(github.event.comment.body, '/mycoder plan')
56+
- name: Run MyCoder with prompt
5057
env:
5158
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5259
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
5360
run: |
54-
echo "Running MyCoder to create implementation plan for issue #${{ github.event.issue.number }}"
55-
mycoder --githubMode true --userPrompt false "Review GitHub issue #${{ github.event.issue.number }} and create an implementation plan. Post your plan as a comment on the issue. Be thorough and consider all requirements mentioned in the issue description."
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: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,16 @@ mycoder config set githubMode true
4040

4141
### GitHub Comment Commands
4242

43-
MyCoder can be triggered directly from GitHub issue comments using special commands:
43+
MyCoder can be triggered directly from GitHub issue comments using the flexible `/mycoder` command:
4444

45-
- `/mycoder pr` - Implements a PR for the given issue
46-
- `/mycoder plan` - Generates an implementation plan as a comment
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`
4753

4854
[Learn more about GitHub comment commands](docs/github-comment-commands.md)
4955

docs/github-comment-commands.md

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,68 @@
11
# GitHub Comment Commands
22

3-
MyCoder provides automated actions in response to specific commands in GitHub issue comments. This feature allows you to trigger MyCoder directly from GitHub issues.
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.
44

5-
## Available Commands
5+
## How to Use
66

7-
### `/mycoder pr`
7+
Simply add a comment to any GitHub issue with `/mycoder` followed by your instructions:
88

9-
When you add a comment with `/mycoder pr` to any issue, MyCoder will:
9+
```
10+
/mycoder [your instructions here]
11+
```
12+
13+
MyCoder will process your instructions in the context of the issue and respond accordingly.
1014

15+
## Examples
16+
17+
### Creating a PR
18+
19+
```
20+
/mycoder implement a PR for this issue
21+
```
22+
23+
MyCoder will:
1124
1. Check out the repository
1225
2. Review the issue details
1326
3. Implement a solution according to the requirements
1427
4. Create a pull request that addresses the issue
1528

16-
Example:
17-
```
18-
This looks like a great feature to add!
29+
### Creating an Implementation Plan
1930

20-
/mycoder pr
31+
```
32+
/mycoder create an implementation plan for this issue
2133
```
2234

23-
### `/mycoder plan`
24-
25-
When you add a comment with `/mycoder plan` to any issue, MyCoder will:
26-
35+
MyCoder will:
2736
1. Review the issue details
2837
2. Create a comprehensive implementation plan
2938
3. Post the plan as a comment on the issue
3039

31-
Example:
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
3250
```
33-
I'm not sure about the best approach for this.
3451

35-
/mycoder plan
52+
```
53+
/mycoder recommend libraries we could use for this implementation
3654
```
3755

3856
## How It Works
3957

40-
This functionality is implemented as a GitHub Action that runs whenever a new comment is added to an issue. The action checks for these specific command patterns and triggers MyCoder with the appropriate instructions.
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.
4166

4267
## Requirements
4368

@@ -52,4 +77,4 @@ For this feature to work in your repository:
5277

5378
- The action runs with GitHub's default timeout limits
5479
- Complex implementations may require multiple iterations
55-
- The AI model's capabilities determine the quality of the implementation or plan
80+
- The AI model's capabilities determine the quality of the results

0 commit comments

Comments
 (0)