Documentation
¶
Overview ¶
Package asks keeps the questions driven agents stop on in one per-user inbox, so the user can answer from anywhere. An ask is a file: open while it waits, moved to answered/ by the first answer from any way in.
Index ¶
- Constants
- func Banner(a Ask, name string) string
- func ContextOf(a Ask, qs []Shown) []string
- func Dir() string
- func Format(qs []Question, answers map[int]string) string
- func Key(root, task string) string
- func Labelled(sentence string) (string, string, bool)
- func Labels(a Ask) map[string]string
- func Letters(opts []string) string
- func Lint(qs []Question) []string
- func Mark(q Shown) string
- func Message(a Ask) *agentsv1.Ask
- func ProjectHash(root string) string
- func Prune(dir string, now time.Time)
- func Resolve(q Question, value string) (string, error)
- func ResolveReply(qs []Shown, reply string) (string, bool)
- func Sentences(text string) []string
- func Source(by string) agentsv1.AnswerSource
- func Update(dir, key string, fn func(a *Ask)) error
- func Way(by string) string
- type Ask
- func Answered(dir string, since time.Time) ([]Ask, error)
- func AnsweredIn(dir, root string, since time.Time) ([]Ask, error)
- func Claim(dir, key, by, answer string, delivered bool, now time.Time) (Ask, error)
- func Get(dir, key string) (*Ask, bool, error)
- func Open(dir string) ([]Ask, error)
- func OpenIn(dir, root string) ([]Ask, error)
- func Raise(dir string, a Ask, now time.Time) (Ask, bool, error)
- func Untaken(dir, root string) ([]Ask, error)
- type ClosedError
- type Inbox
- type Question
- type Recovered
- type Shown
Constants ¶
const ( ByPane = "pane" // typed in the agent's own pane ByAsks = "asks" // f10 inbox answer, or its walk BySkill = "skill" // /f10:inbox ByDrive = "drive" // f10 start --answer ByCancelled = "cancelled" // its drive was cancelled ByAPI = "api" // a client of the control-plane API )
Ways in an ask was answered by.
const ( AskIcon = "\U000F1738" InboxIcon = "\U000F0687" )
Nerd Font Material Design icons, the only range Claude Code keeps: md-chat_question heads a banner, md-inbox marks the inbox's counts and rows.
const BannerInbox = "/f10:inbox from the main session"
BannerInbox closes the footer: the other way to answer.
const BannerWidth = 76
BannerWidth is the column the banner wraps at. It cannot read the width of the pane or of Claude Code's code block, so it picks one that fits both.
Variables ¶
This section is empty.
Functions ¶
func Banner ¶ added in v0.68.0
Banner renders a as plain text, the same questions, letters and default the walk draws, so what the user sees is what an answer resolves against. It carries no styles, because the hook prints it inside a code fence. name labels the task, such as project:task in a list spanning projects. Empty is the task id.
func ContextOf ¶ added in v0.71.0
ContextOf is the context a view prints above the first question: the ask's own, then question 1's recovered background, which reads as the ask's. A later question's background stays beside that question.
func Dir ¶
func Dir() string
Dir is the inbox: F10_INBOX_DIR, else ~/.claude/f10/inbox, beside the run state and outside every project.
func Format ¶
Format renders answers, by question number, as `1. re-plan 2. wait`, numbered as the ask was; a question with no answer takes its default.
func Key ¶
Key names a task's ask: the project's hash, so two projects' FT-1 differ, and the task id.
func Labelled ¶ added in v0.71.0
Labelled splits "Log: see the run." into its label and the rest, which the views draw as a row with the label in a column.
func Labels ¶ added in v0.62.0
Labels are what f10 adds to an ask, kept out of the generic ask's fields.
func Lint ¶ added in v0.69.0
Lint names each question that lists choices in its text but has no bracketed options, so the walk could not offer them as choices.
func Mark ¶ added in v0.71.0
Mark is what follows the default option: "(default)", with the reason recovered from the prose when there is one.
func Message ¶ added in v0.62.0
Message is an inbox ask as agents.v1 carries it, for the API and the ledger alike: what f10 adds (the task, its project and drive) goes in the labels, so the core grows no task field.
func ProjectHash ¶ added in v0.68.0
ProjectHash names a project by its storage root: the prefix of every ask key under it, which the status line globs without opening a file.
func Prune ¶
Prune drops answered asks older than a week, and open ones whose worktree is gone: a task finished or removed has no agent left to ask.
func Resolve ¶
Resolve maps value to an option by letter (`b`), number (`2`) or text; free text answers only a question without options, so a typo never picks a choice.
func ResolveReply ¶ added in v0.71.0
ResolveReply maps a reply typed in the asking agent's pane to the answer the inbox would send: a letter, a number or an option's text for a lone question, "1. a 2. b" or one token per question for several. A numbered reply also answers a free-text question with its words, and a question with options it leaves out takes its default. Anything else stays the user's own words.
func Sentences ¶ added in v0.69.0
Sentences splits text after a ., ? or ! that a space and an upper-case letter or a digit follow, so "e.g. this" and "v0.68.0" stay whole.
func Source ¶ added in v0.62.0
func Source(by string) agentsv1.AnswerSource
Source is the way in an answer came by, as agents.v1 names it.
Types ¶
type Ask ¶
type Ask struct {
Task string `yaml:"task" json:"task"`
URL string `yaml:"url,omitempty" json:"url,omitempty"`
Root string `yaml:"root" json:"root"` // the storage root
Main string `yaml:"main,omitempty" json:"main,omitempty"` // the main checkout, where a drive is resumed from
Project string `yaml:"project,omitempty" json:"project,omitempty"` // the main checkout's basename, for display
Worktree string `yaml:"worktree" json:"worktree"` // the asking agent's checkout
Suffix string `yaml:"suffix,omitempty" json:"suffix,omitempty"` // the agent's name suffix, for a second attempt at a task
Pane string `yaml:"pane,omitempty" json:"pane,omitempty"` // the asking agent's herdr pane, reported blocked while open
Drive int `yaml:"drive,omitempty" json:"drive,omitempty"` // the drive whose task asks, 0 for none
Skill string `yaml:"skill,omitempty" json:"skill,omitempty"` // where it asked; finish for finish's own question
Text string `yaml:"text" json:"text"` // the ask as written, one line
Context string `yaml:"context,omitempty" json:"context,omitempty"` // background kept apart from the questions
Questions []Question `yaml:"questions" json:"questions"`
AskedAt time.Time `yaml:"asked_at" json:"asked_at"`
Answer string `yaml:"answer,omitempty" json:"answer,omitempty"` // what the agent, or finish, receives
By string `yaml:"by,omitempty" json:"by,omitempty"` // which way in answered it
AnsweredAt time.Time `yaml:"answered_at,omitempty" json:"answered_at,omitzero"`
// DeliveredAt is when the answer reached the agent: at once when typed in
// its pane or prompted by the answering command, else when a drive sends it
DeliveredAt time.Time `yaml:"delivered_at,omitempty" json:"delivered_at,omitzero"`
// TakenAt is when a drive acted on the answer, so no later run of it
// acts again
TakenAt time.Time `yaml:"taken_at,omitempty" json:"taken_at,omitzero"`
}
An Ask is one question set a driven agent, or a drive's finish, stopped on.
func AnsweredIn ¶ added in v0.68.0
AnsweredIn is Answered for the project at root, every project when empty.
func Claim ¶
Claim answers the open ask key; the first claim wins and a later one gets ClosedError naming the winner. delivered says the answer already reached the agent; delivered with no drive to take it, the ask is marked taken.
func OpenIn ¶ added in v0.68.0
OpenIn lists the open asks of the project at root, every project's when root is empty.
func Raise ¶
Raise reports whether a is new. An open ask with the same text is the same ask, and so is an answered one no drive has taken yet: it keeps its time and answer and takes what a adds (the drive, the url), so the agent's ask and its drive's report tell the user once. An answer the agent already heard, with no drive to take it, is done: asking again is a new ask.
type ClosedError ¶
ClosedError is an ask no longer open: another way in answered it first.
func (ClosedError) Error ¶
func (e ClosedError) Error() string
type Inbox ¶ added in v0.62.0
type Inbox struct {
Open []Ask `json:"open"`
Answered []Ask `json:"answered"`
Links map[string]map[string]string `json:"links,omitempty"`
}
An Inbox is the asks a list shows, open then answered, with the task urls known for them by display project and task id, so a terminal's list links them.
type Question ¶
type Question struct {
N int `json:"n" yaml:"n"`
Text string `json:"text" yaml:"text"`
Options []string `json:"options,omitempty" yaml:"options,omitempty"`
}
A Question is one numbered question of an ask; Options[0] is the default.
func Parse ¶
Parse splits `1. Reuse the plan? [reuse | re-plan] 2. ...` into questions. Text with no question numbered 1 is one free-text question, so an odd ask still reaches the user whole. Split also keeps the prose before question 1.
type Recovered ¶ added in v0.69.0
Recovered is a question whose choices were written as prose, laid out as the walk shows it. The recommended option comes first as the default, and Note keeps why it is recommended.
type Shown ¶ added in v0.71.0
type Shown struct {
Question
Stored Question
Recovered bool
Context string // background recovered from the question's prose
Note string // why the default is the default, from the prose
}
Shown is a question as the banner and the walk draw it: the stored one, or the one recovered from its prose. Stored is what an answer goes against.
func ShownQuestions ¶ added in v0.71.0
ShownQuestions are a's questions as every view draws and asks them.