mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-15 00:10:50 +08:00
统一技能安装与 Skills 市场接入链路。
新增公开安装工具与多来源 provider 支持,补齐管理端与目录加载逻辑,并同步更新相关测试与文档以保证可见性和路径安全。 Made-with: Cursor
This commit is contained in:
parent
d5e30542aa
commit
4d9232f3b3
66 changed files with 7369 additions and 1099 deletions
208
runtime/skills/word-reader/DEVELOPMENT.md
Normal file
208
runtime/skills/word-reader/DEVELOPMENT.md
Normal file
|
|
@ -0,0 +1,208 @@
|
|||
# Word Reader 技能开发完成
|
||||
|
||||
## 🎯 技能概述
|
||||
|
||||
成功创建了一个功能完整的 Word 文档读取技能,支持读取 .docx 和 .doc 格式的 Word 文档,能够提取文本内容、表格数据、文档元信息,并提供多种输出格式。
|
||||
|
||||
## 📁 技能结构
|
||||
|
||||
```
|
||||
word-reader/
|
||||
├── SKILL.md # 技能定义文件
|
||||
├── README.md # 使用说明
|
||||
├── skill.json # 技能配置
|
||||
├── demo.sh # 演示脚本
|
||||
├── install.sh # 安装脚本
|
||||
├── test.md # 测试文档
|
||||
└── scripts/
|
||||
└── read_word.py # 核心脚本
|
||||
```
|
||||
|
||||
## ✨ 主要功能
|
||||
|
||||
### 1. 文档解析能力
|
||||
- ✅ **文本提取** - 提取文档中的所有段落文本
|
||||
- ✅ **表格解析** - 解析表格数据并转换为结构化格式
|
||||
- ✅ **元数据获取** - 读取文档属性(标题、作者、创建时间等)
|
||||
- ✅ **图片信息** - 获取文档中图片的基本信息
|
||||
|
||||
### 2. 格式支持
|
||||
- ✅ **.docx** - Office 2007+ 格式(主要支持)
|
||||
- ✅ **.doc** - 旧版 Word 格式(需要 antiword)
|
||||
|
||||
### 3. 输出格式
|
||||
- ✅ **JSON** - 结构化数据,适合程序处理
|
||||
- ✅ **Text** - 纯文本格式,简单易读
|
||||
- ✅ **Markdown** - 格式化输出,保留文档结构
|
||||
|
||||
### 4. 高级功能
|
||||
- ✅ **批量处理** - 支持处理整个目录的文档
|
||||
- ✅ **选择性提取** - 可只提取特定内容类型
|
||||
- ✅ **文件输出** - 支持保存结果到文件
|
||||
- ✅ **编码支持** - 支持多种文本编码
|
||||
|
||||
## 🚀 使用示例
|
||||
|
||||
### 基本用法
|
||||
```bash
|
||||
# 读取文档
|
||||
python3 scripts/read_word.py 文档.docx
|
||||
|
||||
# JSON 格式输出
|
||||
python3 scripts/read_word.py 文档.docx --format json
|
||||
|
||||
# Markdown 格式输出
|
||||
python3 scripts/read_word.py 文档.docx --format markdown
|
||||
|
||||
# 只提取文本
|
||||
python3 scripts/read_word.py 文档.docx --extract text
|
||||
```
|
||||
|
||||
### 批量处理
|
||||
```bash
|
||||
# 批量处理目录下所有文档
|
||||
python3 scripts/read_word.py ./文档目录 --batch
|
||||
|
||||
# 批量处理并保存结果
|
||||
python3 scripts/read_word.py ./文档目录 --batch --format json --output results.json
|
||||
```
|
||||
|
||||
## 🔧 安装和配置
|
||||
|
||||
### 自动安装
|
||||
```bash
|
||||
cd word-reader/
|
||||
./install.sh
|
||||
```
|
||||
|
||||
### 手动安装
|
||||
```bash
|
||||
# 安装 Python 依赖
|
||||
pip3 install python-docx
|
||||
|
||||
# 安装系统依赖(可选)
|
||||
sudo apt-get install antiword # Ubuntu/Debian
|
||||
brew install antiword # macOS
|
||||
|
||||
# 设置执行权限
|
||||
chmod +x scripts/read_word.py
|
||||
```
|
||||
|
||||
## 📊 输出示例
|
||||
|
||||
### JSON 格式
|
||||
```json
|
||||
{
|
||||
"metadata": {
|
||||
"filename": "文档.docx",
|
||||
"title": "文档标题",
|
||||
"author": "作者",
|
||||
"created": "2024-01-01T10:00:00",
|
||||
"modified": "2024-01-01T12:00:00"
|
||||
},
|
||||
"format": "docx",
|
||||
"text": "文档内容...",
|
||||
"tables": [...],
|
||||
"images": [...]
|
||||
}
|
||||
```
|
||||
|
||||
### Markdown 格式
|
||||
```markdown
|
||||
# 文档.docx
|
||||
|
||||
**标题**:文档标题
|
||||
**作者**:作者
|
||||
**创建时间**:2024-01-01T10:00:00
|
||||
|
||||
## 正文内容
|
||||
|
||||
文档内容...
|
||||
|
||||
## 表格内容
|
||||
|
||||
| 表头1 | 表头2 |
|
||||
|-------|-------|
|
||||
| 数据1 | 数据2 |
|
||||
```
|
||||
|
||||
## 🎨 技能特点
|
||||
|
||||
### 1. 智能错误处理
|
||||
- 友好的错误提示
|
||||
- 自动检测文档格式
|
||||
- 优雅的异常处理
|
||||
|
||||
### 2. 性能优化
|
||||
- 流式处理大文件
|
||||
- 内存使用优化
|
||||
- 进度显示(批量模式)
|
||||
|
||||
### 3. 用户友好
|
||||
- 详细的帮助信息
|
||||
- 多种使用方式
|
||||
- 完整的文档说明
|
||||
|
||||
### 4. 可扩展性
|
||||
- 模块化设计
|
||||
- 易于添加新功能
|
||||
- 支持自定义输出格式
|
||||
|
||||
## 🎯 应用场景
|
||||
|
||||
### 1. 文档内容分析
|
||||
- 快速查看 Word 文档内容
|
||||
- 提取特定信息
|
||||
- 文档摘要生成
|
||||
|
||||
### 2. 批量处理
|
||||
- 处理大量文档
|
||||
- 文档格式转换
|
||||
- 内容索引创建
|
||||
|
||||
### 3. 自动化工作流
|
||||
- 集到文档处理系统
|
||||
- 自动化文档分析
|
||||
- 内容管理系统集成
|
||||
|
||||
## 📝 开发总结
|
||||
|
||||
### 实现的功能
|
||||
- 完整的 Word 文档解析框架
|
||||
- 支持多种输出格式
|
||||
- 批量处理能力
|
||||
- 错误处理和用户友好性
|
||||
|
||||
### 技术亮点
|
||||
- 模块化设计,易于维护
|
||||
- 优雅的错误处理机制
|
||||
- 支持多种文件格式
|
||||
- 灵活的输出选项
|
||||
|
||||
### 改进空间
|
||||
- 可以添加 PDF 支持
|
||||
- 可以增加图片提取功能
|
||||
- 可以优化大文件处理性能
|
||||
- 可以添加更多文档元素支持
|
||||
|
||||
## 🚀 发布到 ClawHub
|
||||
|
||||
要发布此技能到 ClawHub,可以运行:
|
||||
|
||||
```bash
|
||||
# 安装 ClawHub CLI
|
||||
npm i -g clawhub
|
||||
|
||||
# 登录
|
||||
clawhub login
|
||||
|
||||
# 发布技能
|
||||
clawhub publish ./word-reader \
|
||||
--slug word-reader \
|
||||
--name "Word Reader" \
|
||||
--version 1.0.0 \
|
||||
--changelog "Initial release with .docx and .doc support" \
|
||||
--tags document,word,office,text-extraction
|
||||
```
|
||||
|
||||
这个技能现在已经准备好使用了!它可以帮助用户轻松读取和处理 Word 文档,支持多种格式和输出选项。
|
||||
Loading…
Add table
Add a link
Reference in a new issue