Skip to content

Commit 9800173

Browse files
fix: pass version via CollectConfig instead of hardcoding in orchestrator (#16)
goreleaser sets main.version via ldflags, but the orchestrator had its own hardcoded "0.4.1" that wouldn't be updated. Now version flows: goreleaser → main.version (ldflags) → cfg.Version → orchestrator metadata Added CollectConfig.Version field. Set in: - cmd/melisai/main.go (collect command) - internal/mcp/handlers.go (both get_health and collect_metrics) - internal/mcp/server.go sets mcpVersion package var on startup Co-authored-by: dmitriimaksimovdevelop <227611064+dmitriimaksimovdevelop@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 01461c7 commit 9800173

5 files changed

Lines changed: 13 additions & 1 deletion

File tree

cmd/melisai/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ Examples:
106106
RunE: func(cmd *cobra.Command, args []string) error {
107107
cfg := collector.DefaultConfig()
108108
cfg.Profile = collectProfile
109+
cfg.Version = version
109110
cfg.Quiet = collectQuiet
110111
cfg.Verbose = collectVerbose
111112

internal/collector/collector.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ type CollectConfig struct {
7979
// Verbose enables debug-level logging.
8080
Verbose bool
8181

82+
// Version is the application version (set via ldflags by goreleaser).
83+
Version string
84+
8285
// ProcRoot is the path to procfs mount (default "/proc").
8386
// Can be overridden for testing.
8487
ProcRoot string

internal/mcp/handlers.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ const healthCheckTimeout = 30 * time.Second
2121
// collectMetricsTimeout is the maximum time for a full profile run.
2222
const collectMetricsTimeout = 5 * time.Minute
2323

24+
// mcpVersion is set by the MCP server on startup for use by handlers.
25+
var mcpVersion string
26+
2427
// handleGetHealth runs a quick Tier 1 check and returns health score summary.
2528
func handleGetHealth(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
2629
ctx, cancel := context.WithTimeout(ctx, healthCheckTimeout)
@@ -30,6 +33,7 @@ func handleGetHealth(ctx context.Context, request mcp.CallToolRequest) (*mcp.Cal
3033
// avoiding unnecessary BCC tool discovery overhead.
3134
cfg := collector.DefaultConfig()
3235
cfg.Profile = "quick"
36+
cfg.Version = mcpVersion
3337
cfg.Duration = 1 * time.Second
3438
cfg.Quiet = true
3539

@@ -110,6 +114,7 @@ func handleCollectMetrics(ctx context.Context, request mcp.CallToolRequest) (*mc
110114

111115
cfg := collector.DefaultConfig()
112116
cfg.Profile = profileStr
117+
cfg.Version = mcpVersion
113118
cfg.Quiet = true
114119
cfg.Focus = focusAreas
115120
cfg.TargetPIDs = pids

internal/mcp/server.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ type Server struct {
1515

1616
// NewServer creates a new MCP server with registered tools.
1717
func NewServer(version string) *Server {
18+
// Set package-level version for handlers
19+
mcpVersion = version
20+
1821
// Create MCP server
1922
s := server.NewMCPServer("melisai", version, server.WithLogging())
2023

internal/orchestrator/orchestrator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ func (o *Orchestrator) buildMetadata(profile ProfileConfig) model.Metadata {
309309

310310
meta := model.Metadata{
311311
Tool: "melisai",
312-
Version: "0.4.1",
312+
Version: o.config.Version,
313313
SchemaVersion: "1.1.0",
314314
Hostname: hostname,
315315
Timestamp: time.Now().UTC().Format(time.RFC3339),

0 commit comments

Comments
 (0)