Skip to content

Commit cb9a9b7

Browse files
committed
fix(release): zypi --version and ACP agentInfo show the release version (plan decision 16)
`zypi --version` printed 1.0.8, the version of the upstream project, and the ACP `agentInfo.version` was fixed at 0.1.0 in agent.py. Neither told a user which release they had. - The `pi-pager-bin` and `pi-version` crates, and their entries in tui/Cargo.lock, carry 0.5.0, the version of `pi-agent-cli-lc`. `zypi --version` prints `0.5.0 (<commit>)`. `pi-pager` and `pi-shell` keep 1.0.8: plan decision 16 does not cover them. - `agentInfo.version` reads the version of the installed `pi-agent-cli-lc`. A checkout that was never installed has no package metadata and gets `0.0.0+unknown`, which is still a valid version. - Tests: the agent reports the installed version; the two crates and Cargo.lock stay equal to the version of `pi-agent-cli-lc`; no workflow sets GROK_VERSION (that variable also marks a build as a release build, which turns the folder-trust prompt on). - CHANGELOG: a new Changed entry (with the behaviour change for a `[[version_overrides]]` patch above 0.5.0) and the "Version numbers" known issue is removed. The audit note that said `_AGENT_INFO` is hard-coded now says it changed later. Not run here: cargo build and cargo test, and `zypi --version` (WSL does not start on this machine). TUI CI builds the workspace and runs the Rust tests.
1 parent 59545c1 commit cb9a9b7

8 files changed

Lines changed: 159 additions & 7 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7878
- **What `zypi` does with `config.toml` is written down (`packages/pi-agent-cli/AGENTS.md`, `docs/WINDOWS.md`, `docs/TUI-AND-CODE-AGENT.md`)**: the old text said that Python-only keys break TUI parsing. Measured: `zypi` is strict about the keys it knows and ignores the keys it does not know. A missing file, an unknown table or key and a Python `[model]` table start normally. A top-level `permission = "ask"` (`zypi` expects a table there), a `[[models]]` array and invalid TOML stop `zypi` with exit status 1. The agent reads `agent.toml`, and falls back to `config.toml` only when `agent.toml` does not exist. `TUI-AND-CODE-AGENT.md` now has the real `[model]` keys (`id`, not `model_id`; no `context_window`), the permission values (`ask`, `auto`, `always-approve`) and the real slash commands, and says that `zypi` has no model client, tool runner or MCP client. `docs/DESIGN.md` section 8.5 states the five conditions for a new `pi/` extension, and the Phase 4 spec has a revision note.
7979
- **`zypi -p` refuses a sandbox it cannot apply, and names the flags it ignores (TUI)**: `-p` hands the whole run to the Python agent before `zypi` applies a sandbox, so v0.4.0 dropped a sandbox from `--sandbox`, `GROK_SANDBOX` or `[sandbox].profile` without a word. Now `-p` prints an error that names the profile and where it came from, and exits with status 2 without starting the agent. Where the user may change the profile, the error says that `--sandbox off` runs without one. A flag that `-p` does not pass to the agent (for example `--model`, `--always-approve`, `--permission-mode`, `--allow`, `--deny` or `--resume`) now gives `warning: <flag> has no effect with -p and was ignored` on stderr. **Behaviour change**: a script that runs `zypi -p` with a sandbox profile set in the environment or in `config.toml` now fails with status 2 until it passes `--sandbox off`.
8080
- **`zypi` is the product name wherever the user sees a name (TUI)**: the themes are `zypi Night` and `zypi Day` (saved as `zypinight` and `zypiday`; the old ids and aliases still work, so `config.toml` needs no change). Desktop notifications, the `zypi doctor` title, the `--minimal` welcome page and other messages say `zypi` where they said `Grok`. The `GROK_*` environment variables, the project path `.grok/sandbox.toml` and the `grok_home` field of `zypi du --json` keep their names: a rename of these would break existing setups, so it needs its own decision.
81+
- **`zypi --version` and the ACP `agentInfo.version` show the version of the release (TUI, `pi-agent-cli`)**: `zypi --version` printed `1.0.8`, the version of the upstream project, and the agent reported `0.1.0` whatever the package was. `zypi` now prints `0.5.0` (the version in the `Cargo.toml` of `pi-pager-bin` and `pi-version`), and the agent reports the version of the installed `pi-agent-cli-lc` package. A test fails if those two crates or `Cargo.lock` differ from the version of `pi-agent-cli-lc`, so raise them together with the Python packages at each release. The release workflow does not set `GROK_VERSION`, on purpose: the same variable marks a build as a release build and turns the folder-trust prompt on, and a test fails if a workflow sets it. **Behaviour change**: the number is lower than before. A `[[version_overrides]]` patch in a config file whose `minimum_version` is above `0.5.0` no longer applies; none ships with `zypi`.
8182

