@znmin/claude-remote-cli 0.3.2 → 0.4.1

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 CHANGED
@@ -25,10 +25,10 @@ npm install -g git+https://github.com/znmin/claude-remote-cli.git
25
25
  也可以从已下载的分发包安装:
26
26
 
27
27
  ```bash
28
- npm install -g ./znmin-claude-remote-cli-0.3.2.tgz
28
+ npm install -g ./znmin-claude-remote-cli-0.4.1.tgz
29
29
  ```
30
30
 
31
- 若系统 npm 全局目录不可写,可使用 `npm install -g --prefix "$HOME/.local" ./znmin-claude-remote-cli-0.3.2.tgz`,并确保 `~/.local/bin` 在 PATH 中;卸载时也使用相同的 `--prefix`。
31
+ 若系统 npm 全局目录不可写,可使用 `npm install -g --prefix "$HOME/.local" ./znmin-claude-remote-cli-0.4.1.tgz`,并确保 `~/.local/bin` 在 PATH 中;卸载时也使用相同的 `--prefix`。
32
32
 
33
33
  npm 中不带作用域的 `claude-remote-cli` 属于其他项目。本项目使用独立的 `@znmin/claude-remote-cli` 作用域包名;请安装完整包名,或使用上述 GitHub 地址及本项目分发的 `.tgz` 文件。
34
34
 
@@ -175,10 +175,60 @@ Linux 上仍需安装 Playwright 所需的系统共享库,有窗口模式还
175
175
 
176
176
  启动时使用 `--restricted`、`--tools "WebSearch,WebFetch"`、`--strict-mcp-config`,限定工具和设置来源、关闭普通 hooks。0.2.2 起恢复 `/config`、`/model`、`/help` 等内置交互命令,不再使用禁用整个命令菜单的 `--disable-slash-commands`;通过 `disableSkillShellExecution` 和 `disableBundledSkills` 单独关闭技能内联 shell 和内置技能工作流。恢复菜单不代表所有依赖服务器项目目录或原生工具的命令都适用于本地模式。设置面板修改的是服务器上的 Claude 配置;受限模式仍只加载托管配置和本次 `--settings`,不会恢复读取普通用户/项目 settings.json,因此偏好设置的跨会话持久化仍受该限制影响,可用 `claude --model sonnet` 明确指定启动模型。保留服务器上的订阅认证,不使用跳过 OAuth 的 `--bare`。本地连接失效时不会将文件或命令操作退回服务器执行。支持 `--continue`、`--resume`、`--model`、`--effort`、`--name`、`--fallback-model`、`-p` 和输入/输出格式;`--permission-mode` 支持 `default`、`manual`、`acceptEdits`、`plan`、`auto`、`dontAsk`(受限模式本身拒绝 `bypassPermissions`)。暂不接受替换工具配置、加载插件、切换云会话等参数。
177
177
 
178
+ #### 粘贴本机截图(0.4.1)
179
+
180
+ 本地模式下,截图后直接在 Claude 输入框按平时的图片粘贴快捷键(Windows 为 Alt+V,macOS/Linux 为 Ctrl+V),就能粘贴**本机**剪贴板里的图片,和在本机运行 Claude Code 一样显示为 `[Image #1]`。
181
+
182
+ 原理:Linux 版 Claude Code 通过 `xclip -selection clipboard -t TARGETS/image/png -o` 读取剪贴板图片。每个会话在服务器临时目录放一个 `xclip` 替身,只放在本次 Claude 进程的 PATH 最前面。替身通过同一条 SSH 反向隧道向本机工具服务请求剪贴板图片(`GET /clipboard/image`,校验同一个令牌);令牌以 0600 文件保存,通过 `curl -H @文件` 读取,不出现在服务器进程列表里。其他 `xclip` 调用(读取文本、其他选区)交给服务器上原有的 `xclip`,只有在 Claude 请求图片时才会读取本机剪贴板。退出时替身和令牌文件随临时配置一起删除。
183
+
184
+ - 快捷键:服务器上的 Linux 版 Claude 默认只认 Ctrl+V,而 Windows 终端会自己处理 Ctrl+V。因此从 Windows 启动时,如果服务器上没有 `~/.claude/keybindings.json`,会自动创建它并加入 `"alt+v": "chat:imagePaste"`(`--restricted` 下同样生效)。已有该文件时不会修改,只在启动时提示需要加入的那一行。
185
+ - 本机读取方式:Windows 用 PowerShell 读取截图或资源管理器中复制的图片文件;macOS 用 `osascript`;Linux 用 `wl-paste` 或 `xclip`。
186
+ - 服务器需要 `curl` 或 `python3`。
187
+ - 服务器模式(`remote`)暂不支持;需要时可将图片保存到项目目录,同步后用 `@文件名` 引用。
188
+
178
189
  本地模式的路由规则、本地 CLAUDE.md 和用户传入的 `--append-system-prompt` 内容合并为一个文件,通过 SSH 标准输入写入服务器临时目录(权限 0600),再用 `--append-system-prompt-file` 加载;用户的追加内容排在路由规则之后,不会替换它。退出时与 MCP 配置一起删除。
