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
- Variables
- func Body(verbs []Verb) string
- func Config(client string) string
- func MayWrite(exists bool, content string) bool
- func Merge(existing []byte) ([]byte, bool, error)
- func Note(cwd string) string
- func Path(client string) string
- func Render(verbs []Verb) string
- func Unedited(content string) bool
- func Valid(name string) bool
- func WriteAgentsMD(dir string, verbs []Verb) (string, bool, error)
- func WriteClient(dir, client string) (string, bool, error)
- type Verb
Constants ¶
const ( ClaudeCode = "claude-code" Cursor = "cursor" Codex = "codex" Generic = "generic" )
Client names accepted by `nself mcp setup --client`.
const FileName = "AGENTS.md"
FileName is the project file agents read.
Variables ¶
var Clients = []string{ClaudeCode, Cursor, Codex, Generic}
Clients lists every client name in help order.
Functions ¶
func Body ¶
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 MayWrite ¶
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 ¶
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 ¶
Note is the stderr hint printed with a client config: the server reads the project from its working directory.
func Path ¶
Path returns the project-relative file a client reads its config from, or "" when the client is print-only (codex and generic).
func Unedited ¶
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 WriteAgentsMD ¶
WriteAgentsMD writes AGENTS.md when it is absent or an unedited generated file; any other file is left untouched (written false, no error).