跳到正文
Skillpedia
写作53k · #3391

office-transform

它能做什么

这个工具可以从现有文件的某个选定部分,创建一个新的文档文件(例如 Excel、Word、PDF 或 PowerPoint)。原始文件永远不会被修改。

适用场景

  • ✓把电子表格中的一张表格复制到新文件中。
  • ✓把 Word 文档中的某一段落提取到新文件中。
  • ✓把演示文稿中的某一页幻灯片转换为新文件。

技能链接

https://github.com/CherryHQ/cherry-studio/blob/main/resources/skills/office-transform/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/CherryHQ/cherry-studio/blob/main/resources/skills/office-transform/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请把“Sales”工作表中 A 到 C 列、第 5 到 20 行的数据,新建一个 Excel 文件。”

每周 5 个新技能,1 分钟读完。

工作原理

你先选中文档的某个部分(例如电子表格中的一个区域,或 Word 中的一个段落)。然后,这个工具会读取选中的内容,并创建一个全新的文件来存放这些内容,同时保证原始文件不受影响。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Office Transform

Turn a structural selection of an Office/PDF document into a new derived file.

Two invariants hold for every operation:

  1. The source file is read-only. Every result is a new file; both scripts refuse to write to the source path or overwrite an existing file. Never work around this with ad-hoc shell edits to the original.
  2. Anchors are structural. Selections address the document's own coordinates — worksheet + A1 range, body-level paragraph ordinal, one-based page number — never screen or DOM positions.

When to use which tool

  • Only need to read a document to summarize or answer questions → use mcp__cherry-tools__to_markdown instead (see the cherry-tool-guide skill); it is lossy but built for reading.
  • The user wants a file out — an extracted range, a converted fragment, an edited copy → this skill.

Input: selection references

Chat surfaces may hand you a fenced selection-ref block:

{"path": "/abs/report.xlsx", "anchor": {"format": "xlsx", "sheet": "Sheet1", "range": "A1:C10"}, "excerpt": "…", "fileStamp": {"size": 1024, "mtimeMs": 1700000000000}}

The anchor object is exactly what the scripts take via --anchor.

Freshness check. fileStamp.mtimeMs is milliseconds since the Unix epoch, floored to whole milliseconds. Do not compare it to stat's default output: stat -f %m (macOS) and stat -c %Y (GNU) give whole seconds, so multiplying by 1000 loses the sub-second part and never matches. Read whole milliseconds the way the app wrote them:

uv run python -c "import os,sys;st=os.stat(sys.argv[1]);print(st.st_size, st.st_mtime_ns//1_000_000)" '/abs/report.xlsx'

Treat the file as changed when the size differs, or when the mtimes differ by more than 2 ms. The tolerance is small on purpose: both sides floor the same nanosecond timestamp to milliseconds, so they agree exactly, and the couple of milliseconds only covers the rounding of a double that can no longer represent current epoch milliseconds exactly. A wider window would hide real edits — a same-size change made within it would read as unchanged, which is why the anchor check below is not optional. On a change, tell the user the file changed since they selected and ask them to re-select — never silently re-anchor.

Anchor check. Before a patch-copy edit, also verify the anchor still points where the user thinks: extract the anchored region and compare its text with the reference's excerpt, normalizing both sides the same way (NFC, collapse each whitespace run to one space, trim). The two are not equal and are not meant to be — the excerpt is what the user selected, while the extract is the whole region an edit would replace. A selection sitting inside one region makes the excerpt the shorter side; a selection running past that region anchors to where it starts, which makes it the longer one. So the test is containment, whichever way round fits: the excerpt appears inside the extract, or the extract's tail is where the excerpt begins. Only when neither holds has the anchor stopped pointing at the selection — then stop and tell the user, never edit at a mismatched anchor and never go searching for a "close enough" location. Two cases need care because the two sides are not directly comparable as-is:

  • xlsx: the excerpt is tab-separated cells and newline-separated rows, while extraction writes csv or md. Compare cell values, not the raw file — read the csv with a csv reader and join the fields with single spaces before normalizing, so , and | never count as a difference. That join drops the cell boundaries on both sides, so a match proves the text is unchanged, not the grid — the same words re-split across cells still reads as a match. The freshness check above is what catches that; never skip it on a passing anchor check. Number formats are the second asymmetry: the excerpt holds what Excel displays, because that is what the user pointed at (1,234.50, 45.67%), while extraction writes the stored value (1234.5, 0.4567). Neither side is wrong, so a formatted cell never matches literally. Compare those cells by value, and leave them out of the joined strings so the containment test runs on the text cells alone. Dates, times and durations are the same asymmetry seen from the other side: extraction writes one fixed shape (2024-01-03,

…

常见问题

原始文件会怎样?

原始文件始终保持原样。这个工具不会修改或覆盖它。

我可以编辑原始文件吗?

不可以。这个工具对源文件是只读的,所有操作都会生成一个新文件。

工具怎么知道我想要文档中的哪一部分?

你可以直接在文档中选择,也可以描述范围(例如“工作表 X,A 到 C 列”)。工具会利用这些信息,精确定位要复制的内容。

详情

作者的原始描述

Derive new Office files from structural selections without touching the original. Use when the user points at part of a spreadsheet, Word document, PDF, or PowerPoint deck (a worksheet range, paragraph, page, slide, shape, or a pasted selection-ref block) and wants it extracted, converted, or edited — the result is always a NEW file; the source file is never modified. Covers xlsx range extraction

repo: CherryHQ/cherry-studio

热度

GitHub 星标
53k
排名
#3391
许可证
AGPL-3.0
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能