Skip to content

feat(daemon): add version command with config debug info#165

Merged
AnnatarHe merged 3 commits intomainfrom
feat/daemon-version-command
Dec 25, 2025
Merged

feat(daemon): add version command with config debug info#165
AnnatarHe merged 3 commits intomainfrom
feat/daemon-version-command

Conversation

@AnnatarHe
Copy link
Copy Markdown
Contributor

Summary

  • Add -v/--version flags to shelltime-daemon binary
  • Display version, commit, build date, Go version, and OS/Arch
  • Show current config state (CCOtel, CCUsage, LogCleanup, CodeTracking) without starting services
  • Add debug log when writing CCOtel debug files

This helps diagnose configuration issues by quickly showing what config values the daemon would use.

Test plan

  • Run shelltime-daemon -v and verify output shows version and config
  • Run shelltime-daemon --version and verify same output
  • Verify build succeeds with go build ./cmd/daemon/main.go

🤖 Generated with Claude Code

AnnatarHe and others added 2 commits December 25, 2025 23:23
…able

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add -v/--version flags to shelltime-daemon that display version info
and current config state without starting any services. This helps
diagnose configuration issues by showing:
- Version, commit, build date
- Go version and OS/Arch
- Socket path and API endpoint
- CCOtel, CCUsage, LogCleanup, CodeTracking config states

Also add debug log when writing CCOtel debug files.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @AnnatarHe, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the shelltime-daemon by adding a new version command (-v/--version) that provides not only standard build details but also a snapshot of the daemon's effective configuration. This feature is designed to significantly improve the diagnostic capabilities for users and developers, allowing them to quickly understand the daemon's setup and troubleshoot configuration-related problems without needing to fully start the application.

Highlights

  • New Version Command: Introduced -v and --version command-line flags for the shelltime-daemon binary.
  • Detailed Version Info: The version command now displays comprehensive build information including version, commit hash, build date, Go version, and OS/architecture.
  • Configuration Debug Info: The version command also outputs the current configuration state for CCOtel, CCUsage, LogCleanup, and CodeTracking without initializing the daemon's services, aiding in quick diagnosis of config issues.
  • CCOtel Debug Logging: Added a debug log message in the CCOtel processor to indicate when debug data is successfully written to a file, including the file path.
  • CCOtel Debug Config Handling: Ensured that the CCOtel.Debug configuration option is explicitly set to true if enabled in the config file during the ReadConfigFile process.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 25, 2025

Codecov Report

❌ Patch coverage is 1.49254% with 66 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
daemon/socket.go 0.00% 25 Missing ⚠️
commands/daemon.status.go 0.00% 20 Missing ⚠️
cmd/daemon/main.go 0.00% 14 Missing ⚠️
daemon/base.go 20.00% 4 Missing ⚠️
model/config.go 0.00% 1 Missing and 1 partial ⚠️
daemon/ccotel_processor.go 0.00% 1 Missing ⚠️
Flag Coverage Δ
unittests 20.05% <1.49%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
daemon/ccotel_processor.go 0.00% <0.00%> (ø)
model/config.go 60.57% <0.00%> (-1.19%) ⬇️
daemon/base.go 50.00% <20.00%> (-50.00%) ⬇️
cmd/daemon/main.go 0.00% <0.00%> (ø)
commands/daemon.status.go 0.00% <0.00%> (ø)
daemon/socket.go 0.00% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a useful -v/--version flag to the shelltime-daemon for displaying version and configuration information, which is great for debugging. The implementation is straightforward. I've made a couple of suggestions: one to improve platform compatibility by adhering to repository guidelines for path construction, and another to refactor some repetitive code to enhance maintainability. Overall, a good addition.

