Skip to content

Commit 7e7d4d4

Browse files
committed
chore(release): prepare 0.5.0 - raise the extension packages' core floors (audit follow-up 7, batch 7)
Kept apart from the feature commit so it can be dropped or re-numbered on its own. pi-agent-core-lc, pi-agent-harness-lc and pi-agent-cli-lc go from 0.4.0 to 0.5.0, with the exact pins between them. pi-web-access-py, pi-goal-x-py and pi-dynamic-workflows-py now require pi-agent-core-lc>=0.5.0 (pi-dynamic-workflows-py also pi-agent-harness-lc>=0.5.0): they use APIs 0.4.0 does not have (ExtensionAPI.home, pi_agent_core.home, HarnessBridge.tool_call_gate and trigger_message, ToolAnnotations). test_extension_packaging.py requires the floor to equal the workspace version, so it would have failed on the version bump alone. The three extension packages go from 0.1.0 to 0.2.0 as well: the release workflow publishes with skip-existing, so an unchanged version would have left whatever 0.1.0 is already on PyPI in place instead of this code. CHANGELOG: the Unreleased entries become [0.5.0] - 2026-10-02 (with a fresh empty Unreleased and the release link). Phase 7 spec and audit tracker updated. No tag, no publish, no push. Checked: all six packages build with `uv build` (wheel metadata has the expected versions and pins); the editable install in .venv resolves; full suites unchanged (Windows 1980 passed / 10 skipped, WSL 1975 / 15); ruff 0.15.20 and 0.16.0 clean. Not changed: _AGENT_INFO in pi_agent_cli/agent.py still reports version 0.1.0 to ACP clients, as it has since before 0.4.0.
1 parent d4ab3f8 commit 7e7d4d4

9 files changed

Lines changed: 27 additions & 24 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.5.0] - 2026-10-02
11+
1012
### Added
1113

