@orbit-build/cli 0.8.3 → 0.8.6

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 (45) hide show
  1. package/README.md +4 -1
  2. package/commands/cumcm-draft.md +3 -1
  3. package/dist/index.js +1158 -310
  4. package/package.json +1 -1
  5. package/skills/cumcm-draft/SKILL.md +102 -48
  6. package/skills/cumcm-draft/agents/openai.yaml +1 -1
  7. package/skills/cumcm-draft/assets/project-template/{code → .cumcm}/finalize.py +33 -4
  8. package/skills/cumcm-draft/assets/project-template/{paper/contest-profile.json → .cumcm/profile.json} +9 -6
  9. package/skills/cumcm-draft/assets/project-template/code/requirements.txt +1 -11
  10. 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
  11. package/skills/cumcm-draft/assets/project-template/paper/main.tex +70 -11
  12. package/skills/cumcm-draft/references/code-and-output-style.md +9 -14
  13. package/skills/cumcm-draft/references/cumcm-compliance.md +28 -25
  14. package/skills/cumcm-draft/references/latex-figures-tables.md +1 -1
  15. package/skills/cumcm-draft/references/modeling-quality.md +1 -1
  16. package/skills/cumcm-draft/references/paper-architecture.md +3 -3
  17. package/skills/cumcm-draft/references/project-architecture.md +70 -89
  18. package/skills/cumcm-draft/scripts/audit_paper.py +37 -9
  19. package/skills/cumcm-draft/scripts/bootstrap_project.py +198 -56
  20. package/skills/cumcm-draft/scripts/build_paper.py +38 -23
  21. package/skills/cumcm-draft/scripts/capture_environment.py +3 -1
  22. package/skills/cumcm-draft/scripts/clean_project.py +7 -2
  23. package/skills/cumcm-draft/scripts/evidence_freeze.py +8 -4
  24. package/skills/cumcm-draft/scripts/finalize_project.py +16 -0
  25. package/skills/cumcm-draft/scripts/inspect_inputs.py +6 -4
  26. package/skills/cumcm-draft/scripts/package_support.py +41 -15
  27. package/skills/cumcm-draft/scripts/project_utils.py +40 -8
  28. package/skills/cumcm-draft/scripts/validate_project.py +394 -57
  29. package/skills/cumcm-draft/assets/project-template/code/always/__init__.py +0 -1
  30. package/skills/cumcm-draft/assets/project-template/code/always/config.py +0 -18
  31. package/skills/cumcm-draft/assets/project-template/code/always/data.py +0 -24
  32. package/skills/cumcm-draft/assets/project-template/code/always/plotting.py +0 -25
  33. package/skills/cumcm-draft/assets/project-template/code/always/validation.py +0 -21
  34. package/skills/cumcm-draft/assets/project-template/paper/sections/abstract.tex +0 -6
  35. package/skills/cumcm-draft/assets/project-template/paper/sections/ai-disclosure.tex +0 -3
  36. package/skills/cumcm-draft/assets/project-template/paper/sections/appendix.tex +0 -3
  37. package/skills/cumcm-draft/assets/project-template/paper/sections/assumptions.tex +0 -5
  38. package/skills/cumcm-draft/assets/project-template/paper/sections/data.tex +0 -19
  39. package/skills/cumcm-draft/assets/project-template/paper/sections/evaluation.tex +0 -9
  40. package/skills/cumcm-draft/assets/project-template/paper/sections/problem-analysis.tex +0 -3
  41. package/skills/cumcm-draft/assets/project-template/paper/sections/problem-restatement.tex +0 -3
  42. package/skills/cumcm-draft/assets/project-template/paper/sections/references.tex +0 -12
  43. package/skills/cumcm-draft/assets/project-template/paper/sections/source-code.tex +0 -1
  44. package/skills/cumcm-draft/assets/project-template/paper/sections/support-files.tex +0 -3
  45. /package/skills/cumcm-draft/assets/project-template/{paper → .cumcm}/ai-use-log.md +0 -0
