How standardagents/ssh-clipboard works
Purpose and entry points
ssh-clipboard is a Rust CLI and per-user daemon that synchronizes native clipboard content directly between machines over persistent SSH connections. The user entry point is the npm-installed launcher at bin/ssh-clipboard.js, which selects a platform binary; Rust starts in src/main.rs and exposes shared functionality through src/lib.rs.
CLI, setup, and TUI
The interactive CLI coordinates first-run setup, peer repair, monitoring, status, and updates. src/tui/setup.rs drives peer selection and provisioning; src/tui/monitor.rs presents live peer/version health and update actions. Tailscale is optional discovery support, while arbitrary passwordless SSH peers remain supported.
• src/main.rs
• src/tui/setup.rs
• src/tui/monitor.rs
Peer configuration and domain model
Persistent local state describes this node, configured peers, service state, and synchronization metadata. src/config.rs owns configuration persistence, while src/model.rs defines shared domain structures used across setup, protocol, service, and UI boundaries.
• src/config.rs
• src/model.rs
• src/protocol.rs
SSH transport and synchronization protocol
src/ssh.rs establishes and maintains encrypted SSH connectivity to peers. src/protocol.rs defines peer messages for clipboard transfer, health/status, and update gossip. The protocol carries raw clipboard representations rather than terminal encodings, allowing native content fidelity and peer-to-peer operation without a relay or separate account system.
• src/ssh.rs
• src/protocol.rs
• src/filebundle.rs
Native clipboard capture and application
The clipboard subsystem bridges OS-native clipboard APIs to transferable payloads. src/clipboard.rs is the platform-neutral boundary; macOS support is isolated in src/clipboard/macos.rs. File bundles are handled separately so native file paste behavior can be preserved alongside text, images, and rich formats.
• src/clipboard.rs
• src/clipboard/macos.rs
• src/filebundle.rs
Background daemon and service lifecycle
The daemon owns continuous clipboard observation, deduplication/newest-value queueing, active peer sessions, periodic update checks, and inbound payload application. src/daemon.rs is the long-running control loop; src/service.rs manages per-user OS service installation/reconciliation, targeting launchd on macOS and systemd on Linux.
• src/daemon.rs
• src/service.rs
• src/deploy.rs
Deployment and verified updates
Remote setup/deployment transfers or installs the correct target binary without replacing a peer’s identity or peer configuration. src/update.rs independently checks npm’s stable release, verifies package integrity and bundled manifests, atomically swaps binaries, and requests service restart. Nodes gossip verified target versions, avoiding a permanent update coordinator.
• src/deploy.rs
• src/update.rs
• scripts/stage-npm-binaries.mjs
Distribution and runtimes
The core runtime is Rust on macOS/Linux, arm64/x64, with Ratatui for terminal UI. npm distributes platform binaries and the JavaScript launcher. Optional Tailscale integration supplies machine discovery; SSH is the required transport. The documentation site is a separate Vue/Vite application with a Cloudflare Worker deployment target.
• Cargo.toml
• package.json
• docs/worker/index.js
Main entry points: daemon.rs Background daemon · main.rs Rust entry point · protocol.rs Peer protocol · setup.rs Setup flow
Components 19
CLI & UI
- Rust entry point
src/main.rs - Setup flow · Selects and provisions peers.
src/tui/setup.rs - Monitor flow · Shows peer health and update actions.
src/tui/monitor.rs
Sync Runtime
- Local configuration · Persists node, peers, service state, and sync metadata.
src/config.rs - Domain model
src/model.rs - Background daemon · Observes, deduplicates, queues, and applies clipboard changes.
src/daemon.rs - Clipboard boundary
src/clipboard.rs - macOS clipboard
src/clipboard/macos.rs - File bundles · Preserves native file paste behavior.
src/filebundle.rs - Peer protocol · Carries clipboard, health, and update gossip messages.
src/protocol.rs - SSH transport · Maintains persistent direct peer connections.
src/ssh.rs - Service lifecycle · Reconciles launchd or systemd per-user services.
src/service.rs - Peer deployment · Installs target binaries without replacing peer identity or configuration.
src/deploy.rs - Verified updates · Verifies npm release artifacts and atomically swaps binaries.
src/update.rs
Distribution
- npm launcher · Selects the platform binary.
bin/ssh-clipboard.js - npm package · Distributes launcher and platform binaries.
package.json - Binary staging
scripts/stage-npm-binaries.mjs - Documentation deployment · Separate Vue/Vite documentation deployment target.
docs/worker/index.js - Rust runtime · macOS/Linux arm64/x64 CLI runtime.
Cargo.toml
Connections 23
- npm launcher → Rust entry point: launches platform binary
- npm package → npm launcher: ships
- Binary staging → npm package: stages binaries
- Rust runtime → Rust entry point: builds
- Rust entry point → Setup flow: runs setup
- Rust entry point → Monitor flow: runs monitor
- Rust entry point → Background daemon: starts daemon
- Setup flow → Local configuration: configures peers
- Setup flow → Peer deployment: provisions peers
- Monitor flow → Background daemon: reads live health
- Monitor flow → Verified updates: triggers update
- Background daemon → Clipboard boundary: observes and applies
- Clipboard boundary → macOS clipboard: uses on macOS
- Clipboard boundary → File bundles: preserves files
- Background daemon → Peer protocol: encodes peer events
- Peer protocol → SSH transport: travels over
- SSH transport → Peer deployment: supports remote install
- Background daemon → Local configuration: uses persistent state
- Local configuration → Domain model: stores
- Peer protocol → Domain model: shares types
- Service lifecycle → Background daemon: installs and restarts
- Verified updates → Service lifecycle: requests restart
- Verified updates → Peer protocol: gossips target versions