Documentation
¶
Index ¶
- Constants
- Variables
- func AgentRetryOptions(cfg Config) (maxRetries int, initialDelay time.Duration, backoffFactor float64)
- func ConfigPath() (string, error)
- func EnsureWorktreeGitignore(cwd string)
- func GitHubMCPEndpointOrDefault(c GitHubMCPConfig) string
- func GitignoreCoversWorktrees(contents string) bool
- func InGitCheckout() bool
- func InGitCheckoutAt(cwd string) bool
- func InJujutsuCheckoutAt(cwd string) bool
- func IsProjectConfigEmpty(pc ProjectConfig) bool
- func LinearGraphQLEndpointOrDefault(c LinearMCPConfig) string
- func MigrateLegacyIssuesGitHub(cfg *Config, data []byte)
- func MigrateLegacyProviderBlocks(cfg *Config, data []byte)
- func MigrateLegacyProviderEffort(cfg *Config, data []byte)
- func MigrateLegacyToolOutput(cfg *Config, data []byte)
- func ProjectKey(cwd string) string
- func ProjectRoot(cwd string) string
- func ResolveBraveAPIKey(c WebSearchConfig) string
- func Save(cfg Config) error
- func SaveProject(cwd string, pc ProjectConfig) error
- func SaveProjectLocked(cwd string, pc ProjectConfig) error
- func WithConfigLock(fn func() error) error
- func WorktreeEnabled(cfg Config, cwd string) bool
- func WorktreeNameFromCwd(cwd string) string
- type AskCwdInvalidErr
- type Config
- type GitHubMCPConfig
- type IssuesConfig
- type LinearMCPConfig
- type MCPServerConfig
- type MemoryConfig
- type ProjectConfig
- type ProjectMCPConfig
- type ProviderConfig
- type ProviderSlashEntry
- type RecentModelRef
- type RetryConfig
- type RetryUIConfig
- type UIConfig
- type WebSearchConfig
- type WorkflowDef
- type WorkflowSession
- type WorkflowStep
- type WorkflowsConfig
- type WorkspaceBackend
Constants ¶
const ( AgentDefaultMaxRetries = 4 AgentDefaultInitialDelayMs = 2000 AgentDefaultBackoffFactor = 2.0 )
const ( WorkflowScopeUser = "user" WorkflowScopeRepo = "repo" WorkflowScopeGlobal = "global" WorkflowScopePlugin = "plugin" WorkflowStepKindAgent = "" WorkflowStepKindLoop = "loop" WorkflowLoopBreak = "break" WorkflowLoopContinue = "continue" WorkflowLoopDefaultMaxIterations = 10 )
const AskLockPrefix = "ask:"
const GitHubMCPDefaultEndpoint = "https://api.githubcopilot.com/mcp"
const LinearGraphQLDefaultEndpoint = "https://api.linear.app/graphql"
Variables ¶
var ProviderConfigReservedKeys = []string{providerConfigKeyModel, providerConfigKeySlashCommands}
ProviderConfigReservedKeys are the typed keys of a provider block; a provider must not declare a setting under one of them.
Functions ¶
func AgentRetryOptions ¶
func ConfigPath ¶
ConfigPath returns the standard configuration file path.
func EnsureWorktreeGitignore ¶
func EnsureWorktreeGitignore(cwd string)
func GitHubMCPEndpointOrDefault ¶
func GitHubMCPEndpointOrDefault(c GitHubMCPConfig) string
func GitignoreCoversWorktrees ¶
GitignoreCoversWorktrees reports whether a .gitignore body already ignores the .claude/worktrees/ tree (directly or via a broader .claude rule).
func InGitCheckout ¶
func InGitCheckout() bool
func InGitCheckoutAt ¶
func InJujutsuCheckoutAt ¶
func IsProjectConfigEmpty ¶
func IsProjectConfigEmpty(pc ProjectConfig) bool
IsProjectConfigEmpty reports whether pc carries no user-meaningful data.
func LinearGraphQLEndpointOrDefault ¶
func LinearGraphQLEndpointOrDefault(c LinearMCPConfig) string
func MigrateLegacyIssuesGitHub ¶
MigrateLegacyIssuesGitHub lifts the old per-project `issues.github.{endpoint,token}` block into the new `mcp.github.{endpoint,token}` slot.
func MigrateLegacyProviderBlocks ¶
MigrateLegacyProviderBlocks lifts the pre-registry top-level provider blocks ("vertex": {…}, "openrouter": {…}) into Config.Providers. Each block is already flat, so it decodes as a ProviderConfig directly; the keys listed in legacyProviderBlocks are dropped after the serviceAccount alias is honoured. Runs only for ids absent from the new map — an explicit new block always wins.
func MigrateLegacyProviderEffort ¶
MigrateLegacyProviderEffort folds old per-provider effort fields into the new global Config.Effort field. It maps the first non-empty value found.
func MigrateLegacyToolOutput ¶
MigrateLegacyToolOutput folds the deprecated "renderToolOutput" bool into the new tri-state "toolOutput" string so users who upgrade don't see their tool rendering reset on first launch. Runs only when the new key is absent — an explicit new setting always wins.
func ProjectKey ¶
ProjectKey returns the canonical key for project lookups.
func ProjectRoot ¶
ProjectRoot returns the repository root for cwd, or the cleaned cwd if not in a repository.
func ResolveBraveAPIKey ¶
func ResolveBraveAPIKey(c WebSearchConfig) string
ResolveBraveAPIKey returns the Brave Search API key from config or environment.
func SaveProject ¶
func SaveProject(cwd string, pc ProjectConfig) error
SaveProject updates the per-project settings bag for cwd.
func SaveProjectLocked ¶
func SaveProjectLocked(cwd string, pc ProjectConfig) error
SaveProjectLocked updates the per-project settings bag for cwd without acquiring the lock.
func WithConfigLock ¶
WithConfigLock holds configFileMu around fn for atomic read-modify-write sequences.
func WorktreeEnabled ¶
WorktreeEnabled resolves the effective worktree flag for cwd: the project override when set, else the global UI.Worktree, else false.
func WorktreeNameFromCwd ¶
Types ¶
type AskCwdInvalidErr ¶
func ValidateAskCwd ¶
func ValidateAskCwd(cwd string) AskCwdInvalidErr
type Config ¶
type Config struct {
Provider string `json:"provider,omitempty"`
Effort string `json:"effort,omitempty"`
// Providers holds one block per registered provider id. Providers
// declare their own fields (pkg/providers SettingField); config only
// stores them.
Providers map[string]ProviderConfig `json:"providers,omitempty"`
UI UIConfig `json:"ui,omitempty"`
WebSearch WebSearchConfig `json:"webSearch,omitempty"`
MCPServers map[string]MCPServerConfig `json:"mcpServers,omitempty"`
// MCPDisabled overrides the effective enabled/disabled state of an MCP
// server by name, regardless of which source defined it (project
// .mcp.json, user/project config, or a plugin). true = disabled,
// false = force-enabled. Absent = fall back to the server's own state.
MCPDisabled map[string]bool `json:"mcpDisabled,omitempty"`
Keybindings map[string]string `json:"keybindings,omitempty"`
RecentModels []RecentModelRef `json:"recentModels,omitempty"`
Projects map[string]ProjectConfig `json:"projects,omitempty"`
Memory MemoryConfig `json:"memory,omitempty"`
}
Config represents the user-global ask configuration (~/.config/ask/ask.json).
func UpsertProjectConfig ¶
func UpsertProjectConfig(cfg Config, cwd string, pc ProjectConfig) Config
UpsertProjectConfig writes pc into cfg.Projects under cwd's key.
func (Config) ProviderConfig ¶
func (c Config) ProviderConfig(id string) ProviderConfig
ProviderConfig returns provider id's block, zero when absent.
func (*Config) SetProviderConfig ¶
func (c *Config) SetProviderConfig(id string, pc ProviderConfig)
SetProviderConfig stores pc under id, dropping the entry (and the map, when it empties) for an empty block so ask.json never grows "{}" rows.
type GitHubMCPConfig ¶
type IssuesConfig ¶
type LinearMCPConfig ¶
type MCPServerConfig ¶
type MCPServerConfig struct {
Type string `json:"type,omitempty"`
Command string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
Env map[string]string `json:"env,omitempty"`
URL string `json:"url,omitempty"`
OAuth bool `json:"oauth,omitempty"`
Timeout int `json:"timeout,omitempty"`
EnabledTools []string `json:"enabledTools,omitempty"`
DisabledTools []string `json:"disabledTools,omitempty"`
Disabled bool `json:"disabled,omitempty"`
}
type MemoryConfig ¶
type MemoryConfig struct {
Provider string `json:"provider,omitempty"`
Model string `json:"model,omitempty"`
}
MemoryConfig picks the model that runs the post-turn concept extraction. Empty Provider means the session's provider; empty Model means that provider's cheapest listed model.
type ProjectConfig ¶
type ProjectConfig struct {
Issues IssuesConfig `json:"issues,omitempty"`
MCP ProjectMCPConfig `json:"mcp,omitempty"`
Workflows WorkflowsConfig `json:"workflows,omitempty"`
MCPServers map[string]MCPServerConfig `json:"mcpServers,omitempty"`
MCPDisabled map[string]bool `json:"mcpDisabled,omitempty"`
Worktree *bool `json:"worktree,omitempty"`
}
func LoadProject ¶
func LoadProject(cwd string) (ProjectConfig, error)
LoadProject returns the project configuration for the canonical cwd.
func LoadProjectConfig ¶
func LoadProjectConfig(cfg Config, cwd string) ProjectConfig
LoadProjectConfig returns the saved ProjectConfig for cwd, or zero value if absent.
type ProjectMCPConfig ¶
type ProjectMCPConfig struct {
GitHub GitHubMCPConfig `json:"github,omitempty"`
Linear LinearMCPConfig `json:"linear,omitempty"`
}
type ProviderConfig ¶
type ProviderConfig struct {
Model string
SlashCommands []ProviderSlashEntry
Fields map[string]string
}
ProviderConfig is one provider's block under Config.Providers: the model the user picked, the slash commands the provider discovered, and the settings the provider declares (an API key, a project id, …) keyed by their setting key. On disk the block is flat — {"model": "…", "apiKey": "…"} — so ask.json stays hand-editable and byte-compatible with the per-provider blocks it replaced.
func (ProviderConfig) Field ¶
func (pc ProviderConfig) Field(key string) string
Field returns the stored value for key, "" when unset.
func (ProviderConfig) IsEmpty ¶
func (pc ProviderConfig) IsEmpty() bool
IsEmpty reports whether the block carries nothing worth persisting.
func (ProviderConfig) MarshalJSON ¶
func (pc ProviderConfig) MarshalJSON() ([]byte, error)
func (*ProviderConfig) UnmarshalJSON ¶
func (pc *ProviderConfig) UnmarshalJSON(data []byte) error
UnmarshalJSON reads the flat block: the typed keys land on their fields, every other string-valued key lands in Fields. Non-string extras are dropped — provider settings are strings by contract.
func (ProviderConfig) WithField ¶
func (pc ProviderConfig) WithField(key, value string) ProviderConfig
WithField returns a copy of pc with key set to value; an empty value removes the key. The Fields map is copied, never shared.
type ProviderSlashEntry ¶
type RecentModelRef ¶
type RetryConfig ¶
type RetryConfig = RetryUIConfig
type RetryUIConfig ¶
type UIConfig ¶
type UIConfig struct {
QuietMode *bool `json:"quietMode,omitempty"`
CursorBlink *bool `json:"cursorBlink,omitempty"`
RenderDiffs *bool `json:"renderDiffs,omitempty"`
ToolOutput string `json:"toolOutput,omitempty"`
SkipAllPermissions *bool `json:"skipAllPermissions,omitempty"`
Worktree *bool `json:"worktree,omitempty"`
GateTodosBeforeMutate *bool `json:"gateTodosBeforeMutate,omitempty"`
Theme string `json:"theme,omitempty"`
Retry *RetryUIConfig `json:"retry,omitempty"`
}
type WebSearchConfig ¶
type WebSearchConfig struct {
BraveAPIKey string `json:"braveApiKey,omitempty"`
}
type WorkflowDef ¶
type WorkflowDef struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Steps []WorkflowStep `json:"steps,omitempty"`
Scope string `json:"-"`
// Plugin is the "name@marketplace" that ships this workflow when
// Scope == WorkflowScopePlugin (read-only).
Plugin string `json:"-"`
}
type WorkflowSession ¶
type WorkflowSession struct {
Workflow string `json:"workflow"`
StepIndex int `json:"stepIndex"`
Status string `json:"status"`
StartedAt time.Time `json:"startedAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
func (*WorkflowSession) UnmarshalJSON ¶
func (s *WorkflowSession) UnmarshalJSON(data []byte) error
type WorkflowStep ¶
type WorkflowStep struct {
Name string `json:"name"`
Kind string `json:"kind,omitempty"`
Provider string `json:"provider,omitempty"`
Model string `json:"model,omitempty"`
Prompt string `json:"prompt,omitempty"`
Steps []WorkflowStep `json:"steps,omitempty"`
MaxIterations int `json:"maxIterations,omitempty"`
ExitCondition string `json:"exitCondition,omitempty"`
}
func (WorkflowStep) EffectiveMaxIterations ¶
func (s WorkflowStep) EffectiveMaxIterations() int
func (WorkflowStep) IsLoop ¶
func (s WorkflowStep) IsLoop() bool
type WorkflowsConfig ¶
type WorkflowsConfig struct {
ActiveWorkflow string `json:"activeWorkflow,omitempty"`
Items []WorkflowDef `json:"items,omitempty"`
Sessions map[string]WorkflowSession `json:"sessions,omitempty"`
}
type WorkspaceBackend ¶
type WorkspaceBackend int
const ( WorkspaceBackendNone WorkspaceBackend = iota WorkspaceBackendGit WorkspaceBackendJJ )
func WorktreeBackendAt ¶
func WorktreeBackendAt(cwd string) WorkspaceBackend