config

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package config manages CSX_HOME and $CSX_HOME/config.json (goal.md §5.4 — every setting has a working default; the only choice the user ever has to make is the mode).

Index

Constants

View Source
const (
	ModeUninitialized = ""
	ModeCommunity     = "community"
	ModeLocalOnly     = "local-only"
)

Mode values. Empty means uninitialized: csx init has not run yet.

Variables

This section is empty.

Functions

func EnsureHome

func EnsureHome(home string) error

EnsureHome creates the home directory tree (cas, samples, logs). It is idempotent.

func Home

func Home() (string, error)

Home resolves the csx home directory: $CSX_HOME if set, else ~/.csx.

func MayContactRegistries added in v0.1.4

func MayContactRegistries(mode string) bool

MayContactRegistries reports whether this mode is allowed to ask a public registry whether a package exists.

LOCAL ONLY says "nothing about your projects ever leaves this machine", and the README says it in nine languages: local-only mode transmits nothing at all. A publicness probe is a transmission — it hands npm, PyPI, crates.io or the Go proxy the name of every dependency in the lockfile, one request each, from a user who chose the mode that promised exactly this would not happen. The daemon already refused to name packages to the server for this reason; the scan path, the run path, sample creation and the MCP server all did it anyway, on every build.

Uninitialized is excluded too: before csx init, no mode has been chosen, so no permission has been given.

Types

type Config

type Config struct {
	SchemaVersion    int      `json:"schemaVersion"`
	Mode             string   `json:"mode"` // "" | "community" | "local-only"
	ServerURL        string   `json:"serverUrl"`
	PeerListen       bool     `json:"peerListen"`
	PeerPort         int      `json:"peerPort"`
	DaemonPort       int      `json:"daemonPort"`
	IdleVerification string   `json:"idleVerification"`
	LLMCommand       string   `json:"llmCommand"`
	ExcludedPackages []string `json:"excludedPackages"`
	PinnedPackages   []string `json:"pinnedPackages"`
	CacheBudgetMB    int      `json:"cacheBudgetMB"`
	GithubLogin      string   `json:"githubLogin"`
	APIToken         string   `json:"apiToken"`
}

Config is the persisted local client configuration.

func Default

func Default() *Config

Default returns a fresh Config with every default applied.

func Load

func Load(home string) (*Config, error)

Load reads home/config.json. A missing file yields the defaults; fields absent from the file keep their default values.

func (*Config) IsExcluded added in v0.1.4

func (c *Config) IsExcluded(purl, ecosystem, name string) bool

IsExcluded reports whether the user asked for this package to be left out of everything that leaves the machine.

The setting was accepted, saved, echoed back by `csx config get` and consulted by nothing at all: excluded packages were still recorded as observations, still uploaded, and still named in the shard warm list — which asks the server about them by name, so the exclusion leaked the very interest it was meant to hide.

Matching is deliberately generous, because a person typing this setting is stating an intent, not writing a query. Any of these excludes pkg:npm/@acme/widgets@1.2.3:

pkg:npm/@acme/widgets@1.2.3   the exact purl
pkg:npm/@acme/widgets         the purl without a version
npm/@acme/widgets             ecosystem and name
@acme/widgets                 the name alone, every ecosystem

A privacy setting that silently matches less than the user meant is worse than one that matches a little more, so ambiguity resolves toward excluding.

func (*Config) Save

func (c *Config) Save(home string) error

Save writes home/config.json with mode 0600 (it may hold apiToken).

Jump to

Keyboard shortcuts

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