Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 未发布

- MCP 在作业和实验报告的笔迹建议中区分松散笔迹与偶发涂改,指明对应调节项和预览方法。

## v1.21.0 (2026-11-24)

- 在「关于与反馈 → 支持作者」可查看随应用提供的微信赞赏码。官网首页也可直接扫码支持 Simon。
Expand Down
6 changes: 3 additions & 3 deletions crates/panache-mcp/src/controls.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@
"word_spacing_sigma": {"type":"number","min":0,"max":100,"unit":"px"},
"perturb_x_sigma": {"type":"number","min":0,"max":100,"unit":"px"},
"perturb_y_sigma": {"type":"number","min":0,"max":100,"unit":"px"},
"perturb_theta_sigma": {"type":"number","min":0,"max":3.14,"unit":"rad"},
"perturb_theta_sigma": {"type":"number","min":0,"max":3.14,"unit":"rad","description":"Variation in glyph tilt. For a slightly hurried hand keep the font and seed; try increasing the current value by 0.02 rad, then preview the same line and check digits, units and alignment. perturb_x_sigma and perturb_y_sigma vary position in paper-space pixels."},
"ink_depth_sigma": {"type":"number","min":0,"max":255,"unit":"intensity"}
},
"strike": {
"strikethrough_probability": {"type":"number","min":0,"max":1,"unit":"probability"},
"strikethrough_probability": {"type":"number","min":0,"max":1,"unit":"probability","description":"For requested occasional corrections: randomly insert a crossed-out extra character before the intended text when monospaced=false. Try 0.005 for a sparse sample; a short page may have none. Compare the same line with only probability changed; confirm a visible crossed-out character before reporting one. Check reflow and numbers. For a looser hand alone, leave this unchanged. Exact placement on a chosen word is unsupported; Markdown ~~text~~ is stripped to text."},
"strikethrough_width": {"type":"number","min":0,"max":100,"unit":"px"},
"strikethrough_length_sigma": {"type":"number","min":0,"max":100,"unit":"px"},
"strikethrough_width_sigma": {"type":"number","min":0,"max":100,"unit":"px"},
"strikethrough_angle_sigma": {"type":"number","min":0,"max":3.14,"unit":"rad"}
"strikethrough_angle_sigma": {"type":"number","min":0,"max":3.14,"unit":"deg"}
}
}
5 changes: 3 additions & 2 deletions crates/panache-mcp/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ impl ServerHandler for Panache {
.with_instructions(concat!(
"If a required area of a photo is outside the frame, or blur, occlusion or perspective prevents locating it, identify that area before drafting. ",
"Ask for a photo clearly showing it or permission to fill only visible areas; wait before saving or trial placement. If partial work was requested, proceed there. ",
"For looser, less uniform homework or lab handwriting (字稍微草一点), inspect describe_controls(group=variation). For requested crossed-out mistakes (涂改痕迹), inspect group=strike. ",
"Use save_section(markdown), then its draft_id and revision for preview_handwriting or export_handwriting. ",
"English letters and digits follow the main font by default. Leave Latin controls unset unless the user requests a different look for them or dislikes how they appear. For an undecided homework or lab-report style, see list_fonts for sample guidance. Use list_drafts to resume. A paper_path must be readable on the server computer. ",
"For photos use preview_handwriting(view=review). Follow photo_appearance.preview_arguments for a native detail crop when available. ",
Expand All @@ -148,7 +149,7 @@ impl ServerHandler for Panache {
impl Panache {
#[tool(
annotations(read_only_hint = true, open_world_hint = false),
description = "Discover handwriting settings by group. Omit group for an index; request one group before tuning."
description = "For less even handwriting, inspect group=variation; for requested occasional crossed-out mistakes, group=strike. Pass draft_id to read current values before tune_handwriting. Omit group for the index."
)]
fn describe_controls(&self, Parameters(input): Parameters<Describe>) -> CallToolResult {
tool_result((|| {
Expand Down Expand Up @@ -243,7 +244,7 @@ impl Panache {
"For a hurried pen style, try 李国夫手写体.ttf if listed. Use a short line from the task with Chinese, an English term and a number or unit. ",
"Preview it at the intended size on the intended paper. Compare stroke weight, slant, relative size and digit legibility. ",
"If the style is undecided, show the sample, recommend a font based on what is visible, and ask if it fits before laying out the full page. ",
"Honor an approved or delegated main font. A request for generally messier handwriting applies to the main font. Only consider separate settings for letters or digits when the user specifically requests them or expresses dissatisfaction with their appearance; then inspect describe_controls(group=typography)."
"Keep an approved font. For a less regular hand inspect describe_controls(group=variation) and preview a small change. If the user wants occasional corrections, inspect group=strike. Only consider separate settings for letters or digits when the user specifically requests them or expresses dissatisfaction with their appearance; then inspect describe_controls(group=typography)."
);
let mut data = json!({
"entries": page.fonts, "total": page.total,
Expand Down
25 changes: 25 additions & 0 deletions crates/panache-mcp/tests/smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,25 @@ async def mixed_script_sample(client):
assert png(await call(client, "preview_handwriting", **key)) == primary


async def handwriting_variation_sample(client):
markdown = "样品 A 的质量为 12.5 g。"
saved = (await call(client, "save_section", markdown=markdown, style={"seed": 17})).structuredContent
key = {"draft_id": saved["draft_id"]}
base = png(await call(client, "preview_handwriting", **key))
await call(client, "tune_handwriting", **key, expected_revision=1, changes={"perturb_theta_sigma": 0.07})
loose = png(await call(client, "preview_handwriting", **key))
assert loose != base
strike = (await call(client, "describe_controls", **key, group="strike")).structuredContent
assert strike["values"]["strikethrough_probability"] == 0
assert strike["controls"]["strikethrough_angle_sigma"]["unit"] == "deg"
# Force the optional effect for a deterministic positive control on a short line.
await call(client, "tune_handwriting", **key, expected_revision=2, changes={"strikethrough_probability": 1})
assert png(await call(client, "preview_handwriting", **key)) != loose
assert png(await call(client, "preview_handwriting", **key, revision=2)) == loose
source = (await call(client, "read_section", **key, view="source")).structuredContent
assert source["markdown"] == markdown


async def placement_pixels(client):
saved = (await call(client, "save_section", markdown="字", style={"seed": 17})).structuredContent
key = {"draft_id": saved["draft_id"]}
Expand Down Expand Up @@ -190,6 +209,7 @@ async def smoke(command, arguments, out):
assert "outside the frame" in before_save and "wait before saving" in before_save
assert "partial work was requested" in before_save
assert "ask which field" in info.instructions
assert "group=variation" in info.instructions and "group=strike" in info.instructions
tools = await client.list_tools()
assert {t.name for t in tools.tools} == {
"annotate_review",
Expand All @@ -209,6 +229,10 @@ async def smoke(command, arguments, out):
listed = await call(client, "list_fonts")
guidance = listed.structuredContent["sample_guidance"]
assert guidance in listed.content[0].text
for group, name in [("variation", "perturb_theta_sigma"), ("strike", "strikethrough_probability")]:
assert f"group={group}" in guidance
spec = (await call(client, "describe_controls", group=group)).structuredContent
assert spec["controls"][name]["description"]
assert "志莽行书.ttf" in listed.structuredContent["fonts"]
results = (await call(client, "list_fonts", source="user", query="localsample", limit=1)).structuredContent
assert results["total"] == 1 and results["next_offset"] is None
Expand Down Expand Up @@ -310,6 +334,7 @@ async def smoke(command, arguments, out):
)
assert failed.isError
await mixed_script_sample(client)
await handwriting_variation_sample(client)
await placement_pixels(client)
await coursework_form.exercise(client, Path(temp))
comparison_key, reviewed_id, user_quote = await review_comparison.exercise(client, Path(temp), call)
Expand Down
4 changes: 3 additions & 1 deletion crates/panache-mcp/tool-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

在 AI 客户端登记 Panache 的 stdio 配置后,调用 `list_fonts`。能列出本机字体,就可以试写第一行。用 `save_section` 传入 Markdown,记下返回的 `draft_id` 和 `revision`,再用这两个值调用 `preview_handwriting`。**省略预览的 `view` 时,返回这版手稿的单页 PNG。** 指定节和页时从 1 开始计数。

作业或实验报告适合直接拿一句正文试字,比如“样品 A 的质量为 12.5 g”。新稿只选主字体,英文和数字默认跟随它。如果用户想要整体再潦草一些,先换主字体。在目标纸张和字号下看看:中文和英文的笔画粗细是否协调?`12.5` 和单位能否一眼辨认?风格未定时,把小样给用户看,说清推荐理由,再问“这种笔迹可以用在整份报告里吗?”用户已经定好或委托选字时,就继续排版。
作业或实验报告适合直接拿一句正文试字,比如“样品 A 的质量为 12.5 g”。新稿只选主字体,英文和数字默认跟随它。用户已经选定字体,想要“稍微草一点”时,保留主字体和种子,用 `describe_controls(group="variation", draft_id=…)` 查看当前值。例如将 `perturb_theta_sigma` 从 0.05 调到 0.07 弧度,比较同一行改前改后的倾斜、数字和单位。也可少量调整 `perturb_x_sigma` 和 `perturb_y_sigma` 改变字的位置。在目标纸张和字号下看看:中文和英文的笔画粗细是否协调?`12.5` 和单位能否一眼辨认?风格未定时,把小样给用户看,说清推荐理由,再问“这种笔迹可以用在整份报告里吗?”用户已经定好或委托选字时,就继续排版。

用户明确要“偶尔像写错了又划掉”时,用 `describe_controls(group="strike", draft_id=…)`,在非等宽排版中可试 `strikethrough_probability=0.005`。引擎随机插入一个带划痕的额外字符,后面仍写正确内容。短页可能一次也没有。只调整这个概率后,对照同一行的两版预览,看到划痕才报告出现过涂改,同时检查换行和读数。要划掉指定词时应说明当前能力只提供随机位置,Markdown 的 `~~词~~` 在准备正文时会变成普通文字。

只有用户对英文或数字单独提出要求,才需要查 `describe_controls(group="typography", draft_id=…)`。编辑旧稿时,省略参数会保留原设置。要撤销以前的西文字体和缩放,可以给 `tune_handwriting` 传这组 `changes`:

Expand Down