settings

package
v0.11.4 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package settings provides configuration loading for Entire. This package is separate from cli to allow strategy package to import it without creating an import cycle (cli imports strategy).

Index

Constants

View Source
const (
	EnvCheckpointsPrimary = "ENTIRE_CHECKPOINTS_PRIMARY"
	EnvCheckpointsMirrors = "ENTIRE_CHECKPOINTS_MIRRORS"
)

Environment overrides for checkpoint backend selection. When EnvCheckpointsPrimary is set, it (and the optional comma-separated EnvCheckpointsMirrors) fully replaces any checkpoints block in settings — env wins over file, matching the other ENTIRE_* overrides (ENTIRE_LOG_LEVEL, ENTIRE_TOKEN, …). Primarily for driving e2e/CI and rollout against a specific backend without editing settings.

View Source
const (
	// EntireSettingsFile is the path to the Entire settings file
	EntireSettingsFile = ".entire/settings.json"
	// EntireSettingsLocalFile is the path to the local settings override file (not committed)
	EntireSettingsLocalFile = ".entire/settings.local.json"

	// SettingsName and SettingsLocalName name the same two files relative to
	// the .entire root, which is the coordinate every read and write of them
	// uses. The repo-relative spellings above stay for display, git paths, and
	// tracked-file checks.
	SettingsName      = "settings.json"
	SettingsLocalName = "settings.local.json"
	// ClonePreferencesFile is the path inside the git common dir for clone-local preferences.
	ClonePreferencesFile = "entire/preferences.json"
)
View Source
const (
	// CommitLinkingAlways auto-links commits to sessions without prompting.
	CommitLinkingAlways = "always"
	// CommitLinkingPrompt prompts the user on each commit (default for existing users).
	CommitLinkingPrompt = "prompt"
)

Commit linking mode constants.

View Source
const (
	OPFPromptAsk    = "ask"
	OPFPromptNever  = "never"
	OPFPromptAlways = "always"
)

Valid PromptDefault values. Empty == OPFPromptAsk.

Variables

View Source
var ErrInvalidCheckpointsConfig = errors.New("invalid checkpoints config")

ErrInvalidCheckpointsConfig is returned when a present "checkpoints" settings block is malformed (e.g. a backend with no type).

View Source
var ErrScannerConfig = errors.New("invalid redaction scanner configuration")

ErrScannerConfig marks scanner-configuration failures. Consumers use errors.Is to distinguish these (fail-closed) from ordinary settings problems (warn-and-default).

Functions

func CheckpointRemoteIsLocalOnly added in v0.10.0

func CheckpointRemoteIsLocalOnly(ctx context.Context) bool

CheckpointRemoteIsLocalOnly reports whether a checkpoint_remote entry is present in .entire/settings.local.json.

That file is gitignored and per-clone, so a checkpoint_remote living there is this developer's own explicit choice. Callers use this to distinguish "I configured where my checkpoints go" from "I inherited a committed setting that points at the upstream project's checkpoint repo".

The filename alone does not establish that — see localLayerTrackedReason. This reads the file directly rather than through Load, so it repeats the tracked check the loader applies to the local layer — without it, the ownership signal this gates could be inherited from the very upstream it is meant to distinguish.

The DEEP (index AND HEAD) check, like the OPF command and unlike the layer as a whole: this predicate overrides the checkpoint-remote ownership check on both directions of checkpoint traffic, so being wrong means routing session transcripts to a repository we cannot confirm is ours, not losing a preference. The cost falls only on repos that actually have a local file with the key, and the probe is memoized per process.

Best-effort: an unreadable, malformed, or unverifiable local file reports false, which is the conservative answer (callers then fall back to weaker ownership signals).

func CheckpointRemoteLocalClaimRejection added in v0.11.4

func CheckpointRemoteLocalClaimRejection(ctx context.Context) string

CheckpointRemoteLocalClaimRejection explains why writing a local declaration cannot establish ownership. Check both index and HEAD, even before the local file exists, so a staged removal cannot turn inherited settings into consent.

func ClearVersionedPathCache added in v0.10.2

func ClearVersionedPathCache()

ClearVersionedPathCache drops the memoized trackedness verdicts. Tests that change a file's tracked state within one process must call it; every other process-wide cache in this codebase ships the same seam.

func ClonePreferencesPath added in v0.6.2

func ClonePreferencesPath(ctx context.Context) (string, error)

ClonePreferencesPath returns the clone-local preferences path in the git common dir.

func FilesPresent added in v0.10.4

func FilesPresent(ctx context.Context) (project, local bool, err error)

FilesPresent reports whether each settings file exists, keeping an access failure distinct from absence. IsSetUp and IsSetUpLocal collapse both into false, which is right for a gate but wrong for `entire status`, whose whole job is to say why it cannot see something.

func IsExternalAgentsEnabled added in v0.5.0

func IsExternalAgentsEnabled(ctx context.Context) bool

IsExternalAgentsEnabled checks if external agent discovery is enabled in settings. Returns false by default if settings cannot be loaded or the key is missing.

func IsFilteredFetchesEnabled added in v0.5.5

func IsFilteredFetchesEnabled(ctx context.Context) bool

IsFilteredFetchesEnabled checks if filtered fetches should be used. When enabled, filtered fetches always resolve remote names to URLs first so git does not persist promisor settings onto named remotes in local config. Returns false by default.

func IsImageExternalizationEnabled added in v0.9.0

func IsImageExternalizationEnabled(ctx context.Context) bool

IsImageExternalizationEnabled reports whether inline base64 images should be lifted out of transcripts into the checkpoint asset store. Opt-in via redaction.externalize_images, or the ENTIRE_EXTERNALIZE_IMAGES=1 env override (handy for testing/rollout). Off by default.

func IsSetUp added in v0.4.6

func IsSetUp(ctx context.Context) bool

IsSetUp returns true if Entire has been set up in the current repository. This checks if .entire/settings.json exists. Use this to avoid creating files/directories in repos where Entire was never enabled.

func IsSetUpAndEnabled added in v0.4.6

func IsSetUpAndEnabled(ctx context.Context) bool

IsSetUpAndEnabled returns true if Entire is both set up and enabled. "Set up" spans either scope — .entire/settings.json OR .entire/settings.local.json — so it must check IsSetUpAny, not IsSetUp. `entire enable --local` writes only settings.local.json and never creates the base file; gating on the base file alone would treat such a local-only repo as inactive and make every hook a silent no-op, dropping all checkpoint capture for that documented workflow. The IsSetUpAny guard is still required so a never-enabled repo (no settings file in any scope) is not treated as enabled by Load's default Enabled: true. Any settings read error is treated as disabled (fail closed). Use this for hooks that should be no-ops when Entire is not active.

func IsSetUpAny added in v0.5.1

func IsSetUpAny(ctx context.Context) bool

IsSetUpAny returns true if Entire has been set up in the current repository, checking both .entire/settings.json and .entire/settings.local.json. Use this to detect any prior setup, even if only local settings exist.

func IsSetUpLocal added in v0.10.4

func IsSetUpLocal(ctx context.Context) bool

IsSetUpLocal returns true if .entire/settings.local.json exists. Callers that pick a write target need the two scopes separately, which IsSetUpAny folds together.

func IsSignCheckpointCommitsEnabled added in v0.5.6

func IsSignCheckpointCommitsEnabled(ctx context.Context) bool

IsSignCheckpointCommitsEnabled checks if checkpoint commit signing is enabled in settings. Returns true by default if settings cannot be loaded or the key is missing.

func IsSummarizeEnabled

func IsSummarizeEnabled(ctx context.Context) bool

IsSummarizeEnabled checks if auto-summarize is enabled in settings. Returns false by default if settings cannot be loaded or the key is missing.

func IsTelemetryEnabled added in v0.10.3

func IsTelemetryEnabled(ctx context.Context) bool

IsTelemetryEnabled loads settings and reports the telemetry opt-in. Returns false when settings cannot be loaded — telemetry never fails open.

func LoadLocalBytes added in v0.10.4

func LoadLocalBytes(ctx context.Context) ([]byte, error)

LoadLocalBytes reads .entire/settings.local.json's raw bytes through the shared .entire root, returning nil when the file does not exist. It exists so callers that decode the local layer themselves (they need LoadFromBytes' no-defaults semantics, not loadFromFile's Enabled: true) still read the file through this package rather than reaching for os.ReadFile on a joined path.

func LoadLocalRaw added in v0.6.2

func LoadLocalRaw(ctx context.Context) (path string, raw map[string]json.RawMessage, exists bool, err error)

LoadLocalRaw reads the raw local file and is deliberately UNGATED: it is the read half of read-modify-write for every caller that saves the file back, so hiding a tracked file here would make those writers clobber its other keys. Readers that need the "is this the developer's own choice?" guarantee must apply the tracked check themselves — see CheckpointRemoteIsLocalOnly.

LoadLocalRaw reads .entire/settings.local.json as a generic JSON object, mirroring LoadProjectRaw for the per-developer overrides file. Returns exists=false (and an empty raw map) when the file does not exist — the common case for users who haven't created the local override file.

Pair with SaveProjectRaw for read-modify-write flows that need to preserve unrelated keys in the per-developer override file.

func LoadProjectRaw added in v0.6.2

func LoadProjectRaw(ctx context.Context) (path string, raw map[string]json.RawMessage, exists bool, err error)

LoadProjectRaw reads .entire/settings.json as a generic JSON object so callers can inspect or mutate individual keys without losing unrelated fields to round-trip decoding.

Returns:

  • path: absolute path of the project settings file.
  • raw: parsed JSON object, or an empty map when the file is missing.
  • exists: false when the file does not exist (raw is empty); true otherwise.
  • err: parse error or read error other than ENOENT.

Pair with SaveProjectRaw for read-modify-write flows that need to preserve unrelated keys. Owning the path resolution and raw IO here keeps callers from duplicating settings parsing in violation of the "Settings access must go through the settings package" rule in CLAUDE.md.

func ModifyClonePreferences added in v0.7.8

func ModifyClonePreferences(ctx context.Context, fn func(*ClonePreferences) error) error

ModifyClonePreferences runs a read-modify-write under the preferences lock.

