feat(cli): add version diagnostics and build-aware start

This commit is contained in:
2026-08-15 23:35:55 +02:00
parent 9a8755e4c3
commit 7ac99b4f7e
11 changed files with 989 additions and 306 deletions
+30
View File
@@ -0,0 +1,30 @@
// Package version exposes host CLI build identity without requiring an installation descriptor.
package version
import "runtime"
var (
semanticVersion = "0.0.0-dev"
commit = "unknown"
buildTime = "unknown"
)
// Info is the stable, machine-readable identity of the host-side CLI.
type Info struct {
Version string `json:"version"`
Commit string `json:"commit"`
BuildTime string `json:"buildTime"`
OS string `json:"os"`
Arch string `json:"arch"`
}
// Current returns linker-overridable build metadata plus the executing host platform.
func Current() Info {
return Info{
Version: semanticVersion,
Commit: commit,
BuildTime: buildTime,
OS: runtime.GOOS,
Arch: runtime.GOARCH,
}
}
+17
View File
@@ -0,0 +1,17 @@
package version
import (
"runtime"
"testing"
)
// Catches a source build that reports no usable identity or the wrong host platform.
func TestCurrentReportsUsableSourceBuildIdentity(t *testing.T) {
info := Current()
if info.Version == "" || info.Commit == "" || info.BuildTime == "" {
t.Fatalf("Current() = %#v, want non-empty build identity", info)
}
if info.OS != runtime.GOOS || info.Arch != runtime.GOARCH {
t.Fatalf("Current() platform = %s/%s, want %s/%s", info.OS, info.Arch, runtime.GOOS, runtime.GOARCH)
}
}