179
190
 
180
191
  这是工具路由约束,不是对 Claude Code 主进程的系统隔离。认证、会话和日志仍在服务器,管理员管理策略继续生效。文件内容、命令结果和截图会经过服务器交给模型,不整体同步不代表数据不离开本机。
181
192
 
193
+ ### 项目 MCP 与内网 MCP(0.4.0)
194
+
195
+ 本地模式下,项目或用户自己配置的 MCP 由本机启动或从本机连接,再通过同一条 SSH 反向隧道提供给服务器上的 Claude。因此服务器不需要访问内网,也不需要安装这些 MCP 的依赖:
196
+
197
+ ```
198
+ 服务器 Claude ──> 127.0.0.1:隧道端口 ──SSH -R──> 本机网关 ─┬─ /mcp 内置本地工具
199
+ ├─ /mcp/jira 本机连接内网 http://10.x.x.x/mcp
200
+ └─ /mcp/db 本机启动的 stdio 程序
201
+ ```
202
+
203
+ 配置来源与 Claude Code 相同,同名时优先级为 local > project > user:
204
+
205
+ | 范围 | 存储位置 | 生效范围 |
206
+ | --- | --- | --- |
207
+ | `local`(默认) | `~/.config/claude-remote/mcp.json`,按项目目录区分 | 仅当前项目,仅本机 |
208
+ | `project` | 项目根目录 `.mcp.json`,可提交到仓库 | 当前项目 |
209
+ | `user` | `~/.config/claude-remote/mcp.json` | 本机所有项目 |
210
+
211
+ ```bash
212
+ # stdio:命令在本机运行,工作目录为项目根目录,继承本机终端环境
213
+ claude-remote mcp add db -e DB_URL='${DB_URL}' -- npx -y some-db-mcp
214
+ # HTTP/SSE:从本机连接内网地址
215
+ claude-remote mcp add -t http -s project -H 'Authorization: Bearer ${JIRA_TOKEN}' jira https://jira.corp.local/mcp
216
+ claude-remote mcp add-json -s user docs '{"type":"sse","url":"http://10.0.0.8/sse"}'
217
+ claude-remote mcp list
218
+ claude-remote mcp get jira
219
+ claude-remote mcp remove jira
220
+ claude-remote mcp reset-project-choices # 重新询问是否启用 .mcp.json 中的 MCP
221
+ ```
222
+
223
+ 默认模式为 `local` 时,`claude mcp …` 等同于 `claude-remote mcp …`;服务器模式下 `claude mcp` 仍管理服务器上的配置。
224
+
225
+ - **服务名称不变**:服务器上看到的工具名仍是 `mcp__jira__search` 这种形式,项目文档和权限规则无需修改。MCP 的 tools、resources 和 prompts 都会转发。
226
+ - **凭据不离开本机**:`${VAR}` 和 `${VAR:-默认值}` 在本机启动时用本机环境变量展开。内网地址、请求头和环境变量只在本机网关中使用,服务器上的临时配置只包含 `127.0.0.1` 隧道地址和本次会话的随机令牌。
227
+ - **项目配置需要确认**:`.mcp.json` 可以在本机运行任意命令,首次启动时会逐个显示命令或 URL,询问是否启用。选择按项目记住,配置内容变化后重新询问。非交互运行时,未确认的 MCP 会被跳过并给出提示。通过 `claude-remote mcp add -s project` 添加的条目视为本机已确认。
228
+ - **连接失败不影响启动**:每个 MCP 最多等待 30 秒,失败时打印原因(stdio 程序会附带最后几行错误输出),本次会话不提供该 MCP。stdio 程序的错误输出不会显示在终端上,避免打乱远程界面,`CLAUDE_REMOTE_DEBUG=1` 时才显示。stdio 程序在会话中意外退出时,下次调用会自动重启。退出时停止所有 MCP 程序(Windows 上包括 `npx` 等通过 `cmd.exe` 启动的整个进程树)。
229
+ - **结果大小有上限**:与内置工具相同,单次结果超过约 4 万字符时会截断较长的文本,图片等二进制内容保持不变。为此不向服务器提供工具的 `outputSchema`。单次调用最长 3 分钟,MCP 发送进度通知时会重新计时。
230
+ - **暂不支持**:需要 OAuth 登录或 `headersHelper` 的 MCP,以及 `ws` 类型;请改用固定请求头(可引用本机环境变量)。MCP 在会话中发送的列表变更通知不会转发,修改配置后请重新启动 `claude`。服务器模式(`remote`)仍由服务器自己读取同步过去的 `.mcp.json`。
231
+
182
232
  ## 同步管理(仅服务器模式)
