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:
@@ -32,6 +32,7 @@ from core import (
|
||||
output_result,
|
||||
parse_input,
|
||||
process_content,
|
||||
generate_advice,
|
||||
)
|
||||
from readers import READERS
|
||||
|
||||
@@ -43,6 +44,13 @@ def main() -> None:
|
||||
|
||||
parser.add_argument("input_path", help="DOCX、PPTX、XLSX、PDF、HTML 文件或 URL")
|
||||
|
||||
parser.add_argument(
|
||||
"-a",
|
||||
"--advice",
|
||||
action="store_true",
|
||||
help="仅显示执行建议,不实际解析文件",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"-n",
|
||||
"--context",
|
||||
@@ -80,6 +88,16 @@ def main() -> None:
|
||||
# 实例化所有 readers
|
||||
readers = [ReaderCls() for ReaderCls in READERS]
|
||||
|
||||
# --advice 模式:仅显示建议,不解析
|
||||
if args.advice:
|
||||
advice = generate_advice(args.input_path, readers, "scripts/lyxy_document_reader.py")
|
||||
if advice:
|
||||
print(advice)
|
||||
else:
|
||||
print(f"错误: 无法识别文件类型: {args.input_path}")
|
||||
sys.exit(1)
|
||||
return
|
||||
|
||||
try:
|
||||
content, failures = parse_input(args.input_path, readers)
|
||||
except FileDetectionError as e:
|
||||
|
||||
Reference in New Issue
Block a user