@@ -3,7 +3,7 @@
3
3
  ## Page system
4
4
 
5
5
  - Use `ctexart` with XeLaTeX for Chinese.
6
- - Use the supplied contest template and `paper/contest-profile.json`; for the
6
+ - Use the supplied contest template and `.cumcm/profile.json`; for the
7
7
  bundled CUMCM 2026 profile use A4 and margins of at least 2.5 cm.
8
8
  - Keep the electronic first page as title, abstract, and keywords only.
9
9
  - Center Arabic page numbers in the footer starting at 1.
@@ -144,7 +144,7 @@ Every paper claim must map to:
144
144
  - validation evidence;
145
145
  - paper section and figure/table label.
146
146
 
147
- Keep this mapping in `paper/evidence-map.yaml`. Do not type important numbers
147
+ Keep this mapping in `.cumcm/evidence-map.yaml`. Do not type important numbers
148
148
  into LaTeX from memory.
149
149
 
150
150
  Use `status: verified` only after the producing code has run and the claim's
@@ -47,9 +47,9 @@ For CUMCM-style papers use:
47
47
  only content genuinely reused across questions.
48
48
  8. One major section per qN.
49
49
  9. Model evaluation, limitations, and possible extensions.
50
- 10. Corresponding inline AI marks and an AI tool reference entry when AI was
51
- used; a concise disclosure paragraph may also be included.
52
- 11. References.
50
+ 10. The exact official AI-use declaration immediately before the references;
51
+ used-AI work also includes `AI工具使用详情.pdf` in support materials.
52
+ 11. References. The 2026 rule does not require an AI-tool bibliography entry.
53
53
  12. Appendix:
54
54
  the exact support-archive file list followed by complete runnable source.
55
55
  Group the list by directory instead of omitting names or printing one noisy
@@ -1,37 +1,49 @@
1
1
  # Project architecture
2
2
 
3
- Use one stable project root. Keep inputs, code, paper, results, and figures
4
- separate so a human can replace any layer without reorganizing the project.
3
+ Use one stable project root and separate private workflow state from authored
4
+ and submitted artifacts.
5
5
 
6
6
  ```text
7
7
  project-root/
8
- ├── question/ # Immutable problem PDF/DOCX and source data
8
+ ├── .cumcm/ # Orbit-owned workflow state; never modeling code
9
+ │ ├── profile.json
10
+ │ ├── project.json
11
+ │ ├── evidence-map.yaml
12
+ │ ├── ai-use-log.md
13
+ │ ├── finalize.py
14
+ │ ├── generated/ # generated TeX appendices
15
+ │ └── build/ # LaTeX caches, page renders, audit report
16
+ ├── question/ # immutable problem and supplied data
9
17
  ├── code/
10
- │ ├── requirements.txt
18
+ │ ├── requirements.txt # actual direct runtime dependencies only
11
19
  │ ├── run_all.py
12
- │ ├── always/ # Shared configuration, data, plotting, checks
13
20
  │ ├── q1/
21
+ │ │ ├── main.py # orchestration only
22
+ │ │ ├── forecasting.py # examples; names follow real responsibilities
23
+ │ │ └── evaluation.py
14
24
  │ ├── q2/
15
- │ └── ...
25
+ │ └── common/ # only when two or more questions genuinely reuse it
16
26
  ├── results/
17
- │ ├── q1/ # Tables, metrics, filled workbooks, models
27
+ │ ├── q1/ # Chinese-named tables, metrics, models, workbooks
18
28
  │ ├── q2/
19
29
  │ └── ...
20
30
  ├── figures/
21
- │ ├── q1/ # Final paper-ready figures only
31
+ │ ├── q1/ # final Chinese-named paper figures only
22
32
  │ ├── q2/
23
33
  │ └── ...
24
34
  └── paper/
25
35
  ├── main.tex
26
- ├── references.bib
27
- ├── evidence-map.yaml
28
- ├── sections/
29
- │ ├── q1.tex
30
- │ ├── q2.tex
31
- │ └── ...
32
- └── build/ # LaTeX intermediates and final PDF
36
+ ├── AI工具使用详情.tex
37
+ ├── main.pdf
38
+ ├── AI工具使用详情.pdf
39
+ └── 支撑材料.zip
33
40
  ```
