@orbit-build/cli 1.5.0 → 1.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +114 -3
- package/THIRD_PARTY_NOTICES.md +1 -0
- package/commands/cumcm-draft.md +3 -1
- package/dist/index.js +20538 -5446
- package/package.json +5 -3
- package/skills/cumcm-draft/SKILL.md +62 -36
- package/skills/cumcm-draft/agents/openai.yaml +1 -1
- package/skills/cumcm-draft/assets/project-template/.cumcm/profile.json +1 -0
- package/skills/cumcm-draft/references/code-and-output-style.md +13 -2
- package/skills/cumcm-draft/references/latex-figures-tables.md +4 -2
- package/skills/cumcm-draft/references/modeling-quality.md +17 -0
- package/skills/cumcm-draft/references/project-architecture.md +29 -23
- package/skills/cumcm-draft/scripts/audit_paper.py +6 -6
- package/skills/cumcm-draft/scripts/bootstrap_project.py +86 -28
- package/skills/cumcm-draft/scripts/build_paper.py +6 -8
- package/skills/cumcm-draft/scripts/capture_environment.py +31 -21
- package/skills/cumcm-draft/scripts/clean_project.py +91 -2
- package/skills/cumcm-draft/scripts/evidence_freeze.py +2 -2
- package/skills/cumcm-draft/scripts/finalize_project.py +35 -9
- package/skills/cumcm-draft/scripts/inspect_inputs.py +9 -1
- package/skills/cumcm-draft/scripts/package_support.py +50 -9
- package/skills/cumcm-draft/scripts/project_utils.py +9 -2
- package/skills/cumcm-draft/scripts/validate_project.py +67 -68
- package/skills/cumcm-draft/assets/project-template/.cumcm/finalize.py +0 -90
- /package/skills/cumcm-draft/assets/project-template/{paper → happy}/AI/345/267/245/345/205/267/344/275/277/347/224/250/350/257/246/346/203/205.tex" +0 -0
- /package/skills/cumcm-draft/assets/project-template/{paper → happy}/main.tex +0 -0
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import argparse
|
|
4
|
+
import shutil
|
|
4
5
|
import zipfile
|
|
5
6
|
from pathlib import Path
|
|
6
7
|
|
|
7
8
|
from project_utils import (
|
|
8
9
|
control_path,
|
|
10
|
+
delivery_directory,
|
|
9
11
|
iter_regular_files,
|
|
10
12
|
load_profile,
|
|
11
13
|
numeric_limit,
|
|
14
|
+
question_numbers,
|
|
12
15
|
)
|
|
13
16
|
|
|
14
17
|
|
|
@@ -20,6 +23,47 @@ EXCLUDED_PARTS = {
|
|
|
20
23
|
".ipynb_checkpoints",
|
|
21
24
|
"build",
|
|
22
25
|
}
|
|
26
|
+
DELIVERY_SUFFIXES = {".csv", ".tsv", ".xls", ".xlsx", ".doc", ".docx"}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def copy_question_deliverables(root: Path) -> int:
|
|
30
|
+
"""把需提交的表格复制到 happy/qN;内部审计 JSON 留在 results/qN。"""
|
|
31
|
+
copied = 0
|
|
32
|
+
happy = delivery_directory(root)
|
|
33
|
+
for number in sorted(question_numbers(root)):
|
|
34
|
+
source = root / "results" / f"q{number}"
|
|
35
|
+
if source.is_symlink():
|
|
36
|
+
raise SystemExit(f"Symbolic result directory is unsafe: {source}")
|
|
37
|
+
selected = (
|
|
38
|
+
[
|
|
39
|
+
path
|
|
40
|
+
for path in source.iterdir()
|
|
41
|
+
if path.is_file()
|
|
42
|
+
and not path.is_symlink()
|
|
43
|
+
and path.suffix.lower() in DELIVERY_SUFFIXES
|
|
44
|
+
]
|
|
45
|
+
if source.is_dir()
|
|
46
|
+
else []
|
|
47
|
+
)
|
|
48
|
+
target = happy / f"q{number}"
|
|
49
|
+
if target.is_symlink():
|
|
50
|
+
raise SystemExit(f"Symbolic delivery directory is unsafe: {target}")
|
|
51
|
+
if not selected:
|
|
52
|
+
if target.is_dir() and not any(target.iterdir()):
|
|
53
|
+
target.rmdir()
|
|
54
|
+
continue
|
|
55
|
+
if target.exists() and not target.is_dir():
|
|
56
|
+
raise SystemExit(f"Delivery target is not a directory: {target}")
|
|
57
|
+
target.mkdir(parents=True, exist_ok=True)
|
|
58
|
+
for old in target.iterdir():
|
|
59
|
+
if old.is_symlink():
|
|
60
|
+
raise SystemExit(f"Symbolic delivery file is unsafe: {old}")
|
|
61
|
+
if old.is_file():
|
|
62
|
+
old.unlink()
|
|
63
|
+
for path in selected:
|
|
64
|
+
shutil.copy2(path, target / path.name, follow_symlinks=False)
|
|
65
|
+
copied += 1
|
|
66
|
+
return copied
|
|
23
67
|
|
|
24
68
|
|
|
25
69
|
def main() -> None:
|
|
@@ -29,7 +73,7 @@ def main() -> None:
|
|
|
29
73
|
parser.add_argument("project_root", type=Path)
|
|
30
74
|
args = parser.parse_args()
|
|
31
75
|
root = args.project_root.resolve()
|
|
32
|
-
output = root / "
|
|
76
|
+
output = delivery_directory(root) / "支撑材料.zip"
|
|
33
77
|
try:
|
|
34
78
|
profile = load_profile(root)
|
|
35
79
|
support_profile = profile["support"]
|
|
@@ -46,20 +90,16 @@ def main() -> None:
|
|
|
46
90
|
ai_profile = profile["ai"]
|
|
47
91
|
assert isinstance(ai_profile, dict)
|
|
48
92
|
if bool(ai_profile.get("used")) and bool(ai_profile.get("details_pdf_required")):
|
|
49
|
-
ai_pdf = root / "
|
|
93
|
+
ai_pdf = delivery_directory(root) / "AI工具使用详情.pdf"
|
|
50
94
|
if not ai_pdf.is_file() or ai_pdf.is_symlink():
|
|
51
|
-
raise SystemExit("Active profile requires a built
|
|
95
|
+
raise SystemExit("Active profile requires a built happy/AI工具使用详情.pdf")
|
|
52
96
|
candidates.append((ai_pdf, "AI工具使用详情.pdf"))
|
|
53
97
|
|
|
54
|
-
environment = control_path(root, "environment.json")
|
|
55
|
-
if environment.is_file() and not environment.is_symlink():
|
|
56
|
-
candidates.append((environment, "复现环境.json"))
|
|
57
|
-
|
|
58
98
|
if bool(support_profile.get("include_ai_log")):
|
|
59
99
|
log = control_path(
|
|
60
100
|
root,
|
|
61
101
|
"ai-use-log.md",
|
|
62
|
-
root / "
|
|
102
|
+
delivery_directory(root) / "ai-use-log.md",
|
|
63
103
|
)
|
|
64
104
|
if log.is_file() and not log.is_symlink():
|
|
65
105
|
candidates.append((log, "AI工具使用记录.md"))
|
|
@@ -79,9 +119,10 @@ def main() -> None:
|
|
|
79
119
|
f"Support archive would be {size_mb:.2f} MB; "
|
|
80
120
|
f"active profile limit is {limit:g} MB."
|
|
81
121
|
)
|
|
122
|
+
copied = copy_question_deliverables(root)
|
|
82
123
|
print(
|
|
83
124
|
f"[OK] Packaged {len(candidates)} support file(s): "
|
|
84
|
-
f"{output} ({size_mb:.2f} MB)"
|
|
125
|
+
f"{output} ({size_mb:.2f} MB); copied {copied} deliverable file(s) to happy/qN"
|
|
85
126
|
)
|
|
86
127
|
|
|
87
128
|
|
|
@@ -7,6 +7,7 @@ from typing import Any, Iterable
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
CONTROL_DIRECTORY_NAME = ".cumcm"
|
|
10
|
+
DELIVERY_DIRECTORY_NAME = "happy"
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
DEFAULT_PROFILE: dict[str, Any] = {
|
|
@@ -26,6 +27,7 @@ DEFAULT_PROFILE: dict[str, Any] = {
|
|
|
26
27
|
"require_chinese_headers": True,
|
|
27
28
|
"require_chinese_sheet_names": True,
|
|
28
29
|
"require_chinese_figure_filenames": True,
|
|
30
|
+
"require_pdf_svg_figure_pair": True,
|
|
29
31
|
"require_utf8_sig_csv": True,
|
|
30
32
|
"fixed_schema_exceptions": [],
|
|
31
33
|
},
|
|
@@ -52,6 +54,11 @@ def control_directory(root: Path) -> Path:
|
|
|
52
54
|
return root / CONTROL_DIRECTORY_NAME
|
|
53
55
|
|
|
54
56
|
|
|
57
|
+
def delivery_directory(root: Path) -> Path:
|
|
58
|
+
"""返回论文源码、最终PDF和需提交结果的统一交付目录。"""
|
|
59
|
+
return root / DELIVERY_DIRECTORY_NAME
|
|
60
|
+
|
|
61
|
+
|
|
55
62
|
def control_path(root: Path, name: str, legacy: Path | None = None) -> Path:
|
|
56
63
|
"""Prefer the compact layout while retaining read compatibility with 0.8.3."""
|
|
57
64
|
current = control_directory(root) / name
|
|
@@ -72,7 +79,7 @@ def load_profile(root: Path) -> dict[str, Any]:
|
|
|
72
79
|
path = control_path(
|
|
73
80
|
root,
|
|
74
81
|
"profile.json",
|
|
75
|
-
root / "
|
|
82
|
+
root / "happy" / "contest-profile.json",
|
|
76
83
|
)
|
|
77
84
|
if not path.is_file():
|
|
78
85
|
return json.loads(json.dumps(DEFAULT_PROFILE))
|
|
@@ -144,7 +151,7 @@ def question_numbers(root: Path) -> set[int]:
|
|
|
144
151
|
match = pattern.fullmatch(path.name)
|
|
145
152
|
if path.is_dir() and match:
|
|
146
153
|
numbers.add(int(match.group(1)))
|
|
147
|
-
sections = root / "
|
|
154
|
+
sections = delivery_directory(root) / "sections"
|
|
148
155
|
if sections.is_dir():
|
|
149
156
|
for path in sections.glob("q*.tex"):
|
|
150
157
|
match = re.fullmatch(r"q([1-9]\d*)\.tex", path.name)
|
|
@@ -19,6 +19,7 @@ from xml.etree import ElementTree
|
|
|
19
19
|
from project_utils import (
|
|
20
20
|
build_directory,
|
|
21
21
|
control_path,
|
|
22
|
+
delivery_directory,
|
|
22
23
|
ensure_safe_file,
|
|
23
24
|
generated_directory,
|
|
24
25
|
load_profile,
|
|
@@ -547,6 +548,7 @@ def figure_artifact_contract_errors(
|
|
|
547
548
|
figures = root / "figures"
|
|
548
549
|
if not figures.is_dir() or figures.is_symlink():
|
|
549
550
|
return errors
|
|
551
|
+
formats_by_stem: dict[str, set[str]] = {}
|
|
550
552
|
for path in figures.rglob("*"):
|
|
551
553
|
if not path.is_file() or path.is_symlink():
|
|
552
554
|
continue
|
|
@@ -557,10 +559,22 @@ def figure_artifact_contract_errors(
|
|
|
557
559
|
)
|
|
558
560
|
continue
|
|
559
561
|
stem = path.stem.strip()
|
|
562
|
+
key = path.relative_to(figures).with_suffix("").as_posix().casefold()
|
|
563
|
+
formats_by_stem.setdefault(key, set()).add(path.suffix.lower())
|
|
560
564
|
if stem.lower() in GENERIC_FIGURE_STEMS or not has_chinese(stem):
|
|
561
565
|
errors.append(
|
|
562
566
|
f"figure filename must be descriptive Chinese, not a generic name: {relative}"
|
|
563
567
|
)
|
|
568
|
+
if profile.get("require_pdf_svg_figure_pair", True) is not True:
|
|
569
|
+
errors.append("result_artifacts.require_pdf_svg_figure_pair must be true")
|
|
570
|
+
else:
|
|
571
|
+
for stem, suffixes in sorted(formats_by_stem.items()):
|
|
572
|
+
missing = {".pdf", ".svg"} - suffixes
|
|
573
|
+
if missing:
|
|
574
|
+
errors.append(
|
|
575
|
+
f"final figure requires PDF and SVG vector pair: figures/{stem} "
|
|
576
|
+
f"(missing {', '.join(sorted(missing))})"
|
|
577
|
+
)
|
|
564
578
|
return errors
|
|
565
579
|
|
|
566
580
|
|
|
@@ -687,7 +701,7 @@ def ai_declaration_errors(
|
|
|
687
701
|
errors: list[str] = []
|
|
688
702
|
if not bool(ai_profile.get("declaration_required")):
|
|
689
703
|
return errors
|
|
690
|
-
declaration_source = root / "
|
|
704
|
+
declaration_source = delivery_directory(root) / "sections" / "ai-disclosure.tex"
|
|
691
705
|
declaration_text = (
|
|
692
706
|
declaration_source.read_text(encoding="utf-8", errors="replace")
|
|
693
707
|
if declaration_source.is_file()
|
|
@@ -710,7 +724,7 @@ def ai_declaration_errors(
|
|
|
710
724
|
|
|
711
725
|
if bool(ai_profile.get("declaration_before_references")):
|
|
712
726
|
if not main_tex.is_file():
|
|
713
|
-
errors.append("cannot verify AI declaration placement without
|
|
727
|
+
errors.append("cannot verify AI declaration placement without happy/main.tex")
|
|
714
728
|
return errors
|
|
715
729
|
main = re.sub(
|
|
716
730
|
r"\s+",
|
|
@@ -754,13 +768,10 @@ def expected_support_names(root: Path, ai_profile: dict[str, object], support_pr
|
|
|
754
768
|
names.add(path.relative_to(root).as_posix())
|
|
755
769
|
if bool(ai_profile.get("used")) and bool(ai_profile.get("details_pdf_required")):
|
|
756
770
|
names.add("AI工具使用详情.pdf")
|
|
757
|
-
environment = control_path(root, "environment.json")
|
|
758
|
-
if environment.is_file():
|
|
759
|
-
names.add("复现环境.json")
|
|
760
771
|
ai_log = control_path(
|
|
761
772
|
root,
|
|
762
773
|
"ai-use-log.md",
|
|
763
|
-
root / "
|
|
774
|
+
delivery_directory(root) / "ai-use-log.md",
|
|
764
775
|
)
|
|
765
776
|
if bool(support_profile.get("include_ai_log")) and ai_log.is_file():
|
|
766
777
|
names.add("AI工具使用记录.md")
|
|
@@ -821,7 +832,7 @@ def validate_evidence(root: Path, count: int, errors: list[str], warnings: list[
|
|
|
821
832
|
path = control_path(
|
|
822
833
|
root,
|
|
823
834
|
"evidence-map.yaml",
|
|
824
|
-
root / "
|
|
835
|
+
delivery_directory(root) / "evidence-map.yaml",
|
|
825
836
|
)
|
|
826
837
|
if not path.is_file():
|
|
827
838
|
errors.append("missing .cumcm/evidence-map.yaml")
|
|
@@ -851,7 +862,7 @@ def validate_evidence(root: Path, count: int, errors: list[str], warnings: list[
|
|
|
851
862
|
errors.append(f"duplicate evidence id: {claim_id}")
|
|
852
863
|
else:
|
|
853
864
|
seen_ids.add(claim_id)
|
|
854
|
-
for field, prefix in (("source", "results"), ("paper_section", "
|
|
865
|
+
for field, prefix in (("source", "results"), ("paper_section", "happy")):
|
|
855
866
|
value = claim.get(field)
|
|
856
867
|
if not isinstance(value, str) or not value:
|
|
857
868
|
errors.append(f"{location}.{field} is required")
|
|
@@ -864,12 +875,12 @@ def validate_evidence(root: Path, count: int, errors: list[str], warnings: list[
|
|
|
864
875
|
continue
|
|
865
876
|
relative = resolved.relative_to(root).as_posix()
|
|
866
877
|
if field == "paper_section" and not (
|
|
867
|
-
relative == "
|
|
868
|
-
or relative.startswith("
|
|
878
|
+
relative == "happy/main.tex"
|
|
879
|
+
or relative.startswith("happy/sections/")
|
|
869
880
|
):
|
|
870
881
|
errors.append(
|
|
871
|
-
f"{location}.paper_section must be
|
|
872
|
-
"or a legacy
|
|
882
|
+
f"{location}.paper_section must be happy/main.tex "
|
|
883
|
+
"or a legacy happy/sections file"
|
|
873
884
|
)
|
|
874
885
|
if not resolved.is_file():
|
|
875
886
|
errors.append(f"evidence path does not exist: {value}")
|
|
@@ -898,12 +909,11 @@ def code_architecture_errors(root: Path, count: int) -> list[str]:
|
|
|
898
909
|
f"q{number} contains only main.py; keep it orchestral and add "
|
|
899
910
|
"responsibility-named modules for the actual model and validation"
|
|
900
911
|
)
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
if "NotImplementedError" in main_text or "TODO" in main_text:
|
|
912
|
+
for module_path in modules:
|
|
913
|
+
module_text = module_path.read_text(encoding="utf-8", errors="replace")
|
|
914
|
+
if "NotImplementedError" in module_text or "TODO[" in module_text:
|
|
905
915
|
errors.append(
|
|
906
|
-
f"
|
|
916
|
+
f"{module_path.relative_to(root).as_posix()} is still an unimplemented scaffold"
|
|
907
917
|
)
|
|
908
918
|
return errors
|
|
909
919
|
|
|
@@ -982,7 +992,7 @@ def delivery_hygiene_warnings(root: Path) -> list[str]:
|
|
|
982
992
|
manifest = control_path(
|
|
983
993
|
root,
|
|
984
994
|
"project.json",
|
|
985
|
-
root / "
|
|
995
|
+
delivery_directory(root) / "question-count.json",
|
|
986
996
|
)
|
|
987
997
|
layout = ""
|
|
988
998
|
if manifest.is_file():
|
|
@@ -991,7 +1001,10 @@ def delivery_hygiene_warnings(root: Path) -> list[str]:
|
|
|
991
1001
|
except (OSError, ValueError, json.JSONDecodeError):
|
|
992
1002
|
pass
|
|
993
1003
|
if layout == "compact-v2":
|
|
994
|
-
for directory in (
|
|
1004
|
+
for directory in (
|
|
1005
|
+
delivery_directory(root) / "sections",
|
|
1006
|
+
delivery_directory(root) / "build",
|
|
1007
|
+
):
|
|
995
1008
|
if directory.is_dir():
|
|
996
1009
|
warnings.append(
|
|
997
1010
|
f"compact layout must not expose authoring directory: "
|
|
@@ -1007,16 +1020,19 @@ def delivery_hygiene_warnings(root: Path) -> list[str]:
|
|
|
1007
1020
|
"ai-use-log.md",
|
|
1008
1021
|
)
|
|
1009
1022
|
for name in legacy_controls:
|
|
1010
|
-
if (root /
|
|
1023
|
+
if (delivery_directory(root) / name).exists():
|
|
1011
1024
|
warnings.append(
|
|
1012
|
-
f"move internal workflow state out of
|
|
1025
|
+
f"move internal workflow state out of happy/: happy/{name}"
|
|
1013
1026
|
)
|
|
1014
|
-
if (
|
|
1027
|
+
if (
|
|
1028
|
+
(root / "code" / "finalize.py").exists()
|
|
1029
|
+
or (control_path(root, "finalize.py")).exists()
|
|
1030
|
+
):
|
|
1015
1031
|
warnings.append(
|
|
1016
|
-
"
|
|
1017
|
-
"
|
|
1032
|
+
"project-local finalize.py is redundant; call the active "
|
|
1033
|
+
"cumcm-draft/scripts/finalize_project.py directly"
|
|
1018
1034
|
)
|
|
1019
|
-
|
|
1035
|
+
allowed_happy_files = {
|
|
1020
1036
|
"AI工具使用详情.pdf",
|
|
1021
1037
|
"AI工具使用详情.tex",
|
|
1022
1038
|
"main.pdf",
|
|
@@ -1037,15 +1053,15 @@ def delivery_hygiene_warnings(root: Path) -> list[str]:
|
|
|
1037
1053
|
".toc",
|
|
1038
1054
|
".xdv",
|
|
1039
1055
|
}
|
|
1040
|
-
|
|
1041
|
-
if
|
|
1042
|
-
for path in
|
|
1043
|
-
if not path.is_file() or path.name in
|
|
1056
|
+
happy = delivery_directory(root)
|
|
1057
|
+
if happy.is_dir():
|
|
1058
|
+
for path in happy.iterdir():
|
|
1059
|
+
if not path.is_file() or path.name in allowed_happy_files:
|
|
1044
1060
|
continue
|
|
1045
1061
|
if any(path.name.endswith(suffix) for suffix in compile_suffixes):
|
|
1046
1062
|
continue
|
|
1047
1063
|
warnings.append(
|
|
1048
|
-
f"
|
|
1064
|
+
f"happy/ contains a non-delivery internal artifact: "
|
|
1049
1065
|
f"{path.relative_to(root).as_posix()}"
|
|
1050
1066
|
)
|
|
1051
1067
|
for summary in root.glob("results/q*/summary.json"):
|
|
@@ -1088,7 +1104,7 @@ def main() -> None:
|
|
|
1088
1104
|
result_artifact_profile = None
|
|
1089
1105
|
pdf_limit = page_limit = archive_limit = None
|
|
1090
1106
|
|
|
1091
|
-
for name in ("question", "code", "results", "figures", "
|
|
1107
|
+
for name in ("question", "code", "results", "figures", "happy"):
|
|
1092
1108
|
path = root / name
|
|
1093
1109
|
if not path.is_dir():
|
|
1094
1110
|
errors.append(f"missing top-level directory: {name}/")
|
|
@@ -1098,7 +1114,7 @@ def main() -> None:
|
|
|
1098
1114
|
count_path = control_path(
|
|
1099
1115
|
root,
|
|
1100
1116
|
"project.json",
|
|
1101
|
-
root / "
|
|
1117
|
+
delivery_directory(root) / "question-count.json",
|
|
1102
1118
|
)
|
|
1103
1119
|
count = 0
|
|
1104
1120
|
if not count_path.is_file():
|
|
@@ -1136,17 +1152,17 @@ def main() -> None:
|
|
|
1136
1152
|
for relative in required:
|
|
1137
1153
|
if not (root / relative).exists():
|
|
1138
1154
|
errors.append(f"missing subproblem artifact: {relative}")
|
|
1139
|
-
main_source = root / "
|
|
1140
|
-
legacy_section = root / "
|
|
1155
|
+
main_source = delivery_directory(root) / "main.tex"
|
|
1156
|
+
legacy_section = delivery_directory(root) / "sections" / f"{name}.tex"
|
|
1141
1157
|
if not legacy_section.is_file() and main_source.is_file():
|
|
1142
1158
|
main_content = main_source.read_text(encoding="utf-8", errors="replace")
|
|
1143
1159
|
if not re.search(rf"\\section\{{问题{number}(?:[::]|\}})", main_content):
|
|
1144
|
-
errors.append(f"
|
|
1160
|
+
errors.append(f"happy/main.tex is missing the problem {number} section")
|
|
1145
1161
|
|
|
1146
1162
|
inventory_path = control_path(
|
|
1147
1163
|
root,
|
|
1148
1164
|
"input-inventory.json",
|
|
1149
|
-
root / "
|
|
1165
|
+
delivery_directory(root) / "input-inventory.json",
|
|
1150
1166
|
)
|
|
1151
1167
|
if not inventory_path.is_file():
|
|
1152
1168
|
warnings.append("input inventory is missing; run inspect_inputs.py")
|
|
@@ -1162,7 +1178,7 @@ def main() -> None:
|
|
|
1162
1178
|
baseline = control_path(
|
|
1163
1179
|
root,
|
|
1164
1180
|
"question-fingerprint.json",
|
|
1165
|
-
root / "
|
|
1181
|
+
delivery_directory(root) / "question-fingerprint.json",
|
|
1166
1182
|
)
|
|
1167
1183
|
if not baseline.is_file():
|
|
1168
1184
|
warnings.append("question fingerprint baseline is missing; run inspect_inputs.py")
|
|
@@ -1212,7 +1228,7 @@ def main() -> None:
|
|
|
1212
1228
|
|
|
1213
1229
|
tex_files = [
|
|
1214
1230
|
path
|
|
1215
|
-
for base in (root
|
|
1231
|
+
for base in (delivery_directory(root), generated_directory(root))
|
|
1216
1232
|
if base.is_dir()
|
|
1217
1233
|
for path in base.rglob("*.tex")
|
|
1218
1234
|
if path.is_file() and not path.is_symlink()
|
|
@@ -1225,7 +1241,7 @@ def main() -> None:
|
|
|
1225
1241
|
errors.append("paper contains an absolute Windows path")
|
|
1226
1242
|
if re.search(r"(姓名|学号|学校|指导教师)\s*[::]\s*\S+", tex):
|
|
1227
1243
|
warnings.append("paper may contain identifying information")
|
|
1228
|
-
main_tex = root / "
|
|
1244
|
+
main_tex = delivery_directory(root) / "main.tex"
|
|
1229
1245
|
if main_tex.is_file():
|
|
1230
1246
|
content = main_tex.read_text(encoding="utf-8", errors="replace")
|
|
1231
1247
|
if profile.get("profile") == "cumcm-2026":
|
|
@@ -1240,24 +1256,24 @@ def main() -> None:
|
|
|
1240
1256
|
if bool(paper_profile.get("include_support_file_list")):
|
|
1241
1257
|
support_tex = generated_directory(root) / "support-files.tex"
|
|
1242
1258
|
if not support_tex.is_file():
|
|
1243
|
-
support_tex = root / "
|
|
1259
|
+
support_tex = delivery_directory(root) / "sections" / "support-files.tex"
|
|
1244
1260
|
if not support_tex.is_file() or "支撑材料文件列表" not in support_tex.read_text(encoding="utf-8", errors="replace"):
|
|
1245
1261
|
errors.append("CUMCM appendix is missing the required support-material file list")
|
|
1246
1262
|
if bool(paper_profile.get("include_source_appendix")):
|
|
1247
1263
|
source_tex = generated_directory(root) / "source-code.tex"
|
|
1248
1264
|
if not source_tex.is_file():
|
|
1249
|
-
source_tex = root / "
|
|
1265
|
+
source_tex = delivery_directory(root) / "sections" / "source-code.tex"
|
|
1250
1266
|
if not source_tex.is_file() or r"\lstinputlisting" not in source_tex.read_text(encoding="utf-8", errors="replace"):
|
|
1251
1267
|
errors.append("CUMCM appendix is missing complete runnable source listings")
|
|
1252
1268
|
|
|
1253
|
-
pdf = root / "
|
|
1269
|
+
pdf = delivery_directory(root) / "main.pdf"
|
|
1254
1270
|
if not pdf.is_file():
|
|
1255
|
-
errors.append("
|
|
1271
|
+
errors.append("happy/main.pdf is missing; run build_paper.py")
|
|
1256
1272
|
else:
|
|
1257
1273
|
if pdf_limit is not None and pdf.stat().st_size > pdf_limit * 1024 * 1024:
|
|
1258
|
-
errors.append(f"
|
|
1274
|
+
errors.append(f"happy/main.pdf exceeds active {pdf_limit:g} MB limit")
|
|
1259
1275
|
if any(path.stat().st_mtime > pdf.stat().st_mtime for path in tex_files):
|
|
1260
|
-
warnings.append("
|
|
1276
|
+
warnings.append("happy/main.pdf is older than at least one TeX source")
|
|
1261
1277
|
if profile.get("profile") == "cumcm-2026":
|
|
1262
1278
|
try:
|
|
1263
1279
|
from pypdf import PdfReader
|
|
@@ -1275,13 +1291,7 @@ def main() -> None:
|
|
|
1275
1291
|
except (IndexError, OSError, PdfReadError, ValueError) as error:
|
|
1276
1292
|
warnings.append(f"could not verify CUMCM first-page content: {error}")
|
|
1277
1293
|
|
|
1278
|
-
archive = root / "
|
|
1279
|
-
legacy_archive_used = False
|
|
1280
|
-
if not archive.is_file():
|
|
1281
|
-
legacy_archive = root / "paper" / "support-materials.zip"
|
|
1282
|
-
if legacy_archive.is_file():
|
|
1283
|
-
archive = legacy_archive
|
|
1284
|
-
legacy_archive_used = True
|
|
1294
|
+
archive = delivery_directory(root) / "支撑材料.zip"
|
|
1285
1295
|
if not archive.is_file():
|
|
1286
1296
|
warnings.append("支撑材料.zip is missing; run package_support.py")
|
|
1287
1297
|
else:
|
|
@@ -1299,21 +1309,10 @@ def main() -> None:
|
|
|
1299
1309
|
errors.append("support archive contains immutable question input files")
|
|
1300
1310
|
if any(name.endswith("ai-use-log.md") or name == "AI工具使用记录.md" for name in names) and not bool(support_profile.get("include_ai_log")):
|
|
1301
1311
|
errors.append("support archive leaks the internal AI use log contrary to profile")
|
|
1302
|
-
expected_ai_name =
|
|
1303
|
-
"paper/AI工具使用详情.pdf"
|
|
1304
|
-
if legacy_archive_used
|
|
1305
|
-
else "AI工具使用详情.pdf"
|
|
1306
|
-
)
|
|
1312
|
+
expected_ai_name = "AI工具使用详情.pdf"
|
|
1307
1313
|
if bool(ai_profile.get("used")) and bool(ai_profile.get("details_pdf_required")) and expected_ai_name not in names:
|
|
1308
1314
|
errors.append("support archive is missing required AI工具使用详情.pdf")
|
|
1309
1315
|
expected_names = expected_support_names(root, ai_profile, support_profile)
|
|
1310
|
-
if legacy_archive_used:
|
|
1311
|
-
if "AI工具使用详情.pdf" in expected_names:
|
|
1312
|
-
expected_names.remove("AI工具使用详情.pdf")
|
|
1313
|
-
expected_names.add("paper/AI工具使用详情.pdf")
|
|
1314
|
-
legacy_freeze = root / "paper" / "evidence-freeze.json"
|
|
1315
|
-
if legacy_freeze.is_file():
|
|
1316
|
-
expected_names.add("paper/evidence-freeze.json")
|
|
1317
1316
|
actual_names = set(names)
|
|
1318
1317
|
missing_names = sorted(expected_names - actual_names)
|
|
1319
1318
|
extra_names = sorted(actual_names - expected_names)
|
|
@@ -1326,7 +1325,7 @@ def main() -> None:
|
|
|
1326
1325
|
|
|
1327
1326
|
aux = build_directory(root) / "main.aux"
|
|
1328
1327
|
if not aux.is_file():
|
|
1329
|
-
aux = root / "
|
|
1328
|
+
aux = delivery_directory(root) / "build" / "main.aux"
|
|
1330
1329
|
if page_limit is not None and aux.is_file():
|
|
1331
1330
|
match = re.search(r"\\newlabel\{body-end\}\{\{.*?\}\{(\d+)\}", aux.read_text(encoding="utf-8", errors="replace"))
|
|
1332
1331
|
if match:
|
|
@@ -1342,13 +1341,13 @@ def main() -> None:
|
|
|
1342
1341
|
disclosure = control_path(
|
|
1343
1342
|
root,
|
|
1344
1343
|
"ai-use-log.md",
|
|
1345
|
-
root / "
|
|
1344
|
+
delivery_directory(root) / "ai-use-log.md",
|
|
1346
1345
|
)
|
|
1347
1346
|
if not disclosure.is_file():
|
|
1348
1347
|
warnings.append("internal AI use log is missing")
|
|
1349
|
-
if bool(ai_profile.get("details_pdf_required")) and not (root / "
|
|
1348
|
+
if bool(ai_profile.get("details_pdf_required")) and not (delivery_directory(root) / "AI工具使用详情.pdf").is_file():
|
|
1350
1349
|
errors.append("AI tool disclosure PDF is required but missing")
|
|
1351
|
-
details_source = root / "
|
|
1350
|
+
details_source = delivery_directory(root) / "AI工具使用详情.tex"
|
|
1352
1351
|
if bool(ai_profile.get("details_pdf_required")):
|
|
1353
1352
|
details_text = (
|
|
1354
1353
|
details_source.read_text(encoding="utf-8", errors="replace")
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import json
|
|
4
|
-
import os
|
|
5
|
-
import runpy
|
|
6
|
-
import shutil
|
|
7
|
-
import subprocess
|
|
8
|
-
import sys
|
|
9
|
-
from pathlib import Path
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
PROJECT_ROOT = Path(__file__).resolve().parent.parent
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def resolve_finalizer() -> Path:
|
|
16
|
-
development_root = os.environ.get("CUMCM_DRAFT_SKILL_ROOT")
|
|
17
|
-
if development_root:
|
|
18
|
-
candidate = Path(development_root).resolve() / "scripts" / "finalize_project.py"
|
|
19
|
-
if candidate.is_file() and not candidate.is_symlink():
|
|
20
|
-
return candidate
|
|
21
|
-
configured_roots = (
|
|
22
|
-
os.environ.get("ORBIT_SKILLS_DIRS")
|
|
23
|
-
or os.environ.get("ORBIT_SKILLS_DIR")
|
|
24
|
-
or ""
|
|
25
|
-
)
|
|
26
|
-
for raw_root in configured_roots.replace(",", ";").split(";"):
|
|
27
|
-
if not raw_root.strip():
|
|
28
|
-
continue
|
|
29
|
-
root = Path(os.path.expanduser(raw_root.strip())).resolve()
|
|
30
|
-
candidates = (
|
|
31
|
-
[root / "cumcm-draft", root]
|
|
32
|
-
if root.name != "cumcm-draft"
|
|
33
|
-
else [root]
|
|
34
|
-
)
|
|
35
|
-
for skill_root in candidates:
|
|
36
|
-
candidate = skill_root / "scripts" / "finalize_project.py"
|
|
37
|
-
if candidate.is_file() and not candidate.is_symlink():
|
|
38
|
-
return candidate
|
|
39
|
-
personal = (
|
|
40
|
-
Path.home()
|
|
41
|
-
/ ".orbit"
|
|
42
|
-
/ "skills"
|
|
43
|
-
/ "cumcm-draft"
|
|
44
|
-
/ "scripts"
|
|
45
|
-
/ "finalize_project.py"
|
|
46
|
-
)
|
|
47
|
-
if personal.is_file() and not personal.is_symlink():
|
|
48
|
-
return personal
|
|
49
|
-
orbit = shutil.which("orbit")
|
|
50
|
-
if orbit:
|
|
51
|
-
completed = subprocess.run(
|
|
52
|
-
[orbit, "skills", "list", "--json"],
|
|
53
|
-
cwd=PROJECT_ROOT,
|
|
54
|
-
text=True,
|
|
55
|
-
encoding="utf-8",
|
|
56
|
-
errors="replace",
|
|
57
|
-
stdout=subprocess.PIPE,
|
|
58
|
-
stderr=subprocess.PIPE,
|
|
59
|
-
check=False,
|
|
60
|
-
)
|
|
61
|
-
if completed.returncode == 0:
|
|
62
|
-
try:
|
|
63
|
-
payload = json.loads(completed.stdout)
|
|
64
|
-
except json.JSONDecodeError:
|
|
65
|
-
payload = {}
|
|
66
|
-
for skill in payload.get("skills", []):
|
|
67
|
-
if skill.get("name") != "cumcm-draft":
|
|
68
|
-
continue
|
|
69
|
-
candidate = (
|
|
70
|
-
Path(str(skill.get("path", ""))).resolve().parent
|
|
71
|
-
/ "scripts"
|
|
72
|
-
/ "finalize_project.py"
|
|
73
|
-
)
|
|
74
|
-
if candidate.is_file() and not candidate.is_symlink():
|
|
75
|
-
return candidate
|
|
76
|
-
raise SystemExit(
|
|
77
|
-
"Active cumcm-draft finalizer is missing. Run `orbit skills list` "
|
|
78
|
-
"and ensure the bundled or personal Skill is enabled."
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
def main() -> None:
|
|
83
|
-
finalizer = resolve_finalizer()
|
|
84
|
-
sys.path.insert(0, str(finalizer.parent))
|
|
85
|
-
sys.argv = [str(finalizer), str(PROJECT_ROOT), *sys.argv[1:]]
|
|
86
|
-
runpy.run_path(str(finalizer), run_name="__main__")
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if __name__ == "__main__":
|
|
90
|
-
main()
|
|
File without changes
|
|
File without changes
|