@orbit-build/cli 0.8.3 → 0.8.5

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.
Files changed (44) hide show
  1. package/README.md +4 -1
  2. package/dist/index.js +558 -151
  3. package/package.json +1 -1
  4. package/skills/cumcm-draft/SKILL.md +92 -48
  5. package/skills/cumcm-draft/agents/openai.yaml +1 -1
  6. package/skills/cumcm-draft/assets/project-template/{code → .cumcm}/finalize.py +33 -4
  7. package/skills/cumcm-draft/assets/project-template/{paper/contest-profile.json → .cumcm/profile.json} +9 -6
  8. package/skills/cumcm-draft/assets/project-template/code/requirements.txt +1 -11
  9. package/skills/cumcm-draft/assets/project-template/paper/AI/345/267/245/345/205/267/344/275/277/347/224/250/350/257/246/346/203/205.tex +1 -11
  10. package/skills/cumcm-draft/assets/project-template/paper/main.tex +70 -11
  11. package/skills/cumcm-draft/references/code-and-output-style.md +9 -14
  12. package/skills/cumcm-draft/references/cumcm-compliance.md +28 -25
  13. package/skills/cumcm-draft/references/latex-figures-tables.md +1 -1
  14. package/skills/cumcm-draft/references/modeling-quality.md +1 -1
  15. package/skills/cumcm-draft/references/paper-architecture.md +3 -3
  16. package/skills/cumcm-draft/references/project-architecture.md +70 -89
  17. package/skills/cumcm-draft/scripts/audit_paper.py +37 -9
  18. package/skills/cumcm-draft/scripts/bootstrap_project.py +182 -56
  19. package/skills/cumcm-draft/scripts/build_paper.py +38 -23
  20. package/skills/cumcm-draft/scripts/capture_environment.py +3 -1
  21. package/skills/cumcm-draft/scripts/clean_project.py +7 -2
  22. package/skills/cumcm-draft/scripts/evidence_freeze.py +8 -4
  23. package/skills/cumcm-draft/scripts/finalize_project.py +4 -0
  24. package/skills/cumcm-draft/scripts/inspect_inputs.py +6 -4
  25. package/skills/cumcm-draft/scripts/package_support.py +41 -15
  26. package/skills/cumcm-draft/scripts/project_utils.py +40 -8
  27. package/skills/cumcm-draft/scripts/validate_project.py +374 -57
  28. package/skills/cumcm-draft/assets/project-template/code/always/__init__.py +0 -1
  29. package/skills/cumcm-draft/assets/project-template/code/always/config.py +0 -18
  30. package/skills/cumcm-draft/assets/project-template/code/always/data.py +0 -24
  31. package/skills/cumcm-draft/assets/project-template/code/always/plotting.py +0 -25
  32. package/skills/cumcm-draft/assets/project-template/code/always/validation.py +0 -21
  33. package/skills/cumcm-draft/assets/project-template/paper/sections/abstract.tex +0 -6
  34. package/skills/cumcm-draft/assets/project-template/paper/sections/ai-disclosure.tex +0 -3
  35. package/skills/cumcm-draft/assets/project-template/paper/sections/appendix.tex +0 -3
  36. package/skills/cumcm-draft/assets/project-template/paper/sections/assumptions.tex +0 -5
  37. package/skills/cumcm-draft/assets/project-template/paper/sections/data.tex +0 -19
  38. package/skills/cumcm-draft/assets/project-template/paper/sections/evaluation.tex +0 -9
  39. package/skills/cumcm-draft/assets/project-template/paper/sections/problem-analysis.tex +0 -3
  40. package/skills/cumcm-draft/assets/project-template/paper/sections/problem-restatement.tex +0 -3
  41. package/skills/cumcm-draft/assets/project-template/paper/sections/references.tex +0 -12
  42. package/skills/cumcm-draft/assets/project-template/paper/sections/source-code.tex +0 -1
  43. package/skills/cumcm-draft/assets/project-template/paper/sections/support-files.tex +0 -3
  44. /package/skills/cumcm-draft/assets/project-template/{paper → .cumcm}/ai-use-log.md +0 -0
@@ -6,16 +6,27 @@ import re
6
6
  import shutil
7
7
  from pathlib import Path
8
8
 
9
- from project_utils import question_numbers
9
+ from project_utils import control_directory, control_path, question_numbers
10
10
 
11
11
 
12
12
  SKILL_ROOT = Path(__file__).resolve().parents[1]
13
13
  TEMPLATE_ROOT = SKILL_ROOT / "assets" / "project-template"