34
41
 
42
+ The two TeX sources are the only default authored files under `paper/`.
43
+ External editors may create compiler intermediates there, but Orbit builds into
44
+ `.cumcm/build/` and cleans known intermediates. Do not create `paper/sections/`
45
+ or `paper/build/`.
46
+
35
47
  ## Ownership rules
36
48
 
37
49
  - `question/` is read-only. Never normalize, rename, fill, or save over input.
@@ -39,93 +51,62 @@ project-root/
39
51
  role. Record that they were blank.
40
52
  - A required filled table belongs in `results/qN`, even when its blank template
41
53
  came from `question/`.
42
- - `code/always` contains only logic used by two or more subproblems.
43
- - Do not create a common result directory. Give cleaned data, audits, and every
44
- other generated artifact to the earliest subproblem that produces it; later
45
- subproblems declare and consume that upstream `results/qN` dependency.
46
- - Each `code/qN/main.py` must run independently after its prerequisites exist.
47
- - `code/qN/main.py` only orchestrates loading, domain computation, validation,
48
- and reporting. Name sibling modules after real responsibilities discovered
49
- from the problem; never require a universal `model.py` or `output.py`.
50
- - Keep domain-module dependencies acyclic and add concise Chinese `#` comments
51
- where a reviewer needs the assumption, unit, guard, or execution rationale.
52
- - `code/run_all.py` runs subproblems in dependency order.
53
- - `results/qN` owns numeric and tabular evidence for subproblem N.
54
- - `figures/qN` owns final visuals for subproblem N. Put diagnostic-only images
55
- in a temporary build directory and remove them before handoff.
56
- - `paper/sections/qN.tex` may consume only declared evidence from matching or
57
- explicitly upstream result directories.
54
+ - Create `code/common` only after two or more questions use the same behavior.
55
+ A pre-generated utility package is clutter and often becomes dead code.
56
+ - Each `code/qN/main.py` must run independently after prerequisites exist.
57
+ - `main.py` orchestrates loading, domain computation, validation, and reporting.
58
+ Put substantive models in sibling modules named after their actual role.
59
+ - A strict finalization must not pass when qN still contains only the scaffold
60
+ `main.py`, `NotImplementedError`, or TODO logic.
61
+ - Keep domain-module dependencies acyclic and add concise Chinese comments where
62
+ a reviewer needs the assumption, unit, leakage guard, or numerical safeguard.
63
+ - `code/run_all.py` runs questions in dependency order.
64
+ - `results/qN` owns numeric and tabular evidence for question N. Do not create a
65
+ synthetic `summary.json`; point `.cumcm/evidence-map.yaml` to real results.
66
+ - `figures/qN` owns final visuals for question N. Diagnostic-only images belong
67
+ in `.cumcm/build/` and must not enter the support archive.
68
+ - `paper/main.tex` consumes only declared evidence from matching or explicitly
69
+ upstream result directories.
58
70
  - Treat every cross-question result as a typed interface. The consumer checks
59
- required columns, unique entity/date keys, units, expected coverage, and
60
- freshness before computing. Missing coverage is an error, not permission to
61
- rebuild an undeclared proxy.
71
+ columns, unique entity/date keys, units, coverage, and freshness.
62
72
  - Keep model-selection, validation, and test artifacts under the producing
63
73
  `results/qN`; these are evidence, not disposable debug output.
