Documentation
¶
Overview ¶
Package cli parses Daisybell's command line and dispatches subcommands: serve (the MCP server, default) and the human-facing setup, doctor, uninstall, recordings, install-browser, version.
Index ¶
- Constants
- Variables
- func Run(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) int
- type Change
- type Check
- type Client
- type Entry
- type Env
- func (e *Env) Checks(ctx context.Context, launch bool) []Check
- func (e *Env) Doctor(ctx context.Context, args []string) int
- func (e *Env) Flags(args []string) int
- func (e *Env) GenDocs(ctx context.Context, files []string) int
- func (e *Env) InstallBrowserCmd(ctx context.Context, args []string, logger *slog.Logger) int
- func (e *Env) Main(ctx context.Context, args []string) int
- func (e *Env) Map(args []string, opts server.Options) int
- func (e *Env) Recordings(args []string) int
- func (e *Env) Session(ctx context.Context, args []string, opts server.Options, logger *slog.Logger) int
- func (e *Env) Setup(ctx context.Context, args []string) int
- func (e *Env) Tools(ctx context.Context, args []string) int
- func (e *Env) Uninstall(ctx context.Context, args []string) int
- type Format
- type Scope
- type Status
- type Target
Constants ¶
const ServerName = "daisybell"
ServerName is Daisybell's key in every client's server list.
Variables ¶
var Clients = []*Client{ { ID: "claude-code", Name: "Claude Code", Detect: func(e *Env) bool { return e.has("claude") || exists(e.claudeDir()) || exists(e.claudeJSON()) }, Targets: func(e *Env, s Scope) []Target { if s == ScopeProject { return []Target{{Path: filepath.Join(e.Cwd, ".mcp.json"), Format: FormatJSON, Key: "mcpServers", Entry: stdio}} } f := FormatJSON if e.has("claude") { f = FormatClaudeCLI } return []Target{{Path: e.claudeJSON(), Format: f, Key: "mcpServers", Entry: stdio}} }, Skill: func(e *Env, s Scope) string { if s == ScopeProject { return filepath.Join(e.Cwd, ".claude", "skills", ServerName, "SKILL.md") } return filepath.Join(e.claudeDir(), "skills", ServerName, "SKILL.md") }, Restart: "restartClaudeCode", }, { ID: "claude-desktop", Name: "Claude Desktop", Detect: func(e *Env) bool { return exists(filepath.Join(e.appSupport(), "Claude")) }, Targets: func(e *Env, s Scope) []Target { if s == ScopeProject { return nil } return []Target{{Path: filepath.Join(e.appSupport(), "Claude", "claude_desktop_config.json"), Format: FormatJSON, Key: "mcpServers", Entry: plain}} }, Restart: "restartDesktop", }, { ID: "cursor", Name: "Cursor", Detect: func(e *Env) bool { return exists(filepath.Join(e.Home, ".cursor")) || e.has("cursor") }, Targets: func(e *Env, s Scope) []Target { if s == ScopeProject { return []Target{{Path: filepath.Join(e.Cwd, ".cursor", "mcp.json"), Format: FormatJSON, Key: "mcpServers", Entry: plain}} } return []Target{{Path: filepath.Join(e.Home, ".cursor", "mcp.json"), Format: FormatJSON, Key: "mcpServers", Entry: plain}} }, Skill: func(e *Env, s Scope) string { if s == ScopeProject { return filepath.Join(e.Cwd, ".cursor", "rules", ServerName+".mdc") } return "" }, Restart: "restartCursor", }, { ID: "vscode", Name: "VS Code (Copilot)", Detect: func(e *Env) bool { if exists(e.copilotHome()) || e.has("code") || e.has("copilot") { return true } for _, d := range e.vscodeUserDirs() { if exists(d) { return true } } return false }, Targets: func(e *Env, s Scope) []Target { if s == ScopeProject { return []Target{ {Path: filepath.Join(e.Cwd, ".mcp.json"), Format: FormatJSON, Key: "mcpServers", Entry: stdio}, {Path: filepath.Join(e.Cwd, ".vscode", "mcp.json"), Format: FormatJSON, Key: "servers", Entry: stdio, Legacy: true}, } } ts := []Target{{Path: filepath.Join(e.copilotHome(), "mcp-config.json"), Format: FormatJSON, Key: "mcpServers", Entry: func(bin string) Entry { en := stdio(bin) en.Tools = []string{"*"} return en }}} for _, d := range e.vscodeUserDirs() { ts = append(ts, Target{Path: filepath.Join(d, "mcp.json"), Format: FormatJSON, Key: "servers", Entry: stdio, Legacy: true}) } return ts }, Skill: func(e *Env, s Scope) string { if s == ScopeProject { return filepath.Join(e.Cwd, ".github", "skills", ServerName, "SKILL.md") } return filepath.Join(e.copilotHome(), "skills", ServerName, "SKILL.md") }, Restart: "restartVSCode", }, { ID: "windsurf", Name: "Windsurf", Detect: func(e *Env) bool { return exists(filepath.Join(e.Home, ".codeium", "windsurf")) || e.has("windsurf") }, Targets: func(e *Env, s Scope) []Target { if s == ScopeProject { return nil } return []Target{{Path: filepath.Join(e.Home, ".codeium", "windsurf", "mcp_config.json"), Format: FormatJSON, Key: "mcpServers", Entry: plain}} }, Restart: "restartWindsurf", }, { ID: "codex", Name: "Codex CLI", Detect: func(e *Env) bool { return exists(e.codexHome()) || e.has("codex") }, Targets: func(e *Env, s Scope) []Target { if s == ScopeProject { return nil } return []Target{{Path: filepath.Join(e.codexHome(), "config.toml"), Format: FormatTOML, Entry: plain}} }, Restart: "restartCodex", }, { ID: "zed", Name: "Zed", Detect: func(e *Env) bool { return exists(e.zedDir()) || e.has("zed") }, Targets: func(e *Env, s Scope) []Target { if s == ScopeProject { return nil } return []Target{{Path: filepath.Join(e.zedDir(), "settings.json"), Format: FormatJSON, Key: "context_servers", Entry: func(bin string) Entry { en := plain(bin) en.Env = &struct{}{} return en }}} }, Restart: "restartZed", }, }
Clients is every app setup knows, in the order they are shown.
var Version = "0.0.0-dev"
Version is set at build time with -ldflags "-X .../cli.Version=...".
Functions ¶
Types ¶
type Change ¶
type Change struct {
Target Target
Clients []string // display names sharing this file (.mcp.json: Claude Code and VS Code)
Kind changeKind
Before found
Bin string
Old []byte
New []byte
}
Change is one planned edit of one target. Old/New are the file's bytes before and after (nil for FormatClaudeCLI, which runs the claude CLI instead).
type Check ¶
type Check struct {
ID string `json:"id"`
Status Status `json:"status"`
Text string `json:"text"`
Fix string `json:"fix,omitempty"`
}
Check is one line of doctor's report.
type Client ¶
type Client struct {
ID string
Name string
// Detect reports whether the app seems installed (its config dir exists or its CLI is on PATH).
Detect func(e *Env) bool
// Targets lists the files for a scope (nil when the app has no such scope).
Targets func(e *Env, s Scope) []Target
// Skill is where the usage guide goes for a scope ("" when the app has none).
Skill func(e *Env, s Scope) string
// Restart is the human's next step after setup.
Restart string
}
Client is an AI app Daisybell can configure.
type Entry ¶
type Entry struct {
Type string `json:"type,omitempty"`
Command string `json:"command"`
Args []string `json:"args"`
Env *struct{} `json:"env,omitempty"`
Tools []string `json:"tools,omitempty"`
}
Entry is Daisybell's server entry in a client's config file. Fields are written in this order; empty optional fields are left out, so each client gets the shape its docs show.
type Env ¶
type Env struct {
Home string // the user's home directory
Cwd string // project directory for --scope project
GOOS string
Executable string // this binary, symlinks resolved
Layout paths.Layout
Getenv func(string) string
LookPath func(string) (string, error)
// Run runs a program and returns its combined output (claude mcp, daisybell version, git).
Run func(ctx context.Context, name string, args ...string) (string, error)
Stdin io.Reader
Stdout io.Writer
Stderr io.Writer
// Interactive is true when stdin is a terminal: setup may ask questions.
Interactive bool
// Lang is "en" or "pt-BR" (human-facing output).
Lang string
// Open opens a file or URL with the OS (recordings open).
Open func(target string) error
// Smoke launches a headless browser with the Cockpit and waits for it to connect (doctor).
Smoke func(ctx context.Context) error
// SmokeProfile does the same on an existing profile (doctor probes the default one, where a
// stale Cockpit worker can hide). It returns errCockpit, errStaleWorker or the launch error.
SmokeProfile func(ctx context.Context, dir string) error
// Quarantined reports the macOS quarantine flag on a file (doctor).
Quarantined func(path string) bool
// InstallBrowser downloads the pinned browser (setup); nil uses the real installer.
InstallBrowser func(ctx context.Context) (string, error)
}
Env is everything the human-facing commands (setup, doctor, uninstall, recordings) take from the machine, so tests run them against a temp HOME with fakes and never touch the real one.
func DefaultEnv ¶
DefaultEnv is the real process environment.
func (*Env) Checks ¶
Checks runs every check. launch includes the headless smoke test (a few seconds).
func (*Env) Doctor ¶
Doctor checks the install and prints one line per check, each failure with its fix.
func (*Env) InstallBrowserCmd ¶
InstallBrowserCmd downloads the pinned Chrome for Testing, or installs it from a zip the human downloaded themselves (--from, for offline machines and proxies that block the download).
func (*Env) Recordings ¶
Recordings manages ~/.daisybell/recordings: list, open (the HTML replay) and clean.
func (*Env) Session ¶
func (e *Env) Session(ctx context.Context, args []string, opts server.Options, logger *slog.Logger) int
Session is `daisybell session save|list|delete`.
func (*Env) Setup ¶
Setup installs the binary to ~/.daisybell/bin, configures the chosen AI apps, downloads the browser and offers the usage guide. Running it again updates everything in place.
type Scope ¶
type Scope string
Scope is where a client's config goes: the user's (every project) or the current project's.
type Target ¶
type Target struct {
Client *Client
Scope Scope
Path string // the file; for FormatClaudeCLI the file the CLI writes (read to compare)
Format Format
Key string // JSON key holding the servers (mcpServers, servers, context_servers)
Entry func(bin string) Entry
// Legacy targets are only updated or removed when Daisybell is already in them, never added.
Legacy bool
}
Target is one config file (or CLI call) for one client and scope.