JSPM

fzx-cursor-acp

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q49673F
  • License MIT

Cursor ACP adapter bridge for acpx — stdio JSON-RPC bridge to Cursor CLI (agent acp)

Package Exports

  • fzx-cursor-acp
  • fzx-cursor-acp/dist/main.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (fzx-cursor-acp) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

fzx-cursor-acp

GitHub npm License: MIT Node.js

下游 ACP 客户端 ↔ 上游 Cursor CLI(agent acp / cursor-agent acp)的 stdio 桥接适配器,与 acpxcursor harness 配合使用,重点改善 Windows 下的稳定性与可配置性。

仓库 github.com/limingfa/fzx_cursor_acp
npm 包 fzx-cursor-acp
问题反馈 Issues

目录

工作原理

flowchart LR
  subgraph downstream["下游"]
    C[acpx / 其它 ACP 客户端]
  end
  subgraph bridge["本仓库适配器"]
    B[stdio · JSON-RPC 行分帧]
  end
  subgraph upstream["上游"]
    A[Cursor CLI · agent acp]
  end
  C <-->|stdin/stdout| B
  B <-->|子进程| A
  • 协议:JSON-RPC 2.0,按行写入 stdout,日志只走 **stderr**,避免污染 ACP 流。
  • 适配器负责会话映射、权限策略、上游崩溃重启等;仍需本机安装并登录 Cursor CLI

功能特性

  • stdio + JSON-RPC 2.0 行分帧桥接
  • cursor-agent acp / agent acp 自动探测(可 --cursor-command 覆盖)
  • session/request_permission 自动策略决策
  • 会话 ID 映射与本地持久化
  • 上游进程退出自动重启
  • 所有日志输出到 stderr,避免污染协议流

快速开始

git clone https://github.com/limingfa/fzx_cursor_acp.git
cd fzx_cursor_acp
npm install
npm run build
node dist/main.js

开发模式(示例):

npm run dev -- --cursor-command agent --permission-mode approve-reads

通过 npm 安装

npm install -g fzx-cursor-acp

全局安装后可用命令 **fzx-cursor-acp**,在 ~/.acpx/config.json 中:

{
  "agents": {
    "cursor": {
      "command": "fzx-cursor-acp"
    }
  }
}

不全局安装时也可用 **npx**(首次会拉取包):

{
  "agents": {
    "cursor": {
      "command": "npx -y fzx-cursor-acp@latest"
    }
  }
}

要求:Node.js ≥ 18,且本机已安装并登录 Cursor CLI(见前置条件)。

前置条件

本适配器会启动 Cursor CLI 的 ACP 模式。请确保终端中至少一项可用:

  • agent --versioncursor-agent --version
  • 未登录时先执行:agent login(或按 Cursor 文档配置 API Key)

若命令不在 PATH,可在用户目录创建 ~/.cursor-acp-adapter.json,写入上游可执行文件的绝对路径

Windows 常见安装位置(择一,以本机为准):

  • %LOCALAPPDATA%\cursor-agent\cursor-agent.cmd
  • %LOCALAPPDATA%\cursor-agent\agent.cmd

示例:

{
  "cursor": {
    "command": "C:/Users/你的用户名/AppData/Local/cursor-agent/cursor-agent.cmd"
  }
}

适配器对 .cmd / .bat 在 Windows 上会使用 shell 启动,以便正确执行批处理入口。

与 acpx 集成

重要: acpx(例如 0.3.x)在解析配置时只使用 agents.<name>.command 字符串,不会使用 args 字段。

  • 已全局安装: "command": "fzx-cursor-acp"(推荐)。
  • 从源码目录运行: 路径含空格时,将整条命令写进 command 并为路径加引号,例如:
{
  "agents": {
    "cursor": {
      "command": "node \"D:/cursor acp/dist/main.js\""
    }
  }
}

Windows 上 ~/.acpx/ 一般为 C:\\Users\\你的用户名\\.acpx\\config.json

验证:

acpx cursor sessions new
acpx cursor "hello"
acpx cursor status
acpx cursor exec "one-shot"

在 OpenClaw 中引入

OpenClaw 通过 ACP 插件acpx 对接外部编程智能体(参见 Integrate External Coding Harnesses with OpenClaw ACP)。请先在 ~/.acpx/config.json 中将 cursor 指到本适配器(fzx-cursor-acpnode .../dist/main.js),再在 OpenClaw 中声明同一 harness。

