Documentation
¶
Overview ¶
Package userq provides User Questions, matching interaction/user-questions. Ask collects selections or custom input through an interchangeable provider. The synchronous test stub returns defaults; production SDKs inject real UI or callbacks. Multi-selection and intent labels keep decision logic independent of the presentation backend.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider interface {
// Ask blocks until an answer and returns its result or error.
Ask(ctx context.Context, opts QuestionOptions) (*QuestionResult, error)
}
Provider is the question backend interface.
type QuestionOptions ¶
type QuestionOptions struct {
// Prompt is the user-facing question.
Prompt string
// Choices lists candidate answers.
Choices []string
// DefaultIndex is the default selection; -1 means none.
DefaultIndex int
// MultiSelect permits multiple selected indices.
MultiSelect bool
// Intent labels the question, such as approval, plan-exit, or goal-blocker.
Intent string
}
QuestionOptions describes a question and its options.
type QuestionResult ¶
type QuestionResult struct {
// SelectedIndex is the selected option, or the first in a multi-selection.
SelectedIndex int
// Custom contains user-entered custom input.
Custom string
// SelectedIndices contains all multi-selected indices.
SelectedIndices []int
}
QuestionResult contains a response.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service supports replaceable question providers.
func (*Service) Ask ¶
Ask returns selection index, custom text, and error, matching the upstream signature.
func (*Service) AskDetailed ¶
func (s *Service) AskDetailed(ctx context.Context, opts QuestionOptions) (*QuestionResult, error)
AskDetailed returns the complete response, including multiple indices.
func (*Service) SetProvider ¶
SetProvider replaces the provider at runtime for SDK integration.
type StubProvider ¶
type StubProvider struct {
// DefaultIndex is the default returned selection.
DefaultIndex int
}
StubProvider returns default selections synchronously for tests.
func (*StubProvider) Ask ¶
func (s *StubProvider) Ask(ctx context.Context, opts QuestionOptions) (*QuestionResult, error)
Ask implements Provider with a default selection and empty custom text.