Skip to content

Commit fc590ea

Browse files
AnnatarHeclaude
andcommitted
refactor(model): add omitempty tags to config struct fields
Add omitempty tags to TOML, YAML, and JSON struct tags for optional configuration fields in AIAgentConfig, AIConfig, CCOtel, CodeTracking, LogCleanup, and ShellTimeConfig. This ensures zero-value fields are omitted during serialization for cleaner config output. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 36e851a commit fc590ea

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

model/types.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ type Endpoint struct {
1111

1212
type AIAgentConfig struct {
1313
// AutoRun settings for different command types
14-
View bool `toml:"view" yaml:"view" json:"view"`
15-
Edit bool `toml:"edit" yaml:"edit" json:"edit"`
16-
Delete bool `toml:"delete" yaml:"delete" json:"delete"`
14+
View bool `toml:"view,omitempty" yaml:"view,omitempty" json:"view,omitempty"`
15+
Edit bool `toml:"edit,omitempty" yaml:"edit,omitempty" json:"edit,omitempty"`
16+
Delete bool `toml:"delete,omitempty" yaml:"delete,omitempty" json:"delete,omitempty"`
1717
}
1818

1919
type AIConfig struct {
20-
Agent AIAgentConfig `toml:"agent" yaml:"agent" json:"agent"`
20+
Agent AIAgentConfig `toml:"agent,omitempty" yaml:"agent,omitempty" json:"agent,omitempty"`
2121
ShowTips *bool `toml:"showTips" yaml:"showTips" json:"showTips"`
2222
}
2323

@@ -28,36 +28,36 @@ type CCUsage struct {
2828
// CCOtel configuration for OTEL-based Claude Code tracking (v2)
2929
type CCOtel struct {
3030
Enabled *bool `toml:"enabled" yaml:"enabled" json:"enabled"`
31-
GRPCPort int `toml:"grpcPort" yaml:"grpcPort" json:"grpcPort"` // default: 4317
32-
Debug *bool `toml:"debug" yaml:"debug" json:"debug"` // write raw JSON to debug files
31+
GRPCPort int `toml:"grpcPort,omitempty" yaml:"grpcPort,omitempty" json:"grpcPort,omitempty"` // default: 54027
32+
Debug *bool `toml:"debug" yaml:"debug" json:"debug"` // write raw JSON to debug files
3333
}
3434

3535
// CodeTracking configuration for coding activity heartbeat tracking
3636
type CodeTracking struct {
3737
Enabled *bool `toml:"enabled" yaml:"enabled" json:"enabled"`
38-
APIEndpoint string `toml:"apiEndpoint" yaml:"apiEndpoint" json:"apiEndpoint"` // Custom API endpoint for heartbeats
39-
Token string `toml:"token" yaml:"token" json:"token"` // Custom token for heartbeats
38+
APIEndpoint string `toml:"apiEndpoint,omitempty" yaml:"apiEndpoint,omitempty" json:"apiEndpoint,omitempty"` // Custom API endpoint for heartbeats
39+
Token string `toml:"token,omitempty" yaml:"token,omitempty" json:"token,omitempty"` // Custom token for heartbeats
4040
}
4141

4242
// LogCleanup configuration for automatic log file cleanup
4343
type LogCleanup struct {
44-
Enabled *bool `toml:"enabled" yaml:"enabled" json:"enabled"` // default: true (enabled by default)
45-
ThresholdMB int64 `toml:"thresholdMB" yaml:"thresholdMB" json:"thresholdMB"` // default: 100 MB
44+
Enabled *bool `toml:"enabled" yaml:"enabled" json:"enabled"` // default: true (enabled by default)
45+
ThresholdMB int64 `toml:"thresholdMB,omitempty" yaml:"thresholdMB,omitempty" json:"thresholdMB,omitempty"` // default: 100 MB
4646
}
4747

4848
type ShellTimeConfig struct {
4949
Token string `toml:"Token" yaml:"token" json:"token"`
50-
APIEndpoint string `toml:"APIEndpoint" yaml:"apiEndpoint" json:"apiEndpoint"`
51-
WebEndpoint string `toml:"WebEndpoint" yaml:"webEndpoint" json:"webEndpoint"`
50+
APIEndpoint string `toml:"APIEndpoint" yaml:"apiEndpoint,omitempty" json:"apiEndpoint,omitempty"`
51+
WebEndpoint string `toml:"WebEndpoint" yaml:"webEndpoint,omitempty" json:"webEndpoint,omitempty"`
5252
// how often sync to server
53-
FlushCount int `toml:"FlushCount" yaml:"flushCount" json:"flushCount"`
53+
FlushCount int `toml:"FlushCount,omitempty" yaml:"flushCount,omitempty" json:"flushCount,omitempty"`
5454
// how long the synced data would keep in db:
5555
// unit is days
56-
GCTime int `toml:"GCTime" yaml:"gcTime" json:"gcTime"`
56+
GCTime int `toml:"GCTime,omitempty" yaml:"gcTime,omitempty" json:"gcTime,omitempty"`
5757

5858
// is data should be masking?
5959
// @default true
60-
DataMasking *bool `toml:"dataMasking" yaml:"dataMasking" json:"dataMasking"`
60+
DataMasking *bool `toml:"dataMasking,omitempty" yaml:"dataMasking,omitempty" json:"dataMasking,omitempty"`
6161

6262
// for debug purpose
6363
Endpoints []Endpoint `toml:"ENDPOINTS,omitempty" yaml:"endpoints,omitempty" json:"endpoints,omitempty"`
@@ -66,16 +66,16 @@ type ShellTimeConfig struct {
6666
// This config will track each command metrics you run in current shell.
6767
// Use this config only the developer asked you to do so.
6868
// This could be very slow on each command you run.
69-
EnableMetrics *bool `toml:"enableMetrics" yaml:"enableMetrics" json:"enableMetrics"`
69+
EnableMetrics *bool `toml:"enableMetrics,omitempty" yaml:"enableMetrics,omitempty" json:"enableMetrics,omitempty"`
7070

71-
Encrypted *bool `toml:"encrypted" yaml:"encrypted" json:"encrypted"`
71+
Encrypted *bool `toml:"encrypted,omitempty" yaml:"encrypted,omitempty" json:"encrypted,omitempty"`
7272

7373
// AI configuration
74-
AI *AIConfig `toml:"ai" yaml:"ai" json:"ai"`
74+
AI *AIConfig `toml:"ai,omitempty" yaml:"ai,omitempty" json:"ai,omitempty"`
7575

7676
// Exclude patterns - regular expressions to exclude commands from being saved
7777
// Commands matching any of these patterns will not be synced to the server
78-
Exclude []string `toml:"exclude" yaml:"exclude" json:"exclude"`
78+
Exclude []string `toml:"exclude,omitempty" yaml:"exclude,omitempty" json:"exclude,omitempty"`
7979

8080
// CCUsage configuration for Claude Code usage tracking (v1 - ccusage CLI based)
8181
CCUsage *CCUsage `toml:"ccusage" yaml:"ccusage" json:"ccusage"`

0 commit comments

Comments
 (0)