hosts

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package hosts describes the agent hosts VegaLoad integrates with (Cursor, Claude Code, Claude Desktop) in one place: where each host keeps its MCP server config, which rules or skill files it reads, and how to detect that it is installed.

Both `vegaload init` (which writes these files) and `vegaload doctor` (which checks and can repair them) build on this package, so the two commands cannot disagree about where a host's files live. It knows nothing about the engine, protocols, or reporting.

Supported platforms are macOS, Linux and Windows. Claude Desktop is offered on macOS and Windows, because it has no official Linux build.

Index

Constants

View Source
const (
	StatusOK       = "ok"
	StatusMissing  = "missing"
	StatusOutdated = "outdated" // a rules file that differs from this version's
	StatusOtherExe = "other binary"
	StatusBadArgs  = "wrong args" // an MCP entry that does not run "mcp serve"
	StatusInvalid  = "invalid"
)

Artifact status values, as ArtifactStatus returns them.

Variables

This section is empty.

Functions

func ArtifactStatus added in v0.6.0

func ArtifactStatus(dir string, a Artifact, exePath string) (string, string)

ArtifactStatus checks one project artifact under dir without changing anything. exePath is the binary an MCP entry should point at. The second result is a short note, or empty.

func ProjectEditors added in v0.6.0

func ProjectEditors() []string

ProjectEditors lists the host IDs `vegaload init` can set up in a project.

Types

type Artifact

type Artifact struct {
	Kind    string // "rules" or "mcp"
	Host    string // the host ID that reads this file: "claude-code" or "cursor"
	RelPath string
	Content string // rules content; empty for MCP configs
}

Artifact is one file `vegaload init` writes into a project.

func ProjectArtifacts

func ProjectArtifacts() []Artifact

ProjectArtifacts lists, in a stable order, the files `vegaload init` writes for dir. doctor's --fix repairs the same files.

type ConfigState

type ConfigState struct {
	Config MCPConfig
	Exists bool
	Err    error  // file unreadable, or not valid JSON
	Entry  *Entry // nil when the file has no "vegaload" server
}

ConfigState is what Inspect found in one config file.

func Inspect

func Inspect(c MCPConfig) ConfigState

Inspect reads c and reports whether it registers a "vegaload" server.

type Entry

type Entry struct {
	Command string            `json:"command"`
	Args    []string          `json:"args"`
	Env     map[string]string `json:"env,omitempty"`
}

Entry is a registered "vegaload" MCP server.

func (Entry) Expand

func (e Entry) Expand(env Env, getenv func(string) string) Entry

Expand resolves the placeholders Cursor allows in a config (${workspaceFolder}, ${userHome}, ${env:NAME}) so doctor can run the command the way the host would.

type Env

type Env struct {
	OS       string // runtime.GOOS: "darwin", "linux" or "windows"
	Home     string // the user's home directory
	AppData  string // Windows only: the %APPDATA% folder; empty elsewhere
	Dir      string // the project directory being checked
	LookPath func(name string) (string, error)
	// DirExists reports whether a directory exists. Nil means the real
	// file system; tests pass a fake so detection never depends on what
	// happens to be installed on the machine running them.
	DirExists func(path string) bool
}

Env is the slice of the machine a host adapter needs to answer its questions. Tests build one over a temp directory instead of the real home directory.

type Host

type Host struct {
	ID   string
	Name string
	// Supported reports whether the host exists on osName. Nil means everywhere.
	Supported func(osName string) bool
	// Detect reports whether the host looks installed, with the evidence found.
	Detect func(Env) (bool, string)
	// Configs lists every MCP config file the host may read, project scope first.
	Configs func(Env) []MCPConfig
	// Rules lists the rules or skill files the host reads. Nil for hosts without any.
	Rules func(Env) []RulesFile
}

Host is one agent host.

func All

func All() []Host

All returns the built-in hosts in a stable order.

func Custom

func Custom(path string) Host

Custom returns a host for any MCP-capable tool, pointed at a config file the user names. It has no rules files.

func Get

func Get(id string) (Host, bool)

Get returns the built-in host with the given ID.

func (Host) SupportedOn

func (h Host) SupportedOn(osName string) bool

SupportedOn reports whether h exists on osName.

type MCPConfig

type MCPConfig struct {
	Host  string
	Scope Scope
	Path  string   // absolute path
	Key   []string // path to the mcpServers object inside the JSON; nil means top level
	// ReadOnly marks files doctor reports on but never rewrites,
	// because VegaLoad does not own their structure.
	ReadOnly bool
}

MCPConfig is one JSON file that can hold a host's "mcpServers" map.

type RulesFile

type RulesFile struct {
	Path    string // absolute path
	Content string
}

RulesFile is an agent rules or skill file a host reads, with the content this version of VegaLoad ships for it.

type Scope

type Scope string

Scope says whether a file lives in the project or in the user's home.

const (
	ScopeProject Scope = "project"
	ScopeUser    Scope = "user"
)

type WriteResult

type WriteResult struct {
	Path   string `json:"path"`
	Status string `json:"status"` // "created", "updated", or "skipped (exists)"
}

WriteResult records what a write did, for text and JSON reporting.

func MergeConfigFile

func MergeConfigFile(path, exePath string, force bool) (WriteResult, error)

MergeConfigFile reads path (if it exists), adds or updates a "vegaload" MCP server entry pointing at exePath, and writes the result back, keeping every other key and server. See skills.MergeMCPServerConfig.

func WriteFile

func WriteFile(path, content string, force bool) (WriteResult, error)

WriteFile writes content to path, creating missing parent directories, unless path exists and force is false, in which case it reports "skipped (exists)" and leaves the file alone.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL