Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/amplifier_agent_cli/admin/version_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
16 changes: 15 additions & 1 deletion src/amplifier_agent_lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__"]
15 changes: 11 additions & 4 deletions tests/test_cli_version_subcommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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}"
4 changes: 2 additions & 2 deletions tests/test_protocol_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions tests/test_protocol_version_bump.py
Original file line number Diff line number Diff line change
@@ -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"
Loading