文档Documentation
LinkShell 分两部分:电脑上的 CLI(托管 Agent 会话),和手机上的 App。下面按顺序走一遍。LinkShell has two parts: the CLI on your computer, which hosts the agent sessions, and the app on your phone. Here it is, in order.
安装Install
电脑需要 macOS 或 Linux,Node.js 22.13 或更新版本(LinkShell 用 Node 自带的 SQLite 保存会话)。You need macOS or Linux and Node.js 22.13 or newer (LinkShell stores sessions in Node's built-in SQLite).
$ npm i -g linkshell-cli
# 或or
$ brew install LiuTianjie/linkshell/linkshell
# 或or
$ curl -fsSL https://liutianjie.github.io/LinkShell/install.sh | sh
要用的 Agent 需要你自己安装并在电脑上登录好(比如 claude、codex login、gemini、copilot login)。手机 App:iPhone · Android APK。Install and sign in to the agents you want to use on the computer yourself (for example claude, codex login, gemini, copilot login). Phone app: iPhone · Android APK.
启动 LinkShellStart LinkShell
$ linkshell host --daemon # 后台运行run in the background
$ linkshell host status # Agent、会话、网关状态agents, sessions, gateway
$ linkshell host stop
host 用你登录 shell 的环境变量启动 Agent,所以 PATH、代理、API key 这些和在终端里一样。会话和历史保存在 ~/.linkshell,重启电脑不需要重新配对。The host starts agents with your login shell's environment, so PATH, proxies and API keys match your terminal. Sessions and history live in ~/.linkshell; restarting the computer doesn't need a new pairing.
连接手机Connect a phone
Pro:官方网关Pro: the official gateway
$ linkshell login
$ linkshell host stop && linkshell host --daemon
在 App 里用同一个账号登录,电脑会自动出现在「电脑」页,不需要扫码。了解 Pro。Sign in to the app with the same account and the computer shows up under Computers; no QR code needed. About Pro.
自建网关:配对Your own gateway: pairing
$ linkshell host --gateway wss://gw.example.com --daemon
$ linkshell pair
终端里会出现二维码和 6 位配对码。在 App 的「电脑 → 添加电脑」里扫码或输入配对码。网关地址会保存下来,之后启动 host 不用再写 --gateway;--gateway off 可以关掉。The terminal shows a QR code and a 6-digit code. In the app, go to Computers → Add computer and scan it or type the code. The gateway is remembered, so later starts don't need --gateway; --gateway off turns it off.
自建网关Self-host a gateway
网关只转发加密数据,不需要多少资源。任选一种:A gateway only relays encrypted data and needs very little. Pick one:
# 在服务器上用 CLIwith the CLI on a server
$ linkshell gateway --port 8787 --daemon
# 或 Dockeror Docker
$ docker run -d --name linkshell-gateway -p 8787:8787 \
-v linkshell-gateway:/data nickname4th/linkshell-gateway
公网上请在前面加一层 HTTPS 反向代理(Caddy、Nginx 都行),然后用 wss://你的域名。只在家里用的话,可以直接把网关跑在这台电脑上,用 ws://局域网IP:8787。On the internet, put an HTTPS reverse proxy in front (Caddy or Nginx) and use wss://your-domain. For home use only, you can run the gateway on the computer itself and use ws://LAN-IP:8787.
在电脑终端里用From your terminal
$ linkshell claude [参数args] # Claude Code,可交给手机Claude Code, hand-off ready
$ linkshell codex [参数args] # Codex,和手机同步Codex, shared with the phone
参数原样传给 Agent(比如 linkshell claude --resume <id>)。Claude 在电脑上运行时,手机能实时看到进度;在手机上发消息就接管,终端会显示「已由手机接管」,按任意键收回。Arguments pass straight through (for example linkshell claude --resume <id>). While Claude runs at your desk the phone follows along live; sending from the phone takes over, the terminal says so, and any key takes it back.
Claude 在收到第一条消息之前不会保存会话,所以一个还没发过消息的会话不能交给手机。Claude doesn't save a session until its first message, so a session with no messages yet can't be handed to the phone.
在手机上用On your phone
- 新建会话:选 Agent 和项目目录,直接开始。New session: pick an agent and a project folder and go.
- 回答提问:Codex(含 Desktop 异步提问)、Claude、Cursor 和 Grok 的结构化问题会显示「需要用户输入」,可在手机卡片中作答或跳过。Cursor 支持选择,其他类型按 Agent 提供的能力支持文字回答。Answer questions: Codex (including Desktop asynchronous questions), Claude, Cursor and Grok show when input is needed. Answer or skip from the phone's question card. Cursor supports choices; text answers depend on the agent.
- 忙的时候发消息:消息在输入框上方排队,可以调整顺序、取回编辑、立即发送(Codex 和 Claude 直接插进当前这一轮,其他 Agent 先停下当前这一轮);停止时排队的文字会放回输入框。Messages while busy: they queue above the composer, where you can reorder them, take one back to edit, or send it now (into the running turn for Codex and Claude; other agents stop the turn first). Stopping puts queued text back in the composer.
- 分叉与 worktree:每条回复下方可以「从这里分叉」,会话菜单里可以分叉整个会话;新建会话或分叉时可以选择放进新的 git worktree(在
~/.linkshell/worktrees/ 下,独立分支),删除会话时没有改动的 worktree 会一起清掉。Fork and worktrees: fork from under any reply, or the whole session from its menu; a new session or a fork can go into a new git worktree (under ~/.linkshell/worktrees/, on its own branch). A worktree without changes is removed with its session.
- 命令面板:输入
/、点击输入框的命令按钮,或从会话菜单打开命令面板,搜索 Agent 的命令与 skills;草稿会保留。Command palette: type /, tap the composer’s command button, or choose Commands from the session menu. Search commands and skills without losing your draft.
- 持续目标:Codex 和 Claude Code 支持
/goal,也可从菜单进入目标页面。Codex 可设置预算、暂停和继续;Claude 可设置或清除完成条件。需电脑上的 Agent 支持相应能力。Persistent goals: use /goal with Codex or Claude Code, or open the goal screen from the menu. Codex supports token budgets, pause and resume; Claude supports setting and clearing completion conditions. Requires support from the installed agent.
- 后台任务:
/tasks 或标题旁的入口可查看回复结束后仍运行的命令、输出和退出码。Codex 支持单任务停止;Claude Bash / Monitor 目前只支持查看,停止请在电脑端操作。Background tasks: /tasks or the session header shows commands that keep running after a reply, their output and exit codes. Stop individual Codex tasks; Claude Bash / Monitor tasks are viewable, with stopping handled on the computer.
- 屏幕适配:iPhone Duo 和普通 iPhone 都会根据可用空间调整聊天、输入框和操作区。Adaptive layouts: the conversation, composer and controls adapt to the available space on iPhone Duo and standard iPhones.
- 工作流、子 Agent 与文件:会话标题旁的按钮列出工作流和子 Agent;输入框上方可回到后台工作流;会话和终端的菜单里可以浏览项目文件。Workflows, sub-agents and files: the button beside a session's title lists its Workflows and sub-agents; return to background runs above the composer, and browse project files from a session's or a terminal's menu.
- 设置:输入框下方可以换模型、思考强度、权限模式(取决于 Agent 提供了哪些)。Settings: under the composer, change model, effort and permission mode (whatever the agent offers).
- 整理:长按会话可以重命名、归档、删除;归档的会话在首页底部。不再使用的电脑,在账号页的「我的电脑」里长按移除。Tidying: long-press a session to rename, archive or delete it; archived sessions are at the bottom of Home. A computer you no longer use: long-press it under My computers on the account page.
- 终端、预览、屏幕:在「电脑」页开终端、打开本地端口(可全屏),或看电脑屏幕,并用触控板和键盘控制它。屏幕工具条上有快捷操作(复制、粘贴、切换应用、调度中心、截图、F 键,也可以添加自己的)和「发送文字」(写好一段再发,可以带上手机剪贴板)。需要 Apple 芯片的 Mac;两项权限由
linkshell setup 带你打开,单独设置用 linkshell screen。Terminal, preview, screen: from Computers, open a terminal, open a local port (full screen available), or view the screen and control it with a trackpad and keyboard. The screen's toolbar has one-tap shortcuts (copy, paste, switch app, Mission Control, screenshots, F-keys, and your own) and a text box to write in and send, with the phone's clipboard. Needs a Mac with Apple silicon; linkshell setup takes you through its two permissions, linkshell screen does just that part.
远程桌面的画面与连接Remote screen quality and connection
Mac 使用硬件编码的实时视频,支持原生播放的 iOS 版本默认用原生接收与 Metal 显示,保留同一套悬浮工具栏、手势和键盘。最高 120 帧是请求上限,实际效果取决于电脑与手机的显示器、网络、电量和温控。Android 和浏览器使用常规视频播放器。The Mac sends hardware-encoded real-time video. Supported iOS versions use native reception and Metal display with the same floating controls, gestures and keyboard. The 120 fps ceiling is a request; actual performance depends on both displays, network, power and temperature. Android and browsers use the standard video player.
在「连接信息」中选择流畅 1280、标准 1920、高清 2560 或原生宽度(最高 3840,不超过源屏幕)。直连失败时 iOS 先尝试常规视频,再转入加密中继兼容播放;兼容方式自动降低分辨率与帧率,不受这个清晰度选项控制。重新进入或重试会重新尝试首选路径。原生播放需要包含该功能的 iOS 安装包。Connection info offers widths of 1280, 1920, 2560 or native (up to 3840, bounded by the source display). If direct video fails, iOS tries standard video and then encrypted relay playback. Compatibility playback adapts resolution and frame rate independently of this width choice. Reopening or retrying starts with the preferred path again. Native playback requires an iOS app binary that includes it.
稳定 120 fps、稳定 4K/60 和真机弱网效果仍待验证。完整技术链路、回退规则和已知问题见 远程桌面架构与链路图。Sustained 120 fps, stable 4K/60 and real-device weak-network performance remain unproven. See the remote-desktop architecture and diagrams for the paths, fallback rules and known issues.
iPhone Duo 与自适应布局iPhone Duo and adaptive layouts
从 App 2.3.7 起,LinkShell 支持 iPhone Duo 的可用区域和折叠信息。宽度足够时,打开「改动」或「预览」可以与对话并排;折叠区域会参与内容与操作区的布局计算。较窄的窗口与普通 iPhone 使用单栏布局。布局变化时保留会话和工具面板的状态。From app 2.3.7, LinkShell uses iPhone Duo’s available regions and fold information. With sufficient width, Changes or Preview can sit beside the conversation. Fold regions inform the layout of content and controls; narrower windows and standard iPhones use one column. Session and tool-panel state is preserved as the layout changes.
Duo 布局已通过模拟器交互验证;实际显示取决于系统报告的尺寸和姿态。Duo layouts have been checked in the simulator; actual presentation depends on the size and posture reported by the system.
在手机上用 Computer UseUse Computer Use from your phone
在手机会话里告诉 Codex 你想做什么,让它操作电脑上的浏览器或桌面应用。操作画面会在浮窗中实时预览,你可以边看边补充要求,继续推进任务。Tell Codex what you want done in the phone conversation and let it work in your computer's browser or desktop apps. Watch its actions live in a floating preview and keep giving instructions as it works.
- 边聊边看:小窗不随聊天滚动,可以拖到一边、点击放大,也可以收起成图标或关闭;关闭后在会话菜单点「显示电脑画面」恢复。Watch while chatting: the preview stays in place as you scroll. Drag it aside, tap to enlarge it, collapse it to an icon or close it. Reopen it with “Show computer preview” in the session menu.
- 回来接着看:回合结束后保留最后画面,重新进入会话会恢复预览状态。Pick up where you left off: the last frame stays after the turn, and reopening the session restores the preview state.
目前支持 macOS 上的 Codex,需已配置兼容的 Computer Use 工具,并使用支持此功能的电脑端和手机 App。请在 Mac 上允许 LinkShell 录制屏幕,可运行 linkshell screen 完成设置。Currently supports Codex on macOS with compatible Computer Use tools configured, and versions of the computer and phone apps that support this feature. Allow LinkShell to record the Mac's screen; run linkshell screen to set it up.
命令一览Commands
linkshell setup
- 首次设置:启动 LinkShell、打开屏幕的两项权限、连接手机First-time setup: start LinkShell, the screen's two permissions, connect your phone
linkshell host [--daemon] [--gateway <url>]
- 启动 LinkShell;
status、stopStart LinkShell; status, stop
linkshell pair
- 通过网关配对手机Pair a phone through the gateway
linkshell devices
- 列出已配对的手机;
remove 移除一台List paired phones; remove unpairs one
linkshell screen
- 设置看屏幕和控制屏幕(macOS 的两项权限)Set up watching and controlling the screen (the two macOS permissions)
linkshell login / logout
- Pro 账号(官方网关)Pro account (official gateway)
linkshell claude / codex
- 在终端里启动 Agent,可与手机共享Start an agent in your terminal, shared with the phone
linkshell gateway [--port] [--daemon]
- 运行自己的网关;
status、stopRun your own gateway; status, stop
linkshell doctor
- 检查环境和连接Check the environment and connectivity
linkshell upgrade
- 升级到最新版Upgrade to the latest version
常见问题FAQ
App 显示「电脑暂时连不上」The app says the computer can't be reached
确认电脑没睡眠、linkshell host status 里网关是已连接,然后运行 linkshell doctor。连接恢复后 App 会自动重连。Check the computer is awake and linkshell host status shows the gateway connected, then run linkshell doctor. The app reconnects on its own once it's back.
Agent 显示「未登录」An agent shows "not logged in"
在电脑终端里给那个 Agent 登录一次(claude 里的 /login、codex login、copilot login 等),LinkShell 用的就是那份登录。Sign in to that agent once in a terminal on the computer (/login in claude, codex login, copilot login…); LinkShell uses that sign-in.
从 1.x 升级Upgrading from 1.x
2.0 的 App 和电脑端协议都换了,需要两边一起升级,再重新配对一次。1.x 的 App 和 linkshell start 已不再支持。2.0 changed both the app and the computer side, so upgrade both and pair again. The 1.x app and linkshell start are no longer supported.