promptfiles

package
v1.133.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package promptfiles centralises the search rules used to resolve add_prompt_files entries (typically AGENTS.md, CLAUDE.md, ...). The rules are shared by:

  • the runtime add_prompt_files hook, which executes inside the sandbox at turn-start;
  • the docker-agent kit builder, which walks the same paths on the host before sandbox launch so it can stage every relevant file into the kit (see pkg/sandbox/kit).

Keeping the rules in one place guarantees both ends pick the same files and avoids drift when, for example, the kit ships a redacted copy of ~/AGENTS.md that the in-sandbox lookup must then prefer over the now-missing host $HOME entry.

Index

Constants

View Source
const KitSubdir = "prompt_files"

KitSubdir is the subdirectory inside a docker-agent kit that holds staged prompt files. The host writes to it; the in-sandbox lookup reads from it.

View Source
const MaxIndexEntries = 100

MaxIndexEntries caps how many nested prompt files Index lists so a monorepo with hundreds of sub-projects can't flood the context.

Variables

This section is empty.

Functions

func FindInHierarchy

func FindInHierarchy(startDir, filename string) string

FindInHierarchy searches for filename starting at startDir and walking up the directory tree. Returns the path of the first match, or "" if none.

func Index added in v1.131.0

func Index(ctx context.Context, workDir string, filenames []string, maxDepth int, loaded []string) string

Index lists, by path only, the files named by filenames that live below workDir — up to maxDepth directory levels down, 1 being the direct subdirectories. Contents are deliberately not read: the listing costs tokens proportional to the number of sub-projects rather than to the size of their instructions, and the agent reads the ones it needs itself.

Paths in loaded are skipped, so a file is never both injected and listed. Returns "" when maxDepth <= 0 (the scan is opt-in) or nothing is found.

func Paths

func Paths(workDir, homeDir, kitDir, filename string) []string

Paths returns the prompt-file paths to load for filename, in order:

  1. The closest match found while walking up from workDir, if any.
  2. Either a kitDir match (when kitDir is non-empty — running inside a sandbox with a staged kit), or a homeDir match.

kitDir takes precedence over homeDir because, in the sandbox, $HOME does not contain the host's prompt files; the kit is what brought them along (already redacted). Returns at most two paths. Passing homeDir == "" disables the home-dir lookup — useful in tests so they don't need to touch the real $HOME.

func PathsFromEnv

func PathsFromEnv(workDir, homeDir, filename string) []string

PathsFromEnv is a convenience wrapper around Paths that reads the kit directory from skills.KitDirEnv. The runtime in-sandbox hook uses it; host-side callers (the kit builder) pass kitDir explicitly to Paths instead.

Types

This section is empty.

Jump to

Keyboard shortcuts

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