vibedgames 0.10.0 → 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.
Files changed (175) hide show
  1. package/assets/rebuild-object/.cache/spec-search/core_3d.json +1 -0
  2. package/assets/rebuild-object/.cache/spec-search/cs2.json +1 -0
  3. package/assets/rebuild-object/LICENSE +201 -0
  4. package/assets/rebuild-object/NOTICE +7 -0
  5. package/assets/rebuild-object/docs/materials/material-reference.json +2324 -0
  6. package/assets/rebuild-object/docs/specs/render-profile.v2.example.json +63 -0
  7. package/assets/rebuild-object/docs/specs/render-profile.v2.schema.json +56 -0
  8. package/assets/rebuild-object/docs/specs/vocabulary/README.md +86 -0
  9. package/assets/rebuild-object/docs/specs/vocabulary/core_3d.jsonl +12 -0
  10. package/assets/rebuild-object/docs/specs/vocabulary/core_3d_reconstruction.jsonl +37 -0
  11. package/assets/rebuild-object/docs/specs/vocabulary/cs2.jsonl +8 -0
  12. package/assets/rebuild-object/docs/specs/vocabulary/cs2_reconstruction.jsonl +62 -0
  13. package/assets/rebuild-object/forge/_shared/artifact_cache.py +54 -0
  14. package/assets/rebuild-object/forge/_shared/chirality.py +272 -0
  15. package/assets/rebuild-object/forge/_shared/color_metrics.py +107 -0
  16. package/assets/rebuild-object/forge/_shared/feature_acceptance_policy.py +113 -0
  17. package/assets/rebuild-object/forge/_shared/image_hash.py +113 -0
  18. package/assets/rebuild-object/forge/_shared/jpeg.py +448 -0
  19. package/assets/rebuild-object/forge/_shared/material_physics.py +253 -0
  20. package/assets/rebuild-object/forge/_shared/pipeline_routing.py +177 -0
  21. package/assets/rebuild-object/forge/_shared/scalp_field.py +302 -0
  22. package/assets/rebuild-object/forge/_shared/sdf_primitives.py +172 -0
  23. package/assets/rebuild-object/forge/_shared/spec_search.py +1792 -0
  24. package/assets/rebuild-object/forge/_shared/spec_search_profiles.json +58 -0
  25. package/assets/rebuild-object/forge/_shared/status_banner.py +35 -0
  26. package/assets/rebuild-object/forge/_shared/subdivision.py +232 -0
  27. package/assets/rebuild-object/forge/_shared/vertex_paint.py +236 -0
  28. package/assets/rebuild-object/forge/_shared/workflow_state.py +406 -0
  29. package/assets/rebuild-object/forge/materials/__init__.py +17 -0
  30. package/assets/rebuild-object/forge/materials/compatibility.py +106 -0
  31. package/assets/rebuild-object/forge/materials/reference.py +240 -0
  32. package/assets/rebuild-object/forge/next.py +116 -0
  33. package/assets/rebuild-object/forge/report.py +38 -0
  34. package/assets/rebuild-object/forge/requirements.txt +6 -0
  35. package/assets/rebuild-object/forge/stage1_intake/analyze_texture.py +255 -0
  36. package/assets/rebuild-object/forge/stage1_intake/bind_detail_properties.py +99 -0
  37. package/assets/rebuild-object/forge/stage1_intake/build_detail_inventory.py +349 -0
  38. package/assets/rebuild-object/forge/stage1_intake/camera_fitting_math.py +133 -0
  39. package/assets/rebuild-object/forge/stage1_intake/camera_fitting_solver.py +197 -0
  40. package/assets/rebuild-object/forge/stage1_intake/camera_fitting_types.py +291 -0
  41. package/assets/rebuild-object/forge/stage1_intake/camera_image_helpers.py +133 -0
  42. package/assets/rebuild-object/forge/stage1_intake/check_intake_correctness.py +116 -0
  43. package/assets/rebuild-object/forge/stage1_intake/check_reference_admission.py +203 -0
  44. package/assets/rebuild-object/forge/stage1_intake/cs2_foundation.py +139 -0
  45. package/assets/rebuild-object/forge/stage1_intake/cs2_manifest.py +230 -0
  46. package/assets/rebuild-object/forge/stage1_intake/cs2_review_contract.py +42 -0
  47. package/assets/rebuild-object/forge/stage1_intake/delight_albedo.py +352 -0
  48. package/assets/rebuild-object/forge/stage1_intake/detect_cs2.py +276 -0
  49. package/assets/rebuild-object/forge/stage1_intake/detect_reference_effects.py +275 -0
  50. package/assets/rebuild-object/forge/stage1_intake/extract_cs2_textures.py +126 -0
  51. package/assets/rebuild-object/forge/stage1_intake/extract_gradient_stops.py +149 -0
  52. package/assets/rebuild-object/forge/stage1_intake/extract_hair_evidence.py +385 -0
  53. package/assets/rebuild-object/forge/stage1_intake/extract_landmarks.py +456 -0
  54. package/assets/rebuild-object/forge/stage1_intake/extract_part_color_recipe.py +496 -0
  55. package/assets/rebuild-object/forge/stage1_intake/extract_pbr_evidence.py +843 -0
  56. package/assets/rebuild-object/forge/stage1_intake/fetch_cs2_metadata.py +147 -0
  57. package/assets/rebuild-object/forge/stage1_intake/label_glb_nodes.py +318 -0
  58. package/assets/rebuild-object/forge/stage1_intake/locate_cs2_vpk.py +73 -0
  59. package/assets/rebuild-object/forge/stage1_intake/material_region_analysis.py +227 -0
  60. package/assets/rebuild-object/forge/stage1_intake/probe_glb.py +357 -0
  61. package/assets/rebuild-object/forge/stage1_intake/probe_image.py +168 -0
  62. package/assets/rebuild-object/forge/stage1_intake/run_vision_adapter.py +45 -0
  63. package/assets/rebuild-object/forge/stage1_intake/search_specs.py +258 -0
  64. package/assets/rebuild-object/forge/stage1_intake/semantic_decomposition.py +119 -0
  65. package/assets/rebuild-object/forge/stage1_intake/solve_camera_pose.py +254 -0
  66. package/assets/rebuild-object/forge/stage2_spec/apply_material_analysis.py +192 -0
  67. package/assets/rebuild-object/forge/stage2_spec/cs2_adapters.py +62 -0
  68. package/assets/rebuild-object/forge/stage2_spec/derive_geometry.py +118 -0
  69. package/assets/rebuild-object/forge/stage2_spec/hair_profile.py +306 -0
  70. package/assets/rebuild-object/forge/stage2_spec/humanoid_proportions.py +214 -0
  71. package/assets/rebuild-object/forge/stage2_spec/new_pre_spec_assessment.py +343 -0
  72. package/assets/rebuild-object/forge/stage2_spec/new_sculpt_spec.py +2396 -0
  73. package/assets/rebuild-object/forge/stage2_spec/validate_sculpt_spec.py +2871 -0
  74. package/assets/rebuild-object/forge/stage3_build/bake_projected_texture.py +181 -0
  75. package/assets/rebuild-object/forge/stage3_build/decimate.py +272 -0
  76. package/assets/rebuild-object/forge/stage3_build/generate_threejs_factory.py +4099 -0
  77. package/assets/rebuild-object/forge/stage3_build/module_cache.py +155 -0
  78. package/assets/rebuild-object/forge/stage3_build/morph_targets.py +178 -0
  79. package/assets/rebuild-object/forge/stage3_build/orchestrate_passes.py +653 -0
  80. package/assets/rebuild-object/forge/stage3_build/uv_unwrap.py +622 -0
  81. package/assets/rebuild-object/forge/stage3_build/visual_hull.py +357 -0
  82. package/assets/rebuild-object/forge/stage4_review/_fit_divine_eye.py +64 -0
  83. package/assets/rebuild-object/forge/stage4_review/append_review.py +453 -0
  84. package/assets/rebuild-object/forge/stage4_review/attachment_anchor.py +349 -0
  85. package/assets/rebuild-object/forge/stage4_review/calibrate_eye.py +131 -0
  86. package/assets/rebuild-object/forge/stage4_review/check_part_coverage.py +298 -0
  87. package/assets/rebuild-object/forge/stage4_review/compare_region_passes.py +169 -0
  88. package/assets/rebuild-object/forge/stage4_review/correction_loop.py +258 -0
  89. package/assets/rebuild-object/forge/stage4_review/cs2_review.py +224 -0
  90. package/assets/rebuild-object/forge/stage4_review/diagnose_render.py +356 -0
  91. package/assets/rebuild-object/forge/stage4_review/diagnose_render_multi_angle.py +143 -0
  92. package/assets/rebuild-object/forge/stage4_review/divine_eye.py +461 -0
  93. package/assets/rebuild-object/forge/stage4_review/fit_params.py +381 -0
  94. package/assets/rebuild-object/forge/stage4_review/geometry_integrity.py +294 -0
  95. package/assets/rebuild-object/forge/stage4_review/hair_gate.py +216 -0
  96. package/assets/rebuild-object/forge/stage4_review/interior_difference.py +188 -0
  97. package/assets/rebuild-object/forge/stage4_review/joint_loops.py +209 -0
  98. package/assets/rebuild-object/forge/stage4_review/make_comparison_sheet.py +292 -0
  99. package/assets/rebuild-object/forge/stage4_review/material_comparator.py +181 -0
  100. package/assets/rebuild-object/forge/stage4_review/material_feedback.py +143 -0
  101. package/assets/rebuild-object/forge/stage4_review/material_gate.py +126 -0
  102. package/assets/rebuild-object/forge/stage4_review/material_views.py +184 -0
  103. package/assets/rebuild-object/forge/stage4_review/mesh_reference_compare.py +362 -0
  104. package/assets/rebuild-object/forge/stage4_review/multi_pass.py +102 -0
  105. package/assets/rebuild-object/forge/stage4_review/objectness.py +143 -0
  106. package/assets/rebuild-object/forge/stage4_review/pairwise_penetration.py +376 -0
  107. package/assets/rebuild-object/forge/stage4_review/per_feature.py +215 -0
  108. package/assets/rebuild-object/forge/stage4_review/render_bridge.py +556 -0
  109. package/assets/rebuild-object/forge/stage4_review/scalp_exposure.py +257 -0
  110. package/assets/rebuild-object/forge/stage4_review/self_intersection.py +592 -0
  111. package/assets/rebuild-object/forge/stage4_review/swept_arc_gate.py +336 -0
  112. package/assets/rebuild-object/forge/stage4_review/turntable_gate.py +415 -0
  113. package/assets/rebuild-object/forge/stage4_review/validate_render_profile.py +182 -0
  114. package/assets/rebuild-object/forge/stage4_review/vertex_region_gate.py +456 -0
  115. package/assets/rebuild-object/forge/stage4_review/vlm_gate.py +196 -0
  116. package/assets/rebuild-object/forge/stage5_rig/NOTES.md +149 -0
  117. package/assets/rebuild-object/forge/stage5_rig/__init__.py +6 -0
  118. package/assets/rebuild-object/forge/stage5_rig/emit_rig.py +420 -0
  119. package/assets/rebuild-object/forge/stage5_rig/geodesic_skinning.py +508 -0
  120. package/assets/rebuild-object/forge/stage5_rig/rig_spec.py +174 -0
  121. package/assets/rebuild-object/forge/stage5_rig/validate_rig_payload.py +195 -0
  122. package/assets/rebuild-object/forge/state.py +98 -0
  123. package/assets/rebuild-object/steps.json +381 -0
  124. package/dist/{chunk-FXXVXDTW.js → chunk-24TITAFS.js} +1 -1
  125. package/dist/{chunk-OGX4DKIS.js → chunk-2C5PG2QO.js} +1 -1
  126. package/dist/{chunk-HYOXGNWS.js → chunk-2DEVOKI7.js} +1 -1
  127. package/dist/{chunk-RRI23NK2.js → chunk-2GHPYT2P.js} +1 -1
  128. package/dist/{chunk-S7HYWITX.js → chunk-2HXGMXGC.js} +1 -1
  129. package/dist/{chunk-N2UHAQXC.js → chunk-36FORP7T.js} +0 -1
  130. package/dist/{chunk-VB4WLJR2.js → chunk-3IXRQTRF.js} +1 -1
  131. package/dist/{chunk-2KVQJKIZ.js → chunk-4ENHS32B.js} +23 -36
  132. package/dist/{chunk-SXYQL4GK.js → chunk-4YHA32OE.js} +1 -1
  133. package/dist/{chunk-4FJXCS3K.js → chunk-4ZGQKPK5.js} +1 -1
  134. package/dist/{chunk-SBXCK2I2.js → chunk-6CLUPFQA.js} +2 -2
  135. package/dist/{chunk-TXOE5UY5.js → chunk-7WTF2BA4.js} +1 -1
  136. package/dist/{chunk-R2WVORGD.js → chunk-AAXZNK4Z.js} +1 -1
  137. package/dist/{chunk-DOOQUFPG.js → chunk-ALLBT4FB.js} +1 -1
  138. package/dist/{chunk-HRKVAXNN.js → chunk-BAZDPPIG.js} +5 -5
  139. package/dist/{chunk-RPJR3S5S.js → chunk-CYDENLZ4.js} +5 -8
  140. package/dist/{chunk-I5LELJSK.js → chunk-DKSUD44G.js} +1 -1
  141. package/dist/{chunk-43P4U7CB.js → chunk-DWWSJKTE.js} +1 -1
  142. package/dist/{chunk-SUSX3QIA.js → chunk-E72TFJZP.js} +1 -1
  143. package/dist/{chunk-E3FJUPLT.js → chunk-EUAAQMUA.js} +2 -0
  144. package/dist/{chunk-U6DTE5IX.js → chunk-F7LYJSZE.js} +1 -1
  145. package/dist/{chunk-MEAO33XW.js → chunk-FMON3C74.js} +8 -8
  146. package/dist/{chunk-GLEW7VJQ.js → chunk-FPILHRLZ.js} +1 -1
  147. package/dist/{chunk-OPUCUUID.js → chunk-G63MXDX2.js} +4 -0
  148. package/dist/{chunk-4UU622RK.js → chunk-GGO6ZYYI.js} +1 -3
  149. package/dist/{chunk-2ZKS7V72.js → chunk-GZCRYYS6.js} +5 -5
  150. package/dist/{chunk-E7NDOZ27.js → chunk-LE4GVTYI.js} +8 -8
  151. package/dist/{chunk-RKS7SI5L.js → chunk-NO6KPV64.js} +1 -1
  152. package/dist/{chunk-KJK5CB6E.js → chunk-NXW3Z4Y4.js} +1 -1
  153. package/dist/{chunk-7RPLQWR2.js → chunk-OHOAZGO4.js} +1 -1
  154. package/dist/chunk-PYJNI5WD.js +83 -0
  155. package/dist/{chunk-NCX6LYNJ.js → chunk-Q4XAGTFX.js} +1 -1
  156. package/dist/{chunk-3UGGMFJJ.js → chunk-QMZBSVKF.js} +1 -1
  157. package/dist/{chunk-ABTUEIRC.js → chunk-QO66UBOS.js} +2 -2
  158. package/dist/{chunk-LONQWRTR.js → chunk-S4KVGQQO.js} +8 -8
  159. package/dist/{chunk-HX5Q63UA.js → chunk-T777EXAO.js} +1 -1
  160. package/dist/{chunk-UQ7VO6B3.js → chunk-TZZNRA3S.js} +1 -1
  161. package/dist/{chunk-CTY2WZQK.js → chunk-UC3QLWMQ.js} +1 -1
  162. package/dist/{chunk-MR5KIFI7.js → chunk-UDJH2RED.js} +3 -3
  163. package/dist/{chunk-ZHLPE6LI.js → chunk-UIKYK7KI.js} +1 -1
  164. package/dist/{chunk-KAGVI3CE.js → chunk-UJRSQO2B.js} +1 -1
  165. package/dist/{chunk-Q2QC6KAZ.js → chunk-V7LEYVXB.js} +29 -25
  166. package/dist/{chunk-DB7WVFS7.js → chunk-WRMQEXUC.js} +1 -1
  167. package/dist/{chunk-HSMG6U7J.js → chunk-WXSBNC67.js} +3 -9
  168. package/dist/{chunk-QLCVLCPM.js → chunk-X4QIOXNQ.js} +1 -1
  169. package/dist/{chunk-5YPLKGY3.js → chunk-Y6WHUK2O.js} +1 -1
  170. package/dist/{chunk-VZEJ2ZHE.js → chunk-Z3E7ORGQ.js} +5 -5
  171. package/dist/index.js +20 -20
  172. package/package.json +32 -22
  173. package/dist/{chunk-Q3XQPNF6.js → chunk-BN7TR6OR.js} +3 -3
  174. package/dist/{chunk-LORGE2NB.js → chunk-U2NCN5RO.js} +3 -3
  175. package/dist/{chunk-UPHB5HWO.js → chunk-VQTTSPA3.js} +3 -3
