docs: 分离用户文档与开发文档

- 将 README.md 重构为开发文档,包含开发环境、工作流、代码规范
- 新建 skill/SKILL.md 作为用户文档,包含快速开始和命令选项
- 更新 openspec/config.yaml 添加项目概述和 skill 目录声明
This commit is contained in:
2026-03-08 18:08:44 +08:00
parent 15b63800a8
commit b98e70383c
3 changed files with 172 additions and 179 deletions

125
skill/SKILL.md Normal file
View File

@@ -0,0 +1,125 @@
---
name: lyxy-document-reader
description: 统一文档解析工具 - DOCX/XLSX/PPTX/PDF/HTML/URL 转 Markdown
license: MIT
metadata:
version: "1.0"
---
# 快速开始
```bash
# 基本解析
uv run lyxy-document-reader document.docx
# URL 解析
uv run lyxy-document-reader https://example.com
```
# 命令选项
## 基本参数
- `input_path`:文件路径或 URL必需
## 互斥操作(选其一)
| 选项 | 说明 |
|------|------|
| 无 | 输出完整 Markdown |
| `-c` / `--count` | 统计字数 |
| `-l` / `--lines` | 统计行数 |
| `-t` / `--titles` | 提取所有标题1-6级 |
| `-tc <name>` | 提取指定标题及其内容 |
| `-s <pattern>` | 正则搜索 |
## 辅助选项
| 选项 | 说明 | 配合 |
|------|------|------|
| `-n <num>` / `--context <num>` | 搜索结果上下文行数默认2 | `-s` |
# 按文档类型使用
## DOCX
```bash
uv run lyxy-document-reader file.docx
```
## PDF
```bash
uv run lyxy-document-reader file.pdf
```
## HTML/URL
```bash
# 本地文件
uv run lyxy-document-reader page.html
# URL
uv run lyxy-document-reader https://example.com
```
## XLSX
```bash
uv run lyxy-document-reader file.xlsx
```
## PPTX
```bash
uv run lyxy-document-reader file.pptx
```
# 高级用法
## 搜索内容
```bash
# 搜索关键词
uv run lyxy-document-reader file.docx -s "关键词"
# 指定上下文行数
uv run lyxy-document-reader file.docx -s "关键词" -n 5
# 正则表达式
uv run lyxy-document-reader file.docx -s "\d{4}-\d{2}-\d{2}"
```
## 提取标题
```bash
# 列出所有标题
uv run lyxy-document-reader file.docx -t
# 提取指定标题内容
uv run lyxy-document-reader file.docx -tc "第三章"
```
# Python API
```python
from scripts.core import parse_input, process_content
from scripts.readers import READERS
readers = [ReaderCls() for ReaderCls in READERS]
content, failures = parse_input("document.docx", readers)
if content:
content = process_content(content)
print(content)
```
# 错误处理
| 错误信息 | 原因 | 解决 |
|---------|------|------|
| 错误: input_path 不能为空 | 未提供输入 | 提供 file_path 或 URL |
| 错误: 不支持的文件类型 | 无对应 reader | 检查文件扩展名 |
| 所有解析方法均失败 | 所有解析器失败 | 检查文件是否损坏 |
| 错误: 无效的正则表达式 | 正则语法错误 | 检查正则语法 |
| 错误: 未找到匹配 | 搜索无结果 | 检查搜索词或正则 |