Skip to content

feat(crates/panache-mcp): 文字作业默认用李国夫手写体和轻微笔迹变化 - #66

Merged
SXP-Simon merged 1 commit into
mainfrom
feat/homework-handwriting-defaults
Nov 27, 2026
Merged

SXP-Simon merged 1 commit into
mainfrom
feat/homework-handwriting-defaults

Conversation

@SXP-Simon

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

Copy link
Copy Markdown
Owner

使用场景

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

改后怎么用

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

{"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:

  • 补充作业默认字体、手写变化、覆盖选项及不同底纸场景的测试,并更新无旧稿列表查询测试。

背景:原先只有照片作业会自动选择李国夫手写体,纯文字作业经常仍以文楷排版。

解决手段:按新稿的作业用途选择字体并保存轻微字号与倾角变化,沿用现有调参入口,补充从正文建稿的工具提示。

收益:用户无需准备照片或点名字体就能得到作业小样,也可显式选择更工整的字迹。
@sourcery-ai

sourcery-ai Bot commented Nov 27, 2026

Copy link
Copy Markdown

Reviewer's Guide

Data structures

Add the optional handwriting-variation setting to the style data and default it to unset, so creation can resolve it without changing older saved styles.

  • crates/panache-mcp/src/inputs.rs L51-55, L72

API

Update the save-tool contract to describe homework defaults and the option to request steadier handwriting.

  • crates/panache-mcp/src/inputs.rs L156-158
  • crates/panache-mcp/src/main.rs L431

Uses of the API

Guide the model to mark homework at creation and to start a new assignment directly from provided text when no drafts exist.

  • crates/panache-mcp/src/main.rs L279-281, L463-465

Implementation

Resolve homework font and variation defaults at creation, and apply the larger size and tilt variation only when the saved style enables it.

  • crates/panache-mcp/src/controls.rs L121-124
  • crates/panache-mcp/src/inputs.rs L120-130
  • crates/panache-mcp/src/save.rs L44 (removed lines), L47

Documentation

Explain how to create homework without a paper photo and how to opt for steadier handwriting.

  • crates/panache-mcp/README.md L59-60

Tests

Check creation-time variation defaults, overrides, legacy behavior, and homework font selection across paper types.

  • crates/panache-mcp/src/save.rs L135-175, L188-197

Verify the empty-draft listing includes the new guidance for creating homework from supplied text.

  • crates/panache-mcp/tests/list_drafts.py L55-56

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
SXP-Simon marked this pull request as ready for review November 27, 2026 06:58
@SXP-Simon
SXP-Simon merged commit a3928c0 into main Nov 27, 2026
@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 added a commit that referenced this pull request Nov 27, 2026
## 用户碰到了什么

用户说「帮我把下面的作业写好,先看第一页。第一题:循环从 i = 1 开始,直到 i = 10 结束。」Luna
把“第一页”理解成已有作业的第一页,于是查找本地旧稿。查空后它让用户补照片;有其他作业时,它有时打开了不相关稿件的预览。#66
的默认作业字体要在建稿时才生效,这次问题发生得更早。

## 改动

调整 MCP 启动说明,以及 `save_section`、`list_drafts`
的工具说明。用户在聊天里贴了新题目或正文并要求查看第一页时,先建稿,再按返回的稿件编号预览。用户明确要找回或继续编辑已存稿件时,使用旧稿入口。只改一个
Rust 文件,没有增加工具或参数。

## 真实 Luna 对照

Windows,真实 stdio MCP、`gpt-6-luna`、低推理强度。基线是合并 #66 后的
`main@a3928c0`。每格三次独立会话,完整转发启动说明,用户正文和模型配置相同。两份预置稿为《实验作业》和《周会通知》,每次从同一初始数据库的副本开始。

| 场景 | main | 第一版通用英文说明 | 最终草稿 |
| --- | ---: | ---: | ---: |
| 用户给出上面的原话,稿库为空,直接建稿并预览 | 0/3 | 0/3 | 3/3 |
| 同一句原话,库里有其他稿,直接生成新稿并预览 | 0/3 | 1/3 | 3/3 |
| 「继续改上次那份《实验作业》」,找到原稿、改对并预览 | 3/3 | 3/3 | 3/3 |

新建验收核对了第一步是否调用
`save_section`、只有一个新增编号、已存稿无变化,以及返回的第一页图片是否属于新稿。续改验收核对原编号、温度从 18 度改为 21
度、同页的日期仍为周三、另一份稿件完整保留,以及预览对应修改后版本。单独看到“调用了预览”不算通过:第一版曾成功预览无关旧稿,计为失败。

第一轮在握手开头和两个工具描述里加入了中文引导。与第一版英文同时有位置和含义的差异,这组结果不足以归因于语言。

**等义英文复验(5d3ea00)。**
保持提示位置、用途和模型配置相同,另开独立会话对照中文候选和当前全英文新增说明。用户始终用同一句中文提问。中文候选和等义英文在空库建稿各
3/3、有无关旧稿时新建各 3/3、续改原稿各 3/3。英文另测省略启动说明的三种情况 6/6,以及换一种中文说法新建 2/2。最终提交将本
PR 新增的三处说明统一为英文。此批小样本没有观察到需要混用两种语言的收益。

## 补充验证与边界

- 只给工具目录、省略启动说明重测上述三种情况,每种各 2 次,最终版 6/6 通过。再将新稿请求换成「作业正文给你:温度从 10 ℃ 升至
15 ℃。排成手写稿,第一页给我瞧瞧。」,有旧稿时 2/2 直接建稿并预览。
- 从首次提交构建并读取真实握手及 14 个工具的完整目录,与行为实验使用的最终候选一致。格式、20 项 MCP 单元测试、Clippy
通过;与 #56 本地试合无文本冲突。
- 这些结果只覆盖本次 Luna、小样本中文请求。工具说明影响的是模型的选择,服务端仍允许调用者按需查稿。

## Summary by Sourcery

Ensure new writing requests create the intended draft before its first
page is previewed, while preserving explicit saved-draft continuation
behavior.

Bug Fixes:
- Clarify draft selection so requests containing new text or problems
create and preview a new draft instead of opening an unrelated saved
draft.

Enhancements:
- Align MCP startup and tool guidance so saved drafts are searched only
when users explicitly request continuation or recovery of earlier work.
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