-
Notifications
You must be signed in to change notification settings - Fork 8
feat: add Cursor CLI as a first-class agent type #414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| FROM ubuntu:24.04 | ||
|
|
||
| ARG GO_VERSION=1.25.0 | ||
|
|
||
| RUN apt-get update && apt-get install -y \ | ||
| make \ | ||
| curl \ | ||
| ca-certificates \ | ||
| git \ | ||
| && curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \ | ||
| && apt-get install -y nodejs \ | ||
| && curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \ | ||
| -o /usr/share/keyrings/githubcli-archive-keyring.gpg \ | ||
| && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" \ | ||
| > /etc/apt/sources.list.d/github-cli.list \ | ||
| && apt-get update \ | ||
| && apt-get install -y gh \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| RUN ARCH=$(dpkg --print-architecture) \ | ||
| && TARBALL="go${GO_VERSION}.linux-${ARCH}.tar.gz" \ | ||
| && curl -fsSL -o "/tmp/${TARBALL}" "https://dl.google.com/go/${TARBALL}" \ | ||
| && curl -fsSL -o "/tmp/${TARBALL}.sha256" "https://dl.google.com/go/${TARBALL}.sha256" \ | ||
| && echo "$(cat /tmp/${TARBALL}.sha256) /tmp/${TARBALL}" | sha256sum -c - \ | ||
| && tar -C /usr/local -xzf "/tmp/${TARBALL}" \ | ||
| && rm "/tmp/${TARBALL}" "/tmp/${TARBALL}.sha256" | ||
|
|
||
| ENV PATH="/usr/local/go/bin:${PATH}" | ||
|
|
||
| COPY cursor/axon_entrypoint.sh /axon_entrypoint.sh | ||
| RUN chmod +x /axon_entrypoint.sh | ||
|
|
||
| COPY bin/axon-capture /axon/axon-capture | ||
|
|
||
| RUN useradd -u 61100 -m -s /bin/bash agent | ||
| RUN mkdir -p /home/agent/.cursor && chown -R agent:agent /home/agent | ||
|
|
||
| USER agent | ||
|
|
||
| # Cursor CLI installs to ~/.local/bin | ||
| RUN curl -fsSL https://cursor.com/install | bash | ||
|
|
||
| ENV GOPATH="/home/agent/go" | ||
| ENV PATH="/home/agent/.local/bin:${GOPATH}/bin:${PATH}" | ||
|
|
||
| WORKDIR /workspace | ||
|
|
||
| ENTRYPOINT ["agent"] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| #!/bin/bash | ||
| # axon_entrypoint.sh — Axon agent image interface implementation for | ||
| # Cursor CLI. | ||
| # | ||
| # Interface contract: | ||
| # - First argument ($1): the task prompt | ||
| # - CURSOR_API_KEY env var: API key for authentication | ||
| # - AXON_MODEL env var: model name (optional) | ||
| # - UID 61100: shared between git-clone init container and agent | ||
| # - Working directory: /workspace/repo when a workspace is configured | ||
|
|
||
| set -uo pipefail | ||
|
|
||
| PROMPT="${1:?Prompt argument is required}" | ||
|
|
||
| ARGS=( | ||
| "-p" | ||
| "--force" | ||
| "--trust" | ||
| "--sandbox" "disabled" | ||
| "--output-format" "stream-json" | ||
| "$PROMPT" | ||
| ) | ||
|
|
||
| if [ -n "${AXON_MODEL:-}" ]; then | ||
| ARGS=("--model" "$AXON_MODEL" "${ARGS[@]}") | ||
| fi | ||
|
|
||
| # Write user-level instructions to both user config and workspace root. | ||
| # Cursor CLI may read AGENTS.md from the working directory. | ||
| if [ -n "${AXON_AGENTS_MD:-}" ]; then | ||
| mkdir -p ~/.cursor | ||
| printf '%s' "$AXON_AGENTS_MD" >~/.cursor/AGENTS.md | ||
| printf '%s' "$AXON_AGENTS_MD" >/workspace/AGENTS.md | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we have to add /workspace/AGENTS.md? I guess ~/.cursor/AGENTS.md already cover it. |
||
| fi | ||
|
|
||
| # Install each plugin's skills into Cursor's .cursor/skills/ directory | ||
| # in the workspace so the CLI discovers them at runtime. | ||
| if [ -n "${AXON_PLUGIN_DIR:-}" ] && [ -d "${AXON_PLUGIN_DIR}" ]; then | ||
| for plugindir in "${AXON_PLUGIN_DIR}"/*/; do | ||
| [ -d "$plugindir" ] || continue | ||
| if [ -d "${plugindir}skills" ]; then | ||
| for skilldir in "${plugindir}skills"/*/; do | ||
| [ -d "$skilldir" ] || continue | ||
| skillname=$(basename "$skilldir") | ||
| pluginname=$(basename "$plugindir") | ||
| targetdir="/workspace/.cursor/skills/${pluginname}-${skillname}" | ||
| mkdir -p "$targetdir" | ||
| if [ -f "${skilldir}SKILL.md" ]; then | ||
| cp "${skilldir}SKILL.md" "$targetdir/SKILL.md" | ||
| fi | ||
| done | ||
| fi | ||
| done | ||
| fi | ||
|
Comment on lines
+39
to
+55
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about the agents? |
||
|
|
||
| # Write MCP server configuration to user-scoped ~/.cursor/mcp.json. | ||
| # The AXON_MCP_SERVERS JSON format matches Cursor's native format directly. | ||
| if [ -n "${AXON_MCP_SERVERS:-}" ]; then | ||
| mkdir -p ~/.cursor | ||
| node -e ' | ||
| const fs = require("fs"); | ||
| const cfgPath = require("os").homedir() + "/.cursor/mcp.json"; | ||
| let existing = {}; | ||
| try { existing = JSON.parse(fs.readFileSync(cfgPath, "utf8")); } catch {} | ||
| const mcp = JSON.parse(process.env.AXON_MCP_SERVERS); | ||
| existing.mcpServers = Object.assign(existing.mcpServers || {}, mcp.mcpServers || {}); | ||
| fs.writeFileSync(cfgPath, JSON.stringify(existing, null, 2)); | ||
| ' | ||
| fi | ||
|
|
||
| agent "${ARGS[@]}" | tee /tmp/agent-output.jsonl | ||
| AGENT_EXIT_CODE=${PIPESTATUS[0]} | ||
|
|
||
| /axon/axon-capture | ||
|
|
||
| exit $AGENT_EXIT_CODE | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we pin the cursor to a specific version? so that it will not be siliently updated?