1214
- **An ACP client is asked before a project's own resources are used, and the answer is tied to the files (Phase 7)**: trust used to be a path in `agent.toml` and nothing else, so a project that shipped extensions, `.pi/SYSTEM.md`, `.pi/APPEND_SYSTEM.md` or project-relative skills was quietly ignored until the user edited a file by hand, and once listed it stayed trusted whatever later arrived in the directory (a `git pull` could add an extension that then ran). Now, when a project ships any of those and nothing the project cannot write has decided already (`trusted_projects`, `default_project_trust = "always"` or the older `trust_project_extensions`, `--trust-project-extensions` / `PI_TRUST_PROJECT_EXTENSIONS`), the ACP agent asks. It first says, in an ordinary agent message, which directory and files are involved and what each does (the TUI shows a permission request's title and options only, not its `content`; the names in the message are the repository's to choose, so control characters are written as escapes and names sit in code spans, and a message that cannot be delivered means nothing is asked), then sends `session/request_permission` with `Don't trust` (`reject_once`, listed first) and `Trust and remember` (`allow_always`). There is deliberately no `allow_once` option: clients may answer tool permissions for the user (ACP allows it; the TUI's YOLO mode picks the first `allow_once`), and whether to run a repository's code is not that decision, so with no such option the question reaches a person. Only the exact id of the trust option, selected, is a yes; a cancel, an unknown id or a failing client leaves the project untrusted, and a refusal is not remembered. It asks whatever the `permission` mode is (asking is not trusting). The request goes out after the `session/new` (`load`, `resume`) response, because clients drop requests for sessions they have not registered; until it is answered nothing of the project loads (extensions stay unimported) and the session's first prompt waits (`session/cancel` ends every prompt waiting at that moment, and closing the session ends them too); sessions opened together in one directory are asked one after the other, and a yes answers them all (a refusal is not remembered, so the next one asks again). The answer is saved in `~/.pi-python/agent/trust.json` (version 1; one record per exact directory with a `sha256:` fingerprint of the gated files' contents, the time and what was trusted; written atomically; read fail-closed; a corrupt file is kept as `trust.json.corrupt` instead of being overwritten; delete a project's entry to take the trust back). The fingerprint covers contents, not mtimes (the extensions directory recursively, the two prompt files, the project-relative skills paths; `__pycache__` and `.git` skipped), so a `git pull` that changes one of them asks again and says the files changed since they were trusted; files edited while the dialog is open are not trusted (the disk is checked again after the answer); and if the answer cannot be saved the session is still trusted and the user is told they will be asked again. A project with more than 2000 entries, more than 64 MiB, or unreadable files cannot be fingerprinted, so it is not asked about: list it under `trusted_projects`. New setting `[extensions] default_project_trust = "ask" | "never" | "always"` (upstream pi's `defaultProjectTrust`; default `ask`): `never` neither asks nor trusts (an allow-list entry, the command line or a saved answer still do); `always` trusts every project; the older `trust_project_extensions = true` means `always` unless `default_project_trust` is set. Headless (`-p`) runs never ask, as in upstream's non-interactive modes, but honour a saved answer whose files still match, and their "skipped" notice now says why (not decided, changed since trusted, `never`, too many files). **Behaviour change**: an ACP session in a project that ships such files used to skip them without a word and now asks; set `default_project_trust = "never"` to keep the old behaviour. **Not covered**: a client may auto-approve the request (nothing in ACP prevents that, and the TUI pre-highlights the kind of answer the user confirmed last, so after an "always" answer `Trust and remember` is the highlighted row); files changed after the session started are not re-checked; there is no `/trust` command. New modules `trust_store`, `trust_fingerprint`, `trust_prompt` and `extension_trust.decide_project_trust` / `ProjectTrust` in `pi_agent_cli`; `AgentHarness.set_trust_project_extensions(bool)` (valid until extensions load); `pi_agent_core.extensions.loader.extension_module_names`. Design: Phase 7 spec, section 4.4.
@@ -48,7 +50,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4850

4951
- **`agent(..., cwd=)` is limited to the project (Phase 7)**: a workflow script could point a sub-agent at any directory; the permission prompt showed it, nothing stopped it. The directory must now be inside the project (`WorkflowRuntime.cwd`): a relative path is read against the project, not the process's current directory; symbolic links and Windows junctions are followed before the comparison; a path outside is a `ValueError` the script can catch, a non-string a `TypeError`, and a NUL character a `ValueError`. The check comes before an agent slot is taken and before the journal is consulted (a resume cannot get around a policy that is tighter than the first run's), the journal hash still holds the `cwd` the script gave, and `HarnessSubagentExecutor` checks again before it creates a worktree, so a caller that uses the executor on its own is covered too. **Migration**: a script that used `cwd` to leave the project has to be rewritten. A worktree-isolated sub-agent (`isolation=True`) still runs at the worktree's root, whatever subdirectory was asked for. Design: `docs/specs/2026-10-01-workflow-sandbox-design.md`, section 8.1.
5052
- **Bridge and lifecycle API (Phase 7)**: `HarnessBridge` gains `trigger_message`; it is a runtime-checkable protocol, so a custom bridge (a test double, say) must add the method to keep passing `isinstance` checks. `AgentHarness` gains `closed`; `close()` is idempotent. `WorkflowManager` gains `close(timeout=5)`, which the extension registers instead of `shutdown()` (still there, no longer used at session end), and `start_background()` raises `RuntimeError` once it is closed. `Journal.truncate_from` is removed and `Journal.try_replay` no longer changes the journal on a miss; `WorktreeManager.collect_diff()` returns `bytes` (it returned `str`).
51-
- **Extension packages declare what they use (Phase 7)**: `pi-web-access-py`, `pi-goal-x-py` and `pi-dynamic-workflows-py` required `pi-agent-core-lc>=0.3.0`, which has no `pi_agent_core.extensions`; the floor is now the core version they ship with (`>=0.4.0`), and `pi-dynamic-workflows-py` also declares `pi-agent-harness-lc` (its sub-agents import `pi_agent_harness`; a plain `pip install` used to leave the workflow tool unable to run). `pi_agent_core/tests/test_extension_packaging.py` checks that every workspace distribution an extension imports is declared, that the floor equals the checkout's version, and that `[tool.uv.sources]` points at the workspace. **Release note**: bumping the core version now fails that test until the three extension floors are raised with it, which is intended: this release's extensions use APIs newer than 0.4.0 (`ExtensionAPI.home`, `pi_agent_core.home`, `HarnessBridge.tool_call_gate`, `HarnessBridge.trigger_message`) and must not be installed against an older core.
53+
- **Extension packages declare what they use (Phase 7)**: `pi-web-access-py`, `pi-goal-x-py` and `pi-dynamic-workflows-py` required `pi-agent-core-lc>=0.3.0`, which has no `pi_agent_core.extensions`; the floor is now the core version they ship with (`>=0.5.0`), and `pi-dynamic-workflows-py` also declares `pi-agent-harness-lc` (its sub-agents import `pi_agent_harness`; a plain `pip install` used to leave the workflow tool unable to run). `pi_agent_core/tests/test_extension_packaging.py` checks that every workspace distribution an extension imports is declared, that the floor equals the checkout's version, and that `[tool.uv.sources]` points at the workspace. **Release note**: this release's extensions use APIs newer than 0.4.0 (`ExtensionAPI.home`, `pi_agent_core.home`, `HarnessBridge.tool_call_gate`, `HarnessBridge.trigger_message`, `ToolAnnotations`) and must not be installed against an older core, so the core, `pi-agent-harness-lc` and `pi-agent-cli-lc` are now 0.5.0 and the three floors `>=0.5.0`; raising the core version fails the packaging test until the floors follow, which is intended. The three extension packages themselves go from 0.1.0 to 0.2.0: the publish step skips versions that already exist on PyPI, so unchanged numbers would have kept any 0.1.0 already published (with the old floor and without these changes) in place.
5254
- `resolve_tier(tier, tiers=None, *, provider=None)`: built-in tier defaults are now per parent provider (`DEFAULT_MODEL_TIERS_BY_PROVIDER`, currently `anthropic` only; `DEFAULT_MODEL_TIERS` is removed). With any other parent provider a `tier` inherits the parent model. An explicit `tiers` mapping still wins and may name any provider.
5355
- `make_get_api_key(config)` returns the key only for `config.provider`; other providers get `None`, so their SDK reads its own standard variable (for example `ANTHROPIC_API_KEY`). Export that variable when a workflow routes sub-agents to another provider.
5456
- Sub-agent models keep the parent's `base_url` only when they stay on the parent's provider.
@@ -136,6 +138,7 @@ Initial public release.
136138
- **Compaction & tree navigation (H3)**: token-based compaction with branch summaries, `navigate_tree` for branch exploration.
137139
- **Skills, templates & env (H4)**: skill discovery, prompt templates, system prompt injection, `LocalExecutionEnv` for sandboxed execution.
138140

141+
[0.5.0]: https://github.com/zy1233/pi-python/releases/tag/v0.5.0
139142
[0.4.0]: https://github.com/zy1233/pi-python/releases/tag/v0.4.0
140143
[0.3.0]: https://github.com/zy1233/pi-python/releases/tag/v0.3.0
141144
[0.2.0]: https://github.com/zy1233/pi-python/releases/tag/v0.2.0

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# AUDIT:Phase 6 / Phase 7 设计与实现审计(2026-09-30)
22

3-
> **审计日期**:2026-09-30(发现与前三批修复在同一天完成;批 4 在 10 月 1 日,批 5、6 在 10 月 2 日)
3+
> **审计日期**:2026-09-30(发现与前三批修复在同一天完成;批 4 在 10 月 1 日,批 5 至 7 在 10 月 2 日)
44
>
55
> **审计范围**:
66
> - Phase 6:`packages/pi-agent-cli/pi_agent_cli/{git_context,prompt_options,system_prompt,factory}.py`、`pi_agent_core/adapters/langchain_stream.py`、`pi_agent_core/tests/{provider_matrix,test_provider_matrix}.py`、`.github/workflows/provider-matrix.yml`
@@ -10,7 +10,7 @@
1010
>
1111
> **方法**:代码阅读;在 Windows(zh-CN 区域设置)上用探针脚本实测;provider 文档(DeepSeek 等)对照核对。探针是临时脚本,没有入库;每一项的回归测试入库,并且都先红后绿。
1212
>
13-
> **修复批次**:批 1 `6aaf29a`、批 2 `cf92422`、批 3 `b3de95f`、批 4(P7-02 的交互式信任提示与内容哈希)`0a1dd67`、批 5(P7-01 的子 agent `cwd` 约束与脚本沙盒)`9baefa6`、批 6(第七节的 4–6:DeepSeek 的 `reasoning_content` 回放与 CLI 的 `Model.reasoning`、按 annotations 放行的权限模型、后台 turn 期间到达的 prompt)随本文档的这次更新一起提交(`git log -- docs/AUDIT/AUDIT-PHASE6-PHASE7-2026-09-30.md`)
13+
> **修复批次**:批 1 `6aaf29a`、批 2 `cf92422`、批 3 `b3de95f`、批 4(P7-02 的交互式信任提示与内容哈希)`0a1dd67`、批 5(P7-01 的子 agent `cwd` 约束与脚本沙盒)`9baefa6`、批 6(第七节的 4–6:DeepSeek 的 `reasoning_content` 回放与 CLI 的 `Model.reasoning`、按 annotations 放行的权限模型、后台 turn 期间到达的 prompt)`d4ab3f8`、批 7(第七节的 7:发布准备,版本 0.5.0)随本文档的这次更新一起提交(`git log -- docs/AUDIT/AUDIT-PHASE6-PHASE7-2026-09-30.md`)
1414
>
1515
> **最终测试状态**:
1616
> - Windows:`1980 passed, 10 skipped, 31 deselected`(10 个 skip 是只在 POSIX 上有意义的用例:批 4 的 5 个(符号链接的显示路径、命名管道、权限位 2 个、非法文件名),批 5 的 5 个(`RLIMIT_NPROC`、rlimit 数值、`prctl`、文件描述符上限、信号名);31 个 deselected 是 `real_llm` 用例,批 6 起矩阵的 `deepseek` 行多一项 `thinking_tools`;审计开始时 `576 passed, 30 skipped`)
@@ -273,7 +273,7 @@
273273
| 11 | P7-09 | 走代理时,代理把公开域名解析到私网地址拦不住,也没有「校验的地址即连接的地址」的保证(需要更强保证就在代理一侧限制出口,或不设代理走直连);工具不响应 turn 的 abort 信号,靠 30 秒总时限兜底,超时后 `trafilatura` 的工作线程会自己跑完;服务端无视 `Accept-Encoding: identity` 发压缩正文时,一次读取的 64 KiB 压缩数据最多瞬时膨胀到约 64 MiB,之后被 5 MiB 上限截断 |
274274
| 12 | P7-11 | 提醒次数只在本进程内计,不随状态保存 |
275275
| 13 | P6-03 | 官方 DeepSeek 上开启思考且带工具时回传 `reasoning_content`(批 6)与 CLI 的 `Model.reasoning` 接线都**没有对真实 API 验证**(没有密钥;矩阵 `deepseek` 行的 `thinking_tools` 用例是第一次真实检验)。请求的形状取自 DeepSeek 的文档与样例;测试走已安装的 `langchain-deepseek` 真实的请求构造路径(`_get_request_payload`)与一次完整的工具往返(伪造的只是网络那一端)。网关上的 DeepSeek 模型(SiliconFlow、vLLM 等)刻意不回放:它们各自的要求不同,也没有验证 |
276-
| 14 | P7-15 | 扩展的版本下限必须随下一次核心发布一起上调(测试会拦住),这批扩展用到了比 0.4.0 更新的 API(`ExtensionAPI.home`、`pi_agent_core.home`、`HarnessBridge.tool_call_gate`、`HarnessBridge.trigger_message`) |
276+
| 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`,与包版本早就对不上,这次没有改 |
277277
| 15 | P7-03 | 模型 id 写成 `provider/model`,按第一个 `/` 拆分,对自身含 `/` 的网关模型 id(如 `Qwen/Qwen3-8B`)有歧义,需写成 `<provider>/Qwen/Qwen3-8B` |
278278
| 16 | 编号 | 本文件与 `AUDIT-PHASE7-EXTENSION-API.md` 的编号重名,见文件开头的说明 |
279279