74
+ - `.cumcm/` belongs to Orbit's workflow. Never cite it as modeling output or
75
+ include `finalize.py`, audit reports, evidence freezes, or build caches in the
76
+ modeling-code appendix or support archive. `environment.json` is copied into
77
+ the ZIP as `复现环境.json`.
64
78
 
65
79
  ## Naming
66
80
 
67
- - Use `q1`, `q2`, ... exactly; do not mix `Q1`, `question1`, or Chinese folder
68
- names.
81
+ - Use `q1`, `q2`, ... for structural directories; do not mix `Q1`,
82
+ `question1`, or translated variants.
69
83
  - Use descriptive Chinese filenames for generated tabular artifacts under
70
84
  `results/qN`; use Chinese CSV/TSV headers and Chinese Excel worksheet/table
71
- headers, with units where applicable. Fixed control files such as
72
- `summary.json` retain their documented ASCII names.
73
- - Preserve non-Chinese output names or headers only for a problem-prescribed
74
- fill-in/upload schema, and declare the narrow exception with its immutable
75
- source and reason under
76
- `contest-profile.json.result_artifacts.fixed_schema_exceptions`.
85
+ headers, with units where applicable.
86
+ - Use descriptive Chinese figure filenames such as `需求预测误差对比.png` or
87
+ `价格弹性敏感性分析.pdf`. Generic names such as `summary.png`, `plot.png`,
88
+ `figure.png`, `output.png`, and `final.png` are invalid.
89
+ - Preserve a prescribed non-Chinese result schema only when the problem fixes
90
+ it, and document the narrow exception in
91
+ `.cumcm/profile.json.result_artifacts.fixed_schema_exceptions`.
77
92
  - Use stable ASCII Python module names.
78
93
  - Use UTF-8 for text and UTF-8 with BOM for CSV intended for Excel.
79
94
  - Include units in column labels or metadata.
80
95
 
81
- ## Compatibility with legacy reproduction folders
82
-
83
- Some existing projects place `question/` next to a `reproduce/` directory.
84
- Read those inputs in place, but do not move them automatically. For a new
85
- project, make `question/` a peer of `code/`, `results/`, `figures/`, and
86
- `paper/` as the canonical structure above.
87
-
88
- When the user explicitly requests a compact handoff patterned after an
89
- existing project, this layout is also valid:
96
+ ## Submission boundary
90
97
 
91
- ```text
92
- project-root/
93
- ├── main.tex
94
- ├── main.pdf
95
- ├── AI工具使用详情.tex
96
- ├── AI工具使用详情.pdf
97
- ├── 支撑材料.zip
98
- ├── question/ # still immutable
99
- └── produce/
100
- ├── code/
101
- │ ├── always/
102
- │ ├── q1/
103
- │ └── ...
104
- └── results/
105
- ├── q1/
106
- └── ...
107
- ```
98
+ The formal submission pair is `paper/main.pdf` plus `paper/支撑材料.zip`.
99
+ The archive contains runnable code, necessary results, cited figures,
100
+ `AI工具使用详情.pdf` when required, and `复现环境.json`. It excludes immutable
101
+ question inputs and all `.cumcm/` control state.
108
102
 
109
- Use `main` as the neutral basename unless submission rules require a
110
- team-specific name. Do not add `core_code/`; the PDF appendix must include the
111
- actual runnable files from `produce/code/`. Keep paper sources out of
112
- `produce/`; inline the complete paper into one root `main.tex` for the compact
113
- handoff. Split section files are an authoring aid, not a delivery requirement,
114
- and should be removed after a verified merge unless the user requests them.
115
- Build the support ZIP while `produce/figures/` still exists so the archive and
116
- appendix list remain complete. After the PDF and ZIP are both inspected, remove
117
- reproducible workspace figures from a minimal handoff if requested. Running
118
- `produce/code/run_all.py` must recreate them before recompiling `main.tex`.
103
+ Place separately required filled Excel/Word artifacts outside the ZIP only when
104
+ the statement or submission system explicitly requires them. Do not promote
105
+ every CSV, JSON, diagnostic, or figure to the root.
119
106
 
