launchdefaults

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

View Source
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.

func All

func All(ctx context.Context, db *gorm.DB) ([]Defaults, error)

All returns every stored launch default, by owner and then repository, each owner's own defaults first.

func (Defaults) Target

func (d Defaults) Target() string

Target names the org or repository a Defaults is for: "acme-org" or "acme-org/example-repo".

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

type Index map[string]Defaults

Index holds launch defaults by org and repository, matched ignoring case.

func NewIndex

func NewIndex(all []Defaults) Index

NewIndex indexes launch defaults by their target.

func (Index) For

func (idx Index) For(owner, name string) (org, repo *Defaults)

For returns an org's defaults and a repository's own, each nil when none are stored.

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.

func (Input) Empty

func (in Input) Empty() bool

Empty reports whether every setting inherits.

type Service

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

Service manages the launch defaults.

func NewService

func NewService(db *gorm.DB) *Service

NewService returns a Service over db.

func (*Service) Check

func (s *Service) Check(ctx context.Context, in Input) ([]FieldError, error)

Check validates launch defaults being edited, as Save would, without saving them.

func (*Service) List

func (s *Service) List(ctx context.Context) ([]Defaults, error)

List returns every stored launch default, by owner and then repository, each owner's own defaults first.

func (*Service) Remove

func (s *Service) Remove(ctx context.Context, owner, name string) error

Remove deletes an org's (name "") or a repository's launch defaults.

func (*Service) Save

func (s *Service) Save(ctx context.Context, in Input) (Defaults, error)

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.

func (*Service) Targets

func (s *Service) Targets(ctx context.Context) ([]Target, error)

Targets lists the owners and repositories the inbox has seen, each owner before its repositories, for choosing where to add defaults. Archived repositories are left out. An owner's Items adds up its repositories'.

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.

Directories

Path Synopsis
Package model holds the persisted launch defaults for orgs and repositories.
Package model holds the persisted launch defaults for orgs and repositories.

Jump to

Keyboard shortcuts

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