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 = 2 InstructionVersionMarker = instructionVersionPrefix + "2" + 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 agent sessions. At the start of a new context, run ` + "`td usage --new-session -q`" + ` to see the current work. Use your judgment about how much tracking the task needs. For substantive work, use ` + "`td start <id>`" + `, record useful progress or decisions with ` + "`td log`" + `, hand off unfinished work with ` + "`td handoff <id>`" + `, and submit completed work with ` + "`td review <id>`" + `. Prefer an independent review when practical. In the default trusted mode, self-review is allowed and audited: ` + "`td approve <id> --self-review --reason \"...\"`" + ` Run ` + "`td usage`" + ` for workflow guidance or ` + "`td <command> --help`" + ` for details.` // 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.