diff --git a/src/amplifier_agent_cli/admin/version_info.py b/src/amplifier_agent_cli/admin/version_info.py index edd7423f..ea294f94 100644 --- a/src/amplifier_agent_cli/admin/version_info.py +++ b/src/amplifier_agent_cli/admin/version_info.py @@ -15,9 +15,14 @@ from amplifier_agent_lib import __version__ -#: The wire protocol version implemented by this engine build. -#: Wrappers must match this exactly (unless allowProtocolSkew is set). -PROTOCOL_VERSION: str = "0.1.0" +# Re-export PROTOCOL_VERSION from the protocol package — the engine's wire +# truth source — rather than restating it here, so the admin/version surface +# can never drift from what `engine.py` and `modes/single_turn.py` actually +# speak. (Prior to this, a hardcoded "0.1.0" survived the 0.2.0 protocol bump +# and shipped a misleading `version --json` payload.) +from amplifier_agent_lib.protocol import PROTOCOL_VERSION + +__all__ = ["PROTOCOL_VERSION", "version_command"] @click.command(name="version") diff --git a/src/amplifier_agent_lib/__init__.py b/src/amplifier_agent_lib/__init__.py index af4271a1..e3f1fa9f 100644 --- a/src/amplifier_agent_lib/__init__.py +++ b/src/amplifier_agent_lib/__init__.py @@ -10,5 +10,19 @@ from __future__ import annotations -__version__ = "0.2.0" +from importlib.metadata import PackageNotFoundError +from importlib.metadata import version as _pkg_version + +try: + # Source of truth: the ``[project].version`` field in ``pyproject.toml``, + # surfaced via the installed distribution's metadata. Resolving at import + # time keeps the engine ``__version__`` aligned with the packaging version + # in editable, wheel, and uv-tool installs alike. + __version__ = _pkg_version("amplifier-agent") +except PackageNotFoundError: # pragma: no cover - source tree w/o dist-info + # Fallback for the rare case where the package is on PYTHONPATH but not + # installed (e.g. an in-tree script run before ``uv sync``). Keep this + # string in sync with ``pyproject.toml`` if it ever has to fire. + __version__ = "0.3.0" + __all__ = ["__version__"] diff --git a/tests/test_cli_version_subcommand.py b/tests/test_cli_version_subcommand.py index bf352889..9bcaf38d 100644 --- a/tests/test_cli_version_subcommand.py +++ b/tests/test_cli_version_subcommand.py @@ -2,7 +2,11 @@ TDD bullets (11a): - `cli version --json` exits 0 with JSON payload containing {protocolVersion, version} -- `cli version` (plain) outputs readable string containing '0.1.0' +- `cli version` (plain) outputs readable string containing the wire protocol version + +The asserted protocol version is sourced from ``amplifier_agent_lib.protocol`` +(the wire truth source) so this test moves in lockstep with the engine when +the protocol semver is bumped. """ from __future__ import annotations @@ -12,6 +16,7 @@ from click.testing import CliRunner from amplifier_agent_cli.__main__ import cli +from amplifier_agent_lib.protocol import PROTOCOL_VERSION def test_version_json_exits_zero_with_payload() -> None: @@ -22,15 +27,17 @@ def test_version_json_exits_zero_with_payload() -> None: payload = json.loads(result.output.strip()) assert "protocolVersion" in payload, f"protocolVersion missing from {payload}" assert "version" in payload, f"version missing from {payload}" - assert payload["protocolVersion"] == "0.1.0", f"Expected '0.1.0', got {payload['protocolVersion']!r}" + assert payload["protocolVersion"] == PROTOCOL_VERSION, ( + f"Expected {PROTOCOL_VERSION!r}, got {payload['protocolVersion']!r}" + ) assert isinstance(payload["version"], str) and len(payload["version"]) > 0, ( f"Expected non-empty version string, got {payload['version']!r}" ) def test_version_plain_outputs_protocol_version() -> None: - """cli version (plain, no --json) outputs '0.1.0' in stdout.""" + """cli version (plain, no --json) outputs the current wire protocol version in stdout.""" runner = CliRunner() result = runner.invoke(cli, ["version"]) assert result.exit_code == 0, f"Expected exit 0, got {result.exit_code}. Output: {result.output}" - assert "0.1.0" in result.output, f"Expected '0.1.0' in output, got: {result.output!r}" + assert PROTOCOL_VERSION in result.output, f"Expected {PROTOCOL_VERSION!r} in output, got: {result.output!r}" diff --git a/tests/test_protocol_methods.py b/tests/test_protocol_methods.py index 85b99b66..bd2af097 100644 --- a/tests/test_protocol_methods.py +++ b/tests/test_protocol_methods.py @@ -6,12 +6,12 @@ def test_protocol_version_constant() -> None: - """PROTOCOL_VERSION is a non-empty string equal to '0.1.0'.""" + """PROTOCOL_VERSION is a non-empty string equal to '0.2.0'.""" from amplifier_agent_lib.protocol.methods import PROTOCOL_VERSION assert isinstance(PROTOCOL_VERSION, str) assert PROTOCOL_VERSION != "" - assert PROTOCOL_VERSION == "0.1.0" + assert PROTOCOL_VERSION == "0.2.0" def test_initialize_params_json_roundtrip() -> None: diff --git a/tests/test_protocol_version_bump.py b/tests/test_protocol_version_bump.py index 062d2cb9..2faac72b 100644 --- a/tests/test_protocol_version_bump.py +++ b/tests/test_protocol_version_bump.py @@ -1,10 +1,10 @@ -"""Test PROTOCOL_VERSION is bumped to 0.1.0 (A1).""" +"""Test PROTOCOL_VERSION is bumped to 0.2.0 (path-based MCP config delivery).""" from __future__ import annotations -def test_protocol_version_is_0_1_0() -> None: - """PROTOCOL_VERSION must be '0.1.0' per design §4.10.3 (A1).""" +def test_protocol_version_is_0_2_0() -> None: + """PROTOCOL_VERSION must be '0.2.0' per the path-based MCP config bump (commit ea51d05).""" from amplifier_agent_lib.protocol.methods import PROTOCOL_VERSION - assert PROTOCOL_VERSION == "0.1.0" + assert PROTOCOL_VERSION == "0.2.0"