Skip to content

Commit d877127

Browse files
authored
Merge pull request #55 from drivecore/docs/github-action-issue-comment
Add documentation for GitHub Action issue-comment.yml
2 parents 591a637 + e0657d4 commit d877127

File tree

5 files changed

+226
-10
lines changed

5 files changed

+226
-10
lines changed

docs/getting-started/index.mdx

+2-8
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ Before using MyCoder with a specific provider, you need to provide the appropria
4141
export ANTHROPIC_API_KEY=your-api-key
4242
# or
4343
export OPENAI_API_KEY=your-api-key
44-
# or
45-
export MISTRAL_API_KEY=your-api-key
46-
# or
47-
export XAI_API_KEY=your-api-key
4844
```
4945

5046
2. Create a `.env` file in your working directory with the appropriate key:
@@ -61,10 +57,8 @@ MyCoder supports multiple AI providers:
6157
| Provider | Environment Variable | Models |
6258
| ---------- | -------------------- | ------------------------------------ |
6359
| Anthropic | `ANTHROPIC_API_KEY` | claude-3-opus, claude-3-sonnet, etc. |
64-
| OpenAI | `OPENAI_API_KEY` | gpt-4o, o3-mini, etc. |
65-
| Mistral AI | `MISTRAL_API_KEY` | mistral-large, mistral-medium, etc. |
66-
| xAI/Grok | `XAI_API_KEY` | grok-1 |
67-
| Ollama | N/A (local) | Various local models |
60+
| OpenAI | `OPENAI_API_KEY` | gpt-4o, gpt-4-turbo, etc. |
61+
| Ollama | N/A (local) | Models with tool calling support |
6862

6963
You can specify which provider and model to use with the `--provider` and `--model` options:
7064

docs/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Currently available as a research preview, MyCoder is built to work alongside de
1414

1515
## Key Features
1616

17-
- **AI-Powered**: Supports multiple AI providers including Anthropic, OpenAI, Mistral AI, xAI/Grok, and Ollama
17+
- **AI-Powered**: Supports multiple AI providers including Anthropic, OpenAI, and Ollama
1818
- **Extensible Tool System**: Includes tools for file operations, shell commands, web browsing, and more
1919
- **Parallel Execution**: Can spawn sub-agents to work on different parts of a task simultaneously
2020
- **Self-Modification**: Capable of modifying code, including its own codebase

docs/providers/anthropic.md

+19
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,25 @@ Anthropic offers several Claude models with different capabilities and price poi
5858
- Claude models have a 200K token context window, allowing for large codebases to be processed
5959
- For cost-sensitive applications, consider using Claude Haiku for simpler tasks
6060

61+
## Token Caching
62+
63+
MyCoder implements token caching for Anthropic's Claude models to optimize performance and reduce API costs:
64+
65+
- Token caching stores and reuses parts of the conversation history
66+
- The Anthropic provider uses Claude's native cache control mechanisms
67+
- This significantly reduces token usage for repeated or similar queries
68+
- Cache efficiency is automatically optimized based on conversation context
69+
70+
You can enable or disable token caching in your configuration:
71+
72+
```javascript
73+
export default {
74+
provider: 'anthropic',
75+
model: 'claude-3-7-sonnet-20250219',
76+
tokenCache: true, // Enable token caching (default is true)
77+
};
78+
```
79+
6180
## Troubleshooting
6281

6382
If you encounter issues with Anthropic's Claude:

docs/providers/openai.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,15 @@ export default {
5151

5252
## Supported Models
5353

54-
OpenAI offers several models with different capabilities:
54+
MyCoder supports all OpenAI models that have tool/function calling capabilities. Here are some recommended models:
5555

5656
- `gpt-4o` (recommended) - Latest model with strong reasoning and tool-calling capabilities
5757
- `gpt-4-turbo` - Strong performance with 128K context window
5858
- `gpt-4` - Original GPT-4 model with 8K context window
5959
- `gpt-3.5-turbo` - More affordable option for simpler tasks
6060

61+
You can use any other OpenAI model that supports function calling with MyCoder. The OpenAI provider is not limited to just these listed models.
62+
6163
## Best Practices
6264

6365
- GPT-4o provides the best balance of performance and cost for most MyCoder tasks

docs/usage/github-action.md

+201
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
---
2+
sidebar_position: 6
3+
---
4+
5+
# GitHub Action Integration
6+
7+
MyCoder can be seamlessly integrated into your GitHub workflow through GitHub Actions, enabling powerful automation for your repositories. This guide focuses on the `issue-comment.yml` GitHub Action, which allows you to trigger MyCoder directly from issue or PR comments.
8+
9+
## How It Works
10+
11+
The `issue-comment.yml` GitHub Action monitors comments on issues and pull requests for a specific trigger phrase (typically `/mycoder`). When detected, it launches MyCoder with the context of the issue or PR, allowing it to:
12+
13+
- Analyze and respond to issues
14+
- Implement requested features
15+
- Review pull requests
16+
- Generate documentation
17+
- Create new PRs with changes
18+
- And much more
19+
20+
This integration creates a convenient, chat-like interface with MyCoder directly within your GitHub workflow.
21+
22+
## Benefits
23+
24+
- **Seamless Workflow Integration**: Interact with MyCoder without leaving GitHub
25+
- **Parallel Processing**: Run multiple MyCoder instances simultaneously on different tasks
26+
- **Contextual Understanding**: MyCoder has full access to the repository, issues, and PRs
27+
- **Automated Task Execution**: Trigger complex tasks with a simple comment
28+
- **Collaboration Enhancement**: AI assistance directly in your team's workflow
29+
30+
## Setup Guide
31+
32+
To add the MyCoder GitHub Action to your repository, create a file at `.github/workflows/issue-comment.yml` with the following configuration:
33+
34+
```yaml
35+
name: MyCoder Issue Comment Action
36+
37+
on:
38+
issue_comment:
39+
types: [created]
40+
41+
# Top-level permissions for all jobs
42+
permissions:
43+
contents: write # Required for checkout, commit, push
44+
issues: write # Required for issue comments
45+
pull-requests: write # Required for creating PRs
46+
discussions: write # For interaction capabilities
47+
statuses: write # For creating commit statuses
48+
checks: write # For creating check runs
49+
actions: read # For inspecting workflow runs
50+
packages: read # In case you need to access GitHub packages
51+
52+
env:
53+
PNPM_VERSION: 10.2.1 # Adjust based on your project requirements
54+
55+
jobs:
56+
process-comment:
57+
runs-on: ubuntu-latest
58+
# Only run if comment contains '/mycoder' AND commenter is authorized
59+
if: |
60+
contains(github.event.comment.body, '/mycoder') &&
61+
contains(fromJson('["username1", "username2"]'), github.event.comment.user.login)
62+
steps:
63+
- name: Extract prompt from comment
64+
id: extract-prompt
65+
run: |
66+
echo "comment_url=${{ github.event.comment.html_url }}" >> $GITHUB_OUTPUT
67+
echo "comment_id=${{ github.event.comment.id }}" >> $GITHUB_OUTPUT
68+
69+
- name: Checkout repository
70+
uses: actions/checkout@v3
71+
72+
- uses: actions/setup-node@v4
73+
with:
74+
node-version-file: .nvmrc
75+
76+
- uses: pnpm/action-setup@v2
77+
with:
78+
version: ${{ env.PNPM_VERSION }}
79+
80+
- name: Install dependencies
81+
run: pnpm install
82+
83+
- name: Install browsers
84+
run: cd packages/agent && pnpm exec playwright install --with-deps chromium
85+
86+
- name: Configure Git
87+
run: |
88+
git config --global user.name "Your Name (via MyCoder)"
89+
git config --global user.email "[email protected]"
90+
91+
- run:
92+
pnpm install -g mycoder
93+
94+
# Auth GitHub CLI with the token
95+
- name: Configure GitHub CLI
96+
run: |
97+
echo "${{ secrets.GH_PAT }}" | gh auth login --with-token
98+
# Verify auth status
99+
gh auth status
100+
101+
- env:
102+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
103+
run: |
104+
echo "Running MyCoder for issue #${{ github.event.issue.number }}"
105+
mycoder --userWarning false --upgradeCheck false --githubMode true --userPrompt false "On issue #${{ github.event.issue.number }} in comment ${{ steps.extract-prompt.outputs.comment_url }} the user invoked the mycoder CLI via /mycoder. Can you try to do what they requested or if it is unclear, respond with a comment to that effect to encourage them to be more clear."
106+
```
107+
108+
## Best Practices
109+
110+
### Security Considerations
111+
112+
:::caution Important Security Warning
113+
Only allow trusted individuals to trigger MyCoder via comments. With full repository access, MyCoder could potentially make significant changes if instructed maliciously.
114+
:::
115+
116+
Restrict execution by specifying authorized users:
117+
118+
```yaml
119+
if: |
120+
contains(github.event.comment.body, '/mycoder') &&
121+
contains(fromJson('["trusted-user1", "trusted-user2"]'), github.event.comment.user.login)
122+
```
123+
124+
For open source projects, be especially careful about who can trigger automated workflows.
125+
126+
### Using Personal Access Tokens
127+
128+
While GitHub Actions provides a built-in `GITHUB_TOKEN`, using a Personal Access Token (PAT) is recommended:
129+
130+
- **Why**: Using a PAT preserves standard CI behavior on submitted PRs
131+
- **How**: Store your PAT as a repository secret (`GH_PAT`) and reference it in the workflow
132+
133+
```yaml
134+
- name: Configure GitHub CLI
135+
run: |
136+
echo "${{ secrets.GH_PAT }}" | gh auth login --with-token
137+
```
138+
139+
### Disable User Prompts
140+
141+
Always run MyCoder with user prompts disabled in GitHub Actions:
142+
143+
```bash
144+
mycoder --userPrompt false
145+
```
146+
147+
This prevents the workflow from hanging indefinitely waiting for user input.
148+
149+
### Git Configuration
150+
151+
Configure Git with appropriate user information for commits made by MyCoder:
152+
153+
```yaml
154+
- name: Configure Git
155+
run: |
156+
git config --global user.name "Your Name (via MyCoder)"
157+
git config --global user.email "[email protected]"
158+
```
159+
160+
This clearly identifies commits made automatically by MyCoder.
161+
162+
## Usage Examples
163+
164+
### Trigger MyCoder on an Issue
165+
166+
Comment on any issue with:
167+
168+
```
169+
/mycoder Please analyze this issue and suggest a solution.
170+
```
171+
172+
### Request Documentation
173+
174+
```
175+
/mycoder Please create documentation for the recently added feature XYZ.
176+
```
177+
178+
### Code Review
179+
180+
```
181+
/mycoder Please review this PR and suggest improvements.
182+
```
183+
184+
### Feature Implementation
185+
186+
```
187+
/mycoder Please implement the feature described in this issue and create a PR.
188+
```
189+
190+
## Troubleshooting
191+
192+
If you encounter issues with the GitHub Action:
193+
194+
1. Check the Action logs for error messages
195+
2. Verify that all required secrets are properly configured
196+
3. Ensure the permissions are correctly set
197+
4. Confirm that the commenter is in the authorized users list
198+
199+
## Conclusion
200+
201+
The MyCoder GitHub Action integration provides a powerful way to incorporate AI assistance directly into your development workflow. By following the best practices outlined above, you can safely leverage MyCoder to enhance productivity and collaboration within your GitHub repositories.

0 commit comments

Comments
 (0)