Skip to content

feat(cli): add --version flag - #2

Merged
maxie7 merged 2 commits into
mainfrom
feat/m7-version-flag
Jul 21, 2026
Merged

feat(cli): add --version flag#2
maxie7 merged 2 commits into
mainfrom
feat/m7-version-flag

Conversation

@maxie7

@maxie7 maxie7 commented Jul 21, 2026

Copy link
Copy Markdown
Owner

What

logscry --version previously failed with flag provided but not defined: -version — the binary had no way to report its own version. This adds the flag, plus two documentation riders from the M7 backlog.

How

Version resolution is a small pure helper with a three-step precedence:

  1. an ldflags-injected value (-X main.version=…), set by the Makefile from git describe;
  2. otherwise debug.ReadBuildInfo().Main.Version(devel) treated as absent, vcs.modified-dirty;
  3. otherwise dev.

ldflags alone would not be enough: the primary install path for a Go CLI is go install …@latest, which never runs the Makefile, so those binaries would all report dev. BuildInfo covers that path — verified with go version -m on Go 1.26, where both a clean build at a tagged commit and go install …@latest yield the tag.

The flag is registered on the same flag set as the rest of the configuration, so -h still lists everything in one place, and it short-circuits config.Load immediately after parsing — before the config file is read and before any validation. logscry --version therefore works with a missing or invalid logscry.yaml.

Also

  • README: documents --llm-max-tokens for reasoning models — such a model spends its whole budget on chain-of-thought and returns empty content with finish_reason: length, so the default of 300 is too low.
  • README: documents --version.
  • BACKLOG: both items ticked under Epic M7.

Verification

  • gofmt, go vet, golangci-lint run (0 issues), go test ./..., go test -race ./..., go build ./... — all green.
  • Table-driven unit tests for the resolution helper: ldflags set / BuildInfo / (devel) / dirty tree.
  • Manual: go runlogscry dev; make build → the git describe string; --version --config /nonexistent.yaml → prints and exits 0; -h lists -version.

No changes to the pipeline, scoring, grouping, LLM backend, or TUI.

maxie7 and others added 2 commits July 21, 2026 20:06
The binary could not report its own version: `logscry --version` failed with
"flag provided but not defined: -version".

Resolve the version hybrid, in order: an `-X main.version` ldflags stamp
(injected by `make build` from `git describe --tags --always --dirty`) wins;
else the module version from `debug.ReadBuildInfo()`, ignoring the "(devel)"
placeholder; else "dev". ldflags alone is not enough — the primary install path
`go install .../logscry@latest` never runs the Makefile and would report "dev";
BuildInfo makes that path report the real tag.

The flag is checked in config.Load right after flag parsing and short-circuits
before the file is read or validated, so `logscry --version` prints and exits 0
even with a missing or invalid config. It is registered on the same flag set as
`--config`, so `-h` lists it alongside every other flag.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Reasoning/thinking models (qwen3, deepseek-r1) can spend the whole default
300-token budget on chain-of-thought and return empty content with
`finish_reason: length`; note the symptom and the fix in the Configuration
section, and that non-reasoning models like gemma2:2b are fine at the default.
Add --version to the flags table. Tick both M7 backlog items and record the
--version item and its hybrid-resolution rationale.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@maxie7 maxie7 self-assigned this Jul 21, 2026
@maxie7
maxie7 merged commit 2115f64 into main Jul 21, 2026
1 check passed
@maxie7
maxie7 deleted the feat/m7-version-flag branch July 21, 2026 18:20
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