internal

package
v1.11.3 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package internal holds clai's command adapter and flag machinery: the bridge between go_away_boilerplate/pkg/cmd dispatch and clai's per-command flag groups. It sits at the internal root because every subpackage depends on it: domain packages (text, chat, photo, ...) define their commands with it, and the composition root (internal/cli) injects config-prep and querier factories. It is a leaf — it must never import a domain package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MediaFlagValues added in v1.11.0

func MediaFlagValues(flagName, _ string) []cmd.CompletionItem

MediaFlagValues completes flag values for photo and video.

func PlainItems added in v1.11.0

func PlainItems(prefix string, options []string) []cmd.CompletionItem

PlainItems filters options on the prefix and wraps the sorted matches as plain completion items.

func PrepTheme added in v1.11.0

func PrepTheme() (string, error)

PrepTheme resolves the clai config dir and loads theme.json into the global theme, returning the config dir. Every command that renders conversation content or reaches the completion bell needs it: config-touching commands get it via setup.ConfigRunPrep, the replay commands and the read-only chat subcommands call it directly since they run no config migration. A broken theme.json degrades to the built-in theme instead of failing the command.

func SuppressArgs added in v1.11.0

func SuppressArgs([]string, string) []cmd.CompletionItem

SuppressArgs stops positional completion once prompt text begins.

Types

type AgentTextFlags added in v1.11.0

type AgentTextFlags struct {
	ChatModel                 StringFlag
	UseTools                  StringFlag
	CmdBan                    StringFlag
	UseLookback               BoolFlag
	MaxTokens                 IntFlag
	MaxToolCalls              IntFlag
	MaxToolCallsAfterHandover IntFlag
	Glob                      StringFlag
	Profile                   StringFlag
	ProfilePath               StringFlag
	NonInteractive            NonInteractiveFlag
	MediaTools                MediaToolFlags
}

AgentTextFlags is the model/agent group shared by every text-querier command (query, chat and chat continue): model selection, tool and limit configuration, profiles.

func (*AgentTextFlags) Register added in v1.11.0

func (g *AgentTextFlags) Register(fs *flag.FlagSet)

type BoolFlag added in v1.11.0

type BoolFlag struct {
	// contains filtered or unexported fields
}

func (*BoolFlag) Changed added in v1.11.0

func (f *BoolFlag) Changed() bool

func (*BoolFlag) Explicit added in v1.11.0

func (f *BoolFlag) Explicit() bool

func (*BoolFlag) IsBoolFlag added in v1.11.0

func (f *BoolFlag) IsBoolFlag() bool

IsBoolFlag marks the flag bool-arity for stdlib flag and the upstream command scanner's arity union.

func (*BoolFlag) Register added in v1.11.0

func (f *BoolFlag) Register(fs *flag.FlagSet, desc string, names ...string)

func (*BoolFlag) Set added in v1.11.0

func (f *BoolFlag) Set(v string) error

func (*BoolFlag) String added in v1.11.0

func (f *BoolFlag) String() string

func (*BoolFlag) Value added in v1.11.0

func (f *BoolFlag) Value() bool

type ChatFlags added in v1.11.0

type ChatFlags struct {
	Raw            RawFlag
	NonInteractive NonInteractiveFlag
	Profile        StringFlag
}

ChatFlags is the chat tree's group. Every chat subcommand reads stored transcripts and runs no model, so the agent group's model, tool and limit flags would be inert there. Profile is the exception: continuing a chat stamps it onto the conversation, steering later -dre queries.

func (*ChatFlags) Register added in v1.11.0

func (g *ChatFlags) Register(fs *flag.FlagSet)

type Command added in v1.11.0

type Command struct {
	Name     string
	Desc     string
	HelpText string
	Register func(fs *flag.FlagSet)
	OnSetup  func(ctx context.Context, c *Command) error
	OnRun    func(ctx context.Context, c *Command) error
	Subs     map[string]cmd.Command

	// Raw and NonInteractive point at the command's flag groups (nil when
	// the command doesn't own them) so Setup can derive the session
	// globals in one place.
	Raw            *RawFlag
	NonInteractive *NonInteractiveFlag

	// Optional completion hooks; both must stay side-effect-free apart
	// from lazy, memoized data loading.
	CompleteFlagValueFn func(flagName, partial string) []cmd.CompletionItem
	CompleteArgsFn      func(args []string, partial string) []cmd.CompletionItem
	// contains filtered or unexported fields
}

