refactor(skills): 本地安装改成「README 式说明」,install.sh/requirements.txt 归服务器

按三条原则收紧:
1) 线上零影响:office/install.sh 回退成原来的 linux-only 版本(本地本来就不该跑它);
   image-process 的字体候选表撤回(那是在代码里写环境兼容,方向错了)。
2) install.sh / requirements.txt 只做服务器工件:镜像构建与 agent-executor-init 读它们,
   行为一字未变。
3) 本机缺东西时由 .md 指路,模型自己去装:四个技能各加 INSTALL.md(具体命令 + 平台
   资产/字体表 + 验证方式),并在 SKILL.md 里各加一行指向它(skill get 就能看到)。
   报错文案带上 INSTALL.md 的绝对路径,所以「撞到缺依赖」的那一刻就能拿到说明书。

保留的两处代码钩子都不是环境探测,而是「说明书里写的安装方式得真能生效」:
- office: start.sh 把 skills/office/scripts 塞进 PATH(本地没 root 写 /usr/local/bin);
  封装层 ENOENT 指向 INSTALL.md。
- x2pdf: find_soffice() 探 macOS app bundle(brew cask 装的 soffice 不在 PATH);
  WeasyPrint 不可用时回落 LibreOffice,让本地只需一个后端而不是 pango+WeasyPrint 两条链。

INSTALL.md 里 officecli 指向 releases/latest(它会自更新,实测 1.0.157 跑一次变 1.0.160),
不要求与服务器 pin 对齐。

实测:office --version / office create / office view outline 正常;x2pdf 缺 markdown 与
image-process 缺字体两条报错都给出 INSTALL.md 绝对路径,按 font 参数即通过。
This commit is contained in:
2026-11-11 17:34:30 +08:00
parent 317397154e
commit a52b227d8b
14 changed files with 194 additions and 83 deletions
+30
View File
@@ -0,0 +1,30 @@
# 本机安装依赖与字体(image-process 技能)
下文「技能目录」= `$(dirname "$AGENT_SKILLS_DEPS")/image-process`。
## Python 包:Pillow
```bash
python3 -m pip install --target "$AGENT_SKILLS_DEPS" \
-r "$(dirname "$AGENT_SKILLS_DEPS")/image-process/requirements.txt"
python3 -c "import PIL" # 验证
```
## 中文字体:只在 `watermark` 且文字含中文时需要
技能不内置字体,也不做跨平台查找,只认两条 Linux 路径(镜像里预装文泉驿)。
本机缺字体时报「中文水印缺少字体」,这时**传 `font` 参数**指向任意中文字体即可:
| 平台 | 常见字体路径 |
|---|---|
| macOS | `/System/Library/Fonts/Hiragino Sans GB.ttc`(简体,推荐)、`/System/Library/Fonts/PingFang.ttc` |
| Linux | `/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc` |
| Windows | `C:\Windows\Fonts\msyh.ttc` |
```json
{"action":"watermark","input":"a.jpg","text":"机密",
"font":"/System/Library/Fonts/Hiragino Sans GB.ttc"}
```
英文/数字水印不需要字体(走 Pillow 内置默认字体)。其余动作(info / convert / resize / crop /
compress / slice / grid)只依赖 Pillow。
+2 -2
View File
@@ -106,5 +106,5 @@ output_schema:
- 本技能**只做确定性图像处理**(转换/缩放/裁剪/压缩/水印/拼图),不含 AI 生成、抠图、换脸、扩图、修复等生成式/语义编辑能力。
- 若用户的需求属于"文生图 / AI 修图"等生成式范畴,不要用本技能硬凑,应说明能力边界并推荐第三方工具(豆包、即梦、可灵、Photoshop 等)。
- 任何操作都不会覆盖输入原图;输出目录不存在时自动创建。
- 中文水印需要字体:优先用 `font` 参数指定;否则依赖系统字体(镜像预装文泉驿,install.sh 会兑底安装)。
- 输入依赖预装的 Pillow,无需额外 Python 依赖;系统级字体依赖见 install.sh。
- 中文水印需要字体:优先用 `font` 参数指定;否则依赖系统字体(镜像预装文泉驿)。
- 输入依赖 Pillow;本机缺 Pillow 或字体时按同目录 `INSTALL.md` 自己装(服务器由镜像 + `requirements.txt` 提供)。
+2 -9
View File
@@ -34,16 +34,8 @@ NAMED_COLORS = {
'purple': (128, 0, 128), 'cyan': (0, 255, 255),
}
CJK_FONT_CANDIDATES = [
# 服务端镜像:文泉驿优先(Pillow 优先若用 Noto 的 ttc,索引 0 是 JP 字型)
'/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc',
'/usr/share/fonts/truetype/wqy/wqy-microhei.ttc',
# 本地端:macOS/Windows 的中文字体不在上面这些路径里。
# 索引 0 的字面不同:Hiragino Sans GB 是简体(W3 常规),PingFang.ttc 是 HK 字形,Songti 是 Black。
'/System/Library/Fonts/Hiragino Sans GB.ttc',
'/System/Library/Fonts/PingFang.ttc',
'/System/Library/Fonts/Supplemental/Songti.ttc',
r'C:\Windows\Fonts\msyh.ttc',
r'C:\Windows\Fonts\simsun.ttc',
]
# Noto 只作最后兑底:Pillow(FreeType) 能读它的 CFF 轮廓,但 ttc 默认字型(索引 0)是 JP 字形,
# 中文水印会出日式写法;因此系统文泉驿(CJK_FONT_CANDIDATES)排在它前面。
@@ -257,7 +249,8 @@ def action_watermark(img, fmt, args):
if font_path:
font = ImageFont.truetype(font_path, font_size)
elif need_cjk:
raise ValueError('中文水印缺少字体:传 font 参数指定 TTF/TTC 路径即可(系统字体列表里没找到中文字体)')
raise ValueError('中文水印缺少字体:传 font 参数(TTF/TTC 路径);各平台常见字体路径见 %s'
% (Path(__file__).resolve().parent / 'INSTALL.md'))
else:
try:
font = ImageFont.load_default(size=font_size)