120
- The formal CUMCM submission pair is the paper PDF plus one support ZIP/RAR.
121
- Keep `AI工具使用详情.pdf` inside that archive; a root copy may remain for editing
122
- and inspection. Place separately required filled Excel/Word artifacts at root
123
- only when the problem statement or submission system requires them there.
124
- Internal evidence remains in `produce/results/qN`; do not promote every CSV or
125
- diagnostic file to the root.
107
+ ## Legacy projects
126
108
 
127
- Before compact handoff, remove nested ZIP/RAR/7z copies from `produce/code`,
128
- `produce/results`, and `produce/figures`; remove scratch verification, cleanup,
129
- rebuild, and PDF-contact scripts after their reusable checks live in the Skill
130
- finalizer. Keep only direct runtime dependencies in `requirements.txt`, plus
131
- the file-format engines actually required to read the supplied inputs.
109
+ Orbit 0.8.4 continues to read the 0.8.3 locations under `paper/sections/`,
110
+ `paper/build/`, and `paper/*.json`. Bootstrap copies legacy control state into
111
+ `.cumcm/` without deleting user files. It does not destructively flatten an
112
+ authored legacy paper. New projects always use the compact layout.
@@ -8,6 +8,8 @@ import subprocess
8
8
  from pathlib import Path
9
9
  from typing import Any
10
10
 
11
+ from project_utils import build_directory, generated_directory
12
+
11
13
 
12
14
  FIGURE_SUFFIXES = {".pdf", ".png", ".jpg", ".jpeg", ".eps", ".svg"}
13
15
  PROBLEM_SUFFIXES = {".pdf", ".doc", ".docx", ".csv", ".tsv", ".xls", ".xlsx"}
@@ -96,6 +98,23 @@ def question_outline_findings(label: str, content: str) -> list[dict[str, str]]:
96
98
  return findings
97
99
 
98
100
 
101
+ def flattened_question_sections(main_tex: Path) -> list[tuple[str, str]]:
102
+ """Extract qN blocks from a single-file paper without creating section files."""
103
+ if not main_tex.is_file():
104
+ return []
105
+ content = main_tex.read_text(encoding="utf-8", errors="replace")
106
+ sections = list(re.finditer(r"\\section\*?\{([^{}]+)\}", content))
107
+ extracted: list[tuple[str, str]] = []
108
+ for index, match in enumerate(sections):
109
+ title = match.group(1).strip()
110
+ number = re.match(r"问题([1-9]\d*)(?:[::]|$)", title)
111
+ if not number:
112
+ continue
113
+ end = sections[index + 1].start() if index + 1 < len(sections) else len(content)
114
+ extracted.append((f"paper/main.tex#q{number.group(1)}", content[match.start() : end]))
115
+ return extracted
116
+
117
+
99
118
  def inspect_pdf(pdf: Path) -> dict[str, Any]:
100
119
  if not pdf.is_file():
101
120
  return {"status": "missing"}
@@ -179,7 +198,13 @@ def main() -> None:
179
198
  reference_dirs = [path for path in root.rglob("*") if path.is_dir() and re.search(r"优秀|参考论文|excellent|reference.?paper", path.name, re.IGNORECASE)]
180
199
  inventory["reference_papers"] = [relative(root, path) for base in reference_dirs for path in sorted(base.rglob("*")) if path.is_file() and not path.is_symlink()]
181
200
 
182
- tex_files = [path for path in paper.rglob("*.tex") if path.is_file() and not path.is_symlink()]
201
+ tex_files = [
202
+ path
203
+ for base in (paper, generated_directory(root))
204
+ if base.is_dir()
205
+ for path in base.rglob("*.tex")
206
+ if path.is_file() and not path.is_symlink()
207
+ ]
183
208
  tex_texts = {path: path.read_text(encoding="utf-8", errors="replace") for path in tex_files}