Command adapts one clai command to the cmd.Command interface. Each command owns its flag values (shared groups from this package plus any domain-specific flags) and registers them in Register; subcommands share values with their parent by closing over the same structs. A command with Subs becomes a cmd.Subcommander tree; each level parses its own flagset (D11).

func (*Command) Args added in v1.11.0

func (c *Command) Args() []string

Args returns the positional args, [0] being the command name; valid once Setup has run.

func (*Command) CompleteArgs added in v1.11.0

func (c *Command) CompleteArgs(args []string, partial string) []cmd.CompletionItem

func (*Command) CompleteFlagValue added in v1.11.0

func (c *Command) CompleteFlagValue(flagName, partial string) []cmd.CompletionItem

func (*Command) Describe added in v1.11.0

func (c *Command) Describe() string

func (*Command) Flagset added in v1.11.0

func (c *Command) Flagset() *flag.FlagSet

func (*Command) Help added in v1.11.0

func (c *Command) Help() string

Help returns the command description plus a flag list derived from the command's own flagset.

func (*Command) Run added in v1.11.0

func (c *Command) Run(ctx context.Context) error

func (*Command) SetArgs added in v1.11.0

func (c *Command) SetArgs(args []string)

SetArgs replaces the positional args, for setups that reconstruct a legacy arg shape before delegating.

func (*Command) SetQuerier added in v1.11.0

func (c *Command) SetQuerier(q models.Querier)

SetQuerier hands the adapter the querier its default Run should execute.

func (*Command) Setup added in v1.11.0

func (c *Command) Setup(ctx context.Context) error

func (*Command) Subcommands added in v1.11.0

func (c *Command) Subcommands() map[string]cmd.Command

type CompletionSources added in v1.11.0

type CompletionSources struct {
	ToolNames func() []string
	// contains filtered or unexported fields
}

CompletionSources lazily loads the config-dir-derived completion values, memoized per instance (one per command constructor in production). Loading happens only inside a hook call, keeping Flagset()/Subcommands() pure; a load failure yields no suggestions for that source, never an error — a broken completion must not disturb the shell. ToolNames is injected by the command package (clicmd must not import the tool registry); nil means no -t/-tools value completion.

func (*CompletionSources) TextFlagValues added in v1.11.0

func (s *CompletionSources) TextFlagValues(flagName, partial string) []cmd.CompletionItem

TextFlagValues completes flag values for the text commands (query, chat).

type IntFlag added in v1.11.0

type IntFlag struct {
	// contains filtered or unexported fields
}

IntFlag is an alias-aware int value. The value may be written with a scale ("300k", "1.5M", "2Mi", "3e5"); the notation is documented by intFlagScaleHint and parsed by internal/quantity.

func NewIntFlag added in v1.11.1

func NewIntFlag(def int) IntFlag

NewIntFlag returns an int flag whose zero reading is def.

func (*IntFlag) Changed added in v1.11.0

func (f *IntFlag) Changed() bool

func (*IntFlag) Explicit added in v1.11.0

func (f *IntFlag) Explicit() bool

func (*IntFlag) Register added in v1.11.0

func (f *IntFlag) Register(fs *flag.FlagSet, desc string, names ...string)

func (*IntFlag) Set added in v1.11.0

func (f *IntFlag) Set(v string) error

func (*IntFlag) String added in v1.11.0

func (f *IntFlag) String() string

func (*IntFlag) Value added in v1.11.0

func (f *IntFlag) Value() int

type MediaConfig added in v1.11.0

type MediaConfig struct {
	Model        *string
	ReplyMode    *bool
	StdinReplace *string
	OutputDir    *string
	OutputPrefix *string
}

MediaConfig points at the configuration fields a media command's flags override; the photo and video configurations share this shape.