183
233
 
184
234
  ```bash
@@ -257,7 +307,7 @@ npm run test:windows # Windows 上运行的客户端测试(CI 在 windows-la
257
307
  CLAUDE_REMOTE_INTEGRATION=1 CLAUDE_REMOTE_BROWSER_TEST=1 npm test
258
308
 
259
309
  npm pack
260
- npm install -g ./znmin-claude-remote-cli-0.3.2.tgz
310
+ npm install -g ./znmin-claude-remote-cli-0.4.1.tgz
261
311
 
262
312
  # 确定包名、版本和使用条款后,使用有发布权限的 npm 账号发布
263
313
  npm login
@@ -1,16 +1,16 @@
1
- # Third-party components
2
-
3
- The npm package contains the JavaScript CLI source and depends on `proper-lockfile` (MIT), the official `@modelcontextprotocol/sdk` (MIT), `zod` (MIT), `playwright` (Apache-2.0), and their npm-managed dependencies. Their license files are included in their respective npm packages.
4
-
5
- Playwright downloads its matching Chromium/browser components on first local-mode preparation. These components remain subject to their upstream licenses. A separate local browser context is used; this wrapper does not include the user's browser profile.
6
-
7
- Mutagen binaries are **not bundled in this npm package**. At setup/first use, the tool can reuse an existing Mutagen 0.18.1 installation, or download the matching v0.18.1 archive from the official release repository. SHA-256 values are pinned in `src/installer.js` from the official release's `SHA256SUMS` file.
8
-
9
- - Mutagen project: https://github.com/mutagen-io/mutagen
10
- - Pinned release: https://github.com/mutagen-io/mutagen/releases/tag/v0.18.1
11
- - Release checksums: https://github.com/mutagen-io/mutagen/releases/download/v0.18.1/SHA256SUMS
12
- - Upstream license: https://github.com/mutagen-io/mutagen/blob/v0.18.1/LICENSE
13
-
14
- The upstream license states that, from v0.17 onward, official release builds include SSPL-licensed code by default; other source is generally MIT or as indicated upstream. Mutagen and the automatically deployed remote agents remain subject to the upstream terms independently of this JavaScript wrapper.
15
-
16
- Claude Code is a separate product installed and authenticated on the user's server. This project does not bundle Claude Code and is not affiliated with or endorsed by Anthropic.
1
+ # Third-party components
2
+
3
+ The npm package contains the JavaScript CLI source and depends on `proper-lockfile` (MIT), the official `@modelcontextprotocol/sdk` (MIT), `zod` (MIT), `playwright` (Apache-2.0), and their npm-managed dependencies. Their license files are included in their respective npm packages.
4
+
5
+ Playwright downloads its matching Chromium/browser components on first local-mode preparation. These components remain subject to their upstream licenses. A separate local browser context is used; this wrapper does not include the user's browser profile.
6
+
7
+ Mutagen binaries are **not bundled in this npm package**. At setup/first use, the tool can reuse an existing Mutagen 0.18.1 installation, or download the matching v0.18.1 archive from the official release repository. SHA-256 values are pinned in `src/installer.js` from the official release's `SHA256SUMS` file.
8
+
9
+ - Mutagen project: https://github.com/mutagen-io/mutagen
10
+ - Pinned release: https://github.com/mutagen-io/mutagen/releases/tag/v0.18.1
11
+ - Release checksums: https://github.com/mutagen-io/mutagen/releases/download/v0.18.1/SHA256SUMS
12
+ - Upstream license: https://github.com/mutagen-io/mutagen/blob/v0.18.1/LICENSE
13
+
14
+ The upstream license states that, from v0.17 onward, official release builds include SSPL-licensed code by default; other source is generally MIT or as indicated upstream. Mutagen and the automatically deployed remote agents remain subject to the upstream terms independently of this JavaScript wrapper.
15
+
16
+ Claude Code is a separate product installed and authenticated on the user's server. This project does not bundle Claude Code and is not affiliated with or endorsed by Anthropic.
@@ -1,3 +1,3 @@
1
- #!/usr/bin/env node
2
- import { entry } from '../src/cli.js';
3
- await entry(false);
1
+ #!/usr/bin/env node
2
+ import { entry } from '../src/cli.js';
3
+ await entry(false);
package/bin/claude.js CHANGED
@@ -1,3 +1,3 @@
1
- #!/usr/bin/env node
2
- import { entry } from '../src/cli.js';
3
- await entry(true);
1
+ #!/usr/bin/env node
2
+ import { entry } from '../src/cli.js';
3
+ await entry(true);
package/package.json CHANGED
@@ -1,67 +1,67 @@
1
- {
2
- "name": "@znmin/claude-remote-cli",
3
- "version": "0.3.2",
4
- "description": "Run Claude Code on an SSH server from macOS, Linux or Windows with local filesystem, terminal and browser tools, or remote bidirectional sync",
5
- "type": "module",
6
- "license": "UNLICENSED",
7
- "engines": {
8
- "node": ">=20.11"
9
- },
10
- "os": [
11
- "darwin",
12
- "linux",
13
- "win32"
14
- ],
15
- "cpu": [
16
- "x64",
17
- "arm64"
18
- ],
19
- "bin": {
20
- "claude": "bin/claude.js",
21
- "claude-remote": "bin/claude-remote.js"
22
- },
23
- "files": [
24
- "bin/",
25
- "src/",
26
- "scripts/postinstall.js",
27
- "README.md",
28
- "THIRD_PARTY_NOTICES.md"
29
- ],
30
- "scripts": {
31
- "postinstall": "node scripts/postinstall.js",
32
- "lint": "eslint .",
33
- "test": "node --test test/*.test.js",
34
- "test:windows": "node --test test/windows.test.js test/local-tools.test.js test/browser-choice.test.js",
35
- "prepublishOnly": "npm run lint && npm test"
36
- },
37
- "keywords": [
38
- "claude",
39
- "ssh",
40
- "remote",
41
- "cli",
42
- "sync"
43
- ],
44
- "publishConfig": {
45
- "access": "public",
46
- "registry": "https://registry.npmjs.org/"
47
- },
48
- "dependencies": {
49
- "@modelcontextprotocol/sdk": "1.32.2",
50
- "playwright": "1.64.1",
51
- "proper-lockfile": "4.1.2",
52
- "zod": "4.6.7"
53
- },
54
- "repository": {
55
- "type": "git",
56
- "url": "git+https://github.com/znmin/claude-remote-cli.git"
57
- },
58
- "homepage": "https://github.com/znmin/claude-remote-cli#readme",
59
- "bugs": {
60
- "url": "https://github.com/znmin/claude-remote-cli/issues"
61
- },
62
- "devDependencies": {
63
- "@eslint/js": "9.39.5",
64
- "eslint": "9.39.5",
65
- "globals": "17.14.0"
66
- }
67
- }
1
+ {
2
+ "name": "@znmin/claude-remote-cli",
3
+ "version": "0.4.1",
4
+ "description": "Run Claude Code on an SSH server from macOS, Linux or Windows with local filesystem, terminal and browser tools, or remote bidirectional sync",
5
+ "type": "module",
6
+ "license": "UNLICENSED",
7
+ "engines": {
8
+ "node": ">=20.11"
9
+ },
10
+ "os": [
11
+ "darwin",
12
+ "linux",
13
+ "win32"
14
+ ],
15
+ "cpu": [
16
+ "x64",
17
+ "arm64"
18
+ ],
19
+ "bin": {
20
+ "claude": "bin/claude.js",
21
+ "claude-remote": "bin/claude-remote.js"
22
+ },
23
+ "files": [
24
+ "bin/",
25
+ "src/",
26
+ "scripts/postinstall.js",
27
+ "README.md",
28
+ "THIRD_PARTY_NOTICES.md"
29
+ ],
30
+ "scripts": {
31
+ "postinstall": "node scripts/postinstall.js",
32
+ "lint": "eslint .",
33
+ "test": "node --test test/*.test.js",
34
+ "test:windows": "node --test test/windows.test.js test/local-tools.test.js test/browser-choice.test.js test/mcp-proxy.test.js",
35
+ "prepublishOnly": "npm run lint && npm test"
36
+ },
37
+ "keywords": [
38
+ "claude",
39
+ "ssh",
40
+ "remote",
41
+ "cli",
42
+ "sync"
43
+ ],
44
+ "publishConfig": {
45
+ "access": "public",
46
+ "registry": "https://registry.npmjs.org/"
47
+ },
48
+ "dependencies": {
49
+ "@modelcontextprotocol/sdk": "1.32.2",
50
+ "playwright": "1.64.1",
51
+ "proper-lockfile": "4.1.2",
52
+ "zod": "4.6.7"
53
+ },
54
+ "repository": {
55
+ "type": "git",
56
+ "url": "git+https://github.com/znmin/claude-remote-cli.git"
57
+ },
58
+ "homepage": "https://github.com/znmin/claude-remote-cli#readme",
59
+ "bugs": {
60
+ "url": "https://github.com/znmin/claude-remote-cli/issues"
61
+ },
62
+ "devDependencies": {
63
+ "@eslint/js": "9.39.5",
64
+ "eslint": "9.39.5",
65
+ "globals": "17.14.0"
66
+ }
67
+ }
@@ -1,11 +1,11 @@
1
- import { ensureMutagen } from '../src/installer.js';
2
-
3
- if (process.env.CLAUDE_REMOTE_PREPARE_SYNC === '1' && process.env.CLAUDE_REMOTE_SKIP_DOWNLOAD !== '1') {
4
- try {
5
- await ensureMutagen();
6
- } catch (error) {
7
- // Offline installation and npm --ignore-scripts remain supported: retry at first use.
8
- console.warn(`CLI 已安装,同步工具准备未完成:${error.message}\n首次连接时会重试。`);
9
- }
10
- }
11
- console.log('安装完成,运行 claude 开始。');
1
+ import { ensureMutagen } from '../src/installer.js';
2
+
3
+ if (process.env.CLAUDE_REMOTE_PREPARE_SYNC === '1' && process.env.CLAUDE_REMOTE_SKIP_DOWNLOAD !== '1') {
4
+ try {
5
+ await ensureMutagen();
6
+ } catch (error) {
7
+ // Offline installation and npm --ignore-scripts remain supported: retry at first use.
8
+ console.warn(`CLI 已安装,同步工具准备未完成:${error.message}\n首次连接时会重试。`);
9
+ }
10
+ }
11
+ console.log('安装完成,运行 claude 开始。');