projectdocs

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 16 Imported by: ? 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 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):

  1. ~/.har/AGENTS.md the user's own (trusted; local backend or opt-in)
  2. .github/copilot-instructions.md, .cursorrules, .cursor/rules/*.mdc with alwaysApply: true only when the repository has no AGENTS.md
  3. AGENTS.md, else CLAUDE.md, else GEMINI.md at the root of the repository
  4. .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

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

View Source
var Files = []string{"AGENTS.md", "CLAUDE.md", "GEMINI.md"}

Files are the root files tried in order; the first that exists is used.

View Source
var NestedFiles = []string{"AGENTS.md", "CLAUDE.md"}

NestedFiles are the files looked for in subdirectories, in order.

Functions

func Section

func Section(mgr sandbox.Manager) agent.PromptSection

Section renders the project instructions for the coding variant (nothing for the others, or without a sandbox). It keeps no state between runs.

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 New

func New(o Options) *Docs

New returns the loader.

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.

func (*Docs) Section

func (d *Docs) Section(ctx context.Context, in agent.Input) string

Section renders the instructions of the system prompt. The text is computed once per run, so the prompt is identical at every step even when the agent edits an instruction file.

func (*Docs) Untrusted

func (d *Docs) Untrusted(runID string) bool

Untrusted reports whether the instructions rendered for the run came (in part) from the repository, so the run's context was reported untrusted.

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.

Jump to

Keyboard shortcuts

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