replicator-workshop 0.1.0__py3-none-any.whl

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 (118) hide show
  1. replicator/__init__.py +6 -0
  2. replicator/app.py +204 -0
  3. replicator/config.py +48 -0
  4. replicator/core/__init__.py +0 -0
  5. replicator/core/assembly.py +117 -0
  6. replicator/core/blender_link.py +161 -0
  7. replicator/core/critique.py +594 -0
  8. replicator/core/drawing.py +389 -0
  9. replicator/core/dxf.py +120 -0
  10. replicator/core/evaluate.py +439 -0
  11. replicator/core/explain.py +139 -0
  12. replicator/core/export.py +96 -0
  13. replicator/core/fit.py +170 -0
  14. replicator/core/importers.py +185 -0
  15. replicator/core/materials.py +104 -0
  16. replicator/core/ops_advanced.py +496 -0
  17. replicator/core/ops_engineering.py +223 -0
  18. replicator/core/physics.py +147 -0
  19. replicator/core/printers.py +100 -0
  20. replicator/core/program.py +298 -0
  21. replicator/core/render.py +145 -0
  22. replicator/core/reverse.py +350 -0
  23. replicator/core/robot.py +153 -0
  24. replicator/core/step.py +245 -0
  25. replicator/fixtures/gaming_pc_liquid.json +2259 -0
  26. replicator/fixtures/gas_generator_rocket.json +876 -0
  27. replicator/fixtures/gas_generator_rocket_aero.json +861 -0
  28. replicator/fixtures/house_two_bed.json +979 -0
  29. replicator/fixtures/quadcopter_drone.json +687 -0
  30. replicator/fixtures/raspberry_pi_5.json +884 -0
  31. replicator/fixtures/rocket_engine.json +652 -0
  32. replicator/fixtures/turbofan.json +931 -0
  33. replicator/fixtures/vector_engine.json +314 -0
  34. replicator/gpu.py +81 -0
  35. replicator/image3d/__init__.py +0 -0
  36. replicator/image3d/comfy.py +181 -0
  37. replicator/image3d/pipeline.py +208 -0
  38. replicator/image3d/sheet.py +154 -0
  39. replicator/knowledge/__init__.py +61 -0
  40. replicator/knowledge/car_wheel_corner.md +21 -0
  41. replicator/knowledge/desk_lamp.md +21 -0
  42. replicator/knowledge/desktop_pc.md +20 -0
  43. replicator/knowledge/electronics_board.md +21 -0
  44. replicator/knowledge/exoskeleton.md +21 -0
  45. replicator/knowledge/house.md +22 -0
  46. replicator/knowledge/light_aircraft.md +22 -0
  47. replicator/knowledge/multirotor_drone.md +25 -0
  48. replicator/knowledge/print_replica.md +13 -0
  49. replicator/knowledge/rocket_engine.md +27 -0
  50. replicator/knowledge/turbofan.md +23 -0
  51. replicator/llm/__init__.py +0 -0
  52. replicator/llm/client.py +424 -0
  53. replicator/llm/prompts/blueprint.md +28 -0
  54. replicator/llm/prompts/edit.md +15 -0
  55. replicator/llm/prompts/explain.md +37 -0
  56. replicator/llm/prompts/name_parts.md +13 -0
  57. replicator/llm/prompts/program.md +72 -0
  58. replicator/llm/prompts/research_queries.md +8 -0
  59. replicator/mcp_server.py +307 -0
  60. replicator/qml/Main.qml +874 -0
  61. replicator/qml/Replicator/UI/Chip.qml +17 -0
  62. replicator/qml/Replicator/UI/DockHeader.qml +27 -0
  63. replicator/qml/Replicator/UI/Icon.qml +118 -0
  64. replicator/qml/Replicator/UI/IconButton.qml +31 -0
  65. replicator/qml/Replicator/UI/Kbd.qml +18 -0
  66. replicator/qml/Replicator/UI/NumField.qml +69 -0
  67. replicator/qml/Replicator/UI/Pill.qml +28 -0
  68. replicator/qml/Replicator/UI/RCombo.qml +51 -0
  69. replicator/qml/Replicator/UI/RMenu.qml +42 -0
  70. replicator/qml/Replicator/UI/RSlider.qml +23 -0
  71. replicator/qml/Replicator/UI/Segmented.qml +63 -0
  72. replicator/qml/Replicator/UI/Swatch.qml +47 -0
  73. replicator/qml/Replicator/UI/Theme.qml +149 -0
  74. replicator/qml/Replicator/UI/qmldir +14 -0
  75. replicator/qml/panels/AgentPrompt.qml +53 -0
  76. replicator/qml/panels/AttributeManager.qml +171 -0
  77. replicator/qml/panels/Commander.qml +136 -0
  78. replicator/qml/panels/HolodeckPanel.qml +117 -0
  79. replicator/qml/panels/IssuesCard.qml +78 -0
  80. replicator/qml/panels/LedgerPanel.qml +110 -0
  81. replicator/qml/panels/MaterialShelf.qml +97 -0
  82. replicator/qml/panels/ObjectManager.qml +107 -0
  83. replicator/qml/panels/Preferences.qml +211 -0
  84. replicator/qml/panels/Presenter.qml +316 -0
  85. replicator/qml/panels/StatusBar.qml +77 -0
  86. replicator/qml/panels/Timeline.qml +149 -0
  87. replicator/qml/panels/Welcome.qml +126 -0
  88. replicator/qml/viewport/Callouts.qml +87 -0
  89. replicator/qml/viewport/EdgeMaterial.qml +16 -0
  90. replicator/qml/viewport/GridMaterial.qml +16 -0
  91. replicator/qml/viewport/HoloMaterial.qml +23 -0
  92. replicator/qml/viewport/NavGizmo.qml +72 -0
  93. replicator/qml/viewport/ReferenceMaterial.qml +17 -0
  94. replicator/qml/viewport/Viewport.qml +583 -0
  95. replicator/qt/__init__.py +0 -0
  96. replicator/qt/bridge.py +1427 -0
  97. replicator/qt/drawing_sheet.py +33 -0
  98. replicator/qt/envmap.py +40 -0
  99. replicator/qt/library.py +68 -0
  100. replicator/qt/mesh_geometry.py +167 -0
  101. replicator/qt/svg.py +41 -0
  102. replicator/research/__init__.py +0 -0
  103. replicator/research/lane.py +281 -0
  104. replicator/shaders/edge.frag +9 -0
  105. replicator/shaders/edge.vert +7 -0
  106. replicator/shaders/grid.frag +52 -0
  107. replicator/shaders/grid.vert +6 -0
  108. replicator/shaders/holo.frag +41 -0
  109. replicator/shaders/reference.frag +15 -0
  110. replicator/shaders/reference.vert +6 -0
  111. replicator/voice.py +120 -0
  112. replicator_workshop-0.1.0.dist-info/METADATA +410 -0
  113. replicator_workshop-0.1.0.dist-info/RECORD +118 -0
  114. replicator_workshop-0.1.0.dist-info/WHEEL +5 -0
  115. replicator_workshop-0.1.0.dist-info/entry_points.txt +3 -0
  116. replicator_workshop-0.1.0.dist-info/licenses/LICENSE +21 -0
  117. replicator_workshop-0.1.0.dist-info/licenses/vendor/mcp-for-blender/LICENSE +21 -0
  118. replicator_workshop-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,52 @@