func Save added in v0.3.12

func Save(ctx context.Context, settings *EntireSettings) error

Save saves the settings to .entire/settings.json.

func SaveLocal added in v0.3.12

func SaveLocal(ctx context.Context, settings *EntireSettings) error

SaveLocal saves the settings to .entire/settings.local.json.

func SaveLocalRaw added in v0.7.8

func SaveLocalRaw(path string, raw map[string]json.RawMessage) error

SaveLocalRaw writes a generic JSON object back to .entire/settings.local.json atomically (temp file + rename). Mirrors SaveProjectRaw for the per-developer overrides file; the only difference is the error wording, which says "local settings" so failure messages match the file actually being written.

Pair with LoadLocalRaw for read-modify-write flows that target the local override (e.g. persisting an interactive prompt's "always" choice without touching the project-wide settings file).

func SaveProjectRaw added in v0.6.2

func SaveProjectRaw(path string, raw map[string]json.RawMessage) error

SaveProjectRaw writes a generic JSON object back to .entire/settings.json atomically (temp file + rename). Callers should mutate the map returned by LoadProjectRaw and pass it back here so unrelated fields are preserved.

func SetCheckpointPushRemoteLocal added in v0.11.0

func SetCheckpointPushRemoteLocal(ctx context.Context, name string) (bool, error)

SetCheckpointPushRemoteLocal records an explicit clone-local checkpoint push remote, preserving unrelated local fields and leaving project settings alone. The caller must validate that name identifies an existing git remote. It returns false without writing when the same local override is effective.

func WithWorktreeRoot added in v0.6.3

func WithWorktreeRoot(ctx context.Context, worktreeRoot string) context.Context

WithWorktreeRoot returns a context that makes settings.Load resolve project and clone-local settings relative to worktreeRoot instead of the process cwd.

func WorktreeRoot added in v0.10.1

func WorktreeRoot(ctx context.Context) (string, bool)

WorktreeRoot returns the explicit worktree root carried by ctx. Consumers that combine settings resolution with repo-local git commands use this to keep both operations scoped to the same repository.

Types

type AgentPromptRejection added in v0.11.0

type AgentPromptRejection struct {
	Field  string
	Value  string
	Reason string
}

AgentPromptRejection reports one agent instruction field Load dropped as untrusted: the field's settings path (for example "review_profiles.security.agents.codex.prompt"), the dropped text, and why.

type BackendConfig added in v0.7.8

type BackendConfig struct {
	Type   string          `json:"type"`
	Config json.RawMessage `json:"config,omitempty"`
}

BackendConfig is a discriminated backend selector: Type names the registered backend and Config carries the backend-specific options block (opaque here, decoded by the backend factory).

type CheckpointRemoteConfig added in v0.5.1

type CheckpointRemoteConfig struct {
	Provider string // e.g., "github"
	Repo     string // e.g., "org/checkpoints-repo"
}

CheckpointRemoteConfig holds the structured checkpoint remote configuration. Stored in strategy_options.checkpoint_remote as {"provider": "github", "repo": "org/repo"}.

func (*CheckpointRemoteConfig) Owner added in v0.5.1

func (c *CheckpointRemoteConfig) Owner() string

Owner returns the owner portion of the repo field (before the slash). Returns empty string if the repo field doesn't contain a slash.

type CheckpointsConfig added in v0.7.8

type CheckpointsConfig struct {
	Primary BackendConfig   `json:"primary"`
	Mirrors []BackendConfig `json:"mirrors,omitempty"`
}

CheckpointsConfig selects checkpoint storage backends: one primary (source of truth, serves all reads and writes) and zero or more mirrors (independent backends that receive best-effort write fan-out). When absent, the checkpoint layer defaults to the built-in git-branch backend with no mirrors.

func LoadCheckpointsConfig added in v0.7.8

func LoadCheckpointsConfig(ctx context.Context) (*CheckpointsConfig, error)

LoadCheckpointsConfig reads the checkpoint backend selection from settings without the strict whole-settings validation that Load performs. It is deliberately fail-soft: a missing settings file, a whole-file JSON syntax error, or unrelated invalid fields all resolve to "no checkpoints config" (nil), so checkpoint construction falls back to the default git backend. It errors only when a "checkpoints" block is present but itself invalid.

Precedence mirrors Load: a "checkpoints" block in settings.local.json replaces the one in settings.json wholesale (this is a selection config, not a deep-merged document). Clone preferences carry no checkpoint config and are not consulted.

type ClonePreferences added in v0.6.2

type ClonePreferences struct {
	ReviewProfiles       map[string]ReviewProfileConfig `json:"review_profiles,omitempty"`
	ReviewDefaultProfile string                         `json:"review_default_profile,omitempty"`

	// Deprecated: legacy pre-profile review settings. Kept so old preference
	// files parse. New review setup writes ReviewProfiles instead, while
	// `entire review` may read Review as a fallback when profiles are absent.
	Review         map[string]ReviewConfig `json:"review,omitempty"`
	ReviewFixAgent string                  `json:"review_fix_agent,omitempty"`

	// ReviewMigrationDismissed records that the user declined the one-shot
	// migration of review keys from project settings to clone-local prefs.
	// Once true, `entire review` stops prompting on every invocation; the
	// user can re-enable by editing this file or deleting the key.
	ReviewMigrationDismissed bool `json:"review_migration_dismissed,omitempty"`

	// CheckpointRemoteClaimDeclined records the `provider:repo` the user
	// declined when `entire enable` offered to claim a refused
	// checkpoint_remote, so the confirm prompt is asked once per store
	// instead of on every run. Only the prompt is one-shot: the line saying
	// the store is being ignored still prints every time, because that is
	// the condition the user has to be able to discover.
	//
	// The declined value rather than a bool, because a repo that later
	// configures a DIFFERENT store is a new question. Clone preferences
	// rather than settings.local.json, so declining once covers every
	// worktree of the clone and so a committed file can never suppress the
	// prompt.
	CheckpointRemoteClaimDeclined string `json:"checkpoint_remote_claim_declined,omitempty"`

	// TrailsEnabled caches whether trails are enabled for this repository on the
	// API. Pointer shape distinguishes "unknown/not refreshed yet" (nil) from a
	// definitive false. This is clone-local and not committed so hook-time agent
	// context injection can avoid network/auth work on the prompt path.
	TrailsEnabled *bool `json:"trails_enabled,omitempty"`

	// Freshness and scope for TrailsEnabled.
	TrailsEnabledCheckedAt *time.Time `json:"trails_enabled_checked_at,omitempty"`
	TrailsEnabledRepoKey   string     `json:"trails_enabled_repo_key,omitempty"`
	TrailsEnabledAPIBase   string     `json:"trails_enabled_api_base,omitempty"`
	TrailsEnabledAuthKey   string     `json:"trails_enabled_auth_key,omitempty"`

	// Agent-help refresh failures use a separate, short-lived backoff. Keeping
	// this out of TrailsEnabled ensures a transient help-command failure cannot
	// suppress SessionStart's authoritative enablement probe or context injection.
	TrailsAgentHelpRefreshFailedAt *time.Time `json:"trails_agent_help_refresh_failed_at,omitempty"`
	TrailsAgentHelpFailureRepoKey  string     `json:"trails_agent_help_failure_repo_key,omitempty"`
	TrailsAgentHelpFailureAPIBase  string     `json:"trails_agent_help_failure_api_base,omitempty"`
	TrailsAgentHelpFailureAuthKey  string     `json:"trails_agent_help_failure_auth_key,omitempty"`
}

ClonePreferences stores clone-local, uncommitted preferences that should be shared by linked worktrees in the same git clone.

Stored in the git common dir (not the worktree) so multiple worktrees of the same clone see the same preferences. Not committed because the file lives inside .git/.

func LoadClonePreferences added in v0.6.2

func LoadClonePreferences(ctx context.Context) (*ClonePreferences, error)

LoadClonePreferences loads clone-local preferences from the git common dir.

type EntireSettings

type EntireSettings struct {

	// Enabled indicates whether Entire is active. When false, CLI commands
	// show a disabled message and hooks exit silently. Defaults to true.
	Enabled bool `json:"enabled"`

	// Deprecated: no longer used, and deliberately not read anywhere — not even
	// merged from an override (see mergeScalarFields). Kept so the strict loader
	// (DisallowUnknownFields) still accepts a "local_dev" key in settings files
	// written before it was removed.
	//
	// It let a tracked settings file decide that hooks run repo content; see
	// agent.LegacyLocalDevHookScript for the full rationale. Do not reintroduce a
	// setting that influences hook command generation.
	LocalDev bool `json:"local_dev,omitempty"`

	// LogLevel sets the logging verbosity (debug, info, warn, error).
	// Can be overridden by ENTIRE_LOG_LEVEL environment variable.
	// Defaults to "info".
	LogLevel string `json:"log_level,omitempty"`

	// StrategyOptions contains strategy-specific configuration
	StrategyOptions map[string]any `json:"strategy_options,omitempty"`

	// AbsoluteGitHookPath embeds the full binary path in git hooks instead of
	// bare "entire". This is needed for GUI git clients (Xcode, Tower, etc.)
	// that don't source shell profiles and can't find "entire" on PATH.
	AbsoluteGitHookPath bool `json:"absolute_git_hook_path,omitempty"`

	// Telemetry controls anonymous usage analytics.
	// nil = not asked yet (show prompt), true = opted in, false = opted out
	Telemetry *bool `json:"telemetry,omitempty"`

	// Redaction configures PII redaction behavior for transcripts and metadata.
	Redaction *RedactionSettings `json:"redaction,omitempty"`

	// ReviewProfiles maps profile names (e.g. "general", "security") to
	// named review setups. `entire review` runs one profile: its canonical task
	// is fanned out to the configured agents, then an optional master agent
	// consolidates the worker reports.
	ReviewProfiles map[string]ReviewProfileConfig `json:"review_profiles,omitempty"`

	// ReviewDefaultProfile is the profile used by `entire review` when no
	// profile is supplied. If empty, `general` is used when present, otherwise
	// the single configured profile is used.
	ReviewDefaultProfile string `json:"review_default_profile,omitempty"`

	// Deprecated: legacy pre-profile review settings. Kept so old config files
	// still parse. `entire review` reads this only as a compatibility fallback
	// when no review_profiles are configured, exposing it as the general profile.
	Review map[string]ReviewConfig `json:"review,omitempty"`

	// ReviewFixAgent is a legacy saved fix-agent preference. The `entire review
	// --fix` flow has been removed; this field is retained only so older
	// settings/preferences files still parse. It is no longer read by
	// `entire review`.
	ReviewFixAgent string `json:"review_fix_agent,omitempty"`

	// Deprecated: `entire investigate` moved to the entire-investigate plugin,
	// which owns its configuration in .entire/investigate.local.json. This
	// field is no longer read by anything.
	//
	// It is kept, and kept as a raw message, so the strict loader
	// (DisallowUnknownFields) still accepts an "investigate" key left behind in
	// an existing settings file. Dropping it outright would make settings
	// unloadable — and so the whole CLI unusable — in every repository that
	// still has one. Same reasoning as LocalDev above. Do not reintroduce a
	// typed struct here: the plugin parses its own file.
	//
	// Any well-formed JSON value is accepted and none of it is interpreted.
	// That is the whole contract — the shape of an old investigate block is
	// not this CLI's business any more, and validating it would re-couple the
	// two. Well-formed is not a promise this field makes, it is one the
	// decoder has already kept: a json.RawMessage is only ever populated by a
	// decoder that scanned the value to find its end, so malformed content
	// fails the surrounding settings parse long before it reaches here.
	Investigate json.RawMessage `json:"investigate,omitempty"`

	// CommitLinking controls how commits are linked to agent sessions.
	// "always" = auto-link without prompting, "prompt" = ask on each commit.
	// Defaults to "prompt" (preserves existing user behavior).
	CommitLinking string `json:"commit_linking,omitempty"`

	// ExternalAgents enables discovery and registration of external agent
	// plugins (entire-agent-* binaries on $PATH). Defaults to false.
	//
	// Discovery executes what it finds, so Load() honors a true value only
	// when it is developer-owned — set in an untracked
	// .entire/settings.local.json — and resets it to false otherwise. See
	// enforceExternalAgentsTrust. Readers that obtain settings by any route
	// other than Load() (LoadFromFile, LoadFromBytes) get the ungated value
	// and must not scan $PATH on it.
	ExternalAgents bool `json:"external_agents,omitempty"`

	// AllowSymlinkedAgentDirs lists worktree-relative agent config directories
	// (".claude", ".codex/…") whose symlinks Entire may follow instead of
	// refusing. Defaults to empty, which is the strict behaviour.
	//
	// A list rather than a boolean, on purpose: a flag would disable the whole
	// class, where naming a path is the user saying which arrangement is theirs.
	// Entries are checked against the directories actually derivable from the
	// agents' hook-config paths, so `.entire` and `.git/hooks` cannot be
	// spelled here at all.
	//
	// Following a link means writing where it points, so Load() honors this only
	// from an untracked .entire/settings.local.json, the same gate as
	// ExternalAgents. See enforceSymlinkedAgentDirsTrust and
	// agent.SetVouchedSymlinkedDirs.
	AllowSymlinkedAgentDirs []string `json:"allow_symlinked_agent_dirs,omitempty"`

	// SummaryGeneration stores provider preferences for explain --generate.
	// This is separate from strategy_options.summarize, which controls
	// checkpoint auto-summarize behavior.
	SummaryGeneration *SummaryGenerationSettings `json:"summary_generation,omitempty"`

	// Vercel indicates that the repository uses Vercel and the metadata branch
	// should include a vercel.json that disables deployments for Entire branches.
	Vercel bool `json:"vercel,omitempty"`

	// SummaryTimeoutSeconds is an optional hard deadline (in seconds) for
	// `entire explain --generate` summary generation. Zero or negative means
	// "unset" -- falls back to the per-run --summary-timeout-seconds flag
	// (if set) or the package default (5 minutes). Raise for very large
	// transcripts; lower (e.g. 30) for fast-fail in CI.
	SummaryTimeoutSeconds int `json:"summary_timeout_seconds,omitempty"`

	// SignCheckpointCommits controls whether checkpoint commits are signed.
	// nil/true = sign (default), false = skip signing.
	SignCheckpointCommits *bool `json:"sign_checkpoint_commits,omitempty"`

	// Checkpoints selects checkpoint storage backends (a primary plus optional
	// write-only mirrors). checkpoint.Open consumes it via the lenient
	// LoadCheckpointsConfig loader; the field also lives here so the strict
	// settings loader (DisallowUnknownFields) accepts a "checkpoints" key.
	Checkpoints *CheckpointsConfig `json:"checkpoints,omitempty"`

	// Deprecated: no longer used. Exists to tolerate old settings files
	// that still contain "strategy": "auto-commit" or similar.
	Strategy string `json:"strategy,omitempty"`
	// contains filtered or unexported fields
}

EntireSettings represents the .entire/settings.json configuration

func Load

func Load(ctx context.Context) (*EntireSettings, error)

Load loads the Entire settings from .entire/settings.json, then applies clone-local preferences from the git common dir, then applies any overrides from .entire/settings.local.json if it exists. Returns default settings if no settings or preferences file exists. Works correctly from any subdirectory within the repository.

func LoadFromBytes added in v0.5.4

func LoadFromBytes(data []byte) (*EntireSettings, error)

LoadFromBytes parses settings from raw JSON bytes without merging local overrides. Use this when you have settings content from a non-file source (e.g., git show).

func LoadFromFile added in v0.3.12

func LoadFromFile(filePath string) (*EntireSettings, error)

LoadFromFile loads settings from a specific file path without merging local overrides. Returns default settings if the file doesn't exist. Use this when you need to display individual settings files separately.

func (*EntireSettings) AgentPromptRejections added in v0.11.0

func (s *EntireSettings) AgentPromptRejections() []AgentPromptRejection

AgentPromptRejections reports the agent instruction fields Load dropped as untrusted. Consumers that would have applied a dropped field (review) should surface these on stderr, because it is the only signal that an instruction the user can see in a settings file is not in effect.

func (*EntireSettings) BetterleaksEnabled added in v0.10.3

func (s *EntireSettings) BetterleaksEnabled() bool

BetterleaksEnabled reports whether the betterleaks scanner runs. Default (nil settings, nil redaction, nil scanner, nil enabled): true.

func (*EntireSettings) ExternalAgentsRejection added in v0.10.6

func (s *EntireSettings) ExternalAgentsRejection() (reason string, rejected bool)

ExternalAgentsRejection reports why Load dropped an external_agents grant as untrusted, and whether a rejection happened. Callers that would otherwise scan $PATH should surface it — it is the only signal that a setting the user can see in their settings file is not in effect.

func (*EntireSettings) GetCheckpointPushRemote added in v0.10.0

func (s *EntireSettings) GetCheckpointPushRemote() string

GetCheckpointPushRemote returns the configured checkpoint push remote name. Stored in strategy_options.checkpoint_push_remote as a plain git remote name (e.g. "origin", "private"). This selects WHICH configured remote carries checkpoint data — distinct from checkpoint_remote, which derives a dedicated URL. Returns "" if unset, empty, or not a string.

func (*EntireSettings) GetCheckpointRemote added in v0.5.1

func (s *EntireSettings) GetCheckpointRemote() *CheckpointRemoteConfig

GetCheckpointRemote returns the configured checkpoint remote. Expects a structured object: {"provider": "github", "repo": "org/repo"}. Returns nil if not configured, wrong type, or missing required fields.

func (*EntireSettings) GetCommitLinking added in v0.4.8

func (s *EntireSettings) GetCommitLinking() string

GetCommitLinking returns the effective commit linking mode. Returns the explicit value if set, otherwise defaults to "prompt" to preserve existing user behavior.

func (*EntireSettings) GoredactEnabled added in v0.10.3

func (s *EntireSettings) GoredactEnabled() bool

GoredactEnabled reports whether the goredact scanner runs. Default: false.

func (*EntireSettings) HasCheckpointRemoteKey added in v0.10.0

func (s *EntireSettings) HasCheckpointRemoteKey() bool

HasCheckpointRemoteKey reports whether a checkpoint_remote entry exists in strategy options at all — deliberately including malformed entries that GetCheckpointRemote rejects (it returns nil for absent AND malformed, so it cannot distinguish "no intent" from "botched intent"). Presence in any form means the user intends a checkpoint remote.

func (*EntireSettings) IsFilteredFetchesEnabled added in v0.5.5

func (s *EntireSettings) IsFilteredFetchesEnabled() bool

IsFilteredFetchesEnabled checks if fetches should use --filter=blob:none. When enabled, filtered fetches always use resolved URLs rather than remote names to avoid persisting promisor settings onto named remotes.

func (*EntireSettings) IsPushSessionsDisabled added in v0.3.12

func (s *EntireSettings) IsPushSessionsDisabled() bool

IsPushSessionsDisabled checks if push_sessions is disabled in settings. Returns true if push_sessions is explicitly set to false.

func (*EntireSettings) IsSignCheckpointCommitsEnabled added in v0.5.6

func (s *EntireSettings) IsSignCheckpointCommitsEnabled() bool

IsSignCheckpointCommitsEnabled returns true if checkpoint commits should be signed. Defaults to true when the setting is not explicitly set.

func (*EntireSettings) IsSummarizeEnabled

func (s *EntireSettings) IsSummarizeEnabled() bool

IsSummarizeEnabled checks if auto-summarize is enabled in this settings instance.

func (*EntireSettings) IsTelemetryEnabled added in v0.10.3

func (s *EntireSettings) IsTelemetryEnabled() bool

IsTelemetryEnabled reports whether the user opted in to anonymous usage analytics. Telemetry is opt-in: an absent key means no, so every tracker call site must gate on this rather than on Telemetry being non-nil. Does not consider ENTIRE_TELEMETRY_OPTOUT — the trackers honor that env opt-out themselves (telemetry.IsEnvOptedOut).

func (*EntireSettings) LocalLayerRejection added in v0.10.2

func (s *EntireSettings) LocalLayerRejection() string

LocalLayerRejection reports why .entire/settings.local.json was ignored, or "" when it was applied (or absent). A tracked local file is not local: it arrives by cloning, so honoring it would let one developer's overrides — including ones that pick binaries to execute — apply to everyone.

func (*EntireSettings) SummaryTimeoutValue added in v0.5.6

func (s *EntireSettings) SummaryTimeoutValue() time.Duration

SummaryTimeoutValue returns the configured hard deadline for `entire explain --generate` summary generation. Zero means "unset" -- the caller picks the default. Negative values are treated as unset.

func (*EntireSettings) SymlinkedAgentDirsRejection added in v0.11.0

func (s *EntireSettings) SymlinkedAgentDirsRejection() (reason string, rejected bool)

SymlinkedAgentDirsRejection reports why Load dropped some or all of allow_symlinked_agent_dirs, and whether a rejection happened.

Surfaced for the same reason as ExternalAgentsRejection: without it, a grant that was refused and a setting the user never wrote look identical from the outside, since both end with Entire refusing the link.

type OPFSettings added in v0.7.8

type OPFSettings struct {
	Enabled    bool            `json:"enabled,omitempty"`
	Categories map[string]bool `json:"categories,omitempty"`

	// Command is executed, so Load() honors it only when it is
	// developer-owned — set in an untracked .entire/settings.local.json — and
	// resets it to "" otherwise. See enforceOPFCommandTrust. Readers that
	// obtain settings by any route other than Load() (LoadFromFile,
	// LoadFromBytes) get the ungated value and must not pass it to exec.
	Command        string `json:"command,omitempty"`
	TimeoutSeconds int    `json:"timeout_seconds,omitempty"`

	// PromptDefault controls whether the pre-push hook asks the user
	// before running OPF. "" (default) and "ask" both surface the
	// interactive prompt; "never" skips OPF and pushes regex-only content;
	// "always" runs without asking. ENTIRE_OPF=yes|no on the push
	// invocation overrides this setting per-push.
	PromptDefault string `json:"prompt_default,omitempty"`
	// contains filtered or unexported fields
}

OPFSettings configures the optional OpenAI Privacy Filter detection layer. Disabled by default. Runs only at condensation/export boundaries — see docs/security-and-privacy.md.

There is intentionally no "on_failure" field: warn-only is the only mode the runtime currently supports, and DisallowUnknownFields will reject any future user who tries to set it. Adding the field again should land in lockstep with the runtime enforcement.

func (*OPFSettings) CommandRejection added in v0.10.2

func (o *OPFSettings) CommandRejection() (command, reason string, rejected bool)

CommandRejection reports a Command that Load dropped as untrusted: the original value, why it was rejected, and whether a rejection happened. Callers that configure the OPF runtime should surface this — it is the only signal the user's configured binary is being ignored.

type PIISettings added in v0.5.1

type PIISettings struct {
	Enabled        bool              `json:"enabled"`
	Email          *bool             `json:"email,omitempty"`
	Phone          *bool             `json:"phone,omitempty"`
	Address        *bool             `json:"address,omitempty"`
	CustomPatterns map[string]string `json:"custom_patterns,omitempty"`
}

PIISettings configures PII detection categories. When Enabled is true, email and phone default to true; address defaults to false.

type RedactionSettings added in v0.5.1

type RedactionSettings struct {
	PII *PIISettings `json:"pii,omitempty"`

	// CustomRedactions is a label → RE2 regex map for user-defined patterns
	// to scrub from transcripts. Use it for internal credential shapes the
	// bundled detectors don't know about, project codenames, or any other
	// string pattern you don't want stored. Each match is replaced with the
	// bare "REDACTED" token used by the built-in secret layers, not the
	// "[REDACTED_<LABEL>]" token used by PII. Failed regex compilations are
	// logged via slog.Warn and the rule is skipped.
	CustomRedactions map[string]string `json:"custom_redactions,omitempty"`

	// OpenAIPrivacyFilter is the optional 8th redaction layer (opt-in).
	// See docs/security-and-privacy.md.
	OpenAIPrivacyFilter *OPFSettings `json:"openai_privacy_filter,omitempty"`

	// ExternalizeImages opts into lifting inline base64 images out of transcripts
	// into the checkpoint's assets/ store (off by default). Restore re-injects
	// them regardless of this flag.
	ExternalizeImages bool `json:"externalize_images,omitempty"`

	// Betterleaks toggles the betterleaks scanner engine (layer 2 of the
	// redaction stack). Omitted, or present with `enabled` omitted, means
	// enabled. Honored from the committed settings file only; ignored in
	// settings.local.json.
	Betterleaks *ScannerSettings `json:"betterleaks,omitempty"`

	// Goredact toggles the goredact scanner engine. Omitted, or present
	// with `enabled` omitted, means disabled. Same committed-file-only rule.
	Goredact *ScannerSettings `json:"goredact,omitempty"`
}

RedactionSettings configures redaction behavior beyond the default secret detection.

type ReviewConfig added in v0.6.1

type ReviewConfig struct {
	// Agent is the underlying agent registry key for this worker. Empty means
	// the profile map key is the agent name. Set this when the map key is an
	// alias such as "claude-sonnet" or "claude-opus".
	Agent string `json:"agent,omitempty"`

	// Model is an optional model hint passed to the agent CLI for this worker.
	// Empty means use the agent's own default.
	Model string `json:"model,omitempty"`

	// Skills is the list of slash-prefixed skill invocations configured
	// for this agent. May be empty for prompt/model-driven workers (e.g. Pi),
	// in which case the profile task plus Prompt drive the review.
	Skills []string `json:"skills,omitempty"`

	// Prompt, when non-empty, carries saved agent-specific instructions. It is
	// appended after the profile task (and after any Skills); it is not a
	// verbatim replacement for the whole review prompt.
	//
	// The instructions reach agents spawned with approval checks disabled, so
	// Load() honors this field only from a developer-owned layer (clone-local
	// preferences, or an untracked .entire/settings.local.json) and resets it
	// to "" otherwise. See enforceAgentPromptTrust. Readers that obtain
	// settings by any route other than Load() (LoadFromFile, LoadFromBytes)
	// get the ungated value and must not hand it to an agent.
	Prompt string `json:"prompt,omitempty"`
}

ReviewConfig holds one worker's configuration within a review profile. The profile's agents map is keyed by worker id. For simple configs the worker id is also the agent registry name (for example "claude-code"). To run the same agent more than once with different models, use stable worker ids and set Agent to the underlying registry name.

Skills are agent-specific invocations passed before the task. Prompt is additional agent-specific instruction appended after the profile task; it is no longer a verbatim replacement for the whole review prompt.

func (ReviewConfig) IsZero added in v0.6.1

func (c ReviewConfig) IsZero() bool

IsZero reports whether the config is effectively unset.

type ReviewProfileConfig added in v0.7.8

type ReviewProfileConfig struct {
	// Task is the canonical instruction every reviewer agent receives, so it
	// gets the same provenance gate as ReviewConfig.Prompt: Load() honors it
	// only from a developer-owned layer and resets it to "" otherwise, at
	// which point review falls back to its built-in task text for
	// conventional profile names. See enforceAgentPromptTrust.
	Task   string                  `json:"task,omitempty"`
	Agents map[string]ReviewConfig `json:"agents,omitempty"`
	// Judge is the single agent (plus optional model) that consolidates the
	// reviewers' reports into the final verdict. It is optional: a
	// one-reviewer profile needs no judge (the lone report is the result),
	// and a multi-reviewer profile with no judge set falls back to an
	// auto-selected reviewer that can write a verdict.
	Judge *ReviewConfig `json:"judge,omitempty"`
	// Output selects where the final review verdict is delivered: "local"
	// (printed and saved to the local review manifest — the default) or
	// "trail" (additionally posted to the branch's trail as a finding via
	// the data API). Empty means local.
	Output string `json:"output,omitempty"`
}

ReviewProfileConfig is a named review setup. The profile-level Task is the canonical task every reviewer agent is asked to run; per-agent ReviewConfig entries adapt that task to agent-specific mechanics such as slash commands or additional instructions. Judge names the single agent that consolidates the reviewers' reports into the final verdict in a closing round.

Example:

"review_profiles": {
  "security": {
    "task": "Review this change for auth, injection, secrets, and privilege-boundary bugs.",
    "agents": {
      "claude-sonnet": {"agent": "claude-code", "model": "sonnet", "skills": ["/security-review"]},
      "codex": {"model": "gpt-5-codex", "skills": ["/review"], "prompt": "Focus on security."}
    },
    "judge": {"agent": "claude-code", "model": "opus"}
  }
}

ReviewProfileConfig is intentionally small: the review package owns built-in default task text for conventional profile names like "general".

func (ReviewProfileConfig) IsZero added in v0.7.8

func (c ReviewProfileConfig) IsZero() bool

IsZero reports whether the profile is effectively unset.

type ScannerSettings added in v0.10.3

type ScannerSettings struct {
	Enabled *bool `json:"enabled,omitempty"`
}

ScannerSettings toggles one secret-scanner engine.

type SummaryGenerationSettings added in v0.5.6

type SummaryGenerationSettings struct {
	// Provider is the selected summary provider agent name
	// (for example "claude-code", "codex", or "pi").
	Provider string `json:"provider,omitempty"`

	// Model is an optional model hint passed to the selected provider.
	Model string `json:"model,omitempty"`
}

SummaryGenerationSettings configures provider selection for on-demand checkpoint summaries generated by explain --generate.

func (*SummaryGenerationSettings) SetProvider added in v0.5.6

func (s *SummaryGenerationSettings) SetProvider(newProvider, newModel string)

SetProvider updates the provider and optionally the model, clearing any stale model from the previous provider when switching without a replacement. An empty newProvider preserves the current provider; an empty newModel preserves the current model unless the provider is changing, in which case the old model is cleared to avoid passing (say) a Claude model to Codex.

func (*SummaryGenerationSettings) Validate added in v0.5.6

func (s *SummaryGenerationSettings) Validate() error

Validate returns an error if the settings combination is semantically invalid. A model without a provider is meaningless: the model hint needs a provider to route to. The load path calls Validate() after merging, catching hand-edited files that land in this state.

Jump to

Keyboard shortcuts

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