Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

Unify version management via build-injected ldflags

Martin Vogelfcff5b8dc96c
diff --git a/cmd/codebase-memory-mcp/main.go b/cmd/codebase-memory-mcp/main.go
index cfa581688..899ea5b56 100644
--- a/cmd/codebase-memory-mcp/main.go
+++ b/cmd/codebase-memory-mcp/main.go
@@ -17,6 +17,8 @@ import (
var version = "dev"
func main() {
+ tools.SetVersion(version)
+
if len(os.Args) > 1 {
switch os.Args[1] {
case "--version":
diff --git a/internal/tools/tools.go b/internal/tools/tools.go
index 6fe6c535f..8e1bb4f93 100644
--- a/internal/tools/tools.go
+++ b/internal/tools/tools.go
@@ -24,8 +24,12 @@ import (
"github.com/modelcontextprotocol/go-sdk/mcp"
)
-// Version is the current release version, referenced by MCP handshake and update checker.
-const Version = "0.4.3"
+// Version is the current release version, set from main.version via SetVersion().
+// Defaults to "dev" for local builds.
+var Version = "dev"
+
+// SetVersion sets the package version from the build-injected main.version.
+func SetVersion(v string) { Version = v }
// releaseURL is the GitHub API endpoint for latest release. Package-level var for test injection.
var releaseURL = "https://api.github.com/repos/DeusData/codebase-memory-mcp/releases/latest"
diff --git a/internal/tools/update_test.go b/internal/tools/update_test.go
index 08e279abf..b079ebd11 100644
--- a/internal/tools/update_test.go
+++ b/internal/tools/update_test.go
@@ -37,7 +37,16 @@ func TestCompareVersions(t *testing.T) {
}
}
+func withTestVersion(t *testing.T, v string) {
+ t.Helper()
+ old := Version
+ Version = v
+ t.Cleanup(func() { Version = old })
+}
+
func TestCheckForUpdate_NewerAvailable(t *testing.T) {
+ withTestVersion(t, "1.0.0")
+
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, `{"tag_name": "v99.0.0"}`)
}))
@@ -63,6 +72,8 @@ func TestCheckForUpdate_NewerAvailable(t *testing.T) {
}
func TestCheckForUpdate_AlreadyCurrent(t *testing.T) {
+ withTestVersion(t, "1.0.0")
+
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, `{"tag_name": "v%s"}`, Version)
}))
@@ -82,6 +93,8 @@ func TestCheckForUpdate_AlreadyCurrent(t *testing.T) {
}
func TestCheckForUpdate_OlderAvailable(t *testing.T) {
+ withTestVersion(t, "1.0.0")
+
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, `{"tag_name": "v0.0.1"}`)
}))