14
+ QUESTION_BEGIN = "% ORBIT:QUESTIONS:BEGIN"
15
+ QUESTION_END = "% ORBIT:QUESTIONS:END"
16
+ LEGACY_CONTROL_FILES = {
17
+ "contest-profile.json": "profile.json",
18
+ "question-count.json": "project.json",
19
+ "evidence-map.yaml": "evidence-map.yaml",
20
+ "input-inventory.json": "input-inventory.json",
21
+ "question-fingerprint.json": "question-fingerprint.json",
22
+ "ai-use-log.md": "ai-use-log.md",
23
+ "evidence-freeze.json": "evidence-freeze.json",
24
+ }
14
25
 
15
26
 
16
27
  def main() -> None:
17
28
  parser = argparse.ArgumentParser(
18
- description="Create or extend a non-destructive modeling project skeleton."
29
+ description="Create or extend a compact, non-destructive modeling project."
19
30
  )
20
31
  parser.add_argument("project_root", type=Path)
21
32
  parser.add_argument("--questions", type=int, required=True)
@@ -29,30 +40,56 @@ def main() -> None:
29
40
  preserved: list[str] = []
30
41
  for directory in (
31
42
  root / "question",
32
- root / "code" / "always",
33
- root / "paper" / "sections",
34
- root / "paper" / "build",
43
+ root / "code",
44
+ root / "paper",
45
+ control_directory(root),
46
+ control_directory(root) / "build",
47
+ control_directory(root) / "generated",
35
48
  ):
36
49
  directory.mkdir(parents=True, exist_ok=True)
37
50
 
51
+ migrate_legacy_control_files(root, created, preserved)
52
+ copy_template_tree(root, created, preserved)
38
53
  declared = read_declared_count(root)
39
54
  discovered = max(question_numbers(root), default=0)
40
55
  question_count = max(args.questions, declared, discovered)
41
- copy_template_tree(root, created, preserved)
42
56
  create_question_files(root, question_count, created, updated, preserved)
43
57
  extend_evidence_map(root, question_count, created, updated)
44
58
 
45
- print(f"[OK] Project skeleton ready: {root}")
59
+ print(f"[OK] Compact project skeleton ready: {root}")
46
60
  print(
47
61
  f" Questions: {question_count}; created {len(created)}, "
48
62
  f"updated {len(updated)}, preserved {len(preserved)} file(s)."
49
63
  )
64
+ print(
65
+ " paper/ contains only editable paper sources and final deliverables; "
66
+ ".cumcm/ owns workflow state and build caches."
67
+ )
50
68
  if updated:
51
69
  print(" Updated orchestrators: " + ", ".join(updated))
52
70
 
53
71
 
72
+ def migrate_legacy_control_files(
73
+ root: Path, created: list[str], preserved: list[str]
74
+ ) -> None:
75
+ """Copy legacy 0.8.3 state into .cumcm without deleting user files."""
76
+ destination_root = control_directory(root)
77
+ for legacy_name, current_name in LEGACY_CONTROL_FILES.items():
78
+ source = root / "paper" / legacy_name
79
+ target = destination_root / current_name
80
+ if target.exists():
81
+ preserved.append(target.relative_to(root).as_posix())
82
+ elif source.is_file() and not source.is_symlink():
83
+ shutil.copy2(source, target)
84
+ created.append(target.relative_to(root).as_posix())
85
+
86
+
54
87
  def read_declared_count(root: Path) -> int:
55
- path = root / "paper" / "question-count.json"
88
+ path = control_path(
89
+ root,
90
+ "project.json",
91
+ root / "paper" / "question-count.json",
92
+ )
56
93
  if not path.is_file():
57
94
  return 0
58
95
  try:
@@ -62,7 +99,9 @@ def read_declared_count(root: Path) -> int:
62
99
  return count if 1 <= count <= 20 else 0
63
100
 
64
101
 
65
- def copy_template_tree(root: Path, created: list[str], preserved: list[str]) -> None:
102
+ def copy_template_tree(
103
+ root: Path, created: list[str], preserved: list[str]
104
+ ) -> None:
66
105
  for source in TEMPLATE_ROOT.rglob("*"):
67
106
  if not source.is_file():
68
107
  continue
@@ -85,47 +124,113 @@ def create_question_files(
85
124
  ) -> None:
86
125
  for number in range(1, count + 1):
87
126
  name = f"q{number}"
88
- for directory in (root / "code" / name, root / "results" / name, root / "figures" / name):
127
+ for directory in (
128
+ root / "code" / name,
129
+ root / "results" / name,
130
+ root / "figures" / name,
131
+ ):
89
132
  directory.mkdir(parents=True, exist_ok=True)
