239e110b72
Playground repos can push directly to the default branch instead of opening PRs; agent runtime is configurable (default 5m). Co-authored-by: Cursor <cursoragent@cursor.com>
99 lines
4.0 KiB
Markdown
99 lines
4.0 KiB
Markdown
# Cursor Gitea Agent
|
|
|
|
A Gitea Action for self-hosted Action Runners that enables Cursor AI assistance in your Gitea repository. Mention `@cursor` in an issue or pull request comment to get AI-powered help.
|
|
|
|
Based on [flow96/cursor-gitea-agent](https://github.com/flow96/cursor-gitea-agent), adapted for [gitea.schwenk.online](https://gitea.schwenk.online/).
|
|
|
|
## Prerequisite
|
|
|
|
Action Runners must be set up and working on your Gitea instance.
|
|
|
|
## Setup
|
|
|
|
1. **Create a `cursor` user** in your Gitea instance. The name must be `cursor` — that is the trigger word and bot identity.
|
|
2. **Log in as the cursor user** and create an API token with repository access. Store it as a secret, then log out.
|
|
3. **Add the cursor user** as a member to repositories where you want AI assistance.
|
|
4. **Add the workflow** below to your repository's `.gitea/workflows/` directory.
|
|
5. **Store secrets** in the repository (or org). Gitea secret names are case-insensitive, alphanumeric/underscore only, and **must not** start with `GITEA_` or `GITHUB_`:
|
|
- `CURSOR_API_KEY` — Cursor API key
|
|
- `CURSOR_BOT_TOKEN` — Gitea API token for the `cursor` bot user
|
|
|
|
## Workflow file
|
|
|
|
Add this workflow to your repository's `.gitea/workflows/` directory:
|
|
|
|
```yaml
|
|
name: Cursor Agent
|
|
on:
|
|
issue_comment:
|
|
types: [created]
|
|
|
|
jobs:
|
|
cursor:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: https://gitea.schwenk.online/froxxxy/cursor-gitea-agent@main
|
|
with:
|
|
cursor_api_key: ${{ secrets.CURSOR_API_KEY }}
|
|
gitea_token: ${{ secrets.CURSOR_BOT_TOKEN }}
|
|
gitea_base_url: https://gitea.schwenk.online
|
|
ai_model: composer-2.5
|
|
# push_to_default_branch: "false" # optional — push to default branch instead of opening a PR
|
|
# agent_timeout: 5m # optional — max agent runtime (default 5m)
|
|
```
|
|
|
|
`ai_model` is optional — it defaults to `composer-2.5` when omitted.
|
|
|
|
For playground repos that commit directly to the default branch (no PR workflow):
|
|
|
|
```yaml
|
|
- uses: https://gitea.schwenk.online/froxxxy/cursor-gitea-agent@main
|
|
with:
|
|
cursor_api_key: ${{ secrets.CURSOR_API_KEY }}
|
|
gitea_token: ${{ secrets.CURSOR_BOT_TOKEN }}
|
|
gitea_base_url: https://gitea.schwenk.online
|
|
push_to_default_branch: "true"
|
|
agent_timeout: 10m
|
|
```
|
|
|
|
## Action inputs
|
|
|
|
| Input | Required | Default | Description |
|
|
|-------|----------|---------|-------------|
|
|
| `cursor_api_key` | yes | — | Cursor API key |
|
|
| `gitea_token` | yes | — | Gitea token for the `cursor` bot user |
|
|
| `gitea_base_url` | yes | — | Gitea instance URL |
|
|
| `ai_model` | no | `composer-2.5` | Cursor model id |
|
|
| `push_to_default_branch` | no | `false` | When `"true"`, agent commits and pushes to the default branch instead of opening a PR |
|
|
| `agent_timeout` | no | `5m` | Maximum runtime for the Cursor agent (`timeout` duration, e.g. `5m`, `30m`) |
|
|
|
|
## How it works
|
|
|
|
When someone mentions `@cursor` in a new issue or PR comment:
|
|
|
|
1. The action parses the webhook payload (`GITHUB_EVENT_PATH`) and checks for `@cursor`.
|
|
2. Comments from the `cursor` user are ignored to prevent feedback loops.
|
|
3. Cursor CLI and gitea-mcp are installed only when needed (skipped if already on the runner).
|
|
4. Cursor runs with gitea-mcp so it can read the repo, comment, and open PRs.
|
|
|
|
You can ask Cursor to review a PR, refine a feature request, or implement a change and open a PR.
|
|
|
|
### Ask Cursor to refine a feature request
|
|
|
|

|
|
|
|
### Ask Cursor to implement a feature
|
|
|
|

|
|
|
|
### Ask Cursor to review a PR
|
|
|
|

|
|
|
|
## Supported events
|
|
|
|
- `issue_comment` with `types: [created]` — issue and PR timeline comments (recommended)
|
|
|
|
`pull_request_review_comment` is not enabled by default: Gitea's payload uses a `review` object instead of `comment`, which is easy to get wrong. Open an issue if you need that trigger tested on your Gitea version.
|