Version Mutation
Setup: See /installation for one-time SDK/CLI/MCP install.
Layers: SDK (Go) → CLI (shell) → MCP (AI tools) — pick your entry point.
When to Use
- Bumping a version number (major, minor, or patch) for a release
- Changing a specific component: prefix, suffix, major, minor, patch, or all numbers
- Stripping a suffix to get the core version
- Constructing a version from individual parts (prefix, numbers, suffix)
Decision Tree
Need to increment a version for release?
→ Use BumpMajor / BumpMinor / BumpPatch (clears suffix)
Need to change one field while keeping the rest?
→ Use With* methods (immutable, preserves suffix)
Need to strip the suffix?
→ Use Core()
Need to build from scratch?
→ Use VersionBuilder or version_build
Task Patterns
Bump a version for release
Goal: Increment the version number and clear the prerelease suffix.
| Layer |
Approach |
| SDK |
v := versions.NewVersion("1.2.3-beta1"); next := v.BumpPatch() |
| CLI |
versions bump 1.2.3-beta1 --patch |
| MCP |
{"tool": "version_bump", "arguments": {"version_string": "1.2.3-beta1", "bump_type": "patch"}} |
Change one component immutably
Goal: Modify a single field (prefix, suffix, major, minor, patch) without affecting others.
| Layer |
Approach |
| SDK |
v.WithPrefix("v"), v.WithMajor(2), v.WithSuffix("-beta1") |
| CLI |
versions set-prefix 1.2.3 v, versions set-major 1.2.3 2, versions set-suffix 1.2.3 -- -beta1 |
| MCP |
{"tool": "version_build", "arguments": {"prefix": "v", "major": 2, "minor": 0, "patch": 0}} |
Strip suffix to get core version
Goal: Remove the prerelease suffix, keeping prefix and numbers.
| Layer |
Approach |
| SDK |
v.Core() → "v1.2.3" from "v1.2.3-beta1" |
| CLI |
versions core v1.2.3-beta1 |
| MCP |
{"tool": "version_core", "arguments": {"version_string": "v1.2.3-beta1"}} |
Build a version from parts
Goal: Construct a version string from individual components.
| Layer |
Approach |
| SDK |
versions.NewVersionBuilder().Prefix("v").Major(1).Minor(2).Patch(3).Suffix("-alpha1").Build() |
| CLI |
versions build --prefix v --major 1 --minor 2 --patch 3 --suffix -alpha1 |
| MCP |
{"tool": "version_build", "arguments": {"prefix": "v", "major": 1, "minor": 2, "patch": 3, "suffix": "-alpha1"}} |
Replace all version numbers
Goal: Change all numeric segments while keeping prefix and suffix.
| Layer |
Approach |
| SDK |
v.WithNumbers([]int{4, 5, 6}) → "v4.5.6-beta1" |
| CLI |
versions set-numbers v1.2.3 4,5,6 |
| MCP |
{"tool": "version_build", "arguments": {"prefix": "v", "numbers": [4, 5, 6], "suffix": "-beta1"}} |
API Reference
SDK — Bump Operations
All bump methods clear the suffix and return a new Version:
v.BumpMajor() *Version // 1.2.3 → 2.0.0
v.BumpMinor() *Version // 1.2.3 → 1.3.0
v.BumpPatch() *Version // 1.2.3 → 1.2.4
SDK — Immutable Modification (With* methods)
All With* methods return a new Version — the original is never modified:
v.WithPrefix(prefix string) *Version // change prefix (e.g. "" → "v")
v.WithSuffix(suffix string) *Version // change suffix (e.g. "" → "-beta1")
v.WithMajor(major int) *Version // change Major number
v.WithMinor(minor int) *Version // change Minor number
v.WithPatch(patch int) *Version // change Patch number
v.WithNumbers(numbers []int) *Version // replace all version numbers
v.WithPublicTime(t time.Time) *Version // set release time
v.WithMetadata(m string) *Version // set build metadata
SDK — Core
v.Core() *Version // strip suffix, e.g. "v1.2.3-beta1" → "v1.2.3"
SDK — VersionBuilder
builder := versions.NewVersionBuilder()
builder.Prefix("v")
builder.Major(1)
builder.Minor(2)
builder.Patch(3)
builder.Suffix("-beta1")
builder.Numbers([]int{1, 2, 3, 4}) // overrides Major/Minor/Patch
v := builder.Build()
CLI Commands
# Bump
versions bump <v> --major # 2.0.0
versions bump <v> --minor # 1.3.0
versions bump <v> --patch # 1.2.4
# Core (strip suffix)
versions core <v> # strip suffix
# Set (immutable modification)
versions set-prefix <v> <prefix> # change prefix
versions set-suffix <v> -- <suffix> # change suffix (-- required for -prefix)
versions set-major <v> <n> # change Major
versions set-minor <v> <n> # change Minor
versions set-patch <v> <n> # change Patch
versions set-numbers <v> <n,n,...> # replace all numbers
# Build
versions build --prefix v --major 1 --minor 2 --patch 3
versions build --numbers 1,2,3,4
versions build --prefix v --major 1 --suffix -alpha1
MCP Tools
| Tool |
Arguments |
Returns |
version_bump |
version_string, bump_type (major/minor/patch) |
bumped version string |
version_core |
version_string |
core version string |
version_build |
prefix?, major?, minor?, patch?, suffix?, numbers? |
constructed version string |
Cross-References
- [[version-check]] — check if a version is stable/prerelease before bumping
- [[version-properties]] — inspect version components before mutation
- [[version-parsing]] — parse version strings before mutating
Important Notes
- All
With* and Bump* methods are immutable — they return a new Version; the original is unchanged.
Bump* clears the suffix: 1.2.3-beta1.BumpPatch() returns 1.2.4, not 1.2.4-beta1.
With* preserves the suffix unless you explicitly change it with WithSuffix.
- CLI
set-suffix needs --: suffixes starting with - require -- separator: versions set-suffix 1.2.3 -- -beta1.
WithNumbers replaces ALL numbers, overriding Major/Minor/Patch in the builder.
VersionBuilder.Numbers() overrides Major/Minor/Patch — use it for arbitrary-segment versions like 1.2.3.4.5.
1---2name: version-mutation3description: Bump version numbers, modify version components, strip suffixes, or construct versions from parts.4---56# Version Mutation78> **Setup:** See `/installation` for one-time SDK/CLI/MCP install. 9> **Layers:** SDK (Go) → CLI (shell) → MCP (AI tools) — pick your entry point.1011## When to Use1213- Bumping a version number (major, minor, or patch) for a release14- Changing a specific component: prefix, suffix, major, minor, patch, or all numbers15- Stripping a suffix to get the core version16- Constructing a version from individual parts (prefix, numbers, suffix)1718## Decision Tree1920```21Need to increment a version for release?22 → Use BumpMajor / BumpMinor / BumpPatch (clears suffix)23Need to change one field while keeping the rest?24 → Use With* methods (immutable, preserves suffix)25Need to strip the suffix?26 → Use Core()27Need to build from scratch?28 → Use VersionBuilder or version_build29```3031## Task Patterns3233### Bump a version for release3435**Goal:** Increment the version number and clear the prerelease suffix.3637| Layer | Approach |38|-------|----------|39| SDK | `v := versions.NewVersion("1.2.3-beta1"); next := v.BumpPatch()` |40| CLI | `versions bump 1.2.3-beta1 --patch` |41| MCP | `{"tool": "version_bump", "arguments": {"version_string": "1.2.3-beta1", "bump_type": "patch"}}` |4243### Change one component immutably4445**Goal:** Modify a single field (prefix, suffix, major, minor, patch) without affecting others.4647| Layer | Approach |48|-------|----------|49| SDK | `v.WithPrefix("v")`, `v.WithMajor(2)`, `v.WithSuffix("-beta1")` |50| CLI | `versions set-prefix 1.2.3 v`, `versions set-major 1.2.3 2`, `versions set-suffix 1.2.3 -- -beta1` |51| MCP | `{"tool": "version_build", "arguments": {"prefix": "v", "major": 2, "minor": 0, "patch": 0}}` |5253### Strip suffix to get core version5455**Goal:** Remove the prerelease suffix, keeping prefix and numbers.5657| Layer | Approach |58|-------|----------|59| SDK | `v.Core()` → `"v1.2.3"` from `"v1.2.3-beta1"` |60| CLI | `versions core v1.2.3-beta1` |61| MCP | `{"tool": "version_core", "arguments": {"version_string": "v1.2.3-beta1"}}` |6263### Build a version from parts6465**Goal:** Construct a version string from individual components.6667| Layer | Approach |68|-------|----------|69| SDK | `versions.NewVersionBuilder().Prefix("v").Major(1).Minor(2).Patch(3).Suffix("-alpha1").Build()` |70| CLI | `versions build --prefix v --major 1 --minor 2 --patch 3 --suffix -alpha1` |71| MCP | `{"tool": "version_build", "arguments": {"prefix": "v", "major": 1, "minor": 2, "patch": 3, "suffix": "-alpha1"}}` |7273### Replace all version numbers7475**Goal:** Change all numeric segments while keeping prefix and suffix.7677| Layer | Approach |78|-------|----------|79| SDK | `v.WithNumbers([]int{4, 5, 6})` → `"v4.5.6-beta1"` |80| CLI | `versions set-numbers v1.2.3 4,5,6` |81| MCP | `{"tool": "version_build", "arguments": {"prefix": "v", "numbers": [4, 5, 6], "suffix": "-beta1"}}` |8283## API Reference8485### SDK — Bump Operations8687All bump methods clear the suffix and return a new Version:8889```go90v.BumpMajor() *Version // 1.2.3 → 2.0.091v.BumpMinor() *Version // 1.2.3 → 1.3.092v.BumpPatch() *Version // 1.2.3 → 1.2.493```9495### SDK — Immutable Modification (With* methods)9697All `With*` methods return a **new** Version — the original is never modified:9899```go100v.WithPrefix(prefix string) *Version // change prefix (e.g. "" → "v")101v.WithSuffix(suffix string) *Version // change suffix (e.g. "" → "-beta1")102v.WithMajor(major int) *Version // change Major number103v.WithMinor(minor int) *Version // change Minor number104v.WithPatch(patch int) *Version // change Patch number105v.WithNumbers(numbers []int) *Version // replace all version numbers106v.WithPublicTime(t time.Time) *Version // set release time107v.WithMetadata(m string) *Version // set build metadata108```109110### SDK — Core111112```go113v.Core() *Version // strip suffix, e.g. "v1.2.3-beta1" → "v1.2.3"114```115116### SDK — VersionBuilder117118```go119builder := versions.NewVersionBuilder()120builder.Prefix("v")121builder.Major(1)122builder.Minor(2)123builder.Patch(3)124builder.Suffix("-beta1")125builder.Numbers([]int{1, 2, 3, 4}) // overrides Major/Minor/Patch126v := builder.Build()127```128129### CLI Commands130131```bash132# Bump133versions bump <v> --major # 2.0.0134versions bump <v> --minor # 1.3.0135versions bump <v> --patch # 1.2.4136137# Core (strip suffix)138versions core <v> # strip suffix139140# Set (immutable modification)141versions set-prefix <v> <prefix> # change prefix142versions set-suffix <v> -- <suffix> # change suffix (-- required for -prefix)143versions set-major <v> <n> # change Major144versions set-minor <v> <n> # change Minor145versions set-patch <v> <n> # change Patch146versions set-numbers <v> <n,n,...> # replace all numbers147148# Build149versions build --prefix v --major 1 --minor 2 --patch 3150versions build --numbers 1,2,3,4151versions build --prefix v --major 1 --suffix -alpha1152```153154### MCP Tools155156| Tool | Arguments | Returns |157|------|-----------|---------|158| `version_bump` | `version_string`, `bump_type` (major/minor/patch) | bumped version string |159| `version_core` | `version_string` | core version string |160| `version_build` | `prefix?`, `major?`, `minor?`, `patch?`, `suffix?`, `numbers?` | constructed version string |161162## Cross-References163164- [[version-check]] — check if a version is stable/prerelease before bumping165- [[version-properties]] — inspect version components before mutation166- [[version-parsing]] — parse version strings before mutating167168## Important Notes169170- **All `With*` and `Bump*` methods are immutable** — they return a new Version; the original is unchanged.171- **`Bump*` clears the suffix**: `1.2.3-beta1.BumpPatch()` returns `1.2.4`, not `1.2.4-beta1`.172- **`With*` preserves the suffix** unless you explicitly change it with `WithSuffix`.173- **CLI `set-suffix` needs `--`**: suffixes starting with `-` require `--` separator: `versions set-suffix 1.2.3 -- -beta1`.174- **`WithNumbers` replaces ALL numbers**, overriding Major/Minor/Patch in the builder.175- **`VersionBuilder.Numbers()` overrides Major/Minor/Patch** — use it for arbitrary-segment versions like `1.2.3.4.5`.