184
209
  combined = "\n".join(tex_texts.values())
185
210
  for source, content in tex_texts.items():
@@ -210,14 +235,17 @@ def main() -> None:
210
235
  if latest_mtime(sources) > figure.stat().st_mtime + FIGURE_STALE_TOLERANCE_SECONDS:
211
236
  findings.append({"severity": "warning", "kind": "possibly_stale_figure", "message": relative(root, figure)})
212
237
 
213
- question_sections = [path for path in (paper / "sections").glob("q*.tex") if re.fullmatch(r"q[1-9]\d*\.tex", path.name)] if (paper / "sections").is_dir() else []
214
- for section in sorted(question_sections):
215
- content = tex_texts.get(section, "")
216
- findings.extend(question_outline_findings(relative(root, section), content))
238
+ question_sections = [
239
+ (relative(root, path), tex_texts.get(path, ""))
240
+ for path in sorted((paper / "sections").glob("q*.tex"))
241
+ if re.fullmatch(r"q[1-9]\d*\.tex", path.name)
242
+ ] if (paper / "sections").is_dir() else flattened_question_sections(paper / "main.tex")
243
+ for section_label, content in question_sections:
244
+ findings.extend(question_outline_findings(section_label, content))
217
245
  plain = re.sub(r"\\[A-Za-z@]+\*?(?:\[[^]]*\])?", "", content)
218
246
  plain = re.sub(r"[{}%]", "", plain)
219
247
  if len(re.sub(r"\s+", "", plain)) < 500:
220
- findings.append({"severity": "warning", "kind": "thin_question_section", "message": relative(root, section)})
248
+ findings.append({"severity": "warning", "kind": "thin_question_section", "message": section_label})
221
249
  required_groups = (
222
250
  ("变量", "符号", "参数", "约束", "条件", "假设"),
223
251
  ("选择", "理由", "原因", "采用", "建立", "基于", "考虑", "模型"),
@@ -226,7 +254,7 @@ def main() -> None:
226
254
  )
227
255
  for group in required_groups:
228
256
  if not any(token in content for token in group):
229
- findings.append({"severity": "warning", "kind": "missing_reasoning_stage", "message": f"{relative(root, section)} lacks {'/'.join(group)}"})
257
+ findings.append({"severity": "warning", "kind": "missing_reasoning_stage", "message": f"{section_label} lacks {'/'.join(group)}"})
230
258
 
231
259
  main_pdf = paper / "main.pdf"
232
260
  source_files = tex_files + [path for base_name in ("code", "results", "figures") for path in (root / base_name).rglob("*") if path.is_file()] if all((root / name).exists() for name in ("code", "results", "figures")) else tex_files
@@ -245,7 +273,7 @@ def main() -> None:
245
273
  if not pdftoppm:
246
274
  findings.append({"severity": "warning", "kind": "render_dependency_missing", "message": "pdftoppm not found"})
247
275
  else:
248
- output_dir = paper / "build" / "page-review"
276
+ output_dir = build_directory(root) / "page-review"
249
277
  output_dir.mkdir(parents=True, exist_ok=True)
250
278
  for previous in output_dir.glob("page-*.png"):
251
279
  if previous.is_file() and not previous.is_symlink():
@@ -265,7 +293,7 @@ def main() -> None:
265
293
  "findings": findings,
266
294
  "summary": {"errors": sum(item["severity"] == "error" for item in findings), "warnings": sum(item["severity"] == "warning" for item in findings)},
267
295
  }
268
- output = paper / "build" / "revision-audit.json"
296
+ output = build_directory(root) / "revision-audit.json"
269
297
  output.parent.mkdir(parents=True, exist_ok=True)
270
298
  output.write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
271
299
  print(f"[RUN] Paper audit: {report['summary']['errors']} error(s), {report['summary']['warnings']} warning(s)")