Documentation
¶
Overview ¶
Package ask provides the core ask agent loop and supporting types. Used by the daemon handler (server-side) and the CLI (client-side event types).
Plane: shared
Index ¶
- Variables
- func AllCommands() []logos.CommandDoc
- func BuildProvider(model string) (fantasy.Provider, string, error)
- func BuildSystemPromptForMode(mode Mode, params ModeParams) (string, []logos.CommandDoc, error)
- func EnsureRepo(ctx context.Context, cloneURL, localPath string) error
- func FindClonedRepo(name, referencesPath string) (string, error)
- func NetworkCommands() []logos.CommandDoc
- func NewTemenosClient(ctx context.Context) (logos.CommandRunner, error)
- func ResolveRepoRef(ref, referencesPath string) (cloneURL, localPath string, err error)
- func RunAsk(ctx context.Context, req Request, cfg *config.Config, emit EventFunc) error
- type Event
- type EventFunc
- type EventType
- type Mode
- type ModeParams
- type Request
Constants ¶
This section is empty.
Variables ¶
var RGCommandDoc = logos.CommandDoc{
Name: "rg",
Summary: "Search file contents (ripgrep)",
Help: `Common flags:
--glob "*.go" Filter by file pattern
-C 3 Show 3 lines of context
-i Case insensitive
--type go Filter by language
-l List matching files only
List files:
rg --files [path] --glob "*.ts" --sort modified
rg respects .gitignore by default. Fast, recursive.`,
}
RGCommandDoc documents the rg command (search file contents).
var SrcCommandDoc = logos.CommandDoc{
Name: "src",
Summary: "Symbol-aware source reader and editor",
Help: `Usage:
src <file> Symbol tree (depth 2)
src <file> --depth 3 Deeper tree
src <file> -s <id> Read symbol by ID (from tree output)
src <file> --tree Force tree view
Markdown files (.md, .markdown, .mdx) use heading-based sections.
Prefer src over cat/sed for reading code — it shows structure first,
then lets you zoom into specific symbols without reading the whole file.
Examples:
src internal/router/router.go
src internal/router/router.go -s aB
src docs/architecture.md --tree`,
}
SrcCommandDoc documents the src command (symbol-aware source reader).
var URLCommandDoc = logos.CommandDoc{
Name: "url",
Summary: "Fetch a web page as markdown",
Help: `Flags:
--tree Show heading tree with section IDs
-s ID Read section by ID (2-char base62)
--full Full content, skip auto-tree
--tree-threshold Auto-tree above this char count (default: 5000)
Long pages (>5000 chars) auto-show a heading tree. Use -s to read specific sections.
Examples:
url https://docs.example.com/api
url https://docs.example.com/api -s cD
url https://example.com --full`,
}
URLCommandDoc documents the url command (fetch a web page as markdown).
var WebCommandDoc = logos.CommandDoc{
Name: "web",
Summary: "Search the web",
Help: `Flags:
-n N / --max N Maximum results (default 10, max 20)
Uses Brave Search API when BRAVE_API_KEY is set, falls back to DuckDuckGo.
Examples:
web "golang context timeout patterns"
web "RFC 7231 HTTP semantics" -n 5`,
}
WebCommandDoc documents the web command (search the web).
Functions ¶
func AllCommands ¶
func AllCommands() []logos.CommandDoc
AllCommands returns CommandDocs for modes with both filesystem and network access.
func BuildProvider ¶
BuildProvider creates a fantasy.Provider and resolved model ID from a model string. Model format: "provider/model-id" or bare model ID (defaults to anthropic). Currently supports: "minimax/" prefix (→ anthropic-compat via MINIMAX_API_URL/MINIMAX_API_KEY) and bare model IDs (→ anthropic via ANTHROPIC_API_KEY).
func BuildSystemPromptForMode ¶
func BuildSystemPromptForMode(mode Mode, params ModeParams) (string, []logos.CommandDoc, error)
BuildSystemPromptForMode constructs the full system prompt for the given mode. Returns the system prompt string and the list of CommandDocs to expose.
func EnsureRepo ¶
EnsureRepo clones the repo if it doesn't exist, or pulls if it does. The provided context is respected for cancellation; repoOpTimeout is applied as a deadline.
func FindClonedRepo ¶
FindClonedRepo scans the references directory for an already-cloned repo matching the bare name (case-sensitive). Returns the local path if exactly one match is found. Errors with disambiguation list on multiple matches.
func NetworkCommands ¶
func NetworkCommands() []logos.CommandDoc
NetworkCommands returns CommandDocs for network-only modes (--url, --web).
func NewTemenosClient ¶
func NewTemenosClient(ctx context.Context) (logos.CommandRunner, error)
NewTemenosClient creates a CommandRunner and verifies the temenos daemon is reachable. The "daemon not running" hint is only shown when the health check actually fails.
func ResolveRepoRef ¶
ResolveRepoRef converts a repo reference to a clone URL and local path. Supports full URLs, "org/repo" shorthands (→ GitHub), and bare repo names for repos that are already cloned locally in the references directory.
Types ¶
type Event ¶
type Event struct {
Type EventType `json:"type"`
Text string `json:"text,omitempty"` // delta text
Command string `json:"command,omitempty"` // command_start / command_result
Output string `json:"output,omitempty"` // command_result output
ExitCode int `json:"exit_code,omitempty"` // command_result exit code
Reason string `json:"reason,omitempty"` // retry reason
Step int `json:"step,omitempty"` // retry step number
Message string `json:"message,omitempty"` // status/error message
Response string `json:"response,omitempty"` // done — full accumulated response
}
Event is a single NDJSON streaming event from the daemon's /ask endpoint.
type EventFunc ¶
type EventFunc func(Event)
EventFunc is the callback for streaming events to the caller.
type Mode ¶
type Mode string
Mode identifies the ask operating mode.
const ( // ModeProject asks about a registered ttal project. ModeProject Mode = "project" // ModeRepo asks about an open-source repository (auto-clone/pull). ModeRepo Mode = "repo" // ModeURL asks about a web page using url for pre-fetching. ModeURL Mode = "url" // ModeWeb searches the web to answer a question. ModeWeb Mode = "web" // ModeGeneral asks about the current working directory with both filesystem and web tools. ModeGeneral Mode = "general" )
type ModeParams ¶
type ModeParams struct {
WorkingDir string // CWD or project path
ProjectPath string // resolved project path (project mode)
RepoLocalPath string // local clone path (repo mode)
RawURL string // URL to explore (url mode)
Question string // the user's question (used by web mode for {query})
}
ModeParams holds mode-specific parameters for prompt building.
type Request ¶
type Request struct {
Question string `json:"question"`
Mode Mode `json:"mode"` // project, repo, url, web, general
Project string `json:"project,omitempty"` // project alias (mode=project)
Repo string `json:"repo,omitempty"` // repo ref: org/repo or full URL (mode=repo)
URL string `json:"url,omitempty"` // web page URL (mode=url)
MaxSteps int `json:"max_steps,omitempty"` // 0 = config default
MaxTokens int `json:"max_tokens,omitempty"` // 0 = config default
Save bool `json:"save,omitempty"` // save final answer to flicknote
Quiet bool `json:"quiet,omitempty"` // suppress streaming, return final text only
WorkingDir string `json:"working_dir,omitempty"` // CWD for general mode
}
Request is the wire type for POST /ask.