feat: 添加自启动机制,移除 --advice 参数
- 创建 bootstrap.py 承载实际 CLI 逻辑 - 重写 lyxy_document_reader.py 为轻量入口,自动检测依赖并启动 - 使用 subprocess.run() 实现跨平台兼容的自启动 - 移除 --advice 参数及相关测试 - 更新文档和规范,简化使用方式
This commit is contained in:
37
SKILL.md
37
SKILL.md
@@ -11,16 +11,17 @@ compatibility: Requires Python 3.11+。优先使用 lyxy-runner-python skill,
|
||||
|
||||
### 执行路径选择(按优先级顺序)
|
||||
1. **lyxy-runner-python skill(首选)** - 自动管理依赖
|
||||
2. **uv run --with** - 按需加载依赖
|
||||
3. **主机 Python + pip install** - 手动安装依赖
|
||||
2. **python scripts/lyxy_document_reader.py** - 自启动,自动检测依赖
|
||||
3. **uv run --with** - 手动指定依赖
|
||||
4. **主机 Python + pip install** - 手动安装依赖
|
||||
|
||||
### 第一步:获取执行建议
|
||||
### 推荐用法
|
||||
```bash
|
||||
PYTHONPATH=. uv run --with pyarmor python scripts/lyxy_document_reader.py --advice <文件路径或URL>
|
||||
# 直接运行(自动检测依赖并执行)
|
||||
python scripts/lyxy_document_reader.py <文件路径或URL>
|
||||
```
|
||||
这会输出准确的执行命令,包含所需的依赖配置。
|
||||
|
||||
*也可以使用:`python scripts/lyxy_document_reader.py --advice <文件路径或URL>`*
|
||||
脚本会自动检测文件类型、当前平台,并用正确的 uv 命令执行。
|
||||
|
||||
## Purpose
|
||||
|
||||
@@ -50,7 +51,6 @@ PYTHONPATH=. uv run --with pyarmor python scripts/lyxy_document_reader.py --advi
|
||||
|
||||
| 参数 | 说明 |
|
||||
|------|------|
|
||||
| `-a/--advice` | 仅显示执行建议(**必须先运行此命令**) |
|
||||
| (无) | 输出完整 Markdown |
|
||||
| `-c/--count` | 字数统计 |
|
||||
| `-l/--lines` | 行数统计 |
|
||||
@@ -62,33 +62,28 @@ PYTHONPATH=. uv run --with pyarmor python scripts/lyxy_document_reader.py --advi
|
||||
## 参数使用示例
|
||||
|
||||
```bash
|
||||
# 获取执行建议
|
||||
PYTHONPATH=. uv run --with pyarmor python scripts/lyxy_document_reader.py --advice document.docx
|
||||
|
||||
# 读取全文
|
||||
PYTHONPATH=. uv run --with pyarmor python scripts/lyxy_document_reader.py document.docx
|
||||
# 读取全文(自动检测依赖)
|
||||
python scripts/lyxy_document_reader.py document.docx
|
||||
|
||||
# 统计字数
|
||||
PYTHONPATH=. uv run --with pyarmor python scripts/lyxy_document_reader.py document.docx -c
|
||||
python scripts/lyxy_document_reader.py document.docx -c
|
||||
|
||||
# 提取标题
|
||||
PYTHONPATH=. uv run --with pyarmor python scripts/lyxy_document_reader.py document.docx -t
|
||||
python scripts/lyxy_document_reader.py document.docx -t
|
||||
|
||||
# 提取指定章节
|
||||
PYTHONPATH=. uv run --with pyarmor python scripts/lyxy_document_reader.py document.docx -tc "第三章"
|
||||
python scripts/lyxy_document_reader.py document.docx -tc "第三章"
|
||||
|
||||
# 搜索内容
|
||||
PYTHONPATH=. uv run --with pyarmor python scripts/lyxy_document_reader.py document.docx -s "关键词"
|
||||
python scripts/lyxy_document_reader.py document.docx -s "关键词"
|
||||
|
||||
# 正则搜索
|
||||
PYTHONPATH=. uv run --with pyarmor python scripts/lyxy_document_reader.py document.docx -s "\d{4}-\d{2}-\d{2}"
|
||||
python scripts/lyxy_document_reader.py document.docx -s "\d{4}-\d{2}-\d{2}"
|
||||
|
||||
# 指定搜索上下文行数
|
||||
PYTHONPATH=. uv run --with pyarmor python scripts/lyxy_document_reader.py document.docx -s "关键词" -n 5
|
||||
python scripts/lyxy_document_reader.py document.docx -s "关键词" -n 5
|
||||
```
|
||||
|
||||
*也可以使用纯 python 命令:`python scripts/lyxy_document_reader.py ...`*
|
||||
|
||||
## 错误处理
|
||||
|
||||
| 错误 | 原因 | 解决 |
|
||||
@@ -98,4 +93,4 @@ PYTHONPATH=. uv run --with pyarmor python scripts/lyxy_document_reader.py docume
|
||||
| 所有解析方法均失败 | 所有解析器失败 | 检查文件是否损坏 |
|
||||
| 错误: 无效的正则表达式 | 正则语法错误 | 检查正则语法 |
|
||||
| 错误: 未找到匹配 | 搜索无结果 | 检查搜索词或正则 |
|
||||
| ModuleNotFoundError | 缺少依赖 | 使用 --advice 获取正确的依赖命令 |
|
||||
| ModuleNotFoundError | 缺少依赖 | 脚本会自动检测并安装依赖 |
|
||||
|
||||
Reference in New Issue
Block a user