Documentation
¶
Index ¶
- Constants
- func Check(root string) error
- type CheckConfig
- type Config
- func (c *Config) CacheEnabled() bool
- func (c *Config) GitActivityEnabled() bool
- func (c *Config) MapIconsOff() bool
- func (c *Config) MemoryLimitBytes() int64
- func (c *Config) NormalizedRoots() []string
- func (c *Config) ParseLimits() parser.Limits
- func (c *Config) ParseMemoryBytes() int64
- func (c *Config) ScanIgnore() []string
- func (c *Config) TimestampsEnabled() bool
- func (c *Config) Validate() error
- func (c *Config) WorkerCount() int
- type Error
- type ForbiddenEdge
- type OutputConfig
Constants ¶
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.
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).
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.
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.
const DefaultParseMemoryMB = 256
DefaultParseMemoryMB bounds concurrent parser memory when nothing is set.
Variables ¶
This section is empty.
Functions ¶
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 ¶
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
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
CacheEnabled reports whether the incremental cache is on (default true).
func (*Config) GitActivityEnabled ¶ added in v0.5.0
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
MapIconsOff reports whether the HTML map must not request any remote icon.
func (*Config) MemoryLimitBytes ¶ added in v0.5.0
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
NormalizedRoots returns cleaned, slash-separated scan roots relative to the repo root. Empty means "scan everything".
func (*Config) ParseLimits ¶ added in v0.5.0
ParseLimits resolves the effective per-file cost limits.
func (*Config) ParseMemoryBytes ¶ added in v0.5.0
ParseMemoryBytes returns the concurrent-parse memory budget, or 0 for unlimited (STACKLIT_PARSE_MEMORY_MB=0).
func (*Config) ScanIgnore ¶ added in v0.3.2
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
TimestampsEnabled reports whether generated_at should be written (default false so a committed index stays byte-stable).
func (*Config) WorkerCount ¶ added in v0.5.0
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.
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.