refactor: 优化执行命令,始终包含 pyarmor 依赖
- 更新 SKILL.md 中的命令示例,使用 uv run --with pyarmor - advice_generator.py 中始终添加 pyarmor 依赖(混淆后脚本需要) - 生成的 pip 命令也始终包含 pyarmor
This commit is contained in:
37
SKILL.md
37
SKILL.md
@@ -16,10 +16,12 @@ compatibility: Requires Python 3.11+。优先使用 lyxy-runner-python skill,
|
||||
|
||||
### 第一步:获取执行建议
|
||||
```bash
|
||||
python scripts/lyxy_document_reader.py --advice <文件路径或URL>
|
||||
PYTHONPATH=. uv run --with pyarmor python scripts/lyxy_document_reader.py --advice <文件路径或URL>
|
||||
```
|
||||
这会输出准确的执行命令,包含所需的依赖配置。
|
||||
|
||||
*也可以使用:`python scripts/lyxy_document_reader.py --advice <文件路径或URL>`*
|
||||
|
||||
## Purpose
|
||||
|
||||
**支持格式**
|
||||
@@ -57,49 +59,36 @@ python scripts/lyxy_document_reader.py --advice <文件路径或URL>
|
||||
| `-s <pattern>` | 正则表达式搜索 |
|
||||
| `-n <num>/--context <num>` | 与 `-s` 配合,指定上下文行数(默认 2) |
|
||||
|
||||
## Workflow
|
||||
|
||||
1. **获取执行建议**
|
||||
```bash
|
||||
python scripts/lyxy_document_reader.py --advice <文件>
|
||||
```
|
||||
|
||||
2. **选择执行方式**
|
||||
- 优先使用 lyxy-runner-python skill
|
||||
- 其次使用建议中的 uv 命令
|
||||
- 最后使用建议中的 pip + python 命令
|
||||
|
||||
3. **添加需要的参数**
|
||||
- 如 `-c`、`-t`、`-s` 等
|
||||
|
||||
## 参数使用示例
|
||||
|
||||
```bash
|
||||
# 获取执行建议
|
||||
python scripts/lyxy_document_reader.py --advice document.docx
|
||||
PYTHONPATH=. uv run --with pyarmor python scripts/lyxy_document_reader.py --advice document.docx
|
||||
|
||||
# 读取全文
|
||||
python scripts/lyxy_document_reader.py document.docx
|
||||
PYTHONPATH=. uv run --with pyarmor python scripts/lyxy_document_reader.py document.docx
|
||||
|
||||
# 统计字数
|
||||
python scripts/lyxy_document_reader.py document.docx -c
|
||||
PYTHONPATH=. uv run --with pyarmor python scripts/lyxy_document_reader.py document.docx -c
|
||||
|
||||
# 提取标题
|
||||
python scripts/lyxy_document_reader.py document.docx -t
|
||||
PYTHONPATH=. uv run --with pyarmor python scripts/lyxy_document_reader.py document.docx -t
|
||||
|
||||
# 提取指定章节
|
||||
python scripts/lyxy_document_reader.py document.docx -tc "第三章"
|
||||
PYTHONPATH=. uv run --with pyarmor python scripts/lyxy_document_reader.py document.docx -tc "第三章"
|
||||
|
||||
# 搜索内容
|
||||
python scripts/lyxy_document_reader.py document.docx -s "关键词"
|
||||
PYTHONPATH=. uv run --with pyarmor python scripts/lyxy_document_reader.py document.docx -s "关键词"
|
||||
|
||||
# 正则搜索
|
||||
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 "\d{4}-\d{2}-\d{2}"
|
||||
|
||||
# 指定搜索上下文行数
|
||||
python scripts/lyxy_document_reader.py document.docx -s "关键词" -n 5
|
||||
PYTHONPATH=. uv run --with pyarmor python scripts/lyxy_document_reader.py document.docx -s "关键词" -n 5
|
||||
```
|
||||
|
||||
*也可以使用纯 python 命令:`python scripts/lyxy_document_reader.py ...`*
|
||||
|
||||
## 错误处理
|
||||
|
||||
| 错误 | 原因 | 解决 |
|
||||
|
||||
@@ -106,11 +106,14 @@ def generate_uv_command(
|
||||
Returns:
|
||||
uv run 命令字符串
|
||||
"""
|
||||
parts = ["uv run"]
|
||||
parts = ["PYTHONPATH=. uv run"]
|
||||
|
||||
if python_version:
|
||||
parts.append(f"--python {python_version}")
|
||||
|
||||
# 始终添加 pyarmor 依赖(混淆后脚本需要)
|
||||
parts.append("--with pyarmor")
|
||||
|
||||
for dep in dependencies:
|
||||
# 处理包含空格的依赖(如 unstructured[pdf]),需要加引号
|
||||
if "[" in dep or " " in dep:
|
||||
@@ -141,8 +144,8 @@ def generate_python_command(
|
||||
"""
|
||||
python_cmd = f"python {script_path} {input_path}"
|
||||
|
||||
# 构建 pip install 命令,处理带引号的依赖
|
||||
pip_parts = ["pip install"]
|
||||
# 构建 pip install 命令,处理带引号的依赖,始终包含 pyarmor
|
||||
pip_parts = ["pip install", "pyarmor"]
|
||||
for dep in dependencies:
|
||||
pip_parts.append(dep)
|
||||
pip_cmd = " ".join(pip_parts)
|
||||
|
||||
Reference in New Issue
Block a user