Skip to content

feat(crates/panache-mcp): 按需返回笔迹参数的实际改前改后值 - #59

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

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

Conversation

@SXP-Simon

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

Copy link
Copy Markdown
Owner

场景与改动

调参后只看到原始设置时,客户端需要再读一次才能确认实际值,尤其是清除覆盖、恢复继承值时。

在调参调用中可用 readback_variation 指定一至两个本次提交的笔迹变化控件;保持主线的无变化回执和版号校验。

已知目标值时,写入回执本身就可核对生效结果;相对调整仍可先读当前设置。

独立验证

构建本分支的 panache-mcp,运行 uv run --script crates/panache-mcp/tests/variation_readback.py <binary>。 配置本地字体和已生成的 Markdown worker,或设置 PANACHE_FONT_DIR 和 PANACHE_MARKDOWN_WORKER。

从 #49 拆出,直接基于 main@06cfd43,可以独立审查。来源提交为 040fdd7。

Summary by Sourcery

Add optional effective-value readbacks to handwriting tuning receipts for selected variation controls.

New Features:

  • Allow handwriting tuning requests to optionally return before-and-after effective values for up to two changed variation controls, including inherited-value resets.

Enhancements:

  • Preserve existing no-op receipts and revision validation while adding optional effective-change reporting.
  • Document when to use variation readbacks versus reading current controls first.

Documentation:

  • Document the optional variation readback workflow and effective-change receipt semantics.

Tests:

  • Add an independent integration script covering effective-value reporting, resets, no-ops, unchanged values, validation failures, and default receipts.

背景:调参后只看到原始设置时,客户端需要再读一次才能确认实际值,尤其是清除覆盖、恢复继承值时。

解决手段:在调参调用中可用 readback_variation 指定一至两个本次提交的笔迹变化控件;保持主线的无变化回执和版号校验。

收益:已知目标值时,写入回执本身就可核对生效结果;相对调整仍可先读当前设置。
@sourcery-ai

sourcery-ai Bot commented Nov 26, 2026

Copy link
Copy Markdown

Reviewer's Guide

API

Add the optional readback_variation argument to Tune, limiting requests to two variation-control keys.

  • crates/panache-mcp/src/inputs.rs L153-156

Implementation

Validate requested keys, capture effective values before and after applying changes, and include only changed before/after pairs in the success receipt while preserving no-op behavior.

  • crates/panache-mcp/src/tuning.rs L75-90, L120-139, L163-167

Documentation

Explain how to request effective-value readback and when a separate control read is still needed.

  • crates/panache-mcp/README.md L137-138

Tests

Exercise effective-value receipts for direct changes, resets, no-ops, unchanged effective values, and invalid requests, checking results against independent reads.

  • crates/panache-mcp/tests/variation_readback.py L1-117

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 留下的证据。 原 PR 的四个任务合计 15→12 次真实工具调用,省掉的是三次写后复核。相对任务仍先查询,不能据此承诺每次都少一次。 原 PR 说明 · 调参回执与四个模型任务 · 与主线说明的组合复验

本次独立分支验证(27d5628)。 variation_readback.py 独立读回两版参数核对单项、两项及恢复继承值;嵌套参数重复写同值返回 changed=false 且不升版,未请求时不带额外字段。四种无效请求未改数据库。

Rust 1.94.1 单独构建,目标 crate 的 16 项单元测试和 Clippy 均通过。 本次独立复验测的是接口返回值;15→12 是原 PR 的模型数据。

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

SXP-Simon added a commit that referenced this pull request Nov 27, 2026
## 使用场景

用户只贴一段文字,说「请把这段文字排成一份手写作业」。#64
已能为照片作业选用李国夫手写体,但同一份作业换成白纸时仍会落回文楷。底纸负责落字位置,是否是作业由聊天里的请求决定。

## 改后怎么用

AI 收到作业请求时,在首次 `save_section` 传 `style.homework=true`
即可。用户无需准备纸张照片、点名字体或先调参数。纯文字、预设纸、照片和拉正底纸采用同一套作业默认值。普通通知或便笺仍用普通稿默认值。如果模型先查旧稿,首次查询为空时也会说明如何直接用已给的正文建稿。

