MCPcopy
hub / github.com/charmbracelet/wish

github.com/charmbracelet/wish @v2.0.1 sqlite

repository ↗ · DeepWiki ↗ · release v2.0.1 ↗
267 symbols 940 edges 55 files 107 documented · 40%
README

Wish

<img style="width: 247px" src="https://stuff.charm.sh/wish/wish-header.png" alt="A nice rendering of a star, anthropomorphized somewhat by means of a smile, with the words ‘Charm Wish’ next to it">



<a href="https://github.com/charmbracelet/wish/releases"><img src="https://img.shields.io/github/release/charmbracelet/wish.svg" alt="Latest Release"></a>
<a href="https://pkg.go.dev/github.com/charmbracelet/wish?tab=doc"><img src="https://godoc.org/github.com/golang/gddo?status.svg" alt="GoDoc"></a>
<a href="https://github.com/charmbracelet/wish/actions"><img src="https://github.com/charmbracelet/wish/workflows/Build/badge.svg" alt="Build Status"></a>
<a href="https://codecov.io/gh/charmbracelet/wish"><img alt="Codecov branch" src="https://img.shields.io/codecov/c/github/charmbracelet/wish/main.svg"></a>
<a href="https://goreportcard.com/report/github.com/charmbracelet/wish"><img alt="Go Report Card" src="https://goreportcard.com/badge/github.com/charmbracelet/wish"></a>

Make SSH apps, just like that! 💫

SSH is an excellent platform for building remotely accessible applications. It offers: * secure communication without the hassle of HTTPS certificates * user identification with SSH keys * access from any terminal

Powerful protocols like Git work over SSH and you can even render TUIs directly over an SSH connection.

Wish is an SSH server with sensible defaults and a collection of middlewares that makes building SSH apps really easy. Wish is built on gliderlabs/ssh and should be easy to integrate into any existing projects.

What are SSH Apps?

Usually, when we think about SSH, we think about remote shell access into servers, most commonly through openssh-server.

That's a perfectly valid (and probably the most common) use of SSH, but it can do so much more than that. Just like HTTP, SMTP, FTP and others, SSH is a protocol! It is a cryptographic network protocol for operating network services securely over an unsecured network. ^1

That means, among other things, that we can write custom SSH servers without touching openssh-server, so we can securely do more things than just providing a shell.

Wish is a library that helps writing these kind of apps using Go.

Middleware

Wish middlewares are analogous to those in several HTTP frameworks. They are essentially SSH handlers that you can use to do specific tasks, and then call the next middleware.

Notice that middlewares are composed from first to last, which means the last one is executed first.

Bubble Tea

The bubbletea middleware makes it easy to serve any Bubble Tea application over SSH. Each SSH session will get their own tea.Program with the SSH pty input and output connected. Client window dimension and resize messages are also natively handled by the tea.Program.

You can see a demo of the Wish middleware in action at: ssh git.charm.sh

Git

The git middleware adds git server functionality to any ssh server. It supports repo creation on initial push and custom public key based auth.

This middleware requires that git is installed on the server.

Logging

The logging middleware provides basic connection logging. Connects are logged with the remote address, invoked command, TERM setting, window dimensions and if the auth was public key based. Disconnect will log the remote address and connection duration.

Access Control

Not all applications will support general SSH connections. To restrict access to supported methods, you can use the activeterm middleware to only allow connections with active terminals connected and the accesscontrol middleware that lets you specify allowed commands.

Default Server

Wish includes the ability to easily create an always authenticating default SSH server with automatic server key generation.

Examples

There are examples for a standalone Bubble Tea application and Git server in the examples folder.

Apps Built With Wish

Pro tip

When building various Wish applications locally you can add the following to your ~/.ssh/config to avoid having to clear out localhost entries in your ~/.ssh/known_hosts file:

Host localhost
    UserKnownHostsFile /dev/null

How it works?

Wish uses gliderlabs/ssh to implement its SSH server, and OpenSSH is never used nor needed — you can even uninstall it if you want to.

