config

package
v0.7.25 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultModel    = "claude-sonnet-4-6"
	AnalyzeModel    = "claude-sonnet-4-6"
	PromptModel     = "claude-opus-4-6"
	ValidationModel = "claude-haiku-4-5-20251001"

	// SourceConfigFile is the source label used when a value comes from the user config file.
	SourceConfigFile = "Config file (user config)"
)

Model constants define the Claude models used for different operations.

View Source
const (
	RoleGate     = "gate"     // enforce at Stop, run-and-record at PreToolUse
	RolePrecheck = "precheck" // check at PreToolUse, enforce at Stop (changed-file variants)
	RoleAutofix  = "autofix"  // run at PreToolUse, enforce at Stop (formatters)
)

Command roles determine hook placement in settings.json.

Variables

View Source
var ValidConfigKeys = map[string]bool{
	"model": true,
}

ValidConfigKeys are the keys accepted by "config set". Credentials (anthropicAPIKey, circleCIToken) are intentionally excluded — users should use "auth set" which validates before storing.

Functions

func AppState added in v0.7.1

func AppState() (string, error)

AppState returns XDG_STATE_HOME or ~/.local/state.

func Clear added in v0.7.24

func Clear(key string) error

Clear removes a stored config value by key.

func Dir

func Dir() (string, error)

Dir returns the chunk config directory, respecting XDG_CONFIG_HOME.

func MaskKey added in v0.7.24

func MaskKey(key string) string

MaskKey masks all but the last 4 characters with *.

func Path

func Path() (string, error)

Path returns the full path to config.json.

func Save

func Save(cfg UserConfig) error

Save writes the config file, creating the directory with 0o700 and file with 0o600.

func SaveCommand added in v0.7.2

func SaveCommand(workDir, name, command string) error

SaveCommand upserts a command in .chunk/config.json.

func SaveProjectConfig added in v0.7.2

func SaveProjectConfig(workDir string, cfg *ProjectConfig) error

SaveProjectConfig writes the config back to .chunk/config.json.

Types

type Command added in v0.7.2

type Command struct {
	Name    string `json:"name"`
	Run     string `json:"run"`
	Role    string `json:"role,omitempty"`
	FileExt string `json:"fileExt,omitempty"`
	Timeout int    `json:"timeout,omitempty"`
	Limit   int    `json:"limit,omitempty"`
	Always  bool   `json:"always,omitempty"`
	Staged  bool   `json:"staged,omitempty"`
}

Command is a single validation command.

type ProjectConfig added in v0.7.2

type ProjectConfig struct {
	Commands []Command             `json:"commands,omitempty"`
	Triggers map[string][]string   `json:"triggers,omitempty"`
	Tasks    map[string]TaskConfig `json:"tasks,omitempty"`
	VCS      *VCSConfig            `json:"vcs,omitempty"`
}

ProjectConfig is the per-repo configuration stored in .chunk/config.json.

func LoadProjectConfig added in v0.7.2

func LoadProjectConfig(workDir string) (*ProjectConfig, error)

LoadProjectConfig reads .chunk/config.json from workDir.

func (*ProjectConfig) FindCommand added in v0.7.2

func (c *ProjectConfig) FindCommand(name string) *Command

FindCommand returns the command with the given name, or nil if not found.

func (*ProjectConfig) HasCommands added in v0.7.2

func (c *ProjectConfig) HasCommands() bool

HasCommands reports whether any commands are configured.

type ResolvedConfig

type ResolvedConfig struct {
	AnthropicAPIKey       string
	AnthropicAPIKeySource string
	CircleCIToken         string
	CircleCITokenSource   string
	GitHubToken           string
	GitHubTokenSource     string
	Model                 string
	ModelSource           string
	AnalyzeModel          string
	PromptModel           string
}

ResolvedConfig holds the final resolved values with their sources.

func Resolve

func Resolve(flagAPIKey, flagModel string) (ResolvedConfig, error)

Resolve computes the final config from flags, env, and file. Priority for API key: flag > env > config file > (none). Priority for model: flag > CODE_REVIEW_CLI_MODEL env > config file > default.

type TaskConfig added in v0.7.2

type TaskConfig struct {
	Instructions string `json:"instructions,omitempty"`
	Schema       string `json:"schema,omitempty"`
	Limit        int    `json:"limit,omitempty"`
	Always       bool   `json:"always,omitempty"`
	Timeout      int    `json:"timeout,omitempty"`
}

TaskConfig holds task delegation configuration.

type UserConfig

type UserConfig struct {
	AnthropicAPIKey string `json:"anthropicAPIKey,omitempty"`
	CircleCIToken   string `json:"circleCIToken,omitempty"`
	Model           string `json:"model,omitempty"`

	// LegacyAPIKey reads the pre-rename "apiKey" field so existing users don't
	// silently lose their stored Anthropic key on upgrade. Migrated into
	// AnthropicAPIKey by Load and dropped on the next Save (omitempty).
	LegacyAPIKey string `json:"apiKey,omitempty"`
}

UserConfig is the on-disk JSON config.

func Load

func Load() (UserConfig, error)

Load reads the config file. Returns empty config if not found.

type VCSConfig added in v0.7.2

type VCSConfig struct {
	Org  string `json:"org,omitempty"`
	Repo string `json:"repo,omitempty"`
}

VCSConfig holds VCS configuration for the project.

Jump to

Keyboard shortcuts

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