cyclecad 3.10.0 → 3.10.1

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.
@@ -0,0 +1,150 @@
1
+ # AI Copilot — hands-on tutorial
2
+
3
+ Goal: design a **Raspberry Pi 4B enclosure** from scratch using only natural language, in under 2 minutes.
4
+
5
+ ## Prereqs
6
+
7
+ - cycleCAD v3.10.0 or later (`npm install cyclecad@latest`, or pull from GitHub)
8
+ - An API key for one of: Anthropic Claude, Google Gemini, or Groq
9
+ - Modern browser with `fetch` support (any recent Chrome/Safari/Firefox)
10
+
11
+ ## Step 1 — Open the copilot
12
+
13
+ Tools menu → **AI Copilot (multi-step)**. A dialog opens with a model dropdown, a prompt textarea, Generate/Stop buttons, a progress bar, and a live log.
14
+
15
+ ## Step 2 — Set your API key
16
+
17
+ Click the **🔑** icon next to the model dropdown. A browser prompt asks for your key. Paste it, click OK. The key is stored in `localStorage['cyclecad_api_keys']` — it never leaves your machine.
18
+
19
+ If you have a Claude key, the model dropdown defaults to **Claude Sonnet 4.6**. If not, it defaults to **Gemini 2.0 Flash (free)**.
20
+
21
+ ## Step 3 — First prompt
22
+
23
+ Start simple to validate everything works:
24
+
25
+ ```
26
+ box 100x50x20 with 3mm fillet
27
+ ```
28
+
29
+ Click **⚡ Generate**. You should see:
30
+
31
+ ```
32
+ ℹ Planning with Claude Sonnet 4.6...
33
+ ✓ Got 7-step plan. Executing...
34
+ ⋯ step 1: sketch.start — Start sketch
35
+ ✓ step 1 done
36
+ ⋯ step 2: sketch.rect — Rectangle
37
+ ✓ step 2 done
38
+ ⋯ step 3: sketch.end — Finish
39
+ ✓ step 3 done
40
+ ⋯ step 4: ops.extrude — Extrude
41
+ ✓ step 4 done
42
+ ⋯ step 5: ops.fillet — Fillet edges
43
+ ✓ step 5 done
44
+ ⋯ step 6: view.set — Isometric
45
+ ✓ step 6 done
46
+ ⋯ step 7: view.fit — Fit
47
+ ✓ step 7 done
48
+ ✓ Done — 7/7 succeeded
49
+ ```
50
+
51
+ The 3D viewport will show a 100×50×20 box with rounded edges, framed in isometric view.
52
+
53
+ ## Step 4 — The real deal
54
+
55
+ Clear the prompt and paste:
56
+
57
+ ```
58
+ create a Raspberry Pi 4B case. Use board specs: 85×56mm, 1.4mm thick, mounting holes at (3.5, 3.5), (61.5, 3.5), (3.5, 52.5), (61.5, 52.5) Ø2.7. Add:
59
+ - 2mm wall thickness
60
+ - 12mm internal height
61
+ - USB cutout on the right side
62
+ - HDMI cutout next to USB
63
+ - Ethernet cutout on the left
64
+ - SD card cutout on one short side
65
+ - vent slots on top
66
+ - 3mm fillet on outer edges
67
+ ```
68
+
69
+ Click **⚡ Generate**. This triggers a larger plan — typically 12-18 steps. The log fills in as each step runs. Watch the viewport: the case base appears, then shells into a hollow box, mounting posts rise, port cutouts carve out, vent slots appear, edges round over.
70
+
71
+ Typical elapsed time: 25-60 seconds (most of it is the LLM thinking; the Agent API calls themselves are instant).
72
+
73
+ ## Step 5 — Handling errors gracefully
74
+
75
+ Try this deliberately tricky prompt:
76
+
77
+ ```
78
+ extrude the current sketch 10mm
79
+ ```
80
+
81
+ There's no active sketch — the first call to `ops.extrude` will fail. Watch the log:
82
+
83
+ ```
84
+ ⋯ step 1: ops.extrude — Extrude sketch
85
+ ✗ step 1: No active sketch
86
+ ℹ Asking for recovery plan (1/2)...
87
+ ℹ Inserted 3 recovery steps
88
+ ⋯ step 2: sketch.start — Start a sketch first
89
+ ✓ step 2 done
90
+ ⋯ step 3: sketch.rect — Default rectangle
91
+ ✓ step 3 done
92
+ ⋯ step 4: sketch.end — Finish sketch
93
+ ✓ step 4 done
94
+ ⋯ step 5: ops.extrude — Now extrude
95
+ ✓ step 5 done
96
+ ```
97
+
98
+ The copilot self-corrected: it inserted the missing sketch steps and resumed.
99
+
100
+ ## Step 6 — Programmatic access
101
+
102
+ You can kick off a prompt from the browser console:
103
+
104
+ ```js
105
+ window.CycleCAD.AICopilot.execute('generate', {
106
+ prompt: 'design a 50mm mounting bracket with 4 M5 holes on 40mm PCD'
107
+ });
108
+ ```
109
+
110
+ Monitor state:
111
+
112
+ ```js
113
+ setInterval(() => {
114
+ const s = window.CycleCAD.AICopilot.getState();
115
+ console.log(`${s.running ? 'running' : 'idle'} — ${s.results} ok / ${s.errors} errs`);
116
+ }, 500);
117
+ ```
118
+
119
+ Stop mid-run:
120
+
121
+ ```js
122
+ window.CycleCAD.AICopilot.abort();
123
+ ```
124
+
125
+ ## Step 7 — Tune your prompts
126
+
127
+ | Prompt quality | Example |
128
+ |---|---|
129
+ | **Weak**: *"make a case"* | Claude guesses dimensions |
130
+ | **Better**: *"make a 100×60×25 case with 2mm wall"* | Claude knows the envelope |
131
+ | **Best**: *"make a 100×60×25 case. 2mm wall. 4 M3 mounting holes at (5,5), (95,5), (5,55), (95,55). 3mm fillet on outer edges. One USB-C cutout (9×4) on the front face centered horizontally, 10mm up from the base."* | Claude gets it right in one shot |
132
+
133
+ **Rule of thumb**: mention every dimension you care about. Claude is good at filling gaps with sensible defaults, but precise inputs produce precise parts.
134
+
135
+ ## Step 8 — What's next
136
+
137
+ - Read `docs/AI-COPILOT.md` for the full feature reference
138
+ - Check `docs/API-REFERENCE.md` for the underlying Agent API the copilot drives
139
+ - Try composing prompts: generate a base plate → save → regenerate with additional features
140
+
141
+ ## Troubleshooting
142
+
143
+ | Symptom | Fix |
144
+ |---|---|
145
+ | `Missing anthropic key — click 🔑` | Set the key for the selected provider |
146
+ | `Claude 401` | Key is invalid or expired. Regenerate at console.anthropic.com |
147
+ | `Gemini 429` | Rate-limited on free tier. Wait 60s or switch to Groq |
148
+ | Plan executes but nothing appears in viewport | Agent API may not be loaded. Check console for `window.cycleCAD.execute is not available` |
149
+ | Model returns prose instead of JSON | Rerun — sometimes models forget the format. The parser tries to be lenient but fails on pure prose. |
150
+ | Recovery loop doesn't fire | You're already at the 2-retry limit or the recovery call itself failed. Check log for `Recovery failed: ...` |
@@ -0,0 +1,99 @@
1
+ # AI Copilot — multi-step CAD generation from natural language
2
+
3
+ > *"create a Raspberry Pi 4B case with port cutouts and 3mm fillet"* → Claude writes a 14-step plan → cycleCAD executes it live in the viewport.
4
+
5
+ AI Copilot is cycleCAD's answer to Onshape's Adam AI Tools. It lets you describe a mechanical part in plain English; the LLM plans a sequence of Agent API calls; each call executes against the live 3D scene; on step failure, the LLM is asked for a recovery plan (up to 2 retries).
6
+
7
+ ## Quick start
8
+
9
+ 1. **Tools menu → AI Copilot (multi-step)** (or `Ctrl+Shift+A` if bound)
10
+ 2. Click **🔑** and paste a provider key — Anthropic Claude, Google Gemini (free tier), or Groq (free tier)
11
+ 3. Pick a model in the dropdown (Claude Sonnet 4.6 is the default when you have an Anthropic key)
12
+ 4. Type a prompt in the textarea
13
+ 5. Click **⚡ Generate** — you'll see the plan arrive, then each step execute live
14
+
15
+ ### Try these prompts
16
+
17
+ | Prompt | What Claude builds |
18
+ |---|---|
19
+ | `box 100x50x20 with 3mm fillet` | Simple box, extrude, fillet, iso view |
20
+ | `create a Raspberry Pi 4B case with port cutouts` | Case base → shell → 4 mounting posts → USB/HDMI/Ethernet cutouts → vent slots → fillet |
21
+ | `design a 50mm mounting bracket with 4 holes on 40mm PCD` | Circular sketch → extrude → pattern-hole at PCD |
22
+ | `M10 hex nut, 8mm thick, with chamfered edges` | Hex sketch → extrude → through-hole M10 → chamfer both faces |
23
+ | `L-bracket 100×60×5mm with 4 M5 mounting holes` | L-profile sketch → extrude → 4 holes |
24
+
25
+ ## Models supported
26
+
27
+ | Model | Provider | Best for | Cost |
28
+ |---|---|---|---|
29
+ | **Claude Sonnet 4.6** | Anthropic | Balanced — the default | Paid |
30
+ | Claude Haiku 4.5 | Anthropic | Fastest, cheap | Paid |
31
+ | Claude Opus 4.6 | Anthropic | Highest quality for hard designs | Paid (higher) |
32
+ | Gemini 2.0 Flash | Google | Free tier available | Free |
33
+ | Groq Llama 3.1 70B | Groq | Fast + free | Free |
34
+
35
+ Get Anthropic key at [console.anthropic.com](https://console.anthropic.com), Gemini at [aistudio.google.com/apikey](https://aistudio.google.com/apikey), Groq at [console.groq.com/keys](https://console.groq.com/keys). Keys are stored locally in `localStorage['cyclecad_api_keys']` — never sent to our servers.
36
+
37
+ ## What the copilot can do
38
+
39
+ The LLM is primed with the full Agent API surface:
40
+
41
+ | Namespace | Commands |
42
+ |---|---|
43
+ | `sketch.*` | `start`, `line`, `circle`, `rect`, `end` |
44
+ | `ops.*` | `extrude`, `revolve`, `fillet`, `chamfer`, `shell`, `hole`, `pattern` |
45
+ | `view.*` | `set` (isometric/top/front/etc.), `fit` |
46
+ | `query.*` | `features`, `bbox` |
47
+ | `validate.*` | `cost`, `mass` |
48
+
49
+ It also knows real board specifications:
50
+ - **Raspberry Pi 4B**: 85 × 56 × 1.4 mm, mounting holes at `(3.5,3.5), (61.5,3.5), (3.5,52.5), (61.5,52.5)`, Ø2.7
51
+ - **Arduino Uno**: 68.6 × 53.4 × 1.6 mm
52
+ - **Arduino Nano**: 45 × 18 mm
53
+
54
+ ## Error recovery
55
+
56
+ When a step fails (e.g., `ops.extrude` called without an active sketch), the copilot:
57
+
58
+ 1. Logs `✗ step N: <method>: <error>`
59
+ 2. Sends back to LLM: failed step + error + remaining steps + original goal
60
+ 3. LLM returns a replacement sequence that recovers and continues
61
+ 4. Logs `ℹ Inserted N recovery steps`
62
+
63
+ You get two recovery attempts per prompt. After that the run stops and you see a warning.
64
+
65
+ ## Module API
66
+
67
+ ```js
68
+ window.CycleCAD.AICopilot = {
69
+ init: () => true,
70
+ getUI: () => HTMLElement, // the sidebar panel
71
+ execute: (cmd, params) => ..., // programmatic: "generate" or "stop"
72
+ go: () => Promise<void>, // run the current prompt
73
+ abort: () => void, // stop mid-run
74
+ getState: () => ({ running, stepIndex, results, errors })
75
+ }
76
+ ```
77
+
78
+ To run a prompt programmatically:
79
+ ```js
80
+ window.CycleCAD.AICopilot.execute('generate', { prompt: 'create a 50mm cube with 3mm fillet' });
81
+ ```
82
+
83
+ ## Keyboard shortcuts (in the panel)
84
+
85
+ | Shortcut | Action |
86
+ |---|---|
87
+ | `Cmd/Ctrl + Enter` | Generate (same as ⚡ button) |
88
+ | `⏹ Stop` button | Abort mid-run |
89
+
90
+ ## Known limitations
91
+
92
+ - **LLM accuracy**: complex geometry (sweeps, lofts, assemblies) sometimes confuses the planner. Try breaking into simpler prompts and chaining results.
93
+ - **Units**: always millimeters. Saying "make a 2 inch cylinder" gets parsed as 2 mm. Convert before prompting.
94
+ - **No undo of plan**: once executed, the model is built. Undo individual steps with Ctrl+Z if the feature tree supports it; otherwise start fresh.
95
+ - **API cost**: an enclosure plan uses ~1000-2000 input tokens + ~2000-3000 output tokens. On Sonnet 4.6 that's a few cents per design; on Gemini free tier it's $0.
96
+
97
+ ## Inspired by
98
+
99
+ [Adam AI Tools for Onshape](https://www.adam.new) — their FeatureScript-generating copilot is the inspiration for this module. cycleCAD's version runs natively against the Three.js viewport and works against any of Claude / Gemini / Groq.
@@ -1421,3 +1421,20 @@ async function reviewAndExport() {
1421
1421
  ---
1422
1422
 
1423
1423
  End of API Reference
1424
+
1425
+ ## AI Copilot (v3.10.0+)
1426
+
1427
+ Multi-step CAD generation from natural language. See `docs/AI-COPILOT.md` for full docs.
1428
+
1429
+ ```js
1430
+ window.CycleCAD.AICopilot.execute('generate', {
1431
+ prompt: 'create a Raspberry Pi 4B case with port cutouts'
1432
+ });
1433
+ // Observe state
1434
+ window.CycleCAD.AICopilot.getState();
1435
+ // → { running: true, stepIndex: 3, results: 4, errors: 0 }
1436
+ // Stop mid-run
1437
+ window.CycleCAD.AICopilot.abort();
1438
+ ```
1439
+
1440
+ The copilot uses the Agent API (`window.cycleCAD.execute`) as its execution substrate, so every Agent API command above is reachable from a prompt.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cyclecad",
3
- "version": "3.10.0",
3
+ "version": "3.10.1",
4
4
  "description": "Browser-based parametric 3D CAD modeler with AI-powered tools, native Inventor file parsing, and smart assembly management. No install required.",
5
5
  "main": "index.html",
6
6
  "bin": {