Skip to content
dsh.fish
Bundle

dsh-uno-office

LibreOffice (UNO) powered high-fidelity office engine for DSH — create & edit docx/xlsx/pptx via prompts, with human-in-the-loop review.

Source
MarchLiu
License
MIT
Updated
Updated yesterday

Readme

# dsh-uno-office

**LibreOffice-powered high-fidelity office engine for DSH.** 通过真实排版引擎(LibreOffice / UNO)用提示词创建和编辑 Office 文档,并在必要时支持人工介入编辑。

与 Univer(纯 JS 内核)路线互补:LibreOffice 是真实排版引擎,复杂排版、转 PDF、公式、数据透视表等保真度高。

## 能力

| 工具 | 说明 |
|---|---|
| `uno_status` | 检查 UNO 桥接(python 运行时 / soffice / 连通性) |
| `uno_create` | 创建 docx / xlsx / pptx / odt / ods / odp |
| `uno_read` | 读取文档(段落样式 / 单元格网格含计算值 / 幻灯片) |
| `uno_edit` | 编辑:替换、追加段落、设置单元格、公式、汇总(SUM/COUNT/AVERAGE/MAX/MIN)、数据透视表、增删幻灯片 |
| `uno_convert` | 高保真导出(pdf、docx↔odt、xlsx、csv、html …) |
| `uno_review_export` | **人工介入·第 1 步**:把文档复制到审阅目录交给用户手工编辑 |
| `uno_review_import` | **人工介入·第 2 步**:用户改完后校验可打开并回灌到工作文档 |

## 人工介入工作流

1. Agent 调用 `uno_review_export`,把返回的 `review_path` 通过文件卡片发给用户;
2. 用户在 LibreOffice / Word / Excel 里手工编辑该副本;
3. 用户说「改好了」,Agent 调用 `uno_review_import` 校验并覆盖工作文档,继续后续自动化。

## 安装

```sh
# 1. 先准备 UNO python 运行时(macOS 必须,见下方“为什么”)
bash scripts/setup-runtime.sh

# 2. 安装插件
dsh plugin --profile <name> add github:you/dsh-uno-office#<commit>
```

### 为什么需要 setup-runtime.sh

LibreOffice ≥ 25.2(macOS)给自带 python 签了 **ParentLaunchConstraint**(CVE-2025-14714 修复),外部进程直接运行会被 macOS SIGKILL(`CODESIGNING / Launch Constraint Violation`)。该脚本把运行时复制到 `~/libreoffice-python` 并 ad-hoc 重签,解除约束。上游讨论:[TDF bug 167752](https://bugs.documentfoundation.org/show_bug.cgi?id=167752)。

Linux 上无此问题,可直接用系统 LibreOffice 的 python。

## 架构

```
index.js            # 插件入口:注册 7 个工具
lib/bridge.js       # 定位 UNO python、spawn py/uno_bridge.py、超时控制
py/uno_bridge.py    # UNO 命令分发器:连接常驻 headless soffice(socket :2002)
scripts/setup-runtime.sh  # macOS 运行时准备
```

soffice 以 `--headless --accept=socket` 常驻,由桥接按需拉起并复用。

## License

MIT

Install

dsh plugin --profile web add github:MarchLiu/dsh-uno-office

Profile: web

  • This source has no pinned commit, so a later push upstream changes what installs. Prefer pinning a commit.
Source