Skip to content

feat(crates/panache-mcp): 让客户端按需取回导出的 PDF 或 ZIP - #60

Merged
SXP-Simon merged 1 commit into
mainfrom
split/49-delivery
Nov 27, 2026
Merged

SXP-Simon merged 1 commit into
mainfrom
split/49-delivery

Conversation

@SXP-Simon

@SXP-Simon SXP-Simon commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

场景与改动

只从 stdio 回复取文件的客户端,以前能看见路径,却拿不到生成的 PDF 或 ZIP 字节。

导出时可设 include_file=true,从本次发布文件的句柄读取最多 512 KiB 原始内容。超过上限或读取失败时保留完整本机文件及导出回执,沿用主线 #31 的取件说明。

支持内嵌文件的客户端能取回所选版本的真实内容,再通过自己的附件入口交给用户。

独立验证

分别运行 uv run --script crates/panache-mcp/tests/export_file.py <main-binary> <worker> --baseline --out run-main 和 uv run --script crates/panache-mcp/tests/export_file.py <pr-binary> <worker> --out run-pr,再运行 python crates/panache-mcp/tests/compare_export_files.py run-main run-pr。需要 Poppler 的 pdfimages,两个输出目录须为新目录。

从 #49 拆出,直接基于 main@06cfd43,可以独立审查。来源提交为 73f1331、c990100、dd60477。

Summary by Sourcery

Enable export clients to retrieve small PDF and ZIP artifacts directly through MCP while retaining local-file fallback for larger or unreadable files.

New Features:

  • Add an include_file export option that embeds PDF or ZIP contents in MCP responses for supported clients, up to 512 KiB.
  • Expose file-transfer status and guidance for retrieving embedded, oversized, or unavailable exports.

Bug Fixes:

  • Preserve the published export file handle so embedded content is read from the exact artifact returned to the client.

Enhancements:

  • Update export documentation and tool guidance to distinguish embedded resources, local paths, and user-facing download links.

Documentation:

  • Document client behavior and retrieval guidance for embedded and locally stored export files.

Tests:

  • Add unit and end-to-end coverage for embedded exports, size limits, selected revisions, byte integrity, and fallback behavior.
  • Add a comparison script to verify candidate exports match baseline artifacts while only the candidate delivers supported files to the simulated client.

背景:只从 stdio 回复取文件的客户端,以前能看见路径,却拿不到生成的 PDF 或 ZIP 字节。

解决手段:导出时可设 include_file=true,从本次发布文件的句柄读取最多 512 KiB 原始内容。超过上限或读取失败时保留完整本机文件及导出回执,沿用主线 #31 的取件说明。

收益:支持内嵌文件的客户端能取回所选版本的真实内容,再通过自己的附件入口交给用户。
@sourcery-ai

sourcery-ai Bot commented Nov 26, 2026

Copy link
Copy Markdown

Reviewer's Guide

API

为导出工具公开 include_file 参数,并说明内嵌资源与本机路径的交付边界。

  • crates/panache-mcp/src/inputs.rs L324-327
  • crates/panache-mcp/src/main.rs L623

Uses of the API

在导出成功后按请求将已发布文件交给内嵌文件传输逻辑,同时保留导出回执和本机取件路径。

  • crates/panache-mcp/src/main.rs L643, L703-710

Implementation

让存储层返回本次发布文件的句柄,并从该句柄读取不超过 512 KiB 的内容,以资源块附加到工具回复;超限或读取失败时保留原导出结果并报告传输状态。

  • crates/panache-mcp/src/delivery.rs L1-95
  • crates/panache-mcp/src/main.rs L2
  • crates/panache-mcp/src/storage.rs L204, L240-242, L248

Documentation

说明客户端如何请求附件、如何理解传输状态,以及文件过大或客户端不支持内嵌文件时的取件方式。

  • crates/panache-mcp/README.md L107-108

Tests

验证存储导出调用适配新的返回值,并覆盖不可读句柄、大小边界及真实 stdio 导出文件的传输与内容一致性。

  • crates/panache-mcp/src/storage/tests.rs L47
  • crates/panache-mcp/tests/compare_export_files.py L1-38
  • crates/panache-mcp/tests/export_file.py L1-190

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@SXP-Simon

Copy link
Copy Markdown
Owner Author

拆分依据与实测

原 #49 留下的证据。 原试验实际打开正确文件,也验证“打开了错版”与“只有服务端路径”两个反例。Inspector 曾收到 PDF 字节却没有下载入口;测试客户端收件不代表所有聊天都出现按钮。 原 PR 说明 · 透明稿的生成与交付 · 版号与透明成品 · 查看器实点及无下载入口反例 · 认可小样与最终交付 · 组合树及宿主下载复验

本次独立分支验证(656819d)。 export_file.py 和 compare_export_files.py 对照当前 main 与本分支。只从回执收件时,打印 PDF、练习纸 ZIP、透明字迹 ZIP 从 0/3 到 3/3;含旧版对照的 4 份文件两边逐字节相同。第 2 版 PDF 为 32,704 B,1,639,341 B 的 ZIP 仅留本机。Rust 单测覆盖正好 512 KiB、超 1 字节及读取失败。

Rust 1.94.1 单独构建,目标 crate 的 18 项单元测试和 Clippy 均通过。 本次接收端为测试 SDK;没有在目标商业聊天客户端测下载按钮。 原版固定回放记录

七个分支都直接基于同一个 main 提交,21 对分支试合并均无冲突,正序和逆序七项合并得到相同文件树。组合后重新构建,18 个 MCP 单测通过,并核对握手、14 个工具的接口及相关的真实 stdio 场景。

@SXP-Simon
SXP-Simon marked this pull request as ready for review November 27, 2026 06:45
@sourcery-ai

sourcery-ai Bot commented Nov 27, 2026

Copy link
Copy Markdown

Sorry @SXP-Simon, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 2 days and 22 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@SXP-Simon
SXP-Simon merged commit fd44602 into main Nov 27, 2026
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.

1 participant