feat: add push_to_default_branch and agent_timeout inputs
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>
This commit is contained in:
@@ -39,10 +39,24 @@ jobs:
|
||||
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 |
|
||||
@@ -51,6 +65,8 @@ jobs:
|
||||
| `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
|
||||
|
||||
|
||||
@@ -53,3 +53,5 @@ Fränky and repos on gitea.schwenk.online where the `cursor` bot user is a colla
|
||||
- Parse event context from `GITHUB_EVENT_PATH` with `jq` — do not rely on undocumented `gitea.event.*` template fields in shell scripts.
|
||||
- Install Cursor CLI and gitea-mcp only when `@cursor` fires and only if not already present on the runner.
|
||||
- Gitea secret names cannot start with `GITEA_` or `GITHUB_` — use `CURSOR_BOT_TOKEN` for the bot token, not `GITEA_TOKEN`.
|
||||
- `push_to_default_branch` (`"true"` / `"false"`, default `"false"`): playground repos may push directly to the default branch; production repos keep PR-only behavior.
|
||||
- `agent_timeout` (default `5m`): caps Cursor agent runtime via `timeout`; raise for long tasks (e.g. `30m`).
|
||||
|
||||
+10
@@ -14,6 +14,14 @@ inputs:
|
||||
description: Cursor model id
|
||||
required: false
|
||||
default: composer-2.5
|
||||
push_to_default_branch:
|
||||
description: When true, commit and push directly to the default branch instead of opening a PR
|
||||
required: false
|
||||
default: "false"
|
||||
agent_timeout:
|
||||
description: Maximum runtime for the Cursor agent (timeout duration, e.g. 5m, 30m)
|
||||
required: false
|
||||
default: 5m
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
@@ -39,5 +47,7 @@ runs:
|
||||
GITEA_ACCESS_TOKEN: ${{ inputs.gitea_token }}
|
||||
GITEA_BASE_URL: ${{ inputs.gitea_base_url }}
|
||||
AI_MODEL: ${{ inputs.ai_model }}
|
||||
PUSH_TO_DEFAULT_BRANCH: ${{ inputs.push_to_default_branch }}
|
||||
AGENT_TIMEOUT: ${{ inputs.agent_timeout }}
|
||||
run: |
|
||||
"$GITHUB_ACTION_PATH/scripts/run-cursor.sh"
|
||||
|
||||
+33
-12
@@ -53,6 +53,36 @@ jq -n \
|
||||
git config user.name "cursor"
|
||||
git config user.email "cursor@users.noreply.gitea.schwenk.online"
|
||||
|
||||
AGENT_TIMEOUT="${AGENT_TIMEOUT:-5m}"
|
||||
|
||||
if [ "${PUSH_TO_DEFAULT_BRANCH:-false}" = "true" ]; then
|
||||
TAKE_ACTION_SECTION='3. **Take Action:**
|
||||
- If implementing code: commit changes directly to the default branch and push (do not open a pull request)
|
||||
- If reviewing code: post a structured review in the pull request
|
||||
- If answering questions: provide helpful, accurate information
|
||||
- If the request is not feasible or safe: explain why and suggest alternatives
|
||||
- Do not create a pull request for implementation work — push to the default branch instead'
|
||||
|
||||
SAFETY_RULES_SECTION='## SAFETY RULES
|
||||
|
||||
- Commit and push implementation changes directly to the default branch — do not create a pull request
|
||||
- Always use MCP tools for Gitea interactions
|
||||
- Be minimal, precise, and safe in your actions'
|
||||
else
|
||||
TAKE_ACTION_SECTION='3. **Take Action:**
|
||||
- If implementing code: create a feature branch and open a pull request
|
||||
- If reviewing code: post a structured review in the pull request
|
||||
- If answering questions: provide helpful, accurate information
|
||||
- If the request is not feasible or safe: explain why and suggest alternatives
|
||||
- Use the MCP tool to create a Pull Request if needed'
|
||||
|
||||
SAFETY_RULES_SECTION='## SAFETY RULES
|
||||
|
||||
- NEVER push directly to protected branches (main, master, etc.)
|
||||
- Always use MCP tools for Gitea interactions
|
||||
- Be minimal, precise, and safe in your actions'
|
||||
fi
|
||||
|
||||
PROMPT="You are an autonomous software engineering agent called cursor for repository: ${REPO_FULL_NAME}
|
||||
|
||||
## CONTEXT INFORMATION
|
||||
@@ -84,25 +114,16 @@ You have full access to Gitea via MCP tools. Use them to:
|
||||
- Consider the context of the ${ISSUE_TYPE} and previous discussion
|
||||
- If the request is unclear, ask for clarification via a comment
|
||||
|
||||
3. **Take Action:**
|
||||
- If implementing code: create a feature branch and open a pull request
|
||||
- If reviewing code: post a structured review in the pull request
|
||||
- If answering questions: provide helpful, accurate information
|
||||
- If the request is not feasible or safe: explain why and suggest alternatives
|
||||
- Use the MCP tool to create a Pull Request if needed
|
||||
${TAKE_ACTION_SECTION}
|
||||
|
||||
4. **Let the user know you've completed the request**
|
||||
- Post your response as a comment on the ${ISSUE_TYPE}
|
||||
- If the request is not feasible or safe: explain why and suggest alternatives
|
||||
|
||||
## SAFETY RULES
|
||||
|
||||
- NEVER push directly to protected branches (main, master, etc.)
|
||||
- Always use MCP tools for Gitea interactions
|
||||
- Be minimal, precise, and safe in your actions"
|
||||
${SAFETY_RULES_SECTION}"
|
||||
|
||||
echo "Running Cursor agent for ${REPO_FULL_NAME} ${ISSUE_TYPE} #${ISSUE_NUMBER} (model: ${AI_MODEL})"
|
||||
|
||||
timeout 30m agent -p "$PROMPT" --force --model "${AI_MODEL}" --output-format=text
|
||||
timeout "${AGENT_TIMEOUT}" agent -p "$PROMPT" --force --model "${AI_MODEL}" --output-format=text
|
||||
|
||||
echo "Cursor agent completed."
|
||||
|
||||
Reference in New Issue
Block a user