Help us shape the future of Go! Take the 2026 Go Developer Survey

agentwire

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

User scope: wires agents through files under the home directory (and `claude mcp add --scope user`). Symlinks are followed: these are the human's own files, often managed as dotfiles.

Package agentwire connects coding agents (Claude Code, Codex, Cursor, Gemini CLI) to a product's MCP server: in one project (`<name> init <agent>`) or for the user's account in every project (bare `<name>`, `<name> doctor --fix`). The product supplies its texts and its MCP command (Assets); agentwire owns the file mechanics.

It never overwrites a file the human may have edited: an existing skill or rule is kept, an MCP config gets the product's entry merged in (other servers and keys are kept), and a Markdown instructions file gets one marked section appended. Running it again changes nothing. Every change is computed and checked before the first write. In a project every path is resolved through symlinks and refused if it leaves the project; in the user scope symlinks are followed (dotfiles) but a file of another account is never replaced.

Index

Constants

View Source
const (
	StatusCreated   = "created"   // the file did not exist
	StatusUpdated   = "updated"   // the product's entry was merged into an existing file
	StatusUnchanged = "unchanged" // the file already holds the product's content
	StatusKept      = "kept"      // the file differs and was left as the human wrote it
)

Action statuses.

Variables

This section is empty.

Functions

func Agents

func Agents() []string

Agents returns the supported agent names.

func Detect

func Detect(e Env) []string

Detect lists the installed agents, in Agents() order.

func ProjectRoot

func ProjectRoot(p kit.Product, cwd string) string

ProjectRoot returns the directory a project init writes to: the nearest ancestor of cwd holding .<name>/config.toml, else the nearest one holding .git, else cwd itself.

Types

type Action

type Action struct {
	Path   string // slash-separated, relative to the project root (or ~/... in the user scope)
	Status string
	Detail string // why a file was kept, when it was
}

Action reports what wiring did to one file.

type Assets

type Assets struct {
	// MCPCommand starts the product's MCP server ({"lockmq", "mcp"}).
	MCPCommand []string
	// Skill is the Claude Code skill (skills/<name>/SKILL.md).
	Skill []byte
	// Instructions are the shared agent instructions: the marked section of
	// AGENTS.md and GEMINI.md, and the body of the Cursor rule.
	Instructions []byte
	// CursorFrontMatter starts the Cursor rule (.cursor/rules/<name>.mdc).
	CursorFrontMatter []byte
	// ProjectConfig is the commented example .<name>/config.toml a project
	// init creates when there is none; nil creates none.
	ProjectConfig []byte
	// ClaudeAllow are the calls merged into Claude Code's
	// permissions.allow at user scope, and listed in the project notes:
	// only calls that never touch data without the console's approval.
	ClaudeAllow []string
	// ClaudeNote ends the Claude Code notes of a project init (optional).
	ClaudeNote string
}

Assets are a product's texts and command. agentwire writes them as they are.

type Env

type Env struct {
	Home     string
	Getenv   func(string) string
	LookPath func(string) (string, error)
	// Run runs a command and returns its combined output.
	Run func(name string, args ...string) ([]byte, error)
}

Env is the user account wiring works on, and how it looks for and runs the agents' commands.

func SystemEnv

func SystemEnv() (Env, error)

SystemEnv is the current account: its home directory, environment and PATH.

type Result

type Result struct {
	Root    string
	Actions []Action
	Notes   string // agent-specific steps for the human, such as a global file to edit
}

Result is the outcome of a wiring.

type Wiring

type Wiring struct {
	Product kit.Product
	Assets  Assets
}

Wiring wires agents to one product.

func (Wiring) Init

func (w Wiring) Init(root, agent string) (Result, error)

Init writes the integration files of agent into the project at root. An invalid existing file or an escaping symlink leaves the project untouched.

func (Wiring) InitUser

func (w Wiring) InitUser(e Env, agent string) (Result, error)

InitUser wires agent for the current account, in every project.

func (Wiring) PendingUser

func (w Wiring) PendingUser(e Env, agent string) (bool, error)

PendingUser reports whether InitUser would write or run anything.

func (Wiring) Unwired

func (w Wiring) Unwired(e Env) (found, pending []string)

Unwired lists the installed agents and, among them, those InitUser would still wire (or cannot check): the doctor's "agent wiring" finding.

Jump to

Keyboard shortcuts

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