vibedgames 0.10.1 → 0.10.2
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/assets/rebuild-object/.cache/spec-search/core_3d.json +1 -0
- package/assets/rebuild-object/.cache/spec-search/cs2.json +1 -0
- package/assets/rebuild-object/LICENSE +201 -0
- package/assets/rebuild-object/NOTICE +7 -0
- package/assets/rebuild-object/docs/materials/material-reference.json +2324 -0
- package/assets/rebuild-object/docs/specs/render-profile.v2.example.json +63 -0
- package/assets/rebuild-object/docs/specs/render-profile.v2.schema.json +56 -0
- package/assets/rebuild-object/docs/specs/vocabulary/README.md +86 -0
- package/assets/rebuild-object/docs/specs/vocabulary/core_3d.jsonl +12 -0
- package/assets/rebuild-object/docs/specs/vocabulary/core_3d_reconstruction.jsonl +37 -0
- package/assets/rebuild-object/docs/specs/vocabulary/cs2.jsonl +8 -0
- package/assets/rebuild-object/docs/specs/vocabulary/cs2_reconstruction.jsonl +62 -0
- package/assets/rebuild-object/forge/_shared/artifact_cache.py +54 -0
- package/assets/rebuild-object/forge/_shared/chirality.py +272 -0
- package/assets/rebuild-object/forge/_shared/color_metrics.py +107 -0
- package/assets/rebuild-object/forge/_shared/feature_acceptance_policy.py +113 -0
- package/assets/rebuild-object/forge/_shared/image_hash.py +113 -0
- package/assets/rebuild-object/forge/_shared/jpeg.py +448 -0
- package/assets/rebuild-object/forge/_shared/material_physics.py +253 -0
- package/assets/rebuild-object/forge/_shared/pipeline_routing.py +177 -0
- package/assets/rebuild-object/forge/_shared/scalp_field.py +302 -0
- package/assets/rebuild-object/forge/_shared/sdf_primitives.py +172 -0
- package/assets/rebuild-object/forge/_shared/spec_search.py +1792 -0
- package/assets/rebuild-object/forge/_shared/spec_search_profiles.json +58 -0
- package/assets/rebuild-object/forge/_shared/status_banner.py +35 -0
- package/assets/rebuild-object/forge/_shared/subdivision.py +232 -0
- package/assets/rebuild-object/forge/_shared/vertex_paint.py +236 -0
- package/assets/rebuild-object/forge/_shared/workflow_state.py +406 -0
- package/assets/rebuild-object/forge/materials/__init__.py +17 -0
- package/assets/rebuild-object/forge/materials/compatibility.py +106 -0
- package/assets/rebuild-object/forge/materials/reference.py +240 -0
- package/assets/rebuild-object/forge/next.py +116 -0
- package/assets/rebuild-object/forge/report.py +38 -0
- package/assets/rebuild-object/forge/requirements.txt +6 -0
- package/assets/rebuild-object/forge/stage1_intake/analyze_texture.py +255 -0
- package/assets/rebuild-object/forge/stage1_intake/bind_detail_properties.py +99 -0
- package/assets/rebuild-object/forge/stage1_intake/build_detail_inventory.py +349 -0
- package/assets/rebuild-object/forge/stage1_intake/camera_fitting_math.py +133 -0
- package/assets/rebuild-object/forge/stage1_intake/camera_fitting_solver.py +197 -0
- package/assets/rebuild-object/forge/stage1_intake/camera_fitting_types.py +291 -0
- package/assets/rebuild-object/forge/stage1_intake/camera_image_helpers.py +133 -0
- package/assets/rebuild-object/forge/stage1_intake/check_intake_correctness.py +116 -0
- package/assets/rebuild-object/forge/stage1_intake/check_reference_admission.py +203 -0
- package/assets/rebuild-object/forge/stage1_intake/cs2_foundation.py +139 -0
- package/assets/rebuild-object/forge/stage1_intake/cs2_manifest.py +230 -0
- package/assets/rebuild-object/forge/stage1_intake/cs2_review_contract.py +42 -0
- package/assets/rebuild-object/forge/stage1_intake/delight_albedo.py +352 -0
- package/assets/rebuild-object/forge/stage1_intake/detect_cs2.py +276 -0
- package/assets/rebuild-object/forge/stage1_intake/detect_reference_effects.py +275 -0
- package/assets/rebuild-object/forge/stage1_intake/extract_cs2_textures.py +126 -0
- package/assets/rebuild-object/forge/stage1_intake/extract_gradient_stops.py +149 -0
- package/assets/rebuild-object/forge/stage1_intake/extract_hair_evidence.py +385 -0
- package/assets/rebuild-object/forge/stage1_intake/extract_landmarks.py +456 -0
- package/assets/rebuild-object/forge/stage1_intake/extract_part_color_recipe.py +496 -0
- package/assets/rebuild-object/forge/stage1_intake/extract_pbr_evidence.py +843 -0
- package/assets/rebuild-object/forge/stage1_intake/fetch_cs2_metadata.py +147 -0
- package/assets/rebuild-object/forge/stage1_intake/label_glb_nodes.py +318 -0
- package/assets/rebuild-object/forge/stage1_intake/locate_cs2_vpk.py +73 -0
- package/assets/rebuild-object/forge/stage1_intake/material_region_analysis.py +227 -0
- package/assets/rebuild-object/forge/stage1_intake/probe_glb.py +357 -0
- package/assets/rebuild-object/forge/stage1_intake/probe_image.py +168 -0
- package/assets/rebuild-object/forge/stage1_intake/run_vision_adapter.py +45 -0
- package/assets/rebuild-object/forge/stage1_intake/search_specs.py +258 -0
- package/assets/rebuild-object/forge/stage1_intake/semantic_decomposition.py +119 -0
- package/assets/rebuild-object/forge/stage1_intake/solve_camera_pose.py +254 -0
- package/assets/rebuild-object/forge/stage2_spec/apply_material_analysis.py +192 -0
- package/assets/rebuild-object/forge/stage2_spec/cs2_adapters.py +62 -0
- package/assets/rebuild-object/forge/stage2_spec/derive_geometry.py +118 -0
- package/assets/rebuild-object/forge/stage2_spec/hair_profile.py +306 -0
- package/assets/rebuild-object/forge/stage2_spec/humanoid_proportions.py +214 -0
- package/assets/rebuild-object/forge/stage2_spec/new_pre_spec_assessment.py +343 -0
- package/assets/rebuild-object/forge/stage2_spec/new_sculpt_spec.py +2396 -0
- package/assets/rebuild-object/forge/stage2_spec/validate_sculpt_spec.py +2871 -0
- package/assets/rebuild-object/forge/stage3_build/bake_projected_texture.py +181 -0
- package/assets/rebuild-object/forge/stage3_build/decimate.py +272 -0
- package/assets/rebuild-object/forge/stage3_build/generate_threejs_factory.py +4099 -0
- package/assets/rebuild-object/forge/stage3_build/module_cache.py +155 -0
- package/assets/rebuild-object/forge/stage3_build/morph_targets.py +178 -0
- package/assets/rebuild-object/forge/stage3_build/orchestrate_passes.py +653 -0
- package/assets/rebuild-object/forge/stage3_build/uv_unwrap.py +622 -0
- package/assets/rebuild-object/forge/stage3_build/visual_hull.py +357 -0
- package/assets/rebuild-object/forge/stage4_review/_fit_divine_eye.py +64 -0
- package/assets/rebuild-object/forge/stage4_review/append_review.py +453 -0
- package/assets/rebuild-object/forge/stage4_review/attachment_anchor.py +349 -0
- package/assets/rebuild-object/forge/stage4_review/calibrate_eye.py +131 -0
- package/assets/rebuild-object/forge/stage4_review/check_part_coverage.py +298 -0
- package/assets/rebuild-object/forge/stage4_review/compare_region_passes.py +169 -0
- package/assets/rebuild-object/forge/stage4_review/correction_loop.py +258 -0
- package/assets/rebuild-object/forge/stage4_review/cs2_review.py +224 -0
- package/assets/rebuild-object/forge/stage4_review/diagnose_render.py +356 -0
- package/assets/rebuild-object/forge/stage4_review/diagnose_render_multi_angle.py +143 -0
- package/assets/rebuild-object/forge/stage4_review/divine_eye.py +461 -0
- package/assets/rebuild-object/forge/stage4_review/fit_params.py +381 -0
- package/assets/rebuild-object/forge/stage4_review/geometry_integrity.py +294 -0
- package/assets/rebuild-object/forge/stage4_review/hair_gate.py +216 -0
- package/assets/rebuild-object/forge/stage4_review/interior_difference.py +188 -0
- package/assets/rebuild-object/forge/stage4_review/joint_loops.py +209 -0
- package/assets/rebuild-object/forge/stage4_review/make_comparison_sheet.py +292 -0
- package/assets/rebuild-object/forge/stage4_review/material_comparator.py +181 -0
- package/assets/rebuild-object/forge/stage4_review/material_feedback.py +143 -0
- package/assets/rebuild-object/forge/stage4_review/material_gate.py +126 -0
- package/assets/rebuild-object/forge/stage4_review/material_views.py +184 -0
- package/assets/rebuild-object/forge/stage4_review/mesh_reference_compare.py +362 -0
- package/assets/rebuild-object/forge/stage4_review/multi_pass.py +102 -0
- package/assets/rebuild-object/forge/stage4_review/objectness.py +143 -0
- package/assets/rebuild-object/forge/stage4_review/pairwise_penetration.py +376 -0
- package/assets/rebuild-object/forge/stage4_review/per_feature.py +215 -0
- package/assets/rebuild-object/forge/stage4_review/render_bridge.py +556 -0
- package/assets/rebuild-object/forge/stage4_review/scalp_exposure.py +257 -0
- package/assets/rebuild-object/forge/stage4_review/self_intersection.py +592 -0
- package/assets/rebuild-object/forge/stage4_review/swept_arc_gate.py +336 -0
- package/assets/rebuild-object/forge/stage4_review/turntable_gate.py +415 -0
- package/assets/rebuild-object/forge/stage4_review/validate_render_profile.py +182 -0
- package/assets/rebuild-object/forge/stage4_review/vertex_region_gate.py +456 -0
- package/assets/rebuild-object/forge/stage4_review/vlm_gate.py +196 -0
- package/assets/rebuild-object/forge/stage5_rig/NOTES.md +149 -0
- package/assets/rebuild-object/forge/stage5_rig/__init__.py +6 -0
- package/assets/rebuild-object/forge/stage5_rig/emit_rig.py +420 -0
- package/assets/rebuild-object/forge/stage5_rig/geodesic_skinning.py +508 -0
- package/assets/rebuild-object/forge/stage5_rig/rig_spec.py +174 -0
- package/assets/rebuild-object/forge/stage5_rig/validate_rig_payload.py +195 -0
- package/assets/rebuild-object/forge/state.py +98 -0
- package/assets/rebuild-object/steps.json +381 -0
- package/dist/{chunk-FB3UDZAV.js → chunk-24TITAFS.js} +1 -1
- package/dist/{chunk-QNWCBPVO.js → chunk-2C5PG2QO.js} +1 -1
- package/dist/{chunk-4RYTTD4D.js → chunk-2DEVOKI7.js} +1 -1
- package/dist/{chunk-RRI23NK2.js → chunk-2GHPYT2P.js} +1 -1
- package/dist/{chunk-QEKVZ7BX.js → chunk-2HXGMXGC.js} +1 -1
- package/dist/{chunk-N2UHAQXC.js → chunk-36FORP7T.js} +0 -1
- package/dist/{chunk-DH6WPL3X.js → chunk-3IXRQTRF.js} +1 -1
- package/dist/{chunk-SXYQL4GK.js → chunk-4YHA32OE.js} +1 -1
- package/dist/{chunk-V5ADM3WC.js → chunk-4ZGQKPK5.js} +1 -1
- package/dist/{chunk-BJAN3RMY.js → chunk-6CLUPFQA.js} +1 -1
- package/dist/{chunk-52E6EKZV.js → chunk-7WTF2BA4.js} +1 -1
- package/dist/{chunk-P74GTK23.js → chunk-AAXZNK4Z.js} +1 -1
- package/dist/{chunk-F4J6XCHT.js → chunk-ALLBT4FB.js} +1 -1
- package/dist/{chunk-HRKVAXNN.js → chunk-BAZDPPIG.js} +5 -5
- package/dist/{chunk-RPJR3S5S.js → chunk-CYDENLZ4.js} +5 -8
- package/dist/{chunk-I5LELJSK.js → chunk-DKSUD44G.js} +1 -1
- package/dist/{chunk-43P4U7CB.js → chunk-DWWSJKTE.js} +1 -1
- package/dist/{chunk-6IUFHPMV.js → chunk-E72TFJZP.js} +1 -1
- package/dist/{chunk-E3FJUPLT.js → chunk-EUAAQMUA.js} +2 -0
- package/dist/{chunk-37LLKM73.js → chunk-F7LYJSZE.js} +1 -1
- package/dist/{chunk-MEAO33XW.js → chunk-FMON3C74.js} +8 -8
- package/dist/{chunk-YLUB6252.js → chunk-FPILHRLZ.js} +1 -1
- package/dist/{chunk-4UU622RK.js → chunk-GGO6ZYYI.js} +1 -3
- package/dist/{chunk-2ZKS7V72.js → chunk-GZCRYYS6.js} +5 -5
- package/dist/{chunk-E7NDOZ27.js → chunk-LE4GVTYI.js} +8 -8
- package/dist/{chunk-UTSSDFQL.js → chunk-NO6KPV64.js} +1 -1
- package/dist/{chunk-W2QPNAZ3.js → chunk-NXW3Z4Y4.js} +1 -1
- package/dist/{chunk-NG2X3SMF.js → chunk-OHOAZGO4.js} +1 -1
- package/dist/chunk-PYJNI5WD.js +83 -0
- package/dist/{chunk-VUV5U4J5.js → chunk-Q4XAGTFX.js} +1 -1
- package/dist/{chunk-3UGGMFJJ.js → chunk-QMZBSVKF.js} +1 -1
- package/dist/{chunk-ABTUEIRC.js → chunk-QO66UBOS.js} +2 -2
- package/dist/{chunk-LONQWRTR.js → chunk-S4KVGQQO.js} +8 -8
- package/dist/{chunk-FJXPMA63.js → chunk-T777EXAO.js} +1 -1
- package/dist/{chunk-YXOGRERG.js → chunk-TZZNRA3S.js} +1 -1
- package/dist/{chunk-CTY2WZQK.js → chunk-UC3QLWMQ.js} +1 -1
- package/dist/{chunk-MR5KIFI7.js → chunk-UDJH2RED.js} +3 -3
- package/dist/{chunk-FNJL6Z5C.js → chunk-UIKYK7KI.js} +1 -1
- package/dist/{chunk-PKM3JOKQ.js → chunk-UJRSQO2B.js} +1 -1
- package/dist/{chunk-ALPTHSUT.js → chunk-V7LEYVXB.js} +28 -24
- package/dist/{chunk-DPLFCKXP.js → chunk-WRMQEXUC.js} +1 -1
- package/dist/{chunk-HSMG6U7J.js → chunk-WXSBNC67.js} +3 -9
- package/dist/{chunk-HSCTPDEU.js → chunk-X4QIOXNQ.js} +1 -1
- package/dist/{chunk-72KHWZMN.js → chunk-Y6WHUK2O.js} +1 -1
- package/dist/{chunk-VZEJ2ZHE.js → chunk-Z3E7ORGQ.js} +5 -5
- package/dist/index.js +20 -20
- package/package.json +32 -22
- package/dist/{chunk-OFJIG4K3.js → chunk-4ENHS32B.js} +0 -0
- package/dist/{chunk-Q3XQPNF6.js → chunk-BN7TR6OR.js} +3 -3
- package/dist/{chunk-LORGE2NB.js → chunk-U2NCN5RO.js} +3 -3
- package/dist/{chunk-UPHB5HWO.js → chunk-VQTTSPA3.js} +3 -3
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Probe basic technical properties of a reference image before visual analysis."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import argparse
|
|
7
|
+
import json
|
|
8
|
+
import struct
|
|
9
|
+
import sys
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def png_size(data: bytes) -> tuple[int, int] | None:
|
|
14
|
+
if data.startswith(b"\x89PNG\r\n\x1a\n") and len(data) >= 24:
|
|
15
|
+
return struct.unpack(">II", data[16:24])
|
|
16
|
+
return None
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def gif_size(data: bytes) -> tuple[int, int] | None:
|
|
20
|
+
if data[:6] in {b"GIF87a", b"GIF89a"} and len(data) >= 10:
|
|
21
|
+
return struct.unpack("<HH", data[6:10])
|
|
22
|
+
return None
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def jpeg_size(data: bytes) -> tuple[int, int] | None:
|
|
26
|
+
if not data.startswith(b"\xff\xd8"):
|
|
27
|
+
return None
|
|
28
|
+
index = 2
|
|
29
|
+
while index + 9 < len(data):
|
|
30
|
+
if data[index] != 0xFF:
|
|
31
|
+
index += 1
|
|
32
|
+
continue
|
|
33
|
+
marker = data[index + 1]
|
|
34
|
+
index += 2
|
|
35
|
+
if marker in {0xD8, 0xD9}:
|
|
36
|
+
continue
|
|
37
|
+
if index + 2 > len(data):
|
|
38
|
+
return None
|
|
39
|
+
length = struct.unpack(">H", data[index : index + 2])[0]
|
|
40
|
+
if length < 2 or index + length > len(data):
|
|
41
|
+
return None
|
|
42
|
+
if marker in {0xC0, 0xC1, 0xC2, 0xC3, 0xC5, 0xC6, 0xC7, 0xC9, 0xCA, 0xCB, 0xCD, 0xCE, 0xCF}:
|
|
43
|
+
if length >= 7:
|
|
44
|
+
height, width = struct.unpack(">HH", data[index + 3 : index + 7])
|
|
45
|
+
return width, height
|
|
46
|
+
index += length
|
|
47
|
+
return None
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def webp_size(data: bytes) -> tuple[int, int] | None:
|
|
51
|
+
if len(data) < 30 or data[:4] != b"RIFF" or data[8:12] != b"WEBP":
|
|
52
|
+
return None
|
|
53
|
+
chunk = data[12:16]
|
|
54
|
+
if chunk == b"VP8X" and len(data) >= 30:
|
|
55
|
+
width = 1 + int.from_bytes(data[24:27], "little")
|
|
56
|
+
height = 1 + int.from_bytes(data[27:30], "little")
|
|
57
|
+
return width, height
|
|
58
|
+
if chunk == b"VP8 " and len(data) >= 30:
|
|
59
|
+
start = data.find(b"\x9d\x01\x2a")
|
|
60
|
+
if start != -1 and start + 7 <= len(data):
|
|
61
|
+
width, height = struct.unpack("<HH", data[start + 3 : start + 7])
|
|
62
|
+
return width & 0x3FFF, height & 0x3FFF
|
|
63
|
+
return None
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def bmp_size(data: bytes) -> tuple[int, int] | None:
|
|
67
|
+
if len(data) >= 26 and data[:2] == b"BM":
|
|
68
|
+
width = struct.unpack("<I", data[18:22])[0]
|
|
69
|
+
height = abs(struct.unpack("<i", data[22:26])[0])
|
|
70
|
+
return width, height
|
|
71
|
+
return None
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def tiff_size(data: bytes) -> tuple[int, int] | None:
|
|
75
|
+
if len(data) < 8:
|
|
76
|
+
return None
|
|
77
|
+
if data[:4] == b"II*\x00":
|
|
78
|
+
endian = "<"
|
|
79
|
+
elif data[:4] == b"MM\x00*":
|
|
80
|
+
endian = ">"
|
|
81
|
+
else:
|
|
82
|
+
return None
|
|
83
|
+
offset = struct.unpack(f"{endian}I", data[4:8])[0]
|
|
84
|
+
if offset + 2 > len(data):
|
|
85
|
+
return None
|
|
86
|
+
entries = struct.unpack(f"{endian}H", data[offset : offset + 2])[0]
|
|
87
|
+
width = height = None
|
|
88
|
+
cursor = offset + 2
|
|
89
|
+
for _ in range(entries):
|
|
90
|
+
if cursor + 12 > len(data):
|
|
91
|
+
return None
|
|
92
|
+
tag, value_type, count, raw_value = struct.unpack(f"{endian}HHII", data[cursor : cursor + 12])
|
|
93
|
+
if value_type in {3, 4} and count == 1:
|
|
94
|
+
value = raw_value if value_type == 4 else raw_value & 0xFFFF
|
|
95
|
+
if tag == 256:
|
|
96
|
+
width = value
|
|
97
|
+
elif tag == 257:
|
|
98
|
+
height = value
|
|
99
|
+
cursor += 12
|
|
100
|
+
if width and height:
|
|
101
|
+
return width, height
|
|
102
|
+
return None
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def detect_image_type(data: bytes) -> str | None:
|
|
106
|
+
if data.startswith(b"\x89PNG\r\n\x1a\n"):
|
|
107
|
+
return "png"
|
|
108
|
+
if data.startswith(b"\xff\xd8"):
|
|
109
|
+
return "jpeg"
|
|
110
|
+
if data[:6] in {b"GIF87a", b"GIF89a"}:
|
|
111
|
+
return "gif"
|
|
112
|
+
if len(data) >= 12 and data[:4] == b"RIFF" and data[8:12] == b"WEBP":
|
|
113
|
+
return "webp"
|
|
114
|
+
if data.startswith(b"BM"):
|
|
115
|
+
return "bmp"
|
|
116
|
+
if data[:4] in {b"II*\x00", b"MM\x00*"}:
|
|
117
|
+
return "tiff"
|
|
118
|
+
return None
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def detect_size(data: bytes) -> tuple[int, int] | None:
|
|
122
|
+
return png_size(data) or jpeg_size(data) or gif_size(data) or webp_size(data) or bmp_size(data) or tiff_size(data)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def probe(path: Path) -> dict:
|
|
126
|
+
data = path.read_bytes()
|
|
127
|
+
image_type = detect_image_type(data)
|
|
128
|
+
size = detect_size(data)
|
|
129
|
+
warnings: list[str] = []
|
|
130
|
+
if not image_type:
|
|
131
|
+
warnings.append("unknown image type")
|
|
132
|
+
if not size:
|
|
133
|
+
warnings.append("could not read image dimensions")
|
|
134
|
+
width = height = None
|
|
135
|
+
aspect = None
|
|
136
|
+
else:
|
|
137
|
+
width, height = size
|
|
138
|
+
aspect = width / height if height else None
|
|
139
|
+
if width < 512 or height < 512:
|
|
140
|
+
warnings.append("low resolution; small geometry/material details may be unreliable")
|
|
141
|
+
if aspect and (aspect > 3.0 or aspect < 0.33):
|
|
142
|
+
warnings.append("extreme aspect ratio; object may be cropped or surrounded by empty space")
|
|
143
|
+
return {
|
|
144
|
+
"path": str(path),
|
|
145
|
+
"type": image_type,
|
|
146
|
+
"bytes": len(data),
|
|
147
|
+
"width": width,
|
|
148
|
+
"height": height,
|
|
149
|
+
"aspectRatio": aspect,
|
|
150
|
+
"technicalSuitability": "conditional" if warnings else "pass",
|
|
151
|
+
"warnings": warnings,
|
|
152
|
+
"note": "This is only technical image probing. Semantic object suitability still requires visual inspection.",
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def main(argv: list[str]) -> int:
|
|
157
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
158
|
+
parser.add_argument("image", type=Path)
|
|
159
|
+
args = parser.parse_args(argv)
|
|
160
|
+
path = args.image.expanduser().resolve()
|
|
161
|
+
if not path.exists():
|
|
162
|
+
parser.error(f"{path} does not exist")
|
|
163
|
+
print(json.dumps(probe(path), indent=2, ensure_ascii=False))
|
|
164
|
+
return 0
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
if __name__ == "__main__":
|
|
168
|
+
raise SystemExit(main(sys.argv[1:]))
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Run an optional vision adapter without adding dependencies to forge."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import argparse
|
|
7
|
+
import os
|
|
8
|
+
import subprocess
|
|
9
|
+
import sys
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
ROOT = Path(__file__).resolve().parents[2]
|
|
14
|
+
DEFAULT_PYTHON = ROOT / "integrations" / "vision" / ".venv" / "bin" / "python"
|
|
15
|
+
ADAPTER = ROOT / "integrations" / "vision" / "reference_vision.py"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def resolve_python(explicit: str | None) -> Path:
|
|
19
|
+
configured = explicit or os.environ.get("IMG2THREEJS_VISION_PYTHON")
|
|
20
|
+
return Path(configured).expanduser().resolve() if configured else DEFAULT_PYTHON
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def build_command(python: Path, forwarded: list[str]) -> list[str]:
|
|
24
|
+
return [str(python), str(ADAPTER), *forwarded]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def main(argv: list[str]) -> int:
|
|
28
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
29
|
+
parser.add_argument("--vision-python", help="Override the isolated adapter interpreter")
|
|
30
|
+
parser.add_argument("adapter_args", nargs=argparse.REMAINDER)
|
|
31
|
+
args = parser.parse_args(argv)
|
|
32
|
+
python = resolve_python(args.vision_python)
|
|
33
|
+
if not python.exists():
|
|
34
|
+
parser.error(
|
|
35
|
+
f"optional vision interpreter not found at {python}; "
|
|
36
|
+
"run `uv sync --project integrations/vision --python 3.11`"
|
|
37
|
+
)
|
|
38
|
+
if not args.adapter_args:
|
|
39
|
+
parser.error("provide an adapter command: health, prefetch, segment, depth, or landmarks")
|
|
40
|
+
completed = subprocess.run(build_command(python, args.adapter_args), check=False)
|
|
41
|
+
return int(completed.returncode)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
if __name__ == "__main__":
|
|
45
|
+
raise SystemExit(main(sys.argv[1:]))
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import contextlib
|
|
7
|
+
import io
|
|
8
|
+
import json
|
|
9
|
+
import sys
|
|
10
|
+
from collections.abc import Sequence
|
|
11
|
+
from dataclasses import dataclass
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
from typing import Final, TypeAlias, TypedDict
|
|
14
|
+
|
|
15
|
+
PROJECT_ROOT = Path(__file__).resolve().parents[2]
|
|
16
|
+
sys.path.insert(0, str(PROJECT_ROOT))
|
|
17
|
+
|
|
18
|
+
from forge._shared.spec_search import ( # noqa: E402
|
|
19
|
+
CacheReadError,
|
|
20
|
+
CacheValidationError,
|
|
21
|
+
CacheWriteError,
|
|
22
|
+
IndexBuildError,
|
|
23
|
+
IndexLoadResult,
|
|
24
|
+
IndexRequest,
|
|
25
|
+
ProfileValidationError,
|
|
26
|
+
ProfileCachePathError,
|
|
27
|
+
SearchOutputRequest,
|
|
28
|
+
SerializedSearchMatch,
|
|
29
|
+
SourceIngestionError,
|
|
30
|
+
SpecRecordValidationError,
|
|
31
|
+
UnknownCollectionError,
|
|
32
|
+
load_or_build_index,
|
|
33
|
+
load_profile,
|
|
34
|
+
serialize_search_results,
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
JsonScalar: TypeAlias = str | int | float | bool | None
|
|
38
|
+
JsonValue: TypeAlias = JsonScalar | list["JsonValue"] | dict[str, "JsonValue"]
|
|
39
|
+
MIN_SNIPPET_CHARS: Final = 5
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class OutputIndex(TypedDict):
|
|
43
|
+
status: str
|
|
44
|
+
reason: str
|
|
45
|
+
fingerprint: str
|
|
46
|
+
cache_path: str
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class SuccessPayload(TypedDict):
|
|
50
|
+
query: str
|
|
51
|
+
collection: str
|
|
52
|
+
index: OutputIndex
|
|
53
|
+
matches: list[SerializedSearchMatch]
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@dataclass(frozen=True, slots=True)
|
|
57
|
+
class CliOptions:
|
|
58
|
+
query: str
|
|
59
|
+
collection: str
|
|
60
|
+
limit: int
|
|
61
|
+
snippet_chars: int
|
|
62
|
+
reindex: bool
|
|
63
|
+
json_output: bool
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@dataclass(frozen=True, slots=True)
|
|
67
|
+
class ErrorContext:
|
|
68
|
+
query: str
|
|
69
|
+
collection: str
|
|
70
|
+
json_output: bool
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@dataclass(frozen=True, slots=True)
|
|
74
|
+
class CliFailure:
|
|
75
|
+
code: str
|
|
76
|
+
message: str
|
|
77
|
+
exit_code: int
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class CliArgumentError(ValueError):
|
|
81
|
+
pass
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
class CliNamespace(argparse.Namespace):
|
|
85
|
+
def __init__(self) -> None:
|
|
86
|
+
super().__init__()
|
|
87
|
+
self.query: list[str] = []
|
|
88
|
+
self.collection: str = "cs2"
|
|
89
|
+
self.limit: int = 3
|
|
90
|
+
self.snippet_chars: int = 250
|
|
91
|
+
self.reindex: bool = False
|
|
92
|
+
self.json_output: bool = False
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def _parse_options(argv: Sequence[str]) -> CliOptions:
|
|
96
|
+
parser = argparse.ArgumentParser(
|
|
97
|
+
description="Search registered specification collections with local BM25."
|
|
98
|
+
)
|
|
99
|
+
_ = parser.add_argument("query", nargs="*", help="Search terms")
|
|
100
|
+
_ = parser.add_argument("--collection", default="cs2")
|
|
101
|
+
_ = parser.add_argument("--limit", type=int, default=3)
|
|
102
|
+
_ = parser.add_argument(
|
|
103
|
+
"--snippet-chars",
|
|
104
|
+
type=int,
|
|
105
|
+
default=250,
|
|
106
|
+
help=f"Maximum snippet length; must be at least {MIN_SNIPPET_CHARS}.",
|
|
107
|
+
)
|
|
108
|
+
_ = parser.add_argument("--reindex", action="store_true")
|
|
109
|
+
_ = parser.add_argument("--json", action="store_true", dest="json_output")
|
|
110
|
+
namespace = CliNamespace()
|
|
111
|
+
diagnostics = io.StringIO()
|
|
112
|
+
try:
|
|
113
|
+
with contextlib.redirect_stderr(diagnostics):
|
|
114
|
+
_ = parser.parse_args(argv, namespace=namespace)
|
|
115
|
+
except SystemExit as error:
|
|
116
|
+
if error.code == 0:
|
|
117
|
+
raise
|
|
118
|
+
raise CliArgumentError(diagnostics.getvalue().strip()) from None
|
|
119
|
+
return CliOptions(
|
|
120
|
+
query=" ".join(namespace.query).strip(),
|
|
121
|
+
collection=namespace.collection,
|
|
122
|
+
limit=namespace.limit,
|
|
123
|
+
snippet_chars=namespace.snippet_chars,
|
|
124
|
+
reindex=namespace.reindex,
|
|
125
|
+
json_output=namespace.json_output,
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def _index_payload(result: IndexLoadResult) -> OutputIndex:
|
|
130
|
+
return {
|
|
131
|
+
"status": result.status,
|
|
132
|
+
"reason": result.reason,
|
|
133
|
+
"fingerprint": result.fingerprint,
|
|
134
|
+
"cache_path": str(result.cache_path),
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def _print_json(payload: SuccessPayload | dict[str, JsonValue]) -> None:
|
|
139
|
+
print(json.dumps(payload, ensure_ascii=False, separators=(",", ":")))
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def _print_human(payload: SuccessPayload) -> None:
|
|
143
|
+
print(f"Query: {payload['query']}")
|
|
144
|
+
print(f"Collection: {payload['collection']}")
|
|
145
|
+
index = payload["index"]
|
|
146
|
+
print(f"Index: {index['status']} ({index['reason']}) {index['fingerprint']}")
|
|
147
|
+
if not payload["matches"]:
|
|
148
|
+
print("No matches.")
|
|
149
|
+
return
|
|
150
|
+
for position, match in enumerate(payload["matches"], start=1):
|
|
151
|
+
location = match["file_path"]
|
|
152
|
+
if match["heading"] is not None:
|
|
153
|
+
location += f" :: {match['heading']}"
|
|
154
|
+
if match["key_path"] is not None:
|
|
155
|
+
location += f" :: {match['key_path']}"
|
|
156
|
+
print(f"{position}. {match['record_id']} score={match['score']:.6f}")
|
|
157
|
+
print(f" source: {location}")
|
|
158
|
+
print(f" {match['snippets'][0]}")
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def _emit_error(context: ErrorContext, failure: CliFailure) -> int:
|
|
162
|
+
print(f"error: {failure.message}", file=sys.stderr)
|
|
163
|
+
if context.json_output:
|
|
164
|
+
_print_json(
|
|
165
|
+
{
|
|
166
|
+
"query": context.query,
|
|
167
|
+
"collection": context.collection,
|
|
168
|
+
"index": None,
|
|
169
|
+
"matches": [],
|
|
170
|
+
"error": {"code": failure.code, "message": failure.message},
|
|
171
|
+
}
|
|
172
|
+
)
|
|
173
|
+
return failure.exit_code
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def main(argv: Sequence[str]) -> int:
|
|
177
|
+
json_requested = "--json" in argv
|
|
178
|
+
try:
|
|
179
|
+
options = _parse_options(argv)
|
|
180
|
+
except CliArgumentError as error:
|
|
181
|
+
return _emit_error(
|
|
182
|
+
ErrorContext("", "cs2", json_requested),
|
|
183
|
+
CliFailure("invalid_arguments", str(error), 2),
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
context = ErrorContext(options.query, options.collection, options.json_output)
|
|
187
|
+
if not options.query:
|
|
188
|
+
return _emit_error(context, CliFailure("empty_query", "query must not be empty", 2))
|
|
189
|
+
if options.limit <= 0:
|
|
190
|
+
return _emit_error(
|
|
191
|
+
context,
|
|
192
|
+
CliFailure("invalid_limit", "--limit must be greater than zero", 2),
|
|
193
|
+
)
|
|
194
|
+
if options.snippet_chars < MIN_SNIPPET_CHARS:
|
|
195
|
+
return _emit_error(
|
|
196
|
+
context,
|
|
197
|
+
CliFailure(
|
|
198
|
+
"invalid_snippet_chars",
|
|
199
|
+
f"--snippet-chars must be at least {MIN_SNIPPET_CHARS} to include source text",
|
|
200
|
+
2,
|
|
201
|
+
),
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
try:
|
|
205
|
+
profile = load_profile(options.collection)
|
|
206
|
+
loaded = load_or_build_index(
|
|
207
|
+
IndexRequest(PROJECT_ROOT, options.collection, profile, options.reindex)
|
|
208
|
+
)
|
|
209
|
+
matches = serialize_search_results(
|
|
210
|
+
loaded.index,
|
|
211
|
+
SearchOutputRequest(options.query, options.limit, options.snippet_chars),
|
|
212
|
+
)
|
|
213
|
+
except UnknownCollectionError as error:
|
|
214
|
+
return _emit_error(
|
|
215
|
+
context,
|
|
216
|
+
CliFailure("unknown_collection", str(error), 2),
|
|
217
|
+
)
|
|
218
|
+
except ProfileCachePathError as error:
|
|
219
|
+
return _emit_error(
|
|
220
|
+
context,
|
|
221
|
+
CliFailure("cache_failure", str(error), 3),
|
|
222
|
+
)
|
|
223
|
+
except ProfileValidationError as error:
|
|
224
|
+
return _emit_error(
|
|
225
|
+
context,
|
|
226
|
+
CliFailure("profile_failure", str(error), 3),
|
|
227
|
+
)
|
|
228
|
+
except (SourceIngestionError, SpecRecordValidationError) as error:
|
|
229
|
+
return _emit_error(
|
|
230
|
+
context,
|
|
231
|
+
CliFailure("source_failure", str(error), 3),
|
|
232
|
+
)
|
|
233
|
+
except IndexBuildError as error:
|
|
234
|
+
return _emit_error(
|
|
235
|
+
context,
|
|
236
|
+
CliFailure("index_failure", str(error), 3),
|
|
237
|
+
)
|
|
238
|
+
except (CacheReadError, CacheValidationError, CacheWriteError) as error:
|
|
239
|
+
return _emit_error(
|
|
240
|
+
context,
|
|
241
|
+
CliFailure("cache_failure", str(error), 3),
|
|
242
|
+
)
|
|
243
|
+
|
|
244
|
+
payload: SuccessPayload = {
|
|
245
|
+
"query": options.query,
|
|
246
|
+
"collection": options.collection,
|
|
247
|
+
"index": _index_payload(loaded),
|
|
248
|
+
"matches": matches,
|
|
249
|
+
}
|
|
250
|
+
if options.json_output:
|
|
251
|
+
_print_json(payload)
|
|
252
|
+
else:
|
|
253
|
+
_print_human(payload)
|
|
254
|
+
return 0
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
if __name__ == "__main__":
|
|
258
|
+
raise SystemExit(main(sys.argv[1:]))
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Classify how much semantic part evidence a GLB exposes.
|
|
3
|
+
|
|
4
|
+
This module is deliberately conservative. It does not pretend that a mesh name,
|
|
5
|
+
normal discontinuity, or a guessed connected component is proof of ``head`` or
|
|
6
|
+
``scarf``. It reports what the GLB metadata can support and routes ambiguous
|
|
7
|
+
assets to a browser ID-mask or multipart-GLB decision.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
from typing import Any
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
SEMANTIC_STRATEGIES = (
|
|
16
|
+
"named-node",
|
|
17
|
+
"primitive-material-boundary",
|
|
18
|
+
"uv-texture-boundary",
|
|
19
|
+
"connected-component-hypothesis",
|
|
20
|
+
"curvature-normal-region-growing-hypothesis",
|
|
21
|
+
"multiview-id-mask",
|
|
22
|
+
"multipart-glb",
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def assess_semantic_decomposition(
|
|
27
|
+
*,
|
|
28
|
+
node_count: int,
|
|
29
|
+
mesh_count: int,
|
|
30
|
+
primitive_count: int,
|
|
31
|
+
material_count: int,
|
|
32
|
+
nodes: list[dict[str, Any]],
|
|
33
|
+
meshes: list[dict[str, Any]],
|
|
34
|
+
materials: list[dict[str, Any]],
|
|
35
|
+
texture_count: int = 0,
|
|
36
|
+
) -> dict[str, Any]:
|
|
37
|
+
"""Return a fail-closed semantic readiness assessment from GLB metadata.
|
|
38
|
+
|
|
39
|
+
``insufficient`` means insufficient for *reliable semantic reconstruction*,
|
|
40
|
+
not that geometry algorithms are unable to propose partitions. Hypotheses
|
|
41
|
+
must be validated by a browser ID-mask or by a multipart export before they
|
|
42
|
+
may drive a subject-specific procedural factory.
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
named_nodes = [
|
|
46
|
+
str(item.get("name"))
|
|
47
|
+
for item in nodes
|
|
48
|
+
if isinstance(item, dict) and item.get("name") and not str(item["name"]).startswith("node-")
|
|
49
|
+
]
|
|
50
|
+
named_meshes = [
|
|
51
|
+
str(item.get("name"))
|
|
52
|
+
for item in meshes
|
|
53
|
+
if isinstance(item, dict) and item.get("name") and not str(item["name"]).startswith("mesh-")
|
|
54
|
+
]
|
|
55
|
+
named_materials = [
|
|
56
|
+
str(item.get("name"))
|
|
57
|
+
for item in materials
|
|
58
|
+
if isinstance(item, dict) and item.get("name") and not str(item["name"]).startswith("material-")
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
if node_count == 1 and mesh_count == 1 and primitive_count == 1 and material_count <= 1:
|
|
62
|
+
status = "insufficient"
|
|
63
|
+
boundary = "multipart-glb-required"
|
|
64
|
+
reason = (
|
|
65
|
+
"The metadata exposes one merged drawable and no semantic material boundary. "
|
|
66
|
+
"Connected-component or curvature analysis may produce hypotheses, but cannot "
|
|
67
|
+
"prove which region is head, clothing, weapon, or tail."
|
|
68
|
+
)
|
|
69
|
+
elif len(named_nodes) >= 2 or len(named_meshes) >= 2:
|
|
70
|
+
status = "rich"
|
|
71
|
+
boundary = "named-node-or-mesh"
|
|
72
|
+
reason = "Multiple named scene/mesh entities provide an explicit semantic starting point."
|
|
73
|
+
else:
|
|
74
|
+
status = "partial"
|
|
75
|
+
boundary = "browser-id-mask-or-multipart-glb"
|
|
76
|
+
reason = (
|
|
77
|
+
"Multiple drawable/material records exist, but metadata names do not establish a "
|
|
78
|
+
"complete semantic part map."
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
strategy_status: dict[str, str] = {
|
|
82
|
+
"named-node": "available" if len(named_nodes) >= 2 else "not-proven",
|
|
83
|
+
"primitive-material-boundary": "available" if primitive_count > 1 or material_count > 1 else "not-proven",
|
|
84
|
+
"uv-texture-boundary": "available" if texture_count > 0 else "not-proven",
|
|
85
|
+
"connected-component-hypothesis": "candidate-only",
|
|
86
|
+
"curvature-normal-region-growing-hypothesis": "candidate-only",
|
|
87
|
+
"multiview-id-mask": "required-for-runtime-region-evidence",
|
|
88
|
+
"multipart-glb": "required" if status == "insufficient" else "recommended",
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
"schemaVersion": 1,
|
|
92
|
+
"status": status,
|
|
93
|
+
"reliableSemanticBoundary": boundary,
|
|
94
|
+
"reason": reason,
|
|
95
|
+
"metadataEvidence": {
|
|
96
|
+
"nodeCount": node_count,
|
|
97
|
+
"meshCount": mesh_count,
|
|
98
|
+
"primitiveCount": primitive_count,
|
|
99
|
+
"materialCount": material_count,
|
|
100
|
+
"textureCount": texture_count,
|
|
101
|
+
"namedNodes": named_nodes,
|
|
102
|
+
"namedMeshes": named_meshes,
|
|
103
|
+
"namedMaterials": named_materials,
|
|
104
|
+
},
|
|
105
|
+
"strategies": [
|
|
106
|
+
{"id": strategy, "status": strategy_status[strategy]}
|
|
107
|
+
for strategy in SEMANTIC_STRATEGIES
|
|
108
|
+
],
|
|
109
|
+
"claimsAllowed": [
|
|
110
|
+
"scene and drawable inventory",
|
|
111
|
+
"material/primitive boundaries explicitly present in the GLB",
|
|
112
|
+
"browser-rendered ID-mask evidence when captured",
|
|
113
|
+
],
|
|
114
|
+
"claimsForbiddenUntilEvidence": [
|
|
115
|
+
"exact semantic labels inferred from a merged mesh",
|
|
116
|
+
"per-region material equality without region crops or ID masks",
|
|
117
|
+
"multipart topology reconstructed from metadata alone",
|
|
118
|
+
],
|
|
119
|
+
}
|