forgecad 0.10.2 → 0.10.4
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/README.md +7 -6
- package/dist/assets/{AdminPage-CHY6ZN-p.js → AdminPage-B3L3W1Uo.js} +1 -1
- package/dist/assets/{BenchmarkPage-BcRT5iGN.js → BenchmarkPage-DXKVXMrJ.js} +2 -2
- package/dist/assets/{BlogPage-BssBbnb-.js → BlogPage-B7BWxOCg.js} +1 -1
- package/dist/assets/{DocsPage-DsvdiRNK.js → DocsPage-BPGGwht1.js} +28 -48
- package/dist/assets/{EditorApp-Bfd3jbtC.js → EditorApp-BWUGCdD5.js} +183 -21
- package/dist/assets/{EditorApp-BpjZgzk0.css → EditorApp-C5f24ZN9.css} +8 -0
- package/dist/assets/{EmbedViewer-D5t8WamV.js → EmbedViewer-DygByZS2.js} +2 -2
- package/dist/assets/{LandingPageProofDriven-DbN7o-Be.js → LandingPageProofDriven-BoVE7JGY.js} +54 -36
- package/dist/assets/{LegalPage-DNGrrY0p.js → LegalPage-Din8wv8d.js} +2 -2
- package/dist/assets/{PricingPage-Nczr3pRz.js → PricingPage-C2PMzmDc.js} +2 -2
- package/dist/assets/{SettingsPage-DZlyu4d4.js → SettingsPage-BlJDCRe8.js} +1 -1
- package/dist/assets/{app-C9ct2hRD.js → app-BsRYSfxY.js} +2264 -6259
- package/dist/assets/{backendInit-ymjonyQp.js → backendInit-6C0DLgH0.js} +8290 -2136
- package/dist/assets/cli/{render-B_0lQwKU.js → render-XXol_ET7.js} +822 -105
- package/dist/assets/{constructionHistoryWorker-CZ42Dksy.js → constructionHistoryWorker-cTHWRJEi.js} +699 -284
- package/dist/assets/{evalWorker-C2pm8LHP.js → evalWorker-BssDYW9u.js} +2559 -1330
- package/dist/assets/{forgecad_geometry-BlMtqluF.js → forgecad_geometry-CZ_IfuvA.js} +1 -9
- package/dist/assets/{forgecad_geometry_bg-BllP_WiL.wasm → forgecad_geometry_bg-C3rQHfwg.wasm} +0 -0
- package/dist/assets/{inspectWorker-D5T5VbfK.js → inspectWorker-ymhBV4Ll.js} +6254 -671
- package/dist/assets/{jointPose-4r8ed8_5.js → jointPose-B0blBj9A.js} +1 -1
- package/dist/assets/{landing-proof-driven-ORyigZ6p.css → landing-proof-driven-Cpf-MIbI.css} +73 -13
- package/dist/assets/{manifold-5PP1eGLN.js → manifold-B_7QXpGB.js} +1 -1
- package/dist/assets/{manifold-DjBkyIc8.js → manifold-CNShmpEJ.js} +1 -1
- package/dist/assets/{manifold-C4r6B-XY.js → manifold-CYlIm-M6.js} +2 -2
- package/dist/assets/{reportWorker-CwenM7wB.js → reportWorker-Cb5eyM7D.js} +2485 -1275
- package/dist/cli/render.html +1 -1
- package/dist/docs/index.html +2 -2
- package/dist/docs-raw/AI/usage.md +17 -17
- package/dist/docs-raw/CLI.md +9 -7
- package/dist/docs-raw/README.md +1 -1
- package/dist/docs-raw/component-model.md +2 -2
- package/dist/docs-raw/generated/assembly.md +1 -1
- package/dist/docs-raw/generated/concepts.md +10 -4
- package/dist/docs-raw/generated/core.md +96 -1
- package/dist/docs-raw/generated/curves.md +8 -1
- package/dist/docs-raw/generated/output.md +0 -64
- package/dist/docs-raw/generated/runtime-names.md +6 -6
- package/dist/docs-raw/generated/viewport.md +3 -12
- package/dist/docs-raw/guides/inspection-bundles.md +1 -1
- package/dist/docs-raw/simulation-workflow.md +58 -0
- package/{dist-skill/website/skills/forgecad-make-a-model.md → dist/docs-raw/skills/forgecad-build-model.md} +18 -8
- package/dist/docs-raw/skills/forgecad-design-spec.md +145 -0
- package/dist/docs-raw/skills/{forgecad-model-grader.md → forgecad-grade-model.md} +8 -6
- package/{dist-skill/website/skills/forgecad-visual-spec.md → dist/docs-raw/skills/forgecad-image-prompt.md} +7 -7
- package/dist/docs-raw/skills/{forgecad-render-inspect.md → forgecad-inspect-model.md} +6 -6
- package/{dist-skill/website/skills/forgecad-project.md → dist/docs-raw/skills/forgecad-project-sync.md} +5 -5
- package/{dist-skill/website/skills/forgecad-3d-reconstruction.md → dist/docs-raw/skills/forgecad-reconstruct-cad-file.md} +7 -7
- package/dist/docs-raw/skills/{forgecad-image-replicator.md → forgecad-reconstruct-from-images.md} +12 -12
- package/dist/docs-raw/skills/forgecad-verify-mujoco.md +78 -0
- package/dist/docs-raw/skills/forgecad.md +24 -24
- package/dist/docs-raw/skills/index.md +9 -13
- package/dist/index.html +9 -9
- package/dist/llms.txt +7 -7
- package/dist/sitemap.xml +16 -16
- package/dist-cli/{check-compiler-SP7FAL7R.js → check-compiler-4RPB6SB5.js} +1 -1
- package/dist-cli/{check-query-propagation-BRLSHP22.js → check-query-propagation-KN3DFQTX.js} +1 -1
- package/dist-cli/{chunk-RQQ42YCP.js → chunk-UHBRMYA6.js} +30770 -29253
- package/dist-cli/forgecad.js +3277 -237
- package/dist-cli/{forgecad_geometry-7TVSNVUB.js → forgecad_geometry-2IMYCUWW.js} +0 -8
- package/dist-cli/forgecad_geometry_bg.wasm +0 -0
- package/dist-skill/CONTEXT.md +111 -73
- package/dist-skill/SKILL.md +1 -1
- package/dist-skill/docs/CLI.md +9 -7
- package/dist-skill/docs/generated/assembly.md +1 -1
- package/dist-skill/docs/generated/core.md +96 -1
- package/dist-skill/docs/generated/curves.md +8 -1
- package/dist-skill/docs/generated/output.md +0 -64
- package/dist-skill/docs/generated/runtime-names.md +6 -6
- package/dist-skill/docs/generated/viewport.md +3 -12
- package/dist-skill/docs/guides/inspection-bundles.md +1 -1
- package/dist-skill/library/README.md +9 -13
- package/dist-skill/library/{forgecad-make-a-model → forgecad-build-model}/SKILL.md +16 -6
- package/dist-skill/library/forgecad-design-spec/SKILL.md +132 -0
- package/dist-skill/library/{forgecad-prepare-prompt → forgecad-design-spec}/references/master-prompt.md +1 -1
- package/dist-skill/library/{forgecad-model-grader → forgecad-grade-model}/SKILL.md +6 -4
- package/dist-skill/library/forgecad-grade-model/agents/openai.yaml +4 -0
- package/dist-skill/library/{forgecad-visual-spec → forgecad-image-prompt}/SKILL.md +5 -5
- package/dist-skill/library/forgecad-image-prompt/agents/openai.yaml +4 -0
- package/dist-skill/library/{forgecad-render-inspect → forgecad-inspect-model}/SKILL.md +4 -4
- package/dist-skill/library/{forgecad-project → forgecad-project-sync}/SKILL.md +3 -3
- package/dist-skill/library/{forgecad-3d-reconstruction → forgecad-reconstruct-cad-file}/SKILL.md +5 -5
- package/dist-skill/library/forgecad-reconstruct-cad-file/agents/openai.yaml +4 -0
- package/dist-skill/library/{forgecad-image-replicator → forgecad-reconstruct-from-images}/SKILL.md +10 -10
- package/dist-skill/library/forgecad-reconstruct-from-images/agents/openai.yaml +4 -0
- package/dist-skill/library/forgecad-verify-mujoco/SKILL.md +66 -0
- package/dist-skill/library/forgecad-verify-mujoco/scripts/mujoco_verify.py +385 -0
- package/{dist/docs-raw/skills/forgecad-make-a-model.md → dist-skill/website/skills/forgecad-build-model.md} +18 -8
- package/dist-skill/website/skills/forgecad-design-spec.md +145 -0
- package/dist-skill/website/skills/{forgecad-model-grader.md → forgecad-grade-model.md} +8 -6
- package/{dist/docs-raw/skills/forgecad-visual-spec.md → dist-skill/website/skills/forgecad-image-prompt.md} +7 -7
- package/dist-skill/website/skills/{forgecad-render-inspect.md → forgecad-inspect-model.md} +6 -6
- package/{dist/docs-raw/skills/forgecad-project.md → dist-skill/website/skills/forgecad-project-sync.md} +5 -5
- package/{dist/docs-raw/skills/forgecad-3d-reconstruction.md → dist-skill/website/skills/forgecad-reconstruct-cad-file.md} +7 -7
- package/dist-skill/website/skills/{forgecad-image-replicator.md → forgecad-reconstruct-from-images.md} +12 -12
- package/dist-skill/website/skills/forgecad-verify-mujoco.md +78 -0
- package/dist-skill/website/skills/forgecad.md +24 -24
- package/dist-skill/website/skills/index.md +9 -13
- package/examples/analysis/clearance-fit.forge.js +31 -0
- package/examples/analysis/lever-arm-actuator.forge.js +43 -0
- package/examples/analysis/tipping-tripod.forge.js +35 -0
- package/examples/api/texture-projection.forge.js +75 -0
- package/examples/assets/uv-grid.png +0 -0
- package/examples/products/sportscar.forge.js +77 -0
- package/package.json +1 -3
- package/dist/docs-raw/skills/forgecad-blockout-model.md +0 -49
- package/dist/docs-raw/skills/forgecad-component-model.md +0 -53
- package/dist/docs-raw/skills/forgecad-high-level-spec.md +0 -101
- package/dist/docs-raw/skills/forgecad-lld.md +0 -41
- package/dist/docs-raw/skills/forgecad-prepare-prompt.md +0 -63
- package/dist/docs-raw/skills/forgecad-reconstruction-benchmark.md +0 -60
- package/dist-skill/library/forgecad-3d-reconstruction/agents/openai.yaml +0 -4
- package/dist-skill/library/forgecad-blockout-model/SKILL.md +0 -42
- package/dist-skill/library/forgecad-component-model/SKILL.md +0 -46
- package/dist-skill/library/forgecad-high-level-spec/SKILL.md +0 -94
- package/dist-skill/library/forgecad-image-replicator/agents/openai.yaml +0 -4
- package/dist-skill/library/forgecad-lld/SKILL.md +0 -34
- package/dist-skill/library/forgecad-model-grader/agents/openai.yaml +0 -4
- package/dist-skill/library/forgecad-prepare-prompt/SKILL.md +0 -50
- package/dist-skill/library/forgecad-reconstruction-benchmark/SKILL.md +0 -48
- package/dist-skill/library/forgecad-reconstruction-benchmark/agents/openai.yaml +0 -4
- package/dist-skill/library/forgecad-visual-spec/agents/openai.yaml +0 -4
- package/dist-skill/website/skills/forgecad-blockout-model.md +0 -49
- package/dist-skill/website/skills/forgecad-component-model.md +0 -53
- package/dist-skill/website/skills/forgecad-high-level-spec.md +0 -101
- package/dist-skill/website/skills/forgecad-lld.md +0 -41
- package/dist-skill/website/skills/forgecad-prepare-prompt.md +0 -63
- package/dist-skill/website/skills/forgecad-reconstruction-benchmark.md +0 -60
- /package/dist/assets/{landing-proof-driven-DiGqdtWa.js → landing-proof-driven-BxZZh5r5.js} +0 -0
- /package/dist-skill/library/{forgecad-prepare-prompt → forgecad-design-spec}/references/default-profiles.md +0 -0
- /package/dist-skill/library/{forgecad-render-inspect → forgecad-inspect-model}/summarize_manifest.py +0 -0
- /package/dist-skill/library/{forgecad-image-replicator → forgecad-reconstruct-from-images}/scripts/compare_images.py +0 -0
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Verify a ForgeCAD MJCF package by running MuJoCo dynamics and rendering frames."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import argparse
|
|
7
|
+
import json
|
|
8
|
+
import math
|
|
9
|
+
from collections import Counter
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from typing import Iterable
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def parse_actuator(value: str) -> tuple[str, float]:
|
|
15
|
+
if "=" not in value:
|
|
16
|
+
raise argparse.ArgumentTypeError("expected NAME=VALUE")
|
|
17
|
+
name, raw = value.split("=", 1)
|
|
18
|
+
name = name.strip()
|
|
19
|
+
if not name:
|
|
20
|
+
raise argparse.ArgumentTypeError("actuator name is empty")
|
|
21
|
+
try:
|
|
22
|
+
ctrl = float(raw)
|
|
23
|
+
except ValueError as exc:
|
|
24
|
+
raise argparse.ArgumentTypeError(f"invalid actuator value {raw!r}") from exc
|
|
25
|
+
return name, ctrl
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def parse_joint_range(value: str) -> tuple[str, float, float]:
|
|
29
|
+
if "=" not in value:
|
|
30
|
+
raise argparse.ArgumentTypeError("expected JOINT=MIN:MAX")
|
|
31
|
+
name, raw_range = value.split("=", 1)
|
|
32
|
+
name = name.strip()
|
|
33
|
+
if not name:
|
|
34
|
+
raise argparse.ArgumentTypeError("joint name is empty")
|
|
35
|
+
if ":" not in raw_range:
|
|
36
|
+
raise argparse.ArgumentTypeError("expected range as MIN:MAX")
|
|
37
|
+
raw_min, raw_max = raw_range.split(":", 1)
|
|
38
|
+
try:
|
|
39
|
+
min_value = float(raw_min)
|
|
40
|
+
max_value = float(raw_max)
|
|
41
|
+
except ValueError as exc:
|
|
42
|
+
raise argparse.ArgumentTypeError(f"invalid numeric range {raw_range!r}") from exc
|
|
43
|
+
if min_value > max_value:
|
|
44
|
+
raise argparse.ArgumentTypeError(f"range minimum {min_value} is greater than maximum {max_value}")
|
|
45
|
+
return name, min_value, max_value
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def cycles_from_radians(value: float) -> float:
|
|
49
|
+
return value / math.tau
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def resolve_scene(path: Path) -> Path:
|
|
53
|
+
if path.is_file():
|
|
54
|
+
return path
|
|
55
|
+
scene = path / "scene.xml"
|
|
56
|
+
if scene.is_file():
|
|
57
|
+
return scene
|
|
58
|
+
raise SystemExit(f"Could not find scene.xml at {path}")
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def geom_name(mujoco, model, geom_id: int) -> str:
|
|
62
|
+
return mujoco.mj_id2name(model, mujoco.mjtObj.mjOBJ_GEOM, geom_id) or f"geom#{geom_id}"
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def joint_name(mujoco, model, joint_id: int) -> str:
|
|
66
|
+
return mujoco.mj_id2name(model, mujoco.mjtObj.mjOBJ_JOINT, joint_id) or f"joint#{joint_id}"
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def contact_counts(mujoco, model, data, limit: int) -> list[dict[str, object]]:
|
|
70
|
+
counts: Counter[tuple[str, str]] = Counter()
|
|
71
|
+
for i in range(data.ncon):
|
|
72
|
+
contact = data.contact[i]
|
|
73
|
+
a = geom_name(mujoco, model, int(contact.geom1))
|
|
74
|
+
b = geom_name(mujoco, model, int(contact.geom2))
|
|
75
|
+
if a > b:
|
|
76
|
+
a, b = b, a
|
|
77
|
+
counts[(a, b)] += 1
|
|
78
|
+
return [{"geom1": a, "geom2": b, "count": count} for (a, b), count in counts.most_common(limit)]
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def qpos_for_joint(model, joint_id: int) -> float:
|
|
82
|
+
return float(model.jnt_qposadr[joint_id])
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def first_freejoint(mujoco, model) -> int | None:
|
|
86
|
+
for joint_id in range(model.njnt):
|
|
87
|
+
if model.jnt_type[joint_id] == mujoco.mjtJoint.mjJNT_FREE:
|
|
88
|
+
return joint_id
|
|
89
|
+
return None
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def make_camera(mujoco, lookat: Iterable[float], distance: float, azimuth: float, elevation: float):
|
|
93
|
+
camera = mujoco.MjvCamera()
|
|
94
|
+
camera.type = mujoco.mjtCamera.mjCAMERA_FREE
|
|
95
|
+
camera.lookat[:] = list(lookat)
|
|
96
|
+
camera.distance = distance
|
|
97
|
+
camera.azimuth = azimuth
|
|
98
|
+
camera.elevation = elevation
|
|
99
|
+
return camera
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def render_frame(mujoco, renderer, model, data, camera, label: str, path: Path) -> None:
|
|
103
|
+
from PIL import Image, ImageDraw
|
|
104
|
+
|
|
105
|
+
mujoco.mj_forward(model, data)
|
|
106
|
+
renderer.update_scene(data, camera=camera)
|
|
107
|
+
image = Image.fromarray(renderer.render())
|
|
108
|
+
draw = ImageDraw.Draw(image)
|
|
109
|
+
draw.rectangle((12, 12, min(image.width - 12, 1120), 72), fill=(255, 255, 255))
|
|
110
|
+
draw.text((22, 22), label, fill=(0, 0, 0))
|
|
111
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
112
|
+
image.save(path)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def render_camera_preview_grid(mujoco, renderer, model, data, args, path: Path) -> str:
|
|
116
|
+
from PIL import Image, ImageDraw
|
|
117
|
+
|
|
118
|
+
images = []
|
|
119
|
+
for azimuth in args.camera_preview_azimuths:
|
|
120
|
+
camera = make_camera(mujoco, args.camera_lookat, args.camera_distance, azimuth, args.camera_elevation)
|
|
121
|
+
mujoco.mj_forward(model, data)
|
|
122
|
+
renderer.update_scene(data, camera=camera)
|
|
123
|
+
image = Image.fromarray(renderer.render())
|
|
124
|
+
draw = ImageDraw.Draw(image)
|
|
125
|
+
label = f"azimuth {azimuth:g}"
|
|
126
|
+
draw.rectangle((12, 12, min(image.width - 12, 260), 52), fill=(255, 255, 255))
|
|
127
|
+
draw.text((22, 22), label, fill=(0, 0, 0))
|
|
128
|
+
images.append(image)
|
|
129
|
+
|
|
130
|
+
if not images:
|
|
131
|
+
return ""
|
|
132
|
+
|
|
133
|
+
cols = min(3, len(images))
|
|
134
|
+
rows = int(math.ceil(len(images) / cols))
|
|
135
|
+
width, height = images[0].size
|
|
136
|
+
canvas = Image.new("RGB", (cols * width, rows * height), (255, 255, 255))
|
|
137
|
+
for index, image in enumerate(images):
|
|
138
|
+
canvas.paste(image, ((index % cols) * width, (index // cols) * height))
|
|
139
|
+
|
|
140
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
141
|
+
canvas.save(path)
|
|
142
|
+
return str(path)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def main() -> int:
|
|
146
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
147
|
+
parser.add_argument("package_or_scene", type=Path, help="MJCF package directory or scene.xml path")
|
|
148
|
+
parser.add_argument("--settle-seconds", type=float, default=2.0)
|
|
149
|
+
parser.add_argument("--seconds", type=float, default=6.0)
|
|
150
|
+
parser.add_argument("--actuator", action="append", type=parse_actuator, default=[], help="Control as NAME=VALUE")
|
|
151
|
+
parser.add_argument("--watch-joint", action="append", default=[], help="Joint name whose motion should be reported")
|
|
152
|
+
parser.add_argument("--assert-min-joint-delta", type=float, default=0.0)
|
|
153
|
+
parser.add_argument(
|
|
154
|
+
"--expect-drive-delta",
|
|
155
|
+
action="append",
|
|
156
|
+
type=parse_joint_range,
|
|
157
|
+
default=[],
|
|
158
|
+
help="Require signed post-settle joint delta as JOINT=MIN:MAX in MuJoCo qpos units",
|
|
159
|
+
)
|
|
160
|
+
parser.add_argument(
|
|
161
|
+
"--expect-drive-cycles",
|
|
162
|
+
action="append",
|
|
163
|
+
type=parse_joint_range,
|
|
164
|
+
default=[],
|
|
165
|
+
help="Require signed post-settle revolute joint travel as JOINT=MIN:MAX in cycles/turns",
|
|
166
|
+
)
|
|
167
|
+
parser.add_argument(
|
|
168
|
+
"--expect-final-qvel",
|
|
169
|
+
action="append",
|
|
170
|
+
type=parse_joint_range,
|
|
171
|
+
default=[],
|
|
172
|
+
help="Require final joint velocity as JOINT=MIN:MAX in MuJoCo qvel units",
|
|
173
|
+
)
|
|
174
|
+
parser.add_argument("--max-root-drop", type=float, default=0.02, help="Maximum allowed root Z drop in meters for free-root models")
|
|
175
|
+
parser.add_argument("--contact-top-n", type=int, default=12)
|
|
176
|
+
parser.add_argument("--render-dir", type=Path)
|
|
177
|
+
parser.add_argument("--fps", type=float, default=6.0)
|
|
178
|
+
parser.add_argument("--camera-lookat", nargs=3, type=float, default=[0.0, 0.0, 0.0])
|
|
179
|
+
parser.add_argument("--camera-distance", type=float, default=0.35)
|
|
180
|
+
parser.add_argument("--camera-azimuth", type=float, default=-45.0)
|
|
181
|
+
parser.add_argument("--camera-elevation", type=float, default=-20.0)
|
|
182
|
+
parser.add_argument(
|
|
183
|
+
"--camera-preview-grid",
|
|
184
|
+
action="store_true",
|
|
185
|
+
help="Write a labeled azimuth grid to render-dir/camera_preview_grid.png before choosing/reporting a view",
|
|
186
|
+
)
|
|
187
|
+
parser.add_argument(
|
|
188
|
+
"--camera-preview-azimuths",
|
|
189
|
+
nargs="+",
|
|
190
|
+
type=float,
|
|
191
|
+
default=[-90, 0, 45, 90, 135, 180],
|
|
192
|
+
help="Azimuths in degrees to include in --camera-preview-grid",
|
|
193
|
+
)
|
|
194
|
+
args = parser.parse_args()
|
|
195
|
+
if args.camera_preview_grid and not args.render_dir:
|
|
196
|
+
parser.error("--camera-preview-grid requires --render-dir")
|
|
197
|
+
|
|
198
|
+
import mujoco
|
|
199
|
+
|
|
200
|
+
scene_path = resolve_scene(args.package_or_scene)
|
|
201
|
+
model = mujoco.MjModel.from_xml_path(str(scene_path))
|
|
202
|
+
data = mujoco.MjData(model)
|
|
203
|
+
|
|
204
|
+
actuator_ids: list[tuple[str, int, float]] = []
|
|
205
|
+
for name, ctrl in args.actuator:
|
|
206
|
+
actuator_id = mujoco.mj_name2id(model, mujoco.mjtObj.mjOBJ_ACTUATOR, name)
|
|
207
|
+
if actuator_id < 0:
|
|
208
|
+
raise SystemExit(f"Unknown actuator {name!r}")
|
|
209
|
+
actuator_ids.append((name, actuator_id, ctrl))
|
|
210
|
+
|
|
211
|
+
watch_names = list(dict.fromkeys(
|
|
212
|
+
args.watch_joint
|
|
213
|
+
+ [name for name, _min_value, _max_value in args.expect_drive_delta]
|
|
214
|
+
+ [name for name, _min_value, _max_value in args.expect_drive_cycles]
|
|
215
|
+
+ [name for name, _min_value, _max_value in args.expect_final_qvel]
|
|
216
|
+
))
|
|
217
|
+
watch_joints: list[tuple[str, int, int, int]] = []
|
|
218
|
+
for name in watch_names:
|
|
219
|
+
joint_id = mujoco.mj_name2id(model, mujoco.mjtObj.mjOBJ_JOINT, name)
|
|
220
|
+
if joint_id < 0:
|
|
221
|
+
raise SystemExit(f"Unknown joint {name!r}")
|
|
222
|
+
watch_joints.append((name, joint_id, int(model.jnt_qposadr[joint_id]), int(model.jnt_dofadr[joint_id])))
|
|
223
|
+
|
|
224
|
+
free_joint_id = first_freejoint(mujoco, model)
|
|
225
|
+
free_qadr = int(model.jnt_qposadr[free_joint_id]) if free_joint_id is not None else None
|
|
226
|
+
|
|
227
|
+
renderer = None
|
|
228
|
+
camera = None
|
|
229
|
+
if args.render_dir:
|
|
230
|
+
renderer = mujoco.Renderer(model, height=900, width=1200)
|
|
231
|
+
camera = make_camera(mujoco, args.camera_lookat, args.camera_distance, args.camera_azimuth, args.camera_elevation)
|
|
232
|
+
|
|
233
|
+
def snapshot(label: str) -> dict[str, object]:
|
|
234
|
+
root_pos = None
|
|
235
|
+
if free_qadr is not None:
|
|
236
|
+
root_pos = [float(x) for x in data.qpos[free_qadr : free_qadr + 3]]
|
|
237
|
+
return {
|
|
238
|
+
"label": label,
|
|
239
|
+
"time": float(data.time),
|
|
240
|
+
"root_pos": root_pos,
|
|
241
|
+
"watched": {
|
|
242
|
+
name: {"qpos": float(data.qpos[qadr]), "qvel": float(data.qvel[dadr])}
|
|
243
|
+
for name, _joint_id, qadr, dadr in watch_joints
|
|
244
|
+
},
|
|
245
|
+
"ncon": int(data.ncon),
|
|
246
|
+
"contacts": contact_counts(mujoco, model, data, args.contact_top_n),
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
mujoco.mj_forward(model, data)
|
|
250
|
+
initial = snapshot("initial")
|
|
251
|
+
initial_joint_qpos = {name: float(data.qpos[qadr]) for name, _joint_id, qadr, _dadr in watch_joints}
|
|
252
|
+
initial_root_z = float(data.qpos[free_qadr + 2]) if free_qadr is not None else None
|
|
253
|
+
if renderer and camera:
|
|
254
|
+
camera_preview_grid = None
|
|
255
|
+
if args.camera_preview_grid:
|
|
256
|
+
camera_preview_grid = render_camera_preview_grid(
|
|
257
|
+
mujoco,
|
|
258
|
+
renderer,
|
|
259
|
+
model,
|
|
260
|
+
data,
|
|
261
|
+
args,
|
|
262
|
+
args.render_dir / "camera_preview_grid.png",
|
|
263
|
+
)
|
|
264
|
+
render_frame(mujoco, renderer, model, data, camera, "initial", args.render_dir / "00_initial.png")
|
|
265
|
+
else:
|
|
266
|
+
camera_preview_grid = None
|
|
267
|
+
|
|
268
|
+
settle_steps = max(0, int(round(args.settle_seconds / model.opt.timestep)))
|
|
269
|
+
for _ in range(settle_steps):
|
|
270
|
+
mujoco.mj_step(model, data)
|
|
271
|
+
settled = snapshot("settled")
|
|
272
|
+
settled_joint_qpos = {name: float(data.qpos[qadr]) for name, _joint_id, qadr, _dadr in watch_joints}
|
|
273
|
+
if renderer and camera:
|
|
274
|
+
render_frame(mujoco, renderer, model, data, camera, "settled", args.render_dir / "01_settled.png")
|
|
275
|
+
|
|
276
|
+
total_steps = max(0, int(round(args.seconds / model.opt.timestep)))
|
|
277
|
+
frame_interval = max(1, int(round((1.0 / max(args.fps, 1e-9)) / model.opt.timestep)))
|
|
278
|
+
rendered = []
|
|
279
|
+
for step in range(total_steps):
|
|
280
|
+
for _name, actuator_id, ctrl in actuator_ids:
|
|
281
|
+
data.ctrl[actuator_id] = ctrl
|
|
282
|
+
mujoco.mj_step(model, data)
|
|
283
|
+
if renderer and camera and step % frame_interval == 0:
|
|
284
|
+
frame_path = args.render_dir / f"drive_{step:06d}.png"
|
|
285
|
+
render_frame(mujoco, renderer, model, data, camera, f"drive t={data.time:.2f}s", frame_path)
|
|
286
|
+
rendered.append(str(frame_path))
|
|
287
|
+
|
|
288
|
+
final = snapshot("final")
|
|
289
|
+
if renderer and camera:
|
|
290
|
+
render_frame(mujoco, renderer, model, data, camera, "final", args.render_dir / "99_final.png")
|
|
291
|
+
renderer.close()
|
|
292
|
+
|
|
293
|
+
joint_delta = {
|
|
294
|
+
name: float(data.qpos[qadr]) - initial_joint_qpos[name]
|
|
295
|
+
for name, _joint_id, qadr, _dadr in watch_joints
|
|
296
|
+
}
|
|
297
|
+
joint_drive_delta = {
|
|
298
|
+
name: float(data.qpos[qadr]) - settled_joint_qpos[name]
|
|
299
|
+
for name, _joint_id, qadr, _dadr in watch_joints
|
|
300
|
+
}
|
|
301
|
+
joint_cycles = {name: cycles_from_radians(value) for name, value in joint_delta.items()}
|
|
302
|
+
joint_drive_cycles = {name: cycles_from_radians(value) for name, value in joint_drive_delta.items()}
|
|
303
|
+
final_joint_qvel = {
|
|
304
|
+
name: float(data.qvel[dadr])
|
|
305
|
+
for name, _joint_id, _qadr, dadr in watch_joints
|
|
306
|
+
}
|
|
307
|
+
root_drop = None
|
|
308
|
+
if free_qadr is not None and initial_root_z is not None:
|
|
309
|
+
root_drop = initial_root_z - float(data.qpos[free_qadr + 2])
|
|
310
|
+
|
|
311
|
+
summary = {
|
|
312
|
+
"scene": str(scene_path),
|
|
313
|
+
"counts": {"nbody": int(model.nbody), "njnt": int(model.njnt), "nu": int(model.nu), "ngeom": int(model.ngeom)},
|
|
314
|
+
"free_joint": joint_name(mujoco, model, free_joint_id) if free_joint_id is not None else None,
|
|
315
|
+
"actuators": [{"name": name, "ctrl": ctrl} for name, _actuator_id, ctrl in actuator_ids],
|
|
316
|
+
"joint_delta": joint_delta,
|
|
317
|
+
"joint_drive_delta": joint_drive_delta,
|
|
318
|
+
"joint_cycles": joint_cycles,
|
|
319
|
+
"joint_drive_cycles": joint_drive_cycles,
|
|
320
|
+
"final_joint_qvel": final_joint_qvel,
|
|
321
|
+
"expectations": {
|
|
322
|
+
"drive_delta": [
|
|
323
|
+
{"joint": name, "min": min_value, "max": max_value}
|
|
324
|
+
for name, min_value, max_value in args.expect_drive_delta
|
|
325
|
+
],
|
|
326
|
+
"drive_cycles": [
|
|
327
|
+
{"joint": name, "min": min_value, "max": max_value}
|
|
328
|
+
for name, min_value, max_value in args.expect_drive_cycles
|
|
329
|
+
],
|
|
330
|
+
"final_qvel": [
|
|
331
|
+
{"joint": name, "min": min_value, "max": max_value}
|
|
332
|
+
for name, min_value, max_value in args.expect_final_qvel
|
|
333
|
+
],
|
|
334
|
+
},
|
|
335
|
+
"root_drop_m": root_drop,
|
|
336
|
+
"camera": {
|
|
337
|
+
"lookat": args.camera_lookat,
|
|
338
|
+
"distance": args.camera_distance,
|
|
339
|
+
"azimuth": args.camera_azimuth,
|
|
340
|
+
"elevation": args.camera_elevation,
|
|
341
|
+
"preview_grid": camera_preview_grid,
|
|
342
|
+
},
|
|
343
|
+
"snapshots": [initial, settled, final],
|
|
344
|
+
"render_dir": str(args.render_dir) if args.render_dir else None,
|
|
345
|
+
"rendered_frames": rendered[:5] + (["..."] if len(rendered) > 5 else []),
|
|
346
|
+
}
|
|
347
|
+
print(json.dumps(summary, indent=2))
|
|
348
|
+
|
|
349
|
+
failures = []
|
|
350
|
+
if root_drop is not None and root_drop > args.max_root_drop:
|
|
351
|
+
failures.append(f"root dropped {root_drop:.6f}m > {args.max_root_drop:.6f}m")
|
|
352
|
+
if args.assert_min_joint_delta > 0:
|
|
353
|
+
max_delta = max((abs(value) for value in joint_delta.values()), default=0.0)
|
|
354
|
+
if max_delta < args.assert_min_joint_delta:
|
|
355
|
+
failures.append(f"watched joints moved only {max_delta:.6f}; expected {args.assert_min_joint_delta:.6f}")
|
|
356
|
+
for name, min_value, max_value in args.expect_drive_delta:
|
|
357
|
+
value = joint_drive_delta[name]
|
|
358
|
+
if not min_value <= value <= max_value:
|
|
359
|
+
failures.append(
|
|
360
|
+
f"{name} drive delta {value:.6f} outside expected range [{min_value:.6f}, {max_value:.6f}]"
|
|
361
|
+
)
|
|
362
|
+
for name, min_value, max_value in args.expect_drive_cycles:
|
|
363
|
+
value = joint_drive_cycles[name]
|
|
364
|
+
if not min_value <= value <= max_value:
|
|
365
|
+
failures.append(
|
|
366
|
+
f"{name} drive cycles {value:.6f} outside expected range [{min_value:.6f}, {max_value:.6f}]"
|
|
367
|
+
)
|
|
368
|
+
for name, min_value, max_value in args.expect_final_qvel:
|
|
369
|
+
value = final_joint_qvel[name]
|
|
370
|
+
if not min_value <= value <= max_value:
|
|
371
|
+
failures.append(
|
|
372
|
+
f"{name} final qvel {value:.6f} outside expected range [{min_value:.6f}, {max_value:.6f}]"
|
|
373
|
+
)
|
|
374
|
+
if any(math.isnan(value) or math.isinf(value) for value in data.qpos):
|
|
375
|
+
failures.append("qpos contains NaN or Inf")
|
|
376
|
+
|
|
377
|
+
if failures:
|
|
378
|
+
for failure in failures:
|
|
379
|
+
print(f"FAIL: {failure}")
|
|
380
|
+
return 2
|
|
381
|
+
return 0
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
if __name__ == "__main__":
|
|
385
|
+
raise SystemExit(main())
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
<!-- Generated by scripts/build-forgecad-skill.mjs — do not edit. Edit agent-skill-library/forgecad-
|
|
1
|
+
<!-- Generated by scripts/build-forgecad-skill.mjs — do not edit. Edit agent-skill-library/forgecad-build-model/SKILL.md instead. -->
|
|
2
2
|
|
|
3
|
-
# forgecad-
|
|
3
|
+
# forgecad-build-model
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Build or edit a manufacture-realistic `.forge.js` model in a project, then validate it with run, render, inspect, and export evidence.
|
|
6
6
|
|
|
7
7
|
| Field | Value |
|
|
8
8
|
| --- | --- |
|
|
9
9
|
| Installed by | `forgecad skill install` |
|
|
10
|
-
| Source | `agent-skill-library/forgecad-
|
|
10
|
+
| Source | `agent-skill-library/forgecad-build-model/SKILL.md` |
|
|
11
11
|
|
|
12
12
|
---
|
|
13
13
|
|
|
14
|
-
##
|
|
14
|
+
## Build Model
|
|
15
15
|
|
|
16
16
|
Create new ForgeCAD models in the user's active ForgeCAD project.
|
|
17
17
|
|
|
@@ -86,7 +86,17 @@ For any mechanism (linkage, hinge, slider, suspension, gripper, drawer), the rig
|
|
|
86
86
|
|
|
87
87
|
A mechanical script is not done when it merely looks assembled. Every visible piece needs a physical reason to be where it is: fused material, contact faces, a screw stack, a pin in a bore, a tab in a slot, a gasket on a land, a bearing in a seat, a cable in a channel, or a named intentional ghost.
|
|
88
88
|
|
|
89
|
-
-
|
|
89
|
+
For multi-part assemblies, the component model is mandatory:
|
|
90
|
+
|
|
91
|
+
- Parts build at origin in their own local coordinates. They do not know final assembly-space offsets, sibling dimensions, or world placement.
|
|
92
|
+
- A part's public interface is `shape` plus connectors and metadata, e.g. `return { shape, boltPattern, pinionZ }`. Declare mating faces with `.withConnectors({})`; axes point outward, with prismatic slide axes as the explicit exception.
|
|
93
|
+
- The parent assembly chooses the root and positions every structural part through connectors, `connect()`, `match()`, or `matchTo()`. Final `translate()` calls are not assembly contracts.
|
|
94
|
+
- Data flows down through `require('./part.forge.js', params)` overrides and up through returned metadata. Siblings never import each other; the parent routes shared decisions and measured outputs.
|
|
95
|
+
- Default to one file for a project-specific assembly. Split only for cross-project reuse, independent subassemblies, or when a file grows past roughly 300 lines. Never create `shared-dims.js` just to coordinate siblings.
|
|
96
|
+
|
|
97
|
+
Reject these shortcuts on sight: sibling `require()`, assembly-space coordinates inside a part, `translate()` used to position a structural assembly member, `console.log` + `if` validation instead of `verify.*`, and bare `connector.neutral()` outside a reusable component library with compatibility checks.
|
|
98
|
+
|
|
99
|
+
- Bespoke fixed assemblies: build each part in local coordinates, pick one root, place every touching part with `matchTo()`, verify each mate with `verify.connectorDistance`.
|
|
90
100
|
- Manual joint frames (`addFixed`/`addRevolute`/`addPrismatic` with a hand-built `frame:`) are scaffolding, not contracts. Before delivery, convert mating interfaces to connectors with `connect()`/`match()`, or prove the manual joint with `forgecad debug assembly --fail-on warning` and documented geometry.
|
|
91
101
|
- A named part must not contain unintentional disconnected bodies: boolean-join manufactured features, model fasteners/seals as separate named parts, or add the receiving holes/lands that explain the separation.
|
|
92
102
|
- Screws are not decoration: clearance/counterbore in the cover, receiving boss or through stack in the parent, material around both, axes aligned from one shared bolt pattern.
|
|
@@ -101,7 +111,7 @@ Treat `fillet()`/`chamfer()` as experimental (Manifold can be incorrect, OCCT sl
|
|
|
101
111
|
|
|
102
112
|
### Imported Parts (User-Supplied 3D Files)
|
|
103
113
|
|
|
104
|
-
When the user supplies mesh or CAD files to design around (a motor, an off-the-shelf housing, a scanned part), the import IS a component of the assembly — keep it, don't rebuild it parametrically (rebuilding is `forgecad-
|
|
114
|
+
When the user supplies mesh or CAD files to design around (a motor, an off-the-shelf housing, a scanned part), the import IS a component of the assembly — keep it, don't rebuild it parametrically (rebuilding is `forgecad-reconstruct-cad-file`, a different request).
|
|
105
115
|
|
|
106
116
|
- Wrap each import in its own part file: `Import.mesh()` for STL/OBJ/3MF, `Import.step()` for STEP (OCCT backend), normalize scale and orientation, recenter to a sane local origin, then treat it exactly like a purchased part — connectors at its real mating features, positioned by the assembly via `matchTo()`.
|
|
107
117
|
- Never trust units. Verify against a known dimension before mating anything: bbox via `forgecad run --details`, or `inspect section --ray` across a bore or face pair. For 3MF, account for every build item printed by `forgecad run` before flattening.
|
|
@@ -153,7 +163,7 @@ A manufacture-realistic model must yield a package a shop can consume, not just
|
|
|
153
163
|
|
|
154
164
|
### Render and Inspect Cadence
|
|
155
165
|
|
|
156
|
-
**You are building blind unless you render.** `forgecad run` passing only means the code didn't crash — it cannot tell you a hole is misplaced, a rib pokes through a cover, or a part doesn't fit. Render from angles chosen for the model's actual geometry and read every PNG. For command syntax, evidence selection, and manifest reading, use the `forgecad-
|
|
166
|
+
**You are building blind unless you render.** `forgecad run` passing only means the code didn't crash — it cannot tell you a hole is misplaced, a rib pokes through a cover, or a part doesn't fit. Render from angles chosen for the model's actual geometry and read every PNG. For command syntax, evidence selection, and manifest reading, use the `forgecad-inspect-model` skill and the CLI docs — this skill fixes only the cadence and the gates.
|
|
157
167
|
|
|
158
168
|
Render after every feature addition, boolean cut, symmetric copy placement, and the last feature. Inspect after adding hidden geometry a surface render cannot prove, after adding or moving mating parts, ghosts, connectors, thin walls, or screw holes, and before delivery with thresholds set for the material/process.
|
|
159
169
|
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
<!-- Generated by scripts/build-forgecad-skill.mjs — do not edit. Edit agent-skill-library/forgecad-design-spec/SKILL.md instead. -->
|
|
2
|
+
|
|
3
|
+
# forgecad-design-spec
|
|
4
|
+
|
|
5
|
+
Create a ForgeCAD design brief, HLD, or LLD before coding by walking through use, assembly, interfaces, decisions, and verification.
|
|
6
|
+
|
|
7
|
+
| Field | Value |
|
|
8
|
+
| --- | --- |
|
|
9
|
+
| Installed by | `forgecad skill install` |
|
|
10
|
+
| Source | `agent-skill-library/forgecad-design-spec/SKILL.md` |
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Design Spec
|
|
15
|
+
|
|
16
|
+
The design document — a git-committed, diff-reviewed markdown file — is the source of truth. Not the code, not the chat, not your head. You iterate it by commit-and-review, and the `git diff` is the review artifact.
|
|
17
|
+
|
|
18
|
+
**Validate the design by mentally operating the thing, step by step.** Walk it as someone assembles, uses, or moves it. The step with no answer — *"how does the servo get inside the housing?"* — is the real design gap. A spec that reads complete on the page can still hide a hole that only surfaces when you try to put it together in your head. State each gap falsifiably: not "tolerances might be tight" but "the 12mm arm cantilevers under gripping load, may flex >0.5mm."
|
|
19
|
+
|
|
20
|
+
**Every number has a reason; the narrative comes before the numbers.** Describe the object as if over the phone, then derive each value and show its math: `wallThickness = 2.4mm = 6 × 0.4mm nozzle`. The design is **implementation-blind** — shaped by the object, never by what the ForgeCAD API makes easy. **Manufacturing process is one of those reasons** — a design decision you weigh, never a default you inherit (never assume FDM/printing).
|
|
21
|
+
|
|
22
|
+
**A vague request is a set of decisions you make honestly, not information to extract.** No placeholders ("appropriate motor"); choose a defensible value, show why, continue. The Decisions table fills only after user review, so the loop stays in the document.
|
|
23
|
+
|
|
24
|
+
### Altitude — three phases, one document trail
|
|
25
|
+
|
|
26
|
+
| Phase | When | Output |
|
|
27
|
+
|-------|------|--------|
|
|
28
|
+
| Intake | request is fuzzy / process unspecified | engineering brief + master prompt |
|
|
29
|
+
| HLD | design is wrong in *approach*, alternatives exist | `<name>-hld.md` |
|
|
30
|
+
| LLD | decisions locked, or a simple single-body part | `<name>-lld.md` |
|
|
31
|
+
|
|
32
|
+
The HLD carries only decision-driving dimensions and genuinely-different alternatives; the LLD carries enough that someone builds from it alone. Speccing every tolerance in an HLD, or revisiting locked decisions in an LLD, is an altitude error — back up. Simple parts skip straight from HLD to code, or from a request to an LLD.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
### Phase 1 — Intake (fuzzy request → concrete brief)
|
|
37
|
+
|
|
38
|
+
Use when the user wants something physically real but the ask is vague ("make me a robot gripper", "make it production ready", "pick sensible numbers"). This phase owns intake; once the brief is concrete, continue to HLD or hand off to the `forgecad` skill.
|
|
39
|
+
|
|
40
|
+
**Manufacturing is a design decision, not a default.** Derive the process stack from artifact family, load path, scale, safety expectations, material, production intent, and operating story — never assume printing/plastic. If the user names a process, honor it but warn when it is unsafe or dishonest for the duty. Family→process anchors live in `references/default-profiles.md`.
|
|
41
|
+
|
|
42
|
+
**Default posture: manufacture-realistic prototype** — real materials, purchased-part boundaries, assembly logic, validation; no claims of production tooling or certification. Other postures only when justified: `production-realistic`, `printable`, `visual-CAD`, or a specific process posture (`sheet-metal`, `CNC-machined`, `laser-cut`, `welded-tube`, `injection-molded`, `cast`, `hybrid purchased-hardware`). Pick the posture honest for the artifact, not the easiest CAD surface.
|
|
43
|
+
|
|
44
|
+
**Family-scoped numbers.** Every starter assumption is scoped to one artifact family; never reuse numbers across families.
|
|
45
|
+
|
|
46
|
+
Workflow:
|
|
47
|
+
1. **Normalize the ask** into plain mechanism language ("6 DOF gripper" → standalone gripper, wrist+gripper, or arm+gripper).
|
|
48
|
+
2. **Build a specific operating story** — invented (non-famous) org, named program, prototype revision, review moment, mission pressure (pilot gate, demo date, investor milestone), and the generic failure mode to avoid. Prefer bold high-agency stories over modest lab exercises. Never assert the user works for a named real company; use real products only as public comparison anchors; never clone proprietary designs.
|
|
49
|
+
3. **Classify the artifact family** (`references/default-profiles.md`); use the no-family-fits escape rather than forcing one. Rideables route to human-vehicles, never chassis.
|
|
50
|
+
4. **Choose the process posture** per the taxonomy above.
|
|
51
|
+
5. **Pick qualitative levers** — duty (`light`/`general`/`sturdy`), scale (`compact`/`medium`/`large`), cost (`cheapest`/`balanced`/`performance-first`) — and translate to family-scoped starter assumptions.
|
|
52
|
+
6. **Close only critical gaps** — at most 3 grouped questions, always choice menus, never raw engineering inputs unless the architecture truly depends on them. Good: "light desk demo, useful hobby tool, or sturdier bench mechanism?" Bad: "What payload mass?"
|
|
53
|
+
7. **Write the engineering brief**: artifact + family + normalized interpretation; operating story + production reason + test setting + failure mode to avoid; output posture; intended loads, size envelope, motion/DOF; process stack + material defaults; purchased-part (BOM) boundary; validation standard; variant policy (versions are selectable params, one rendered at a time); file organization (`main.forge.js` entry for multi-file); explicit uncertainty policy.
|
|
54
|
+
8. **Emit one master prompt** — fill `references/master-prompt.md`; return the finished prompt, not notes about it. It must demand exactly `BUILD-READY` or `BEST-EFFORT BUILD CANDIDATE` (human-bearing furniture and rideables usually end the latter).
|
|
55
|
+
|
|
56
|
+
Defaults if the user stays vague: `general-duty` / `medium` / `balanced`, invent the operating story, use family starter assumptions.
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
### Phase 2 — High-Level Design (HLD)
|
|
61
|
+
|
|
62
|
+
Aligns user and agent on *what* to build before *how*. Brevity is a readability tool, not a metric — include whatever evidence, diagrams, and dimensions a good decision needs. Write the sections top to bottom; the order is the workflow.
|
|
63
|
+
|
|
64
|
+
```markdown
|
|
65
|
+
# [Name] — High-Level Design
|
|
66
|
+
|
|
67
|
+
## Problem
|
|
68
|
+
What must this do? Hard requirements (grip 40-90mm objects, fit a 60mm
|
|
69
|
+
housing, use purchased bearings). State the problem without implying a
|
|
70
|
+
solution. Unspecified process choice is an open design dimension.
|
|
71
|
+
|
|
72
|
+
## Approach
|
|
73
|
+
How it works conceptually. ASCII diagram of key elements and their
|
|
74
|
+
spatial relationships — diagram labels stay in this markdown, never
|
|
75
|
+
carried into CAD geometry unless the real artifact needs markings.
|
|
76
|
+
|
|
77
|
+
## Key Interfaces
|
|
78
|
+
Every point where this touches another part or the outside world:
|
|
79
|
+
mating surfaces, shared dimensions, coordination points. These are the
|
|
80
|
+
contracts that constrain the design.
|
|
81
|
+
|
|
82
|
+
## Dictionary
|
|
83
|
+
| Term | What it is |
|
|
84
|
+
Define every domain term in plain words, with dimensions where relevant.
|
|
85
|
+
Write for a developer without a mechanical-engineering background.
|
|
86
|
+
|
|
87
|
+
## Alternatives
|
|
88
|
+
| Option | Description | Tradeoff |
|
|
89
|
+
2-3 genuinely different strategies, not minor variations. Mark one
|
|
90
|
+
recommended and say why. If there is honestly one approach, say so.
|
|
91
|
+
|
|
92
|
+
## Usage Guide
|
|
93
|
+
Work backwards from how someone uses, assembles, or operates the thing,
|
|
94
|
+
step by step. If a step doesn't make sense ("how does the servo get
|
|
95
|
+
inside?"), flag it inline with ⚠️ and promote it to Concerns.
|
|
96
|
+
|
|
97
|
+
## Concerns
|
|
98
|
+
1. Numbered, falsifiably specific — a reviewer must be able to say "real
|
|
99
|
+
problem" or "fine, because…".
|
|
100
|
+
|
|
101
|
+
## Decisions
|
|
102
|
+
| # | Decision | Rationale |
|
|
103
|
+
Filled ONLY after user review — never pre-decide. Each row resolves a
|
|
104
|
+
concern or alternative.
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Rules: if you're speccing every part, formula, and tolerance, you're writing an LLD — back up. If you can't draw it, you don't understand it yet.
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
### Phase 3 — Low-Level Design (LLD)
|
|
112
|
+
|
|
113
|
+
Implements the HLD's locked Decisions table; it never revisits those decisions. Simple single-body parts skip the HLD and start here. Complex assemblies split into a numbered directory: overview, global constraints, per-component files, assembly, verification.
|
|
114
|
+
|
|
115
|
+
An LLD is **narrative-first** (reads like describing the object over the phone), **authoritative** (the single source code implements), **implementation-blind**, and shows **every number's rationale**.
|
|
116
|
+
|
|
117
|
+
Required structure:
|
|
118
|
+
1. **Narrative** — what it is, how it behaves and interacts, why it exists. Concrete comparisons ("about the size of a deck of cards"); no ungrounded vague terms.
|
|
119
|
+
2. **Technical** — typed parameter table (length / angle / count / boolean / choice / ratio / clearance — design-document vocabulary, not the runtime `Param.*` API), always with units (mm, degrees default) and a rationale for every default and range; derived dimensions shown as math; geometry and constraints, each constraint with a rationale.
|
|
120
|
+
3. **Verification** — mandatory checklist: dimensional, functional, printability/process checks.
|
|
121
|
+
|
|
122
|
+
Don'ts: never open with a parameter list (story before numbers), never leave a constraint implicit, never skip verification. Completeness gate before presenting: can someone build from this alone? Does it implement every HLD decision? Is every constraint explicit with a rationale?
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
### Review via git
|
|
127
|
+
|
|
128
|
+
HLDs and LLDs iterate through git, not conversation:
|
|
129
|
+
- **Commit every version.** No drafts floating in chat. After writing, commit and tell the user it's ready for review.
|
|
130
|
+
- **Feedback arrives as file edits (inline comments, strikethroughs) or chat — check both.** Read `git diff`: the diff is the review artifact.
|
|
131
|
+
- **Update, commit, repeat** until the Decisions table is filled and the user says "go."
|
|
132
|
+
|
|
133
|
+
### Pipeline
|
|
134
|
+
|
|
135
|
+
| Stage | This skill's phase | Output | Next |
|
|
136
|
+
|-------|--------------------|--------|------|
|
|
137
|
+
| Explore a fuzzy ask | Intake | engineering brief + master prompt | HLD |
|
|
138
|
+
| Decide *what* to build | HLD | `*-hld.md` (Decisions filled) | LLD |
|
|
139
|
+
| Detail *how* to build | LLD | `*-lld.md` | `forgecad-build-model` + `forgecad` → `.forge.js` |
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
## Bundled Files
|
|
143
|
+
|
|
144
|
+
- `references/default-profiles.md`
|
|
145
|
+
- `references/master-prompt.md`
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
<!-- Generated by scripts/build-forgecad-skill.mjs — do not edit. Edit agent-skill-library/forgecad-model
|
|
1
|
+
<!-- Generated by scripts/build-forgecad-skill.mjs — do not edit. Edit agent-skill-library/forgecad-grade-model/SKILL.md instead. -->
|
|
2
2
|
|
|
3
|
-
# forgecad-model
|
|
3
|
+
# forgecad-grade-model
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Grade a ForgeCAD or CAD-as-code model against a requirement, brief, prompt, reference, or acceptance criteria with evidence and a 0-10 score.
|
|
6
6
|
|
|
7
7
|
| Field | Value |
|
|
8
8
|
| --- | --- |
|
|
9
9
|
| Installed by | `forgecad skill install` |
|
|
10
|
-
| Source | `agent-skill-library/forgecad-model
|
|
10
|
+
| Source | `agent-skill-library/forgecad-grade-model/SKILL.md` |
|
|
11
11
|
|
|
12
12
|
---
|
|
13
13
|
|
|
14
|
-
##
|
|
14
|
+
## Grade Model
|
|
15
15
|
|
|
16
16
|
Grade the delivered model against the requirement, not against what could be fixed later. Never edit the model unless the user explicitly requests repairs — then record the baseline grade first, change, and re-grade.
|
|
17
17
|
|
|
@@ -21,7 +21,7 @@ Grade the delivered model against the requirement, not against what could be fix
|
|
|
21
21
|
2. **Run the model**: `forgecad run <model>.forge.js` (in the ForgeCAD repo use the local build, `node dist-cli/forgecad.js run ...`). If it fails to execute, stop and apply the caps.
|
|
22
22
|
3. **Render** at least `iso`, `front`, `right`, `top` to a scratch dir; add views (back, bottom, close-up, section) when the model is asymmetric, hollow, mechanical, or likely to hide mistakes.
|
|
23
23
|
4. **Open and look at every PNG** — never score from command output alone. Check silhouette, proportions, required features, part boundaries, interfaces, and whether the model reads as the requested artifact from more than one angle.
|
|
24
|
-
5. **Inspect** whenever hidden internals, fit, wall thickness, or assembly behavior are central to the brief — grading without inspecting them caps the score. Delegate evidence choice, commands, and manifest reading to the `forgecad-
|
|
24
|
+
5. **Inspect** whenever hidden internals, fit, wall thickness, or assembly behavior are central to the brief — grading without inspecting them caps the score. Delegate evidence choice, commands, and manifest reading to the `forgecad-inspect-model` skill. Findings (unexpected collisions, thin regions, floating bodies, wrong component counts) are evidence, not warnings to wave away.
|
|
25
25
|
6. **Score**: fill the rubric, apply caps, give a final 0-10 in whole or `.5` increments. Unknowns count against the score.
|
|
26
26
|
|
|
27
27
|
### Rubric
|
|
@@ -47,6 +47,7 @@ Maximum scores, applied after the rubric:
|
|
|
47
47
|
- A must-have requirement is absent: max `6`.
|
|
48
48
|
- Visually recognizable but physically impossible for the requested use: max `6`.
|
|
49
49
|
- Internals, fit, walls, or assembly central to the brief but uninspected: max `7`.
|
|
50
|
+
- Multi-part assembly violates the ForgeCAD component model — sibling imports, assembly-space coordinates inside parts, structural `translate()` placement, missing connector mates, or parent/child data flow confusion: max `7`; max `6` when the violation makes the assembly brittle or mechanically wrong.
|
|
50
51
|
- Inspection finds unexpected collisions, floating bodies, critical thin walls, or wrong connectivity: max `6`; max `5` when the defect invalidates the main function.
|
|
51
52
|
- Delivered as a finished product/prototype but presented with default flat lighting (no `scene()` rig), a generically colorful or material-false palette, or teaching-diagram styling: max `8`. Does not apply when the brief asks for a blockout or bare technical study.
|
|
52
53
|
- Any score relying on an assumption the evidence cannot verify: mark it `Unknown`, never score above `8`.
|
|
@@ -73,6 +74,7 @@ Next fixes: the 2-5 highest-leverage improvements.
|
|
|
73
74
|
- Grade the default returned model unless the user names a parameter set or variant.
|
|
74
75
|
- No points for comments, labels, or intentions absent from the geometry.
|
|
75
76
|
- Decorative screws, floating labels, and teaching-diagram callouts are not real mechanical interfaces.
|
|
77
|
+
- For multi-part assemblies, require the component model: parts build locally at origin, expose connectors/metadata, the parent positions them, and inter-part data flows through parent props and returned metadata.
|
|
76
78
|
- Cite which render or inspection finding drove the grade.
|
|
77
79
|
- When comparing models, use identical checklist, cameras, inspection evidence, and caps for all.
|
|
78
80
|
|