type MediaFlagSpec added in v1.11.0

type MediaFlagSpec struct {
	ModelNames  []string
	ModelDesc   string
	DirNames    []string
	DirDesc     string
	DirDefault  string
	PrefixNames []string
	PrefixDesc  string
}

MediaFlagSpec parameterizes one medium's flag surface: photo and video differ only in these names, descriptions and the output-dir default.

type MediaFlags added in v1.11.0

type MediaFlags struct {
	Raw        RawFlag
	ReplyStdin ReplyStdinFlags
	Model      StringFlag
	Dir        StringFlag
	Prefix     StringFlag
	// contains filtered or unexported fields
}

MediaFlags is the flag surface shared by the media commands: raw output, the reply/stdin group and the model/dir/prefix triple.

func NewMediaFlags added in v1.11.0

func NewMediaFlags(spec MediaFlagSpec) MediaFlags

NewMediaFlags seeds a medium's defaults: its output dir, the 'clai' file prefix and the group's '{}' stdin placeholder.

func (*MediaFlags) Apply added in v1.11.0

func (f *MediaFlags) Apply(c MediaConfig)

Apply writes the flag values onto the configuration, keeping the flags > file > default precedence: -i seeds the placeholder, an explicit -I/-replace overrules it, and a flag equal to its default counts as unset.

func (*MediaFlags) Register added in v1.11.0

func (f *MediaFlags) Register(fs *flag.FlagSet)

type MediaToolFlags added in v1.11.0

type MediaToolFlags struct {
	AudioModel  StringFlag
	AudioFormat StringFlag
}

MediaToolFlags configures the media tools an agent run may call. The media commands own the same flag names one level down for their own runs; here they configure the tools, so a normal query or chat can pick the model its transcriptions use. Video and photo join when tools for them exist — a flag that silently does nothing is worse than no flag.

func (*MediaToolFlags) Register added in v1.11.0

func (g *MediaToolFlags) Register(fs *flag.FlagSet)

type NonInteractiveFlag added in v1.11.0

type NonInteractiveFlag struct {
	BoolFlag
}

NonInteractiveFlag disables the interactive-macro fallback.

func (*NonInteractiveFlag) Register added in v1.11.0

func (g *NonInteractiveFlag) Register(fs *flag.FlagSet)

type QueryTextFlags added in v1.11.0

type QueryTextFlags struct {
	DirReply       BoolFlag
	UseSkills      StringFlag
	ResponseFormat StringFlag
	ShellContext   StringFlag
	Summarize      BoolFlag
	SummaryModel   StringFlag
}

QueryTextFlags holds the query-only flags: reply modes, skills, structured responses and prompt shell context — none of which apply to chat sessions.

func (*QueryTextFlags) Register added in v1.11.0

func (g *QueryTextFlags) Register(fs *flag.FlagSet)

type RawFlag added in v1.11.0

type RawFlag struct {
	BoolFlag
}

RawFlag is the "common" group: raw output for every command that prints querier or conversation content.

func (*RawFlag) Register added in v1.11.0

func (g *RawFlag) Register(fs *flag.FlagSet)

type ReplyStdinFlags added in v1.11.0

type ReplyStdinFlags struct {
	Reply         BoolFlag
	StdinReplace  StringFlag
	ExpectReplace BoolFlag
}

ReplyStdinFlags holds the reply + stdin-substitution flags shared by the text, photo and video commands.

func NewReplyStdinFlags added in v1.11.0

func NewReplyStdinFlags() ReplyStdinFlags

NewReplyStdinFlags seeds the group's defaults ('{}' stdin placeholder).

func (*ReplyStdinFlags) Register added in v1.11.0

func (g *ReplyStdinFlags) Register(fs *flag.FlagSet)

type StringFlag added in v1.11.0

type StringFlag struct {
	// contains filtered or unexported fields
}

StringFlag, BoolFlag and IntFlag are alias-aware flag values: one value backs both a short and a long name (last one parsed wins), explicit-set is tracked, and each value carries its own default so override cascades can ask Changed() locally instead of comparing against a global defaults bag. Flags equal to their default are treated as unset by Changed() — the historical override semantics, preserved deliberately.

