-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.go
More file actions
47 lines (41 loc) · 1.5 KB
/
config.go
File metadata and controls
47 lines (41 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package demojify
import "strings"
// LimitConfig specifies per-file line limits used when scanning files in a
// repository. A zero Default field falls back to DefaultLineLimit.
// Use [DefaultLimitConfig] to obtain a pre-populated config suitable for most
// Go module and AI-agent workspaces.
type LimitConfig struct {
// Default is the maximum number of lines to scan per file.
// When zero, [DefaultLineLimit] is used as the fallback.
Default int
// Files maps individual file paths (relative, forward-slash formatted)
// to their per-file line limits, overriding Default for those files.
Files map[string]int
}
// DefaultLineLimit is the fallback line limit applied when LimitConfig.Default
// is zero.
const DefaultLineLimit = 500
// DefaultLimitConfig returns a LimitConfig with sensible defaults for typical Go
// module and AI-agent workspace scanning:
// - Default line limit of 500
// - .claude/CLAUDE.md limited to 50 lines (short AI context file)
func DefaultLimitConfig() LimitConfig {
return LimitConfig{
Default: 500,
Files: map[string]int{
".claude/CLAUDE.md": 50,
},
}
}
// ResolveLimit returns the effective line limit for path using cfg.
// A file-specific entry in cfg.Files takes precedence over cfg.Default.
// When cfg.Default is zero the fallback [DefaultLineLimit] is returned.
func ResolveLimit(cfg LimitConfig, path string) int {
if v, ok := cfg.Files[strings.ReplaceAll(path, `\`, `/`)]; ok {
return v
}
if cfg.Default == 0 {
return DefaultLineLimit
}
return cfg.Default
}