preamble

package
v0.73.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 11 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 preamble builds what a skill's `!` line injects before the model's first turn, each load of which used to cost a turn. Claude Code 2.1.332 spills injected output over 30,000 characters to a file, hence the parts.

Index

Constants

View Source
const (
	// InlineLimit keeps the injected text under Claude Code's 30,000-character cap.
	InlineLimit = 29_000
	// PartLimit keeps a part under the Read tool's default token limit.
	PartLimit = 50_000
)

Variables

View Source
var Loads = map[string][]string{
	"audit":      {"audit", "capture"},
	"brainstorm": {"brainstorm"},
	"capture":    {"capture"},
	"catchup":    {"catchup"},
	"ci":         {"ci", "catchup"},
	"cleanup":    {"cleanup"},
	"debug":      {"debug", "capture", "fetch", "investigate", "plan"},
	"demo":       {"demo"},
	"explain":    {"explain"},
	"handoff":    {"handoff"},
	"judge":      {"judge"},
	"plan":       {"fetch", "investigate", "plan"},
	"resolve":    {"review", "resolve"},
	"review":     {"review"},
	"standup":    {"standup"},
	"ship":       {"fetch"},
}

Loads mirrors each skill's Run block: the steps its first load names. A layout test pins every entry to its SKILL.md, so the two cannot drift.

Functions

func Build

func Build(ctx context.Context, env Env) string

Build is the injected text. It never fails: a failure is the failure block of conventions/failure.md, which the skill stops on.

func StepsFor

func StepsFor(ctx context.Context, env Env, a Args) []string

StepsFor is the steps the preamble loads for this call.

Types

type Args

type Args struct {
	Raw     string
	Driven  bool
	Paced   bool // explain only: one beat per turn (modes/paced.md)
	Help    bool
	DryRun  bool
	Flow    string // a leading `name:` word
	Pace    string
	Subject string   // the first word left, the task id or the description's first word
	Words   []string // what is left, the subject first
	// Lead is the lead task's id as `f10 task read` printed it, so a number
	// or a url subject still finds its saved plan
	Lead string
}

Args is a skill's argument as the preamble reads it.

func ParseArgs

func ParseArgs(raw string) Args

ParseArgs reads the argument up to a chained `&&`; --driven counts anywhere, because driven mode holds for the whole chain.

func (Args) PlanFile

func (a Args) PlanFile() bool

PlanFile is a subject that names a saved plan, which ship runs with no fetch.

func (Args) TaskIDs

func (a Args) TaskIDs() []string

TaskIDs are the subject's task ids when it names a task or a bundle, else nil. A first word reads as the hook's seed reads it (taskid.IsWord), so `x86-64 builds crash` stays a description.

type Env

type Env struct {
	Root     string // the plugin root: bin/, modes/, conventions/
	Self     string // the f10 binary, for the verbs the preamble runs
	Cwd      string
	StateDir string
	Session  string
	Skill    string // without the f10: prefix
	Args     string
	Now      time.Time
	Run      Runner
	// PlanExists reports whether a task's plan file is saved.
	PlanExists func(lead string) bool
	// FlowByArea reports whether project.md maps areas to flows, so ship
	// cannot know its flow before investigate.
	FlowByArea bool
	// NoHandover is a call that got no arguments from the hook, which a
	// skill given arguments cannot tell from one given none.
	NoHandover bool
}

Env is what one preamble reads.

type Runner

type Runner func(ctx context.Context, dir, name string, args ...string) (string, int, error)

A Runner runs a command and returns its stdout and stderr together, and its exit code; err is only for a command that could not start.

Jump to

Keyboard shortcuts

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