1. 本机前提

  • Node.js(≥18);可用 npm install -g fzx-cursor-acp 或克隆本仓库后 npm install && npm run build
  • Cursor CLI 已安装并完成登录。
  • ~/.acpx/config.json 示例(全局安装):
{
  "agents": {
    "cursor": {
      "command": "fzx-cursor-acp"
    }
  }
}

(若从源码运行,仍可使用 "node \"D:/path/to/repo/dist/main.js\""。)

2. 启用 acpx 插件与 ACP

openclaw plugins install acpx
openclaw config set plugins.entries.acpx.enabled true

并在配置中打开 ACP(如 acp.enabled: trueacp.backend: "acpx"),以当前 OpenClaw 文档为准。

3. 在 agents.list 中注册(acp.agent: cursor

{
  "agents": {
    "list": [
      {
        "id": "cursor",
        "runtime": {
          "type": "acp",
          "acp": {
            "agent": "cursor",
            "backend": "acpx",
            "mode": "persistent",
            "cwd": "D:/cursor acp"
          }
        }
      }
    ]
  }
}
  • **id**:OpenClaw 侧 agent 标识,建议清晰易辨。
  • **acp.agent**:须为 **cursor**,与 acpx 内置名一致。
  • **cwd**:智能体默认工作目录。

若存在 **acp.allowedAgents**,请将 cursor 加入白名单。

4. 验证

  • 执行 **/acp doctor**,确认 acpx 与健康状态。
  • 使用 **/acp spawn cursor**(或你配置的 agentId)发起会话。

5. 说明

OpenClaw 与 ~/.acpx/config.json 需同时正确:前者决定使用哪个 acpx agent 名,后者决定该名对应的启动命令。字段以 OpenClaw ACP Agents 文档 最新版为准。

可选配置

复制 .cursor-acp-adapter.example.json.cursor-acp-adapter.json(项目级)或 ~/.cursor-acp-adapter.json(用户级)。

参数 说明
cursor.command 上游 Cursor 命令(cursor-agentagent
cursor.args 启动附加参数
permissionMode approve-all | approve-reads | deny-all
permissionTimeoutMs 权限决策超时(ms)
sessionDir 会话映射文件目录

验收脚本(Windows)

powershell -ExecutionPolicy Bypass -File ./scripts/verify-acpx.ps1

故障排查

现象 处理
agent / cursor-agent 找不到 确认 Cursor CLI 已安装且在 PATH 中;或使用 --cursor-command / cursor.command 绝对路径。
authenticate 失败 执行 agent login 或设置 CURSOR_API_KEY / CURSOR_AUTH_TOKEN(见 Cursor CLI 文档)。
协议无输出或乱码 勿向 stdout 打日志;JSON-RPC 只应出现在 stdout,日志在 stderr
上游进程频繁退出 查看 stderr;可设 LOG_LEVEL=debug。崩溃后会重启;若会话失效请 acpx cursor sessions new
agent needs reconnect 后出现 RUNTIME: Invalid params 多为 Cursor 侧会话失效。适配器会将 session/load-32602 映射为 -32001 以触发重建;仍失败时请 sessions newsessions close 后重试。
command 含空格 JSON 中整条字符串加引号,例如 "node \"D:/cursor acp/dist/main.js\""

许可与贡献

本项目以 MIT 许可证发布(见仓库内 LICENSE)。

欢迎通过 Issues 反馈问题;若提交 PR,请尽量附带复现步骤与环境说明(OS、Node、acpx / OpenClaw 版本)。

联系与作者

风之馨风之馨品牌创始人,熟悉 Prompt 提示工程RPA 自动化,以及 n8nCozeDify 等智能体与应用搭建,并关注 AI 视频AI 生图 等方向。长期主张以 RPA + AI 组合提升自动化与内容生产效率,用 RPA + AI 实现高效益创收

项目 内容
联系人 风之馨
身份 风之馨品牌创始人
微信公众号 风之馨技术录
联系方式 A18206083581

欢迎通过公众号或上述方式交流本适配器、acpx 与 OpenClaw 集成问题,以及 RPA、智能体与 AI 创作相关实践。