Incidentally, there's no risk of accidentally sharing a shell because there's no default behavior that does that on Wish.

Running with SystemD

If you want to run a Wish app with systemd, you can create an unit like so:

/etc/systemd/system/myapp.service:

[Unit]
Description=My App
After=network.target

[Service]
Type=simple
User=myapp
Group=myapp
WorkingDirectory=/home/myapp/
ExecStart=/usr/bin/myapp
Restart=on-failure

[Install]
WantedBy=multi-user.target

You can tune the values below, and once you're happy with them, you can run:

# need to run this every time you change the unit file
sudo systemctl daemon-reload

# start/restart/stop/etc:
sudo systemctl start myapp

If you use a new user for each app (which is good), you'll need to create them first:

useradd --system --user-group --create-home myapp

That should do it.

Contributing

See contributing.

Feedback

We’d love to hear your thoughts on this project. Feel free to drop us a note!

License

MIT


Part of Charm.

The Charm logo

Charm热爱开源 • Charm loves open source

Extension points exported contracts — how you extend this code

CopyToClientHandler (Interface)
CopyToClientHandler is a handler that can be implemented to handle files being copied from the server to the client. [2 …
scp/scp.go
Hooks (Interface)
nolint:revive Hooks is an interface that allows for custom authorization implementations and post push/fetch notificatio [2 …
git/git.go
RateLimiter (Interface)
RateLimiter implementations should check if a given session is allowed to proceed or not, returning an error if they are [1 …
ratelimiter/ratelimiter.go
Middleware (FuncType)
Middleware is a function that takes an ssh.Handler and returns an ssh.Handler. Implementations should call the provided
wish.go
Handler (FuncType)
nolint:revive Handler is the function Bubble Tea apps implement to hook into the SSH Middleware. This will create a new
bubbletea/tea.go
Logger (Interface)
Logger is the interface that wraps the basic Log method.
logging/logging.go
Logger (Interface)
Logger is the interface that wraps the basic Log method.
recover/recover.go
Entry (Interface)
Entry defines something that knows how to write itself and its path. [2 implementers]
scp/scp.go

Core symbols most depended-on inside this repo

Run
called by 115
cmd.go
Error
called by 65
scp/copy_from_client.go
Write
called by 23
scp/scp.go
New
called by 18
testsession/testsession.go
NewFileSystemHandler
called by 17
scp/filesystem.go
Middleware
called by 15
logging/logging.go
Printf
called by 14
recover/recover.go
prefixed
called by 8
scp/filesystem.go

Shape

Function 157
Method 71
Struct 21
Interface 9
TypeAlias 6
FuncType 3

Languages

Go100%

Modules by API surface

scp/scp.go32 symbols
options.go16 symbols
examples/multichat/main.go13 symbols
wish.go12 symbols
options_test.go12 symbols
git/git_test.go12 symbols
git/git.go12 symbols
scp/filesystem.go10 symbols
cmd.go10 symbols
examples/scp/main.go7 symbols
examples/bubbleteaprogram/main.go7 symbols
examples/bubbletea-exec/main.go7 symbols

Used by 1 indexed graphs manifest dependencies, hub-wide

Dependencies from manifests, versioned

charm.land/bubbles/v2v2.1.0 · 1×
charm.land/bubbletea/v2v2.0.2 · 1×
charm.land/lipgloss/v2v2.0.2 · 1×
charm.land/log/v2v2.0.0 · 1×
charm.land/wish/v2v2.0.0-0001010100000 · 1×
dario.cat/mergov1.0.0 · 1×
github.com/Microsoft/go-winiov0.6.2 · 1×
github.com/ProtonMail/go-cryptov1.1.6 · 1×
github.com/anmitsu/go-shlexv0.0.0-2020051411343 · 1×
github.com/atotto/clipboardv0.1.4 · 1×
github.com/charmbracelet/colorprofilev0.4.3 · 1×
github.com/charmbracelet/keygenv0.5.4 · 1×

For agents

$ claude mcp add wish \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact