显示HN:Coasts – 容器化代理主机
Show HN: Coasts – Containerized Hosts for Agents

原始链接: https://github.com/coast-guard/coasts

## Coasts:轻松打造本地开发环境 Coasts 是一款 CLI 工具,可在单台机器上运行多个隔离的完整开发环境,并提供本地可观察性 UI。它旨在与您现有的设置协同工作——无论您是否使用 Docker Compose——只需在仓库根目录下放置一个 `Coastfile` 即可。 Coasts 只需构建一次,即可运行多个实例,并根据需要管理卷和网络。您可以“检出”特定的环境,将其绑定到标准端口,或使用动态端口进行监控。它与提供商无关,这意味着它可以与任何 AI 工具或代理 Harness 配合使用,并且仅依赖于 Git 工作树来实现灵活性。 重要的是,Coasts 优先考虑离线使用,并且没有托管服务依赖,从而避免了供应商锁定。目前它主要针对 macOS,并提供 Linux 支持。开发涉及一个三终端工作流程:一个守护进程、一个 Rust 重建过程和一个具有热重载功能的 Web UI。 您可以在 [coasts.dev](https://coasts.dev) 上找到安装说明和文档,并在 [coasts-demo 仓库](https://github.com/coasts-dev/coasts-demo) 中找到演示项目。

## 海岸:隔离的开发运行时 Coasts 是一款新工具,旨在简化在单台机器上运行多个隔离的开发环境,尤其适用于使用 Codex 和 Conductor 等 AI 代理的工作。它允许开发者启动多个“容器化主机”——本质上是 Docker-in-Docker 运行时——基于现有的 `docker-compose` 文件,无需修改。 其核心思想是为代理提供专用的运行时,以隔离方式测试代码变更。Coasts 通过从与项目关联的 `Coastfile` 创建 Docker 镜像来实现这一点,然后将该运行时分配给特定的 git 工作树。它使用绑定挂载和挂载传播有效地管理工作树切换,最大限度地减少停机时间。 主要功能包括动态端口映射、 “检出”海岸以直接访问的能力,以及卷拓扑和服务行为的配置选项。虽然 Coasts 本身不是沙箱工具,但它旨在与现有的主机端沙箱解决方案良好集成。开发者承认 DinD 的开销,并正在探索 Podman 作为更轻量级的替代方案,并提供“共享服务”以减少重复。 更多信息和演示请访问:[https://github.com/coast-guard](https://github.com/coast-guard) 和 [https://coasts.dev/docs/learn-coasts-videos](https://coasts.dev/docs/learn-coasts-videos)
相关文章

原文

Coasts

Coasts (Containerized Hosts) is a CLI tool with a local observability UI for running multiple isolated instances of a full development environment on a single machine. It works out of the box with your current setup: no changes to your existing application code, just a small Coastfile at your repo root. If you already use Docker Compose, Coasts can boot from your existing docker-compose.yml; if you do not use Docker or Compose, Coasts works just as well.

Build once and run N instances with whatever volume and networking topology your project needs. Check out one coast at a time to bind canonical ports to your host, and use dynamic ports to peek into the progress of any worktree.

Coasts is agnostic to AI providers and agent harnesses. The only host requirement is Git worktrees, so you can switch tools without changing how you work and without any harness-specific environment setup.

Coasts is also offline-first with no hosted service dependency, so there is no vendor lock-in risk: even if we disappeared, your local workflow would keep running.

Install the latest public release:

eval "$(curl -fsSL https://coasts.dev/install)"

Visit coasts.dev for the website, docs, and installation instructions.

Coastguard overview showing multiple coasts

For the full user-facing documentation, see the Coasts docs.

Want a concrete example to explore? Check out the coasts-demo repository for a small demo project you can use to try Coasts end to end.

To contribute, read the contributing guide for PR guidelines.

Note: Coasts is currently macOS-first. Linux development works, but canonical ports below 1024 require host setup before coast checkout can bind them.

For local HTTPS stacks that use Caddy, Coast now reuses one local Caddy root CA per Coast installation. Trust that root once and recreated workspaces under the same COAST_HOME keep using it. coast and coast-dev stay separate because they use different Coast homes.

  • Rust (stable toolchain)
  • Docker
  • Node.js
  • socat (brew install socat on macOS, sudo apt install socat on Ubuntu)
  • Git

Run the setup script once to build the web UI, compile the workspace, and symlink coast-dev / coastd-dev into ~/.local/bin:

On first run it adds ~/.local/bin to your PATH — restart your shell or source ~/.zshrc to pick it up.

Dev mode uses ~/.coast-dev/ and port 31416, so it never conflicts with a global coast install on port 31415.

