Files
agent/skills/office/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

47 lines
2.2 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.
# 本机安装 officecli(office 技能)
技能三件套:本文件同目录的 `SKILL.md`(用法)、`scripts/office`(Node 封装层,已在 `PATH` 里)、
`bin/officecli`(.NET 单文件二进制,**不入库**)。
服务器上由镜像构建 / `agent-executor-init` 跑同目录的 `install.sh`(只处理 linux-x64)。
**本机不要跑 `install.sh`**,按下面自己下:先装才用,不需要重启 agent(封装层每次执行时才解析二进制路径)。
下文「技能目录」= `$(dirname "$AGENT_SKILLS_DEPS")/office`(本地形态 `AGENT_SKILLS_DEPS` 指向 `<仓库>/skills/deps`)。
## 1. 下载对应平台的资产
| 平台 | 资产名 |
|---|---|
| macOS Apple Silicon | `officecli-mac-arm64` |
| macOS Intel | `officecli-mac-x64` |
| Linux x64 | `officecli-linux-x64` |
| Linux arm64 | `officecli-linux-arm64` |
```bash
mkdir -p "$(dirname "$AGENT_SKILLS_DEPS")/office/bin"
curl -fL --progress-bar \
-o "$(dirname "$AGENT_SKILLS_DEPS")/office/bin/officecli" \
https://github.com/iOfficeAI/OfficeCLI/releases/latest/download/officecli-mac-x64
```
- 用 `latest` 就够(officecli 首次运行也会把自己更新到 latest),不用对齐服务器 pin 的版本。
- 国内慢就换源:`https://gh-proxy.com/https://github.com/iOfficeAI/OfficeCLI/releases/latest/download/<资产>`。
- 约 34MB,超时/断流就重试;`curl -fL` 失败时不会留下半截文件可用。
## 2. 赋可执行位并验证
```bash
chmod +x "$(dirname "$AGENT_SKILLS_DEPS")/office/bin/officecli"
office --version # 或 office help
```
`office` 命令由本地启动器注入 `PATH` 提供(`skills/office/scripts` 目录),不需要建软链、不需要 root。
如果 `office` 不在 PATH(例如手工起 core 没带启动器),可以直接跑
`node "$(dirname "$AGENT_SKILLS_DEPS")/office/scripts/office" help`。
## 3. 装不上怎么办
封装层会报 `office.core binary missing: <路径>`,说明二进制没到位;文档的创建/编辑/读取全部依赖它,
没有它就用别的路子(例如要 PDF 用 `x2pdf` 技能)。**不要**为此改系统目录或去装 .NET 运行时——
该二进制是自包含的。