90
- files = {
91
- root / "code" / name / "__init__.py": "",
92
- root / "code" / name / "main.py": question_main(name),
93
- root / "paper" / "sections" / f"{name}.tex": question_tex(number),
94
- }
95
- for path, content in files.items():
96
- write_if_missing(root, path, content, created, preserved)
97
-
98
- merge_questions_tex(root, count, created, updated)
133
+ write_if_missing(
134
+ root,
135
+ root / "code" / name / "main.py",
136
+ question_main(name),
137
+ created,
138
+ preserved,
139
+ )
140
+
141
+ legacy_sections = root / "paper" / "sections"
142
+ if legacy_sections.is_dir():
143
+ create_legacy_question_sections(
144
+ root, count, created, updated, preserved
145
+ )
146
+ else:
147
+ merge_questions_into_main(root, count, updated)
99
148
  merge_run_all(root, count, created, updated)
100
- write_count(root, count, created, updated)
149
+ write_project_manifest(root, count, created, updated)
101
150
 
102
151
 
103
- def merge_questions_tex(root: Path, count: int, created: list[str], updated: list[str]) -> None:
152
+ def create_legacy_question_sections(
153
+ root: Path,
154
+ count: int,
155
+ created: list[str],
156
+ updated: list[str],
157
+ preserved: list[str],
158
+ ) -> None:
159
+ for number in range(1, count + 1):
160
+ write_if_missing(
161
+ root,
162
+ root / "paper" / "sections" / f"q{number}.tex",
163
+ question_tex(number),
164
+ created,
165
+ preserved,
166
+ )
104
167
  path = root / "paper" / "sections" / "questions.tex"
105
168
  if not path.exists():
106
- path.write_text("".join(f"\\input{{sections/q{i}}}\n" for i in range(1, count + 1)), encoding="utf-8")
169
+ path.write_text(
170
+ "".join(f"\\input{{sections/q{i}}}\n" for i in range(1, count + 1)),
171
+ encoding="utf-8",
172
+ )
107
173
  created.append(path.relative_to(root).as_posix())
108
174
  return
109
175
  content = path.read_text(encoding="utf-8")
110
- additions = [f"\\input{{sections/q{i}}}" for i in range(1, count + 1) if not re.search(rf"\\input\{{sections/q{i}\}}", content)]
176
+ additions = [
177
+ f"\\input{{sections/q{i}}}"
178
+ for i in range(1, count + 1)
179
+ if not re.search(rf"\\input\{{sections/q{i}\}}", content)
180
+ ]
111
181
  if additions:
112
- path.write_text(content.rstrip() + "\n" + "\n".join(additions) + "\n", encoding="utf-8")
182
+ path.write_text(
183
+ content.rstrip() + "\n" + "\n".join(additions) + "\n",
184
+ encoding="utf-8",
185
+ )
113
186
  updated.append(path.relative_to(root).as_posix())
114
187
 
115
188
 
116
- def merge_run_all(root: Path, count: int, created: list[str], updated: list[str]) -> None:
189
+ def merge_questions_into_main(root: Path, count: int, updated: list[str]) -> None:
190
+ path = root / "paper" / "main.tex"
191
+ if not path.is_file():
192
+ raise SystemExit(f"Missing compact paper template: {path}")
193
+ content = path.read_text(encoding="utf-8")
194
+ if QUESTION_BEGIN not in content or QUESTION_END not in content:
195
+ print(
196
+ "[WARN] Preserved custom paper/main.tex without Orbit question markers; "
197
+ "add missing question sections manually."
198
+ )
199
+ return
200
+ additions = [
201
+ question_tex(number).rstrip()
202
+ for number in range(1, count + 1)
203
+ if not re.search(rf"\\section\{{问题{number}(?:[::]|\}})", content)
204
+ ]
205
+ if not additions:
206
+ return
207
+ insertion = "\n\n".join(additions) + "\n"
208
+ content = content.replace(QUESTION_END, insertion + QUESTION_END, 1)
209
+ path.write_text(content, encoding="utf-8")
210
+ updated.append(path.relative_to(root).as_posix())
211
+
212
+
213
+ def merge_run_all(
214
+ root: Path, count: int, created: list[str], updated: list[str]
215
+ ) -> None:
117
216
  path = root / "code" / "run_all.py"
118
217
  if not path.exists():
119
218
  path.write_text(run_all(count), encoding="utf-8")
120
219
  created.append(path.relative_to(root).as_posix())
121
220
  return
122
221
  content = path.read_text(encoding="utf-8")