@@ -0,0 +1,147 @@
1
+ #!/usr/bin/env python3
2
+ """Resolve CS2 skin metadata (paint index, float range, rarity, CDN image) from the CSGO-API
3
+ skins index -- an optional exactness upgrade over the image-only default. Never guesses: a
4
+ no-match or an ambiguous multi-match is an error, not a silent pick. See
5
+ grimoire/intake/cs2_texture_acquisition.md and openspec add-cs2-item-reconstruction task 5.2.
6
+
7
+ The index is the public CSGO-API `skins.json` shape: a list of records like
8
+ {"name": "Karambit | Doppler (Phase 2)", "weapon": {"name": "Karambit"},
9
+ "paint_index": 419, "min_float": 0.0, "max_float": 0.08,
10
+ "rarity": {"name": "Covert"}, "image": "https://.../419.png"}
11
+ Load it locally with --index-file (no network) or fetch it with --index-url.
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ import argparse
17
+ import json
18
+ import sys
19
+ import urllib.request
20
+ from pathlib import Path
21
+
22
+
23
+ def load_index(index_file: Path | None, index_url: str | None) -> list[dict]:
24
+ if index_file is not None:
25
+ data = json.loads(index_file.expanduser().read_text(encoding="utf-8"))
26
+ elif index_url is not None:
27
+ with urllib.request.urlopen(index_url, timeout=30) as response: # noqa: S310 (user-supplied trusted URL)
28
+ data = json.loads(response.read().decode("utf-8"))
29
+ else:
30
+ raise ValueError("provide --index-file or --index-url")
31
+ if isinstance(data, dict): # some CSGO-API mirrors key by id
32
+ data = list(data.values())
33
+ if not isinstance(data, list):
34
+ raise ValueError("index must be a JSON list (or id-keyed object) of skin records")
35
+ return [record for record in data if isinstance(record, dict)]
36
+
37
+
38
+ def _weapon_name(record: dict) -> str:
39
+ weapon = record.get("weapon")
40
+ if isinstance(weapon, dict):
41
+ return str(weapon.get("name") or "")
42
+ return str(weapon or "")
43
+
44
+
45
+ def _rarity_name(record: dict) -> str:
46
+ rarity = record.get("rarity")
47
+ if isinstance(rarity, dict):
48
+ return str(rarity.get("name") or "")
49
+ return str(rarity or "")
50
+
51
+
52
+ def match_records(records: list[dict], weapon: str, skin: str, phase: str | None,
53
+ paint_index: int | None = None) -> list[dict]:
54
+ weapon_l, skin_l = weapon.lower(), skin.lower()
55
+ phase_l = phase.lower() if phase else None
56
+ matches = []
57
+ for record in records:
58
+ name_l = str(record.get("name") or "").lower()
59
+ if _weapon_name(record).lower() != weapon_l:
60
+ continue
61
+ if skin_l not in name_l:
62
+ continue
63
+ if phase_l is not None and phase_l not in name_l:
64
+ continue
65
+ if paint_index is not None and str(record.get("paint_index")) != str(paint_index):
66
+ continue
67
+ matches.append(record)
68
+ return matches
69
+
70
+
71
+ def to_metadata(record: dict, source: str | None = None) -> dict:
72
+ metadata = {
73
+ "name": record.get("name"),
74
+ "weapon": _weapon_name(record),
75
+ "paintIndex": record.get("paint_index"),
76
+ "minFloat": record.get("min_float"),
77
+ "maxFloat": record.get("max_float"),
78
+ "floatRange": {"min": record.get("min_float"), "max": record.get("max_float")},
79
+ "rarity": _rarity_name(record),
80
+ "imageUrl": record.get("image"),
81
+ }
82
+ if source:
83
+ metadata["source"] = source
84
+ metadata["provenance"] = {"kind": "metadata-index", "source": source or "unspecified"}
85
+ return metadata
86
+
87
+
88
+ def main(argv: list[str]) -> int:
89
+ parser = argparse.ArgumentParser(description=__doc__)
90
+ parser.add_argument("--weapon", required=True, help="Weapon name, e.g. 'Karambit'")
91
+ parser.add_argument("--skin", required=True, help="Skin/paint kit name substring, e.g. 'Doppler'")
92
+ parser.add_argument("--phase", help="Disambiguating phase substring, e.g. 'Phase 2' or 'Emerald'")
93
+ parser.add_argument("--paint-index", type=int, dest="paint_index",
94
+ help="Exact paint_index to disambiguate when names collide (e.g. CSGO-API lists "
95
+ "every Doppler phase as the same name; --paint-index 419 picks Phase 2).")
96
+ parser.add_argument("--index-file", type=Path, help="Local CSGO-API skins JSON")
97
+ parser.add_argument("--index-url", help="Remote CSGO-API skins JSON URL")
98
+ parser.add_argument("--out", type=Path, help="Write the resolved metadata JSON here")
99
+ parser.add_argument("--force", action="store_true", help="Overwrite --out if it exists")
100
+ parser.add_argument("--download-image", type=Path,
101
+ help="Directory to download the resolved CDN image into (optional)")
102
+ args = parser.parse_args(argv)
103
+
104
+ try:
105
+ records = load_index(args.index_file, args.index_url)
106
+ except (ValueError, OSError, json.JSONDecodeError) as exc:
107
+ print(f"error: could not load skin index: {exc}", file=sys.stderr)
108
+ return 2
109
+
110
+ matches = match_records(records, args.weapon, args.skin, args.phase, args.paint_index)
111
+ if not matches:
112
+ print(f"error: no match for weapon={args.weapon!r} skin={args.skin!r} "
113
+ f"phase={args.phase!r}; refine the query (nothing guessed)", file=sys.stderr)
114
+ return 2
115
+ if len(matches) > 1:
116
+ names = "; ".join(f"{m.get('name')} (paint_index={m.get('paint_index')})" for m in matches)
117
+ print(f"error: ambiguous match ({len(matches)}): {names}. Add --phase or --paint-index to "
118
+ "disambiguate (nothing guessed).", file=sys.stderr)
119
+ return 2
120
+
121
+ source = str(args.index_file.expanduser().resolve()) if args.index_file else args.index_url
122
+ metadata = to_metadata(matches[0], source)
123
+
124
+ if args.download_image and metadata.get("imageUrl"):
125
+ args.download_image.expanduser().mkdir(parents=True, exist_ok=True)
126
+ target = args.download_image.expanduser() / f"{metadata.get('paintIndex')}.png"
127
+ try:
128
+ urllib.request.urlretrieve(metadata["imageUrl"], target) # noqa: S310
129
+ metadata["imagePath"] = str(target)
130
+ except OSError as exc:
131
+ print(f"warning: image download failed ({exc}); metadata still resolved", file=sys.stderr)
132
+
133
+ payload = json.dumps(metadata, indent=2, ensure_ascii=False) + "\n"
134
+ if args.out:
135
+ output = args.out.expanduser().resolve()
136
+ if output.exists() and not args.force:
137
+ print(f"error: {output} exists (use --force)", file=sys.stderr)
138
+ return 2
139
+ output.write_text(payload, encoding="utf-8")
140
+ print(f"wrote {output}")
141
+ else:
142
+ sys.stdout.write(payload)
143
+ return 0
144
+
145
+
146
+ if __name__ == "__main__":
147
+ raise SystemExit(main(sys.argv[1:]))
@@ -0,0 +1,318 @@
1
+ #!/usr/bin/env python3
2
+ """Label a multipart GLB's mesh nodes from MEASURED world-space bounds, never from their names.
3
+
4
+ WHY THIS REFUSES TO READ NAMES. `probe_glb.py` can report `reliableSemanticBoundary:
5
+ named-node-or-mesh` while every name is meaningless -- the reference this was written against has 16
6
+ nodes called `root.0`..`root.15` and 16 materials with the same strings. A pipeline that trusts those
7
+ names will confidently call a boot a knee pad, and every per-region comparison built on top inherits
8
+ the error silently. So the only inputs here are geometry: each node's world-space axis-aligned bounds,
9
+ normalised against the figure's own height.
10
+
11
+ WHAT THIS IS, EXACTLY. Hypothesis evidence, at the level `SKILL.md`'s GLB track allows for
12
+ connected-component/curvature segmentation -- NOT a confirmed semantic label. Every entry carries a
13
+ `confidence` and the measurement that produced it, and the report's `status` stays
14
+ `hypothesis-requires-render-confirmation` until a browser semantic-ID pass confirms it. Treating this
15
+ output as confirmed is the failure it is designed to make visible rather than prevent.
16
+
17
+ Only the glTF JSON chunk is read. Accessors carry POSITION `min`/`max`, so per-mesh bounds are exact
18
+ without decoding a single vertex -- which matters when the asset is 104 MB.
19
+
20
+ Pure Python 3.10+ standard library.
21
+ """
22
+ from __future__ import annotations
23
+
24
+ import argparse
25
+ import json
26
+ import struct
27
+ import sys
28
+ from pathlib import Path
29
+ from typing import Any, Sequence
30
+
31
+ GLB_MAGIC = 0x46546C67
32
+ CHUNK_JSON = 0x4E4F534A
33
+
34
+ # Height fractions of the figure's own bounding box. Derived from human proportion, not tuned against
35
+ # this asset: a boot sole is at 0, a head crown at 1. Bands overlap on purpose -- an overlap produces
36
+ # a lower confidence and a named ambiguity, which is the honest answer for a node that spans two.
37
+ BANDS: tuple[tuple[str, float, float], ...] = (
38
+ ("footwear", 0.00, 0.12),
39
+ ("lower-leg", 0.10, 0.30),
40
+ ("knee", 0.28, 0.42),
41
+ ("thigh", 0.38, 0.55),
42
+ ("hip-waist", 0.50, 0.62),
43
+ ("torso", 0.60, 0.80),
44
+ ("shoulder-neck", 0.78, 0.88),
45
+ ("head", 0.86, 1.00),
46
+ )
47
+
48
+ # Below this fraction of the figure's half-width, a node sits on the midline and has no side.
49
+ MIDLINE_FRACTION = 0.08
50
+
51
+
52
+ def _read_gltf_json(path: Path) -> dict[str, Any]:
53
+ with path.open("rb") as handle:
54
+ header = handle.read(12)
55
+ if len(header) < 12:
56
+ raise ValueError("file is too short to be a GLB")
57
+ magic, _version, _length = struct.unpack("<III", header)
58
+ if magic != GLB_MAGIC:
59
+ raise ValueError("not a GLB container (bad magic)")
60
+ chunk_header = handle.read(8)
61
+ if len(chunk_header) < 8:
62
+ raise ValueError("GLB has no chunk header")
63
+ chunk_length, chunk_type = struct.unpack("<II", chunk_header)
64
+ if chunk_type != CHUNK_JSON:
65
+ raise ValueError("first GLB chunk is not JSON")
66
+ payload = handle.read(chunk_length)
67
+ return json.loads(payload.decode("utf-8"))
68
+
69
+
70
+ def _identity() -> list[float]:
71
+ return [1.0, 0, 0, 0, 0, 1.0, 0, 0, 0, 0, 1.0, 0, 0, 0, 0, 1.0]
72
+
73
+
74
+ def _compose(node: dict[str, Any]) -> list[float]:
75
+ """Column-major 4x4 for a glTF node, from `matrix` or from TRS."""
76
+ if isinstance(node.get("matrix"), list) and len(node["matrix"]) == 16:
77
+ return [float(v) for v in node["matrix"]]
78
+ tx, ty, tz = (node.get("translation") or [0.0, 0.0, 0.0])[:3]
79
+ qx, qy, qz, qw = (node.get("rotation") or [0.0, 0.0, 0.0, 1.0])[:4]
80
+ sx, sy, sz = (node.get("scale") or [1.0, 1.0, 1.0])[:3]
81
+ # Rotation matrix from quaternion, then scale each basis column.
82
+ xx, yy, zz = qx * qx, qy * qy, qz * qz
83
+ xy, xz, yz = qx * qy, qx * qz, qy * qz
84
+ wx, wy, wz = qw * qx, qw * qy, qw * qz
85
+ r = [
86
+ 1 - 2 * (yy + zz), 2 * (xy + wz), 2 * (xz - wy),
87
+ 2 * (xy - wz), 1 - 2 * (xx + zz), 2 * (yz + wx),
88
+ 2 * (xz + wy), 2 * (yz - wx), 1 - 2 * (xx + yy),
89
+ ]
90
+ return [
91
+ r[0] * sx, r[1] * sx, r[2] * sx, 0.0,
92
+ r[3] * sy, r[4] * sy, r[5] * sy, 0.0,
93
+ r[6] * sz, r[7] * sz, r[8] * sz, 0.0,
94
+ float(tx), float(ty), float(tz), 1.0,
95
+ ]
96
+
97
+
98
+ def _multiply(a: Sequence[float], b: Sequence[float]) -> list[float]:
99
+ """Column-major `a * b`, applying b first."""
100
+ out = [0.0] * 16
101
+ for col in range(4):
102
+ for row in range(4):
103
+ out[col * 4 + row] = sum(a[k * 4 + row] * b[col * 4 + k] for k in range(4))
104
+ return out
105
+
106
+
107
+ def _apply(matrix: Sequence[float], point: Sequence[float]) -> tuple[float, float, float]:
108
+ x, y, z = point
109
+ return (
110
+ matrix[0] * x + matrix[4] * y + matrix[8] * z + matrix[12],
111
+ matrix[1] * x + matrix[5] * y + matrix[9] * z + matrix[13],
112
+ matrix[2] * x + matrix[6] * y + matrix[10] * z + matrix[14],
113
+ )
114
+
115
+
116
+ def _mesh_local_bounds(gltf: dict[str, Any], mesh_index: int) -> tuple[list[float], list[float]] | None:
117
+ """Union of every primitive's POSITION accessor min/max. Exact, and reads no vertex data."""
118
+ meshes = gltf.get("meshes") or []
119
+ accessors = gltf.get("accessors") or []
120
+ if mesh_index >= len(meshes):
121
+ return None
122
+ lo = [float("inf")] * 3
123
+ hi = [float("-inf")] * 3
124
+ found = False
125
+ for primitive in meshes[mesh_index].get("primitives") or []:
126
+ position = (primitive.get("attributes") or {}).get("POSITION")
127
+ if position is None or position >= len(accessors):
128
+ continue
129
+ accessor = accessors[position]
130
+ amin, amax = accessor.get("min"), accessor.get("max")
131
+ if not (isinstance(amin, list) and isinstance(amax, list) and len(amin) >= 3):
132
+ continue
133
+ found = True
134
+ for axis in range(3):
135
+ lo[axis] = min(lo[axis], float(amin[axis]))
136
+ hi[axis] = max(hi[axis], float(amax[axis]))
137
+ return (lo, hi) if found else None
138
+
139
+
140
+ def _world_bounds(matrix: Sequence[float], lo: Sequence[float], hi: Sequence[float]) -> dict[str, list[float]]:
141
+ """AABB of the transformed local AABB. All 8 corners, because a rotation makes the naive
142
+ min/max-of-endpoints answer wrong."""
143
+ wlo = [float("inf")] * 3
144
+ whi = [float("-inf")] * 3
145
+ for ix in (lo[0], hi[0]):
146
+ for iy in (lo[1], hi[1]):
147
+ for iz in (lo[2], hi[2]):
148
+ for axis, value in enumerate(_apply(matrix, (ix, iy, iz))):
149
+ wlo[axis] = min(wlo[axis], value)
150
+ whi[axis] = max(whi[axis], value)
151
+ return {
152
+ "min": [round(v, 6) for v in wlo],
153
+ "max": [round(v, 6) for v in whi],
154
+ "center": [round((wlo[i] + whi[i]) / 2, 6) for i in range(3)],
155
+ "size": [round(whi[i] - wlo[i], 6) for i in range(3)],
156
+ }
157
+
158
+
159
+ def _collect(gltf: dict[str, Any]) -> list[dict[str, Any]]:
160
+ """Every mesh-bearing node with its world matrix, walking the scene tree parents-first."""
161
+ nodes = gltf.get("nodes") or []
162
+ scenes = gltf.get("scenes") or []
163
+ scene_index = gltf.get("scene", 0)
164
+ roots = scenes[scene_index].get("nodes", []) if scene_index < len(scenes) else list(range(len(nodes)))
165
+ collected: list[dict[str, Any]] = []
166
+ stack: list[tuple[int, list[float]]] = [(int(r), _identity()) for r in roots]
167
+ seen: set[int] = set()
168
+ while stack:
169
+ index, parent = stack.pop()
170
+ if index in seen or index >= len(nodes):
171
+ continue
172
+ seen.add(index)
173
+ node = nodes[index]
174
+ world = _multiply(parent, _compose(node))
175
+ if isinstance(node.get("mesh"), int):
176
+ local = _mesh_local_bounds(gltf, node["mesh"])
177
+ if local is not None:
178
+ collected.append({
179
+ "nodeIndex": index,
180
+ "nodeName": node.get("name"),
181
+ "meshIndex": node["mesh"],
182
+ "bounds": _world_bounds(world, local[0], local[1]),
183
+ })
184
+ for child in node.get("children") or []:
185
+ stack.append((int(child), world))
186
+ return sorted(collected, key=lambda e: e["nodeIndex"])
187
+
188
+
189
+ def _classify(entry: dict[str, Any], figure: dict[str, list[float]]) -> dict[str, Any]:
190
+ """Height band + lateral side, from measurement only. Overlap lowers confidence and is named."""
191
+ base_y, top_y = figure["min"][1], figure["max"][1]
192
+ height = max(top_y - base_y, 1e-9)
193
+ centre = entry["bounds"]["center"]
194
+ lo_f = (entry["bounds"]["min"][1] - base_y) / height
195
+ hi_f = (entry["bounds"]["max"][1] - base_y) / height
196
+ mid_f = (centre[1] - base_y) / height
197
+
198
+ matches = [name for name, low, high in BANDS if not (hi_f < low or lo_f > high)]
199
+ containing = [name for name, low, high in BANDS if low <= mid_f <= high]
200
+ band = containing[0] if containing else (matches[0] if matches else "unbanded")
201
+
202
+ half_width = max(abs(figure["min"][0]), abs(figure["max"][0]), 1e-9)
203
+ lateral = centre[0] / half_width
204
+ if abs(lateral) < MIDLINE_FRACTION:
205
+ side = "midline"
206
+ else:
207
+ # With forward +Z and a right-handed frame the character's own left is +X. Same convention as
208
+ # forge/_shared/chirality.py CHARACTER_LEFT_SIGN, which exists so this cannot silently diverge.
209
+ side = "left" if lateral > 0 else "right"
210
+
211
+ span_fraction = hi_f - lo_f
212
+ # A node spanning most of the figure is a merged multi-part shell, not one body part. Saying so is
213
+ # more useful than picking whichever band its centroid happens to land in.
214
+ if span_fraction > 0.45:
215
+ band, confidence, reason = "multi-region-shell", 0.20, "spans >45% of figure height"
216
+ elif len(matches) > 2:
217
+ confidence, reason = 0.35, f"overlaps {len(matches)} height bands: {', '.join(matches)}"
218
+ elif len(matches) == 2:
219
+ confidence, reason = 0.55, f"straddles {matches[0]} and {matches[1]}"
220
+ else:
221
+ confidence, reason = 0.70, "centroid falls inside exactly one height band"
222
+
223
+ return {
224
+ "partHypothesis": f"{band}-{side}" if side != "midline" else band,
225
+ "band": band,
226
+ "side": side,
227
+ "confidence": confidence,
228
+ "evidence": {
229
+ "method": "measured-world-bounds",
230
+ "heightFractionRange": [round(lo_f, 4), round(hi_f, 4)],
231
+ "centroidHeightFraction": round(mid_f, 4),
232
+ "lateralFractionOfHalfWidth": round(lateral, 4),
233
+ "reason": reason,
234
+ },
235
+ }
236
+
237
+
238
+ def label(path: Path) -> dict[str, Any]:
239
+ gltf = _read_gltf_json(path)
240
+ entries = _collect(gltf)
241
+ if not entries:
242
+ raise ValueError("no mesh-bearing nodes found; this is not usable as a multipart baseline")
243
+
244
+ lo = [min(e["bounds"]["min"][i] for e in entries) for i in range(3)]
245
+ hi = [max(e["bounds"]["max"][i] for e in entries) for i in range(3)]
246
+ figure = {
247
+ "min": [round(v, 6) for v in lo],
248
+ "max": [round(v, 6) for v in hi],
249
+ "size": [round(hi[i] - lo[i], 6) for i in range(3)],
250
+ }
251
+
252
+ labelled = []
253
+ for entry in entries:
254
+ labelled.append({**entry, **_classify(entry, figure)})
255
+
256
+ # A name is recorded as an observation and never used as evidence. If a caller ever wants to trust
257
+ # it, this flag is what they have to argue past.
258
+ names = [e.get("nodeName") for e in entries]
259
+ return {
260
+ "schemaVersion": 1,
261
+ "kind": "glb-semantic-map",
262
+ "status": "hypothesis-requires-render-confirmation",
263
+ "source": {"path": str(path), "nodeCount": len(entries)},
264
+ "figureBounds": figure,
265
+ "namesUsedAsEvidence": False,
266
+ "observedNodeNames": names,
267
+ "nodes": labelled,
268
+ "note": (
269
+ "Labels are hypotheses from measured world bounds, at the confidence level SKILL.md allows "
270
+ "for geometric segmentation. Confirm each with a browser semantic-ID pass before asserting "
271
+ "any per-region result against this baseline."
272
+ ),
273
+ }
274
+
275
+
276
+ def main(argv: Sequence[str] | None = None) -> int:
277
+ parser = argparse.ArgumentParser(description=__doc__.split("\n\n")[0])
278
+ parser.add_argument("glb", type=Path)
279
+ parser.add_argument("--out", type=Path)
280
+ parser.add_argument(
281
+ "--min-confidence",
282
+ type=float,
283
+ default=0.0,
284
+ help="exit 1 if any node lands below this; use it to gate a downstream per-region claim",
285
+ )
286
+ args = parser.parse_args(argv)
287
+
288
+ try:
289
+ report = label(args.glb)
290
+ except ValueError as error:
291
+ print(f"FAILED: {error}", file=sys.stderr)
292
+ return 2
293
+
294
+ if args.out:
295
+ args.out.parent.mkdir(parents=True, exist_ok=True)
296
+ args.out.write_text(json.dumps(report, indent=2) + "\n", encoding="utf-8")
297
+
298
+ weak = [n for n in report["nodes"] if n["confidence"] < args.min_confidence]
299
+ for node in report["nodes"]:
300
+ print(
301
+ f" node {node['nodeIndex']:>3} {str(node['nodeName'])[:18]:20s} "
302
+ f"{node['partHypothesis']:24s} conf={node['confidence']:.2f} "
303
+ f"y={node['evidence']['heightFractionRange']} {node['evidence']['reason']}"
304
+ )
305
+ print(f"\n{len(report['nodes'])} nodes, figure size {report['figureBounds']['size']}")
306
+ print(f"status: {report['status']}")
307
+ if weak:
308
+ print(
309
+ f"\nFAILED: {len(weak)} node(s) below --min-confidence {args.min_confidence}: "
310
+ f"{', '.join(str(n['nodeIndex']) for n in weak)}",
311
+ file=sys.stderr,
312
+ )
313
+ return 1
314
+ return 0
315
+
316
+
317
+ if __name__ == "__main__":
318
+ raise SystemExit(main())
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env python3
2
+ """Locate a local CS2 install's paks VPK (`pak01_dir.vpk`) so the optional exact-texture upgrade
3
+ can extract Valve's authored paint textures from the user's own legal copy. Best-effort and
4
+ non-fatal: returns None / {"found": false} when nothing is located, never raises -- the pipeline
5
+ falls back to the image-only path. See grimoire/intake/cs2_texture_acquisition.md and openspec
6
+ add-cs2-item-reconstruction task 5.3.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import argparse
12
+ import json
13
+ import sys
14
+ from pathlib import Path
15
+
16
+ # CS2 (Source 2) ships the paints under game/csgo relative to the install dir.
17
+ _VPK_RELATIVE = Path("steamapps/common/Counter-Strike Global Offensive/game/csgo/pak01_dir.vpk")
18
+
19
+
20
+ def default_steam_roots() -> list[Path]:
21
+ """Per-OS default Steam library roots. Missing paths are harmless -- they just don't match."""
22
+ home = Path.home()
23
+ if sys.platform == "darwin":
24
+ return [home / "Library/Application Support/Steam"]
25
+ if sys.platform.startswith("win"):
26
+ return [Path("C:/Program Files (x86)/Steam"), Path("C:/Program Files/Steam")]
27
+ # linux / other
28
+ return [
29
+ home / ".steam/steam",
30
+ home / ".local/share/Steam",
31
+ home / ".steam/root",
32
+ ]
33
+
34
+
35
+ def locate_vpk(roots: list[Path] | None = None) -> Path | None:
36
+ """Return the first existing pak01_dir.vpk across the given (or default) Steam roots.
37
+ Dependency-injectable `roots` keeps this testable offline."""
38
+ search_roots = list(roots) if roots else default_steam_roots()
39
+ seen: set[Path] = set()
40
+ for root in search_roots:
41
+ root = Path(root)
42
+ if root in seen:
43
+ continue
44
+ seen.add(root)
45
+ vpk = root / _VPK_RELATIVE
46
+ if vpk.is_file():
47
+ return vpk
48
+ return None
49
+
50
+
51
+ def main(argv: list[str]) -> int:
52
+ parser = argparse.ArgumentParser(description=__doc__)
53
+ parser.add_argument("--root", type=Path, action="append", dest="roots",
54
+ help="Steam root to search (repeatable); defaults to per-OS Steam locations")
55
+ parser.add_argument("--json", action="store_true", help="Emit a JSON result object")
56
+ args = parser.parse_args(argv)
57
+
58
+ vpk = locate_vpk(args.roots)
59
+ found = vpk is not None
60
+ if args.json:
61
+ result = {"found": found, "path": str(vpk) if vpk else None}
62
+ if not found:
63
+ result["reason"] = "no local CS2 VPK found in the searched Steam roots"
64
+ print(json.dumps(result, indent=2))
65
+ elif found:
66
+ print(str(vpk))
67
+ else:
68
+ print("no local CS2 VPK found", file=sys.stderr)
69
+ return 0 if found else 1
70
+
71
+
72
+ if __name__ == "__main__":
73
+ raise SystemExit(main(sys.argv[1:]))