Documentation
¶
Overview ¶
Package projectdocs puts the instructions of the project and of the user (AGENTS.md and the files other agent tools read) in front of the agent of the coding profile, so it knows the build and test commands and the conventions without spending a tool call to find them.
What is read, lowest priority first (a later file wins where they disagree):
- ~/.har/AGENTS.md the user's own (trusted; local backend or opt-in)
- .github/copilot-instructions.md, .cursorrules, .cursor/rules/*.mdc with alwaysApply: true only when the repository has no AGENTS.md
- AGENTS.md, else CLAUDE.md, else GEMINI.md at the root of the repository
- .har/instructions.md always, last
These go in the system prompt, which stays byte-identical for the whole run (the prompt cache). Notes of subdirectories (an AGENTS.md or CLAUDE.md next to the code, Cursor rules with globs) are not in the prompt: the first time read_file, write_file or edit_file touches a path they cover, they are appended once to that tool's result (AfterPath).
The text of the repository is data, not instructions of the harness: the run's context is marked untrusted (agent.ReportUntrusted). Everything is read through the sandbox, so it works with remote sandboxes; only the user's file comes from the host.
Index ¶
Constants ¶
const ( // MaxBytes bounds one instruction file (and one imported file). MaxBytes = 16 << 10 // MaxTotalBytes bounds all the instructions of the system prompt. MaxTotalBytes = 48 << 10 // MaxNestedBytes bounds the notes of one subdirectory appended to a tool result. MaxNestedBytes = 8 << 10 // MaxImportDepth is how deep @imports are followed. MaxImportDepth = 3 )
Limits.
Variables ¶
var Files = []string{"AGENTS.md", "CLAUDE.md", "GEMINI.md"}
Files are the root files tried in order; the first that exists is used.
var NestedFiles = []string{"AGENTS.md", "CLAUDE.md"}
NestedFiles are the files looked for in subdirectories, in order.
Functions ¶
Types ¶
type Docs ¶
type Docs struct {
// contains filtered or unexported fields
}
Docs loads the instructions. Its Section goes into the system prompt and its AfterPath into sandboxtools.Options.
func (*Docs) AfterPath ¶
func (d *Docs) AfterPath(ctx context.Context, rc tools.RunContext, sb sandbox.Sandbox, p string) string
AfterPath is the hook for sandboxtools.Options.AfterPath: when a tool touches a path covered by notes that the system prompt does not carry, they are returned (to be appended to the tool's result) the first time in the run:
- the AGENTS.md (else CLAUDE.md) of the closest directory above the path that has one, below the workspace root (the root's is in the prompt);
- the Cursor rules with globs that match the path (when the repository has no AGENTS.md).
Each is shown once per run, as "[Instructions for <dir>: …]". The system prompt is not touched, so it stays identical across steps.
type Options ¶
type Options struct {
// Manager supplies the run's sandbox.
Manager sandbox.Manager
// UserDir is the host directory of the user's own files (~/.har); the
// user-level AGENTS.md is read from it. Empty: not read. Set it only when
// the host is the user's own machine (local backend) or the operator opted in:
// a server must not read its own account's home for remote tenants.
UserDir string
}
Options configure the loader.