Comment thread cmd/daemon/main.go Outdated
Comment on lines +179 to +185
configFile := os.ExpandEnv(fmt.Sprintf("%s/%s/%s", "$HOME", model.COMMAND_BASE_STORAGE_FOLDER, "config.toml"))
configService := model.NewConfigService(configFile)
cfg, err := configService.ReadConfigFile(ctx)
if err != nil {
fmt.Printf("\nConfig: error reading config: %v\n", err)
return
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

For platform-independent paths, it's better to use os.UserHomeDir() and filepath.Join as per the repository's general rules. This avoids hardcoding path separators and reliance on environment variables like $HOME, making the code more robust across different operating systems. Note that this change requires importing the path/filepath package.

Suggested change
configFile := os.ExpandEnv(fmt.Sprintf("%s/%s/%s", "$HOME", model.COMMAND_BASE_STORAGE_FOLDER, "config.toml"))
configService := model.NewConfigService(configFile)
cfg, err := configService.ReadConfigFile(ctx)
if err != nil {
fmt.Printf("\nConfig: error reading config: %v\n", err)
return
}
homeDir, err := os.UserHomeDir()
if err != nil {
fmt.Printf("\nConfig: error getting user home directory: %v\n", err)
return
}
configFile := filepath.Join(homeDir, model.COMMAND_BASE_STORAGE_FOLDER, "config.toml")
configService := model.NewConfigService(configFile)
cfg, err := configService.ReadConfigFile(ctx)
if err != nil {
fmt.Printf("\nConfig: error reading config: %v\n", err)
return
}
References
  1. For platform-independent paths, use filepath.Join to combine segments and os.UserHomeDir() to get the home directory, rather than hardcoding path separators or environment variables like $HOME.

Comment thread cmd/daemon/main.go Outdated
Comment on lines +191 to +238
// CCOtel config
if cfg.CCOtel != nil {
fmt.Println("\nCCOtel:")
if cfg.CCOtel.Enabled != nil {
fmt.Printf(" Enabled: %v\n", *cfg.CCOtel.Enabled)
} else {
fmt.Printf(" Enabled: <nil>\n")
}
fmt.Printf(" gRPC Port: %d\n", cfg.CCOtel.GRPCPort)
if cfg.CCOtel.Debug != nil {
fmt.Printf(" Debug: %v\n", *cfg.CCOtel.Debug)
} else {
fmt.Printf(" Debug: <nil>\n")
}
} else {
fmt.Println("\nCCOtel: <not configured>")
}

// CCUsage config
if cfg.CCUsage != nil {
fmt.Println("\nCCUsage:")
if cfg.CCUsage.Enabled != nil {
fmt.Printf(" Enabled: %v\n", *cfg.CCUsage.Enabled)
} else {
fmt.Printf(" Enabled: <nil>\n")
}
}

// LogCleanup config
if cfg.LogCleanup != nil {
fmt.Println("\nLogCleanup:")
if cfg.LogCleanup.Enabled != nil {
fmt.Printf(" Enabled: %v\n", *cfg.LogCleanup.Enabled)
} else {
fmt.Printf(" Enabled: <nil>\n")
}
fmt.Printf(" ThresholdMB: %d\n", cfg.LogCleanup.ThresholdMB)
}

// CodeTracking config
if cfg.CodeTracking != nil {
fmt.Println("\nCodeTracking:")
if cfg.CodeTracking.Enabled != nil {
fmt.Printf(" Enabled: %v\n", *cfg.CodeTracking.Enabled)
} else {
fmt.Printf(" Enabled: <nil>\n")
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The logic for printing each configuration section is very similar across CCOtel, CCUsage, LogCleanup, and CodeTracking. To improve maintainability and reduce code duplication, consider abstracting this logic into a helper function. For instance, a helper could accept a section name and a pointer to its Enabled field, and handle the nil check and formatted printing. This would make the printVersionInfo function more concise and easier to modify in the future.

Enhance `shelltime daemon status` command to query the running daemon
via socket for real-time status including:
- Version and build info
- Uptime (tracked from daemon start)
- Go version and platform

The daemon now tracks its start time in daemon.Init() and responds to
status requests via the Unix socket, providing accurate runtime info.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@AnnatarHe AnnatarHe merged commit a31d021 into main Dec 25, 2025
2 of 3 checks passed
@AnnatarHe AnnatarHe deleted the feat/daemon-version-command branch December 25, 2025 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant