Skip to content

feature/refactor-versions#88

Merged
yuval-qf merged 13 commits intoqualifire-dev:mainfrom
puwun:feature/refactor-versions
Oct 20, 2025
Merged

feature/refactor-versions#88
yuval-qf merged 13 commits intoqualifire-dev:mainfrom
puwun:feature/refactor-versions

Conversation

@puwun
Copy link
Contributor

@puwun puwun commented Oct 16, 2025

Description

This PR introduces a centralized VERSION file to serve as the single source of truth for version management across the Rogue project. All components now read the version from this file, removing the need to manually update version numbers in multiple places.

Motivation and Context

Previously, version numbers were hardcoded in three different files:

  • packages/tui/internal/tui/app.go
  • rogue/__init__.py
  • pyproject.toml

This led to unnecessary maintenance overhead and inconsistencies.

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🔧 Configuration/build changes

Changes Made

  • Added VERSION file as single source of truth containing version 0.1.12
  • Updated rogue/__init__.py to read version from VERSION file at runtime with fallback to package metadata
  • Updated packages/tui/internal/tui/version.go to use build-time variable injection instead of hardcoded value
  • Updated packages/tui/Makefile to read VERSION file and inject version via ldflags
  • Updated packages/tui/cmd/rogue/main.go to add version command and --version flag
  • Updated pyproject.toml to use hatch version plugin with VERSION file
  • Removed hardcoded version strings from multiple locations

Screenshots/Examples

image image

Checklist

  • I have read the CONTRIBUTING.md guide
  • My code follows the code style of this project (PEP 8, type hints, docstrings)
  • I have run uv run black . to format my code
  • I have run uv run flake8 . and fixed all issues
  • I have run uv run mypy --config-file .mypy.ini . and addressed type checking issues
  • I have run uv run bandit -c .bandit.yaml -r . for security checks
  • I have added tests that prove my fix is effective or that my feature works
  • I have run uv run pytest and all tests pass
  • I have manually tested my changes
  • I have updated the documentation accordingly
  • I have added/updated type hints for new/modified functions
  • My changes generate no new warnings
  • I have checked my code for security issues
  • Any dependent changes have been merged and published

Related Issues/PRs

Test Steps:

# Python package version
$ uv run python -c "import rogue; print(rogue.__version__)"
0.1.12

# TUI version command
$ cd packages/tui && make build && ./dist/rogue-tui version
rogue-tui v0.1.12

# TUI version flag
$ ./dist/rogue-tui --version
rogue-tui v0.1.12

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 16, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added -v/--version flag to rogue-tui CLI for quick version lookup.
    • Added version subcommand to rogue-tui CLI.
  • Chores

    • Centralized version management across all packages via a single VERSION file for consistent versioning.

Walkthrough

Adds a single-source-of-truth VERSION file and wires it into Go builds and runtime and Python packaging/runtime; introduces a package-exported tui.Version, CLI -v/--version flag and version subcommand, and utilities to read dynamic versions in Python.

Changes

Cohort / File(s) Summary
Root version file
\VERSION``
New file containing the project version string 0.1.12.
Go: build & version variable
\packages/tui/Makefile`, `packages/tui/internal/tui/version.go``
Makefile reads ../../VERSION (fallback dev) and sets ldflags to populate github.com/rogue/tui/internal/tui.Version; new exported Version variable initialized to "vdev" for build-time override.
Go: CLI & app wiring
\packages/tui/cmd/rogue/main.go`, `packages/tui/internal/tui/app.go``
Adds root -v/--version flag, version subcommand, PreRun early-exit to print tui.Version; App.Run uses tui.Version instead of a hardcoded string.
Python: packaging config
\pyproject.toml`, `sdks/python/pyproject.toml``
Switches to dynamic versioning sourced from VERSION via Hatch config; updates wheel sources and adds a few dependencies.
Python: runtime version resolution
\rogue/init.py`, `rogue/common/version.py`, `sdks/python/rogue_sdk/init.py``
Adds get_version(package_name) to read VERSION (walk-up) or fallback to package metadata; replaces hardcoded __version__ values with dynamic resolution and safe fallbacks.

Sequence Diagram(s)

sequenceDiagram
    participant User as Developer / CLI user
    participant CLI as rogue-tui (root cmd)
    participant TUIpkg as tui package (tui.Version)
    User->>CLI: run 'rogue-tui --version' or 'rogue-tui version'
    CLI->>TUIpkg: read tui.Version
    TUIpkg-->>CLI: return Version (ldflags value or default)
    CLI-->>User: print Version and exit
Loading
sequenceDiagram
    participant Make as Makefile / Build
    participant VERSION as VERSION file
    participant Binary as Built binary
    Make->>VERSION: read ../../VERSION (or fallback to dev)
    Make->>Binary: set ldflags github.com/rogue/tui/internal/tui.Version=vX.Y.Z
    Binary->>Binary: runtime uses tui.Version for CLI and app
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 I found one VERSION, neat and small,
No scattered numbers bouncing down the hall.
Built with ldflags, my badge on show,
From Go to Python the versions flow.
Hop, print, release — one file to call. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title Check ❓ Inconclusive The PR title "feature/refactor-versions" is related to the changeset as it references version management, which is the focus of the changes. However, the title is vague and generic, reading more like a branch naming convention than a descriptive PR title. It does not clearly communicate the primary change: that a centralized VERSION file has been added as a single source of truth for version management across the project. A reader scanning commit history would not immediately understand what specific improvement was made.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues Check ✅ Passed The PR fully addresses the requirements from issue #83. All specified objectives are met: (1) a centralized VERSION file has been established as the single source of truth containing 0.1.12 [VERSION], (2) hardcoded version strings have been removed from packages/tui/internal/tui/app.go, rogue/init.py, and pyproject.toml [VERSION, rogue/init.py, packages/tui/internal/tui/version.go, packages/tui/Makefile, pyproject.toml], (3) all components now read from the centralized source including the TUI (via Makefile ldflags injection), Python package (via get_version function and importlib.metadata), and Python SDK (via build-time embedding) [packages/tui/cmd/rogue/main.go, sdks/python/pyproject.toml, rogue/common/version.py, sdks/python/rogue_sdk/init.py]. The changes eliminate coupling and inconsistencies by establishing a single source of truth.
Out of Scope Changes Check ✅ Passed All changes in the PR are directly related to the version refactoring objective defined in issue #83. The modifications to the VERSION file, all configuration files (Makefile, pyproject.toml files), build files, and source files align with centralizing version management. The addition of [tool.hatch.build.targets.wheel.sources] and [tool.uv.sources] in the root pyproject.toml are supporting infrastructure changes necessary for the version management refactoring to function correctly across the monorepo, as documented in the PR objectives. No extraneous changes unrelated to the version consolidation objective are present.
Description Check ✅ Passed The PR description is well-structured and comprehensive, including all major required sections from the template. It provides a clear description of the changes, explains the motivation and context for the refactoring (version numbers previously hardcoded in three locations), specifies the type of change (New Feature and Configuration/build changes), details all major modifications, includes screenshots/examples of the version output, provides test steps with expected results, and includes a thorough checklist with all items marked complete. The description effectively communicates what was changed and why, addressing the centralized version management objective.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b5a2c85 and 545da85.

📒 Files selected for processing (1)
  • sdks/python/rogue_sdk/__init__.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Format Python code with Black
Ensure code passes flake8 linting
Run mypy with the repository configuration for static typing
Run Bandit security checks using .bandit.yaml configuration
Use isort import conventions for import ordering
Add type hints to all function signatures
Follow PEP 8 naming (snake_case for variables/functions, PascalCase for classes)
Use try/except around code that may raise exceptions

Files:

  • sdks/python/rogue_sdk/__init__.py
🔇 Additional comments (1)
sdks/python/rogue_sdk/__init__.py (1)

56-63: Previous review comment successfully addressed.

The implementation correctly addresses the previous review feedback:

  • Type hint __version__: str added
  • Specific PackageNotFoundError exception caught instead of broad Exception
  • Import of both PackageNotFoundError and version from importlib.metadata

The fallback to "0.0.0-dev" is appropriate for development environments where the package isn't installed. This approach aligns with the PR's objective of dynamic version resolution from package metadata.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (4)
packages/tui/Makefile (1)

14-14: Remove hardcoded "v" prefix to avoid cross-tool inconsistency.

Current ldflags result in v0.1.12, while Python exposes 0.1.12. Prefer injecting the raw version and let UIs decide how to display it.

Apply this diff:

-LDFLAGS=-ldflags "-X github.com/rogue/tui/internal/tui.Version=v$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE)"
+LDFLAGS=-ldflags "-X github.com/rogue/tui/internal/tui.Version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE)"

Also ensure main.commit and main.date are still defined in package main, otherwise the build will fail when using -X.

pyproject.toml (1)

48-51: Hatch version sourcing looks correct. Consider including VERSION in artifacts.

Build-time extraction from VERSION is fine. For transparency/debugging, consider including VERSION in the sdist/wheel so tools/users can inspect it after install.

Would you like me to propose hatchling config to force-include VERSION in both sdist and wheel?

packages/tui/internal/tui/version.go (1)

3-5: Align default with raw semver (drop "v" prefix).

Defaulting to "vdev" conflicts with Python’s "0.0.0-dev" style and raw VERSION content. Prefer "dev" here to keep a single convention.

-// Default to "dev" if not set during build
-var Version = "vdev"
+// Default to "dev" if not set during build
+var Version = "dev"
packages/tui/cmd/rogue/main.go (1)

30-55: Version handling works; consider simplifying via Cobra’s built-in Version.

Optional: set rootCmd.Version = tui.Version and drop the custom PreRun and version subcommand, or keep the subcommand and remove PreRun to avoid duplication.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cb07f95 and 3e4abb6.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • VERSION (1 hunks)
  • packages/tui/Makefile (1 hunks)
  • packages/tui/cmd/rogue/main.go (1 hunks)
  • packages/tui/internal/tui/app.go (1 hunks)
  • packages/tui/internal/tui/version.go (1 hunks)
  • pyproject.toml (3 hunks)
  • rogue/__init__.py (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
pyproject.toml

📄 CodeRabbit inference engine (AGENTS.md)

Manage dependencies with uv and declare them in pyproject.toml

Files:

  • pyproject.toml
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Format Python code with Black
Ensure code passes flake8 linting
Run mypy with the repository configuration for static typing
Run Bandit security checks using .bandit.yaml configuration
Use isort import conventions for import ordering
Add type hints to all function signatures
Follow PEP 8 naming (snake_case for variables/functions, PascalCase for classes)
Use try/except around code that may raise exceptions

Files:

  • rogue/__init__.py
🧬 Code graph analysis (2)
packages/tui/internal/tui/app.go (1)
packages/tui/internal/tui/version.go (1)
  • Version (5-5)
packages/tui/cmd/rogue/main.go (2)
packages/tui/internal/commands/commands.go (2)
  • RunTUI (11-16)
  • NewTUICommand (19-27)
packages/tui/internal/tui/version.go (1)
  • Version (5-5)
🔇 Additional comments (1)
packages/tui/internal/tui/app.go (1)

278-279: Good switch to centralized Version.

Initializing from the package-level Version variable aligns the UI with build-time injected version.

Please confirm the intended "v" prefix convention matches the CLI and Python outputs.

Copy link
Collaborator

@yuval-qf yuval-qf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this great contribution! This will without a doubt help us manage the versions more efficiently!

A few notes before approving:

  1. In go, indentation is usually done in tabs instead of spaces. I've noticed that you used spaces. Please convert back to tabs.

From the go.dev docs:

Indentation
We use tabs for indentation and gofmt emits them by default. Use spaces only if you must.

  1. Please look at the two notes from coderabbit. His notes are valid
  2. If you can, please use the same versioning logic in the rogue_sdk, located in sdks/python/pyproject.toml
  3. Please fix the conflicts :)

@puwun
Copy link
Contributor Author

puwun commented Oct 17, 2025

heyy @yuval-qf, I noticed sdks/python/pyproject.toml has a hardcoded version of 0.1.4, while the main project is at 0.1.12
my plan is to align the sdk with the main version logic by making its version dynamic and pointing it to the root VERSION file,
this would change the SDK's version to 0.1.12 as well

does this sound correct to you? just wanted to double-check before I push the changes.

@yuval-qf
Copy link
Collaborator

heyy @yuval-qf, I noticed sdks/python/pyproject.toml has a hardcoded version of 0.1.4, while the main project is at 0.1.12
my plan is to align the sdk with the main version logic by making its version dynamic and pointing it to the root VERSION file,
this would change the SDK's version to 0.1.12 as well

does this sound correct to you? just wanted to double-check before I push the changes.

Hey @puwun ,
Thanks for raising this concern!
This seems great to me, managing a single global version across all components of this repo sounds like a much easier task to handle.
Feel free to update the sdk version :)

Thanks!

@puwun
Copy link
Contributor Author

puwun commented Oct 19, 2025

the python sdk now uses the same versioning logic and pulls from the root VERSION file


image

Copy link
Collaborator

@yuval-qf yuval-qf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @puwun for this PR, left a few minor comments

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is being reviewed by Cursor Bugbot

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
} No newline at end of file
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Go Code Formatting Violation

The Go code in main.go now uses spaces for indentation instead of tabs throughout the file. This goes against Go's standard formatting conventions and was also noted in PR review feedback.

Fix in Cursor Fix in Web

@puwun
Copy link
Contributor Author

puwun commented Oct 19, 2025

@yuval-qf , i have centralized versioning so both rogue-ai and rogue-ai-sdk use the single root VERSION file

So, the key challenge was that the rogue-ai-sdk is a standalone package and can't access the project's file structure after a user installs it. To solve this, I now have embedded the version number into the sdk's package metadata during the build process itself.
The sdk then reads this metadata at runtime to get its version

To improve the local development workflow, I've also updated the root pyproject.toml :

[tool.uv.sources]
rogue-ai-sdk = { path = "sdks/python", editable = true }

This tells our tools to use the local sdk code instead of downloading it from a repository, this gives us a true monorepo workflow where changes to the sdk are instantly available to the main application, which speeds up development and testing 🚀🚀

I also took care of the Go code formatting issue in main.go and addressed the bandit security warning

Pls take a look and suggest if any changes needed

@yuval-qf
Copy link
Collaborator

@yuval-qf , i have centralized versioning so both rogue-ai and rogue-ai-sdk use the single root VERSION file

So, the key challenge was that the rogue-ai-sdk is a standalone package and can't access the project's file structure after a user installs it. To solve this, I now have embedded the version number into the sdk's package metadata during the build process itself. The sdk then reads this metadata at runtime to get its version

To improve the local development workflow, I've also updated the root pyproject.toml :

[tool.uv.sources]
rogue-ai-sdk = { path = "sdks/python", editable = true }

This tells our tools to use the local sdk code instead of downloading it from a repository, this gives us a true monorepo workflow where changes to the sdk are instantly available to the main application, which speeds up development and testing 🚀🚀

I also took care of the Go code formatting issue in main.go and addressed the bandit security warning

Pls take a look and suggest if any changes needed

Thanks @puwun, this solution seems great!

It seems that the pr/codestyle GitHub action had failed due to some formatting issues. Could you please address them?

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7c8ca92 and 558a821.

📒 Files selected for processing (2)
  • rogue/common/version.py (1 hunks)
  • sdks/python/rogue_sdk/__init__.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • rogue/common/version.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Format Python code with Black
Ensure code passes flake8 linting
Run mypy with the repository configuration for static typing
Run Bandit security checks using .bandit.yaml configuration
Use isort import conventions for import ordering
Add type hints to all function signatures
Follow PEP 8 naming (snake_case for variables/functions, PascalCase for classes)
Use try/except around code that may raise exceptions

Files:

  • sdks/python/rogue_sdk/__init__.py

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
sdks/python/rogue_sdk/__init__.py (1)

60-67: Good: typed version and specific exception.

This implements the earlier ask: add type annotation and catch PackageNotFoundError instead of broad Exception. Nice.

🧹 Nitpick comments (1)
sdks/python/rogue_sdk/__init__.py (1)

54-57: Remove unused TYPE_CHECKING stub (and import) or put it to use.

The empty TYPE_CHECKING block adds noise and will trigger F401 once removed from use. Either drop it or use it for type-only imports. Also, isort will want stdlib imports (typing) before local package imports. As per coding guidelines.

Apply this minimal cleanup:

-from typing import TYPE_CHECKING
-
-if TYPE_CHECKING:
-    pass
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 558a821 and e71128e.

📒 Files selected for processing (1)
  • sdks/python/rogue_sdk/__init__.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Format Python code with Black
Ensure code passes flake8 linting
Run mypy with the repository configuration for static typing
Run Bandit security checks using .bandit.yaml configuration
Use isort import conventions for import ordering
Add type hints to all function signatures
Follow PEP 8 naming (snake_case for variables/functions, PascalCase for classes)
Use try/except around code that may raise exceptions

Files:

  • sdks/python/rogue_sdk/__init__.py
🔇 Additional comments (1)
sdks/python/rogue_sdk/__init__.py (1)

61-67: The review comment is incorrect and should be disregarded.

The package requires Python >= 3.9, and importlib.metadata has been available in the standard library since Python 3.8. The original code is already correct and appropriate for the stated requirements. There is no need to add a fallback to the importlib_metadata backport, as it would only add unnecessary complexity.

The dist name "rogue-ai-sdk" is also verified as correct.

Likely an incorrect or invalid review comment.

Copy link
Collaborator

@yuval-qf yuval-qf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @puwun for this first community contribution!
Happy to merge this 👍

@yuval-qf yuval-qf merged commit 10c23d2 into qualifire-dev:main Oct 20, 2025
7 of 8 checks passed
This was referenced Oct 20, 2025
@drorIvry drorIvry mentioned this pull request Oct 28, 2025
21 tasks
@drorIvry drorIvry mentioned this pull request Nov 10, 2025
21 tasks
@coderabbitai coderabbitai bot mentioned this pull request Jan 4, 2026
21 tasks
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.

[Feature] - Refactor the way versions work

3 participants