# 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** `CURSOR_API_KEY` and `GITEA_TOKEN` in the repository (or org) secrets.

## 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.GITEA_TOKEN }}
          gitea_base_url: https://gitea.schwenk.online
          ai_model: composer-2.5
```

`ai_model` is optional — it defaults to `composer-2.5` when omitted.

## 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 |

## 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

![Refine feature request example](docs/refine.png)

### Ask Cursor to implement a feature

![Implement a feature](docs/implement.png)

### Ask Cursor to review a PR

![Review a PR](docs/review.png)

## 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.
