feat: 添加 --advice 参数,支持快速获取执行建议

- 新增 scripts/core/advice_generator.py 建议生成器模块
- 在 config.py 中添加 DEPENDENCIES 依赖配置
- 在 lyxy_document_reader.py 中添加 -a/--advice 参数
- 复用 Reader 实例的 supports 方法检测文件类型
- 支持平台检测,对 macOS x86_64 PDF 返回特殊命令
- 添加单元测试和集成测试
- 更新 SKILL.md,引导优先使用 --advice 参数
- 更新 README.md,添加项目结构说明
- 添加 openspec/specs/cli-advice/spec.md 规范文档
This commit is contained in:
2026-03-09 18:13:00 +08:00
parent 9daff73589
commit aaa1171e60
9 changed files with 757 additions and 103 deletions

View File

@@ -4,6 +4,41 @@ import pytest
import os
class TestCLIAdviceOption:
"""测试 CLI --advice 参数功能。"""
def test_advice_option_pdf(self, cli_runner):
"""测试 -a/--advice 选项对 PDF 文件。"""
stdout, stderr, exit_code = cli_runner(["test.pdf", "-a"])
assert exit_code == 0
assert "文件类型: PDF" in stdout
assert "[uv 命令]" in stdout
assert "[python 命令]" in stdout
def test_advice_option_docx(self, cli_runner):
"""测试 --advice 选项对 DOCX 文件。"""
stdout, stderr, exit_code = cli_runner(["test.docx", "--advice"])
assert exit_code == 0
assert "文件类型: DOCX" in stdout
def test_advice_option_url(self, cli_runner):
"""测试 --advice 选项对 URL。"""
stdout, stderr, exit_code = cli_runner(["https://example.com", "--advice"])
assert exit_code == 0
assert "文件类型: HTML" in stdout
def test_advice_option_unknown(self, cli_runner):
"""测试 --advice 选项对未知文件类型。"""
stdout, stderr, exit_code = cli_runner(["test.xyz", "--advice"])
assert exit_code != 0
output = stdout + stderr
assert "无法识别" in output or "错误" in output
class TestCLIDefaultOutput:
"""测试 CLI 默认输出功能。"""