1
+ // Workshop floor: an adaptive decimal grid. `span` is the camera distance; the cell size follows it in powers of
2
+ // ten (10 mm tiles up close, 100 mm at a metre or two, 1 m for a building), and the finest level cross-fades out
3
+ // as you pull back, so the line count on screen stays about the same at every zoom. The floor also fades with
4
+ // distance and at grazing angles, so it stays a quiet reference under the build and never shimmers at the horizon.
5
+ // Uniforms from GridMaterial.qml: lineColor, majorColor, blueprint, fade, span.
6
+ VARYING vec3 wpos;
7
+
8
+ float gridLine(vec2 p, float cell, float width, out float density)
9
+ {
10
+ vec2 c = p / cell;
11
+ vec2 d = fwidth(c);
12
+ vec2 g = abs(fract(c - 0.5) - 0.5) / (d * width);
13
+ density = max(d.x, d.y);
14
+ return 1.0 - min(min(g.x, g.y), 1.0);
15
+ }
16
+
17
+ void MAIN()
18
+ {
19
+ vec2 p = wpos.xz;
20
+ float lg = log(max(span, 1.0) / 14.0) / log(10.0);
21
+ float cell = pow(10.0, floor(lg));
22
+ float t = fract(lg); // 0 = this level just appeared, 1 = about to hand over
23
+ float d1, d2, d3;
24
+ float minor = gridLine(p, cell, 1.0, d1) * (1.0 - smoothstep(0.35, 1.0, t));
25
+ float major = gridLine(p, cell * 10.0, 1.1, d2);
26
+ float section = gridLine(p, cell * 100.0, 1.4, d3);
27
+ minor *= 1.0 - smoothstep(0.10, 0.34, d1);
28
+ major *= 1.0 - smoothstep(0.12, 0.42, d2);
29
+ section *= 1.0 - smoothstep(0.20, 0.60, d3);
30
+
31
+ // axis lines: X red, Z blue
32
+ float ax = 1.0 - min(abs(p.y) / fwidth(p.y) / 1.4, 1.0);
33
+ float az = 1.0 - min(abs(p.x) / fwidth(p.x) / 1.4, 1.0);
34
+
35
+ vec3 toCam = CAMERA_POSITION - wpos;
36
+ float dist = length(toCam);
37
+ float f = 1.0 - smoothstep(fade * 0.18, fade * 0.85, dist);
38
+ float graze = smoothstep(0.02, 0.22, abs(toCam.y) / max(dist, 0.001));
39
+ f *= graze;
40
+
41
+ float boost = 1.0 + blueprint * 0.35;
42
+ vec3 col = mix(lineColor.rgb, majorColor.rgb, clamp(major + section, 0.0, 1.0));
43
+ float a = minor * 0.10 * boost;
44
+ a = max(a, major * 0.22 * boost);
45
+ a = max(a, section * 0.36 * boost);
46
+ vec3 axc = mix(vec3(0.90, 0.28, 0.30), vec3(0.3, 0.9, 1.0), blueprint);
47
+ vec3 azc = mix(vec3(0.24, 0.52, 0.96), vec3(0.3, 0.9, 1.0), blueprint);
48
+ col = mix(col, axc, ax);
49
+ col = mix(col, azc, az * (1.0 - ax));
50
+ a = max(a, max(ax, az) * 0.62);
51
+ FRAGCOLOR = vec4(col, a * f);
52
+ }
@@ -0,0 +1,6 @@
1
+ VARYING vec3 wpos;
2
+ void MAIN()
3
+ {
4
+ wpos = (MODEL_MATRIX * vec4(VERTEX, 1.0)).xyz;
5
+ POSITION = MODELVIEWPROJECTION_MATRIX * vec4(VERTEX, 1.0);
6
+ }
@@ -0,0 +1,41 @@
1
+ // Replicator part material: PBR when built, a holo scan while it materializes, cyan line-work in blueprint mode.
2
+ // Uniforms come from HoloMaterial.qml properties: baseColor, emissiveColor, metal, rough, reveal, minY, maxY,
3
+ // blueprint, selected, alpha, time.
4
+ void MAIN()
5
+ {
6
+ vec3 wp = VAR_WORLD_POSITION;
7
+ float span = max(maxY - minY, 1.0);
8
+ float scan = mix(minY - span * 0.05, maxY + span * 0.05, reveal); // the build plane rises with reveal
9
+ if (wp.y > scan)
10
+ discard; // not built yet
11
+
12
+ vec3 cyan = vec3(0.25, 0.85, 1.0);
13
+ float below = scan - wp.y;
14
+ float edge = 1.0 - smoothstep(0.0, span * 0.02, below); // bright seam at the scan plane
15
+ float band = (1.0 - smoothstep(0.0, span * 0.22, below)) * step(reveal, 0.999); // freshly built zone
16
+
17
+ // voxel lattice in the fresh zone, world space so it reads as one field across parts
18
+ float cell = max(span / 28.0, 1.5);
19
+ vec3 g = abs(fract(wp / cell) - 0.5);
20
+ float lattice = smoothstep(0.42, 0.5, max(g.x, max(g.y, g.z)));
21
+
22
+ // blueprint: contour lines every 1/40 of the height plus a fresnel rim
23
+ vec3 n = normalize(VAR_WORLD_NORMAL);
24
+ float rim = pow(1.0 - clamp(abs(dot(n, normalize(VIEW_VECTOR))), 0.0, 1.0), 2.5);
25
+ float cy = abs(fract(wp.y / (span / 40.0)) - 0.5);
26
+ float contour = 1.0 - smoothstep(0.0, 0.06, cy);
27
+
28
+ vec3 navy = vec3(0.03, 0.10, 0.22);
29
+ vec3 albedo = mix(baseColor.rgb, tint.rgb * 0.85, tintAmount); // colour by component (Dissect)
30
+ albedo = mix(albedo, navy, blueprint);
31
+ albedo = mix(albedo, albedo * 0.25, band); // fresh zone is darker under the glow
32
+ BASE_COLOR = vec4(albedo, alpha); // < 1 only for glass and clear parts
33
+ METALNESS = mix(metal, 0.0, blueprint);
34
+ ROUGHNESS = mix(rough, 0.9, blueprint);
35
+ vec3 em = emissiveColor.rgb;
36
+ em += cyan * (edge * 3.0 + band * lattice * 1.6 + band * 0.15);
37
+ em += cyan * blueprint * (rim * 1.4 + contour * 0.35);
38
+ em += vec3(1.0, 0.62, 0.15) * selected * (0.25 + rim * 1.2); // amber when selected
39
+ em += tint.rgb * xray * (0.15 + rim * 1.5); // x-ray ghost for isolated views
40
+ EMISSIVE_COLOR = em;
41
+ }
@@ -0,0 +1,15 @@
1
+ // Reference image plane: a sheet of frosted glass. The paper white of the view is almost keyed out (enough is
2
+ // left that a dark figure still reads against a dark stage), the figure stays solid, a thin frame marks the sheet.
3
+ // Uniforms from ReferenceMaterial.qml: tex, strength, paper.
4
+ VARYING vec2 uv;
5
+ void MAIN()
6
+ {
7
+ vec4 c = texture(tex, uv);
8
+ float white = min(c.r, min(c.g, c.b));
9
+ float ink = 1.0 - smoothstep(0.80, 0.97, white);
10
+ vec2 e = min(uv, 1.0 - uv);
11
+ float frame = 1.0 - smoothstep(0.0, 0.005, min(e.x, e.y));
12
+ vec3 col = mix(c.rgb, vec3(0.45, 0.8, 1.0), frame);
13
+ float a = mix(paper, strength, ink);
14
+ FRAGCOLOR = vec4(col, max(a, frame * 0.45));
15
+ }
@@ -0,0 +1,6 @@
1
+ VARYING vec2 uv;
2
+ void MAIN()
3
+ {
4
+ uv = UV0;
5
+ POSITION = MODELVIEWPROJECTION_MATRIX * vec4(VERTEX, 1.0);
6
+ }
replicator/voice.py ADDED
@@ -0,0 +1,120 @@
1
+ """Optional voice: Replicator reads an explanation aloud, and you can dictate a dream.
2
+
3
+ Nothing here loads a model in this process or uses the GPU. Speech comes from a server you already run
4
+ (any OpenAI-compatible `/v1/audio/speech`, such as Kokoro-FastAPI), a local command (Kokoro on the CPU) or espeak-ng; dictation goes to
5
+ an OpenAI-compatible `/v1/audio/transcriptions` server or to a local command such as whisper.cpp's `whisper-cli`.
6
+ Child processes get an environment with every GPU hidden. Audio is recorded and played through PipeWire.
7
+ """
8
+ from __future__ import annotations
9
+
10
+ import json
11
+ import os
12
+ import shlex
13
+ import shutil
14
+ import subprocess
15
+ import tempfile
16
+ import urllib.request
17
+ import uuid
18
+ from pathlib import Path
19
+
20
+ CPU_ENV = {"CUDA_VISIBLE_DEVICES": "", "NODE_LLAMA_CPP_GPU": "false"}
21
+ TMP = Path(tempfile.gettempdir()) / "replicator-voice"
22
+
23
+
24
+ def _env() -> dict:
25
+ return {**os.environ, **CPU_ENV}
26
+
27
+
28
+ def status(cfg: dict) -> dict:
29
+ """What is usable right now, in words the Preferences panel can show."""
30
+ tts = ("Kokoro / OpenAI-compatible server" if cfg.get("tts_url") else
31
+ "local command" if cfg.get("tts_cmd") and _runnable(cfg["tts_cmd"]) else
32
+ "espeak-ng (CPU, robotic; set a speech server for a natural voice)" if shutil.which("espeak-ng") else "")
33
+ stt = ("transcription server" if cfg.get("stt_url") else
34
+ "local command" if cfg.get("stt_cmd") and _runnable(cfg["stt_cmd"]) else "")
35
+ return {"tts": tts, "stt": stt, "play": bool(shutil.which("pw-play") or shutil.which("paplay")),
36
+ "record": bool(shutil.which("pw-record") or shutil.which("arecord"))}
37
+
38
+
39
+ def _runnable(cmd: str) -> bool:
40
+ try:
41
+ return bool(shutil.which(os.path.expanduser(shlex.split(cmd)[0])))
42
+ except (ValueError, IndexError):
43
+ return False
44
+
45
+
46
+ def _fill(cmd: str, **values: str) -> list[str]:
47
+ """Split a command template and fill {placeholders} per argument: no shell, so text cannot inject anything."""
48
+ out = []
49
+ for arg in shlex.split(cmd):
50
+ for k, v in values.items():
51
+ arg = arg.replace("{" + k + "}", v)
52
+ out.append(os.path.expanduser(arg))
53
+ return out
54
+
55
+
56
+ def synthesize(text: str, cfg: dict) -> Path:
57
+ """Text -> a WAV file. Raises RuntimeError with the reason when no voice is available."""
58
+ TMP.mkdir(parents=True, exist_ok=True)
59
+ out = TMP / f"say-{uuid.uuid4().hex[:10]}.wav"
60
+ if cfg.get("tts_url"):
61
+ body = {"model": "kokoro", "input": text, "voice": cfg.get("tts_voice") or "af_heart",
62
+ "response_format": "wav"}
63
+ req = urllib.request.Request(cfg["tts_url"].rstrip("/") + "/v1/audio/speech", json.dumps(body).encode(),
64
+ {"Content-Type": "application/json"})
65
+ try:
66
+ with urllib.request.urlopen(req, timeout=60) as r:
67
+ out.write_bytes(r.read())
68
+ return out
69
+ except OSError as e:
70
+ raise RuntimeError(f"speech server unreachable ({e})") from None
71
+ if cfg.get("tts_cmd"):
72
+ cmd = _fill(cfg["tts_cmd"], text=text, wav=str(out), voice=cfg.get("tts_voice") or "af_heart")
73
+ r = subprocess.run(cmd, capture_output=True, text=True, env=_env(), timeout=180)
74
+ if r.returncode or not out.exists():
75
+ raise RuntimeError(f"speech command failed: {(r.stderr or r.stdout).strip()[-200:]}")
76
+ return out
77
+ if shutil.which("espeak-ng"):
78
+ subprocess.run(["espeak-ng", "-s", "165", "-w", str(out), text], check=True, env=_env(), timeout=60)
79
+ return out
80
+ raise RuntimeError("no voice: set a speech server in Preferences or install espeak-ng")
81
+
82
+
83
+ def player(wav: Path) -> subprocess.Popen:
84
+ cmd = ["pw-play", str(wav)] if shutil.which("pw-play") else ["paplay", str(wav)]
85
+ return subprocess.Popen(cmd, env=_env(), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
86
+
87
+
88
+ def recorder() -> tuple[subprocess.Popen, Path]:
89
+ """Start recording the default microphone (16 kHz mono). Stop it with .terminate()."""
90
+ TMP.mkdir(parents=True, exist_ok=True)
91
+ wav = TMP / f"mic-{uuid.uuid4().hex[:10]}.wav"
92
+ if shutil.which("pw-record"):
93
+ cmd = ["pw-record", "--rate", "16000", "--channels", "1", str(wav)]
94
+ elif shutil.which("arecord"):
95
+ cmd = ["arecord", "-q", "-f", "S16_LE", "-r", "16000", "-c", "1", str(wav)]
96
+ else:
97
+ raise RuntimeError("no recorder (pw-record or arecord)")
98
+ return subprocess.Popen(cmd, env=_env(), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL), wav
99
+
100
+
101
+ def transcribe(wav: Path, cfg: dict) -> str:
102
+ if cfg.get("stt_url"):
103
+ boundary = uuid.uuid4().hex
104
+ parts = [f'--{boundary}\r\nContent-Disposition: form-data; name="model"\r\n\r\nwhisper-1\r\n'.encode(),
105
+ f'--{boundary}\r\nContent-Disposition: form-data; name="file"; filename="mic.wav"\r\n'
106
+ f'Content-Type: audio/wav\r\n\r\n'.encode(), wav.read_bytes(), f"\r\n--{boundary}--\r\n".encode()]
107
+ req = urllib.request.Request(cfg["stt_url"].rstrip("/") + "/v1/audio/transcriptions", b"".join(parts),
108
+ {"Content-Type": f"multipart/form-data; boundary={boundary}"})
109
+ try:
110
+ with urllib.request.urlopen(req, timeout=120) as r:
111
+ return str(json.load(r).get("text", "")).strip()
112
+ except OSError as e:
113
+ raise RuntimeError(f"transcription server unreachable ({e})") from None
114
+ if cfg.get("stt_cmd"):
115
+ cmd = _fill(cfg["stt_cmd"], wav=str(wav))
116
+ r = subprocess.run(cmd, capture_output=True, text=True, env=_env(), timeout=180)
117
+ if r.returncode:
118
+ raise RuntimeError(f"transcription command failed: {r.stderr.strip()[-200:]}")
119
+ return " ".join(r.stdout.split())
120
+ raise RuntimeError("dictation is not set up: add a transcription server or command in Preferences")