asks

package
v0.55.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 14 Imported by: 0

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

View Source
const (
	ByPane      = "pane"      // typed in the agent's own pane
	ByAsks      = "asks"      // f10 asks answer, or its walk
	BySkill     = "skill"     // /f10:asks
	ByDrive     = "drive"     // f10 drive --answer
	ByCancelled = "cancelled" // its drive was cancelled
)

Ways in an ask was answered by.

Variables

This section is empty.

Functions

func Dir

func Dir() string

Dir is the inbox: F10_ASKS_DIR, else ~/.claude/f10/asks, beside the run state and outside every project.

func Format

func Format(qs []Question, answers map[int]string) string

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

func Key(root, task string) string

Key names a task's ask: the storage root's hash, so two projects' FT-1 differ, and the task id.

func Letters

func Letters(opts []string) string

Letters lists options as `a) reuse, b) re-plan`.

func Prune

func Prune(dir string, now time.Time)

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

func Resolve(q Question, value string) (string, error)

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 Update

func Update(dir, key string, fn func(a *Ask)) error

Update rewrites the answered ask key through fn.

func Way

func Way(by string) string

Way names a way in for a sentence: `in its pane`, `with f10 asks`.

Types

type Ask

type Ask struct {
	Task      string     `yaml:"task"`
	URL       string     `yaml:"url,omitempty"`
	Root      string     `yaml:"root"`              // the storage root
	Main      string     `yaml:"main,omitempty"`    // the main checkout, where a drive is resumed from
	Project   string     `yaml:"project,omitempty"` // the main checkout's basename, for display
	Worktree  string     `yaml:"worktree"`          // the asking agent's checkout
	Suffix    string     `yaml:"suffix,omitempty"`  // the agent's name suffix, for a second attempt at a task
	Drive     int        `yaml:"drive,omitempty"`   // the drive whose task asks, 0 for none
	Skill     string     `yaml:"skill,omitempty"`   // where it asked; finish for finish's own question
	Text      string     `yaml:"text"`              // the ask as written, one line
	Questions []Question `yaml:"questions"`
	AskedAt   time.Time  `yaml:"asked_at"`

	Answer     string    `yaml:"answer,omitempty"` // what the agent, or finish, receives
	By         string    `yaml:"by,omitempty"`     // which way in answered it
	AnsweredAt time.Time `yaml:"answered_at,omitempty"`
	// 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"`
	// TakenAt is when a drive acted on the answer, so no later run of it
	// acts again
	TakenAt time.Time `yaml:"taken_at,omitempty"`
}

An Ask is one question set a driven agent, or a drive's finish, stopped on.

func Answered

func Answered(dir string, since time.Time) ([]Ask, error)

Answered lists asks answered since, oldest answer first.

func Claim

func Claim(dir, key, by, answer string, delivered bool, now time.Time) (Ask, error)

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 Get

func Get(dir, key string) (*Ask, bool, error)

Get is the open ask key, else its answered one, with whether it is open.

func Open

func Open(dir string) ([]Ask, error)

Open lists the open asks, oldest first.

func Raise

func Raise(dir string, a Ask, now time.Time) (Ask, bool, error)

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.

func Untaken

func Untaken(dir, root string) ([]Ask, error)

Untaken lists answered asks under root that no drive has acted on.

func (*Ask) Key

func (a *Ask) Key() string

Key is the ask's own key.

type ClosedError

type ClosedError struct {
	By string
	At time.Time
}

ClosedError is an ask no longer open: another way in answered it first.

func (ClosedError) Error

func (e ClosedError) Error() string

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

func Parse(text string) []Question

Parse splits `1. Reuse the plan? [reuse | re-plan] 2. ...` into questions; text not numbered from 1 is one free-text question, so an odd ask still reaches the user whole.

func (Question) Default

func (q Question) Default() string

Default is the answer the question takes when none is given.

Jump to

Keyboard shortcuts

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