agent

package
v0.57.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package agent provides utilities for detecting and configuring AI agent instruction files.

Index

Constants

View Source
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

View Source
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

func AnyFileHasTDInstructions(baseDir string) bool

AnyFileHasTDInstructions checks all known agent files in baseDir for td guidance. Returns true if any file already contains the instructions (dedup check).

func DetectAgentFile

func DetectAgentFile(baseDir string) string

DetectAgentFile finds the first existing agent file in baseDir. Returns the full path if found, empty string if none exist.

func HasTDInstructions

func HasTDInstructions(path string) bool

HasTDInstructions checks if the file already contains td guidance.

func InstallInstructions

func InstallInstructions(path string) error

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

func OutdatedMarkedInstructionsFile(baseDir string) string

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

func PreferredAgentFile(baseDir string) string

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.

Jump to

Keyboard shortcuts

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