Documentation
¶
Overview ¶
Package agent provides utilities for detecting and configuring AI agent instruction files.
Index ¶
- Constants
- Variables
- func AnyFileHasTDInstructions(baseDir string) bool
- func DetectAgentFile(baseDir string) string
- func HasTDInstructions(path string) bool
- func InstallInstructions(path string) error
- func OutdatedMarkedInstructionsFile(baseDir string) string
- func PreferredAgentFile(baseDir string) string
Constants ¶
const ( // Versioned markers let future td releases update their own guidance without // disturbing the rest of a project's agent file. InstructionStartMarker = "<!-- td-agent-instructions:start -->" InstructionVersion = 3 InstructionVersionMarker = instructionVersionPrefix + "3" + instructionVersionSuffix InstructionEndMarker = "<!-- td-agent-instructions:end -->" // InstructionBody is intentionally compact because agent files consume // context on every turn. Detailed workflow guidance remains available from // `td usage` and command-specific help. InstructionBody = `## Working with td td keeps task context durable across sessions. In a new context, run ` + "`td usage --new-session -q`" + ` to see current work. Use your judgment about how much tracking a task needs. For substantive work: ` + "`td start <id>`" + `, record progress with ` + "`td log`" + `, hand off with ` + "`td handoff <id>`" + `, then ` + "`td review <id>`" + `. Closing needs a review. Say who did it (default trusted mode; delegated/strict allow only the first): - independent session: ` + "`td approve <id> --reason \"...\"`" + ` - a sub-agent: ` + "`td approve <id> --reviewed-by \"<who>\"`" + ` - you: ` + "`td approve <id> --self-review --reason \"...\"`" + ` Prefer a reviewer with its own ` + "`TD_CONTEXT_ID`" + `; never name one who did not review. Run ` + "`td usage`" + ` or ` + "`td <command> --help`" + `.` // InstructionText is the complete versioned block installed in agent files. InstructionText = InstructionStartMarker + "\n" + InstructionVersionMarker + "\n\n" + InstructionBody + "\n\n" + InstructionEndMarker + "\n" )
Variables ¶
var KnownAgentFiles = []string{
"AGENTS.md",
"CLAUDE.md",
"CLAUDE.local.md",
"GEMINI.md",
"GEMINI.local.md",
"CODEX.md",
"COPILOT.md",
"CURSOR.md",
".github/copilot-instructions.md",
}
KnownAgentFiles lists agent instruction files in priority order. AGENTS.md is preferred since td supports multiple agent types.
Functions ¶
func AnyFileHasTDInstructions ¶ added in v0.39.0
AnyFileHasTDInstructions checks all known agent files in baseDir for td guidance. Returns true if any file already contains the instructions (dedup check).
func DetectAgentFile ¶
DetectAgentFile finds the first existing agent file in baseDir. Returns the full path if found, empty string if none exist.
func HasTDInstructions ¶
HasTDInstructions checks if the file already contains td guidance.
func InstallInstructions ¶
InstallInstructions adds or updates td guidance in an agent file. Creates the file if it doesn't exist.
func OutdatedMarkedInstructionsFile ¶ added in v0.52.0
OutdatedMarkedInstructionsFile returns the first recognized agent file with a td-owned block from an older version. Unmarked legacy guidance is excluded because td cannot safely determine which surrounding text it owns. Blocks from newer td versions are left untouched to prevent accidental downgrades.
func PreferredAgentFile ¶
PreferredAgentFile returns the best agent file to use for installation. Priority: 1. If AGENTS.md exists, use it (td supports many agents) 2. Use the first existing known agent file 3. If none exist, prefer AGENTS.md for new installations
Types ¶
This section is empty.