81 lines
2.7 KiB
Python
81 lines
2.7 KiB
Python
from __future__ import annotations
|
|
|
|
import argparse
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
SCRIPT_DIR = Path(__file__).resolve().parent
|
|
|
|
|
|
def run(script_name: str, *extra_args: str) -> None:
|
|
subprocess.run([sys.executable, str(SCRIPT_DIR / script_name), *extra_args], check=True)
|
|
|
|
|
|
def main() -> None:
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--project", required=True)
|
|
parser.add_argument(
|
|
"--tool",
|
|
required=True,
|
|
help="低层开发辅助操作。真正 workflow 由 SKILL.md 定义,不由本脚本编排。",
|
|
)
|
|
parser.add_argument("--outline")
|
|
parser.add_argument("--content")
|
|
parser.add_argument("--input")
|
|
parser.add_argument("--out")
|
|
parser.add_argument("--bundle")
|
|
args = parser.parse_args()
|
|
|
|
project_dir = Path(args.project).resolve()
|
|
tool_aliases = {
|
|
"extract": "parse-rfp",
|
|
"review-outline": "render-outline",
|
|
"compose": "render-bid",
|
|
"scan-materials": "scan-project",
|
|
}
|
|
selected_tool = tool_aliases.get(args.tool, args.tool)
|
|
if selected_tool == "parse-rfp":
|
|
run("extract_rfp_docx.py", "--project", str(project_dir))
|
|
return
|
|
if selected_tool == "scan-project":
|
|
run("scan_project_materials.py", "--project", str(project_dir))
|
|
return
|
|
if selected_tool == "render-outline":
|
|
extra_args = ["--project", str(project_dir)]
|
|
if args.outline:
|
|
extra_args.extend(["--outline", args.outline])
|
|
if args.out:
|
|
extra_args.extend(["--out", args.out])
|
|
if args.bundle:
|
|
extra_args.extend(["--bundle", args.bundle])
|
|
run("review_outline_and_generate_toc.py", *extra_args)
|
|
return
|
|
if selected_tool == "render-bid":
|
|
extra_args = ["--project", str(project_dir)]
|
|
if args.content:
|
|
extra_args.extend(["--content", args.content])
|
|
if args.out:
|
|
extra_args.extend(["--out", args.out])
|
|
if args.bundle:
|
|
extra_args.extend(["--bundle", args.bundle])
|
|
run("compose_bid_docx.py", *extra_args)
|
|
return
|
|
if selected_tool == "write-large-json":
|
|
extra_args: list[str] = []
|
|
if not args.input:
|
|
raise ValueError("write-large-json 模式必须提供 --input。")
|
|
if not args.out:
|
|
raise ValueError("write-large-json 模式必须提供 --out。")
|
|
extra_args.extend(["--input", args.input, "--out", args.out])
|
|
run("write_large_json.py", *extra_args)
|
|
return
|
|
|
|
allowed = ["parse-rfp", "scan-project", "render-outline", "render-bid", "write-large-json"]
|
|
raise ValueError(f"不支持的 tool: {args.tool}。允许值:{', '.join(allowed)}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|