```json
{"markdown":"第一题:观察循环中 i 的变化。\n当 i = 10 时,记录结果为 20 cm。","style":{"homework":true}}
```

- 有随包字体时优先选李国夫手写体。显式指定的文楷、个人字体等优先,缺少李国夫时沿用原有字体回退。
- 基于已有的逐字随机变化:字号的标准差从 **1 px 到 1.5 px**,倾角的标准差从 **0.05 到 0.07 弧度**(约
2.9° 到 4.0°)。字间距、行距、横纵偏移、墨色和涂改均沿用原值。数字和字母沿用主字体。
- 想要工整小样,创建时可设 `relaxed_handwriting=false`。已有稿继续用保存时的字体、变化幅度和种子。单项参数仍可通过
`tune_handwriting` 调整,清除覆盖值会恢复建稿时的手感。

## Windows 本机验证

基线 `main@fd44602`。使用真实 stdio MCP,把相同正文、34 px 字号和相同随机种子 60
分别渲染成文楷、只换李国夫、李国夫加轻微变化三份样张。后两张有 **5,020
个像素不同**,主要风格差别来自字体。这个数字只验证变化确实参与出图。预览后导出 1 页 PDF。


新程序重开旧程序创建的纯文字作业和照片作业,重新渲染结果均逐像素相同。新稿固定种子重复渲染相同,普通便笺与基线相同。覆盖上述两项数值后与「只换字体」小样完全相同,清除覆盖后与新默认小样完全相同。另验证照片与拉正底纸的实际参数、缺少字体与显式选字。20
项 MCP 单元测试、Clippy 和格式检查通过;真实稿件列表分页脚本通过。

## Luna / Terra 实测


用独立会话和新数据库,不给纸张或字体提示。真实工具回执和图片向模型开放,转发器省略启动说明,检查实际建稿参数和数据库记录。每个模型、每种措辞、每个受测版本各一次。

| 用户给的任务 | 当前 main | 此稿 |
| --- | --- | --- |
| 明确说「请把这段文字排成一份手写作业,生成第一页给我预览」 | 两者都启用作业排版、都省略字体,首张均是文楷 |
两者同样省略字体,首张均是李国夫,且均已启用轻微扰动 |
| 「帮我把下面的作业写好,先看第一页」后附文字 | 两者都去找旧稿,均未建稿 | Terra 用给定文字建稿并实际预览;Luna 仍要求补材料
|
| 作业明确要求文楷、工整 | — | 两者都保存文楷、关闭额外扰动,并预览 |
| 普通会议便笺 | — | Terra 用文楷及普通排版;Luna 停在查旧稿 |

边界是调用者须将用户的作业意图传入
`homework`。服务端不会根据正文里出现「第一题」等词强行分类。上述会话用于复现操作路径,不能当作整体成功率。与
#56(新手和选版提示)、#59(按需回读控件)分别本地试合,无文本冲突。

## Summary by Sourcery

为文字作业统一应用手写字体和轻微笔迹变化默认值,并完善作业创建与恢复提示。

New Features:
- 为纯文字、预设纸和照片底纸的作业创建统一的默认手写风格,优先使用随包的李国夫手写体并启用轻微字形变化。
- 新增 `relaxed_handwriting` 创建选项,允许用户关闭作业字形的额外大小和倾斜变化。
- 在无旧稿且用户已提供作业正文时,提示客户端直接创建并预览作业。

Bug Fixes:
- 修正作业字体默认值仅在照片底纸场景生效的问题,使其适用于所有底纸类型。

Enhancements:
- 将作业字体与手写变化参数在创建时固定保存,确保已有稿件和后续重新渲染保持一致,并继续支持显式字体和参数覆盖。

Documentation:
- 更新 MCP 使用说明和工具提示,说明如何创建文字作业、选择字体及控制手写变化。

Tests:
- 补充作业默认字体、手写变化、覆盖选项及不同底纸场景的测试,并更新无旧稿列表查询测试。
@SXP-Simon
SXP-Simon marked this pull request as ready for review November 27, 2026 07:37
@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 21 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@SXP-Simon
SXP-Simon merged commit 20c4a2b into main Nov 27, 2026
1 check passed
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