123
- missing = [f'q{i}.main' for i in range(1, count + 1) if f'"q{i}.main"' not in content and f"'q{i}.main'" not in content]
222
+ missing = [
223
+ f"q{i}.main"
224
+ for i in range(1, count + 1)
225
+ if f'"q{i}.main"' not in content and f"'q{i}.main'" not in content
226
+ ]
124
227
  if not missing:
125
228
  return
126
229
  match = re.search(r"(?ms)(^\s*modules\s*=\s*\[.*?)(^\s*\])", content)
127
230
  if not match:
128
- print(f"[WARN] Preserved custom run_all.py; add manually: {', '.join(missing)}")
231
+ print(
232
+ f"[WARN] Preserved custom run_all.py; add manually: {', '.join(missing)}"
233
+ )
129
234
  return
130
235
  indent = re.match(r"\s*", match.group(2)).group(0)
131
236
  rows = "".join(f'{indent} "{module}",\n' for module in missing)
@@ -134,8 +239,10 @@ def merge_run_all(root: Path, count: int, created: list[str], updated: list[str]
134
239
  updated.append(path.relative_to(root).as_posix())
135
240
 
136
241
 
137
- def write_count(root: Path, count: int, created: list[str], updated: list[str]) -> None:
138
- path = root / "paper" / "question-count.json"
242
+ def write_project_manifest(
243
+ root: Path, count: int, created: list[str], updated: list[str]
244
+ ) -> None:
245
+ path = control_directory(root) / "project.json"
139
246
  existing: dict[str, object] = {}
140
247
  if path.is_file():
141
248
  try:
@@ -144,8 +251,18 @@ def write_count(root: Path, count: int, created: list[str], updated: list[str])
144
251
  existing = payload
145
252
  except (OSError, json.JSONDecodeError):
146
253
  pass
254
+ existing["schema_version"] = 1
255
+ existing["layout"] = (
256
+ "legacy-v1"
257
+ if (root / "paper" / "sections").is_dir()
258
+ else "compact-v2"
259
+ )
147
260
  existing["questions"] = count
148
- existing["support_paths"] = [item for i in range(1, count + 1) for item in (f"code/q{i}", f"results/q{i}", f"figures/q{i}")]
261
+ existing["support_paths"] = [
262
+ item
263
+ for i in range(1, count + 1)
264
+ for item in (f"code/q{i}", f"results/q{i}", f"figures/q{i}")
265
+ ]
149
266
  rendered = json.dumps(existing, ensure_ascii=False, indent=2) + "\n"
150
267
  if path.exists() and path.read_text(encoding="utf-8") == rendered:
151
268
  return
@@ -154,9 +271,19 @@ def write_count(root: Path, count: int, created: list[str], updated: list[str])
154
271
  (updated if was_present else created).append(path.relative_to(root).as_posix())
155
272
 
156
273
 
157
- def extend_evidence_map(root: Path, count: int, created: list[str], updated: list[str]) -> None:
158
- path = root / "paper" / "evidence-map.yaml"
159
- content = path.read_text(encoding="utf-8") if path.exists() else "# Claims must resolve to program-generated evidence.\n"
274
+ def extend_evidence_map(
275
+ root: Path, count: int, created: list[str], updated: list[str]
276
+ ) -> None:
277
+ path = control_path(
278
+ root,
279
+ "evidence-map.yaml",
280
+ root / "paper" / "evidence-map.yaml",
281
+ )
282
+ content = (
283
+ path.read_text(encoding="utf-8")
284
+ if path.exists()
285
+ else "# Claims must resolve to program-generated evidence.\n"
286
+ )
160
287
  additions: list[str] = []
161
288
  for i in range(1, count + 1):
162
289
  if not re.search(rf"(?m)^q{i}:\s*$", content):
@@ -166,8 +293,8 @@ def extend_evidence_map(root: Path, count: int, created: list[str], updated: lis
166
293
  " claims:",
167
294
  f" - id: q{i}-main-result",
168
295
  f" generated_by: code/q{i}/main.py",
169
- f" source: results/q{i}/summary.json",
170
- f" paper_section: paper/sections/q{i}.tex",
296
+ f" source: results/q{i}/TODO-替换为实际中文结果文件",
297
+ " paper_section: paper/main.tex",
171
298
  " upstream: TODO",
172
299
  " validation: TODO",
173
300
  " status: TODO",
@@ -177,11 +304,18 @@ def extend_evidence_map(root: Path, count: int, created: list[str], updated: lis
177
304
  return
178
305
  rendered = content.rstrip() + "\n" + "\n".join(additions) + "\n"
179
306
  existed = path.exists()
307
+ path.parent.mkdir(parents=True, exist_ok=True)
180
308
  path.write_text(rendered, encoding="utf-8")
181
309
  (updated if existed else created).append(path.relative_to(root).as_posix())
182
310
 
183
311
 
184
- def write_if_missing(root: Path, path: Path, content: str, created: list[str], preserved: list[str]) -> None:
312
+ def write_if_missing(
313
+ root: Path,
314
+ path: Path,
315
+ content: str,
316
+ created: list[str],
317
+ preserved: list[str],
318
+ ) -> None:
185
319
  relative = path.relative_to(root).as_posix()
186
320
  if path.exists():
187
321
  preserved.append(relative)
@@ -194,28 +328,20 @@ def write_if_missing(root: Path, path: Path, content: str, created: list[str], p
194
328
  def question_main(name: str) -> str:
195
329
  return f'''from __future__ import annotations
196
330
 
197
- import json
331
+ from pathlib import Path
198
332
 
199
- from always.config import question_output_dirs
333
+
334
+ PROJECT_ROOT = Path(__file__).resolve().parents[2]
335
+ RESULTS_DIR = PROJECT_ROOT / "results" / "{name}"
336
+ FIGURES_DIR = PROJECT_ROOT / "figures" / "{name}"
200
337
 
201
338
 
202
339
  def main() -> None:
203
- results_dir, figure_dir = question_output_dirs("{name}")
204
- results_dir.mkdir(parents=True, exist_ok=True)
205
- figure_dir.mkdir(parents=True, exist_ok=True)
206
-
207
- # 脚手架只保留入口;读题后请创建按实际职责命名的领域模块。
208
- summary = {{
209
- "question": "{name}",
210
- "status": "TODO",
211
- "validation": {{"selection_data": "TODO", "test_data": "TODO", "checks": []}},
212
- "claims": [],
213
- }}
214
- (results_dir / "summary.json").write_text(
215
- json.dumps(summary, ensure_ascii=False, indent=2) + "\\n",
216
- encoding="utf-8",
217
- )
218
- print("[OK] {name} scaffold completed")
340
+ RESULTS_DIR.mkdir(parents=True, exist_ok=True)
341
+ FIGURES_DIR.mkdir(parents=True, exist_ok=True)
342
+ # 读题后:让 main.py 只编排输入、领域计算、检验和落盘。
343
+ # 将实际模型拆到按职责命名的同级模块,并使用中文结果/图件文件名。
344
+ raise NotImplementedError("请先实现问题{name}的真实模型与验证流程")
219
345
 
220
346
 
221
347
  if __name__ == "__main__":
@@ -230,7 +356,7 @@ def question_tex(number: int) -> str:
230
356
  \TODO{{明确本题交付、输入、单位及其与前后小题的数据关系;成稿时把本标题改成领域化标题。}}
231
357
 
232
358
  \subsection{{方法比较与选择依据}}
233
- \TODO{{比较候选方法,说明所选方法为何匹配数据、约束和决策目标。}}\AIUseMark
359
+ \TODO{{比较候选方法,说明所选方法为何匹配数据、约束和决策目标。}}
234
360
 
235
361
  \subsection{{模型构建与参数来源}}
236
362
  \TODO{{定义变量、目标函数、约束和参数来源,保持符号、单位与代码一致。}}
@@ -239,7 +365,7 @@ def question_tex(number: int) -> str:
239
365
  \TODO{{说明算法步骤、数据切分、边界处理及结果文件的生成路径。}}
240
366
 
241
367
  \subsection{{结果解释与有效性检验}}
242
- \TODO{{从 results/q{number}/ 引用实际数值和 figures/q{number}/ 的当前图,解释结果并报告误差、敏感性、稳健性或基线比较。}}
368
+ \TODO{{从 results/q{number}/ 引用实际中文结果文件和 figures/q{number}/ 的描述性中文图件,解释结果并报告误差、敏感性、稳健性或基线比较。}}
243
369
 
244
370
  \subsection{{本问结论与后续接口}}
245
371
  \TODO{{用两三句话直接回答本题,并说明输出如何进入下一问;成稿时按实际内容改名。}}
@@ -8,7 +8,14 @@ import subprocess
8
8
  from collections import defaultdict
9
9
  from pathlib import Path
10
10
 
11
- from project_utils import iter_regular_files, load_profile, numeric_limit
11
+ from project_utils import (
12
+ build_directory,
13
+ control_path,
14
+ generated_directory,
15
+ iter_regular_files,
16
+ load_profile,
17
+ numeric_limit,
18
+ )
12
19
 
13
20
 
14
21
  EXCLUDED_PARTS = {
@@ -72,25 +79,31 @@ def tex_file_name(value: str) -> str:
72
79
 
73
80
 
74
81
  def generate_appendices(root: Path, profile: dict[str, object]) -> None:
75
- sections = root / "paper" / "sections"
76
- sections.mkdir(parents=True, exist_ok=True)
82
+ generated = generated_directory(root)
83
+ generated.mkdir(parents=True, exist_ok=True)
77
84
  paper_profile = profile["paper"]
78
85
  assert isinstance(paper_profile, dict)
79
86
 
80
- support_path = sections / "support-files.tex"
87
+ support_path = generated / "support-files.tex"
81
88
  if bool(paper_profile.get("include_support_file_list")):
82
89
  support = []
83
90
  for directory in ("code", "results", "figures"):
84
91
  support.extend(path.relative_to(root).as_posix() for path in iter_regular_files(root, directory, EXCLUDED_PARTS))
85
92
  ai_pdf = root / "paper" / "AI工具使用详情.pdf"
86
93
  if ai_pdf.is_file():
87
- support.append("paper/AI工具使用详情.pdf")
88
- support.append("paper/evidence-freeze.json")
94
+ support.append("AI工具使用详情.pdf")
89
95
  support_profile = profile["support"]
90
96
  assert isinstance(support_profile, dict)
91
- ai_log = root / "paper" / "ai-use-log.md"
97
+ environment = control_path(root, "environment.json")
98
+ if environment.is_file():
99
+ support.append("复现环境.json")
100
+ ai_log = control_path(
101
+ root,
102
+ "ai-use-log.md",
103
+ root / "paper" / "ai-use-log.md",
104
+ )
92
105
  if bool(support_profile.get("include_ai_log")) and ai_log.is_file():
93
- support.append("paper/ai-use-log.md")
106
+ support.append("AI工具使用记录.md")
94
107
  grouped: dict[str, list[str]] = defaultdict(list)
95
108
  for path in sorted(set(support)):
96
109
  item = Path(path)
@@ -117,9 +130,9 @@ def generate_appendices(root: Path, profile: dict[str, object]) -> None:
117
130
  rows.extend([" \\bottomrule", "\\end{longtable}", "\\normalsize"])
118
131
  support_path.write_text("\n".join(rows) + "\n", encoding="utf-8")
119
132
  else:
120
- support_path.write_text("% Disabled by paper/contest-profile.json.\n", encoding="utf-8")
133
+ support_path.write_text("% Disabled by .cumcm/profile.json.\n", encoding="utf-8")
121
134
 
122
- source_path = sections / "source-code.tex"
135
+ source_path = generated / "source-code.tex"
123
136
  if bool(paper_profile.get("include_source_appendix")):
124
137
  listings = [
125
138
  "\\section{完整可运行程序代码}",
@@ -148,18 +161,19 @@ def generate_appendices(root: Path, profile: dict[str, object]) -> None:
148
161
  )
149
162
  source_path.write_text("\n\n".join(listings) + "\n", encoding="utf-8")
150
163
  else:
151
- source_path.write_text("% Disabled by paper/contest-profile.json.\n", encoding="utf-8")
164
+ source_path.write_text("% Disabled by .cumcm/profile.json.\n", encoding="utf-8")
152
165
 
153
166
 
154
- def find_engine() -> tuple[list[str], str]:
167
+ def find_engine(output_directory: Path) -> tuple[list[str], str]:
168
+ output = str(output_directory)
155
169
  xelatex = shutil.which("xelatex")
156
170
  if os.name == "nt" and xelatex:
157
- return [xelatex, "-interaction=nonstopmode", "-halt-on-error", "-file-line-error", "-output-directory=build", "main.tex"], "xelatex"
171
+ return [xelatex, "-interaction=nonstopmode", "-halt-on-error", "-file-line-error", f"-output-directory={output}", "main.tex"], "xelatex"
158
172
  latexmk = shutil.which("latexmk")
159
173
  if latexmk:
160
- return [latexmk, "-xelatex", "-interaction=nonstopmode", "-halt-on-error", "-file-line-error", "-outdir=build", "main.tex"], "latexmk"
174
+ return [latexmk, "-xelatex", "-interaction=nonstopmode", "-halt-on-error", "-file-line-error", f"-outdir={output}", "main.tex"], "latexmk"
161
175
  if xelatex:
162
- return [xelatex, "-interaction=nonstopmode", "-halt-on-error", "-file-line-error", "-output-directory=build", "main.tex"], "xelatex"
176
+ return [xelatex, "-interaction=nonstopmode", "-halt-on-error", "-file-line-error", f"-output-directory={output}", "main.tex"], "xelatex"
163
177
  raise SystemExit("Neither latexmk nor xelatex is available on PATH (TeX Live required).")
164
178
 
165
179
 
@@ -189,9 +203,8 @@ def audit_log(log_path: Path, strict_layout: bool) -> None:
189
203
  raise SystemExit("TeX quality audit failed: " + ", ".join(failures) + f". Inspect {log_path}\n{diagnostics}")
190
204
 
191
205
 
192
- def clear_entry_build_artifacts(paper: Path, source_name: str) -> None:
206
+ def clear_entry_build_artifacts(build: Path, source_name: str) -> None:
193
207
  """Remove only deterministic outputs for one TeX entry point."""
194
- build = paper / "build"
195
208
  stem = Path(source_name).stem
196
209
  for suffix in BUILD_ARTIFACT_SUFFIXES:
197
210
  target = build / f"{stem}{suffix}"
@@ -229,23 +242,25 @@ def build_tex(paper: Path, source_name: str, output_name: str, strict_layout: bo
229
242
  source = paper / source_name
230
243
  if source.is_symlink():
231
244
  raise SystemExit(f"Symbolic TeX entry points are not allowed: {source}")
232
- clear_entry_build_artifacts(paper, source_name)
233
- command, engine = find_engine()
245
+ build = build_directory(paper.parent)
246
+ build.mkdir(parents=True, exist_ok=True)
247
+ clear_entry_build_artifacts(build, source_name)
248
+ command, engine = find_engine(build)
234
249
  command[-1] = source_name
235
250
  completed = run(command, paper)
236
251
  if completed.returncode == 0 and engine == "xelatex":
237
252
  completed = run(command, paper)
238
253
  if completed.returncode != 0:
239
254
  stem = Path(source_name).stem
240
- log_path = paper / "build" / f"{stem}.log"
255
+ log_path = build / f"{stem}.log"
241
256
  diagnostics = tex_failure_diagnostics(log_path, completed.stdout)
242
257
  raise SystemExit(
243
258
  f"TeX build failed ({engine}, {source_name}). "
244
259
  f"Repair the first reported source error and rerun the finalizer.\n{diagnostics}"
245
260
  )
246
261
  stem = Path(source_name).stem
247
- built = paper / "build" / f"{stem}.pdf"
248
- audit_log(paper / "build" / f"{stem}.log", strict_layout)
262
+ built = build / f"{stem}.pdf"
263
+ audit_log(build / f"{stem}.log", strict_layout)
249
264
  if not built.is_file():
250
265
  raise SystemExit(f"TeX reported success but did not create {built}")
251
266
  final = paper / output_name
@@ -274,7 +289,7 @@ def main() -> None:
274
289
  pdf_limit = numeric_limit(profile["paper"], "max_pdf_mb")
275
290
  except (ValueError, TypeError) as error:
276
291
  raise SystemExit(str(error)) from error
277
- (paper / "build").mkdir(parents=True, exist_ok=True)
292
+ build_directory(root).mkdir(parents=True, exist_ok=True)
278
293
 
279
294
  ai_profile = profile["ai"]
280
295
  assert isinstance(ai_profile, dict)
@@ -7,6 +7,8 @@ import platform
7
7
  import sys
8
8
  from pathlib import Path
9
9
 
10
+ from project_utils import control_directory
11
+
10
12
 
11
13
  def main() -> None:
12
14
  parser = argparse.ArgumentParser(description="Capture the reproducibility environment.")
@@ -36,7 +38,7 @@ def main() -> None:
36
38
  "platform": platform.platform(),
37
39
  "packages": packages,
38
40
  }
39
- output = root / "results" / "environment.json"
41
+ output = control_directory(root) / "environment.json"
40
42
  output.parent.mkdir(parents=True, exist_ok=True)
41
43
  output.write_text(json.dumps(payload, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
42
44
  print(f"[OK] Environment captured: {output}")
@@ -4,6 +4,8 @@ import argparse
4
4
  import shutil
5
5
  from pathlib import Path
6
6
 
7
+ from project_utils import build_directory
8
+
7
9
 
8
10
  CACHE_DIR_NAMES = {
9
11
  "__pycache__",
@@ -23,9 +25,12 @@ def targets(root: Path) -> list[Path]:
23
25
  if path.is_dir() and path.name in CACHE_DIR_NAMES:
24
26
  found.add(path)
25
27
  elif path.is_file() and any(path.name.endswith(suffix) for suffix in TEX_CACHE_SUFFIXES):
26
- if "paper" in path.relative_to(root).parts:
28
+ if any(
29
+ part in {"paper", ".cumcm"}
30
+ for part in path.relative_to(root).parts
31
+ ):
27
32
  found.add(path)
28
- page_review = root / "paper" / "build" / "page-review"
33
+ page_review = build_directory(root) / "page-review"
29
34
  if page_review.is_dir() and not page_review.is_symlink():
30
35
  found.add(page_review)
31
36
  return sorted(found, key=lambda path: (len(path.parts), str(path)), reverse=True)
@@ -7,7 +7,7 @@ from datetime import datetime, timezone
7
7
  from pathlib import Path
8
8
  from typing import Any
9
9
 
10
- from project_utils import iter_regular_files
10
+ from project_utils import control_path, iter_regular_files
11
11
 
12
12
 
13
13
  EXCLUDED_PARTS = {"__pycache__", ".pytest_cache", ".mypy_cache", ".ruff_cache", "build"}
@@ -37,7 +37,11 @@ def snapshot_evidence(root: Path) -> list[dict[str, Any]]:
37
37
 
38
38
 
39
39
  def freeze_path(root: Path) -> Path:
40
- return root / "paper" / "evidence-freeze.json"
40
+ return control_path(
41
+ root,
42
+ "evidence-freeze.json",
43
+ root / "paper" / "evidence-freeze.json",
44
+ )
41
45
 
42
46
 
43
47
  def load_freeze(root: Path) -> dict[str, Any] | None:
@@ -53,7 +57,7 @@ def load_freeze(root: Path) -> dict[str, Any] | None:
53
57
  def evidence_differences(root: Path) -> list[str]:
54
58
  payload = load_freeze(root)
55
59
  if payload is None:
56
- return ["paper/evidence-freeze.json is missing"]
60
+ return [".cumcm/evidence-freeze.json is missing"]
57
61
  expected = {str(item["path"]): (int(item["size_bytes"]), str(item["sha256"])) for item in payload["files"] if isinstance(item, dict)}
58
62
  actual = {str(item["path"]): (int(item["size_bytes"]), str(item["sha256"])) for item in snapshot_evidence(root)}
59
63
  differences = [f"added evidence: {path}" for path in sorted(actual.keys() - expected.keys())]
@@ -65,7 +69,7 @@ def evidence_differences(root: Path) -> list[str]:
65
69
  def require_refresh_authorization(root: Path, refresh: bool) -> None:
66
70
  if freeze_path(root).is_file() and not refresh:
67
71
  raise SystemExit(
68
- "Evidence is frozen by paper/evidence-freeze.json. Refusing to rerun code. "
72
+ "Evidence is frozen by .cumcm/evidence-freeze.json. Refusing to rerun code. "
69
73
  "Use --refresh-evidence together with --run-code only after an explicit request to recompute results."
70
74
  )
71
75
 
@@ -51,6 +51,10 @@ def main() -> None:
51
51
  if args.clean:
52
52
  run("clean_project.py", root, "--apply")
53
53
  print(f"[OK] Complete modeling-paper delivery finalized: {root / 'paper' / 'main.pdf'}")
54
+ print(
55
+ "[ORBIT_TERMINAL_SUCCESS] Final PDF and support archive are current. "
56
+ "Stop tool use and return the final delivery report."
57
+ )
54
58
 
55
59
 
56
60
  if __name__ == "__main__":
@@ -9,6 +9,8 @@ import shutil
9
9
  import subprocess
10
10
  import zipfile
11
11
  from pathlib import Path
12
+
13
+ from project_utils import control_directory
12
14
  from typing import Any
13
15
  from xml.etree import ElementTree
14
16
 
@@ -217,11 +219,11 @@ def main() -> None:
217
219
  details = inspect_file(path)
218
220
  entries.append({"path": path.relative_to(root).as_posix(), "size_bytes": path.stat().st_size, "sha256": sha256(path), "supported": path.suffix.lower() in SUPPORTED, "status": details["status"], "details": details})
219
221
 
220
- paper = root / "paper"
221
- paper.mkdir(parents=True, exist_ok=True)
222
- inventory = paper / "input-inventory.json"
222
+ state = control_directory(root)
223
+ state.mkdir(parents=True, exist_ok=True)
224
+ inventory = state / "input-inventory.json"
223
225
  inventory.write_text(json.dumps({"schema_version": 1, "files": entries}, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
224
- baseline = paper / "question-fingerprint.json"
226
+ baseline = state / "question-fingerprint.json"
225
227
  baseline_state = "preserved"
226
228
  if args.refresh_baseline or not baseline.exists():
227
229
  baseline.write_text(json.dumps({"schema_version": 1, "files": [{"path": item["path"], "sha256": item["sha256"]} for item in entries]}, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")