@@ -330,6 +330,6 @@
330330
4. ~~**DeepSeek 的 `reasoning_content` 回放**,并在 CLI 里接入 `Model.reasoning`~~:已在批 6 完成(P6-03;仍未对真实 API 验证,第五节 13)。
331331
5. ~~**默认需授权的权限模型**:按工具 annotations 放行只读工具~~:已在批 6 完成(P7-01;残留见第五节 3)。
332332
6. ~~**ACP `state_update`**~~:调查后**决定不发**(它只存在于协议 v2,SDK 与 TUI 的 crate 都读不了),改为让 turn 之外到达的 prompt 等该 turn 结束(批 6,P7-07;第五节 10)。
333-
7. **发布时**:上调三个扩展包的版本下限(第五节 14)。
333+
7. ~~**发布时**:上调三个扩展包的版本下限~~:已在批 7 完成(核心 0.5.0,扩展包 0.2.0;只做了本地提交,没有打 tag、没有发布;第五节 14)。
334334

335-
第 7 项要等到发布时才做,版本号与 tag 由发布者决定。其余没有已排期的后续工作;仍然开放的是:第 3 项里写的加固方向(Landlock / 用户与挂载命名空间、seccomp,需要 ≥ 5.13 的 Linux 内核才能验证,本机 WSL 是 5.10)、用真实的 DeepSeek API 验证批 6 的回放(第五节 13)、以及 TUI 怎样渲染 turn 之外的更新(第五节 10)。
335+
以上各项做完之后,没有已排期的后续工作;仍然开放的是:第 3 项里写的加固方向(Landlock / 用户与挂载命名空间、seccomp,需要 ≥ 5.13 的 Linux 内核才能验证,本机 WSL 是 5.10)、用真实的 DeepSeek API 验证批 6 的回放(第五节 13)、以及 TUI 怎样渲染 turn 之外的更新(第五节 10)。

‎docs/specs/2026-09-22-phase7-extension-api-design.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ import 一个扩展就是执行它的代码,而 `<项目>/.pi-python/extension
308308

309309
**一个「家」。** `pi_agent_core.home.pi_home(override=None)` 是唯一的解析器:参数 > `$PI_HOME` > `~/.pi-python`。CLI、`ExtensionLoader(home=)`、`AgentHarness(home=)`、`ExtensionAPI.home`(`pi.home`)和 pi-dynamic-workflows(journal、saved workflow)都走它。以前 CLI 认 `PI_HOME`,而 loader 与 workflow 扩展直接用 `Path.home() / ".pi-python"`:设了 `PI_HOME` 的会话会从一处读配置、从另一处读扩展、往第三处写 journal。
310310

311-
**打包。** 扩展包与核心一同发布,所以 `pi-agent-core-lc` 的下限就是仓库里的核心版本(旧下限 `>=0.3.0`,而 `pi_agent_core.extensions` 到 0.4.0 才出现)。用到 `pi_agent_harness` 的包(pi-dynamic-workflows)必须声明 `pi-agent-harness-lc`,并在 `[tool.uv.sources]` 里指向工作区;否则 `pip install` 之后 workflow 工具只能回答「sub-agents unavailable」。`pi_agent_core/tests/test_extension_packaging.py` 检查这三点:发版时抬高核心版本却忘了抬下限,会在 CI 里失败,而不是发布之后才暴露。
311+
**打包。** 扩展包与核心一同发布,所以 `pi-agent-core-lc` 的下限就是仓库里的核心版本(旧下限 `>=0.3.0`,而 `pi_agent_core.extensions` 到 0.4.0 才出现;0.5.0 起是 `>=0.5.0`:扩展用到了 `ToolAnnotations` 等 0.4.0 没有的接口)。扩展包自己的版本号也要随发布抬高(0.5.0 时三个都从 0.1.0 到 0.2.0):发布工作流的 PyPI 步骤带 `skip-existing`,版本号不变就会让已发布的旧构建原样留在 PyPI 上。用到 `pi_agent_harness` 的包(pi-dynamic-workflows)必须声明 `pi-agent-harness-lc`,并在 `[tool.uv.sources]` 里指向工作区;否则 `pip install` 之后 workflow 工具只能回答「sub-agents unavailable」。`pi_agent_core/tests/test_extension_packaging.py` 检查这三点:发版时抬高核心版本却忘了抬下限,会在 CI 里失败,而不是发布之后才暴露。
312312

313313
---
314314

‎packages/pi-agent-cli/pyproject.toml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "pi-agent-cli-lc"
7-
version = "0.4.0"
7+
version = "0.5.0"
88
description = "Standard ACP agent over AgentHarness (no x.ai extensions)"
99
readme = "README.md"
1010
requires-python = ">=3.11"
@@ -25,8 +25,8 @@ classifiers = [
2525
"Typing :: Typed",
2626
]
2727
dependencies = [
28-
"pi-agent-core-lc==0.4.0",
29-
"pi-agent-harness-lc==0.4.0",
28+
"pi-agent-core-lc==0.5.0",
29+
"pi-agent-harness-lc==0.5.0",
3030
"agent-client-protocol>=0.12.0",
3131
"pydantic>=2.0",
3232
]

‎packages/pi-agent-harness/pyproject.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "pi-agent-harness-lc"
7-
version = "0.4.0"
7+
version = "0.5.0"
88
description = "AgentHarness runtime, session storage, and orchestration layer for pi-agent-core"
99
readme = "README.md"
1010
requires-python = ">=3.11"
@@ -25,7 +25,7 @@ classifiers = [
2525
"Typing :: Typed",
2626
]
2727
dependencies = [
28-
"pi-agent-core-lc==0.4.0",
28+
"pi-agent-core-lc==0.5.0",
2929
"pathspec>=0.12",
3030
"pydantic>=2.0",
3131
"PyYAML>=6",

0 commit comments

Comments
 (0)