Skip to content

增加拓展cursor cli 方式调用模型#14

Open
15735107240 wants to merge 1 commit into
formulahendry:mainfrom
15735107240:cursor
Open

增加拓展cursor cli 方式调用模型#14
15735107240 wants to merge 1 commit into
formulahendry:mainfrom
15735107240:cursor

Conversation

@15735107240

Copy link
Copy Markdown

增加拓展cursor cli 方式调用模型,需要先安装cursor cli脚手架,然后登陆cursor cli,启动项目(node dist/bin/wechat-acp.js --agent cursor
)就可以调用cursor

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

该 PR 为 wechat-acp 增加通过 Cursor CLI 以 ACP 协议接入的内置 agent preset,并补齐与 Cursor ACP 交互时的一些兼容性与可观测性改进,使用户可以直接通过 --agent cursor 启动并调用 Cursor。

Changes:

  • 新增内置 cursor agent preset(cursor agent acp)并在 README 中补充使用说明
  • 在创建 ACP session 前,支持按 agent 广播的 auth methods 进行 authenticate(优先 cursor_login
  • 改进错误日志输出与 permission auto-allow 的 kind 匹配兼容性(snake_case / kebab-case)

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/config.ts 增加 cursor 内置 preset(command/args)
src/bridge.ts enqueue 失败日志改为结构化错误格式输出
src/acp/client.ts permission auto-allow 支持更多 kind 命名风格
src/acp/agent-manager.ts 初始化后新增可选的 ACP authenticate 流程(支持 Cursor)
README.md 文档补充 cursor preset 与登录提示
CHANGELOG.md 记录 Unreleased 变更点

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/acp/agent-manager.ts
Comment on lines +76 to +81
const authMethod = pickAuthMethod(initResult.authMethods);
if (authMethod) {
log(`Authenticating ACP client via "${authMethod}"...`);
await connection.authenticate({ methodId: authMethod });
log("ACP authentication completed");
}

Copilot AI Mar 27, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If initialization/authentication/session creation throws (e.g., authenticate fails), the spawned agent process is not cleaned up and can be left running. Wrap the init/auth/newSession sequence in a try/catch (or try/finally) that kills the child process on failure before rethrowing so failed sessions don’t leak processes.

Copilot uses AI. Check for mistakes.
Comment thread src/bridge.ts
}
if (typeof err === "string") return err;
try {
return JSON.stringify(err);

Copilot AI Mar 27, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSON.stringify can return undefined for values like undefined, functions, or symbols. Since formatError is typed to return string, ensure the JSON branch always returns a string (e.g., fall back to String(err) when stringify returns a non-string) so log output is consistent.

Suggested change
return JSON.stringify(err);
const json = JSON.stringify(err);
return typeof json === "string" ? json : String(err);

Copilot uses AI. Check for mistakes.
Comment thread src/acp/agent-manager.ts
});
log(`ACP initialized (protocol v${initResult.protocolVersion})`);

const authMethod = pickAuthMethod(initResult.authMethods);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per https://agentclientprotocol.com/protocol/schema#session/new: May return an auth_required error if the agent requires authentication., so only when getting an auth_required, we need to trigger auth flow.

Comment thread src/acp/agent-manager.ts
if (!authMethods || authMethods.length === 0) return null;

// Prefer cursor_login when available, then fallback to first advertised method.
const cursorLogin = authMethods.find((method) => method.id === "cursor_login");

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little hacky here, we'd better not have code specific to a certain Agent.

Comment thread src/acp/agent-manager.ts

// Prefer cursor_login when available, then fallback to first advertised method.
const cursorLogin = authMethods.find((method) => method.id === "cursor_login");
return cursorLogin?.id ?? authMethods[0]?.id ?? null;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd better to allow user to select auth method.

Comment thread src/config.ts
export const BUILT_IN_AGENTS: Record<string, AgentPreset> = {
cursor: {
label: "Cursor Agent (ACP)",
command: "cursor",

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the docs (https://cursor.com/docs/cli/overview), it seems to be agent not cursor?

YrracOwl pushed a commit to YrracOwl/hermes-wechat-acp that referenced this pull request Jun 7, 2026
…ission messages

formulahendry#14: daemonize() now detects TypeScript source and replaces the .ts
entry with compiled dist/bin/wechat-acp.js for the child process.
Prints a clear error if the compiled file doesn't exist (user forgot
to run 'npm run build').

formulahendry#15: Add in-memory lastContextToken map updated from handleMessage.
handlePermissionRequest reads it and passes it to sendReply instead
of hardcoded empty string. Falls back to '' when no message has been
received yet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants