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

agentsetup

package
v1.4.15 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package agentsetup renders what an AI agent needs to work with an nSelf project: the stdio MCP client config (Claude Code, Cursor, Codex, generic) and the project AGENTS.md (P7-SURF-05, cap:cli.agent-setup).

Purpose: one place that knows the client config shapes and the AGENTS.md

template, shared by `nself mcp setup` and `nself init`.

Inputs: a client name, the existing file bytes, the registry verbs. Outputs: config bytes, merged config bytes, AGENTS.md text. Constraints: render and merge are pure over bytes; files.go does the writes. No

token or secret is ever written: stdio needs none.

Index

Constants

View Source
const (
	ClaudeCode = "claude-code"
	Cursor     = "cursor"
	Codex      = "codex"
	Generic    = "generic"
)

Client names accepted by `nself mcp setup --client`.

View Source
const FileName = "AGENTS.md"

FileName is the project file agents read.

Variables

Clients lists every client name in help order.

Functions

func Body

func Body(verbs []Verb) string

Body renders the AGENTS.md body for the given canon verbs. It holds nothing that varies per project, machine or day, so the same registry gives the same bytes (init regenerates an unedited file identically).

func Config

func Config(client string) string

Config returns the compact config document a client needs.

func MayWrite

func MayWrite(exists bool, content string) bool

MayWrite reports whether nself may write AGENTS.md over the existing content: the file is absent (exists false) or is an unedited generated file.

func Merge

func Merge(existing []byte) ([]byte, bool, error)

Merge adds the nself server entry to an existing client config file and returns the new bytes and whether they changed. Empty existing content means a new file. Every other key and server entry keeps its place; an nself entry that is already present is left alone (the user may have tuned it), so a second run changes nothing and returns the input unchanged, byte for byte.

func Note

func Note(cwd string) string

Note is the stderr hint printed with a client config: the server reads the project from its working directory.

func Path

func Path(client string) string

Path returns the project-relative file a client reads its config from, or "" when the client is print-only (codex and generic).

func Render

func Render(verbs []Verb) string

Render returns the full AGENTS.md: the generated marker line, then the body.

func Unedited

func Unedited(content string) bool

Unedited reports whether content is a file nself generated and nobody has changed since: the first line is the marker and its hash matches the rest.

func Valid

func Valid(name string) bool

Valid reports whether name is a known client.

func WriteAgentsMD

func WriteAgentsMD(dir string, verbs []Verb) (string, bool, error)

WriteAgentsMD writes AGENTS.md when it is absent or an unedited generated file; any other file is left untouched (written false, no error).

func WriteClient

func WriteClient(dir, client string) (string, bool, error)

WriteClient merges the nself server entry into the client's config file under dir, creating it when absent. Print-only clients are an error.

Types

type Verb

type Verb struct {
	Name    string
	Summary string
}

Verb is one canon verb with its one-line summary, from the registry.

Jump to

Keyboard shortcuts

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