func NewStringFlag added in v1.11.0

func NewStringFlag(def string) StringFlag

NewStringFlag returns a string flag whose zero reading is def.

func (*StringFlag) Changed added in v1.11.0

func (f *StringFlag) Changed() bool

Changed reports whether the value differs from the flag's default.

func (*StringFlag) Explicit added in v1.11.0

func (f *StringFlag) Explicit() bool

Explicit reports whether the flag was passed on the command line.

func (*StringFlag) Register added in v1.11.0

func (f *StringFlag) Register(fs *flag.FlagSet, desc string, names ...string)

Register binds the flag onto fs under every given name.

func (*StringFlag) Set added in v1.11.0

func (f *StringFlag) Set(v string) error

func (*StringFlag) String added in v1.11.0

func (f *StringFlag) String() string

func (*StringFlag) Value added in v1.11.0

func (f *StringFlag) Value() string

Value returns the current value (the default until parsed).

type SummarizeFlags added in v1.11.1

type SummarizeFlags struct {
	Force        BoolFlag
	Yes          BoolFlag
	Workers      IntFlag
	SummaryModel StringFlag
}

SummarizeFlags is the chat summarize surface: regeneration, confirmation, concurrency and the summarizer model. The window is the verb's positional argument. It registers on the summarize sub only, next to the tree's shared -r, -n and -p.

func NewSummarizeFlags added in v1.11.1

func NewSummarizeFlags() SummarizeFlags

NewSummarizeFlags seeds the worker-pool default.

func (*SummarizeFlags) Register added in v1.11.1

func (g *SummarizeFlags) Register(fs *flag.FlagSet)

type TextFlags added in v1.11.0

type TextFlags struct {
	Raw        RawFlag
	ReplyStdin ReplyStdinFlags
	AgentText  AgentTextFlags
	QueryText  QueryTextFlags
}

TextFlags composes the four text-path groups: the parameter type for text.SetupQuerier. Query registers all four; chat registers Raw and AgentText, leaving the others zero-valued (behavior-identical to unset).

func NewTextFlags added in v1.11.0

func NewTextFlags() TextFlags

NewTextFlags seeds the composed groups' defaults.

Directories

