config

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 10 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

Index

Constants

View Source
const (
	DefaultMaxModuleFiles   = 30
	DefaultModuleSplitFiles = 40
)

Defaults for the per-module listing caps. Override with max_module_files and module_split_files in .stacklitrc.json or STACKLIT_MAX_MODULE_FILES and STACKLIT_MODULE_SPLIT_FILES.

View Source
const (
	DefaultParseTimeoutMS       = 3000
	DefaultTSMaxBytes     int64 = 128 << 10
	DefaultMaxLineLen           = 2000
)

Defaults for the per-file parse limits. Each is overridable in .stacklitrc.json or by env (a value of -1, or 0 in env, disables it).

View Source
const DefaultMaxFileSize int64 = 1 << 20

DefaultMaxFileSize is the fallback cap for a single source file (bytes). Override with max_file_size in .stacklitrc.json or STACKLIT_MAX_FILE_SIZE.

View Source
const DefaultMemoryLimitMB = 448

DefaultMemoryLimitMB is the soft heap limit applied during a scan. The pure-Go parser churns gigabytes of short-lived arenas; without a limit the GC lets RSS run several times above the live set.

View Source
const DefaultParseMemoryMB = 256

DefaultParseMemoryMB bounds concurrent parser memory when nothing is set.

Variables

This section is empty.

Functions

func Check added in v0.5.0

func Check(root string) error

Check returns a *Error when .stacklitrc.json exists but is not valid JSON or holds values that cannot work. Unknown keys are tolerated so an older binary still runs against a newer rc file; `stacklit doctor` reports them.

Types

type CheckConfig added in v0.5.0

type CheckConfig struct {
	Forbidden []ForbiddenEdge `json:"forbidden,omitempty"`
	Cycles    bool            `json:"cycles,omitempty"`  // report import cycles between modules
	Orphans   bool            `json:"orphans,omitempty"` // report modules with no edges in or out
	MaxFanIn  int             `json:"max_fan_in,omitempty"`
	MaxFanOut int             `json:"max_fan_out,omitempty"`
}

CheckConfig lists the architecture rules `stacklit check` enforces. Every rule is off until configured; limits come from this file, never from code.

type Config

type Config struct {
	Ignore     []string `json:"ignore,omitempty"`
	MaxDepth   int      `json:"max_depth,omitempty"`
	MaxModules int      `json:"max_modules,omitempty"`
	MaxExports int      `json:"max_exports,omitempty"`
	// MaxModuleFiles caps the file names listed per module.
	MaxModuleFiles int `json:"max_module_files,omitempty"`
	// ModuleSplitFiles splits a module with more files than this into
	// subdirectory modules. A negative value turns splitting off.
	ModuleSplitFiles int          `json:"module_split_files,omitempty"`
	Output           OutputConfig `json:"output,omitempty"`

	// Scan controls (see scan.go for env overrides and validation).
	Roots          []string `json:"roots,omitempty"`            // scan only these subdirectories
	Include        []string `json:"include,omitempty"`          // gitignore-style globs; when set only matches are kept
	Exclude        []string `json:"exclude,omitempty"`          // gitignore-style globs always skipped
	MaxFileSize    int64    `json:"max_file_size,omitempty"`    // bytes; larger files are skipped with a warning
	Workers        int      `json:"workers,omitempty"`          // parser pool size; 0 means NumCPU
	ParseMemoryMB  int      `json:"parse_memory_mb,omitempty"`  // soft cap on concurrent parse memory; 0 means default
	ParseTimeoutMS int      `json:"parse_timeout_ms,omitempty"` // per-file tree-sitter budget; 0 means default, -1 disables
	TSMaxBytes     int64    `json:"ts_max_bytes,omitempty"`     // larger files use the lightweight parser; 0 means default, -1 disables
	MaxLineLen     int      `json:"max_line_len,omitempty"`     // longer lines mark a file minified; 0 means default, -1 disables
	SkipGenerated  *bool    `json:"skip_generated,omitempty"`   // generated files use the lightweight parser, default on
	MemoryLimitMB  int      `json:"memory_limit_mb,omitempty"`  // soft Go heap limit during a scan; 0 means default, -1 disables
	Cache          *bool    `json:"cache,omitempty"`            // incremental cache, default on
	Timestamps     *bool    `json:"timestamps,omitempty"`       // write generated_at, default off
	GitActivity    *bool    `json:"git_activity,omitempty"`     // include hot/recent files, default off
	MapIcons       string   `json:"map_icons,omitempty"`        // "remote" (default) or "off" for the HTML map

	// Steering picks the rule wording in the generated CLAUDE.md block ("a", "b", "c" or "d", the strict no-crawl wording).
	Steering string `json:"steering,omitempty"`
	// CrawlGuard sets the Claude Code crawl guard hook mode: "off", "nudge" or
	// "redirect". Also STACKLIT_CRAWL_GUARD. Empty uses the mode setup installed.
	CrawlGuard string `json:"crawl_guard,omitempty"`
	// Stats turns on the local usage log (also STACKLIT_STATS=1). Default off.
	Stats *bool `json:"stats,omitempty"`

	// Check holds architecture rules evaluated by `stacklit check`.
	Check *CheckConfig `json:"check,omitempty"`
}

