Documentation
¶
Overview ¶
Package launchdefaults stores launch defaults for orgs and repositories: the coding tool, profile, default prompt for each kind of item, model, effort, plan mode, worktree, and extra flags that launches on their items start from.
An owner's defaults (Name "") apply to every repository of that owner, and a repository's own defaults win over them. Every setting inherits when it is "" or nil, so a row only holds what differs. The launcher resolves the full order: the app's settings, then the owner's defaults, the repository's, the chosen prompt's, and last the launch menu's.
Index ¶
- Constants
- Variables
- type Defaults
- type FieldError
- type Index
- type Input
- type Service
- func (s *Service) Check(ctx context.Context, in Input) ([]FieldError, error)
- func (s *Service) List(ctx context.Context) ([]Defaults, error)
- func (s *Service) Remove(ctx context.Context, owner, name string) error
- func (s *Service) Save(ctx context.Context, in Input) (Defaults, error)
- func (s *Service) Targets(ctx context.Context) ([]Target, error)
- type Target
- type ValidationError
Constants ¶
const ( FieldOwner = "owner" FieldName = "name" FieldAgent = "agent" FieldProfile = "profile" FieldPRPromptID = "prPromptId" FieldIssuePromptID = "issuePromptId" FieldModel = "model" FieldEffort = "effort" FieldExtraFlags = "extraFlags" )
Fields a FieldError can name, matching Input's JSON names.
Variables ¶
var ( // ErrInvalidDefaults is returned when launch defaults cannot be saved (see // ValidationError). ErrInvalidDefaults = errors.New("the launch defaults can't be saved") // ErrNotFound is returned when removing defaults that are not stored. ErrNotFound = errors.New("no launch defaults are stored for that org or repository") )
Functions ¶
This section is empty.
Types ¶
type Defaults ¶
type Defaults struct {
// Owner is the org or user; Name is the repository, or "" for the owner's defaults.
Owner string `json:"owner"`
Name string `json:"name"`
// Agent is the coding tool's ID; "" inherits (the app's tool, Claude).
Agent string `json:"agent"`
// Profile names the profile; "" inherits.
Profile string `json:"profile"`
// PRPromptID and IssuePromptID are the default prompts; nil inherits.
PRPromptID *int64 `json:"prPromptId"`
IssuePromptID *int64 `json:"issuePromptId"`
// Model and Effort set --model and --effort; "" inherits.
Model string `json:"model"`
Effort string `json:"effort"`
// PlanMode and Worktree turn plan mode and the worktree on or off; nil inherits.
PlanMode *bool `json:"planMode"`
Worktree *bool `json:"worktree"`
// ExtraArgs are added after the profile's arguments (an owner's before its
// repository's), and ExtraFlags is them on one line, quoted.
ExtraArgs []string `json:"extraArgs"`
ExtraFlags string `json:"extraFlags"`
// UpdatedAt is when the defaults were last saved, as RFC 3339.
UpdatedAt string `json:"updatedAt"`
}
Defaults are one org's or repository's launch defaults. Every field is a plain value.
type FieldError ¶
type FieldError struct {
// Field is the Input field's JSON name, such as "profile".
Field string `json:"field"`
// Message is a sentence saying what is wrong and how to fix it.
Message string `json:"message"`
}
FieldError is a problem with one field of an Input.
type Index ¶
Index holds launch defaults by org and repository, matched ignoring case.
type Input ¶
type Input struct {
Owner string `json:"owner"`
Name string `json:"name"`
Agent string `json:"agent"`
Profile string `json:"profile"`
PRPromptID *int64 `json:"prPromptId"`
IssuePromptID *int64 `json:"issuePromptId"`
Model string `json:"model"`
Effort string `json:"effort"`
PlanMode *bool `json:"planMode"`
Worktree *bool `json:"worktree"`
// ExtraFlags are the extra arguments typed on one line, quoted as in a shell.
ExtraFlags string `json:"extraFlags"`
}
Input is launch defaults as the editor saves them.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service manages the launch defaults.
func (*Service) Check ¶
Check validates launch defaults being edited, as Save would, without saving them.
func (*Service) List ¶
List returns every stored launch default, by owner and then repository, each owner's own defaults first.
func (*Service) Save ¶
Save stores an org's or repository's launch defaults, replacing any it had. Defaults where every setting inherits are removed instead, since they would change nothing.
type Target ¶
type Target struct {
// Owner is the org or user; Name is the repository, or "" for the owner.
Owner string `json:"owner"`
Name string `json:"name"`
// Items counts the inbox items listed for it now.
Items int `json:"items"`
}
Target is an org or repository the inbox has seen, offered when adding defaults.
type ValidationError ¶
type ValidationError struct {
Fields []FieldError
}
ValidationError lists why launch defaults cannot be saved. It matches ErrInvalidDefaults.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
Error joins the field messages.
func (*ValidationError) Is ¶
func (e *ValidationError) Is(target error) bool
Is makes a ValidationError match ErrInvalidDefaults.