Documentation
¶
Overview ¶
Package observe turns what a hook sees (a Bash command and its output, a file written) into typed facts about a run. It only recognises; observers act on them: the badge settles what the model would otherwise report.
Index ¶
- Constants
- func Segments(line string) [][]string
- func Stamp(o Observation, session, cwd string, at time.Time)
- type Committed
- type FindingsWritten
- type Finished
- type IssueCreated
- type Meta
- type Observation
- type Observer
- type PRCreated
- type PlanArchived
- type PlanWritten
- type Pushed
- type SessionStopped
- type SkillStarted
- type StepStarted
- type VerdictWritten
- type WaitEnded
- type WaitStarted
Constants ¶
const ( WaitTurn = "turn" WaitQuestion = "question" WaitPermission = "permission" )
Wait reasons: a turn ended and the user has not answered, an AskUserQuestion open, a permission dialog open.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Committed ¶
type Committed struct {
Meta
Branch string `json:"branch"`
SHA string `json:"sha"` // abbreviated, as git printed it
Subject string `json:"subject"`
}
Committed is a `git commit` that made a commit, seen by its `[branch sha] subject` line.
type FindingsWritten ¶
type FindingsWritten struct {
Meta
Path string `json:"path"`
Task string `json:"task"`
Round string `json:"round"`
}
FindingsWritten is a review's findings file saved under the storage root's reviews/<task>/.
func (*FindingsWritten) Kind ¶
func (*FindingsWritten) Kind() string
type IssueCreated ¶
IssueCreated is a tracker issue opened with `gh issue create` or `glab issue create`, seen by the url it printed.
func (*IssueCreated) Kind ¶
func (*IssueCreated) Kind() string
type Meta ¶
type Meta struct {
Session string `json:"session"`
Cwd string `json:"cwd,omitempty"`
At time.Time `json:"at"`
}
Meta is what every observation carries: the session it happened in, the directory it ran from, and when the hook saw it.
type Observation ¶
type Observation interface {
Kind() string
// contains filtered or unexported methods
}
An Observation is one fact. The set is closed: only this package's types satisfy it, so an observer's type switch can be exhaustive.
func FromBash ¶
func FromBash(command, stdout, stderr string) []Observation
FromBash reads one Bash tool call. A creation, commit or push counts only with its evidence in the output, so failures and dry runs need no exit code; urls come from stdout alone: a refused `gh pr create` names a PR on stderr.
func FromMoves ¶
func FromMoves(command, cwd, storageRoot string) []Observation
FromMoves reads the `mv` commands in a Bash call for plans moved into plans/archive/, counted only when the archived file exists afterwards. Relative paths resolve against cwd; storageRoot is matched as in FromWrite.
func FromWrite ¶
func FromWrite(path, storageRoot string) Observation
FromWrite reads one file written with Write or Edit. storageRoot is the resolved storage root; empty falls back to the `.f10/` the path holds. Plan archives are moves, not new plans, and are not matched.
type Observer ¶
type Observer interface {
Observe(ctx context.Context, o Observation) error
}
An Observer receives observations, one at a time, in the order a hook saw them. An error is the observer's own; the hook carries on.
type PlanArchived ¶
type PlanArchived struct {
Meta
From string `json:"from"`
To string `json:"to"`
Task string `json:"task"`
}
PlanArchived is a plan moved into the storage root's plans/archive/, the plan step's way of superseding it.
func (*PlanArchived) Kind ¶
func (*PlanArchived) Kind() string
type PlanWritten ¶
PlanWritten is a plan file saved under the storage root's plans/.
func (*PlanWritten) Kind ¶
func (*PlanWritten) Kind() string
type Pushed ¶
type Pushed struct {
Meta
Remote string `json:"remote,omitempty"` // the `To <remote>` line
Refs []string `json:"refs"` // each `src -> dst` as printed
}
Pushed is a `git push` that moved at least one ref.
type SessionStopped ¶
type SessionStopped struct {
Meta
Task string `json:"task,omitempty"`
Phase string `json:"phase"`
Status string `json:"status"`
Leaf string `json:"leaf,omitempty"`
Backstop bool `json:"backstop,omitempty"`
}
SessionStopped is a turn ending with a run in the session, at the phase, status and leaf its state held before the Stop backstop ran. Backstop says the backstop then promoted it to done.
func (*SessionStopped) Kind ¶
func (*SessionStopped) Kind() string
type SkillStarted ¶
SkillStarted is an f10 skill starting: typed, which Claude Code expands, or called by the model through the Skill tool.
func (*SkillStarted) Kind ¶
func (*SkillStarted) Kind() string
type StepStarted ¶
StepStarted is `f10-load-project.sh` loading steps: ship loads each pipeline step right before it runs, so one step named is that step starting. No steps is a load for a pipeline with no step to name.
func (*StepStarted) Kind ¶
func (*StepStarted) Kind() string
type VerdictWritten ¶
type VerdictWritten struct {
Meta
Path string `json:"path"`
Key string `json:"key"`
N string `json:"n"`
}
VerdictWritten is a judge's verdict file saved under the storage root's verdicts/<key>/, key the task id or, for an idea, a slug.
func (*VerdictWritten) Kind ¶
func (*VerdictWritten) Kind() string
type WaitEnded ¶ added in v0.45.0
type WaitEnded struct {
Meta
Reason string `json:"reason"`
Tool string `json:"tool,omitempty"`
By string `json:"by"`
}
WaitEnded is that wait over, By the hook event that ended it.
type WaitStarted ¶ added in v0.45.0
WaitStarted is a run starting to wait on the user. Tool names the tool a question or permission dialog belongs to.
func (*WaitStarted) Kind ¶ added in v0.45.0
func (*WaitStarted) Kind() string