Files
agent/skills/x2pdf/INSTALL.md
T
kicer a52b227d8b 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 参数即通过。
2026-11-11 17:34:30 +08:00

34 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 本机安装渲染后端(x2pdf 技能)
两条渲染路径,依赖各不相同。`requirements.txt` 列的是 Python 包(服务器 init 也按它装)。
下文「技能目录」= `$(dirname "$AGENT_SKILLS_DEPS")/x2pdf`。
## 文本类(md / txt / html):默认 WeasyPrint
```bash
python3 -m pip install --target "$AGENT_SKILLS_DEPS" -r "$(dirname "$AGENT_SKILLS_DEPS")/x2pdf/requirements.txt"
```
WeasyPrint 除了 Python 包,还要系统库 pango/cairo:
- macOS:`brew install pango`
- Linux:见同目录 `install.sh`(apt 装 那串 `libpango*` / `libcairo2` / 字体)
**不想装 pango 也行**:装 LibreOffice(见下),技能在 WeasyPrint 不可用时(缺包或缺 pango 符号)
会自动回落到 LibreOffice 渲染文本。代价是 `page` 的边距/页码与大部分 CSS 不生效——够看,不够精确。
## Office 类(docx / xlsx / pptx / odt / ods / odp):必须 LibreOffice
- macOS:`brew install --cask libreoffice`
装完**不需要**把 `soffice` 加进 `PATH`,技能会自己找 `/Applications/LibreOffice.app/Contents/MacOS/soffice`。
- Linux:`apt-get install libreoffice-writer libreoffice-calc libreoffice-impress`(服务器镜像已预装)。
## 验证
```bash
python3 -c "import weasyprint, markdown" # 文本类(走 WeasyPrint)
/Applications/LibreOffice.app/Contents/MacOS/soffice --version # LibreOffice
```
两者都没有时,技能会报「这台机器没有可用的 PDF 渲染后端」。装完不需要重启 agent。