@m2canvas/connect 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/bridge/precheck.js +2 -1
- package/dist/clients.js +1 -1
- package/dist/config-files.js +14 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,11 +14,11 @@ It finds the supported clients you have installed, shows what it will change, an
|
|
|
14
14
|
|
|
15
15
|
| Client | How it is set up | Sign-in |
|
|
16
16
|
|---|---|---|
|
|
17
|
-
| Claude Code | `claude mcp add --transport http --scope user
|
|
18
|
-
| Codex (CLI or the desktop app's bundled CLI) | appends `[mcp_servers.
|
|
19
|
-
| Cursor | merges `
|
|
20
|
-
| OpenCode | merges `
|
|
21
|
-
| Qoder (CLI + desktop app) | `qodercli mcp add -s user -t http
|
|
17
|
+
| Claude Code | `claude mcp add --transport http --scope user patch …` | `claude mcp login patch` |
|
|
18
|
+
| Codex (CLI or the desktop app's bundled CLI) | appends `[mcp_servers.patch]` to `~/.codex/config.toml` | `codex mcp login patch` |
|
|
19
|
+
| Cursor | merges `patch` into `~/.cursor/mcp.json`, then `cursor-agent mcp enable patch` | `cursor-agent mcp login patch` |
|
|
20
|
+
| OpenCode | merges `patch` into `~/.config/opencode/opencode.json`, keeping the file's existing format | `opencode mcp auth patch` |
|
|
21
|
+
| Qoder (CLI + desktop app) | `qodercli mcp add -s user -t http patch …` | in Qoder: Extensions → Connectors → patch → Authorize |
|
|
22
22
|
|
|
23
23
|
Clients that already have an entry pointing at `mcp.patch.design`, under any name, are skipped. Before a config file is edited, the original is copied to `<file>.bak-m2canvas`.
|
|
24
24
|
|
package/dist/bridge/precheck.js
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* 不退回本机的 claude(否则预检和会话看的是两个程序)。
|
|
17
17
|
*/
|
|
18
18
|
import { join } from 'node:path';
|
|
19
|
+
import { SERVER_NAME } from '../config-files.js';
|
|
19
20
|
import { findM2Names } from './m2-config.js';
|
|
20
21
|
import { ADAPTERS, CODEX_BIN_LINK, CODEX_SCRIPT } from './adapters.js';
|
|
21
22
|
import { combinedOutput } from './exec.js';
|
|
@@ -57,7 +58,7 @@ function toLogin(parse, next) {
|
|
|
57
58
|
return { state: parse.state, next: parse.state === 'logged_out' || parse.state === 'unknown' ? next : null, raw: parse.raw };
|
|
58
59
|
}
|
|
59
60
|
function toM2(parse, nextFor) {
|
|
60
|
-
const next = parse.state === 'not_configured' ? { kind: 'configure' } : nextFor(parse.state, parse.entry ??
|
|
61
|
+
const next = parse.state === 'not_configured' ? { kind: 'configure' } : nextFor(parse.state, parse.entry ?? SERVER_NAME);
|
|
61
62
|
return { state: parse.state, entry: parse.entry, next, raw: parse.raw };
|
|
62
63
|
}
|
|
63
64
|
function plan(agent, deps) {
|
package/dist/clients.js
CHANGED
|
@@ -6,7 +6,7 @@ function jsonExisting(path, find) {
|
|
|
6
6
|
const read = readJson(path);
|
|
7
7
|
return read.kind === 'ok' ? find(read.value) : null;
|
|
8
8
|
}
|
|
9
|
-
/** 用户级 server
|
|
9
|
+
/** 用户级 server 表里同名(`SERVER_NAME`)入口指向别处 → blocked 提示(D-C1);读不出文件按无冲突,由客户端自己的 CLI 报错 */
|
|
10
10
|
function jsonConflict(path, servers) {
|
|
11
11
|
const read = readJson(path);
|
|
12
12
|
return read.kind === 'ok' && hasNameConflictInServers(servers(read.value)) ? nameConflictNote(path) : null;
|
package/dist/config-files.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
//
|
|
1
|
+
// 各客户端配置文件的纯函数读写:查已有的本产品入口(按 MCP 主机认,不看名字)、按原格式合并。全部不碰磁盘,便于单测。
|
|
2
2
|
// MCP 地址来自 site-config.ts(connect 唯一的站点配置来源),这里转出供 cli.ts / clients.ts 沿用原导出名。
|
|
3
3
|
import { M2_MCP_URL, MCP_HOST } from './site-config.js';
|
|
4
4
|
export { M2_MCP_URL };
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* connect 写进各家 agent 配置的条目名(change mcp-entry-name-patch,2026-11-10 起由 `m2` 改为 `patch`)。
|
|
7
|
+
* 只用于新写入与同名冲突判断;识别已有条目一律按 MCP 主机(`isM2Url`),所以改名前写下、指向当前主机的 `m2`
|
|
8
|
+
* 照常认作已配置,不改名、不追加第二条(design D2)。网站接入片段与 `agent-setup.md` 用同一个名字,改动时同步。
|
|
9
|
+
*/
|
|
10
|
+
export const SERVER_NAME = 'patch';
|
|
6
11
|
function isObject(value) {
|
|
7
12
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
8
13
|
}
|
|
@@ -28,9 +33,10 @@ export function findM2Entry(servers) {
|
|
|
28
33
|
return null;
|
|
29
34
|
}
|
|
30
35
|
/**
|
|
31
|
-
* server 表里已有名为 `
|
|
32
|
-
*
|
|
33
|
-
*
|
|
36
|
+
* server 表里已有名为 `SERVER_NAME`、但不指向当前 MCP 主机的入口(change domain-cutover design D-C1,
|
|
37
|
+
* mcp-entry-name-patch D3 起判的是 `patch`)。我们只会以这个名字写入;同名入口指向别处时既不能追加
|
|
38
|
+
* (Codex 的 TOML 会出现重复表、整个文件解析失败),也不能覆盖(那可能是用户自己的 server,静默改掉用户看不出发生了什么)。
|
|
39
|
+
* 一律报冲突交给用户。
|
|
34
40
|
*/
|
|
35
41
|
export function hasNameConflictInServers(servers) {
|
|
36
42
|
if (!isObject(servers) || !Object.hasOwn(servers, SERVER_NAME))
|
|
@@ -40,7 +46,7 @@ export function hasNameConflictInServers(servers) {
|
|
|
40
46
|
}
|
|
41
47
|
/** 同名冲突的提示(给 ClientPlan.blocked 用):说明不改的原因与用户要做的事,不打印对方的地址 */
|
|
42
48
|
export function nameConflictNote(where) {
|
|
43
|
-
return `${where} already has an MCP server named "${SERVER_NAME}" that does not point to
|
|
49
|
+
return `${where} already has an MCP server named "${SERVER_NAME}" that does not point to Patch (${MCP_HOST}). Remove or rename it, then run this again.`;
|
|
44
50
|
}
|
|
45
51
|
/** Claude Code `~/.claude.json` 顶层 mcpServers = user scope。 */
|
|
46
52
|
export function findInClaudeConfig(config) {
|
|
@@ -73,7 +79,7 @@ export function findInCodexToml(toml) {
|
|
|
73
79
|
}
|
|
74
80
|
return null;
|
|
75
81
|
}
|
|
76
|
-
/** Codex `config.toml` 里已有 `[mcp_servers
|
|
82
|
+
/** Codex `config.toml` 里已有 `[mcp_servers.<SERVER_NAME>]` 段且段内 url 不指向当前 MCP 主机(判定见 `hasNameConflictInServers`) */
|
|
77
83
|
export function hasCodexNameConflict(toml) {
|
|
78
84
|
let inTarget = false;
|
|
79
85
|
let found = false;
|
|
@@ -132,7 +138,7 @@ export function mergeOpencodeConfig(config) {
|
|
|
132
138
|
return { existing: null, conflict: false, config: { ...base, mcp: nextMcp } };
|
|
133
139
|
}
|
|
134
140
|
/**
|
|
135
|
-
* Codex `config.toml` 追加
|
|
141
|
+
* Codex `config.toml` 追加 `[mcp_servers.<SERVER_NAME>]` 段。不走 `codex mcp add`:它在没有已存 token 时会顺手启动 OAuth
|
|
136
142
|
* 并阻塞等浏览器回调(实测),agent 代跑时输出被捕获、链接不可见,命令永远不返回。
|
|
137
143
|
* 只做追加、不解析重写,用户原有内容与注释逐字保留;调用方先用 findInCodexToml 判重。
|
|
138
144
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m2canvas/connect",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Connect your local agent clients (Claude Code, Codex, Cursor, OpenCode, Qoder) to M2 Canvas over MCP in one command, and run the local bridge that lets M2 drive them over ACP.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|