From dc5da21f5aaa377c0baa14f824bbe1d2874edcb6 Mon Sep 17 00:00:00 2001 From: oliver Date: Mon, 13 Jul 2026 11:00:38 +0800 Subject: [PATCH] docs(skill): clarify write_file vs run_command for channel file delivery Guide the model to use run_command with openpyxl for xlsx exports instead of claiming the tool is unavailable. Co-authored-by: Cursor --- .../public/channel-file-delivery/SKILL.md | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/skills/_workspace/public/channel-file-delivery/SKILL.md b/skills/_workspace/public/channel-file-delivery/SKILL.md index b788da04..2bd3e9c5 100644 --- a/skills/_workspace/public/channel-file-delivery/SKILL.md +++ b/skills/_workspace/public/channel-file-delivery/SKILL.md @@ -1,6 +1,6 @@ --- name: channel-file-delivery -description: "在 WhatsApp/微信等渠道会话中,把生成的文件作为附件发回用户的流程。适用于:导出 Excel/CSV/TXT、run_command 生成报告后需要让用户在聊天里收到文件。" +description: "在 WhatsApp/微信等渠道会话中,把生成的文件作为附件发回用户。区分:write_file 仅文本(csv/txt);xlsx 等二进制用 run_command + save_deliverable_attachment。" --- # 渠道文件发送 — Channel File Delivery @@ -20,12 +20,32 @@ description: "在 WhatsApp/微信等渠道会话中,把生成的文件作为 3. **再用简短文字回复** 说明文件名与要点;系统会把标记为 deliverable 的附件随本条回复发到渠道。 +## 工具选择(文本 vs 二进制) + +| 目标格式 | 用哪个工具 | 说明 | +|----------|------------|------| +| `.csv`、`.txt`、`.md`、`.json` 等纯文本 | `write_file` | 只能写文本内容,不能生成二进制 | +| `.xlsx`、`.xls` 等 Excel | `run_command` | 用 Python(`openpyxl` 已安装)在 workspace 里生成 | +| 其他需脚本/命令产出的文件 | `run_command` | 生成后再走 deliverable 流程 | + +**不要声称没有 `run_command`。** 若用户要真 `.xlsx`,优先用 `run_command` 生成,不要只用 `write_file` 写 CSV 再说是「限制」。 + ## 推荐流程 +**文本文件(CSV/TXT):** + ```text -1. run_command 或 write_file → 生成 data/workspace/tmp/report.xlsx +1. write_file → data/workspace/tmp/report.csv +2. save_deliverable_attachment(path="data/workspace/tmp/report.csv", name="report.csv") +3. 文字回复:「已附上 report.csv…」 +``` + +**Excel(xlsx):** + +```text +1. run_command → python 写入 data/workspace/tmp/report.xlsx 2. save_deliverable_attachment(path="data/workspace/tmp/report.xlsx", name="report.xlsx") -3. 文字回复:「已附上 report.xlsx,共 N 行…」 +3. 文字回复:「已附上 report.xlsx…」 ``` ## Excel 示例 @@ -34,11 +54,14 @@ description: "在 WhatsApp/微信等渠道会话中,把生成的文件作为 用户:帮我把统计结果导出 Excel 发我 步骤: -1. run_command:用 pandas 写入 data/workspace/tmp/summary.xlsx -2. save_deliverable_attachment(path="data/workspace/tmp/summary.xlsx") +1. run_command(示例): + python -c "from openpyxl import Workbook; wb=Workbook(); ws=wb.active; ws.append(['姓名','数量']); ws.append(['A',10]); wb.save('data/workspace/tmp/summary.xlsx')" +2. save_deliverable_attachment(path="data/workspace/tmp/summary.xlsx", name="summary.xlsx") 3. 回复摘要(行数、主要结论) ``` +用户明确要 `.xlsx` 时,不要退化成只发 CSV,除非用户同意用 CSV 代替。 + ## 限制 - 每轮回复通常只发送**第一个**附件(约 8MB 上限)。