8283
### Removed
8384

@@ -91,7 +92,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9192
- **Some flags and settings have no effect**: in the interactive UI, `--system-prompt-override` and `--rules` do nothing, and `--allow` and `--deny` do not reach the agent. `zypi --help` still lists flags from the upstream project that nobody has checked one by one. On the settings page, the items other than the permission mode may have no effect with the Python agent. `remember_tool_approvals` and `default_selected_permission` were not tested.
9293
- **`[ui.status_line]` draws nothing**: the row comes from a `session_status` notification that only the removed Rust agent sent.
9394
- **The user guide has no way to open it**: the 7 pages are in the binary, but nothing in the UI opens them.
94-
- **Version numbers**: `zypi --version` shows `1.0.8`, the version of the upstream code, and the agent reports `agentInfo.version` `0.1.0`. Neither is the release version.
9595
- **Tested on Linux only for the latest changes**: the end-to-end and pseudo-terminal scripts ran on Linux (WSL2). `zypi` last ran on macOS before the final changes to `tui/`. The macOS binary of this release is built by CI (a dry run of the release workflow built it) and nobody has started it. There is no Windows binary. The Landlock layer of the sandbox was not tested: the kernel of the test machine (5.10) has none.
9696
- **Open findings in the Python packages**: the low-risk findings F7-02 to F7-09 of the Phase 6 and Phase 7 audit have no fix yet (small defects in the extension API, and notes for the specs). See `docs/AUDIT/AUDIT-PHASE6-PHASE7-2026-09-30.md`, section 8.
9797

‎docs/AUDIT/AUDIT-PHASE6-PHASE7-2026-09-30.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@
292292
| 11 | P7-09 | 走代理时,代理把公开域名解析到私网地址拦不住,也没有「校验的地址即连接的地址」的保证(需要更强保证就在代理一侧限制出口,或不设代理走直连);工具不响应 turn 的 abort 信号,靠 30 秒总时限兜底,超时后 `trafilatura` 的工作线程会自己跑完;服务端无视 `Accept-Encoding: identity` 发压缩正文时,一次读取的 64 KiB 压缩数据最多瞬时膨胀到约 64 MiB,之后被 5 MiB 上限截断 |
293293
| 12 | P7-11 | 提醒次数只在本进程内计,不随状态保存 |
294294
| 13 | P6-03 | 官方 DeepSeek 上开启思考且带工具时回传 `reasoning_content`(批 6)与 CLI 的 `Model.reasoning` 接线都**没有对真实 API 验证**(没有密钥;矩阵 `deepseek` 行的 `thinking_tools` 用例是第一次真实检验)。请求的形状取自 DeepSeek 的文档与样例;测试走已安装的 `langchain-deepseek` 真实的请求构造路径(`_get_request_payload`)与一次完整的工具往返(伪造的只是网络那一端)。网关上的 DeepSeek 模型(SiliconFlow、vLLM 等)刻意不回放:它们各自的要求不同,也没有验证 |
295-
| 14 | P7-15 | 扩展的版本下限必须随核心发布一起上调(`test_extension_packaging.py` 会拦住不同步的情况)。批 7 把核心、`pi-agent-harness-lc`、`pi-agent-cli-lc` 升到 0.5.0,三个扩展包的下限同步成 `>=0.5.0`,并把扩展包自己的版本从 0.1.0 升到 0.2.0(发布工作流的 PyPI 步骤带 `skip-existing`,版本号不变就会让 PyPI 上已有的旧构建原样留着);六个包都用 `uv build` 构建过,wheel 元数据的版本与依赖符合预期。**只做了本地提交:没有打 tag、没有发布、没有推送**;0.5.0 这个版本号与扩展包的 0.2.0 是按惯例选的,发布者可以改。今后每次发布都要重复这一步。另外 ACP 的 `agentInfo.version`(`agent.py` 的 `_AGENT_INFO`)一直硬编码为 `0.1.0`,与包版本早就对不上,这次没有改 |
295+
| 14 | P7-15 | 扩展的版本下限必须随核心发布一起上调(`test_extension_packaging.py` 会拦住不同步的情况)。批 7 把核心、`pi-agent-harness-lc`、`pi-agent-cli-lc` 升到 0.5.0,三个扩展包的下限同步成 `>=0.5.0`,并把扩展包自己的版本从 0.1.0 升到 0.2.0(发布工作流的 PyPI 步骤带 `skip-existing`,版本号不变就会让 PyPI 上已有的旧构建原样留着);六个包都用 `uv build` 构建过,wheel 元数据的版本与依赖符合预期。**只做了本地提交:没有打 tag、没有发布、没有推送**;0.5.0 这个版本号与扩展包的 0.2.0 是按惯例选的,发布者可以改。今后每次发布都要重复这一步。另外 ACP 的 `agentInfo.version`(`agent.py` 的 `_AGENT_INFO`)一直硬编码为 `0.1.0`,与包版本早就对不上,这次没有改(后来改了:现在读已装包 `pi-agent-cli-lc` 的版本,见 CHANGELOG 的 0.5.0) |
296296
| 15 | P7-03 | 模型 id 写成 `provider/model`,按第一个 `/` 拆分,对自身含 `/` 的网关模型 id(如 `Qwen/Qwen3-8B`)有歧义,需写成 `<provider>/Qwen/Qwen3-8B` |
297297
| 16 | 编号 | 本文件与 `AUDIT-PHASE7-EXTENSION-API.md` 的编号重名,见文件开头的说明 |
298298

‎packages/pi-agent-cli/pi_agent_cli/agent.py‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import annotations
44

55
import asyncio
6+
import importlib.metadata
67
import logging
78
import uuid
89
from collections.abc import Sequence
@@ -101,7 +102,25 @@
101102

102103
logger = logging.getLogger(__name__)
103104

104-
_AGENT_INFO = Implementation(name="pi-agent-cli", title="pi-python ACP agent", version="0.1.0")
105+
# The package this agent ships in. Its version is the version of the release.
106+
_DISTRIBUTION = "pi-agent-cli-lc"
107+
108+
109+
def _installed_version() -> str:
110+
"""The version of the installed package, for ACP ``agentInfo.version``.
111+
112+
Without package metadata (a checkout that was never installed) the answer is
113+
``0.0.0+unknown``, which is still a valid version.
114+
"""
115+
try:
116+
return importlib.metadata.version(_DISTRIBUTION)
117+
except importlib.metadata.PackageNotFoundError:
118+
return "0.0.0+unknown"
119+
120+
121+
_AGENT_INFO = Implementation(
122+
name="pi-agent-cli", title="pi-python ACP agent", version=_installed_version()
123+
)
105124

106125
# ACP Session Config Option id for the model selector (``session/set_config_option``).
107126
MODEL_CONFIG_ID = "model"
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
"""ACP ``agentInfo``: the agent reports the version of the package it ships in (plan decision 16).
2+
3+
The version used to be written into ``agent.py`` (``0.1.0``) and no longer matched the package.
4+
"""
5+
6+
from __future__ import annotations
7+
8+
import importlib.metadata
9+
from pathlib import Path
10+
11+
import pytest
12+
from packaging.version import Version
13+
14+
from pi_agent_cli import agent as agent_module
15+
from pi_agent_cli.agent import PiAcpAgent
16+
from pi_agent_cli.config import CliConfig
17+
from pi_agent_core.tests.mock_stream import mock_text_stream
18+
19+
DISTRIBUTION = "pi-agent-cli-lc"
20+
21+
22+
@pytest.mark.asyncio
23+
async def test_initialize_reports_the_version_of_the_installed_package(tmp_path: Path):
24+
agent = PiAcpAgent(
25+
stream_fn=mock_text_stream,
26+
home=tmp_path,
27+
config=CliConfig(permission="ask", provider="mock", model_id="mock"), # type: ignore[arg-type]
28+
)
29+
response = await agent.initialize(protocol_version=1)
30+
31+
assert response.agent_info is not None
32+
assert response.agent_info.name == "pi-agent-cli"
33+
assert response.agent_info.version == importlib.metadata.version(DISTRIBUTION)
34+
# What a client reads from the wire.
35+
assert response.model_dump(by_alias=True)["agentInfo"]["version"] == response.agent_info.version
36+
37+
38+
def test_installed_version_falls_back_to_a_valid_version_without_package_metadata(
39+
monkeypatch: pytest.MonkeyPatch,
40+
):
41+
def not_installed(name: str) -> str:
42+
raise importlib.metadata.PackageNotFoundError(name)
43+
44+
monkeypatch.setattr(importlib.metadata, "version", not_installed)
45+
46+
version = agent_module._installed_version()
47+
48+
assert version == "0.0.0+unknown"
49+
Version(version) # a client may parse it, so it must be a valid version
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
"""The version numbers that name the release stay in step (plan decision 16).
2+
3+
``zypi --version`` and the ACP ``agentInfo.version`` must show the version of the release. The TUI
4+
crates kept the version of the upstream project (1.0.8) and the agent said 0.1.0, so a user could
5+
not tell which release a binary came from. The release version is the version of
6+
``pi-agent-cli-lc``, the package that ``zypi`` starts. The two crates whose version ``zypi`` shows,
7+
and ``Cargo.lock``, must carry it: raise them together with the Python packages at each release.
8+
9+
No workflow may set ``GROK_VERSION``. The same variable marks a build as a release build
10+
(``pi_version::IS_DEV_BUILD``), and a release build turns the folder-trust gate on. An unstamped
11+
build, like v0.3.0 and v0.4.0, has it off. To turn it on is a change of behaviour that needs its
12+
own decision. The version number comes from ``Cargo.toml`` instead.
13+
"""
14+
15+
from __future__ import annotations
16+
17+
import tomllib
18+
from pathlib import Path
19+
from typing import Any
20+
21+
import pytest
22+
23+
REPO_ROOT = Path(__file__).resolve().parents[2]
24+
RELEASE_PACKAGE = REPO_ROOT / "packages" / "pi-agent-cli" / "pyproject.toml"
25+
CARGO_LOCK = REPO_ROOT / "tui" / "Cargo.lock"
26+
WORKFLOWS = REPO_ROOT / ".github" / "workflows"
27+
28+
# The crates whose version zypi prints: `pi-pager-bin` for `zypi --version`, `pi-version` for
29+
# `pi_version::VERSION` (the welcome page, the update and config version checks).
30+
TUI_CRATES = {
31+
"pi-pager-bin": REPO_ROOT / "tui" / "crates" / "codegen" / "pi-pager-bin" / "Cargo.toml",
32+
"pi-version": REPO_ROOT / "tui" / "crates" / "codegen" / "pi-version" / "Cargo.toml",
33+
}
34+
35+
pytestmark = pytest.mark.skipif(
36+
not (CARGO_LOCK.is_file() and RELEASE_PACKAGE.is_file()),
37+
reason="needs the monorepo checkout (tui/ and packages/ are not part of an installed wheel)",
38+
)
39+
40+
41+
def _toml(path: Path) -> dict[str, Any]:
42+
return tomllib.loads(path.read_text(encoding="utf-8"))
43+
44+
45+
def _release_version() -> str:
46+
return _toml(RELEASE_PACKAGE)["project"]["version"]
47+
48+
49+
@pytest.mark.parametrize("crate", sorted(TUI_CRATES))
50+
def test_tui_crate_version_is_the_release_version(crate: str):
51+
manifest = TUI_CRATES[crate]
52+
package = _toml(manifest)["package"]
53+
54+
assert package["name"] == crate
55+
assert package["version"] == _release_version(), (
56+
f"`{crate}` is {package['version']} but pi-agent-cli-lc is {_release_version()}: "
57+
"`zypi` would show the wrong release. "
58+
f"Set `version` in {manifest.relative_to(REPO_ROOT)} and in tui/Cargo.lock "
59+
f"to {_release_version()}."
60+
)
61+
62+
63+
def test_cargo_lock_carries_the_release_version_of_those_crates():
64+
locked = {
65+
entry["name"]: entry["version"]
66+
for entry in _toml(CARGO_LOCK)["package"]
67+
if entry["name"] in TUI_CRATES
68+
}
69+
70+
assert locked == {crate: _release_version() for crate in TUI_CRATES}
71+
72+
73+
def test_no_workflow_sets_grok_version():
74+
setting = [
75+
path.name
76+
for path in sorted(WORKFLOWS.glob("*.y*ml"))
77+
if "GROK_VERSION" in path.read_text(encoding="utf-8")
78+
]
79+
80+
assert setting == [], (
81+
f"{setting} set GROK_VERSION. That stamps the version, and it also marks the build as a "
82+
"release build, which turns on folder trust (plan decision 16). Change the version in "
83+
"Cargo.toml instead."
84+
)

‎tui/Cargo.lock‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎tui/crates/codegen/pi-pager-bin/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pi-pager-bin"
3-
version = "1.0.8"
3+
version = "0.5.0"
44
edition.workspace = true
55
license = "Apache-2.0"
66
authors = ["pi"]

‎tui/crates/codegen/pi-version/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
license = "Apache-2.0"
33
name = "pi-version"
4-
version = "1.0.8"
4+
version = "0.5.0"
55
edition.workspace = true
66
description = "Lockstepped grok CLI version."
77

0 commit comments

Comments
 (0)