Path Synopsis
Package audio holds the vendor-agnostic transcription segment model, wire-payload normalization, local output rendering, and the ffmpeg-backed split/stitch orchestration for oversized files.
Package audio holds the vendor-agnostic transcription segment model, wire-payload normalization, local output rendering, and the ffmpeg-backed split/stitch orchestration for oversized files.
generic
Wire-level transcript normalization: the shared Segment model and the vendor payload parsers live below the vendor clients so that both the vendors and internal/audio can import them (text keeps the same shape with pkg/text/models).
Wire-level transcript normalization: the shared Segment model and the vendor payload parsers live below the vendor clients so that both the vendors and internal/audio can import them (text keeps the same shape with pkg/text/models).
Package board renders a parallel-work progress table: a ▸ title, an optional phase line, a column header, one row per unit of work with a ✓/✗/spinner mark and a live elapsed time, and a footer.
Package board renders a parallel-work progress table: a ▸ title, an optional phase line, a column header, one row per unit of work with a ✓/✗/spinner mark and a live elapsed time, and a footer.
Package cli is clai's composition root: it builds the command dispatch table, interpolates the usage template and owns the entry points that both the root main and the e2e suite call.
Package cli is clai's composition root: it builds the command dispatch table, interpolates the usage template and owns the entry points that both the root main and the e2e suite call.
Package confdir prints the clai config dir or registered subpaths of it.
Package confdir prints the clai config dir or registered subpaths of it.
Package debugflags implements the uniform clai debug-flag scheme.
Package debugflags implements the uniform clai debug-flag scheme.
This package contains test intended to be used by the implementations of the Querier, ChatQuerier and StreamCompleter interfaces
This package contains test intended to be used by the implementations of the Querier, ChatQuerier and StreamCompleter interfaces
generic
Package generic holds photo's vendor-shared surface — the configuration types, image saving and the progress animation — below the vendor clients, so both vendors and internal/photo can import it (same layering as text with pkg/text/models).
Package generic holds photo's vendor-shared surface — the configuration types, image saving and the progress animation — below the vendor clients, so both vendors and internal/photo can import it (same layering as text with pkg/text/models).
Package quantity parses whole numbers written with a scale, the way budgets are typed on a command line: "300k", "1.5M", "2Mi", "3e5".
Package quantity parses whole numbers written with a scale, the way budgets are typed on a command line: "300k", "1.5M", "2Mi", "3e5".
Package skills implements discovery, parsing, trust, activation, and runtime policy handling for clai skills.
Package skills implements discovery, parsing, trust, activation, and runtime policy handling for clai skills.
mcp
mcp/httptestserver
Package httptestserver is the fake streamable-HTTP MCP server this worklog's transport phase introduces and every later phase consumes (worklog 2026-10-02-mcp-connection-cost, phase 4, README shared interfaces).
Package httptestserver is the fake streamable-HTTP MCP server this worklog's transport phase introduces and every later phase consumes (worklog 2026-10-02-mcp-connection-cost, phase 4, README shared interfaces).
mcp/launcher
Package launcher resolves what a command-based MCP server's command line will actually run, using only local evidence and without starting anything.
Package launcher resolves what a command-based MCP server's command line will actually run, using only local evidence and without starting anything.
mcp/mcpauth
Package mcpauth is clai's OAuth 2.1 client for an endpoint-based MCP server: discovery, dynamic client registration, PKCE, the authorization code grant and refresh, a token store, and the credential-precedence chain ahead of all of it (worklog 2026-10-02-mcp-connection-cost, phase 5).
Package mcpauth is clai's OAuth 2.1 client for an endpoint-based MCP server: discovery, dynamic client registration, PKCE, the authorization code grant and refresh, a token store, and the credential-precedence chain ahead of all of it (worklog 2026-10-02-mcp-connection-cost, phase 5).
mcp/oauthtestserver
Package oauthtestserver is the fake OAuth 2.1 authorization server the authorization phase introduces (worklog 2026-10-02-mcp-connection-cost, phase 5, README shared interfaces: "Phase 5 introduces the fake OAuth authorization server only").
Package oauthtestserver is the fake OAuth 2.1 authorization server the authorization phase introduces (worklog 2026-10-02-mcp-connection-cost, phase 5, README shared interfaces: "Phase 5 introduces the fake OAuth authorization server only").
mcp/schemacache
Package schemacache persists a command-based MCP server's negotiated tools/list result, keyed by the content of its identity, so a lazy server can advertise its tools at setup without a transport being constructed (worklog 2026-10-02-mcp-connection-cost, phase 3, D18).
Package schemacache persists a command-based MCP server's negotiated tools/list result, keyed by the content of its identity, so a lazy server can advertise its tools at setup without a transport being constructed (worklog 2026-10-02-mcp-connection-cost, phase 3, D18).
mcp/serverconfig
Package serverconfig parses and validates MCP server config files into pub_models.McpServer values.
Package serverconfig parses and validates MCP server config files into pub_models.McpServer values.
mcp/testserver command
jev
jsonltest
Package jsonltest generates deterministic JSONL session corpora and instrumented filesystems for tests of JSONL-backed conversation sources.
Package jsonltest generates deterministic JSONL session corpora and instrumented filesystems for tests of JSONL-backed conversation sources.
openai
Package openai implements OpenAI vendor integrations (chat, photo, video).
Package openai implements OpenAI vendor integrations (chat, photo, video).
pi
xai
Package version prints clai's build version and dependency versions.
Package version prints clai's build version and dependency versions.
generic
Package generic holds video's vendor-shared configuration types below the vendor clients, so both vendors and internal/video can import them (same layering as text with pkg/text/models).
Package generic holds video's vendor-shared configuration types below the vendor clients, so both vendors and internal/video can import them (same layering as text with pkg/text/models).

Jump to

Keyboard shortcuts

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