refactor(skills): 本机环境说明改放技能目录的 AGENTS.md,启动器不再特判任何技能

上一版把安装说明写成 INSTALL.md 并在 SKILL.md 里加段落,两处都不对:SKILL.md 是用法说明,
不该塞安装内容;启动器为 office 单独注入 PATH 也不成立,再加技能就得逐条改 start.sh。

- 删除 4 个 INSTALL.md,改为各技能目录下的 AGENTS.md(只写命令:下载/安装/验证、
  平台资产名、字体路径),SKILL.md 恢复原样
- start.sh 去掉 office 的 PATH 注入;技能要命令入口时由 AGENTS.md 指导按次前缀
  (PATH="$SK/scripts:$PATH" office ...)。启动器只保留 AGENT_SKILLS_DEPS 这个路径变量
- 找不到依赖时的指路不放在 core 里做特征匹配,而是各自报错带自己 AGENTS.md 的绝对路径
  (office 封装层 ENOENT / x2pdf 缺包或无后端 / image-process 缺字体)
- env-local 提示词加一句:技能失败就读其目录下的 AGENTS.md

实测:无 PATH 时 office 报 command not found,按 AGENTS.md 加前缀后 --version 正常;
三条缺依赖报错均给出 AGENTS.md 绝对路径。
This commit is contained in:
2026-11-11 19:12:01 +08:00
parent a52b227d8b
commit 4e1c1f36d0
19 changed files with 130 additions and 184 deletions
+30
View File
@@ -0,0 +1,30 @@
# x2pdf:本机环境
```sh
SK="$(dirname "$AGENT_SKILLS_DEPS")/x2pdf"
```
## 文本类 md / txt / html
```sh
python3 -m pip install --target "$AGENT_SKILLS_DEPS" -r "$SK/requirements.txt"
brew install pango # macOS;Linux 的系统库见 install.sh
```
不装 pango 也能用:技能在 WeasyPrint 不可用时回落 LibreOffice,代价是 `page` 的边距/页码与部分 CSS 不生效。
## Office 类 docx / xlsx / pptx / odt / ods / odp
必须有 LibreOffice(文本类也可用它渲染):
```sh
brew install --cask libreoffice # macOS:soffice 在 app bundle 内,技能会自己找到
apt-get install libreoffice-writer libreoffice-calc libreoffice-impress # Linux(镜像已预装)
```
## 验证
```sh
python3 -c "import weasyprint, markdown"
/Applications/LibreOffice.app/Contents/MacOS/soffice --version
```
-33
View File
@@ -1,33 +0,0 @@
# 本机安装渲染后端(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。
-5
View File
@@ -90,8 +90,3 @@ output_schema:
```json
{"input": "layout.html", "css": "print-override.css"}
```
## 环境
缺渲染后端时按同目录 `INSTALL.md` 自己装(文本类 WeasyPrint/或 LibreOffice;Office 类必须 LibreOffice)。
服务器由镜像 + `requirements.txt` / `install.sh` 提供,本机不要跑 `install.sh`。
+1 -1
View File
@@ -51,7 +51,7 @@ def find_soffice():
def req_hint():
return '安装步骤: %s(依赖清单 requirements.txt)' % (SKILL_DIR / 'INSTALL.md')
return '本机环境: %s' % (SKILL_DIR / 'AGENTS.md')
# 默认样式:黑白友好、打印向。字号用 em 相对值,整体缩放只依赖 html font-size
# (由 page.font_size 参数注入),因此压单页只需调小字号/边距。