That separation also applies to local HTTPS trust. coast-dev reuses a stable Caddy root under ~/.coast-dev/caddy/pki/..., while the regular install uses ~/.coast/caddy/pki/....

You can inspect or export the active install's root certificate with:

coast cert info
coast cert export --to ~/Downloads/coast-root.crt

Coast does not install the certificate into your OS or browser trust store automatically. Export it, then import/trust it wherever your environment needs it.

Day-to-day development workflow

You'll want three terminals:

Terminal 1 — dev daemon:

coast-dev daemon start        # start in background
# or: coastd-dev --foreground # start in foreground for log output

After Rust changes are rebuilt by make watch, restart the daemon to pick them up:

Terminal 2 — Rust rebuild on save:

This runs cargo watch and recompiles the workspace whenever Rust source files change. After a rebuild completes, restart the daemon in Terminal 1.

Terminal 3 — web UI with hot reload:

cd coast-guard
npm install
npm run dev:coast-dev

This starts the Vite dev server on http://localhost:5173 with hot module replacement, proxying /api requests to the dev daemon at localhost:31416.

Use npm run dev (without :coast-dev) if you're developing the UI against a production daemon on port 31415.

The Makefile is the primary entry point for development tasks:

Command What it does
make lint Check formatting (cargo fmt --check) and run cargo clippy
make fix Auto-format and auto-fix clippy warnings
make test Run the full unit test suite across all workspace crates
make check make lint + make test in sequence
make coverage Generate an HTML coverage report and open it
make watch Rebuild on source changes (requires cargo-watch)

Generating TypeScript types

The web UI depends on TypeScript types generated from Rust structs via ts-rs. After changing any Rust types that are used by the UI, regenerate the bindings:

cd coast-guard
npm run generate:types

This runs cargo test -p coast-core export_bindings and rebuilds the barrel file in src/types/generated/.

Generating the docs manifest

The docs viewer in the UI reads from a generated manifest. After changing any markdown files in docs/, regenerate it:

cd coast-guard
npm run generate:docs

Docs localization and search indexes

Translation and search index generation are centralized Python scripts invoked via the Makefile:

make docs-status                      # show which docs need translation
make translate LOCALE=es              # translate docs for one locale
make translate-all                    # translate all supported locales
make doc-search LOCALE=en             # generate search index for one locale
make doc-search-all                   # generate search indexes for all locales

Both scripts read OPENAI_API_KEY from the environment or from .env in the project root. See .env.example.

Runs cargo test --workspace across all crates.

Integration tests live in integrated-examples/ and exercise full end-to-end coast workflows. Most tests can run inside a Docker-in-Docker container via the DinD runner, which only requires Docker:

make run-dind-integration TEST=test_assign    # run one test
make run-dind-integration TEST=all            # run all ported tests

Tests can also run directly on the host (requires Docker, socat, and a release build). Each test spins up real DinD containers, so a full run can consume significant disk space -- run docker system prune periodically to reclaim it.

For the full list of tests and average run times, see dindind/integration.yaml. For host-mode usage and prerequisites, see the integrated-examples README.

Quick usage:

integrated-examples/test.sh                            # run all tests
integrated-examples/test.sh test_checkout test_secrets  # run specific tests
integrated-examples/test.sh --include-keychain          # include macOS Keychain test
coast/
  coast-cli/          # Thin CLI client, talks to daemon over unix socket
  coast-daemon/       # coastd background process (handlers, state DB, port manager)
  coast-core/         # Shared types, Coastfile parsing, protocol definitions
  coast-secrets/      # Secret extraction, encryption, keystore
  coast-docker/       # Docker API wrapper, DinD runtime, compose interaction
  coast-git/          # Git worktree management
  coast-guard/        # Web UI (React + Vite), served by the daemon
  coast-i18n/         # i18n locale files for the CLI
  scripts/            # Python build scripts (translation, search index generation)
  docs/               # User-facing documentation (English + translations)
  integrated-examples/  # Example projects and shell-based integration tests

Binaries are placed in target/release/:

  • coast -- the CLI client
  • coastd -- the background daemon
# Start the daemon
coastd --foreground &

# In a project with a Coastfile and docker-compose.yml:
coast build
coast run main
coast run feature-x --worktree feature/x

# Swap which instance owns the canonical ports
coast checkout main
coast checkout feature-x

# Inspect
coast ls
coast ps main
coast logs main
coast ports main

# Clean up
coast rm main
coast rm feature-x

This project started in another repository and had some of its history squashed. Please see the original repo here for the full commit history.

联系我们 contact @ memedata.com