Config holds the settings loaded from a .stacklitrc.json file.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a Config populated with sensible defaults.

func Load

func Load(root string) *Config

Load reads .stacklitrc.json from root and merges it over the defaults. If the file does not exist or cannot be parsed, defaults are returned.

func LoadStrict added in v0.5.0

func LoadStrict(root string) (*Config, error)

LoadStrict reads .stacklitrc.json and reports parse and validation errors instead of silently falling back to defaults. A missing file is not an error.

func (*Config) CacheEnabled added in v0.5.0

func (c *Config) CacheEnabled() bool

CacheEnabled reports whether the incremental cache is on (default true).

func (*Config) GitActivityEnabled added in v0.5.0

func (c *Config) GitActivityEnabled() bool

GitActivityEnabled reports whether git history feeds the index (default false, opt in with git_activity or STACKLIT_GIT).

func (*Config) MapIconsOff added in v0.5.0

func (c *Config) MapIconsOff() bool

MapIconsOff reports whether the HTML map must not request any remote icon.

func (*Config) MemoryLimitBytes added in v0.5.0

func (c *Config) MemoryLimitBytes() int64

MemoryLimitBytes returns the soft heap limit, or 0 for none. An explicit GOMEMLIMIT in the environment always wins.

func (*Config) NormalizedRoots added in v0.5.0

func (c *Config) NormalizedRoots() []string

NormalizedRoots returns cleaned, slash-separated scan roots relative to the repo root. Empty means "scan everything".

func (*Config) ParseLimits added in v0.5.0

func (c *Config) ParseLimits() parser.Limits

ParseLimits resolves the effective per-file cost limits.

func (*Config) ParseMemoryBytes added in v0.5.0

func (c *Config) ParseMemoryBytes() int64

ParseMemoryBytes returns the concurrent-parse memory budget, or 0 for unlimited (STACKLIT_PARSE_MEMORY_MB=0).

func (*Config) ScanIgnore added in v0.3.2

func (c *Config) ScanIgnore() []string

ScanIgnore returns ignore patterns plus Stacklit output files so generated artifacts never feed back into the next scan. All patterns are normalized to forward slashes so they match the walker's normalized paths on every OS.

func (*Config) TimestampsEnabled added in v0.5.0

func (c *Config) TimestampsEnabled() bool

TimestampsEnabled reports whether generated_at should be written (default false so a committed index stays byte-stable).

func (*Config) Validate added in v0.5.0

func (c *Config) Validate() error

Validate checks the settings for values that cannot work.

func (*Config) WorkerCount added in v0.5.0

func (c *Config) WorkerCount() int

WorkerCount returns the effective parser pool size.

type Error added in v0.5.0

type Error struct{ Err error }

Error marks a problem with the user's configuration, as opposed to an internal failure. The CLI maps it to its own exit code.

func (*Error) Error added in v0.5.0

func (e *Error) Error() string

func (*Error) Unwrap added in v0.5.0

func (e *Error) Unwrap() error

type ForbiddenEdge added in v0.5.0

type ForbiddenEdge struct {
	From   string `json:"from"`
	To     string `json:"to"`
	Reason string `json:"reason,omitempty"`
}

ForbiddenEdge bans dependencies from modules matching From to modules matching To. Patterns are module paths with optional * wildcards; "dir/**" matches dir and below.

type OutputConfig

type OutputConfig struct {
	JSON    string `json:"json,omitempty"`
	Mermaid string `json:"mermaid,omitempty"`
	HTML    string `json:"html,omitempty"`
}

OutputConfig controls where output files are written.

Jump to

Keyboard shortcuts

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