@orbit-build/cli 1.6.7 → 1.6.8
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/dist/index.js +109 -5
- package/package.json +1 -1
- package/skills/cumcm-draft/SKILL.md +9 -10
- package/skills/cumcm-draft/agents/openai.yaml +1 -1
- package/skills/cumcm-draft/assets/project-template/.cumcm/profile.json +2 -1
- package/skills/cumcm-draft/references/code-and-output-style.md +4 -4
- package/skills/cumcm-draft/references/latex-figures-tables.md +3 -2
- package/skills/cumcm-draft/references/project-architecture.md +9 -8
- package/skills/cumcm-draft/scripts/audit_paper.py +1 -1
- package/skills/cumcm-draft/scripts/bootstrap_project.py +2 -1
- package/skills/cumcm-draft/scripts/project_utils.py +2 -1
- package/skills/cumcm-draft/scripts/validate_project.py +53 -16
package/dist/index.js
CHANGED
|
@@ -293365,10 +293365,38 @@ var WEB_UI_APPROVAL_STYLES = String.raw`
|
|
|
293365
293365
|
}
|
|
293366
293366
|
|
|
293367
293367
|
@media (max-width: 560px) {
|
|
293368
|
-
.approval-panel {
|
|
293369
|
-
|
|
293370
|
-
|
|
293371
|
-
|
|
293368
|
+
.approval-panel {
|
|
293369
|
+
margin-bottom: 8px;
|
|
293370
|
+
padding: 12px;
|
|
293371
|
+
border-radius: 14px;
|
|
293372
|
+
}
|
|
293373
|
+
|
|
293374
|
+
.approval-panel-head {
|
|
293375
|
+
gap: 9px;
|
|
293376
|
+
}
|
|
293377
|
+
|
|
293378
|
+
.approval-reason {
|
|
293379
|
+
margin: 8px 0 0;
|
|
293380
|
+
font-size: 11.5px;
|
|
293381
|
+
}
|
|
293382
|
+
|
|
293383
|
+
.approval-preview {
|
|
293384
|
+
max-height: min(128px, 20dvh);
|
|
293385
|
+
margin-top: 9px;
|
|
293386
|
+
padding-block: 7px;
|
|
293387
|
+
font-size: 10.75px;
|
|
293388
|
+
}
|
|
293389
|
+
|
|
293390
|
+
.approval-actions {
|
|
293391
|
+
display: grid;
|
|
293392
|
+
grid-template-columns: 1fr 1fr;
|
|
293393
|
+
margin-top: 10px;
|
|
293394
|
+
}
|
|
293395
|
+
|
|
293396
|
+
.approval-button {
|
|
293397
|
+
width: 100%;
|
|
293398
|
+
height: 40px;
|
|
293399
|
+
}
|
|
293372
293400
|
}
|
|
293373
293401
|
`;
|
|
293374
293402
|
|
|
@@ -295595,7 +295623,9 @@ button:focus-visible,
|
|
|
295595
295623
|
input:focus-visible,
|
|
295596
295624
|
select:focus-visible,
|
|
295597
295625
|
textarea:focus-visible,
|
|
295598
|
-
summary:focus-visible
|
|
295626
|
+
summary:focus-visible,
|
|
295627
|
+
a:focus-visible,
|
|
295628
|
+
[tabindex]:focus-visible {
|
|
295599
295629
|
outline: 2px solid color-mix(in srgb, var(--accent) 72%, transparent);
|
|
295600
295630
|
outline-offset: 2px;
|
|
295601
295631
|
}
|
|
@@ -297295,6 +297325,15 @@ var WEB_UI_RESPONSIVE_STYLES = String.raw`
|
|
|
297295
297325
|
.registered-project-remove {
|
|
297296
297326
|
opacity: 1;
|
|
297297
297327
|
}
|
|
297328
|
+
|
|
297329
|
+
.icon-button,
|
|
297330
|
+
.details-button,
|
|
297331
|
+
.connection-state,
|
|
297332
|
+
.new-project-button,
|
|
297333
|
+
.approval-button {
|
|
297334
|
+
min-width: 40px;
|
|
297335
|
+
min-height: 40px;
|
|
297336
|
+
}
|
|
297298
297337
|
}
|
|
297299
297338
|
|
|
297300
297339
|
@media (min-width: 901px) {
|
|
@@ -297516,6 +297555,22 @@ var WEB_UI_RESPONSIVE_STYLES = String.raw`
|
|
|
297516
297555
|
}
|
|
297517
297556
|
|
|
297518
297557
|
@media (max-width: 560px) {
|
|
297558
|
+
.message-scroll,
|
|
297559
|
+
.project-chat-body,
|
|
297560
|
+
.project-list,
|
|
297561
|
+
.inspector-content,
|
|
297562
|
+
.workspace-view {
|
|
297563
|
+
scrollbar-gutter: auto;
|
|
297564
|
+
}
|
|
297565
|
+
|
|
297566
|
+
.message-scroll {
|
|
297567
|
+
scrollbar-width: none;
|
|
297568
|
+
}
|
|
297569
|
+
|
|
297570
|
+
.message-scroll::-webkit-scrollbar {
|
|
297571
|
+
display: none;
|
|
297572
|
+
}
|
|
297573
|
+
|
|
297519
297574
|
.project-dialog-card {
|
|
297520
297575
|
padding: 17px;
|
|
297521
297576
|
}
|
|
@@ -297663,6 +297718,26 @@ var WEB_UI_RESPONSIVE_STYLES = String.raw`
|
|
|
297663
297718
|
border-radius: 16px;
|
|
297664
297719
|
}
|
|
297665
297720
|
|
|
297721
|
+
.prompt-queue {
|
|
297722
|
+
gap: 4px;
|
|
297723
|
+
margin-inline: 4px;
|
|
297724
|
+
padding: 6px;
|
|
297725
|
+
}
|
|
297726
|
+
|
|
297727
|
+
.prompt-queue-list {
|
|
297728
|
+
max-height: 76px;
|
|
297729
|
+
}
|
|
297730
|
+
|
|
297731
|
+
.prompt-queue-row {
|
|
297732
|
+
min-height: 27px;
|
|
297733
|
+
font-size: 10.5px;
|
|
297734
|
+
}
|
|
297735
|
+
|
|
297736
|
+
.prompt-queue-actions button {
|
|
297737
|
+
width: 24px;
|
|
297738
|
+
height: 24px;
|
|
297739
|
+
}
|
|
297740
|
+
|
|
297666
297741
|
.composer-hint {
|
|
297667
297742
|
display: none;
|
|
297668
297743
|
}
|
|
@@ -297800,6 +297875,28 @@ var WEB_UI_RESPONSIVE_STYLES = String.raw`
|
|
|
297800
297875
|
}
|
|
297801
297876
|
}
|
|
297802
297877
|
|
|
297878
|
+
@media (prefers-contrast: more) {
|
|
297879
|
+
:root {
|
|
297880
|
+
--border: color-mix(in srgb, var(--ink-strong) 24%, transparent);
|
|
297881
|
+
--border-strong: color-mix(in srgb, var(--ink-strong) 38%, transparent);
|
|
297882
|
+
}
|
|
297883
|
+
|
|
297884
|
+
button:focus-visible,
|
|
297885
|
+
input:focus-visible,
|
|
297886
|
+
select:focus-visible,
|
|
297887
|
+
textarea:focus-visible,
|
|
297888
|
+
summary:focus-visible,
|
|
297889
|
+
a:focus-visible,
|
|
297890
|
+
[tabindex]:focus-visible {
|
|
297891
|
+
outline-width: 3px;
|
|
297892
|
+
}
|
|
297893
|
+
|
|
297894
|
+
.topbar,
|
|
297895
|
+
.composer {
|
|
297896
|
+
backdrop-filter: none;
|
|
297897
|
+
}
|
|
297898
|
+
}
|
|
297899
|
+
|
|
297803
297900
|
@media (forced-colors: active) {
|
|
297804
297901
|
button,
|
|
297805
297902
|
input,
|
|
@@ -298353,6 +298450,12 @@ var WEB_UI_SHELL_STYLES = String.raw`
|
|
|
298353
298450
|
border-radius: 12px;
|
|
298354
298451
|
}
|
|
298355
298452
|
|
|
298453
|
+
.project-section:has(.project-toggle[aria-expanded="false"]) {
|
|
298454
|
+
min-height: 0;
|
|
298455
|
+
flex: 0 0 auto;
|
|
298456
|
+
grid-template-rows: auto;
|
|
298457
|
+
}
|
|
298458
|
+
|
|
298356
298459
|
.recent-projects-shell {
|
|
298357
298460
|
min-width: 0;
|
|
298358
298461
|
min-height: 0;
|
|
@@ -298973,6 +299076,7 @@ var WEB_UI_SHELL_STYLES = String.raw`
|
|
|
298973
299076
|
padding: 0 clamp(18px, 2vw, 30px);
|
|
298974
299077
|
border-bottom: 1px solid var(--border);
|
|
298975
299078
|
background: color-mix(in srgb, var(--surface-glass) 97%, white);
|
|
299079
|
+
box-shadow: 0 1px 0 color-mix(in srgb, var(--surface-raised) 68%, transparent);
|
|
298976
299080
|
backdrop-filter: blur(24px) saturate(125%);
|
|
298977
299081
|
z-index: 15;
|
|
298978
299082
|
}
|
package/package.json
CHANGED
|
@@ -188,9 +188,9 @@ the outcome. Record explicit upstream artifact contracts between subproblems.
|
|
|
188
188
|
|
|
189
189
|
### 3. Implement and run
|
|
190
190
|
|
|
191
|
-
-
|
|
192
|
-
|
|
193
|
-
|
|
191
|
+
- Put genuinely cross-question configuration/loading/plotting/validation logic
|
|
192
|
+
under `code/always/`. Keep question-owned logic under its `code/qN/` directory;
|
|
193
|
+
do not copy a module into `always` merely to make the tree look modular. Give every generated artifact one producing subproblem and
|
|
194
194
|
store it in `results/qN`. Downstream questions may read an upstream qN result;
|
|
195
195
|
do not create `results/always`, `results/shared`, or another ownerless result
|
|
196
196
|
directory. Keep each `main.py` orchestral. After reading the problem, name
|
|
@@ -239,13 +239,12 @@ the outcome. Record explicit upstream artifact contracts between subproblems.
|
|
|
239
239
|
and reproducibility metadata belong under `.cumcm/`, not `results/`.
|
|
240
240
|
- Give every final figure a descriptive Chinese filename and Chinese title,
|
|
241
241
|
axes, legend, annotations, and category labels. Configure a CJK font fallback
|
|
242
|
-
such as Microsoft YaHei, SimHei, or Noto Sans CJK SC.
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
itself is correct.
|
|
242
|
+
such as Microsoft YaHei, SimHei, or Noto Sans CJK SC. Generate PNG only,
|
|
243
|
+
at 300 dpi or higher, and update every paper/support reference. Do not leave
|
|
244
|
+
PDF, SVG, JPG, or EPS siblings in `figures/`; those formats belong to source
|
|
245
|
+
inputs or transient build output, not final figure delivery. Names such as
|
|
246
|
+
`summary.png`, `plot.png`, `figure.png`, `output.png`, or `final.png` are
|
|
247
|
+
invalid even when the graphic itself is correct.
|
|
249
248
|
- Preserve a non-Chinese filename, header, or worksheet name only when the
|
|
250
249
|
problem statement or supplied fill-in template fixes it. Do not translate or
|
|
251
250
|
silently reshape that prescribed schema. Register the exact output path,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
interface:
|
|
2
2
|
display_name: "cumcm-draft"
|
|
3
3
|
short_description: "Complete CUMCM paper, code, PDF, AI record, and support ZIP"
|
|
4
|
-
default_prompt: "Use $cumcm-draft to ask which Python or Conda interpreter to use, audit the current official CUMCM rules, build responsibility-based q1/q2 code without project-local finalizers or Python caches, generate Chinese-named tables and Chinese
|
|
4
|
+
default_prompt: "Use $cumcm-draft to ask which Python or Conda interpreter to use, audit the current official CUMCM rules, build responsibility-based q1/q2 code with genuinely shared modules under code/always without project-local finalizers or Python caches, generate Chinese-named tables and 300-dpi Chinese PNG figures, keep final PDFs/TeX and required qN submission copies under happy/, inspect the full Chinese paper, and package the matching PDF/ZIP pair."
|
|
5
5
|
policy:
|
|
6
6
|
allow_implicit_invocation: false
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"require_chinese_headers": true,
|
|
19
19
|
"require_chinese_sheet_names": true,
|
|
20
20
|
"require_chinese_figure_filenames": true,
|
|
21
|
-
"
|
|
21
|
+
"require_png_figures": true,
|
|
22
|
+
"min_png_dpi": 300,
|
|
22
23
|
"require_utf8_sig_csv": true,
|
|
23
24
|
"fixed_schema_exceptions": []
|
|
24
25
|
},
|
|
@@ -14,7 +14,7 @@ code/
|
|
|
14
14
|
├── forecasting.py
|
|
15
15
|
├── evaluation.py
|
|
16
16
|
└── reporting.py
|
|
17
|
-
└──
|
|
17
|
+
└── always/ # genuinely shared cross-question logic only
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
The names above are examples, not a fixed template. Another question may need
|
|
@@ -119,9 +119,9 @@ For each `figures/qN`:
|
|
|
119
119
|
- save only figures used or directly useful in the paper;
|
|
120
120
|
- use descriptive Chinese filenames; reject generic names such as
|
|
121
121
|
`summary.png`, `plot.png`, `figure.png`, `output.png`, and `final.png`;
|
|
122
|
-
- generate
|
|
123
|
-
-
|
|
124
|
-
|
|
122
|
+
- generate final figures as PNG at 300 dpi or higher;
|
|
123
|
+
- remove stale PDF, SVG, JPG, and EPS siblings from `figures/` so the final
|
|
124
|
+
figure contract is unambiguous;
|
|
125
125
|
- write figure titles, axes, legends, annotations, and categories in Chinese;
|
|
126
126
|
- use Chinese-capable fonts and minus-sign handling;
|
|
127
127
|
- label axes and colorbars with units;
|
|
@@ -35,8 +35,9 @@
|
|
|
35
35
|
|
|
36
36
|
## Figures
|
|
37
37
|
|
|
38
|
-
- Generate
|
|
39
|
-
-
|
|
38
|
+
- Generate every final figure as PNG at 300 dpi or higher.
|
|
39
|
+
- Do not leave PDF, SVG, JPG, or EPS siblings in `figures/`; keep transient
|
|
40
|
+
vector exports under `.cumcm/build/` when an analysis tool needs them.
|
|
40
41
|
- Use Chinese filenames and Chinese titles, axes, legends, annotations, and
|
|
41
42
|
category labels, with a CJK-capable font fallback.
|
|
42
43
|
- Make labels readable at final printed size.
|
|
@@ -22,7 +22,7 @@ project-root/
|
|
|
22
22
|
│ │ ├── forecasting.py # examples; names follow real responsibilities
|
|
23
23
|
│ │ └── evaluation.py
|
|
24
24
|
│ ├── q2/
|
|
25
|
-
│ └──
|
|
25
|
+
│ └── always/ # genuinely shared cross-question logic only
|
|
26
26
|
├── results/
|
|
27
27
|
│ ├── q1/ # Chinese-named tables, metrics, models, workbooks
|
|
28
28
|
│ ├── q2/
|
|
@@ -53,8 +53,9 @@ or `happy/build/`.
|
|
|
53
53
|
role. Record that they were blank.
|
|
54
54
|
- A required filled table belongs in `results/qN`, even when its blank template
|
|
55
55
|
came from `question/`.
|
|
56
|
-
-
|
|
57
|
-
|
|
56
|
+
- Put genuinely shared behavior in `code/always`; keep question-specific logic
|
|
57
|
+
in `code/qN`. Do not duplicate a module into `always` merely to make the
|
|
58
|
+
tree look modular, and do not put result artifacts there.
|
|
58
59
|
- Each `code/qN/main.py` must run independently after prerequisites exist,
|
|
59
60
|
both through `code/run_all.py` and as a direct script from its qN directory.
|
|
60
61
|
- `main.py` orchestrates loading, domain computation, validation, and reporting.
|
|
@@ -86,11 +87,11 @@ or `happy/build/`.
|
|
|
86
87
|
- Use descriptive Chinese filenames for generated tabular artifacts under
|
|
87
88
|
`results/qN`; use Chinese CSV/TSV headers and Chinese Excel worksheet/table
|
|
88
89
|
headers, with units where applicable.
|
|
89
|
-
- Use descriptive Chinese figure filenames such as `需求预测误差对比.
|
|
90
|
-
`价格弹性敏感性分析.
|
|
91
|
-
categories in Chinese. Generate
|
|
92
|
-
|
|
93
|
-
`figure.png`, `output.png`, and `final.png` are invalid.
|
|
90
|
+
- Use descriptive Chinese PNG figure filenames such as `需求预测误差对比.png`
|
|
91
|
+
or `价格弹性敏感性分析.png`. Write titles, axes, legends, annotations, and
|
|
92
|
+
categories in Chinese. Generate at least 300 dpi PNG output and remove stale
|
|
93
|
+
PDF, SVG, JPG, and EPS siblings. Generic names such as `summary.png`,
|
|
94
|
+
`plot.png`, `figure.png`, `output.png`, and `final.png` are invalid.
|
|
94
95
|
- Preserve a prescribed non-Chinese result schema only when the problem fixes
|
|
95
96
|
it, and document the narrow exception in
|
|
96
97
|
`.cumcm/profile.json.result_artifacts.fixed_schema_exceptions`.
|
|
@@ -11,7 +11,7 @@ from typing import Any
|
|
|
11
11
|
from project_utils import build_directory, delivery_directory, generated_directory
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
FIGURE_SUFFIXES = {".
|
|
14
|
+
FIGURE_SUFFIXES = {".png"}
|
|
15
15
|
PROBLEM_SUFFIXES = {".pdf", ".doc", ".docx", ".csv", ".tsv", ".xls", ".xlsx"}
|
|
16
16
|
INVENTORY_EXCLUDED_PARTS = {"__pycache__", ".pytest_cache", ".mypy_cache", ".ruff_cache", ".orbit", "_work"}
|
|
17
17
|
FIGURE_STALE_TOLERANCE_SECONDS = 30.0
|
|
@@ -47,6 +47,7 @@ def main() -> None:
|
|
|
47
47
|
for directory in (
|
|
48
48
|
root / "question",
|
|
49
49
|
root / "code",
|
|
50
|
+
root / "code" / "always",
|
|
50
51
|
delivery_directory(root),
|
|
51
52
|
control_directory(root),
|
|
52
53
|
control_directory(root) / "build",
|
|
@@ -415,7 +416,7 @@ def solve(inputs):
|
|
|
415
416
|
|
|
416
417
|
|
|
417
418
|
def evaluate_and_report(inputs, solution) -> None:
|
|
418
|
-
# TODO[{name}] 完成验证,并输出中文命名的CSV/XLSX及
|
|
419
|
+
# TODO[{name}] 完成验证,并输出中文命名的CSV/XLSX及300 dpi PNG图。
|
|
419
420
|
raise NotImplementedError("请实现问题{name}的评价与报告")
|
|
420
421
|
''',
|
|
421
422
|
}
|
|
@@ -27,7 +27,8 @@ DEFAULT_PROFILE: dict[str, Any] = {
|
|
|
27
27
|
"require_chinese_headers": True,
|
|
28
28
|
"require_chinese_sheet_names": True,
|
|
29
29
|
"require_chinese_figure_filenames": True,
|
|
30
|
-
"
|
|
30
|
+
"require_png_figures": True,
|
|
31
|
+
"min_png_dpi": 300,
|
|
31
32
|
"require_utf8_sig_csv": True,
|
|
32
33
|
"fixed_schema_exceptions": [],
|
|
33
34
|
},
|
|
@@ -8,6 +8,7 @@ import io
|
|
|
8
8
|
import json
|
|
9
9
|
import posixpath
|
|
10
10
|
import re
|
|
11
|
+
import struct
|
|
11
12
|
import subprocess
|
|
12
13
|
import sys
|
|
13
14
|
import zipfile
|
|
@@ -40,7 +41,7 @@ SUPPORT_EXCLUDED_PARTS = {
|
|
|
40
41
|
}
|
|
41
42
|
NESTED_ARCHIVE_SUFFIXES = {".zip", ".rar", ".7z"}
|
|
42
43
|
TABULAR_RESULT_SUFFIXES = {".csv", ".tsv", ".xls", ".xlsx"}
|
|
43
|
-
FIGURE_SUFFIXES = {".
|
|
44
|
+
FIGURE_SUFFIXES = {".png"}
|
|
44
45
|
GENERIC_FIGURE_STEMS = {
|
|
45
46
|
"chart",
|
|
46
47
|
"figure",
|
|
@@ -539,45 +540,81 @@ def result_artifact_contract_errors(
|
|
|
539
540
|
def figure_artifact_contract_errors(
|
|
540
541
|
root: Path, profile: dict[str, object]
|
|
541
542
|
) -> list[str]:
|
|
542
|
-
"""Require final figures to
|
|
543
|
+
"""Require final figures to be descriptive, valid, high-resolution PNGs."""
|
|
543
544
|
errors: list[str] = []
|
|
544
545
|
if profile.get("require_chinese_figure_filenames", True) is not True:
|
|
545
546
|
errors.append(
|
|
546
547
|
"result_artifacts.require_chinese_figure_filenames must be true"
|
|
547
548
|
)
|
|
549
|
+
if profile.get("require_png_figures", True) is not True:
|
|
550
|
+
errors.append("result_artifacts.require_png_figures must be true")
|
|
551
|
+
minimum_dpi = profile.get("min_png_dpi", 300)
|
|
552
|
+
if (
|
|
553
|
+
isinstance(minimum_dpi, bool)
|
|
554
|
+
or not isinstance(minimum_dpi, (int, float))
|
|
555
|
+
or minimum_dpi < 300
|
|
556
|
+
):
|
|
557
|
+
errors.append("result_artifacts.min_png_dpi must be a number >= 300")
|
|
558
|
+
minimum_dpi = 300
|
|
548
559
|
figures = root / "figures"
|
|
549
560
|
if not figures.is_dir() or figures.is_symlink():
|
|
550
561
|
return errors
|
|
551
|
-
formats_by_stem: dict[str, set[str]] = {}
|
|
552
562
|
for path in figures.rglob("*"):
|
|
553
563
|
if not path.is_file() or path.is_symlink():
|
|
554
564
|
continue
|
|
555
565
|
relative = path.relative_to(root).as_posix()
|
|
556
566
|
if path.suffix.lower() not in FIGURE_SUFFIXES:
|
|
557
567
|
errors.append(
|
|
558
|
-
f"figures
|
|
568
|
+
f"final figures must be PNG only; remove or move this artifact: {relative}"
|
|
559
569
|
)
|
|
560
570
|
continue
|
|
561
571
|
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())
|
|
564
572
|
if stem.lower() in GENERIC_FIGURE_STEMS or not has_chinese(stem):
|
|
565
573
|
errors.append(
|
|
566
574
|
f"figure filename must be descriptive Chinese, not a generic name: {relative}"
|
|
567
575
|
)
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
576
|
+
dpi = png_dpi(path)
|
|
577
|
+
if dpi is None:
|
|
578
|
+
errors.append(
|
|
579
|
+
f"PNG figure must contain valid resolution metadata at or above {minimum_dpi:g} dpi: {relative}"
|
|
580
|
+
)
|
|
581
|
+
# PNG stores pixels-per-metre as an integer; allow the sub-dpi
|
|
582
|
+
# quantization error produced by an exact 300 dpi export.
|
|
583
|
+
elif dpi + 0.5 < float(minimum_dpi):
|
|
584
|
+
errors.append(
|
|
585
|
+
f"PNG figure resolution is {dpi:.1f} dpi, below the required {minimum_dpi:g} dpi: {relative}"
|
|
586
|
+
)
|
|
578
587
|
return errors
|
|
579
588
|
|
|
580
589
|
|
|
590
|
+
def png_dpi(path: Path) -> float | None:
|
|
591
|
+
"""Read PNG pHYs metadata without requiring Pillow at validation time."""
|
|
592
|
+
try:
|
|
593
|
+
with path.open("rb") as stream:
|
|
594
|
+
if stream.read(8) != b"\x89PNG\r\n\x1a\n":
|
|
595
|
+
return None
|
|
596
|
+
while True:
|
|
597
|
+
length_bytes = stream.read(4)
|
|
598
|
+
if len(length_bytes) != 4:
|
|
599
|
+
return None
|
|
600
|
+
length = struct.unpack(">I", length_bytes)[0]
|
|
601
|
+
chunk_type = stream.read(4)
|
|
602
|
+
if len(chunk_type) != 4:
|
|
603
|
+
return None
|
|
604
|
+
data = stream.read(length)
|
|
605
|
+
if len(data) != length or len(stream.read(4)) != 4:
|
|
606
|
+
return None
|
|
607
|
+
if chunk_type == b"pHYs" and len(data) >= 9:
|
|
608
|
+
pixels_x, pixels_y, unit = struct.unpack(">IIB", data[:9])
|
|
609
|
+
if unit != 1 or not pixels_x or not pixels_y:
|
|
610
|
+
return None
|
|
611
|
+
return min(pixels_x, pixels_y) * 0.0254
|
|
612
|
+
if chunk_type == b"IEND":
|
|
613
|
+
return None
|
|
614
|
+
except (OSError, struct.error):
|
|
615
|
+
return None
|
|
616
|
+
|
|
617
|
+
|
|
581
618
|
def fixed_schema_congruence_errors(
|
|
582
619
|
target: Path, source: Path, allowances: set[str], relative: str
|
|
583
620
|
) -> list[str]:
|