Skip to content

docs: rewrite remote environment guide for users - #4693

Merged
7Sageer merged 3 commits into
mainfrom
docs-remote-env-guide
Nov 5, 2026
Merged

7Sageer merged 3 commits into
mainfrom
docs-remote-env-guide

Conversation

@7Sageer

@7Sageer 7Sageer commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Requirement or Bug

远程环境指南(docs/*/guides/remote-environment.md)原本更像设计规格:大量篇幅在讲路径规范化、错误码、心跳参数、/new 的绑定优先级这类实现细节,用户真正关心的"怎么把一台机器或容器配起来"反而被淹没。这个 PR 把它改写成面向用户的任务式文档。

Bug Reproduction Steps

N/A

Root Cause

N/A

Code Changes

核心思路:指南只保留用户配置和使用远程环境时需要的信息——每种接入方式一个最小可抄的示例,加上会踩到的限制;字段级细节交给 config-files.md#environments。

页面结构(中英文镜像):

远程环境 / Remote environments
├─ 远程环境的工作原理        本机运行,目标只负责读写文件和执行命令
├─ 快速开始                  SSH 场景三步跑通:安装、写配置、--environment 启动
├─ 声明环境
│  ├─ SSH 主机 / Docker 容器 / 其他环境(kubectl exec、WSL 示例)
│  ├─ 设为默认环境
│  └─ Windows 目标环境
├─ 临时指定环境              --environment / --environment-cwd
├─ SSH 认证                  一条自检命令 + 密钥 / 密码 / 主机密钥
├─ 注意事项                  恢复、配置变更、版本、hooks/MCP、联网工具、路径、Tower
└─ 下一步

关键取舍:

决策 选择 没选 理由
目标上的程序怎么称呼 "目标环境上的 Kimi Code CLI" "执行器" 目标上装的就是同一个 kimi 二进制(官方安装脚本默认落在 ~/.kimi-code/bin/kimi,与 remoteBin 默认值一致),"执行器"对用户不直观
如何安装 链接到常规安装文档 从 CDN 手动下载放到指定路径 默认安装位置即 remoteBin 默认值,零配置
实现细节 删除 移到其他页面 心跳、握手超时、目录上限、工作区键、Askpass 机制等用户无需操作
删除的内容清单
  • defaultCwd 的路径规范化与符号链接语义
  • config.invalid、environment.not_found、environment.unavailable 等错误码
  • /new 在无会话时取 --environment 的优先级
  • 计划文件、任务输出同步细节
  • 断线检测参数(30s 空闲 ping、10s 超时)与握手超时
  • 远程执行器节(传输方式、版本校验机制)
  • SSH BatchMode / Askpass / StrictHostKeyChecking 机制说明、ControlMaster 方案
  • 限制节中的边缘项:目录 50,000 条上限、小文件延迟、同路径共用工作区、/feedback、项目级 Agent 文件、远程无热重载、Windows 进程树清理
  • "远程环境 vs. 远程控制"提示框

其余改动:

  • config-files.md:remoteBin 字段说明从"执行器路径"改为"kimi 的路径";Windows 链接指向新锚点。
  • kimi-command.md:--environment 的链接指向新锚点。

Behavior Changes and Affected Users

None。只改 docs/ 下的 Markdown,不进入任何发布产物;没有改动代码、配置、契约文件。

文档内锚点变化:#windows-目标 → #windows-目标环境、#windows-targets → #windows-target-environments、#kimi-environment-与-environment-cwd → #临时指定环境、#kimi-environment-and-environment-cwd → #picking-an-environment-for-one-launch;仓库内引用已同步更新,VitePress 构建无死链。

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • The behavior-change table above is complete, and every removed behavior or flipped default is named in the changeset and either has an escape hatch or was explicitly approved by a maintainer in this PR.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

Copilot AI balanced review requested due to automatic review settings November 5, 2026 04:19
@changeset-bot

changeset-bot Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 01f10d4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@7Hanrui

7Hanrui commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-05T04:44:53.895000Z 01f10d4 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@7Hanrui

7Hanrui commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@codex review

@7Hanrui

7Hanrui commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 01f10d40f2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

There is **no silent fallback to the local environment** after a drop: a command like `rm` or `git` that was meant for the remote machine must never land on yours. The next tool call opens the pipe again. While the target stays unreachable, tool calls fail with an `environment.unavailable` error. A call that was already in flight on the old connection fails and is not retried on the new connection.

Each SSH platform probe and the executor handshake has its own 10-second limit. SSH connections using an executor path can run up to two probes before the handshake; bare executable names skip them. A target that never answers the handshake fails with an `initialize timed out` error instead of hanging silently, and when the launcher wrote anything to stderr — a stuck password prompt or an `npx` download's progress — the error includes that tail so the cause is visible.
Only Kimi Code CLI can pick an environment for one launch. Sessions created from other clients such as the Web UI use the [default environment](#setting-a-default-environment), and run on your machine when no default is set.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Do not claim the CLI is the only environment selector

This excludes supported API and SDK clients: sessionCreateSchema accepts environment_id and environment_cwd, POST /api/v1/sessions passes them to ISessionManager.create, and the public Node SDK exposes the equivalent CreateSessionOptions.environmentId and environmentCwd. As written, consumers may incorrectly conclude that programmatic session creation cannot override the default environment; narrow this statement to clients that currently lack a picker, such as the Web UI.

Useful? React with 👍 / 👎.

- **Small-file latency adds up**: session startup reads many small files, and each read is a remote round trip; remote sessions start slower than local ones.
- **One shared connection per target**: workspaces bound to the same environment share a single connection instead of opening one each. The flip side: a connection drop affects every workspace bound to that target, and a turn in flight on the old connection fails as on a drop.
- **Resuming a session reconnects to its environment**: if the environment has been removed or cannot be reached, resuming fails.
- **Changing an environment's configuration disconnects it**: commands running on the target environment are terminated, and the next use connects with the new settings.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Limit the disconnect warning to launcher changes

When a user changes only defaultCwd, the connection is not disconnected and running commands are not terminated: declarationFingerprint() includes only the launcher fields, and reconciliation simply updates the declaration when that fingerprint is unchanged. Since defaultCwd is prominently presented as environment configuration above, this blanket warning misstates the behavior; retain the prior launcher-field qualification.

AGENTS.md reference: docs/AGENTS.md:L28-L28

Useful? React with 👍 / 👎.

### Windows target environments

Windows targets use Git Bash for the `Bash` tool, matching local Windows sessions. Install [Git for Windows](https://gitforwindows.org/) and the Windows `kimi` binary on the target. Native PowerShell tool commands and Windows Docker containers are not supported.
Windows targets need [Git for Windows](https://gitforwindows.org/) installed (the `Bash` tool runs through Git Bash).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restore the Windows Docker limitation

For a Windows Docker container, installing Git for Windows is not sufficient: the Docker launcher always runs docker exec ... sh -c, so native Windows containers are unsupported. The rewrite removes the previous explicit warning while presenting generic Windows-target setup, which can send users toward a configuration that cannot connect; state that Windows targets require SSH or a custom launcher and that Windows Docker containers are unsupported.

AGENTS.md reference: docs/AGENTS.md:L28-L28

Useful? React with 👍 / 👎.

kimi --environment dev-box
```

Once the session opens, the footer shows `dev-box` before the working directory. From then on, the files the agent reads and writes and the commands it runs are on `dev-box`.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the local plan-file exception

In Plan mode, the files handled by Read, Write, and Edit are not all on dev-box: planFileTarget() deliberately points into the local session directory, and the file tools route matching plan paths through the host filesystem before acquiring the remote environment. The rewrite deletes this exception and then states that all files the agent reads and writes are remote, so users can look for or back up plans on the wrong machine; restore the plan-file locality note.

AGENTS.md reference: docs/AGENTS.md:L28-L28

Useful? React with 👍 / 👎.

- **Hooks and MCP servers run on your machine by default**: they cannot see files on the target environment; stdio MCP servers can run on the target environment through `environment_id`, see [MCP](../customization/mcp.md).
- **Web tools run on your machine**: `WebSearch` and `FetchURL` reach the network your computer is on.
- **File paths in prompts resolve on the target environment**: `/tmp/x.png` refers to a file on the target environment; paste local images directly instead.
- **Tower mode is not supported**, and the footer does not show git status.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Document the project-agent limitation

For remote users who keep custom agents in a project's .kimi-code/agents/ or .agents/agents/, the shortened limitations list removes the only warning that neither the local launch project's nor the target project's agent profiles are discovered. The SDK regression test explicitly confirms that a remote session's profile catalog contains only user-level agents, so the missing project agent silently disappears from selectors; retain this caveat or users will reasonably expect target-project agents to work.

AGENTS.md reference: docs/AGENTS.md:L28-L28

Useful? React with 👍 / 👎.

- **`ControlMaster`**: BatchMode connections can ride an existing master connection — the basis of the password-only setup below.

Host keys use `StrictHostKeyChecking=accept-new` (trust on first use): the first connection to a new host records its key in `known_hosts` without asking, while a later host-key change fails the connection until you fix the entry by hand.
Kimi Code connects to SSH hosts non-interactively. If the following command succeeds in your terminal, Kimi Code can connect:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Describe the SSH probe as an authentication check

A successful ssh -o BatchMode=yes dev-box true only proves that a noninteractive command can authenticate and run; Kimi Code still has to locate the configured remoteBin, start exec-server, complete its initialization handshake, and pass executor-version and platform checks. The command therefore succeeds when the executor is missing, outdated, or incompatible, while the text tells users that Kimi Code can connect; describe it as an SSH authentication check instead.

AGENTS.md reference: docs/AGENTS.md:L28-L28

Useful? React with 👍 / 👎.

- **One shared connection per target**: workspaces bound to the same environment share a single connection instead of opening one each. The flip side: a connection drop affects every workspace bound to that target, and a turn in flight on the old connection fails as on a drop.
- **Resuming a session reconnects to its environment**: if the environment has been removed or cannot be reached, resuming fails.
- **Changing an environment's configuration disconnects it**: commands running on the target environment are terminated, and the next use connects with the new settings.
- **An outdated Kimi Code CLI on the target environment cannot connect**: run the install command again on the target environment to upgrade.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Upgrade the configured executor path

When an environment overrides remoteBin with an absolute path or a bare executable name, rerunning the page's standard install command updates the default ~/.kimi-code/bin/kimi, not necessarily the executable the launcher still invokes. That leaves the configured executor below the minimum version and the connection continues to fail; the guidance should tell users to replace the binary at the configured remoteBin path or update the setting to the newly installed binary.

AGENTS.md reference: docs/AGENTS.md:L28-L28

Useful? React with 👍 / 👎.

@7Sageer
7Sageer marked this pull request as ready for review November 5, 2026 04:36
@pkg-pr-new

pkg-pr-new Bot commented Nov 5, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@01f10d4
npx https://pkg.pr.new/@moonshot-ai/kimi-code@01f10d4

commit: 01f10d4

@7Sageer
7Sageer merged commit a78f55e into main Nov 5, 2026
17 checks passed
@7Sageer
7Sageer deleted the docs-remote-env-guide branch November 5, 2026 04:38

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 01f10d40f2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

### Windows target environments

Windows targets use Git Bash for the `Bash` tool, matching local Windows sessions. Install [Git for Windows](https://gitforwindows.org/) and the Windows `kimi` binary on the target. Native PowerShell tool commands and Windows Docker containers are not supported.
Windows targets need [Git for Windows](https://gitforwindows.org/) installed (the `Bash` tool runs through Git Bash).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restore the Windows process-tree cleanup caveat

For Windows targets running background commands whose leader exits first, this rewrite removes the previous warning that orphaned descendants may survive (base guide line 155). ProcessManager.maybeClose() drops the exited entry and returns on win32 instead of retaining the process group (packages/agent-core-v2/src/remote/server/processManager.ts:225-240), so users can leave remote processes behind; keep this caveat in the Windows section.

AGENTS.md reference: docs/AGENTS.md:L28-L28

Useful? React with 👍 / 👎.

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.

4 participants